use of com.google.android.exoplayer2.extractor.Extractor in project ExoPlayer by google.
the class DefaultHlsExtractorFactoryTest method createExtractor_onFailedSniff_fallsBackOnFormatInferred.
@Test
public void createExtractor_onFailedSniff_fallsBackOnFormatInferred() throws Exception {
ExtractorInput emptyExtractorInput = new FakeExtractorInput.Builder().build();
BundledHlsMediaChunkExtractor result = new DefaultHlsExtractorFactory().createExtractor(URI_WITH_MP4_EXTENSION, webVttFormat, /* muxedCaptionFormats= */
null, timestampAdjuster, ac3ResponseHeaders, emptyExtractorInput, PlayerId.UNSET);
// The format indicates WebVTT so we expect a WebVTT extractor.
assertThat(result.extractor.getClass()).isEqualTo(WebvttExtractor.class);
}
use of com.google.android.exoplayer2.extractor.Extractor in project ExoPlayer by google.
the class DefaultHlsExtractorFactoryTest method createExtractor_onFailedSniff_fallsBackOnHttpContentType.
@Test
public void createExtractor_onFailedSniff_fallsBackOnHttpContentType() throws Exception {
ExtractorInput emptyExtractorInput = new FakeExtractorInput.Builder().build();
BundledHlsMediaChunkExtractor result = new DefaultHlsExtractorFactory().createExtractor(URI_WITH_MP4_EXTENSION, new Format.Builder().build(), /* muxedCaptionFormats= */
null, timestampAdjuster, ac3ResponseHeaders, emptyExtractorInput, PlayerId.UNSET);
// No format info, so we expect an AC-3 Extractor, as per HTTP Content-Type header.
assertThat(result.extractor.getClass()).isEqualTo(Ac3Extractor.class);
}
use of com.google.android.exoplayer2.extractor.Extractor in project ExoPlayer by google.
the class DefaultHlsExtractorFactoryTest method createExtractor_onFailedSniff_fallsBackOnFileExtension.
@Test
public void createExtractor_onFailedSniff_fallsBackOnFileExtension() throws Exception {
ExtractorInput emptyExtractorInput = new FakeExtractorInput.Builder().build();
BundledHlsMediaChunkExtractor result = new DefaultHlsExtractorFactory().createExtractor(URI_WITH_MP4_EXTENSION, new Format.Builder().build(), /* muxedCaptionFormats= */
null, timestampAdjuster, /* responseHeaders= */
ImmutableMap.of(), emptyExtractorInput, PlayerId.UNSET);
// No format info, and no HTTP headers, so we expect an fMP4 extractor, as per file extension.
assertThat(result.extractor.getClass()).isEqualTo(FragmentedMp4Extractor.class);
}
use of com.google.android.exoplayer2.extractor.Extractor in project ExoPlayer by google.
the class DashUtil method newChunkExtractor.
private static ChunkExtractor newChunkExtractor(int trackType, Format format) {
String mimeType = format.containerMimeType;
boolean isWebm = mimeType != null && (mimeType.startsWith(MimeTypes.VIDEO_WEBM) || mimeType.startsWith(MimeTypes.AUDIO_WEBM));
Extractor extractor = isWebm ? new MatroskaExtractor() : new FragmentedMp4Extractor();
return new BundledChunkExtractor(extractor, trackType, format);
}
use of com.google.android.exoplayer2.extractor.Extractor in project ExoPlayer by google.
the class AtomParsers method parseEdts.
/**
* Parses the edts atom (defined in ISO/IEC 14496-12 subsection 8.6.5).
*
* @param edtsAtom edts (edit box) atom to decode.
* @return Pair of edit list durations and edit list media times, or {@code null} if they are not
* present.
*/
@Nullable
private static Pair<long[], long[]> parseEdts(Atom.ContainerAtom edtsAtom) {
@Nullable Atom.LeafAtom elstAtom = edtsAtom.getLeafAtomOfType(Atom.TYPE_elst);
if (elstAtom == null) {
return null;
}
ParsableByteArray elstData = elstAtom.data;
elstData.setPosition(Atom.HEADER_SIZE);
int fullAtom = elstData.readInt();
int version = Atom.parseFullAtomVersion(fullAtom);
int entryCount = elstData.readUnsignedIntToInt();
long[] editListDurations = new long[entryCount];
long[] editListMediaTimes = new long[entryCount];
for (int i = 0; i < entryCount; i++) {
editListDurations[i] = version == 1 ? elstData.readUnsignedLongToLong() : elstData.readUnsignedInt();
editListMediaTimes[i] = version == 1 ? elstData.readLong() : elstData.readInt();
int mediaRateInteger = elstData.readShort();
if (mediaRateInteger != 1) {
// The extractor does not handle dwell edits (mediaRateInteger == 0).
throw new IllegalArgumentException("Unsupported media rate.");
}
elstData.skipBytes(2);
}
return Pair.create(editListDurations, editListMediaTimes);
}
Aggregations