Search in sources :

Example 11 with ExtractorOutput

use of androidx.media3.extractor.ExtractorOutput in project media by androidx.

the class Ac4Extractor method init.

@Override
public void init(ExtractorOutput output) {
    reader.createTracks(output, new TrackIdGenerator(/* firstTrackId= */
    0, /* trackIdIncrement= */
    1));
    output.endTracks();
    output.seekMap(new SeekMap.Unseekable(/* durationUs= */
    C.TIME_UNSET));
}
Also used : TrackIdGenerator(androidx.media3.extractor.ts.TsPayloadReader.TrackIdGenerator) SeekMap(androidx.media3.extractor.SeekMap)

Example 12 with ExtractorOutput

use of androidx.media3.extractor.ExtractorOutput in project media by androidx.

the class AdtsExtractor method init.

@Override
public void init(ExtractorOutput output) {
    this.extractorOutput = output;
    reader.createTracks(output, new TrackIdGenerator(0, 1));
    output.endTracks();
}
Also used : TrackIdGenerator(androidx.media3.extractor.ts.TsPayloadReader.TrackIdGenerator)

Example 13 with ExtractorOutput

use of androidx.media3.extractor.ExtractorOutput in project media by androidx.

the class AdtsReader method createTracks.

@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
    idGenerator.generateNewId();
    formatId = idGenerator.getFormatId();
    output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_AUDIO);
    currentOutput = output;
    if (exposeId3) {
        idGenerator.generateNewId();
        id3Output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_METADATA);
        id3Output.format(new Format.Builder().setId(idGenerator.getFormatId()).setSampleMimeType(MimeTypes.APPLICATION_ID3).build());
    } else {
        id3Output = new DummyTrackOutput();
    }
}
Also used : DummyTrackOutput(androidx.media3.extractor.DummyTrackOutput)

Example 14 with ExtractorOutput

use of androidx.media3.extractor.ExtractorOutput in project media by androidx.

the class SubtitleExtractor method init.

@Override
public void init(ExtractorOutput output) {
    checkState(state == STATE_CREATED);
    extractorOutput = output;
    trackOutput = extractorOutput.track(/* id= */
    0, C.TRACK_TYPE_TEXT);
    extractorOutput.endTracks();
    extractorOutput.seekMap(new IndexSeekMap(/* positions= */
    new long[] { 0 }, /* timesUs= */
    new long[] { 0 }, /* durationUs= */
    C.TIME_UNSET));
    trackOutput.format(format);
    state = STATE_INITIALIZED;
}
Also used : IndexSeekMap(androidx.media3.extractor.IndexSeekMap)

Example 15 with ExtractorOutput

use of androidx.media3.extractor.ExtractorOutput in project media by androidx.

the class AmrExtractorSeekTest method seeking_handlesSeekingForward_extractsCorrectFrames_forNarrowBandAmr.

@Test
public void seeking_handlesSeekingForward_extractsCorrectFrames_forNarrowBandAmr() throws IOException {
    String fileName = NARROW_BAND_AMR_FILE;
    Uri fileUri = TestUtil.buildAssetUri(fileName);
    expectedTrackOutput = TestUtil.extractAllSamplesFromFile(createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName).trackOutputs.get(0);
    AmrExtractor extractor = createAmrExtractor();
    FakeExtractorOutput extractorOutput = new FakeExtractorOutput();
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
    long firstSeekTimeUs = 980_000;
    TestUtil.seekToTimeUs(extractor, seekMap, firstSeekTimeUs, dataSource, trackOutput, fileUri);
    long targetSeekTimeUs = 1_200_000;
    int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
    assertThat(extractedFrameIndex).isNotEqualTo(-1);
    assertFirstFrameAfterSeekContainTargetSeekTime(trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
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)

Aggregations

SeekMap (androidx.media3.extractor.SeekMap)72 Test (org.junit.Test)66 Uri (android.net.Uri)59 FakeTrackOutput (androidx.media3.test.utils.FakeTrackOutput)57 FakeExtractorOutput (androidx.media3.test.utils.FakeExtractorOutput)31 Nullable (androidx.annotation.Nullable)8 TrackOutput (androidx.media3.extractor.TrackOutput)5 Format (androidx.media3.common.Format)4 Metadata (androidx.media3.common.Metadata)4 ExtractorOutput (com.google.android.exoplayer2.extractor.ExtractorOutput)4 Before (org.junit.Before)4 ExtractorInput (androidx.media3.extractor.ExtractorInput)3 MotionPhotoMetadata (androidx.media3.extractor.metadata.mp4.MotionPhotoMetadata)3 TrackIdGenerator (androidx.media3.extractor.ts.TsPayloadReader.TrackIdGenerator)3 SeekMap (com.google.android.exoplayer2.extractor.SeekMap)3 RequiresNonNull (org.checkerframework.checker.nullness.qual.RequiresNonNull)3 ParsableByteArray (androidx.media3.common.util.ParsableByteArray)2 DefaultExtractorInput (androidx.media3.extractor.DefaultExtractorInput)2 Extractor (androidx.media3.extractor.Extractor)2 ExtractorOutput (androidx.media3.extractor.ExtractorOutput)2