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


Java ParsableByteArray.readUnsignedByte方法代码示例

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


在下文中一共展示了ParsableByteArray.readUnsignedByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decodeGeobFrame

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static GeobFrame decodeGeobFrame(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 mimeTypeEndIndex = indexOfZeroByte(data, 0);
  String mimeType = new String(data, 0, mimeTypeEndIndex, "ISO-8859-1");

  int filenameStartIndex = mimeTypeEndIndex + 1;
  int filenameEndIndex = indexOfEos(data, filenameStartIndex, encoding);
  String filename = new String(data, filenameStartIndex, filenameEndIndex - filenameStartIndex,
      charset);

  int descriptionStartIndex = filenameEndIndex + delimiterLength(encoding);
  int descriptionEndIndex = indexOfEos(data, descriptionStartIndex, encoding);
  String description = new String(data, descriptionStartIndex,
      descriptionEndIndex - descriptionStartIndex, charset);

  int objectDataStartIndex = descriptionEndIndex + delimiterLength(encoding);
  byte[] objectData = Arrays.copyOfRange(data, objectDataStartIndex, data.length);

  return new GeobFrame(mimeType, filename, description, objectData);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:27,代码来源:Id3Decoder.java

示例2: skipToNextSync

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Locates the next syncword, advancing the position to the byte that immediately follows it. If a
 * syncword was not located, the position is advanced to the limit.
 *
 * @param pesBuffer The buffer whose position should be advanced.
 * @return Whether a syncword position was found.
 */
private boolean skipToNextSync(ParsableByteArray pesBuffer) {
  while (pesBuffer.bytesLeft() > 0) {
    if (!lastByteWas0B) {
      lastByteWas0B = pesBuffer.readUnsignedByte() == 0x0B;
      continue;
    }
    int secondByte = pesBuffer.readUnsignedByte();
    if (secondByte == 0x77) {
      lastByteWas0B = false;
      return true;
    } else {
      lastByteWas0B = secondByte == 0x0B;
    }
  }
  return false;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:24,代码来源:Ac3Reader.java

示例3: consume

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
@Override
public void consume(ParsableByteArray sectionData) {
  int tableId = sectionData.readUnsignedByte();
  if (tableId != 0x00 /* program_association_section */) {
    // See ISO/IEC 13818-1, section 2.4.4.4 for more information on table id assignment.
    return;
  }
  // section_syntax_indicator(1), '0'(1), reserved(2), section_length(12),
  // transport_stream_id (16), reserved (2), version_number (5), current_next_indicator (1),
  // section_number (8), last_section_number (8)
  sectionData.skipBytes(7);

  int programCount = sectionData.bytesLeft() / 4;
  for (int i = 0; i < programCount; i++) {
    sectionData.readBytes(patScratch, 4);
    int programNumber = patScratch.readBits(16);
    patScratch.skipBits(3); // reserved (3)
    if (programNumber == 0) {
      patScratch.skipBits(13); // network_PID (13)
    } else {
      int pid = patScratch.readBits(13);
      tsPayloadReaders.put(pid, new SectionReader(new PmtReader(pid)));
      remainingPmts++;
    }
  }
  if (mode != MODE_HLS) {
    tsPayloadReaders.remove(TS_PAT_PID);
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:30,代码来源:TsExtractor.java

示例4: consume

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Consumes the unescaped content of an SEI NAL unit, writing the content of any CEA-608 messages
 * as samples to all of the provided outputs.
 *
 * @param presentationTimeUs The presentation time in microseconds for any samples.
 * @param seiBuffer The unescaped SEI NAL unit data, excluding the NAL unit start code and type.
 * @param outputs The outputs to which any samples should be written.
 */
public static void consume(long presentationTimeUs, ParsableByteArray seiBuffer,
    TrackOutput[] outputs) {
  while (seiBuffer.bytesLeft() > 1 /* last byte will be rbsp_trailing_bits */) {
    int payloadType = readNon255TerminatedValue(seiBuffer);
    int payloadSize = readNon255TerminatedValue(seiBuffer);
    // Process the payload.
    if (payloadSize == -1 || payloadSize > seiBuffer.bytesLeft()) {
      // This might occur if we're trying to read an encrypted SEI NAL unit.
      Log.w(TAG, "Skipping remainder of malformed SEI NAL unit.");
      seiBuffer.setPosition(seiBuffer.limit());
    } else if (isSeiMessageCea608(payloadType, payloadSize, seiBuffer)) {
      // Ignore country_code (1) + provider_code (2) + user_identifier (4)
      // + user_data_type_code (1).
      seiBuffer.skipBytes(8);
      // Ignore first three bits: reserved (1) + process_cc_data_flag (1) + zero_bit (1).
      int ccCount = seiBuffer.readUnsignedByte() & 0x1F;
      // Ignore em_data (1)
      seiBuffer.skipBytes(1);
      // Each data packet consists of 24 bits: marker bits (5) + cc_valid (1) + cc_type (2)
      // + cc_data_1 (8) + cc_data_2 (8).
      int sampleLength = ccCount * 3;
      int sampleStartPosition = seiBuffer.getPosition();
      for (TrackOutput output : outputs) {
        seiBuffer.setPosition(sampleStartPosition);
        output.sampleData(seiBuffer, sampleLength);
        output.sampleMetadata(presentationTimeUs, C.BUFFER_FLAG_KEY_FRAME, sampleLength, 0, null);
      }
      // Ignore trailing information in SEI, if any.
      seiBuffer.skipBytes(payloadSize - (10 + ccCount * 3));
    } else {
      seiBuffer.skipBytes(payloadSize);
    }
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:43,代码来源:CeaUtil.java

示例5: checkNextByte

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private boolean checkNextByte(ParsableByteArray data, int expectedValue) {
  if (data.bytesLeft() == 0) {
    return false;
  }
  if (data.readUnsignedByte() != expectedValue) {
    writingSample = false;
  }
  bytesToCheck--;
  return writingSample;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:11,代码来源:DvbSubtitleReader.java

示例6: 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

示例7: readVorbisCommentHeader

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Reads a vorbis comment header.
 *
 * @see <a href="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-640004.2.3">
 *     Vorbis spec/Comment header</a>
 * @param headerData a {@link ParsableByteArray} wrapping the header data.
 * @return a {@link VorbisUtil.CommentHeader} with all the comments.
 * @throws ParserException thrown if invalid capture pattern is detected.
 */
public static CommentHeader readVorbisCommentHeader(ParsableByteArray headerData)
    throws ParserException {

  verifyVorbisHeaderCapturePattern(0x03, headerData, false);
  int length = 7;

  int len = (int) headerData.readLittleEndianUnsignedInt();
  length += 4;
  String vendor = headerData.readString(len);
  length += vendor.length();

  long commentListLen = headerData.readLittleEndianUnsignedInt();
  String[] comments = new String[(int) commentListLen];
  length += 4;
  for (int i = 0; i < commentListLen; i++) {
    len = (int) headerData.readLittleEndianUnsignedInt();
    length += 4;
    comments[i] = headerData.readString(len);
    length += comments[i].length();
  }
  if ((headerData.readUnsignedByte() & 0x01) == 0) {
    throw new ParserException("framing bit expected to be set");
  }
  length += 1;
  return new CommentHeader(vendor, comments, length);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:36,代码来源:VorbisUtil.java

示例8: verifyVorbisHeaderCapturePattern

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

示例9: readVorbisModes

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * This method reads the modes which are located at the very end of the vorbis setup header.
 * That's why we need to partially decode or at least read the entire setup header to know
 * where to start reading the modes.
 *
 * @see <a href="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-650004.2.4">
 *     Vorbis spec/Setup header</a>
 * @param headerData a {@link ParsableByteArray} containing setup header data.
 * @param channels the number of channels.
 * @return an array of {@link Mode}s.
 * @throws ParserException thrown if bit stream is invalid.
 */
public static Mode[] readVorbisModes(ParsableByteArray headerData, int channels)
    throws ParserException {

  verifyVorbisHeaderCapturePattern(0x05, headerData, false);

  int numberOfBooks = headerData.readUnsignedByte() + 1;

  VorbisBitArray bitArray  = new VorbisBitArray(headerData.data);
  bitArray.skipBits(headerData.getPosition() * 8);

  for (int i = 0; i < numberOfBooks; i++) {
    readBook(bitArray);
  }

  int timeCount = bitArray.readBits(6) + 1;
  for (int i = 0; i < timeCount; i++) {
    if (bitArray.readBits(16) != 0x00) {
      throw new ParserException("placeholder of time domain transforms not zeroed out");
    }
  }
  readFloors(bitArray);
  readResidues(bitArray);
  readMappings(channels, bitArray);

  Mode[] modes = readModes(bitArray);
  if (!bitArray.readBit()) {
    throw new ParserException("framing bit after modes not set as expected");
  }
  return modes;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:43,代码来源:VorbisUtil.java

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

示例11: getFlacFrameBlockSize

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private int getFlacFrameBlockSize(ParsableByteArray packet) {
  int blockSizeCode = (packet.data[2] & 0xFF) >> 4;
  switch (blockSizeCode) {
    case 1:
      return 192;
    case 2:
    case 3:
    case 4:
    case 5:
      return 576 << (blockSizeCode - 2);
    case 6:
    case 7:
      // skip the sample number
      packet.skipBytes(FRAME_HEADER_SAMPLE_NUMBER_OFFSET);
      packet.readUtf8EncodedLong();
      int value = blockSizeCode == 6 ? packet.readUnsignedByte() : packet.readUnsignedShort();
      packet.setPosition(0);
      return value + 1;
    case 8:
    case 9:
    case 10:
    case 11:
    case 12:
    case 13:
    case 14:
    case 15:
      return 256 << (blockSizeCode - 8);
  }
  return -1;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:31,代码来源:FlacReader.java

示例12: parseAc3AnnexFFormat

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Returns the AC-3 format given {@code data} containing the AC3SpecificBox according to
 * ETSI TS 102 366 Annex F. The reading position of {@code data} will be modified.
 *
 * @param data The AC3SpecificBox to parse.
 * @param trackId The track identifier to set on the format, or null.
 * @param language The language to set on the format.
 * @param drmInitData {@link DrmInitData} to be included in the format.
 * @return The AC-3 format parsed from data in the header.
 */
public static Format parseAc3AnnexFFormat(ParsableByteArray data, String trackId,
    String language, DrmInitData drmInitData) {
  int fscod = (data.readUnsignedByte() & 0xC0) >> 6;
  int sampleRate = SAMPLE_RATE_BY_FSCOD[fscod];
  int nextByte = data.readUnsignedByte();
  int channelCount = CHANNEL_COUNT_BY_ACMOD[(nextByte & 0x38) >> 3];
  if ((nextByte & 0x04) != 0) { // lfeon
    channelCount++;
  }
  return Format.createAudioSampleFormat(trackId, MimeTypes.AUDIO_AC3, null, Format.NO_VALUE,
      Format.NO_VALUE, channelCount, sampleRate, null, drmInitData, 0, language);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:23,代码来源:Ac3Util.java

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

示例14: 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

示例15: parsePayload

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
@Override
protected void parsePayload(ParsableByteArray data, long timeUs) throws ParserException {
  int packetType = data.readUnsignedByte();
  int compositionTimeMs = data.readUnsignedInt24();
  timeUs += compositionTimeMs * 1000L;
  // Parse avc sequence header in case this was not done before.
  if (packetType == AVC_PACKET_TYPE_SEQUENCE_HEADER && !hasOutputFormat) {
    ParsableByteArray videoSequence = new ParsableByteArray(new byte[data.bytesLeft()]);
    data.readBytes(videoSequence.data, 0, data.bytesLeft());
    AvcConfig avcConfig = AvcConfig.parse(videoSequence);
    nalUnitLengthFieldLength = avcConfig.nalUnitLengthFieldLength;
    // Construct and output the format.
    Format format = Format.createVideoSampleFormat(null, MimeTypes.VIDEO_H264, null,
        Format.NO_VALUE, Format.NO_VALUE, avcConfig.width, avcConfig.height, Format.NO_VALUE,
        avcConfig.initializationData, Format.NO_VALUE, avcConfig.pixelWidthAspectRatio, null);
    output.format(format);
    hasOutputFormat = true;
  } else if (packetType == AVC_PACKET_TYPE_AVC_NALU && hasOutputFormat) {
    // TODO: Deduplicate with Mp4Extractor.
    // Zero the top three bytes of the array that we'll use to decode nal unit lengths, in case
    // they're only 1 or 2 bytes long.
    byte[] nalLengthData = nalLength.data;
    nalLengthData[0] = 0;
    nalLengthData[1] = 0;
    nalLengthData[2] = 0;
    int nalUnitLengthFieldLengthDiff = 4 - nalUnitLengthFieldLength;
    // NAL units are length delimited, but the decoder requires start code delimited units.
    // Loop until we've written the sample to the track output, replacing length delimiters with
    // start codes as we encounter them.
    int bytesWritten = 0;
    int bytesToWrite;
    while (data.bytesLeft() > 0) {
      // Read the NAL length so that we know where we find the next one.
      data.readBytes(nalLength.data, nalUnitLengthFieldLengthDiff, nalUnitLengthFieldLength);
      nalLength.setPosition(0);
      bytesToWrite = nalLength.readUnsignedIntToInt();

      // Write a start code for the current NAL unit.
      nalStartCode.setPosition(0);
      output.sampleData(nalStartCode, 4);
      bytesWritten += 4;

      // Write the payload of the NAL unit.
      output.sampleData(data, bytesToWrite);
      bytesWritten += bytesToWrite;
    }
    output.sampleMetadata(timeUs, frameType == VIDEO_FRAME_KEYFRAME ? C.BUFFER_FLAG_KEY_FRAME : 0,
        bytesWritten, 0, null);
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:51,代码来源:VideoTagPayloadReader.java


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