Search in sources :

Example 46 with ExtractorOutput

use of com.google.android.exoplayer2.extractor.ExtractorOutput in project ExoPlayer by google.

the class RtpAc3ReaderTest method setUp.

@Before
public void setUp() {
    packetData = new ParsableByteArray();
    trackOutput = new FakeTrackOutput(/* deduplicateConsecutiveFormats= */
    true);
    when(extractorOutput.track(anyInt(), anyInt())).thenReturn(trackOutput);
    ac3Reader = new RtpAc3Reader(AC3_FORMAT);
    ac3Reader.createTracks(extractorOutput, /* trackId= */
    0);
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray) FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput) Before(org.junit.Before)

Example 47 with ExtractorOutput

use of com.google.android.exoplayer2.extractor.ExtractorOutput in project ExoPlayer by google.

the class DvbSubtitleReader method createTracks.

@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
    for (int i = 0; i < outputs.length; i++) {
        DvbSubtitleInfo subtitleInfo = subtitleInfos.get(i);
        idGenerator.generateNewId();
        TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
        output.format(new Format.Builder().setId(idGenerator.getFormatId()).setSampleMimeType(MimeTypes.APPLICATION_DVBSUBS).setInitializationData(Collections.singletonList(subtitleInfo.initializationData)).setLanguage(subtitleInfo.language).build());
        outputs[i] = output;
    }
}
Also used : DvbSubtitleInfo(com.google.android.exoplayer2.extractor.ts.TsPayloadReader.DvbSubtitleInfo) TrackOutput(com.google.android.exoplayer2.extractor.TrackOutput)

Example 48 with ExtractorOutput

use of com.google.android.exoplayer2.extractor.ExtractorOutput in project ExoPlayer by google.

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(com.google.android.exoplayer2.extractor.ts.TsPayloadReader.TrackIdGenerator) SeekMap(com.google.android.exoplayer2.extractor.SeekMap)

Example 49 with ExtractorOutput

use of com.google.android.exoplayer2.extractor.ExtractorOutput in project ExoPlayer by google.

the class StreamReader method readPayload.

@RequiresNonNull({ "trackOutput", "oggSeeker", "extractorOutput" })
private int readPayload(ExtractorInput input, PositionHolder seekPosition) throws IOException {
    long position = oggSeeker.read(input);
    if (position >= 0) {
        seekPosition.position = position;
        return Extractor.RESULT_SEEK;
    } else if (position < -1) {
        onSeekEnd(-(position + 2));
    }
    if (!seekMapSet) {
        SeekMap seekMap = checkStateNotNull(oggSeeker.createSeekMap());
        extractorOutput.seekMap(seekMap);
        seekMapSet = true;
    }
    if (lengthOfReadPacket > 0 || oggPacket.populate(input)) {
        lengthOfReadPacket = 0;
        ParsableByteArray payload = oggPacket.getPayload();
        long granulesInPacket = preparePayload(payload);
        if (granulesInPacket >= 0 && currentGranule + granulesInPacket >= targetGranule) {
            // calculate time and send payload data to codec
            long timeUs = convertGranuleToTime(currentGranule);
            trackOutput.sampleData(payload, payload.limit());
            trackOutput.sampleMetadata(timeUs, C.BUFFER_FLAG_KEY_FRAME, payload.limit(), 0, null);
            targetGranule = -1;
        }
        currentGranule += granulesInPacket;
    } else {
        state = STATE_END_OF_INPUT;
        return Extractor.RESULT_END_OF_INPUT;
    }
    return Extractor.RESULT_CONTINUE;
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull)

Example 50 with ExtractorOutput

use of com.google.android.exoplayer2.extractor.ExtractorOutput in project ExoPlayer by google.

the class SeiReader method createTracks.

public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
    for (int i = 0; i < outputs.length; i++) {
        idGenerator.generateNewId();
        TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
        Format channelFormat = closedCaptionFormats.get(i);
        @Nullable String channelMimeType = channelFormat.sampleMimeType;
        Assertions.checkArgument(MimeTypes.APPLICATION_CEA608.equals(channelMimeType) || MimeTypes.APPLICATION_CEA708.equals(channelMimeType), "Invalid closed caption mime type provided: " + channelMimeType);
        String formatId = channelFormat.id != null ? channelFormat.id : idGenerator.getFormatId();
        output.format(new Format.Builder().setId(formatId).setSampleMimeType(channelMimeType).setSelectionFlags(channelFormat.selectionFlags).setLanguage(channelFormat.language).setAccessibilityChannel(channelFormat.accessibilityChannel).setInitializationData(channelFormat.initializationData).build());
        outputs[i] = output;
    }
}
Also used : Format(com.google.android.exoplayer2.Format) TrackOutput(com.google.android.exoplayer2.extractor.TrackOutput) Nullable(androidx.annotation.Nullable)

Aggregations

SeekMap (com.google.android.exoplayer2.extractor.SeekMap)79 Test (org.junit.Test)66 Uri (android.net.Uri)59 FakeTrackOutput (com.google.android.exoplayer2.testutil.FakeTrackOutput)57 FakeExtractorOutput (com.google.android.exoplayer2.testutil.FakeExtractorOutput)31 Nullable (androidx.annotation.Nullable)12 TrackOutput (com.google.android.exoplayer2.extractor.TrackOutput)9 Format (com.google.android.exoplayer2.Format)6 TrackIdGenerator (com.google.android.exoplayer2.extractor.ts.TsPayloadReader.TrackIdGenerator)6 Metadata (com.google.android.exoplayer2.metadata.Metadata)6 RequiresNonNull (org.checkerframework.checker.nullness.qual.RequiresNonNull)5 Extractor (com.google.android.exoplayer2.extractor.Extractor)4 OutputFrameHolder (com.google.android.exoplayer2.ext.flac.FlacBinarySearchSeeker.OutputFrameHolder)3 ExtractorInput (com.google.android.exoplayer2.extractor.ExtractorInput)3 ExtractorOutput (com.google.android.exoplayer2.extractor.ExtractorOutput)3 Mp3Extractor (com.google.android.exoplayer2.extractor.mp3.Mp3Extractor)3 Before (org.junit.Before)3 CallSuper (androidx.annotation.CallSuper)2 Format (androidx.media3.common.Format)2 Metadata (androidx.media3.common.Metadata)2