Search in sources :

Example 1 with AdtsExtractor

use of androidx.media3.extractor.ts.AdtsExtractor in project ExoPlayer by google.

the class HlsMediaChunk method buildPackedAudioExtractor.

private Extractor buildPackedAudioExtractor(long startTimeUs) {
    Extractor extractor;
    if (lastPathSegment.endsWith(AAC_FILE_EXTENSION)) {
        extractor = new AdtsExtractor(startTimeUs);
    } else if (lastPathSegment.endsWith(AC3_FILE_EXTENSION) || lastPathSegment.endsWith(EC3_FILE_EXTENSION)) {
        extractor = new Ac3Extractor(startTimeUs);
    } else if (lastPathSegment.endsWith(MP3_FILE_EXTENSION)) {
        extractor = new Mp3Extractor(0, startTimeUs);
    } else {
        throw new IllegalArgumentException("Unkown extension for audio file: " + lastPathSegment);
    }
    extractor.init(extractorOutput);
    return extractor;
}
Also used : AdtsExtractor(com.google.android.exoplayer2.extractor.ts.AdtsExtractor) Mp3Extractor(com.google.android.exoplayer2.extractor.mp3.Mp3Extractor) FragmentedMp4Extractor(com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor) Extractor(com.google.android.exoplayer2.extractor.Extractor) TsExtractor(com.google.android.exoplayer2.extractor.ts.TsExtractor) Mp3Extractor(com.google.android.exoplayer2.extractor.mp3.Mp3Extractor) AdtsExtractor(com.google.android.exoplayer2.extractor.ts.AdtsExtractor) Ac3Extractor(com.google.android.exoplayer2.extractor.ts.Ac3Extractor) Ac3Extractor(com.google.android.exoplayer2.extractor.ts.Ac3Extractor)

Example 2 with AdtsExtractor

use of androidx.media3.extractor.ts.AdtsExtractor in project media by androidx.

the class DefaultExtractorsFactory method addExtractorsForFileType.

private void addExtractorsForFileType(@FileTypes.Type int fileType, List<Extractor> extractors) {
    switch(fileType) {
        case FileTypes.AC3:
            extractors.add(new Ac3Extractor());
            break;
        case FileTypes.AC4:
            extractors.add(new Ac4Extractor());
            break;
        case FileTypes.ADTS:
            extractors.add(new AdtsExtractor(adtsFlags | (constantBitrateSeekingEnabled ? AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0) | (constantBitrateSeekingAlwaysEnabled ? AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING_ALWAYS : 0)));
            break;
        case FileTypes.AMR:
            extractors.add(new AmrExtractor(amrFlags | (constantBitrateSeekingEnabled ? AmrExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0) | (constantBitrateSeekingAlwaysEnabled ? AmrExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING_ALWAYS : 0)));
            break;
        case FileTypes.FLAC:
            @Nullable Extractor flacExtractor = FLAC_EXTENSION_LOADER.getExtractor(flacFlags);
            if (flacExtractor != null) {
                extractors.add(flacExtractor);
            } else {
                extractors.add(new FlacExtractor(flacFlags));
            }
            break;
        case FileTypes.FLV:
            extractors.add(new FlvExtractor());
            break;
        case FileTypes.MATROSKA:
            extractors.add(new MatroskaExtractor(matroskaFlags));
            break;
        case FileTypes.MP3:
            extractors.add(new Mp3Extractor(mp3Flags | (constantBitrateSeekingEnabled ? Mp3Extractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0) | (constantBitrateSeekingAlwaysEnabled ? Mp3Extractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING_ALWAYS : 0)));
            break;
        case FileTypes.MP4:
            extractors.add(new FragmentedMp4Extractor(fragmentedMp4Flags));
            extractors.add(new Mp4Extractor(mp4Flags));
            break;
        case FileTypes.OGG:
            extractors.add(new OggExtractor());
            break;
        case FileTypes.PS:
            extractors.add(new PsExtractor());
            break;
        case FileTypes.TS:
            extractors.add(new TsExtractor(tsMode, tsFlags, tsTimestampSearchBytes));
            break;
        case FileTypes.WAV:
            extractors.add(new WavExtractor());
            break;
        case FileTypes.JPEG:
            extractors.add(new JpegExtractor());
            break;
        case FileTypes.WEBVTT:
        case FileTypes.UNKNOWN:
        default:
            break;
    }
}
Also used : FragmentedMp4Extractor(androidx.media3.extractor.mp4.FragmentedMp4Extractor) JpegExtractor(androidx.media3.extractor.jpeg.JpegExtractor) Ac4Extractor(androidx.media3.extractor.ts.Ac4Extractor) AdtsExtractor(androidx.media3.extractor.ts.AdtsExtractor) Mp3Extractor(androidx.media3.extractor.mp3.Mp3Extractor) MatroskaExtractor(androidx.media3.extractor.mkv.MatroskaExtractor) TsExtractor(androidx.media3.extractor.ts.TsExtractor) FlacExtractor(androidx.media3.extractor.flac.FlacExtractor) AmrExtractor(androidx.media3.extractor.amr.AmrExtractor) Mp4Extractor(androidx.media3.extractor.mp4.Mp4Extractor) FragmentedMp4Extractor(androidx.media3.extractor.mp4.FragmentedMp4Extractor) PsExtractor(androidx.media3.extractor.ts.PsExtractor) OggExtractor(androidx.media3.extractor.ogg.OggExtractor) WavExtractor(androidx.media3.extractor.wav.WavExtractor) WavExtractor(androidx.media3.extractor.wav.WavExtractor) Ac4Extractor(androidx.media3.extractor.ts.Ac4Extractor) TsExtractor(androidx.media3.extractor.ts.TsExtractor) AmrExtractor(androidx.media3.extractor.amr.AmrExtractor) FlacExtractor(androidx.media3.extractor.flac.FlacExtractor) AdtsExtractor(androidx.media3.extractor.ts.AdtsExtractor) PsExtractor(androidx.media3.extractor.ts.PsExtractor) Mp3Extractor(androidx.media3.extractor.mp3.Mp3Extractor) OggExtractor(androidx.media3.extractor.ogg.OggExtractor) JpegExtractor(androidx.media3.extractor.jpeg.JpegExtractor) Ac3Extractor(androidx.media3.extractor.ts.Ac3Extractor) FlvExtractor(androidx.media3.extractor.flv.FlvExtractor) Mp4Extractor(androidx.media3.extractor.mp4.Mp4Extractor) MatroskaExtractor(androidx.media3.extractor.mkv.MatroskaExtractor) FragmentedMp4Extractor(androidx.media3.extractor.mp4.FragmentedMp4Extractor) FlvExtractor(androidx.media3.extractor.flv.FlvExtractor) Ac3Extractor(androidx.media3.extractor.ts.Ac3Extractor) Nullable(androidx.annotation.Nullable)

Example 3 with AdtsExtractor

use of androidx.media3.extractor.ts.AdtsExtractor in project media by androidx.

the class AdtsExtractorSeekTest method seeking_handlesRandomSeeks_extractsCorrectSamples.

@Test
public void seeking_handlesRandomSeeks_extractsCorrectSamples() throws IOException {
    String fileName = TEST_FILE;
    Uri fileUri = TestUtil.buildAssetUri(fileName);
    expectedTrackOutput = TestUtil.extractAllSamplesFromFile(createAdtsExtractor(), ApplicationProvider.getApplicationContext(), fileName).trackOutputs.get(0);
    AdtsExtractor extractor = createAdtsExtractor();
    FakeExtractorOutput extractorOutput = new FakeExtractorOutput();
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
    long numSeek = 100;
    for (long i = 0; i < numSeek; i++) {
        long targetSeekTimeUs = random.nextInt(FILE_DURATION_US + 1);
        int extractedSampleIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
        assertThat(extractedSampleIndex).isNotEqualTo(-1);
        assertFirstSampleAfterSeekContainTargetSeekTime(trackOutput, targetSeekTimeUs, extractedSampleIndex);
    }
}
Also used : FakeTrackOutput(androidx.media3.test.utils.FakeTrackOutput) SeekMap(androidx.media3.extractor.SeekMap) Uri(android.net.Uri) FakeExtractorOutput(androidx.media3.test.utils.FakeExtractorOutput) Test(org.junit.Test)

Example 4 with AdtsExtractor

use of androidx.media3.extractor.ts.AdtsExtractor in project ExoPlayer by google.

the class DefaultExtractorsFactory method addExtractorsForFileType.

private void addExtractorsForFileType(@FileTypes.Type int fileType, List<Extractor> extractors) {
    switch(fileType) {
        case FileTypes.AC3:
            extractors.add(new Ac3Extractor());
            break;
        case FileTypes.AC4:
            extractors.add(new Ac4Extractor());
            break;
        case FileTypes.ADTS:
            extractors.add(new AdtsExtractor(adtsFlags | (constantBitrateSeekingEnabled ? AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0) | (constantBitrateSeekingAlwaysEnabled ? AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING_ALWAYS : 0)));
            break;
        case FileTypes.AMR:
            extractors.add(new AmrExtractor(amrFlags | (constantBitrateSeekingEnabled ? AmrExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0) | (constantBitrateSeekingAlwaysEnabled ? AmrExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING_ALWAYS : 0)));
            break;
        case FileTypes.FLAC:
            @Nullable Extractor flacExtractor = FLAC_EXTENSION_LOADER.getExtractor(flacFlags);
            if (flacExtractor != null) {
                extractors.add(flacExtractor);
            } else {
                extractors.add(new FlacExtractor(flacFlags));
            }
            break;
        case FileTypes.FLV:
            extractors.add(new FlvExtractor());
            break;
        case FileTypes.MATROSKA:
            extractors.add(new MatroskaExtractor(matroskaFlags));
            break;
        case FileTypes.MP3:
            extractors.add(new Mp3Extractor(mp3Flags | (constantBitrateSeekingEnabled ? Mp3Extractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0) | (constantBitrateSeekingAlwaysEnabled ? Mp3Extractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING_ALWAYS : 0)));
            break;
        case FileTypes.MP4:
            extractors.add(new FragmentedMp4Extractor(fragmentedMp4Flags));
            extractors.add(new Mp4Extractor(mp4Flags));
            break;
        case FileTypes.OGG:
            extractors.add(new OggExtractor());
            break;
        case FileTypes.PS:
            extractors.add(new PsExtractor());
            break;
        case FileTypes.TS:
            extractors.add(new TsExtractor(tsMode, tsFlags, tsTimestampSearchBytes));
            break;
        case FileTypes.WAV:
            extractors.add(new WavExtractor());
            break;
        case FileTypes.JPEG:
            extractors.add(new JpegExtractor());
            break;
        case FileTypes.WEBVTT:
        case FileTypes.UNKNOWN:
        default:
            break;
    }
}
Also used : FragmentedMp4Extractor(com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor) JpegExtractor(com.google.android.exoplayer2.extractor.jpeg.JpegExtractor) Ac4Extractor(com.google.android.exoplayer2.extractor.ts.Ac4Extractor) AdtsExtractor(com.google.android.exoplayer2.extractor.ts.AdtsExtractor) Mp3Extractor(com.google.android.exoplayer2.extractor.mp3.Mp3Extractor) MatroskaExtractor(com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor) TsExtractor(com.google.android.exoplayer2.extractor.ts.TsExtractor) FlacExtractor(com.google.android.exoplayer2.extractor.flac.FlacExtractor) AmrExtractor(com.google.android.exoplayer2.extractor.amr.AmrExtractor) FragmentedMp4Extractor(com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor) Mp4Extractor(com.google.android.exoplayer2.extractor.mp4.Mp4Extractor) PsExtractor(com.google.android.exoplayer2.extractor.ts.PsExtractor) OggExtractor(com.google.android.exoplayer2.extractor.ogg.OggExtractor) WavExtractor(com.google.android.exoplayer2.extractor.wav.WavExtractor) FragmentedMp4Extractor(com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor) PsExtractor(com.google.android.exoplayer2.extractor.ts.PsExtractor) FlvExtractor(com.google.android.exoplayer2.extractor.flv.FlvExtractor) OggExtractor(com.google.android.exoplayer2.extractor.ogg.OggExtractor) TsExtractor(com.google.android.exoplayer2.extractor.ts.TsExtractor) JpegExtractor(com.google.android.exoplayer2.extractor.jpeg.JpegExtractor) Mp4Extractor(com.google.android.exoplayer2.extractor.mp4.Mp4Extractor) Mp3Extractor(com.google.android.exoplayer2.extractor.mp3.Mp3Extractor) Ac4Extractor(com.google.android.exoplayer2.extractor.ts.Ac4Extractor) WavExtractor(com.google.android.exoplayer2.extractor.wav.WavExtractor) AdtsExtractor(com.google.android.exoplayer2.extractor.ts.AdtsExtractor) Ac3Extractor(com.google.android.exoplayer2.extractor.ts.Ac3Extractor) AmrExtractor(com.google.android.exoplayer2.extractor.amr.AmrExtractor) MatroskaExtractor(com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor) FlacExtractor(com.google.android.exoplayer2.extractor.flac.FlacExtractor) FlvExtractor(com.google.android.exoplayer2.extractor.flv.FlvExtractor) Ac3Extractor(com.google.android.exoplayer2.extractor.ts.Ac3Extractor) Nullable(androidx.annotation.Nullable)

Example 5 with AdtsExtractor

use of androidx.media3.extractor.ts.AdtsExtractor in project ExoPlayer by google.

the class BundledHlsMediaChunkExtractor method recreate.

@Override
public HlsMediaChunkExtractor recreate() {
    Assertions.checkState(!isReusable());
    Extractor newExtractorInstance;
    if (extractor instanceof WebvttExtractor) {
        newExtractorInstance = new WebvttExtractor(multivariantPlaylistFormat.language, timestampAdjuster);
    } else if (extractor instanceof AdtsExtractor) {
        newExtractorInstance = new AdtsExtractor();
    } else if (extractor instanceof Ac3Extractor) {
        newExtractorInstance = new Ac3Extractor();
    } else if (extractor instanceof Ac4Extractor) {
        newExtractorInstance = new Ac4Extractor();
    } else if (extractor instanceof Mp3Extractor) {
        newExtractorInstance = new Mp3Extractor();
    } else {
        throw new IllegalStateException("Unexpected extractor type for recreation: " + extractor.getClass().getSimpleName());
    }
    return new BundledHlsMediaChunkExtractor(newExtractorInstance, multivariantPlaylistFormat, timestampAdjuster);
}
Also used : AdtsExtractor(com.google.android.exoplayer2.extractor.ts.AdtsExtractor) Ac4Extractor(com.google.android.exoplayer2.extractor.ts.Ac4Extractor) Mp3Extractor(com.google.android.exoplayer2.extractor.mp3.Mp3Extractor) FragmentedMp4Extractor(com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor) Extractor(com.google.android.exoplayer2.extractor.Extractor) TsExtractor(com.google.android.exoplayer2.extractor.ts.TsExtractor) Ac3Extractor(com.google.android.exoplayer2.extractor.ts.Ac3Extractor) Mp3Extractor(com.google.android.exoplayer2.extractor.mp3.Mp3Extractor) Ac4Extractor(com.google.android.exoplayer2.extractor.ts.Ac4Extractor) AdtsExtractor(com.google.android.exoplayer2.extractor.ts.AdtsExtractor) Ac3Extractor(com.google.android.exoplayer2.extractor.ts.Ac3Extractor)

Aggregations

Uri (android.net.Uri)6 SeekMap (androidx.media3.extractor.SeekMap)6 FakeExtractorOutput (androidx.media3.test.utils.FakeExtractorOutput)6 Test (org.junit.Test)6 FakeTrackOutput (androidx.media3.test.utils.FakeTrackOutput)5 Mp3Extractor (com.google.android.exoplayer2.extractor.mp3.Mp3Extractor)5 FragmentedMp4Extractor (com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor)5 Ac3Extractor (com.google.android.exoplayer2.extractor.ts.Ac3Extractor)5 AdtsExtractor (com.google.android.exoplayer2.extractor.ts.AdtsExtractor)5 TsExtractor (com.google.android.exoplayer2.extractor.ts.TsExtractor)5 Ac4Extractor (com.google.android.exoplayer2.extractor.ts.Ac4Extractor)4 Extractor (com.google.android.exoplayer2.extractor.Extractor)3 Nullable (androidx.annotation.Nullable)2 Mp3Extractor (androidx.media3.extractor.mp3.Mp3Extractor)2 FragmentedMp4Extractor (androidx.media3.extractor.mp4.FragmentedMp4Extractor)2 Ac3Extractor (androidx.media3.extractor.ts.Ac3Extractor)2 Ac4Extractor (androidx.media3.extractor.ts.Ac4Extractor)2 AdtsExtractor (androidx.media3.extractor.ts.AdtsExtractor)2 TsExtractor (androidx.media3.extractor.ts.TsExtractor)2 AmrExtractor (com.google.android.exoplayer2.extractor.amr.AmrExtractor)2