本文整理汇总了Java中com.google.android.exoplayer2.extractor.Extractor.RESULT_END_OF_INPUT属性的典型用法代码示例。如果您正苦于以下问题:Java Extractor.RESULT_END_OF_INPUT属性的具体用法?Java Extractor.RESULT_END_OF_INPUT怎么用?Java Extractor.RESULT_END_OF_INPUT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.android.exoplayer2.extractor.Extractor
的用法示例。
在下文中一共展示了Extractor.RESULT_END_OF_INPUT属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
@Override
public int read(ExtractorInput input, PositionHolder seekPosition)
throws IOException, InterruptedException {
int currentFileSize = (int) input.getLength();
// Increase the size of sampleData if necessary.
if (sampleSize == sampleData.length) {
sampleData = Arrays.copyOf(sampleData,
(currentFileSize != C.LENGTH_UNSET ? currentFileSize : sampleData.length) * 3 / 2);
}
// Consume to the input.
int bytesRead = input.read(sampleData, sampleSize, sampleData.length - sampleSize);
if (bytesRead != C.RESULT_END_OF_INPUT) {
sampleSize += bytesRead;
if (currentFileSize == C.LENGTH_UNSET || sampleSize != currentFileSize) {
return Extractor.RESULT_CONTINUE;
}
}
// We've reached the end of the input, which corresponds to the end of the current file.
processSample();
return Extractor.RESULT_END_OF_INPUT;
}
示例2: read
@Override
public int read(ExtractorInput input, PositionHolder seekPosition)
throws IOException, InterruptedException {
while (true) {
switch (parserState) {
case STATE_READING_ATOM_HEADER:
if (!readAtomHeader(input)) {
return Extractor.RESULT_END_OF_INPUT;
}
break;
case STATE_READING_ATOM_PAYLOAD:
readAtomPayload(input);
break;
case STATE_READING_ENCRYPTION_DATA:
readEncryptionData(input);
break;
default:
if (readSample(input)) {
return RESULT_CONTINUE;
}
}
}
}
示例3: testCustomPesReader
public void testCustomPesReader() throws Exception {
CustomEsReaderFactory factory = new CustomEsReaderFactory();
TsExtractor tsExtractor = new TsExtractor(new TimestampAdjuster(0), factory, false);
FakeExtractorInput input = new FakeExtractorInput.Builder()
.setData(TestUtil.getByteArray(getInstrumentation(), "ts/sample.ts"))
.setSimulateIOErrors(false)
.setSimulateUnknownLength(false)
.setSimulatePartialReads(false).build();
FakeExtractorOutput output = new FakeExtractorOutput();
tsExtractor.init(output);
tsExtractor.seek(input.getPosition());
PositionHolder seekPositionHolder = new PositionHolder();
int readResult = Extractor.RESULT_CONTINUE;
while (readResult != Extractor.RESULT_END_OF_INPUT) {
readResult = tsExtractor.read(input, seekPositionHolder);
}
CustomEsReader reader = factory.reader;
assertEquals(2, reader.packetsRead);
TrackOutput trackOutput = reader.getTrackOutput();
assertTrue(trackOutput == output.trackOutputs.get(257 /* PID of audio track. */));
assertEquals(
Format.createTextSampleFormat("Overriding format", "mime", null, 0, 0, "und", null, 0),
((FakeTrackOutput) trackOutput).format);
}
示例4: testCustomPesReader
public void testCustomPesReader() throws Exception {
CustomTsPayloadReaderFactory factory = new CustomTsPayloadReaderFactory(true, false);
TsExtractor tsExtractor = new TsExtractor(TsExtractor.MODE_MULTI_PMT, new TimestampAdjuster(0),
factory);
FakeExtractorInput input = new FakeExtractorInput.Builder()
.setData(TestUtil.getByteArray(getInstrumentation(), "ts/sample.ts"))
.setSimulateIOErrors(false)
.setSimulateUnknownLength(false)
.setSimulatePartialReads(false).build();
FakeExtractorOutput output = new FakeExtractorOutput();
tsExtractor.init(output);
PositionHolder seekPositionHolder = new PositionHolder();
int readResult = Extractor.RESULT_CONTINUE;
while (readResult != Extractor.RESULT_END_OF_INPUT) {
readResult = tsExtractor.read(input, seekPositionHolder);
}
CustomEsReader reader = factory.esReader;
assertEquals(2, reader.packetsRead);
TrackOutput trackOutput = reader.getTrackOutput();
assertTrue(trackOutput == output.trackOutputs.get(257 /* PID of audio track. */));
assertEquals(
Format.createTextSampleFormat("1/257", "mime", null, 0, 0, "und", null, 0),
((FakeTrackOutput) trackOutput).format);
}
示例5: testCustomInitialSectionReader
public void testCustomInitialSectionReader() throws Exception {
CustomTsPayloadReaderFactory factory = new CustomTsPayloadReaderFactory(false, true);
TsExtractor tsExtractor = new TsExtractor(TsExtractor.MODE_MULTI_PMT, new TimestampAdjuster(0),
factory);
FakeExtractorInput input = new FakeExtractorInput.Builder()
.setData(TestUtil.getByteArray(getInstrumentation(), "ts/sample_with_sdt.ts"))
.setSimulateIOErrors(false)
.setSimulateUnknownLength(false)
.setSimulatePartialReads(false).build();
tsExtractor.init(new FakeExtractorOutput());
PositionHolder seekPositionHolder = new PositionHolder();
int readResult = Extractor.RESULT_CONTINUE;
while (readResult != Extractor.RESULT_END_OF_INPUT) {
readResult = tsExtractor.read(input, seekPositionHolder);
}
assertEquals(1, factory.sdtReader.consumedSdts);
}
示例6: consumeTestData
private static void consumeTestData(Extractor extractor, FakeExtractorInput input, long timeUs,
FakeExtractorOutput output, boolean retryFromStartIfLive)
throws IOException, InterruptedException {
extractor.seek(input.getPosition(), timeUs);
PositionHolder seekPositionHolder = new PositionHolder();
int readResult = Extractor.RESULT_CONTINUE;
while (readResult != Extractor.RESULT_END_OF_INPUT) {
try {
// Extractor.read should not read seekPositionHolder.position. Set it to a value that's
// likely to cause test failure if a read does occur.
seekPositionHolder.position = Long.MIN_VALUE;
readResult = extractor.read(input, seekPositionHolder);
if (readResult == Extractor.RESULT_SEEK) {
long seekPosition = seekPositionHolder.position;
Assertions.checkState(0 <= seekPosition && seekPosition <= Integer.MAX_VALUE);
input.setPosition((int) seekPosition);
}
} catch (SimulatedIOException e) {
if (!retryFromStartIfLive) {
continue;
}
boolean isOnDemand = input.getLength() != C.LENGTH_UNSET
|| (output.seekMap != null && output.seekMap.getDurationUs() != C.TIME_UNSET);
if (isOnDemand) {
continue;
}
input.setPosition(0);
for (int i = 0; i < output.numberOfTracks; i++) {
output.trackOutputs.valueAt(i).clear();
}
extractor.seek(0, 0);
}
}
}
示例7: readHeaders
private int readHeaders(ExtractorInput input) throws IOException, InterruptedException {
boolean readingHeaders = true;
while (readingHeaders) {
if (!oggPacket.populate(input)) {
state = STATE_END_OF_INPUT;
return Extractor.RESULT_END_OF_INPUT;
}
lengthOfReadPacket = input.getPosition() - payloadStartPosition;
readingHeaders = readHeaders(oggPacket.getPayload(), payloadStartPosition, setupData);
if (readingHeaders) {
payloadStartPosition = input.getPosition();
}
}
sampleRate = setupData.format.sampleRate;
if (!formatSet) {
trackOutput.format(setupData.format);
formatSet = true;
}
if (setupData.oggSeeker != null) {
oggSeeker = setupData.oggSeeker;
} else if (input.getLength() == C.LENGTH_UNSET) {
oggSeeker = new UnseekableOggSeeker();
} else {
OggPageHeader firstPayloadPageHeader = oggPacket.getPageHeader();
oggSeeker = new DefaultOggSeeker(payloadStartPosition, input.getLength(), this,
firstPayloadPageHeader.headerSize + firstPayloadPageHeader.bodySize,
firstPayloadPageHeader.granulePosition);
}
setupData = null;
state = STATE_READ_PAYLOAD;
// First payload packet. Trim the payload array of the ogg packet after headers have been read.
oggPacket.trimPayload();
return Extractor.RESULT_CONTINUE;
}
示例8: readPayload
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;
}
示例9: read
@Override
public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException,
InterruptedException {
sampleRead = false;
boolean continueReading = true;
while (continueReading && !sampleRead) {
continueReading = reader.read(input);
if (continueReading && maybeSeekForCues(seekPosition, input.getPosition())) {
return Extractor.RESULT_SEEK;
}
}
return continueReading ? Extractor.RESULT_CONTINUE : Extractor.RESULT_END_OF_INPUT;
}
示例10: readHeaders
private int readHeaders(ExtractorInput input) throws IOException, InterruptedException {
boolean readingHeaders = true;
while (readingHeaders) {
if (!oggPacket.populate(input)) {
state = STATE_END_OF_INPUT;
return Extractor.RESULT_END_OF_INPUT;
}
lengthOfReadPacket = input.getPosition() - payloadStartPosition;
readingHeaders = readHeaders(oggPacket.getPayload(), payloadStartPosition, setupData);
if (readingHeaders) {
payloadStartPosition = input.getPosition();
}
}
sampleRate = setupData.format.sampleRate;
if (!formatSet) {
trackOutput.format(setupData.format);
formatSet = true;
}
if (setupData.oggSeeker != null) {
oggSeeker = setupData.oggSeeker;
} else if (input.getLength() == C.LENGTH_UNSET) {
oggSeeker = new UnseekableOggSeeker();
} else {
OggPageHeader firstPayloadPageHeader = oggPacket.getPageHeader();
oggSeeker = new DefaultOggSeeker(payloadStartPosition, input.getLength(), this,
firstPayloadPageHeader.headerSize + firstPayloadPageHeader.bodySize,
firstPayloadPageHeader.granulePosition);
}
setupData = null;
state = STATE_READ_PAYLOAD;
return Extractor.RESULT_CONTINUE;
}
示例11: readHeaders
private int readHeaders(ExtractorInput input) throws IOException, InterruptedException {
boolean readingHeaders = true;
while (readingHeaders) {
if (!oggPacket.populate(input)) {
state = STATE_END_OF_INPUT;
return Extractor.RESULT_END_OF_INPUT;
}
lengthOfReadPacket = input.getPosition() - payloadStartPosition;
readingHeaders = readHeaders(oggPacket.getPayload(), payloadStartPosition, setupData);
if (readingHeaders) {
payloadStartPosition = input.getPosition();
}
}
sampleRate = setupData.format.sampleRate;
if (!formatSet) {
trackOutput.format(setupData.format);
formatSet = true;
}
if (setupData.oggSeeker != null) {
oggSeeker = setupData.oggSeeker;
} else if (input.getLength() == C.LENGTH_UNSET) {
oggSeeker = new UnseekableOggSeeker();
} else {
oggSeeker = new DefaultOggSeeker(payloadStartPosition, input.getLength(), this);
}
setupData = null;
state = STATE_READ_PAYLOAD;
return Extractor.RESULT_CONTINUE;
}
示例12: readPayload
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;
}