com.google.android.exoplayer2.util.ParsableByteArray Java Examples
The following examples show how to use
com.google.android.exoplayer2.util.ParsableByteArray.
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: AtomParsers.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Parses the edts atom (defined in 14496-12 subsection 8.6.5). * * @param edtsAtom edts (edit box) atom to decode. * @return Pair of edit list durations and edit list media times, or a pair of nulls if they are * not present. */ private static Pair<long[], long[]> parseEdts(Atom.ContainerAtom edtsAtom) { Atom.LeafAtom elst; if (edtsAtom == null || (elst = edtsAtom.getLeafAtomOfType(Atom.TYPE_elst)) == null) { return Pair.create(null, null); } ParsableByteArray elstData = elst.data; elstData.setPosition(Atom.HEADER_SIZE); int fullAtom = elstData.readInt(); int version = Atom.parseFullAtomVersion(fullAtom); int entryCount = elstData.readUnsignedIntToInt(); long[] editListDurations = new long[entryCount]; long[] editListMediaTimes = new long[entryCount]; for (int i = 0; i < entryCount; i++) { editListDurations[i] = version == 1 ? elstData.readUnsignedLongToLong() : elstData.readUnsignedInt(); editListMediaTimes[i] = version == 1 ? elstData.readLong() : elstData.readInt(); int mediaRateInteger = elstData.readShort(); if (mediaRateInteger != 1) { // The extractor does not handle dwell edits (mediaRateInteger == 0). throw new IllegalArgumentException("Unsupported media rate."); } elstData.skipBytes(2); } return Pair.create(editListDurations, editListMediaTimes); }
Example #2
Source File: WebvttParserUtil.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Reads lines up to and including the next WebVTT cue header. * * @param input The input from which lines should be read. * @return A {@link Matcher} for the WebVTT cue header, or null if the end of the input was * reached without a cue header being found. In the case that a cue header is found, groups 1, * 2 and 3 of the returned matcher contain the start time, end time and settings list. */ @Nullable public static Matcher findNextCueHeader(ParsableByteArray input) { @Nullable String line; while ((line = input.readLine()) != null) { if (COMMENT.matcher(line).matches()) { // Skip until the end of the comment block. while ((line = input.readLine()) != null && !line.isEmpty()) {} } else { Matcher cueHeaderMatcher = WebvttCueParser.CUE_HEADER_PATTERN.matcher(line); if (cueHeaderMatcher.matches()) { return cueHeaderMatcher; } } } return null; }
Example #3
Source File: Cea608Decoder.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public Cea608Decoder(String mimeType, int accessibilityChannel) { ccData = new ParsableByteArray(); cueBuilders = new ArrayList<>(); currentCueBuilder = new CueBuilder(CC_MODE_UNKNOWN, DEFAULT_CAPTIONS_ROW_COUNT); packetLength = MimeTypes.APPLICATION_MP4CEA608.equals(mimeType) ? 2 : 3; switch (accessibilityChannel) { case 3: case 4: selectedField = 2; break; case 1: case 2: case Format.NO_VALUE: default: selectedField = 1; } setCaptionMode(CC_MODE_UNKNOWN); resetCueBuilders(); }
Example #4
Source File: VorbisReader.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override protected long preparePayload(ParsableByteArray packet) { // if this is not an audio packet... if ((packet.data[0] & 0x01) == 1) { return -1; } // ... we need to decode the block size int packetBlockSize = decodeBlockSize(packet.data[0], vorbisSetup); // a packet contains samples produced from overlapping the previous and current frame data // (https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-350001.3.2) int samplesInPacket = seenFirstAudioPacket ? (packetBlockSize + previousPacketBlockSize) / 4 : 0; // codec expects the number of samples appended to audio data appendNumberOfSamples(packet, samplesInPacket); // update state in members for next iteration seenFirstAudioPacket = true; previousPacketBlockSize = packetBlockSize; return samplesInPacket; }
Example #5
Source File: WebvttDecoder.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Positions the input right before the next event, and returns the kind of event found. Does not * consume any data from such event, if any. * * @return The kind of event found. */ private static int getNextEvent(ParsableByteArray parsableWebvttData) { int foundEvent = EVENT_NONE; int currentInputPosition = 0; while (foundEvent == EVENT_NONE) { currentInputPosition = parsableWebvttData.getPosition(); String line = parsableWebvttData.readLine(); if (line == null) { foundEvent = EVENT_END_OF_FILE; } else if (STYLE_START.equals(line)) { foundEvent = EVENT_STYLE_BLOCK; } else if (COMMENT_START.startsWith(line)) { foundEvent = EVENT_COMMENT; } else { foundEvent = EVENT_CUE; } } parsableWebvttData.setPosition(currentInputPosition); return foundEvent; }
Example #6
Source File: FragmentedMp4Extractor.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private static void parseSenc(ParsableByteArray senc, int offset, TrackFragment out) throws ParserException { senc.setPosition(Atom.HEADER_SIZE + offset); int fullAtom = senc.readInt(); int flags = Atom.parseFullAtomFlags(fullAtom); if ((flags & 0x01 /* override_track_encryption_box_parameters */) != 0) { // TODO: Implement this. throw new ParserException("Overriding TrackEncryptionBox parameters is unsupported."); } boolean subsampleEncryption = (flags & 0x02 /* use_subsample_encryption */) != 0; int sampleCount = senc.readUnsignedIntToInt(); if (sampleCount != out.sampleCount) { throw new ParserException("Length mismatch: " + sampleCount + ", " + out.sampleCount); } Arrays.fill(out.sampleHasSubsampleEncryptionTable, 0, sampleCount, subsampleEncryption); out.initEncryptionData(senc.bytesLeft()); out.fillEncryptionData(senc); }
Example #7
Source File: AudioTagPayloadReader.java From LiveVideoBroadcaster with Apache License 2.0 | 6 votes |
@Override protected void parsePayload(ParsableByteArray data, long timeUs) { int packetType = data.readUnsignedByte(); if (packetType == AAC_PACKET_TYPE_SEQUENCE_HEADER && !hasOutputFormat) { // Parse the sequence header. byte[] audioSpecificConfig = new byte[data.bytesLeft()]; data.readBytes(audioSpecificConfig, 0, audioSpecificConfig.length); Pair<Integer, Integer> audioParams = CodecSpecificDataUtil.parseAacAudioSpecificConfig( audioSpecificConfig); Format format = Format.createAudioSampleFormat(null, MimeTypes.AUDIO_AAC, null, Format.NO_VALUE, Format.NO_VALUE, audioParams.second, audioParams.first, Collections.singletonList(audioSpecificConfig), null, 0, null); output.format(format); hasOutputFormat = true; } else if (audioFormat != AUDIO_FORMAT_AAC || packetType == AAC_PACKET_TYPE_AAC_RAW) { int sampleSize = data.bytesLeft(); output.sampleData(data, sampleSize); output.sampleMetadata(timeUs, C.BUFFER_FLAG_KEY_FRAME, sampleSize, 0, null); } }
Example #8
Source File: MatroskaExtractor.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
MatroskaExtractor(EbmlReader reader, @Flags int flags) { this.reader = reader; this.reader.init(new InnerEbmlReaderOutput()); seekForCuesEnabled = (flags & FLAG_DISABLE_SEEK_FOR_CUES) == 0; varintReader = new VarintReader(); tracks = new SparseArray<>(); scratch = new ParsableByteArray(4); vorbisNumPageSamples = new ParsableByteArray(ByteBuffer.allocate(4).putInt(-1).array()); seekEntryIdBytes = new ParsableByteArray(4); nalStartCode = new ParsableByteArray(NalUnitUtil.NAL_START_CODE); nalLength = new ParsableByteArray(4); sampleStrippedBytes = new ParsableByteArray(); subtitleSample = new ParsableByteArray(); encryptionInitializationVector = new ParsableByteArray(ENCRYPTION_IV_SIZE); encryptionSubsampleData = new ParsableByteArray(); }
Example #9
Source File: Id3Decoder.java From K-Sonic with MIT License | 6 votes |
private static TextInformationFrame decodeTxxxFrame(ParsableByteArray id3Data, int frameSize) throws UnsupportedEncodingException { int encoding = id3Data.readUnsignedByte(); String charset = getCharsetName(encoding); byte[] data = new byte[frameSize - 1]; id3Data.readBytes(data, 0, frameSize - 1); int descriptionEndIndex = indexOfEos(data, 0, encoding); String description = new String(data, 0, descriptionEndIndex, charset); String value; int valueStartIndex = descriptionEndIndex + delimiterLength(encoding); if (valueStartIndex < data.length) { int valueEndIndex = indexOfEos(data, valueStartIndex, encoding); value = new String(data, valueStartIndex, valueEndIndex - valueStartIndex, charset); } else { value = ""; } return new TextInformationFrame("TXXX", description, value); }
Example #10
Source File: AtomParsers.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Parses the edts atom (defined in 14496-12 subsection 8.6.5). * * @param edtsAtom edts (edit box) atom to decode. * @return Pair of edit list durations and edit list media times, or a pair of nulls if they are * not present. */ private static Pair<long[], long[]> parseEdts(Atom.ContainerAtom edtsAtom) { Atom.LeafAtom elst; if (edtsAtom == null || (elst = edtsAtom.getLeafAtomOfType(Atom.TYPE_elst)) == null) { return Pair.create(null, null); } ParsableByteArray elstData = elst.data; elstData.setPosition(Atom.HEADER_SIZE); int fullAtom = elstData.readInt(); int version = Atom.parseFullAtomVersion(fullAtom); int entryCount = elstData.readUnsignedIntToInt(); long[] editListDurations = new long[entryCount]; long[] editListMediaTimes = new long[entryCount]; for (int i = 0; i < entryCount; i++) { editListDurations[i] = version == 1 ? elstData.readUnsignedLongToLong() : elstData.readUnsignedInt(); editListMediaTimes[i] = version == 1 ? elstData.readLong() : elstData.readInt(); int mediaRateInteger = elstData.readShort(); if (mediaRateInteger != 1) { // The extractor does not handle dwell edits (mediaRateInteger == 0). throw new IllegalArgumentException("Unsupported media rate."); } elstData.skipBytes(2); } return Pair.create(editListDurations, editListMediaTimes); }
Example #11
Source File: TsDurationReader.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private long readFirstPcrValueFromBuffer(ParsableByteArray packetBuffer, int pcrPid) { int searchStartPosition = packetBuffer.getPosition(); int searchEndPosition = packetBuffer.limit(); for (int searchPosition = searchStartPosition; searchPosition < searchEndPosition; searchPosition++) { if (packetBuffer.data[searchPosition] != TsExtractor.TS_SYNC_BYTE) { continue; } long pcrValue = TsUtil.readPcrFromPacket(packetBuffer, searchPosition, pcrPid); if (pcrValue != C.TIME_UNSET) { return pcrValue; } } return C.TIME_UNSET; }
Example #12
Source File: TsExtractor.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * @param mode Mode for the extractor. One of {@link #MODE_MULTI_PMT}, {@link #MODE_SINGLE_PMT} * and {@link #MODE_HLS}. * @param timestampAdjuster A timestamp adjuster for offsetting and scaling sample timestamps. * @param payloadReaderFactory Factory for injecting a custom set of payload readers. */ public TsExtractor( @Mode int mode, TimestampAdjuster timestampAdjuster, TsPayloadReader.Factory payloadReaderFactory) { this.payloadReaderFactory = Assertions.checkNotNull(payloadReaderFactory); this.mode = mode; if (mode == MODE_SINGLE_PMT || mode == MODE_HLS) { timestampAdjusters = Collections.singletonList(timestampAdjuster); } else { timestampAdjusters = new ArrayList<>(); timestampAdjusters.add(timestampAdjuster); } tsPacketBuffer = new ParsableByteArray(new byte[BUFFER_SIZE], 0); trackIds = new SparseBooleanArray(); trackPids = new SparseBooleanArray(); tsPayloadReaders = new SparseArray<>(); continuityCounters = new SparseIntArray(); durationReader = new TsDurationReader(); pcrPid = -1; resetPayloadReaders(); }
Example #13
Source File: VorbisReader.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override protected boolean readHeaders(ParsableByteArray packet, long position, SetupData setupData) throws IOException, InterruptedException { if (vorbisSetup != null) { return false; } vorbisSetup = readSetupHeaders(packet); if (vorbisSetup == null) { return true; } ArrayList<byte[]> codecInitialisationData = new ArrayList<>(); codecInitialisationData.add(vorbisSetup.idHeader.data); codecInitialisationData.add(vorbisSetup.setupHeaderData); setupData.format = Format.createAudioSampleFormat(null, MimeTypes.AUDIO_VORBIS, null, this.vorbisSetup.idHeader.bitrateNominal, Format.NO_VALUE, this.vorbisSetup.idHeader.channels, (int) this.vorbisSetup.idHeader.sampleRate, codecInitialisationData, null, 0, null); return true; }
Example #14
Source File: MetadataUtil.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private static @Nullable Id3Frame parseUint8Attribute( int type, String id, ParsableByteArray data, boolean isTextInformationFrame, boolean isBoolean) { int value = parseUint8AttributeValue(data); if (isBoolean) { value = Math.min(1, value); } if (value >= 0) { return isTextInformationFrame ? new TextInformationFrame(id, /* description= */ null, Integer.toString(value)) : new CommentFrame(LANGUAGE_UNDEFINED, id, Integer.toString(value)); } Log.w(TAG, "Failed to parse uint8 attribute: " + Atom.getAtomTypeString(type)); return null; }
Example #15
Source File: AtomParsers.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Parses the size of an expandable class, as specified by ISO 14496-1 subsection 8.3.3. */ private static int parseExpandableClassSize(ParsableByteArray data) { int currentByte = data.readUnsignedByte(); int size = currentByte & 0x7F; while ((currentByte & 0x80) == 0x80) { currentByte = data.readUnsignedByte(); size = (size << 7) | (currentByte & 0x7F); } return size; }
Example #16
Source File: MetadataUtil.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static @Nullable CommentFrame parseCommentAttribute(int type, ParsableByteArray data) { int atomSize = data.readInt(); int atomType = data.readInt(); if (atomType == Atom.TYPE_data) { data.skipBytes(8); // version (1), flags (3), empty (4) String value = data.readNullTerminatedString(atomSize - 16); return new CommentFrame(LANGUAGE_UNDEFINED, value, value); } Log.w(TAG, "Failed to parse comment attribute: " + Atom.getAtomTypeString(type)); return null; }
Example #17
Source File: CeaUtil.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Reads a value from the provided buffer consisting of zero or more 0xFF bytes followed by a * terminating byte not equal to 0xFF. The returned value is ((0xFF * N) + T), where N is the * number of 0xFF bytes and T is the value of the terminating byte. * * @param buffer The buffer from which to read the value. * @return The read value, or -1 if the end of the buffer is reached before a value is read. */ private static int readNon255TerminatedValue(ParsableByteArray buffer) { int b; int value = 0; do { if (buffer.bytesLeft() == 0) { return -1; } b = buffer.readUnsignedByte(); value += b; } while (b == 0xFF); return value; }
Example #18
Source File: VorbisUtil.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Verifies whether the next bytes in {@code header} are a vorbis header of the given * {@code headerType}. * * @param headerType the type of the header expected. * @param header the alleged header bytes. * @param quiet if {@code true} no exceptions are thrown. Instead {@code false} is returned. * @return the number of bytes read. * @throws ParserException thrown if header type or capture pattern is not as expected. */ public static boolean verifyVorbisHeaderCapturePattern(int headerType, ParsableByteArray header, boolean quiet) throws ParserException { if (header.bytesLeft() < 7) { if (quiet) { return false; } else { throw new ParserException("too short header: " + header.bytesLeft()); } } if (header.readUnsignedByte() != headerType) { if (quiet) { return false; } else { throw new ParserException("expected header type " + Integer.toHexString(headerType)); } } if (!(header.readUnsignedByte() == 'v' && header.readUnsignedByte() == 'o' && header.readUnsignedByte() == 'r' && header.readUnsignedByte() == 'b' && header.readUnsignedByte() == 'i' && header.readUnsignedByte() == 's')) { if (quiet) { return false; } else { throw new ParserException("expected characters 'vorbis'"); } } return true; }
Example #19
Source File: Id3Decoder.java From K-Sonic with MIT License | 5 votes |
private static ChapterTocFrame decodeChapterTOCFrame(ParsableByteArray id3Data, int frameSize, int majorVersion, boolean unsignedIntFrameSizeHack, int frameHeaderSize, FramePredicate framePredicate) throws UnsupportedEncodingException { int framePosition = id3Data.getPosition(); int elementIdEndIndex = indexOfZeroByte(id3Data.data, framePosition); String elementId = new String(id3Data.data, framePosition, elementIdEndIndex - framePosition, "ISO-8859-1"); id3Data.setPosition(elementIdEndIndex + 1); int ctocFlags = id3Data.readUnsignedByte(); boolean isRoot = (ctocFlags & 0x0002) != 0; boolean isOrdered = (ctocFlags & 0x0001) != 0; int childCount = id3Data.readUnsignedByte(); String[] children = new String[childCount]; for (int i = 0; i < childCount; i++) { int startIndex = id3Data.getPosition(); int endIndex = indexOfZeroByte(id3Data.data, startIndex); children[i] = new String(id3Data.data, startIndex, endIndex - startIndex, "ISO-8859-1"); id3Data.setPosition(endIndex + 1); } ArrayList<Id3Frame> subFrames = new ArrayList<>(); int limit = framePosition + frameSize; while (id3Data.getPosition() < limit) { Id3Frame frame = decodeFrame(majorVersion, id3Data, unsignedIntFrameSizeHack, frameHeaderSize, framePredicate); if (frame != null) { subFrames.add(frame); } } Id3Frame[] subFrameArray = new Id3Frame[subFrames.size()]; subFrames.toArray(subFrameArray); return new ChapterTocFrame(elementId, isRoot, isOrdered, children, subFrameArray); }
Example #20
Source File: AtomParsers.java From Telegram with GNU General Public License v2.0 | 5 votes |
public ChunkIterator(ParsableByteArray stsc, ParsableByteArray chunkOffsets, boolean chunkOffsetsAreLongs) { this.stsc = stsc; this.chunkOffsets = chunkOffsets; this.chunkOffsetsAreLongs = chunkOffsetsAreLongs; chunkOffsets.setPosition(Atom.FULL_HEADER_SIZE); length = chunkOffsets.readUnsignedIntToInt(); stsc.setPosition(Atom.FULL_HEADER_SIZE); remainingSamplesPerChunkChanges = stsc.readUnsignedIntToInt(); Assertions.checkState(stsc.readInt() == 1, "first_chunk must be 1"); index = -1; }
Example #21
Source File: FlacReader.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Parses a FLAC file seek table metadata structure and initializes internal fields. * * @param data A {@link ParsableByteArray} including whole seek table metadata block. Its * position should be set to the beginning of the block. * @see <a href="https://xiph.org/flac/format.html#metadata_block_seektable">FLAC format * METADATA_BLOCK_SEEKTABLE</a> */ public void parseSeekTable(ParsableByteArray data) { data.skipBytes(METADATA_LENGTH_OFFSET); int length = data.readUnsignedInt24(); int numberOfSeekPoints = length / SEEK_POINT_SIZE; seekPointGranules = new long[numberOfSeekPoints]; seekPointOffsets = new long[numberOfSeekPoints]; for (int i = 0; i < numberOfSeekPoints; i++) { seekPointGranules[i] = data.readLong(); seekPointOffsets[i] = data.readLong(); data.skipBytes(2); // Skip "Number of samples in the target frame." } }
Example #22
Source File: ProjectionDecoder.java From MediaSDK with Apache License 2.0 | 5 votes |
/** Returns true if the input contains a proj box. Indicates MP4 container. */ private static boolean isProj(ParsableByteArray input) { input.skipBytes(4); // size int type = input.readInt(); input.setPosition(0); return type == TYPE_PROJ; }
Example #23
Source File: CssParser.java From Telegram with GNU General Public License v2.0 | 5 votes |
static void skipStyleBlock(ParsableByteArray input) { // The style block cannot contain empty lines, so we assume the input ends when a empty line // is found. String line; do { line = input.readLine(); } while (!TextUtils.isEmpty(line)); }
Example #24
Source File: CssParser.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Returns a string containing the selector. The input is expected to have the form * {@code ::cue(tag#id.class1.class2[voice="someone"]}, where every element is optional. * * @param input From which the selector is obtained. * @return A string containing the target, empty string if the selector is universal * (targets all cues) or null if an error was encountered. */ private static String parseSelector(ParsableByteArray input, StringBuilder stringBuilder) { skipWhitespaceAndComments(input); if (input.bytesLeft() < 5) { return null; } String cueSelector = input.readString(5); if (!"::cue".equals(cueSelector)) { return null; } int position = input.getPosition(); String token = parseNextToken(input, stringBuilder); if (token == null) { return null; } if (BLOCK_START.equals(token)) { input.setPosition(position); return ""; } String target = null; if ("(".equals(token)) { target = readCueTarget(input); } token = parseNextToken(input, stringBuilder); if (!")".equals(token) || token == null) { return null; } return target; }
Example #25
Source File: CssParser.java From K-Sonic with MIT License | 5 votes |
/** * Reads the contents of ::cue() and returns it as a string. */ private static String readCueTarget(ParsableByteArray input) { int position = input.getPosition(); int limit = input.limit(); boolean cueTargetEndFound = false; while (position < limit && !cueTargetEndFound) { char c = (char) input.data[position++]; cueTargetEndFound = c == ')'; } return input.readString(--position - input.getPosition()).trim(); // --offset to return ')' to the input. }
Example #26
Source File: PsDurationReader.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
PsDurationReader() { scrTimestampAdjuster = new TimestampAdjuster(/* firstSampleTimestampUs= */ 0); firstScrValue = C.TIME_UNSET; lastScrValue = C.TIME_UNSET; durationUs = C.TIME_UNSET; packetBuffer = new ParsableByteArray(DURATION_READ_BYTES); }
Example #27
Source File: SpliceScheduleCommand.java From MediaSDK with Apache License 2.0 | 5 votes |
static SpliceScheduleCommand parseFromSection(ParsableByteArray sectionData) { int spliceCount = sectionData.readUnsignedByte(); ArrayList<Event> events = new ArrayList<>(spliceCount); for (int i = 0; i < spliceCount; i++) { events.add(Event.parseFromSection(sectionData)); } return new SpliceScheduleCommand(events); }
Example #28
Source File: AdtsReader.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Reads the rest of the sample */ private void readSample(ParsableByteArray data) { int bytesToRead = Math.min(data.bytesLeft(), sampleSize - bytesRead); currentOutput.sampleData(data, bytesToRead); bytesRead += bytesToRead; if (bytesRead == sampleSize) { currentOutput.sampleMetadata(timeUs, C.BUFFER_FLAG_KEY_FRAME, sampleSize, 0, null); timeUs += currentSampleDuration; setFindingSampleState(); } }
Example #29
Source File: PsDurationReader.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private long readScrValueFromPack(ParsableByteArray packetBuffer, int packHeaderStartPosition) { packetBuffer.setPosition(packHeaderStartPosition); if (packetBuffer.bytesLeft() < 9) { // We require at 9 bytes for pack header to read scr value return C.TIME_UNSET; } byte[] scrBytes = new byte[9]; packetBuffer.readBytes(scrBytes, /* offset= */ 0, scrBytes.length); if (!checkMarkerBits(scrBytes)) { return C.TIME_UNSET; } return readScrValueFromPackHeader(scrBytes); }
Example #30
Source File: FragmentedMp4Extractor.java From MediaSDK with Apache License 2.0 | 5 votes |
private static void parseUuid(ParsableByteArray uuid, TrackFragment out, byte[] extendedTypeScratch) throws ParserException { uuid.setPosition(Atom.HEADER_SIZE); uuid.readBytes(extendedTypeScratch, 0, 16); // Currently this parser only supports Microsoft's PIFF SampleEncryptionBox. if (!Arrays.equals(extendedTypeScratch, PIFF_SAMPLE_ENCRYPTION_BOX_EXTENDED_TYPE)) { return; } // Except for the extended type, this box is identical to a SENC box. See "Portable encoding of // audio-video objects: The Protected Interoperable File Format (PIFF), John A. Bocharov et al, // Section 5.3.2.1." parseSenc(uuid, 16, out); }