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);
}
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;
}
}
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));
}
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;
}
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;
}
}
Aggregations