Fix intermittent decoder crash when playing MP3 inside MP4
This commit is contained in:
parent
3bcd9ca6c3
commit
588be2bd4b
@ -30,7 +30,6 @@ import com.google.android.exoplayer.util.Util;
|
|||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts data from an MP3 file.
|
* Extracts data from an MP3 file.
|
||||||
@ -247,7 +246,7 @@ public final class Mp3Extractor implements Extractor {
|
|||||||
extractorOutput.seekMap(seeker);
|
extractorOutput.seekMap(seeker);
|
||||||
trackOutput.format(MediaFormat.createAudioFormat(synchronizedHeader.mimeType,
|
trackOutput.format(MediaFormat.createAudioFormat(synchronizedHeader.mimeType,
|
||||||
MpegAudioHeader.MAX_FRAME_SIZE_BYTES, seeker.getDurationUs(), synchronizedHeader.channels,
|
MpegAudioHeader.MAX_FRAME_SIZE_BYTES, seeker.getDurationUs(), synchronizedHeader.channels,
|
||||||
synchronizedHeader.sampleRate, Collections.<byte[]>emptyList()));
|
synchronizedHeader.sampleRate, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
return headerPosition;
|
return headerPosition;
|
||||||
|
@ -471,8 +471,7 @@ import java.util.List;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<byte[]> initializationData = csdLength == 0 ? Collections.<byte[]>emptyList()
|
List<byte[]> initializationData = csdLength == 0 ? null : Collections.singletonList(buffer);
|
||||||
: Collections.singletonList(buffer);
|
|
||||||
return Pair.create(initializationData, lengthSizeMinusOne + 1);
|
return Pair.create(initializationData, lengthSizeMinusOne + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,6 +627,10 @@ import java.util.List;
|
|||||||
int objectTypeIndication = parent.readUnsignedByte();
|
int objectTypeIndication = parent.readUnsignedByte();
|
||||||
String mimeType;
|
String mimeType;
|
||||||
switch (objectTypeIndication) {
|
switch (objectTypeIndication) {
|
||||||
|
case 0x6B:
|
||||||
|
mimeType = MimeTypes.AUDIO_MPEG;
|
||||||
|
// Don't extract codec-specific data for MPEG audio tracks, as it is not needed.
|
||||||
|
return Pair.create(mimeType, null);
|
||||||
case 0x20:
|
case 0x20:
|
||||||
mimeType = MimeTypes.VIDEO_MP4V;
|
mimeType = MimeTypes.VIDEO_MP4V;
|
||||||
break;
|
break;
|
||||||
@ -640,9 +643,6 @@ import java.util.List;
|
|||||||
case 0x40:
|
case 0x40:
|
||||||
mimeType = MimeTypes.AUDIO_AAC;
|
mimeType = MimeTypes.AUDIO_AAC;
|
||||||
break;
|
break;
|
||||||
case 0x6B:
|
|
||||||
mimeType = MimeTypes.AUDIO_MPEG;
|
|
||||||
break;
|
|
||||||
case 0xA5:
|
case 0xA5:
|
||||||
mimeType = MimeTypes.AUDIO_AC3;
|
mimeType = MimeTypes.AUDIO_AC3;
|
||||||
break;
|
break;
|
||||||
|
@ -21,8 +21,6 @@ import com.google.android.exoplayer.extractor.TrackOutput;
|
|||||||
import com.google.android.exoplayer.util.MpegAudioHeader;
|
import com.google.android.exoplayer.util.MpegAudioHeader;
|
||||||
import com.google.android.exoplayer.util.ParsableByteArray;
|
import com.google.android.exoplayer.util.ParsableByteArray;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a continuous MPEG Audio byte stream and extracts individual frames.
|
* Parses a continuous MPEG Audio byte stream and extracts individual frames.
|
||||||
*/
|
*/
|
||||||
@ -164,7 +162,7 @@ import java.util.Collections;
|
|||||||
frameDurationUs = (C.MICROS_PER_SECOND * header.samplesPerFrame) / header.sampleRate;
|
frameDurationUs = (C.MICROS_PER_SECOND * header.samplesPerFrame) / header.sampleRate;
|
||||||
MediaFormat mediaFormat = MediaFormat.createAudioFormat(header.mimeType,
|
MediaFormat mediaFormat = MediaFormat.createAudioFormat(header.mimeType,
|
||||||
MpegAudioHeader.MAX_FRAME_SIZE_BYTES, C.UNKNOWN_TIME_US, header.channels,
|
MpegAudioHeader.MAX_FRAME_SIZE_BYTES, C.UNKNOWN_TIME_US, header.channels,
|
||||||
header.sampleRate, Collections.<byte[]>emptyList());
|
header.sampleRate, null);
|
||||||
output.format(mediaFormat);
|
output.format(mediaFormat);
|
||||||
hasOutputFormat = true;
|
hasOutputFormat = true;
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,6 @@ package com.google.android.exoplayer.util;
|
|||||||
|
|
||||||
import com.google.android.exoplayer.MediaFormat;
|
import com.google.android.exoplayer.MediaFormat;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility methods for parsing AC-3 headers.
|
* Utility methods for parsing AC-3 headers.
|
||||||
*/
|
*/
|
||||||
@ -51,7 +49,7 @@ public final class Ac3Util {
|
|||||||
channelCount++;
|
channelCount++;
|
||||||
}
|
}
|
||||||
return MediaFormat.createAudioFormat(MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE,
|
return MediaFormat.createAudioFormat(MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE,
|
||||||
channelCount, sampleRate, Collections.<byte[]>emptyList());
|
channelCount, sampleRate, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,7 +72,7 @@ public final class Ac3Util {
|
|||||||
channelCount++;
|
channelCount++;
|
||||||
}
|
}
|
||||||
return MediaFormat.createAudioFormat(MimeTypes.AUDIO_EC3, MediaFormat.NO_VALUE,
|
return MediaFormat.createAudioFormat(MimeTypes.AUDIO_EC3, MediaFormat.NO_VALUE,
|
||||||
channelCount, sampleRate, Collections.<byte[]>emptyList());
|
channelCount, sampleRate, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,8 +100,7 @@ public final class Ac3Util {
|
|||||||
}
|
}
|
||||||
boolean lfeon = data.readBit();
|
boolean lfeon = data.readBit();
|
||||||
return MediaFormat.createAudioFormat(MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE,
|
return MediaFormat.createAudioFormat(MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE,
|
||||||
CHANNEL_COUNTS[acmod] + (lfeon ? 1 : 0), SAMPLE_RATES[fscod],
|
CHANNEL_COUNTS[acmod] + (lfeon ? 1 : 0), SAMPLE_RATES[fscod], null);
|
||||||
Collections.<byte[]>emptyList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user