当前位置: 首页>>代码示例>>Java>>正文


Java ParsableByteArray.readUnsignedIntToInt方法代码示例

本文整理汇总了Java中com.google.android.exoplayer2.util.ParsableByteArray.readUnsignedIntToInt方法的典型用法代码示例。如果您正苦于以下问题:Java ParsableByteArray.readUnsignedIntToInt方法的具体用法?Java ParsableByteArray.readUnsignedIntToInt怎么用?Java ParsableByteArray.readUnsignedIntToInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.exoplayer2.util.ParsableByteArray的用法示例。


在下文中一共展示了ParsableByteArray.readUnsignedIntToInt方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:33,代码来源:AtomParsers.java

示例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();
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:25,代码来源:FragmentedMp4Extractor.java

示例3: parseSenc

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
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);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:22,代码来源:FragmentedMp4Extractor.java

示例4: parsePsshAtom

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Parses the UUID and scheme specific data from a PSSH atom. Version 0 and 1 PSSH atoms are
 * supported.
 *
 * @param atom The atom to parse.
 * @return A pair consisting of the parsed UUID and scheme specific data. Null if the input is
 *     not a valid PSSH atom, or if the PSSH atom has an unsupported version.
 */
private static Pair<UUID, byte[]> parsePsshAtom(byte[] atom) {
  ParsableByteArray atomData = new ParsableByteArray(atom);
  if (atomData.limit() < Atom.FULL_HEADER_SIZE + 16 /* UUID */ + 4 /* DataSize */) {
    // Data too short.
    return null;
  }
  atomData.setPosition(0);
  int atomSize = atomData.readInt();
  if (atomSize != atomData.bytesLeft() + 4) {
    // Not an atom, or incorrect atom size.
    return null;
  }
  int atomType = atomData.readInt();
  if (atomType != Atom.TYPE_pssh) {
    // Not an atom, or incorrect atom type.
    return null;
  }
  int atomVersion = Atom.parseFullAtomVersion(atomData.readInt());
  if (atomVersion > 1) {
    Log.w(TAG, "Unsupported pssh version: " + atomVersion);
    return null;
  }
  UUID uuid = new UUID(atomData.readLong(), atomData.readLong());
  if (atomVersion == 1) {
    int keyIdCount = atomData.readUnsignedIntToInt();
    atomData.skipBytes(16 * keyIdCount);
  }
  int dataSize = atomData.readUnsignedIntToInt();
  if (dataSize != atomData.bytesLeft()) {
    // Incorrect dataSize.
    return null;
  }
  byte[] data = new byte[dataSize];
  atomData.readBytes(data, 0, dataSize);
  return Pair.create(uuid, data);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:45,代码来源:PsshAtomUtil.java

示例5: ChunkIterator

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
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 = C.INDEX_UNSET;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:13,代码来源:AtomParsers.java

示例6: parseTrex

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Parses a trex atom (defined in 14496-12).
 */
private static Pair<Integer, DefaultSampleValues> parseTrex(ParsableByteArray trex) {
  trex.setPosition(Atom.FULL_HEADER_SIZE);
  int trackId = trex.readInt();
  int defaultSampleDescriptionIndex = trex.readUnsignedIntToInt() - 1;
  int defaultSampleDuration = trex.readUnsignedIntToInt();
  int defaultSampleSize = trex.readUnsignedIntToInt();
  int defaultSampleFlags = trex.readInt();

  return Pair.create(trackId, new DefaultSampleValues(defaultSampleDescriptionIndex,
      defaultSampleDuration, defaultSampleSize, defaultSampleFlags));
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:15,代码来源:FragmentedMp4Extractor.java

示例7: parseTruns

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static void parseTruns(ContainerAtom traf, TrackBundle trackBundle, long decodeTime,
    @Flags int flags) {
  int trunCount = 0;
  int totalSampleCount = 0;
  List<LeafAtom> leafChildren = traf.leafChildren;
  int leafChildrenSize = leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom atom = leafChildren.get(i);
    if (atom.type == Atom.TYPE_trun) {
      ParsableByteArray trunData = atom.data;
      trunData.setPosition(Atom.FULL_HEADER_SIZE);
      int trunSampleCount = trunData.readUnsignedIntToInt();
      if (trunSampleCount > 0) {
        totalSampleCount += trunSampleCount;
        trunCount++;
      }
    }
  }
  trackBundle.currentTrackRunIndex = 0;
  trackBundle.currentSampleInTrackRun = 0;
  trackBundle.currentSampleIndex = 0;
  trackBundle.fragment.initTables(trunCount, totalSampleCount);

  int trunIndex = 0;
  int trunStartPosition = 0;
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom trun = leafChildren.get(i);
    if (trun.type == Atom.TYPE_trun) {
      trunStartPosition = parseTrun(trackBundle, trunIndex++, decodeTime, flags, trun.data,
          trunStartPosition);
    }
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:34,代码来源:FragmentedMp4Extractor.java

示例8: 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);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:32,代码来源:FragmentedMp4Extractor.java

示例9: 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;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:41,代码来源:FragmentedMp4Extractor.java

示例10: readAmfStrictArray

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Read an array from an AMF encoded buffer.
 *
 * @param data The buffer from which to read.
 * @return The value read from the buffer.
 */
private static ArrayList<Object> readAmfStrictArray(ParsableByteArray data) {
  int count = data.readUnsignedIntToInt();
  ArrayList<Object> list = new ArrayList<>(count);
  for (int i = 0; i < count; i++) {
    int type = readAmfType(data);
    list.add(readAmfData(data, type));
  }
  return list;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:16,代码来源:ScriptTagPayloadReader.java

示例11: readAmfEcmaArray

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Read an ECMA array from an AMF encoded buffer.
 *
 * @param data The buffer from which to read.
 * @return The value read from the buffer.
 */
private static HashMap<String, Object> readAmfEcmaArray(ParsableByteArray data) {
  int count = data.readUnsignedIntToInt();
  HashMap<String, Object> array = new HashMap<>(count);
  for (int i = 0; i < count; i++) {
    String key = readAmfString(data);
    int type = readAmfType(data);
    array.put(key, readAmfData(data, type));
  }
  return array;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:17,代码来源:ScriptTagPayloadReader.java

示例12: create

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Returns a {@link XingSeeker} for seeking in the stream, if required information is present.
 * Returns {@code null} if not. On returning, {@code frame}'s position is not specified so the
 * caller should reset it.
 *
 * @param mpegAudioHeader The MPEG audio header associated with the frame.
 * @param frame The data in this audio frame, with its position set to immediately after the
 *    'Xing' or 'Info' tag.
 * @param position The position (byte offset) of the start of this frame in the stream.
 * @param inputLength The length of the stream in bytes.
 * @return A {@link XingSeeker} for seeking in the stream, or {@code null} if the required
 *     information is not present.
 */
public static XingSeeker create(MpegAudioHeader mpegAudioHeader, ParsableByteArray frame,
    long position, long inputLength) {
  int samplesPerFrame = mpegAudioHeader.samplesPerFrame;
  int sampleRate = mpegAudioHeader.sampleRate;
  long firstFramePosition = position + mpegAudioHeader.frameSize;

  int flags = frame.readInt();
  int frameCount;
  if ((flags & 0x01) != 0x01 || (frameCount = frame.readUnsignedIntToInt()) == 0) {
    // If the frame count is missing/invalid, the header can't be used to determine the duration.
    return null;
  }
  long durationUs = Util.scaleLargeTimestamp(frameCount, samplesPerFrame * C.MICROS_PER_SECOND,
      sampleRate);
  if ((flags & 0x06) != 0x06) {
    // If the size in bytes or table of contents is missing, the stream is not seekable.
    return new XingSeeker(firstFramePosition, durationUs, inputLength);
  }

  long sizeBytes = frame.readUnsignedIntToInt();
  frame.skipBytes(1);
  long[] tableOfContents = new long[99];
  for (int i = 0; i < 99; i++) {
    tableOfContents[i] = frame.readUnsignedByte();
  }

  // TODO: Handle encoder delay and padding in 3 bytes offset by xingBase + 213 bytes:
  // delay = (frame.readUnsignedByte() << 4) + (frame.readUnsignedByte() >> 4);
  // padding = ((frame.readUnsignedByte() & 0x0F) << 8) + frame.readUnsignedByte();
  return new XingSeeker(firstFramePosition, durationUs, inputLength, tableOfContents,
      sizeBytes, mpegAudioHeader.frameSize);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:46,代码来源:XingSeeker.java

示例13: parsePaspFromParent

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static float parsePaspFromParent(ParsableByteArray parent, int position) {
  parent.setPosition(position + Atom.HEADER_SIZE);
  int hSpacing = parent.readUnsignedIntToInt();
  int vSpacing = parent.readUnsignedIntToInt();
  return (float) hSpacing / vSpacing;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:7,代码来源:AtomParsers.java

示例14: create

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Returns a {@link VbriSeeker} for seeking in the stream, if required information is present.
 * Returns {@code null} if not. On returning, {@code frame}'s position is not specified so the
 * caller should reset it.
 *
 * @param mpegAudioHeader The MPEG audio header associated with the frame.
 * @param frame The data in this audio frame, with its position set to immediately after the
 *     'VBRI' tag.
 * @param position The position (byte offset) of the start of this frame in the stream.
 * @param inputLength The length of the stream in bytes.
 * @return A {@link VbriSeeker} for seeking in the stream, or {@code null} if the required
 *     information is not present.
 */
public static VbriSeeker create(MpegAudioHeader mpegAudioHeader, ParsableByteArray frame,
    long position, long inputLength) {
  frame.skipBytes(10);
  int numFrames = frame.readInt();
  if (numFrames <= 0) {
    return null;
  }
  int sampleRate = mpegAudioHeader.sampleRate;
  long durationUs = Util.scaleLargeTimestamp(numFrames,
      C.MICROS_PER_SECOND * (sampleRate >= 32000 ? 1152 : 576), sampleRate);
  int entryCount = frame.readUnsignedShort();
  int scale = frame.readUnsignedShort();
  int entrySize = frame.readUnsignedShort();
  frame.skipBytes(2);

  // Skip the frame containing the VBRI header.
  position += mpegAudioHeader.frameSize;

  // Read table of contents entries.
  long[] timesUs = new long[entryCount + 1];
  long[] positions = new long[entryCount + 1];
  timesUs[0] = 0L;
  positions[0] = position;
  for (int index = 1; index < timesUs.length; index++) {
    int segmentSize;
    switch (entrySize) {
      case 1:
        segmentSize = frame.readUnsignedByte();
        break;
      case 2:
        segmentSize = frame.readUnsignedShort();
        break;
      case 3:
        segmentSize = frame.readUnsignedInt24();
        break;
      case 4:
        segmentSize = frame.readUnsignedIntToInt();
        break;
      default:
        return null;
    }
    position += segmentSize * scale;
    timesUs[index] = index * durationUs / entryCount;
    positions[index] =
        inputLength == C.LENGTH_UNSET ? position : Math.min(inputLength, position);
  }
  return new VbriSeeker(timesUs, positions, durationUs);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:62,代码来源:VbriSeeker.java


注:本文中的com.google.android.exoplayer2.util.ParsableByteArray.readUnsignedIntToInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。