本文整理汇总了Java中com.google.android.exoplayer2.util.ParsableByteArray.readUnsignedInt方法的典型用法代码示例。如果您正苦于以下问题:Java ParsableByteArray.readUnsignedInt方法的具体用法?Java ParsableByteArray.readUnsignedInt怎么用?Java ParsableByteArray.readUnsignedInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.exoplayer2.util.ParsableByteArray
的用法示例。
在下文中一共展示了ParsableByteArray.readUnsignedInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseEdts
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
* 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);
}
示例2: parseSaio
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
* Parses a saio atom (defined in 14496-12).
*
* @param saio The saio atom to decode.
* @param out The {@link TrackFragment} to populate with data from the saio atom.
*/
private static void parseSaio(ParsableByteArray saio, TrackFragment out) throws ParserException {
saio.setPosition(Atom.HEADER_SIZE);
int fullAtom = saio.readInt();
int flags = Atom.parseFullAtomFlags(fullAtom);
if ((flags & 0x01) == 1) {
saio.skipBytes(8);
}
int entryCount = saio.readUnsignedIntToInt();
if (entryCount != 1) {
// We only support one trun element currently, so always expect one entry.
throw new ParserException("Unexpected saio entry count: " + entryCount);
}
int version = Atom.parseFullAtomVersion(fullAtom);
out.auxiliaryDataPosition +=
version == 0 ? saio.readUnsignedInt() : saio.readUnsignedLongToLong();
}
示例3: parseMvhd
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
* Parses a mvhd atom (defined in 14496-12), returning the timescale for the movie.
*
* @param mvhd Contents of the mvhd atom to be parsed.
* @return Timescale for the movie.
*/
private static long parseMvhd(ParsableByteArray mvhd) {
mvhd.setPosition(Atom.HEADER_SIZE);
int fullAtom = mvhd.readInt();
int version = Atom.parseFullAtomVersion(fullAtom);
mvhd.skipBytes(version == 0 ? 8 : 16);
return mvhd.readUnsignedInt();
}
示例4: parseMdhd
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
* Parses an mdhd atom (defined in 14496-12).
*
* @param mdhd The mdhd atom to decode.
* @return A pair consisting of the media timescale defined as the number of time units that pass
* in one second, and the language code.
*/
private static Pair<Long, String> parseMdhd(ParsableByteArray mdhd) {
mdhd.setPosition(Atom.HEADER_SIZE);
int fullAtom = mdhd.readInt();
int version = Atom.parseFullAtomVersion(fullAtom);
mdhd.skipBytes(version == 0 ? 8 : 16);
long timescale = mdhd.readUnsignedInt();
mdhd.skipBytes(version == 0 ? 4 : 8);
int languageCode = mdhd.readUnsignedShort();
String language = "" + (char) (((languageCode >> 10) & 0x1F) + 0x60)
+ (char) (((languageCode >> 5) & 0x1F) + 0x60)
+ (char) (((languageCode) & 0x1F) + 0x60);
return Pair.create(timescale, language);
}
示例5: onEmsgLeafAtomRead
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
* Handles an emsg atom (defined in 23009-1).
*/
private void onEmsgLeafAtomRead(ParsableByteArray atom) {
if (eventMessageTrackOutput == null) {
return;
}
// Parse the event's presentation time delta.
atom.setPosition(Atom.FULL_HEADER_SIZE);
atom.readNullTerminatedString(); // schemeIdUri
atom.readNullTerminatedString(); // value
long timescale = atom.readUnsignedInt();
long presentationTimeDeltaUs =
Util.scaleLargeTimestamp(atom.readUnsignedInt(), C.MICROS_PER_SECOND, timescale);
// Output the sample data.
atom.setPosition(Atom.FULL_HEADER_SIZE);
int sampleSize = atom.bytesLeft();
eventMessageTrackOutput.sampleData(atom, sampleSize);
// Output the sample metadata.
if (segmentIndexEarliestPresentationTimeUs != C.TIME_UNSET) {
// We can output the sample metadata immediately.
eventMessageTrackOutput.sampleMetadata(
segmentIndexEarliestPresentationTimeUs + presentationTimeDeltaUs,
C.BUFFER_FLAG_KEY_FRAME, sampleSize, 0 /* offset */, null);
} else {
// We need the first sample timestamp in the segment before we can output the metadata.
pendingMetadataSampleInfos.addLast(
new MetadataSampleInfo(presentationTimeDeltaUs, sampleSize));
pendingMetadataSampleBytes += sampleSize;
}
}
示例6: parseMehd
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
* Parses an mehd atom (defined in 14496-12).
*/
private static long parseMehd(ParsableByteArray mehd) {
mehd.setPosition(Atom.HEADER_SIZE);
int fullAtom = mehd.readInt();
int version = Atom.parseFullAtomVersion(fullAtom);
return version == 0 ? mehd.readUnsignedInt() : mehd.readUnsignedLongToLong();
}
示例7: parseTfdt
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
* Parses a tfdt atom (defined in 14496-12).
*
* @return baseMediaDecodeTime The sum of the decode durations of all earlier samples in the
* media, expressed in the media's timescale.
*/
private static long parseTfdt(ParsableByteArray tfdt) {
tfdt.setPosition(Atom.HEADER_SIZE);
int fullAtom = tfdt.readInt();
int version = Atom.parseFullAtomVersion(fullAtom);
return version == 1 ? tfdt.readUnsignedLongToLong() : tfdt.readUnsignedInt();
}
示例8: decodeChapterFrame
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static ChapterFrame decodeChapterFrame(ParsableByteArray id3Data, int frameSize,
int majorVersion, boolean unsignedIntFrameSizeHack, int frameHeaderSize,
FramePredicate framePredicate) throws UnsupportedEncodingException {
int framePosition = id3Data.getPosition();
int chapterIdEndIndex = indexOfZeroByte(id3Data.data, framePosition);
String chapterId = new String(id3Data.data, framePosition, chapterIdEndIndex - framePosition,
"ISO-8859-1");
id3Data.setPosition(chapterIdEndIndex + 1);
int startTime = id3Data.readInt();
int endTime = id3Data.readInt();
long startOffset = id3Data.readUnsignedInt();
if (startOffset == 0xFFFFFFFFL) {
startOffset = C.POSITION_UNSET;
}
long endOffset = id3Data.readUnsignedInt();
if (endOffset == 0xFFFFFFFFL) {
endOffset = C.POSITION_UNSET;
}
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 ChapterFrame(chapterId, startTime, endTime, startOffset, endOffset, subFrameArray);
}
示例9: if
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
* Parses pts_time from splice_time(), defined in Section 9.4.1. Returns {@link C#TIME_UNSET}, if
* time_specified_flag is false.
*
* @param sectionData The section data from which the pts_time is parsed.
* @param ptsAdjustment The pts adjustment provided by the splice info section header.
* @return The pts_time defined by splice_time(), or {@link C#TIME_UNSET}, if time_specified_flag
* is false.
*/
/* package */ static long parseSpliceTime(ParsableByteArray sectionData, long ptsAdjustment) {
long firstByte = sectionData.readUnsignedByte();
long ptsTime = C.TIME_UNSET;
if ((firstByte & 0x80) != 0 /* time_specified_flag */) {
// See SCTE35 9.2.1 for more information about pts adjustment.
ptsTime = (firstByte & 0x01) << 32 | sectionData.readUnsignedInt();
ptsTime += ptsAdjustment;
ptsTime &= 0x1FFFFFFFFL;
}
return ptsTime;
}
示例10: parseFromSection
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
static PrivateCommand parseFromSection(ParsableByteArray sectionData,
int commandLength, long ptsAdjustment) {
long identifier = sectionData.readUnsignedInt();
byte[] privateBytes = new byte[commandLength - 4 /* identifier size */];
sectionData.readBytes(privateBytes, 0, privateBytes.length);
return new PrivateCommand(identifier, privateBytes, ptsAdjustment);
}
示例11: readEsInfo
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
* Returns the stream info read from the available descriptors. Sets {@code data}'s position to
* the end of the descriptors.
*
* @param data A buffer with its position set to the start of the first descriptor.
* @param length The length of descriptors to read from the current position in {@code data}.
* @return The stream info read from the available descriptors.
*/
private EsInfo readEsInfo(ParsableByteArray data, int length) {
int descriptorsStartPosition = data.getPosition();
int descriptorsEndPosition = descriptorsStartPosition + length;
int streamType = -1;
String language = null;
List<DvbSubtitleInfo> dvbSubtitleInfos = null;
while (data.getPosition() < descriptorsEndPosition) {
int descriptorTag = data.readUnsignedByte();
int descriptorLength = data.readUnsignedByte();
int positionOfNextDescriptor = data.getPosition() + descriptorLength;
if (descriptorTag == TS_PMT_DESC_REGISTRATION) { // registration_descriptor
long formatIdentifier = data.readUnsignedInt();
if (formatIdentifier == AC3_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_AC3;
} else if (formatIdentifier == E_AC3_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_E_AC3;
} else if (formatIdentifier == HEVC_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_H265;
}
} else if (descriptorTag == TS_PMT_DESC_AC3) { // AC-3_descriptor in DVB (ETSI EN 300 468)
streamType = TS_STREAM_TYPE_AC3;
} else if (descriptorTag == TS_PMT_DESC_EAC3) { // enhanced_AC-3_descriptor
streamType = TS_STREAM_TYPE_E_AC3;
} else if (descriptorTag == TS_PMT_DESC_DTS) { // DTS_descriptor
streamType = TS_STREAM_TYPE_DTS;
} else if (descriptorTag == TS_PMT_DESC_ISO639_LANG) {
language = data.readString(3).trim();
// Audio type is ignored.
} else if (descriptorTag == TS_PMT_DESC_DVBSUBS) {
streamType = TS_STREAM_TYPE_DVBSUBS;
dvbSubtitleInfos = new ArrayList<>();
while (data.getPosition() < positionOfNextDescriptor) {
String dvbLanguage = data.readString(3).trim();
int dvbSubtitlingType = data.readUnsignedByte();
byte[] initializationData = new byte[4];
data.readBytes(initializationData, 0, 4);
dvbSubtitleInfos.add(new DvbSubtitleInfo(dvbLanguage, dvbSubtitlingType,
initializationData));
}
}
// Skip unused bytes of current descriptor.
data.skipBytes(positionOfNextDescriptor - data.getPosition());
}
data.setPosition(descriptorsEndPosition);
return new EsInfo(streamType, language, dvbSubtitleInfos,
Arrays.copyOfRange(data.data, descriptorsStartPosition, descriptorsEndPosition));
}
示例12: verifyBitstreamType
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
public static boolean verifyBitstreamType(ParsableByteArray data) {
return data.bytesLeft() >= 5 && data.readUnsignedByte() == 0x7F && // packet type
data.readUnsignedInt() == 0x464C4143; // ASCII signature "FLAC"
}
示例13: parseTkhd
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
* Parses a tkhd atom (defined in 14496-12).
*
* @return An object containing the parsed data.
*/
private static TkhdData parseTkhd(ParsableByteArray tkhd) {
tkhd.setPosition(Atom.HEADER_SIZE);
int fullAtom = tkhd.readInt();
int version = Atom.parseFullAtomVersion(fullAtom);
tkhd.skipBytes(version == 0 ? 8 : 16);
int trackId = tkhd.readInt();
tkhd.skipBytes(4);
boolean durationUnknown = true;
int durationPosition = tkhd.getPosition();
int durationByteCount = version == 0 ? 4 : 8;
for (int i = 0; i < durationByteCount; i++) {
if (tkhd.data[durationPosition + i] != -1) {
durationUnknown = false;
break;
}
}
long duration;
if (durationUnknown) {
tkhd.skipBytes(durationByteCount);
duration = C.TIME_UNSET;
} else {
duration = version == 0 ? tkhd.readUnsignedInt() : tkhd.readUnsignedLongToLong();
if (duration == 0) {
// 0 duration normally indicates that the file is fully fragmented (i.e. all of the media
// samples are in fragments). Treat as unknown.
duration = C.TIME_UNSET;
}
}
tkhd.skipBytes(16);
int a00 = tkhd.readInt();
int a01 = tkhd.readInt();
tkhd.skipBytes(4);
int a10 = tkhd.readInt();
int a11 = tkhd.readInt();
int rotationDegrees;
int fixedOne = 65536;
if (a00 == 0 && a01 == fixedOne && a10 == -fixedOne && a11 == 0) {
rotationDegrees = 90;
} else if (a00 == 0 && a01 == -fixedOne && a10 == fixedOne && a11 == 0) {
rotationDegrees = 270;
} else if (a00 == -fixedOne && a01 == 0 && a10 == 0 && a11 == -fixedOne) {
rotationDegrees = 180;
} else {
// Only 0, 90, 180 and 270 are supported. Treat anything else as 0.
rotationDegrees = 0;
}
return new TkhdData(trackId, duration, rotationDegrees);
}
示例14: parseSgpd
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static void parseSgpd(ParsableByteArray sbgp, ParsableByteArray sgpd, TrackFragment out)
throws ParserException {
sbgp.setPosition(Atom.HEADER_SIZE);
int sbgpFullAtom = sbgp.readInt();
if (sbgp.readInt() != SAMPLE_GROUP_TYPE_seig) {
// Only seig grouping type is supported.
return;
}
if (Atom.parseFullAtomVersion(sbgpFullAtom) == 1) {
sbgp.skipBytes(4);
}
if (sbgp.readInt() != 1) {
throw new ParserException("Entry count in sbgp != 1 (unsupported).");
}
sgpd.setPosition(Atom.HEADER_SIZE);
int sgpdFullAtom = sgpd.readInt();
if (sgpd.readInt() != SAMPLE_GROUP_TYPE_seig) {
// Only seig grouping type is supported.
return;
}
int sgpdVersion = Atom.parseFullAtomVersion(sgpdFullAtom);
if (sgpdVersion == 1) {
if (sgpd.readUnsignedInt() == 0) {
throw new ParserException("Variable length decription in sgpd found (unsupported)");
}
} else if (sgpdVersion >= 2) {
sgpd.skipBytes(4);
}
if (sgpd.readUnsignedInt() != 1) {
throw new ParserException("Entry count in sgpd != 1 (unsupported).");
}
// CencSampleEncryptionInformationGroupEntry
sgpd.skipBytes(2);
boolean isProtected = sgpd.readUnsignedByte() == 1;
if (!isProtected) {
return;
}
int initVectorSize = sgpd.readUnsignedByte();
byte[] keyId = new byte[16];
sgpd.readBytes(keyId, 0, keyId.length);
out.definesEncryptionData = true;
out.trackEncryptionBox = new TrackEncryptionBox(isProtected, initVectorSize, keyId);
}
示例15: parseSidx
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
* Parses a sidx atom (defined in 14496-12).
*
* @param atom The atom data.
* @param inputPosition The input position of the first byte after the atom.
* @return A pair consisting of the earliest presentation time in microseconds, and the parsed
* {@link ChunkIndex}.
*/
private static Pair<Long, ChunkIndex> parseSidx(ParsableByteArray atom, long inputPosition)
throws ParserException {
atom.setPosition(Atom.HEADER_SIZE);
int fullAtom = atom.readInt();
int version = Atom.parseFullAtomVersion(fullAtom);
atom.skipBytes(4);
long timescale = atom.readUnsignedInt();
long earliestPresentationTime;
long offset = inputPosition;
if (version == 0) {
earliestPresentationTime = atom.readUnsignedInt();
offset += atom.readUnsignedInt();
} else {
earliestPresentationTime = atom.readUnsignedLongToLong();
offset += atom.readUnsignedLongToLong();
}
long earliestPresentationTimeUs = Util.scaleLargeTimestamp(earliestPresentationTime,
C.MICROS_PER_SECOND, timescale);
atom.skipBytes(2);
int referenceCount = atom.readUnsignedShort();
int[] sizes = new int[referenceCount];
long[] offsets = new long[referenceCount];
long[] durationsUs = new long[referenceCount];
long[] timesUs = new long[referenceCount];
long time = earliestPresentationTime;
long timeUs = earliestPresentationTimeUs;
for (int i = 0; i < referenceCount; i++) {
int firstInt = atom.readInt();
int type = 0x80000000 & firstInt;
if (type != 0) {
throw new ParserException("Unhandled indirect reference");
}
long referenceDuration = atom.readUnsignedInt();
sizes[i] = 0x7FFFFFFF & firstInt;
offsets[i] = offset;
// Calculate time and duration values such that any rounding errors are consistent. i.e. That
// timesUs[i] + durationsUs[i] == timesUs[i + 1].
timesUs[i] = timeUs;
time += referenceDuration;
timeUs = Util.scaleLargeTimestamp(time, C.MICROS_PER_SECOND, timescale);
durationsUs[i] = timeUs - timesUs[i];
atom.skipBytes(4);
offset += sizes[i];
}
return Pair.create(earliestPresentationTimeUs,
new ChunkIndex(sizes, offsets, durationsUs, timesUs));
}