本文整理汇总了Java中com.google.android.exoplayer2.extractor.SeekMap类的典型用法代码示例。如果您正苦于以下问题:Java SeekMap类的具体用法?Java SeekMap怎么用?Java SeekMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SeekMap类属于com.google.android.exoplayer2.extractor包,在下文中一共展示了SeekMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChunkLoadCompleted
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void onChunkLoadCompleted(Chunk chunk) {
if (chunk instanceof InitializationChunk) {
InitializationChunk initializationChunk = (InitializationChunk) chunk;
RepresentationHolder representationHolder =
representationHolders[trackSelection.indexOf(initializationChunk.trackFormat)];
// The null check avoids overwriting an index obtained from the manifest with one obtained
// from the stream. If the manifest defines an index then the stream shouldn't, but in cases
// where it does we should ignore it.
if (representationHolder.segmentIndex == null) {
SeekMap seekMap = representationHolder.extractorWrapper.getSeekMap();
if (seekMap != null) {
representationHolder.segmentIndex = new DashWrappingSegmentIndex((ChunkIndex) seekMap);
}
}
}
}
示例2: onChunkLoadCompleted
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void onChunkLoadCompleted(Chunk chunk) {
if (chunk instanceof InitializationChunk) {
InitializationChunk initializationChunk = (InitializationChunk) chunk;
RepresentationHolder representationHolder =
representationHolders[trackSelection.indexOf(initializationChunk.trackFormat)];
Format sampleFormat = initializationChunk.getSampleFormat();
if (sampleFormat != null) {
representationHolder.setSampleFormat(sampleFormat);
}
// The null check avoids overwriting an index obtained from the manifest with one obtained
// from the stream. If the manifest defines an index then the stream shouldn't, but in cases
// where it does we should ignore it.
if (representationHolder.segmentIndex == null) {
SeekMap seekMap = initializationChunk.getSeekMap();
if (seekMap != null) {
representationHolder.segmentIndex = new DashWrappingSegmentIndex((ChunkIndex) seekMap,
initializationChunk.dataSpec.uri.toString());
}
}
}
}
示例3: readTagData
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
/**
* 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.
* @throws InterruptedException If the thread was interrupted.
*/
private boolean readTagData(ExtractorInput input) throws IOException, InterruptedException {
boolean wasConsumed = true;
if (tagType == TAG_TYPE_AUDIO && audioReader != null) {
ensureReadyForMediaOutput();
audioReader.consume(prepareTagData(input), mediaTagTimestampOffsetUs + tagTimestampUs);
} else if (tagType == TAG_TYPE_VIDEO && videoReader != null) {
ensureReadyForMediaOutput();
videoReader.consume(prepareTagData(input), mediaTagTimestampOffsetUs + tagTimestampUs);
} else if (tagType == TAG_TYPE_SCRIPT_DATA && !outputSeekMap) {
metadataReader.consume(prepareTagData(input), tagTimestampUs);
long durationUs = metadataReader.getDurationUs();
if (durationUs != C.TIME_UNSET) {
extractorOutput.seekMap(new SeekMap.Unseekable(durationUs));
outputSeekMap = true;
}
} else {
input.skipFully(tagDataSize);
wasConsumed = false;
}
bytesToNextTagHeader = 4; // There's a 4 byte previous tag size before the next header.
state = STATE_SKIPPING_TO_TAG_HEADER;
return wasConsumed;
}
示例4: assertOutput
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
/**
* Asserts that {@code extractor} consumes {@code sampleFile} successfully and its output equals
* to a prerecorded output dump file with the name {@code sampleFile} + "{@value
* #DUMP_EXTENSION}". If {@code simulateUnknownLength} is true and {@code sampleFile} + "{@value
* #UNKNOWN_LENGTH_EXTENSION}" exists, it's preferred.
*
* @param extractor The {@link Extractor} to be tested.
* @param sampleFile The path to the input sample.
* @param fileData Content of the input file.
* @param instrumentation To be used to load the sample file.
* @param simulateIOErrors If true simulates IOErrors.
* @param simulateUnknownLength If true simulates unknown input length.
* @param simulatePartialReads If true simulates partial reads.
* @return The {@link FakeExtractorOutput} used in the test.
* @throws IOException If reading from the input fails.
* @throws InterruptedException If interrupted while reading from the input.
*/
public static FakeExtractorOutput assertOutput(Extractor extractor, String sampleFile,
byte[] fileData, Instrumentation instrumentation, boolean simulateIOErrors,
boolean simulateUnknownLength, boolean simulatePartialReads) throws IOException,
InterruptedException {
FakeExtractorInput input = new FakeExtractorInput.Builder().setData(fileData)
.setSimulateIOErrors(simulateIOErrors)
.setSimulateUnknownLength(simulateUnknownLength)
.setSimulatePartialReads(simulatePartialReads).build();
Assert.assertTrue(sniffTestData(extractor, input));
input.resetPeekPosition();
FakeExtractorOutput extractorOutput = consumeTestData(extractor, input, 0, true);
if (simulateUnknownLength
&& assetExists(instrumentation, sampleFile + UNKNOWN_LENGTH_EXTENSION)) {
extractorOutput.assertOutput(instrumentation, sampleFile + UNKNOWN_LENGTH_EXTENSION);
} else {
extractorOutput.assertOutput(instrumentation, sampleFile + ".0" + DUMP_EXTENSION);
}
SeekMap seekMap = extractorOutput.seekMap;
if (seekMap.isSeekable()) {
long durationUs = seekMap.getDurationUs();
for (int j = 0; j < 4; j++) {
long timeUs = (durationUs * j) / 3;
long position = seekMap.getPosition(timeUs);
input.setPosition((int) position);
for (int i = 0; i < extractorOutput.numberOfTracks; i++) {
extractorOutput.trackOutputs.valueAt(i).clear();
}
consumeTestData(extractor, input, timeUs, extractorOutput, false);
extractorOutput.assertOutput(instrumentation, sampleFile + '.' + j + DUMP_EXTENSION);
}
}
return extractorOutput;
}
示例5: init
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void init(ExtractorOutput output) {
reader = new AdtsReader(true);
reader.createTracks(output, new TrackIdGenerator(0, 1));
output.endTracks();
output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
}
示例6: init
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void init(ExtractorOutput output) {
reader = new Ac3Reader(); // TODO: Add support for embedded ID3.
reader.createTracks(output, new TrackIdGenerator(0, 1));
output.endTracks();
output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
}
示例7: readPayload
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
private int readPayload(ExtractorInput input, PositionHolder seekPosition)
throws IOException, InterruptedException {
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 = 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;
}
示例8: buildSeekMap
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
/**
* Builds a {@link SeekMap} from the recently gathered Cues information.
*
* @return The built {@link SeekMap}. The returned {@link SeekMap} may be unseekable if cues
* information was missing or incomplete.
*/
private SeekMap buildSeekMap() {
if (segmentContentPosition == C.POSITION_UNSET || durationUs == C.TIME_UNSET
|| cueTimesUs == null || cueTimesUs.size() == 0
|| cueClusterPositions == null || cueClusterPositions.size() != cueTimesUs.size()) {
// Cues information is missing or incomplete.
cueTimesUs = null;
cueClusterPositions = null;
return new SeekMap.Unseekable(durationUs);
}
int cuePointsSize = cueTimesUs.size();
int[] sizes = new int[cuePointsSize];
long[] offsets = new long[cuePointsSize];
long[] durationsUs = new long[cuePointsSize];
long[] timesUs = new long[cuePointsSize];
for (int i = 0; i < cuePointsSize; i++) {
timesUs[i] = cueTimesUs.get(i);
offsets[i] = segmentContentPosition + cueClusterPositions.get(i);
}
for (int i = 0; i < cuePointsSize - 1; i++) {
sizes[i] = (int) (offsets[i + 1] - offsets[i]);
durationsUs[i] = timesUs[i + 1] - timesUs[i];
}
sizes[cuePointsSize - 1] =
(int) (segmentContentPosition + segmentContentSize - offsets[cuePointsSize - 1]);
durationsUs[cuePointsSize - 1] = durationUs - timesUs[cuePointsSize - 1];
cueTimesUs = null;
cueClusterPositions = null;
return new ChunkIndex(sizes, offsets, durationsUs, timesUs);
}
示例9: init
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void init(ExtractorOutput output) {
output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
trackOutput = output.track(0, C.TRACK_TYPE_TEXT);
output.endTracks();
trackOutput.format(format);
}
示例10: init
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void init(ExtractorOutput output) {
reader = new AdtsReader(true);
reader.init(output, new TrackIdGenerator(0, 1));
output.endTracks();
output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
}
示例11: init
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void init(ExtractorOutput output) {
reader = new Ac3Reader(); // TODO: Add support for embedded ID3.
reader.init(output, new TrackIdGenerator(0, 1));
output.endTracks();
output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
}
示例12: readPayload
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
private int readPayload(ExtractorInput input, PositionHolder seekPosition)
throws IOException, InterruptedException {
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 = 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;
}
示例13: init
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void init(ExtractorOutput output) {
this.extractorOutput = output;
extractorOutput.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
trackOutput = extractorOutput.track(0);
extractorOutput.endTracks();
trackOutput.format(Format.createTextSampleFormat(null, MimeTypes.APPLICATION_CEA608,
null, Format.NO_VALUE, 0, null, null));
}
示例14: ensureReadyForMediaOutput
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
private void ensureReadyForMediaOutput() {
if (!outputSeekMap) {
extractorOutput.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
outputSeekMap = true;
}
if (mediaTagTimestampOffsetUs == C.TIME_UNSET) {
mediaTagTimestampOffsetUs =
metadataReader.getDurationUs() == C.TIME_UNSET ? -tagTimestampUs : 0;
}
}
示例15: init
import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void init(ExtractorOutput output) {
this.output = output;
output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
}