use of com.google.android.exoplayer2.extractor.IndexSeekMap in project ExoPlayer by google.
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;
}
use of com.google.android.exoplayer2.extractor.IndexSeekMap in project ExoPlayer by google.
the class FlvExtractor method readTagData.
/**
* Reads the body of a tag from the provided {@link ExtractorInput}.
*
* @param input The {@link ExtractorInput} from which to read.
* @return True if the data was consumed by a reader. False if it was skipped.
* @throws IOException If an error occurred reading or parsing data from the source.
*/
@RequiresNonNull("extractorOutput")
private boolean readTagData(ExtractorInput input) throws IOException {
boolean wasConsumed = true;
boolean wasSampleOutput = false;
long timestampUs = getCurrentTimestampUs();
if (tagType == TAG_TYPE_AUDIO && audioReader != null) {
ensureReadyForMediaOutput();
wasSampleOutput = audioReader.consume(prepareTagData(input), timestampUs);
} else if (tagType == TAG_TYPE_VIDEO && videoReader != null) {
ensureReadyForMediaOutput();
wasSampleOutput = videoReader.consume(prepareTagData(input), timestampUs);
} else if (tagType == TAG_TYPE_SCRIPT_DATA && !outputSeekMap) {
wasSampleOutput = metadataReader.consume(prepareTagData(input), timestampUs);
long durationUs = metadataReader.getDurationUs();
if (durationUs != C.TIME_UNSET) {
extractorOutput.seekMap(new IndexSeekMap(metadataReader.getKeyFrameTagPositions(), metadataReader.getKeyFrameTimesUs(), durationUs));
outputSeekMap = true;
}
} else {
input.skipFully(tagDataSize);
wasConsumed = false;
}
if (!outputFirstSample && wasSampleOutput) {
outputFirstSample = true;
mediaTagTimestampOffsetUs = metadataReader.getDurationUs() == C.TIME_UNSET ? -tagTimestampUs : 0;
}
// There's a 4 byte previous tag size before the next header.
bytesToNextTagHeader = 4;
state = STATE_SKIPPING_TO_TAG_HEADER;
return wasConsumed;
}
Aggregations