Search in sources :

Example 1 with OggExtractor

use of androidx.media3.extractor.ogg.OggExtractor 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 2 with OggExtractor

use of androidx.media3.extractor.ogg.OggExtractor in project media by androidx.

the class OggExtractorNonParameterizedTest method read_afterEndOfInput_doesNotThrowIllegalState.

@Test
public void read_afterEndOfInput_doesNotThrowIllegalState() throws Exception {
    byte[] data = getByteArray(ApplicationProvider.getApplicationContext(), "media/ogg/bear_flac.ogg");
    FakeExtractorInput input = new FakeExtractorInput.Builder().setData(data).build();
    OggExtractor oggExtractor = new OggExtractor();
    oggExtractor.init(new FakeExtractorOutput());
    // We feed data to the extractor until the end of input is reached.
    while (oggExtractor.read(input, new PositionHolder()) != C.RESULT_END_OF_INPUT) {
    }
    // We call read again to check that it does not throw an IllegalStateException.
    assertThat(oggExtractor.read(input, new PositionHolder())).isEqualTo(C.RESULT_END_OF_INPUT);
}
Also used : FakeExtractorInput(androidx.media3.test.utils.FakeExtractorInput) PositionHolder(androidx.media3.extractor.PositionHolder) FakeExtractorOutput(androidx.media3.test.utils.FakeExtractorOutput) Test(org.junit.Test)

Example 3 with OggExtractor

use of androidx.media3.extractor.ogg.OggExtractor in project media by androidx.

the class OggExtractorNonParameterizedTest method assertSniff.

private void assertSniff(byte[] data, boolean expectedResult) throws IOException {
    FakeExtractorInput input = new FakeExtractorInput.Builder().setData(data).setSimulateIOErrors(true).setSimulateUnknownLength(true).setSimulatePartialReads(true).build();
    ExtractorAsserts.assertSniff(new OggExtractor(), input, expectedResult);
}
Also used : FakeExtractorInput(androidx.media3.test.utils.FakeExtractorInput)

Example 4 with OggExtractor

use of androidx.media3.extractor.ogg.OggExtractor in project hms-wiseplay-demo-exoplayer by HMS-Core.

the class DefaultExtractorsFactory method createExtractors.

@Override
public synchronized Extractor[] createExtractors() {
    Extractor[] extractors = new Extractor[14];
    extractors[0] = new MatroskaExtractor(matroskaFlags);
    extractors[1] = new FragmentedMp4Extractor(fragmentedMp4Flags);
    extractors[2] = new Mp4Extractor(mp4Flags);
    extractors[3] = new Mp3Extractor(mp3Flags | (constantBitrateSeekingEnabled ? Mp3Extractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0));
    extractors[4] = new AdtsExtractor(adtsFlags | (constantBitrateSeekingEnabled ? AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0));
    extractors[5] = new Ac3Extractor();
    extractors[6] = new TsExtractor(tsMode, tsFlags);
    extractors[7] = new FlvExtractor();
    extractors[8] = new OggExtractor();
    extractors[9] = new PsExtractor();
    extractors[10] = new WavExtractor();
    extractors[11] = new AmrExtractor(amrFlags | (constantBitrateSeekingEnabled ? AmrExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0));
    extractors[12] = new Ac4Extractor();
    if (FLAC_EXTENSION_EXTRACTOR_CONSTRUCTOR != null) {
        try {
            extractors[13] = FLAC_EXTENSION_EXTRACTOR_CONSTRUCTOR.newInstance();
        } catch (Exception e) {
            // Should never happen.
            throw new IllegalStateException("Unexpected error creating FLAC extractor", e);
        }
    } else {
        extractors[13] = new FlacExtractor();
    }
    return extractors;
}
Also used : FragmentedMp4Extractor(com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor) AdtsExtractor(com.google.android.exoplayer2.extractor.ts.AdtsExtractor) Ac4Extractor(com.google.android.exoplayer2.extractor.ts.Ac4Extractor) 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) Mp4Extractor(com.google.android.exoplayer2.extractor.mp4.Mp4Extractor) Ac3Extractor(com.google.android.exoplayer2.extractor.ts.Ac3Extractor) Mp3Extractor(com.google.android.exoplayer2.extractor.mp3.Mp3Extractor) Ac4Extractor(com.google.android.exoplayer2.extractor.ts.Ac4Extractor) WavExtractor(com.google.android.exoplayer2.extractor.wav.WavExtractor) AmrExtractor(com.google.android.exoplayer2.extractor.amr.AmrExtractor) MatroskaExtractor(com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor) AdtsExtractor(com.google.android.exoplayer2.extractor.ts.AdtsExtractor) FlacExtractor(com.google.android.exoplayer2.extractor.flac.FlacExtractor) FlvExtractor(com.google.android.exoplayer2.extractor.flv.FlvExtractor) Ac3Extractor(com.google.android.exoplayer2.extractor.ts.Ac3Extractor)

Example 5 with OggExtractor

use of androidx.media3.extractor.ogg.OggExtractor 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)

Aggregations

AmrExtractor (com.google.android.exoplayer2.extractor.amr.AmrExtractor)3 FlacExtractor (com.google.android.exoplayer2.extractor.flac.FlacExtractor)3 FlvExtractor (com.google.android.exoplayer2.extractor.flv.FlvExtractor)3 MatroskaExtractor (com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor)3 Mp3Extractor (com.google.android.exoplayer2.extractor.mp3.Mp3Extractor)3 FragmentedMp4Extractor (com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor)3 Mp4Extractor (com.google.android.exoplayer2.extractor.mp4.Mp4Extractor)3 OggExtractor (com.google.android.exoplayer2.extractor.ogg.OggExtractor)3 Ac3Extractor (com.google.android.exoplayer2.extractor.ts.Ac3Extractor)3 Ac4Extractor (com.google.android.exoplayer2.extractor.ts.Ac4Extractor)3 AdtsExtractor (com.google.android.exoplayer2.extractor.ts.AdtsExtractor)3 PsExtractor (com.google.android.exoplayer2.extractor.ts.PsExtractor)3 TsExtractor (com.google.android.exoplayer2.extractor.ts.TsExtractor)3 WavExtractor (com.google.android.exoplayer2.extractor.wav.WavExtractor)3 Nullable (androidx.annotation.Nullable)2 FakeExtractorInput (androidx.media3.test.utils.FakeExtractorInput)2 PositionHolder (androidx.media3.extractor.PositionHolder)1 AmrExtractor (androidx.media3.extractor.amr.AmrExtractor)1 FlacExtractor (androidx.media3.extractor.flac.FlacExtractor)1 FlvExtractor (androidx.media3.extractor.flv.FlvExtractor)1