Java Code Examples for com.google.android.exoplayer2.extractor.Extractor#ReadResult
The following examples show how to use
com.google.android.exoplayer2.extractor.Extractor#ReadResult .
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: TsDurationReader.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Reads a TS duration from the input, using the given PCR PID. * * <p>This reader reads the duration by reading PCR values of the PCR PID packets at the start and * at the end of the stream, calculating the difference, and converting that into stream duration. * * @param input The {@link ExtractorInput} from which data should be read. * @param seekPositionHolder If {@link Extractor#RESULT_SEEK} is returned, this holder is updated * to hold the position of the required seek. * @param pcrPid The PID of the packet stream within this TS stream that contains PCR values. * @return One of the {@code RESULT_} values defined in {@link Extractor}. * @throws IOException If an error occurred reading from the input. * @throws InterruptedException If the thread was interrupted. */ public @Extractor.ReadResult int readDuration( ExtractorInput input, PositionHolder seekPositionHolder, int pcrPid) throws IOException, InterruptedException { if (pcrPid <= 0) { return finishReadDuration(input); } if (!isLastPcrValueRead) { return readLastPcrValue(input, seekPositionHolder, pcrPid); } if (lastPcrValue == C.TIME_UNSET) { return finishReadDuration(input); } if (!isFirstPcrValueRead) { return readFirstPcrValue(input, seekPositionHolder, pcrPid); } if (firstPcrValue == C.TIME_UNSET) { return finishReadDuration(input); } long minPcrPositionUs = pcrTimestampAdjuster.adjustTsTimestamp(firstPcrValue); long maxPcrPositionUs = pcrTimestampAdjuster.adjustTsTimestamp(lastPcrValue); durationUs = maxPcrPositionUs - minPcrPositionUs; return finishReadDuration(input); }
Example 2
Source File: PsDurationReader.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Reads a PS duration from the input. * * <p>This reader reads the duration by reading SCR values from the header of a pack at the start * and at the end of the stream, calculating the difference, and converting that into stream * duration. * * @param input The {@link ExtractorInput} from which data should be read. * @param seekPositionHolder If {@link Extractor#RESULT_SEEK} is returned, this holder is updated * to hold the position of the required seek. * @return One of the {@code RESULT_} values defined in {@link Extractor}. * @throws IOException If an error occurred reading from the input. * @throws InterruptedException If the thread was interrupted. */ public @Extractor.ReadResult int readDuration( ExtractorInput input, PositionHolder seekPositionHolder) throws IOException, InterruptedException { if (!isLastScrValueRead) { return readLastScrValue(input, seekPositionHolder); } if (lastScrValue == C.TIME_UNSET) { return finishReadDuration(input); } if (!isFirstScrValueRead) { return readFirstScrValue(input, seekPositionHolder); } if (firstScrValue == C.TIME_UNSET) { return finishReadDuration(input); } long minScrPositionUs = scrTimestampAdjuster.adjustTsTimestamp(firstScrValue); long maxScrPositionUs = scrTimestampAdjuster.adjustTsTimestamp(lastScrValue); durationUs = maxScrPositionUs - minScrPositionUs; return finishReadDuration(input); }
Example 3
Source File: TsDurationReader.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Reads a TS duration from the input, using the given PCR PID. * * <p>This reader reads the duration by reading PCR values of the PCR PID packets at the start and * at the end of the stream, calculating the difference, and converting that into stream duration. * * @param input The {@link ExtractorInput} from which data should be read. * @param seekPositionHolder If {@link Extractor#RESULT_SEEK} is returned, this holder is updated * to hold the position of the required seek. * @param pcrPid The PID of the packet stream within this TS stream that contains PCR values. * @return One of the {@code RESULT_} values defined in {@link Extractor}. * @throws IOException If an error occurred reading from the input. * @throws InterruptedException If the thread was interrupted. */ public @Extractor.ReadResult int readDuration( ExtractorInput input, PositionHolder seekPositionHolder, int pcrPid) throws IOException, InterruptedException { if (pcrPid <= 0) { return finishReadDuration(input); } if (!isLastPcrValueRead) { return readLastPcrValue(input, seekPositionHolder, pcrPid); } if (lastPcrValue == C.TIME_UNSET) { return finishReadDuration(input); } if (!isFirstPcrValueRead) { return readFirstPcrValue(input, seekPositionHolder, pcrPid); } if (firstPcrValue == C.TIME_UNSET) { return finishReadDuration(input); } long minPcrPositionUs = pcrTimestampAdjuster.adjustTsTimestamp(firstPcrValue); long maxPcrPositionUs = pcrTimestampAdjuster.adjustTsTimestamp(lastPcrValue); durationUs = maxPcrPositionUs - minPcrPositionUs; return finishReadDuration(input); }
Example 4
Source File: PsDurationReader.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Reads a PS duration from the input. * * <p>This reader reads the duration by reading SCR values from the header of a pack at the start * and at the end of the stream, calculating the difference, and converting that into stream * duration. * * @param input The {@link ExtractorInput} from which data should be read. * @param seekPositionHolder If {@link Extractor#RESULT_SEEK} is returned, this holder is updated * to hold the position of the required seek. * @return One of the {@code RESULT_} values defined in {@link Extractor}. * @throws IOException If an error occurred reading from the input. * @throws InterruptedException If the thread was interrupted. */ public @Extractor.ReadResult int readDuration( ExtractorInput input, PositionHolder seekPositionHolder) throws IOException, InterruptedException { if (!isLastScrValueRead) { return readLastScrValue(input, seekPositionHolder); } if (lastScrValue == C.TIME_UNSET) { return finishReadDuration(input); } if (!isFirstScrValueRead) { return readFirstScrValue(input, seekPositionHolder); } if (firstScrValue == C.TIME_UNSET) { return finishReadDuration(input); } long minScrPositionUs = scrTimestampAdjuster.adjustTsTimestamp(firstScrValue); long maxScrPositionUs = scrTimestampAdjuster.adjustTsTimestamp(lastScrValue); durationUs = maxScrPositionUs - minScrPositionUs; return finishReadDuration(input); }
Example 5
Source File: TsDurationReader.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Reads a TS duration from the input, using the given PCR PID. * * <p>This reader reads the duration by reading PCR values of the PCR PID packets at the start and * at the end of the stream, calculating the difference, and converting that into stream duration. * * @param input The {@link ExtractorInput} from which data should be read. * @param seekPositionHolder If {@link Extractor#RESULT_SEEK} is returned, this holder is updated * to hold the position of the required seek. * @param pcrPid The PID of the packet stream within this TS stream that contains PCR values. * @return One of the {@code RESULT_} values defined in {@link Extractor}. * @throws IOException If an error occurred reading from the input. * @throws InterruptedException If the thread was interrupted. */ public @Extractor.ReadResult int readDuration( ExtractorInput input, PositionHolder seekPositionHolder, int pcrPid) throws IOException, InterruptedException { if (pcrPid <= 0) { return finishReadDuration(input); } if (!isLastPcrValueRead) { return readLastPcrValue(input, seekPositionHolder, pcrPid); } if (lastPcrValue == C.TIME_UNSET) { return finishReadDuration(input); } if (!isFirstPcrValueRead) { return readFirstPcrValue(input, seekPositionHolder, pcrPid); } if (firstPcrValue == C.TIME_UNSET) { return finishReadDuration(input); } long minPcrPositionUs = pcrTimestampAdjuster.adjustTsTimestamp(firstPcrValue); long maxPcrPositionUs = pcrTimestampAdjuster.adjustTsTimestamp(lastPcrValue); durationUs = maxPcrPositionUs - minPcrPositionUs; return finishReadDuration(input); }
Example 6
Source File: PsDurationReader.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Reads a PS duration from the input. * * <p>This reader reads the duration by reading SCR values from the header of a pack at the start * and at the end of the stream, calculating the difference, and converting that into stream * duration. * * @param input The {@link ExtractorInput} from which data should be read. * @param seekPositionHolder If {@link Extractor#RESULT_SEEK} is returned, this holder is updated * to hold the position of the required seek. * @return One of the {@code RESULT_} values defined in {@link Extractor}. * @throws IOException If an error occurred reading from the input. * @throws InterruptedException If the thread was interrupted. */ public @Extractor.ReadResult int readDuration( ExtractorInput input, PositionHolder seekPositionHolder) throws IOException, InterruptedException { if (!isLastScrValueRead) { return readLastScrValue(input, seekPositionHolder); } if (lastScrValue == C.TIME_UNSET) { return finishReadDuration(input); } if (!isFirstScrValueRead) { return readFirstScrValue(input, seekPositionHolder); } if (firstScrValue == C.TIME_UNSET) { return finishReadDuration(input); } long minScrPositionUs = scrTimestampAdjuster.adjustTsTimestamp(firstScrValue); long maxScrPositionUs = scrTimestampAdjuster.adjustTsTimestamp(lastScrValue); durationUs = maxScrPositionUs - minScrPositionUs; return finishReadDuration(input); }
Example 7
Source File: TsDurationReader.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
/** * Reads a TS duration from the input, using the given PCR PID. * * <p>This reader reads the duration by reading PCR values of the PCR PID packets at the start and * at the end of the stream, calculating the difference, and converting that into stream duration. * * @param input The {@link ExtractorInput} from which data should be read. * @param seekPositionHolder If {@link Extractor#RESULT_SEEK} is returned, this holder is updated * to hold the position of the required seek. * @param pcrPid The PID of the packet stream within this TS stream that contains PCR values. * @return One of the {@code RESULT_} values defined in {@link Extractor}. * @throws IOException If an error occurred reading from the input. * @throws InterruptedException If the thread was interrupted. */ public @Extractor.ReadResult int readDuration( ExtractorInput input, PositionHolder seekPositionHolder, int pcrPid) throws IOException, InterruptedException { if (pcrPid <= 0) { return finishReadDuration(input); } if (!isLastPcrValueRead) { return readLastPcrValue(input, seekPositionHolder, pcrPid); } if (lastPcrValue == C.TIME_UNSET) { return finishReadDuration(input); } if (!isFirstPcrValueRead) { return readFirstPcrValue(input, seekPositionHolder, pcrPid); } if (firstPcrValue == C.TIME_UNSET) { return finishReadDuration(input); } long minPcrPositionUs = pcrTimestampAdjuster.adjustTsTimestamp(firstPcrValue); long maxPcrPositionUs = pcrTimestampAdjuster.adjustTsTimestamp(lastPcrValue); durationUs = maxPcrPositionUs - minPcrPositionUs; return finishReadDuration(input); }
Example 8
Source File: PsDurationReader.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
/** * Reads a PS duration from the input. * * <p>This reader reads the duration by reading SCR values from the header of a pack at the start * and at the end of the stream, calculating the difference, and converting that into stream * duration. * * @param input The {@link ExtractorInput} from which data should be read. * @param seekPositionHolder If {@link Extractor#RESULT_SEEK} is returned, this holder is updated * to hold the position of the required seek. * @return One of the {@code RESULT_} values defined in {@link Extractor}. * @throws IOException If an error occurred reading from the input. * @throws InterruptedException If the thread was interrupted. */ public @Extractor.ReadResult int readDuration( ExtractorInput input, PositionHolder seekPositionHolder) throws IOException, InterruptedException { if (!isLastScrValueRead) { return readLastScrValue(input, seekPositionHolder); } if (lastScrValue == C.TIME_UNSET) { return finishReadDuration(input); } if (!isFirstScrValueRead) { return readFirstScrValue(input, seekPositionHolder); } if (firstScrValue == C.TIME_UNSET) { return finishReadDuration(input); } long minScrPositionUs = scrTimestampAdjuster.adjustTsTimestamp(firstScrValue); long maxScrPositionUs = scrTimestampAdjuster.adjustTsTimestamp(lastScrValue); durationUs = maxScrPositionUs - minScrPositionUs; return finishReadDuration(input); }
Example 9
Source File: TsDurationReader.java From Telegram with GNU General Public License v2.0 | 6 votes |
/** * Reads a TS duration from the input, using the given PCR PID. * * <p>This reader reads the duration by reading PCR values of the PCR PID packets at the start and * at the end of the stream, calculating the difference, and converting that into stream duration. * * @param input The {@link ExtractorInput} from which data should be read. * @param seekPositionHolder If {@link Extractor#RESULT_SEEK} is returned, this holder is updated * to hold the position of the required seek. * @param pcrPid The PID of the packet stream within this TS stream that contains PCR values. * @return One of the {@code RESULT_} values defined in {@link Extractor}. * @throws IOException If an error occurred reading from the input. * @throws InterruptedException If the thread was interrupted. */ public @Extractor.ReadResult int readDuration( ExtractorInput input, PositionHolder seekPositionHolder, int pcrPid) throws IOException, InterruptedException { if (pcrPid <= 0) { return finishReadDuration(input); } if (!isLastPcrValueRead) { return readLastPcrValue(input, seekPositionHolder, pcrPid); } if (lastPcrValue == C.TIME_UNSET) { return finishReadDuration(input); } if (!isFirstPcrValueRead) { return readFirstPcrValue(input, seekPositionHolder, pcrPid); } if (firstPcrValue == C.TIME_UNSET) { return finishReadDuration(input); } long minPcrPositionUs = pcrTimestampAdjuster.adjustTsTimestamp(firstPcrValue); long maxPcrPositionUs = pcrTimestampAdjuster.adjustTsTimestamp(lastPcrValue); durationUs = maxPcrPositionUs - minPcrPositionUs; return finishReadDuration(input); }
Example 10
Source File: PsDurationReader.java From Telegram with GNU General Public License v2.0 | 6 votes |
/** * Reads a PS duration from the input. * * <p>This reader reads the duration by reading SCR values from the header of a pack at the start * and at the end of the stream, calculating the difference, and converting that into stream * duration. * * @param input The {@link ExtractorInput} from which data should be read. * @param seekPositionHolder If {@link Extractor#RESULT_SEEK} is returned, this holder is updated * to hold the position of the required seek. * @return One of the {@code RESULT_} values defined in {@link Extractor}. * @throws IOException If an error occurred reading from the input. * @throws InterruptedException If the thread was interrupted. */ public @Extractor.ReadResult int readDuration( ExtractorInput input, PositionHolder seekPositionHolder) throws IOException, InterruptedException { if (!isLastScrValueRead) { return readLastScrValue(input, seekPositionHolder); } if (lastScrValue == C.TIME_UNSET) { return finishReadDuration(input); } if (!isFirstScrValueRead) { return readFirstScrValue(input, seekPositionHolder); } if (firstScrValue == C.TIME_UNSET) { return finishReadDuration(input); } long minScrPositionUs = scrTimestampAdjuster.adjustTsTimestamp(firstScrValue); long maxScrPositionUs = scrTimestampAdjuster.adjustTsTimestamp(lastScrValue); durationUs = maxScrPositionUs - minScrPositionUs; return finishReadDuration(input); }