Java Code Examples for com.google.android.exoplayer2.C#BufferFlags
The following examples show how to use
com.google.android.exoplayer2.C#BufferFlags .
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: SampleQueue.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public void sampleMetadata( long timeUs, @C.BufferFlags int flags, int size, int offset, @Nullable CryptoData cryptoData) { if (pendingFormatAdjustment) { format(lastUnadjustedFormat); } timeUs += sampleOffsetUs; if (pendingSplice) { if ((flags & C.BUFFER_FLAG_KEY_FRAME) == 0 || !metadataQueue.attemptSplice(timeUs)) { return; } pendingSplice = false; } long absoluteOffset = totalBytesWritten - size - offset; metadataQueue.commitSample(timeUs, flags, absoluteOffset, size, cryptoData); }
Example 2
Source File: SampleQueue.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void sampleMetadata( long timeUs, @C.BufferFlags int flags, int size, int offset, @Nullable CryptoData cryptoData) { if (pendingFormatAdjustment) { format(lastUnadjustedFormat); } if (pendingSplice) { if ((flags & C.BUFFER_FLAG_KEY_FRAME) == 0 || !metadataQueue.attemptSplice(timeUs)) { return; } pendingSplice = false; } timeUs += sampleOffsetUs; long absoluteOffset = totalBytesWritten - size - offset; metadataQueue.commitSample(timeUs, flags, absoluteOffset, size, cryptoData); }
Example 3
Source File: SampleQueue.java From MediaSDK with Apache License 2.0 | 6 votes |
@Override public void sampleMetadata( long timeUs, @C.BufferFlags int flags, int size, int offset, @Nullable CryptoData cryptoData) { if (pendingFormatAdjustment) { format(lastUnadjustedFormat); } timeUs += sampleOffsetUs; if (pendingSplice) { if ((flags & C.BUFFER_FLAG_KEY_FRAME) == 0 || !metadataQueue.attemptSplice(timeUs)) { return; } pendingSplice = false; } long absoluteOffset = totalBytesWritten - size - offset; metadataQueue.commitSample(timeUs, flags, absoluteOffset, size, cryptoData); }
Example 4
Source File: MatroskaExtractor.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void startSample(ExtractorInput input, @C.BufferFlags int blockFlags, int size) throws IOException, InterruptedException { if (!foundSyncframe) { input.peekFully(syncframePrefix, 0, Ac3Util.TRUEHD_SYNCFRAME_PREFIX_LENGTH); input.resetPeekPosition(); if (Ac3Util.parseTrueHdSyncframeAudioSampleCount(syncframePrefix) == 0) { return; } foundSyncframe = true; sampleCount = 0; } if (sampleCount == 0) { // This is the first sample in the chunk, so reset the block flags and chunk size. this.blockFlags = blockFlags; chunkSize = 0; } chunkSize += size; }
Example 5
Source File: DefaultTrackOutput.java From K-Sonic with MIT License | 5 votes |
@Override public void sampleMetadata(long timeUs, @C.BufferFlags int flags, int size, int offset, byte[] encryptionKey) { if (pendingFormatAdjustment) { format(lastUnadjustedFormat); } if (!startWriteOperation()) { infoQueue.commitSampleTimestamp(timeUs); return; } try { if (pendingSplice) { if ((flags & C.BUFFER_FLAG_KEY_FRAME) == 0 || !infoQueue.attemptSplice(timeUs)) { return; } pendingSplice = false; } if (needKeyframe) { if ((flags & C.BUFFER_FLAG_KEY_FRAME) == 0) { return; } needKeyframe = false; } timeUs += sampleOffsetUs; long absoluteOffset = totalBytesWritten - size - offset; infoQueue.commitSample(timeUs, flags, absoluteOffset, size, encryptionKey); } finally { endWriteOperation(); } }
Example 6
Source File: DummyTrackOutput.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void sampleMetadata( long timeUs, @C.BufferFlags int flags, int size, int offset, @Nullable CryptoData cryptoData) { // Do nothing. }
Example 7
Source File: ChunkExtractorWrapper.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void sampleMetadata(long timeUs, @C.BufferFlags int flags, int size, int offset, CryptoData cryptoData) { if (endTimeUs != C.TIME_UNSET && timeUs >= endTimeUs) { trackOutput = dummyTrackOutput; } trackOutput.sampleMetadata(timeUs, flags, size, offset, cryptoData); }
Example 8
Source File: DummyTrackOutput.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void sampleMetadata( long timeUs, @C.BufferFlags int flags, int size, int offset, @Nullable CryptoData cryptoData) { // Do nothing. }
Example 9
Source File: ChunkExtractorWrapper.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public void sampleMetadata(long timeUs, @C.BufferFlags int flags, int size, int offset, CryptoData cryptoData) { if (endTimeUs != C.TIME_UNSET && timeUs >= endTimeUs) { trackOutput = dummyTrackOutput; } trackOutput.sampleMetadata(timeUs, flags, size, offset, cryptoData); }
Example 10
Source File: H262Reader.java From K-Sonic with MIT License | 4 votes |
@Override public void consume(ParsableByteArray data) { int offset = data.getPosition(); int limit = data.limit(); byte[] dataArray = data.data; // Append the data to the buffer. totalBytesWritten += data.bytesLeft(); output.sampleData(data, data.bytesLeft()); int searchOffset = offset; while (true) { int startCodeOffset = NalUnitUtil.findNalUnit(dataArray, searchOffset, limit, prefixFlags); if (startCodeOffset == limit) { // We've scanned to the end of the data without finding another start code. if (!hasOutputFormat) { csdBuffer.onData(dataArray, offset, limit); } return; } // We've found a start code with the following value. int startCodeValue = data.data[startCodeOffset + 3] & 0xFF; if (!hasOutputFormat) { // This is the number of bytes from the current offset to the start of the next start // code. It may be negative if the start code started in the previously consumed data. int lengthToStartCode = startCodeOffset - offset; if (lengthToStartCode > 0) { csdBuffer.onData(dataArray, offset, startCodeOffset); } // This is the number of bytes belonging to the next start code that have already been // passed to csdDataTargetBuffer. int bytesAlreadyPassed = lengthToStartCode < 0 ? -lengthToStartCode : 0; if (csdBuffer.onStartCode(startCodeValue, bytesAlreadyPassed)) { // The csd data is complete, so we can decode and output the media format. Pair<Format, Long> result = parseCsdBuffer(csdBuffer, formatId); output.format(result.first); frameDurationUs = result.second; hasOutputFormat = true; } } if (hasOutputFormat && (startCodeValue == START_GROUP || startCodeValue == START_PICTURE)) { int bytesWrittenPastStartCode = limit - startCodeOffset; if (foundFirstFrameInGroup) { @C.BufferFlags int flags = isKeyframe ? C.BUFFER_FLAG_KEY_FRAME : 0; int size = (int) (totalBytesWritten - framePosition) - bytesWrittenPastStartCode; output.sampleMetadata(frameTimeUs, flags, size, bytesWrittenPastStartCode, null); isKeyframe = false; } if (startCodeValue == START_GROUP) { foundFirstFrameInGroup = false; isKeyframe = true; } else /* startCodeValue == START_PICTURE */ { frameTimeUs = pesPtsUsAvailable ? pesTimeUs : (frameTimeUs + frameDurationUs); framePosition = totalBytesWritten - bytesWrittenPastStartCode; pesPtsUsAvailable = false; foundFirstFrameInGroup = true; } } offset = startCodeOffset; searchOffset = offset + 3; } }
Example 11
Source File: H265Reader.java From K-Sonic with MIT License | 4 votes |
private void outputSample(int offset) { @C.BufferFlags int flags = sampleIsKeyframe ? C.BUFFER_FLAG_KEY_FRAME : 0; int size = (int) (nalUnitStartPosition - samplePosition); output.sampleMetadata(sampleTimeUs, flags, size, offset, null); }
Example 12
Source File: H265Reader.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void outputSample(int offset) { @C.BufferFlags int flags = sampleIsKeyframe ? C.BUFFER_FLAG_KEY_FRAME : 0; int size = (int) (nalUnitStartPosition - samplePosition); output.sampleMetadata(sampleTimeUs, flags, size, offset, null); }
Example 13
Source File: ChunkExtractorWrapper.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void sampleMetadata(long timeUs, @C.BufferFlags int flags, int size, int offset, CryptoData cryptoData) { trackOutput.sampleMetadata(timeUs, flags, size, offset, cryptoData); }
Example 14
Source File: SampleMetadataQueue.java From MediaSDK with Apache License 2.0 | 4 votes |
public synchronized void commitSample(long timeUs, @C.BufferFlags int sampleFlags, long offset, int size, CryptoData cryptoData) { if (upstreamKeyframeRequired) { if ((sampleFlags & C.BUFFER_FLAG_KEY_FRAME) == 0) { return; } upstreamKeyframeRequired = false; } Assertions.checkState(!upstreamFormatRequired); isLastSampleQueued = (sampleFlags & C.BUFFER_FLAG_LAST_SAMPLE) != 0; largestQueuedTimestampUs = Math.max(largestQueuedTimestampUs, timeUs); int relativeEndIndex = getRelativeIndex(length); timesUs[relativeEndIndex] = timeUs; offsets[relativeEndIndex] = offset; sizes[relativeEndIndex] = size; flags[relativeEndIndex] = sampleFlags; cryptoDatas[relativeEndIndex] = cryptoData; formats[relativeEndIndex] = upstreamFormat; sourceIds[relativeEndIndex] = upstreamSourceId; upstreamCommittedFormat = upstreamFormat; length++; if (length == capacity) { // Increase the capacity. int newCapacity = capacity + SAMPLE_CAPACITY_INCREMENT; int[] newSourceIds = new int[newCapacity]; long[] newOffsets = new long[newCapacity]; long[] newTimesUs = new long[newCapacity]; int[] newFlags = new int[newCapacity]; int[] newSizes = new int[newCapacity]; CryptoData[] newCryptoDatas = new CryptoData[newCapacity]; Format[] newFormats = new Format[newCapacity]; int beforeWrap = capacity - relativeFirstIndex; System.arraycopy(offsets, relativeFirstIndex, newOffsets, 0, beforeWrap); System.arraycopy(timesUs, relativeFirstIndex, newTimesUs, 0, beforeWrap); System.arraycopy(flags, relativeFirstIndex, newFlags, 0, beforeWrap); System.arraycopy(sizes, relativeFirstIndex, newSizes, 0, beforeWrap); System.arraycopy(cryptoDatas, relativeFirstIndex, newCryptoDatas, 0, beforeWrap); System.arraycopy(formats, relativeFirstIndex, newFormats, 0, beforeWrap); System.arraycopy(sourceIds, relativeFirstIndex, newSourceIds, 0, beforeWrap); int afterWrap = relativeFirstIndex; System.arraycopy(offsets, 0, newOffsets, beforeWrap, afterWrap); System.arraycopy(timesUs, 0, newTimesUs, beforeWrap, afterWrap); System.arraycopy(flags, 0, newFlags, beforeWrap, afterWrap); System.arraycopy(sizes, 0, newSizes, beforeWrap, afterWrap); System.arraycopy(cryptoDatas, 0, newCryptoDatas, beforeWrap, afterWrap); System.arraycopy(formats, 0, newFormats, beforeWrap, afterWrap); System.arraycopy(sourceIds, 0, newSourceIds, beforeWrap, afterWrap); offsets = newOffsets; timesUs = newTimesUs; flags = newFlags; sizes = newSizes; cryptoDatas = newCryptoDatas; formats = newFormats; sourceIds = newSourceIds; relativeFirstIndex = 0; length = capacity; capacity = newCapacity; } }
Example 15
Source File: TrackOutput.java From Telegram-FOSS with GNU General Public License v2.0 | 3 votes |
/** * Called when metadata associated with a sample has been extracted from the stream. * * <p>The corresponding sample data will have already been passed to the output via calls to * {@link #sampleData(ExtractorInput, int, boolean)} or {@link #sampleData(ParsableByteArray, * int)}. * * @param timeUs The media timestamp associated with the sample, in microseconds. * @param flags Flags associated with the sample. See {@code C.BUFFER_FLAG_*}. * @param size The size of the sample data, in bytes. * @param offset The number of bytes that have been passed to {@link #sampleData(ExtractorInput, * int, boolean)} or {@link #sampleData(ParsableByteArray, int)} since the last byte belonging * to the sample whose metadata is being passed. * @param encryptionData The encryption data required to decrypt the sample. May be null. */ void sampleMetadata( long timeUs, @C.BufferFlags int flags, int size, int offset, @Nullable CryptoData encryptionData);
Example 16
Source File: TrackOutput.java From MediaSDK with Apache License 2.0 | 3 votes |
/** * Called when metadata associated with a sample has been extracted from the stream. * * <p>The corresponding sample data will have already been passed to the output via calls to * {@link #sampleData(ExtractorInput, int, boolean)} or {@link #sampleData(ParsableByteArray, * int)}. * * @param timeUs The media timestamp associated with the sample, in microseconds. * @param flags Flags associated with the sample. See {@code C.BUFFER_FLAG_*}. * @param size The size of the sample data, in bytes. * @param offset The number of bytes that have been passed to {@link #sampleData(ExtractorInput, * int, boolean)} or {@link #sampleData(ParsableByteArray, int)} since the last byte belonging * to the sample whose metadata is being passed. * @param encryptionData The encryption data required to decrypt the sample. May be null. */ void sampleMetadata( long timeUs, @C.BufferFlags int flags, int size, int offset, @Nullable CryptoData encryptionData);
Example 17
Source File: Buffer.java From TelePlus-Android with GNU General Public License v2.0 | 2 votes |
/** * Adds the {@code flag} to this buffer's flags. * * @param flag The flag to add to this buffer's flags, which should be one of the * {@code C.BUFFER_FLAG_*} constants. */ public final void addFlag(@C.BufferFlags int flag) { flags |= flag; }
Example 18
Source File: Buffer.java From K-Sonic with MIT License | 2 votes |
/** * Replaces this buffer's flags with {@code flags}. * * @param flags The flags to set, which should be a combination of the {@code C.BUFFER_FLAG_*} * constants. */ public final void setFlags(@C.BufferFlags int flags) { this.flags = flags; }
Example 19
Source File: Buffer.java From Telegram with GNU General Public License v2.0 | 2 votes |
/** * Removes the {@code flag} from this buffer's flags, if it is set. * * @param flag The flag to remove. */ public final void clearFlag(@C.BufferFlags int flag) { flags &= ~flag; }
Example 20
Source File: Buffer.java From TelePlus-Android with GNU General Public License v2.0 | 2 votes |
/** * Removes the {@code flag} from this buffer's flags, if it is set. * * @param flag The flag to remove. */ public final void clearFlag(@C.BufferFlags int flag) { flags &= ~flag; }