本文整理汇总了Java中com.google.android.exoplayer2.util.ParsableByteArray.readInt方法的典型用法代码示例。如果您正苦于以下问题:Java ParsableByteArray.readInt方法的具体用法?Java ParsableByteArray.readInt怎么用?Java ParsableByteArray.readInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.exoplayer2.util.ParsableByteArray
的用法示例。
在下文中一共展示了ParsableByteArray.readInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readHeaders
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
@Override
protected boolean readHeaders(ParsableByteArray packet, long position, SetupData setupData)
throws IOException, InterruptedException {
if (!headerRead) {
byte[] metadata = Arrays.copyOf(packet.data, packet.limit());
int channelCount = metadata[9] & 0xFF;
int preskip = ((metadata[11] & 0xFF) << 8) | (metadata[10] & 0xFF);
List<byte[]> initializationData = new ArrayList<>(3);
initializationData.add(metadata);
putNativeOrderLong(initializationData, preskip);
putNativeOrderLong(initializationData, DEFAULT_SEEK_PRE_ROLL_SAMPLES);
setupData.format = Format.createAudioSampleFormat(null, MimeTypes.AUDIO_OPUS, null,
Format.NO_VALUE, Format.NO_VALUE, channelCount, SAMPLE_RATE, initializationData, null, 0,
null);
headerRead = true;
} else {
boolean headerPacket = packet.readInt() == OPUS_CODE;
packet.setPosition(0);
return headerPacket;
}
return true;
}
示例2: parseUdta
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
* Parses a udta atom.
*
* @param udtaAtom The udta (user data) atom to decode.
* @param isQuickTime True for QuickTime media. False otherwise.
* @return Parsed metadata, or null.
*/
public static Metadata parseUdta(Atom.LeafAtom udtaAtom, boolean isQuickTime) {
if (isQuickTime) {
// Meta boxes are regular boxes rather than full boxes in QuickTime. For now, don't try and
// decode one.
return null;
}
ParsableByteArray udtaData = udtaAtom.data;
udtaData.setPosition(Atom.HEADER_SIZE);
while (udtaData.bytesLeft() >= Atom.HEADER_SIZE) {
int atomPosition = udtaData.getPosition();
int atomSize = udtaData.readInt();
int atomType = udtaData.readInt();
if (atomType == Atom.TYPE_meta) {
udtaData.setPosition(atomPosition);
return parseMetaAtom(udtaData, atomPosition + atomSize);
}
udtaData.skipBytes(atomSize - Atom.HEADER_SIZE);
}
return null;
}
示例3: parseVttCueBox
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static Cue parseVttCueBox(ParsableByteArray sampleData, WebvttCue.Builder builder,
int remainingCueBoxBytes) throws SubtitleDecoderException {
builder.reset();
while (remainingCueBoxBytes > 0) {
if (remainingCueBoxBytes < BOX_HEADER_SIZE) {
throw new SubtitleDecoderException("Incomplete vtt cue box header found.");
}
int boxSize = sampleData.readInt();
int boxType = sampleData.readInt();
remainingCueBoxBytes -= BOX_HEADER_SIZE;
int payloadLength = boxSize - BOX_HEADER_SIZE;
String boxPayload = new String(sampleData.data, sampleData.getPosition(), payloadLength);
sampleData.skipBytes(payloadLength);
remainingCueBoxBytes -= payloadLength;
if (boxType == TYPE_sttg) {
WebvttCueParser.parseCueSettingsList(boxPayload, builder);
} else if (boxType == TYPE_payl) {
WebvttCueParser.parseCueText(null, boxPayload.trim(), builder,
Collections.<WebvttCssStyle>emptyList());
} else {
// Other VTTCueBox children are still not supported and are ignored.
}
}
return builder.build();
}
示例4: 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);
}
示例5: parseSchiFromParent
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static TrackEncryptionBox parseSchiFromParent(ParsableByteArray parent, int position,
int size) {
int childPosition = position + Atom.HEADER_SIZE;
while (childPosition - position < size) {
parent.setPosition(childPosition);
int childAtomSize = parent.readInt();
int childAtomType = parent.readInt();
if (childAtomType == Atom.TYPE_tenc) {
parent.skipBytes(6);
boolean defaultIsEncrypted = parent.readUnsignedByte() == 1;
int defaultInitVectorSize = parent.readUnsignedByte();
byte[] defaultKeyId = new byte[16];
parent.readBytes(defaultKeyId, 0, defaultKeyId.length);
return new TrackEncryptionBox(defaultIsEncrypted, defaultInitVectorSize, defaultKeyId);
}
childPosition += childAtomSize;
}
return null;
}
示例6: parseIndexAndCountAttribute
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static TextInformationFrame parseIndexAndCountAttribute(int type, String attributeName,
ParsableByteArray data) {
int atomSize = data.readInt();
int atomType = data.readInt();
if (atomType == Atom.TYPE_data && atomSize >= 22) {
data.skipBytes(10); // version (1), flags (3), empty (4), empty (2)
int index = data.readUnsignedShort();
if (index > 0) {
String value = "" + index;
int count = data.readUnsignedShort();
if (count > 0) {
value += "/" + count;
}
return new TextInformationFrame(attributeName, null, value);
}
}
Log.w(TAG, "Failed to parse index/count attribute: " + Atom.getAtomTypeString(type));
return null;
}
示例7: 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();
}
示例8: parseUint8AttributeValue
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static int parseUint8AttributeValue(ParsableByteArray data) {
data.skipBytes(4); // atomSize
int atomType = data.readInt();
if (atomType == Atom.TYPE_data) {
data.skipBytes(8); // version (1), flags (3), empty (4)
return data.readUnsignedByte();
}
Log.w(TAG, "Failed to parse uint8 attribute value");
return -1;
}
示例9: parseMetaAtom
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static Metadata parseMetaAtom(ParsableByteArray meta, int limit) {
meta.skipBytes(Atom.FULL_HEADER_SIZE);
while (meta.getPosition() < limit) {
int atomPosition = meta.getPosition();
int atomSize = meta.readInt();
int atomType = meta.readInt();
if (atomType == Atom.TYPE_ilst) {
meta.setPosition(atomPosition);
return parseIlst(meta, atomPosition + atomSize);
}
meta.skipBytes(atomSize - Atom.HEADER_SIZE);
}
return null;
}
示例10: 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();
}
示例11: parseSaiz
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static void parseSaiz(TrackEncryptionBox encryptionBox, ParsableByteArray saiz,
TrackFragment out) throws ParserException {
int vectorSize = encryptionBox.initializationVectorSize;
saiz.setPosition(Atom.HEADER_SIZE);
int fullAtom = saiz.readInt();
int flags = Atom.parseFullAtomFlags(fullAtom);
if ((flags & 0x01) == 1) {
saiz.skipBytes(8);
}
int defaultSampleInfoSize = saiz.readUnsignedByte();
int sampleCount = saiz.readUnsignedIntToInt();
if (sampleCount != out.sampleCount) {
throw new ParserException("Length mismatch: " + sampleCount + ", " + out.sampleCount);
}
int totalSize = 0;
if (defaultSampleInfoSize == 0) {
boolean[] sampleHasSubsampleEncryptionTable = out.sampleHasSubsampleEncryptionTable;
for (int i = 0; i < sampleCount; i++) {
int sampleInfoSize = saiz.readUnsignedByte();
totalSize += sampleInfoSize;
sampleHasSubsampleEncryptionTable[i] = sampleInfoSize > vectorSize;
}
} else {
boolean subsampleEncryption = defaultSampleInfoSize > vectorSize;
totalSize += defaultSampleInfoSize * sampleCount;
Arrays.fill(out.sampleHasSubsampleEncryptionTable, 0, sampleCount, subsampleEncryption);
}
out.initEncryptionData(totalSize);
}
示例12: findEsdsPosition
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
* Returns the position of the esds box within a parent, or {@link C#POSITION_UNSET} if no esds
* box is found
*/
private static int findEsdsPosition(ParsableByteArray parent, int position, int size) {
int childAtomPosition = parent.getPosition();
while (childAtomPosition - position < size) {
parent.setPosition(childAtomPosition);
int childAtomSize = parent.readInt();
Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
int childType = parent.readInt();
if (childType == Atom.TYPE_esds) {
return childAtomPosition;
}
childAtomPosition += childAtomSize;
}
return C.POSITION_UNSET;
}
示例13: parseTfhd
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
* Parses a tfhd atom (defined in 14496-12), updates the corresponding {@link TrackFragment} and
* returns the {@link TrackBundle} of the corresponding {@link Track}. If the tfhd does not refer
* to any {@link TrackBundle}, {@code null} is returned and no changes are made.
*
* @param tfhd The tfhd atom to decode.
* @param trackBundles The track bundles, one of which corresponds to the tfhd atom being parsed.
* @return The {@link TrackBundle} to which the {@link TrackFragment} belongs, or null if the tfhd
* does not refer to any {@link TrackBundle}.
*/
private static TrackBundle parseTfhd(ParsableByteArray tfhd,
SparseArray<TrackBundle> trackBundles, int flags) {
tfhd.setPosition(Atom.HEADER_SIZE);
int fullAtom = tfhd.readInt();
int atomFlags = Atom.parseFullAtomFlags(fullAtom);
int trackId = tfhd.readInt();
TrackBundle trackBundle = trackBundles.get((flags & FLAG_SIDELOADED) == 0 ? trackId : 0);
if (trackBundle == null) {
return null;
}
if ((atomFlags & 0x01 /* base_data_offset_present */) != 0) {
long baseDataPosition = tfhd.readUnsignedLongToLong();
trackBundle.fragment.dataPosition = baseDataPosition;
trackBundle.fragment.auxiliaryDataPosition = baseDataPosition;
}
DefaultSampleValues defaultSampleValues = trackBundle.defaultSampleValues;
int defaultSampleDescriptionIndex =
((atomFlags & 0x02 /* default_sample_description_index_present */) != 0)
? tfhd.readUnsignedIntToInt() - 1 : defaultSampleValues.sampleDescriptionIndex;
int defaultSampleDuration = ((atomFlags & 0x08 /* default_sample_duration_present */) != 0)
? tfhd.readUnsignedIntToInt() : defaultSampleValues.duration;
int defaultSampleSize = ((atomFlags & 0x10 /* default_sample_size_present */) != 0)
? tfhd.readUnsignedIntToInt() : defaultSampleValues.size;
int defaultSampleFlags = ((atomFlags & 0x20 /* default_sample_flags_present */) != 0)
? tfhd.readUnsignedIntToInt() : defaultSampleValues.flags;
trackBundle.fragment.header = new DefaultSampleValues(defaultSampleDescriptionIndex,
defaultSampleDuration, defaultSampleSize, defaultSampleFlags);
return trackBundle;
}
示例14: parseSinfFromParent
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static Pair<Integer, TrackEncryptionBox> parseSinfFromParent(ParsableByteArray parent,
int position, int size) {
int childPosition = position + Atom.HEADER_SIZE;
boolean isCencScheme = false;
TrackEncryptionBox trackEncryptionBox = null;
Integer dataFormat = null;
while (childPosition - position < size) {
parent.setPosition(childPosition);
int childAtomSize = parent.readInt();
int childAtomType = parent.readInt();
if (childAtomType == Atom.TYPE_frma) {
dataFormat = parent.readInt();
} else if (childAtomType == Atom.TYPE_schm) {
parent.skipBytes(4);
isCencScheme = parent.readInt() == TYPE_cenc;
} else if (childAtomType == Atom.TYPE_schi) {
trackEncryptionBox = parseSchiFromParent(parent, childPosition, childAtomSize);
}
childPosition += childAtomSize;
}
if (isCencScheme) {
Assertions.checkArgument(dataFormat != null, "frma atom is mandatory");
Assertions.checkArgument(trackEncryptionBox != null, "schi->tenc atom is mandatory");
return Pair.create(dataFormat, trackEncryptionBox);
} else {
return null;
}
}
示例15: parseTextAttribute
import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static TextInformationFrame parseTextAttribute(int type, String id,
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 TextInformationFrame(id, null, value);
}
Log.w(TAG, "Failed to parse text attribute: " + Atom.getAtomTypeString(type));
return null;
}