Java Code Examples for com.google.android.exoplayer2.extractor.Extractor#RESULT_SEEK
The following examples show how to use
com.google.android.exoplayer2.extractor.Extractor#RESULT_SEEK .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PsDurationReader.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private int readFirstScrValue(ExtractorInput input, PositionHolder seekPositionHolder) throws IOException, InterruptedException { if (input.getPosition() != 0) { seekPositionHolder.position = 0; return Extractor.RESULT_SEEK; } int bytesToRead = (int) Math.min(DURATION_READ_BYTES, input.getLength()); input.resetPeekPosition(); input.peekFully(packetBuffer.data, /* offset= */ 0, bytesToRead); packetBuffer.setPosition(0); packetBuffer.setLimit(bytesToRead); firstScrValue = readFirstScrValueFromBuffer(packetBuffer); isFirstScrValueRead = true; return Extractor.RESULT_CONTINUE; }
Example 2
Source File: PsDurationReader.java From Telegram with GNU General Public License v2.0 | 6 votes |
private int readFirstScrValue(ExtractorInput input, PositionHolder seekPositionHolder) throws IOException, InterruptedException { int bytesToSearch = (int) Math.min(TIMESTAMP_SEARCH_BYTES, input.getLength()); int searchStartPosition = 0; if (input.getPosition() != searchStartPosition) { seekPositionHolder.position = searchStartPosition; return Extractor.RESULT_SEEK; } packetBuffer.reset(bytesToSearch); input.resetPeekPosition(); input.peekFully(packetBuffer.data, /* offset= */ 0, bytesToSearch); firstScrValue = readFirstScrValueFromBuffer(packetBuffer); isFirstScrValueRead = true; return Extractor.RESULT_CONTINUE; }
Example 3
Source File: MatroskaExtractor.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public final 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; } } if (!continueReading) { for (int i = 0; i < tracks.size(); i++) { tracks.valueAt(i).outputPendingSampleMetadata(); } return Extractor.RESULT_END_OF_INPUT; } return Extractor.RESULT_CONTINUE; }
Example 4
Source File: MatroskaExtractor.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public final 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; } } if (!continueReading) { for (int i = 0; i < tracks.size(); i++) { tracks.valueAt(i).outputPendingSampleMetadata(); } return Extractor.RESULT_END_OF_INPUT; } return Extractor.RESULT_CONTINUE; }
Example 5
Source File: TsDurationReader.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private int readLastPcrValue(ExtractorInput input, PositionHolder seekPositionHolder, int pcrPid) throws IOException, InterruptedException { int bytesToRead = (int) Math.min(DURATION_READ_BYTES, input.getLength()); long bufferStartStreamPosition = input.getLength() - bytesToRead; if (input.getPosition() != bufferStartStreamPosition) { seekPositionHolder.position = bufferStartStreamPosition; return Extractor.RESULT_SEEK; } input.resetPeekPosition(); input.peekFully(packetBuffer.data, /* offset= */ 0, bytesToRead); packetBuffer.setPosition(0); packetBuffer.setLimit(bytesToRead); lastPcrValue = readLastPcrValueFromBuffer(packetBuffer, pcrPid); isLastPcrValueRead = true; return Extractor.RESULT_CONTINUE; }
Example 6
Source File: MatroskaExtractor.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@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; } } if (!continueReading) { for (int i = 0; i < tracks.size(); i++) { tracks.valueAt(i).outputPendingSampleMetadata(); } return Extractor.RESULT_END_OF_INPUT; } return Extractor.RESULT_CONTINUE; }
Example 7
Source File: PsDurationReader.java From Telegram with GNU General Public License v2.0 | 6 votes |
private int readLastScrValue(ExtractorInput input, PositionHolder seekPositionHolder) throws IOException, InterruptedException { long inputLength = input.getLength(); int bytesToSearch = (int) Math.min(TIMESTAMP_SEARCH_BYTES, inputLength); long searchStartPosition = inputLength - bytesToSearch; if (input.getPosition() != searchStartPosition) { seekPositionHolder.position = searchStartPosition; return Extractor.RESULT_SEEK; } packetBuffer.reset(bytesToSearch); input.resetPeekPosition(); input.peekFully(packetBuffer.data, /* offset= */ 0, bytesToSearch); lastScrValue = readLastScrValueFromBuffer(packetBuffer); isLastScrValueRead = true; return Extractor.RESULT_CONTINUE; }
Example 8
Source File: PsDurationReader.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private int readLastScrValue(ExtractorInput input, PositionHolder seekPositionHolder) throws IOException, InterruptedException { int bytesToRead = (int) Math.min(DURATION_READ_BYTES, input.getLength()); long bufferStartStreamPosition = input.getLength() - bytesToRead; if (input.getPosition() != bufferStartStreamPosition) { seekPositionHolder.position = bufferStartStreamPosition; return Extractor.RESULT_SEEK; } input.resetPeekPosition(); input.peekFully(packetBuffer.data, /* offset= */ 0, bytesToRead); packetBuffer.setPosition(0); packetBuffer.setLimit(bytesToRead); lastScrValue = readLastScrValueFromBuffer(packetBuffer); isLastScrValueRead = true; return Extractor.RESULT_CONTINUE; }
Example 9
Source File: TsDurationReader.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private int readLastPcrValue(ExtractorInput input, PositionHolder seekPositionHolder, int pcrPid) throws IOException, InterruptedException { int bytesToRead = (int) Math.min(DURATION_READ_BYTES, input.getLength()); long bufferStartStreamPosition = input.getLength() - bytesToRead; if (input.getPosition() != bufferStartStreamPosition) { seekPositionHolder.position = bufferStartStreamPosition; return Extractor.RESULT_SEEK; } input.resetPeekPosition(); input.peekFully(packetBuffer.data, /* offset= */ 0, bytesToRead); packetBuffer.setPosition(0); packetBuffer.setLimit(bytesToRead); lastPcrValue = readLastPcrValueFromBuffer(packetBuffer, pcrPid); isLastPcrValueRead = true; return Extractor.RESULT_CONTINUE; }
Example 10
Source File: PsDurationReader.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private int readFirstScrValue(ExtractorInput input, PositionHolder seekPositionHolder) throws IOException, InterruptedException { int bytesToSearch = (int) Math.min(TIMESTAMP_SEARCH_BYTES, input.getLength()); int searchStartPosition = 0; if (input.getPosition() != searchStartPosition) { seekPositionHolder.position = searchStartPosition; return Extractor.RESULT_SEEK; } packetBuffer.reset(bytesToSearch); input.resetPeekPosition(); input.peekFully(packetBuffer.data, /* offset= */ 0, bytesToSearch); firstScrValue = readFirstScrValueFromBuffer(packetBuffer); isFirstScrValueRead = true; return Extractor.RESULT_CONTINUE; }
Example 11
Source File: MatroskaExtractor.java From MediaSDK with Apache License 2.0 | 6 votes |
@Override public final int read(ExtractorInput input, PositionHolder seekPosition) throws IOException, InterruptedException { haveOutputSample = false; boolean continueReading = true; while (continueReading && !haveOutputSample) { continueReading = reader.read(input); if (continueReading && maybeSeekForCues(seekPosition, input.getPosition())) { return Extractor.RESULT_SEEK; } } if (!continueReading) { for (int i = 0; i < tracks.size(); i++) { tracks.valueAt(i).outputPendingSampleMetadata(); } return Extractor.RESULT_END_OF_INPUT; } return Extractor.RESULT_CONTINUE; }
Example 12
Source File: TsDurationReader.java From Telegram with GNU General Public License v2.0 | 6 votes |
private int readFirstPcrValue(ExtractorInput input, PositionHolder seekPositionHolder, int pcrPid) throws IOException, InterruptedException { int bytesToSearch = (int) Math.min(TIMESTAMP_SEARCH_BYTES, input.getLength()); int searchStartPosition = 0; if (input.getPosition() != searchStartPosition) { seekPositionHolder.position = searchStartPosition; return Extractor.RESULT_SEEK; } packetBuffer.reset(bytesToSearch); input.resetPeekPosition(); input.peekFully(packetBuffer.data, /* offset= */ 0, bytesToSearch); firstPcrValue = readFirstPcrValueFromBuffer(packetBuffer, pcrPid); isFirstPcrValueRead = true; return Extractor.RESULT_CONTINUE; }
Example 13
Source File: PsDurationReader.java From MediaSDK with Apache License 2.0 | 6 votes |
private int readLastScrValue(ExtractorInput input, PositionHolder seekPositionHolder) throws IOException, InterruptedException { long inputLength = input.getLength(); int bytesToSearch = (int) Math.min(TIMESTAMP_SEARCH_BYTES, inputLength); long searchStartPosition = inputLength - bytesToSearch; if (input.getPosition() != searchStartPosition) { seekPositionHolder.position = searchStartPosition; return Extractor.RESULT_SEEK; } packetBuffer.reset(bytesToSearch); input.resetPeekPosition(); input.peekFully(packetBuffer.data, /* offset= */ 0, bytesToSearch); lastScrValue = readLastScrValueFromBuffer(packetBuffer); isLastScrValueRead = true; return Extractor.RESULT_CONTINUE; }
Example 14
Source File: TsDurationReader.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private int readLastPcrValue(ExtractorInput input, PositionHolder seekPositionHolder, int pcrPid) throws IOException, InterruptedException { long inputLength = input.getLength(); int bytesToSearch = (int) Math.min(TIMESTAMP_SEARCH_BYTES, inputLength); long searchStartPosition = inputLength - bytesToSearch; if (input.getPosition() != searchStartPosition) { seekPositionHolder.position = searchStartPosition; return Extractor.RESULT_SEEK; } packetBuffer.reset(bytesToSearch); input.resetPeekPosition(); input.peekFully(packetBuffer.data, /* offset= */ 0, bytesToSearch); lastPcrValue = readLastPcrValueFromBuffer(packetBuffer, pcrPid); isLastPcrValueRead = true; return Extractor.RESULT_CONTINUE; }
Example 15
Source File: TsDurationReader.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private int readFirstPcrValue(ExtractorInput input, PositionHolder seekPositionHolder, int pcrPid) throws IOException, InterruptedException { int bytesToSearch = (int) Math.min(TIMESTAMP_SEARCH_BYTES, input.getLength()); int searchStartPosition = 0; if (input.getPosition() != searchStartPosition) { seekPositionHolder.position = searchStartPosition; return Extractor.RESULT_SEEK; } packetBuffer.reset(bytesToSearch); input.resetPeekPosition(); input.peekFully(packetBuffer.data, /* offset= */ 0, bytesToSearch); firstPcrValue = readFirstPcrValueFromBuffer(packetBuffer, pcrPid); isFirstPcrValueRead = true; return Extractor.RESULT_CONTINUE; }
Example 16
Source File: StreamReader.java From K-Sonic with MIT License | 5 votes |
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; }
Example 17
Source File: TestUtil.java From ExoPlayer-Offline with Apache License 2.0 | 5 votes |
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); } } }
Example 18
Source File: MatroskaExtractor.java From K-Sonic with MIT License | 5 votes |
@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; }
Example 19
Source File: StreamReader.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
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; }
Example 20
Source File: StreamReader.java From Telegram with GNU General Public License v2.0 | 5 votes |
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; }