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


Java ExtractorInput.peekFully方法代码示例

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


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

示例1: sniff

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
@Override
public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
  byte[] buffer = tsPacketBuffer.data;
  input.peekFully(buffer, 0, BUFFER_SIZE);
  for (int j = 0; j < TS_PACKET_SIZE; j++) {
    for (int i = 0; true; i++) {
      if (i == BUFFER_PACKET_COUNT) {
        input.skipFully(j);
        return true;
      }
      if (buffer[j + i * TS_PACKET_SIZE] != TS_SYNC_BYTE) {
        break;
      }
    }
  }
  return false;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:18,代码来源:TsExtractor.java

示例2: sniff

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
@Override
public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
  try {
    OggPageHeader header = new OggPageHeader();
    if (!header.populate(input, true) || (header.type & 0x02) != 0x02) {
      return false;
    }

    int length = Math.min(header.bodySize, MAX_VERIFICATION_BYTES);
    ParsableByteArray scratch = new ParsableByteArray(length);
    input.peekFully(scratch.data, 0, length);

    if (FlacReader.verifyBitstreamType(resetPosition(scratch))) {
      streamReader = new FlacReader();
    } else if (VorbisReader.verifyBitstreamType(resetPosition(scratch))) {
      streamReader = new VorbisReader();
    } else if (OpusReader.verifyBitstreamType(resetPosition(scratch))) {
      streamReader = new OpusReader();
    } else {
      return false;
    }
    return true;
  } catch (ParserException e) {
    return false;
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:27,代码来源:OggExtractor.java

示例3: maybeResyncToNextLevel1Element

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
/**
 * Does a byte by byte search to try and find the next level 1 element. This method is called if
 * some invalid data is encountered in the parser.
 *
 * @param input The {@link ExtractorInput} from which data has to be read.
 * @return id of the next level 1 element that has been found.
 * @throws EOFException If the end of input was encountered when searching for the next level 1
 *     element.
 * @throws IOException If an error occurs reading from the input.
 * @throws InterruptedException If the thread is interrupted.
 */
private long maybeResyncToNextLevel1Element(ExtractorInput input) throws IOException,
    InterruptedException {
  input.resetPeekPosition();
  while (true) {
    input.peekFully(scratch, 0, MAX_ID_BYTES);
    int varintLength = VarintReader.parseUnsignedVarintLength(scratch[0]);
    if (varintLength != C.LENGTH_UNSET && varintLength <= MAX_ID_BYTES) {
      int potentialId = (int) VarintReader.assembleVarint(scratch, varintLength, false);
      if (output.isLevel1Element(potentialId)) {
        input.skipFully(varintLength);
        return potentialId;
      }
    }
    input.skipFully(1);
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:28,代码来源:DefaultEbmlReader.java

示例4: readUint

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
/**
 * Peeks a variable-length unsigned EBML integer from the input.
 */
private long readUint(ExtractorInput input) throws IOException, InterruptedException {
  input.peekFully(scratch.data, 0, 1);
  int value = scratch.data[0] & 0xFF;
  if (value == 0) {
    return Long.MIN_VALUE;
  }
  int mask = 0x80;
  int length = 0;
  while ((value & mask) == 0) {
    mask >>= 1;
    length++;
  }
  value &= ~mask;
  input.peekFully(scratch.data, 1, length);
  for (int i = 0; i < length; i++) {
    value <<= 8;
    value += scratch.data[i + 1] & 0xFF;
  }
  peekLength += length + 1;
  return value;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:25,代码来源:Sniffer.java

示例5: sniff

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
@Override
public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
  byte[] scratch = new byte[14];
  input.peekFully(scratch, 0, 14);

  // Verify the PACK_START_CODE for the first 4 bytes
  if (PACK_START_CODE != (((scratch[0] & 0xFF) << 24) | ((scratch[1] & 0xFF) << 16)
      | ((scratch[2] & 0xFF) << 8) | (scratch[3] & 0xFF))) {
    return false;
  }
  // Verify the 01xxx1xx marker on the 5th byte
  if ((scratch[4] & 0xC4) != 0x44) {
    return false;
  }
  // Verify the xxxxx1xx marker on the 7th byte
  if ((scratch[6] & 0x04) != 0x04) {
    return false;
  }
  // Verify the xxxxx1xx marker on the 9th byte
  if ((scratch[8] & 0x04) != 0x04) {
    return false;
  }
  // Verify the xxxxxxx1 marker on the 10th byte
  if ((scratch[9] & 0x01) != 0x01) {
    return false;
  }
  // Verify the xxxxxx11 marker on the 13th byte
  if ((scratch[12] & 0x03) != 0x03) {
    return false;
  }
  // Read the stuffing length from the 14th byte (last 3 bits)
  int packStuffingLength = scratch[13] & 0x07;
  input.advancePeekPosition(packStuffingLength);
  // Now check that the next 3 bytes are the beginning of an MPEG start code
  input.peekFully(scratch, 0, 3);
  return (PACKET_START_CODE_PREFIX == (((scratch[0] & 0xFF) << 16) | ((scratch[1] & 0xFF) << 8)
      | (scratch[2] & 0xFF)));
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:39,代码来源:PsExtractor.java

示例6: peek

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
/**
 * Peeks and returns a {@link ChunkHeader}.
 *
 * @param input Input stream to peek the chunk header from.
 * @param scratch Buffer for temporary use.
 * @throws IOException If peeking from the input fails.
 * @throws InterruptedException If interrupted while peeking from input.
 * @return A new {@code ChunkHeader} peeked from {@code input}.
 */
public static ChunkHeader peek(ExtractorInput input, ParsableByteArray scratch)
    throws IOException, InterruptedException {
  input.peekFully(scratch.data, 0, SIZE_IN_BYTES);
  scratch.setPosition(0);

  int id = scratch.readInt();
  long size = scratch.readLittleEndianUnsignedInt();

  return new ChunkHeader(id, size);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:20,代码来源:WavHeaderReader.java

示例7: skipToNextPage

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
/**
 * Skips to the next page. Searches for the next page header.
 *
 * @param input The {@code ExtractorInput} to skip to the next page.
 * @param until Searches until this position.
 * @return true if the next page is found.
 * @throws IOException thrown if peeking/reading from the input fails.
 * @throws InterruptedException thrown if interrupted while peeking/reading from the input.
 */
//@VisibleForTesting
boolean skipToNextPage(ExtractorInput input, long until)
    throws IOException, InterruptedException {
  until = Math.min(until + 3, endPosition);
  byte[] buffer = new byte[2048];
  int peekLength = buffer.length;
  while (true) {
    if (input.getPosition() + peekLength > until) {
      // Make sure to not peek beyond the end of the input.
      peekLength = (int) (until - input.getPosition());
      if (peekLength < 4) {
        // Not found until end.
        return false;
      }
    }
    input.peekFully(buffer, 0, peekLength, false);
    for (int i = 0; i < peekLength - 3; i++) {
      if (buffer[i] == 'O' && buffer[i + 1] == 'g' && buffer[i + 2] == 'g'
          && buffer[i + 3] == 'S') {
        // Match! Skip to the start of the pattern.
        input.skipFully(i);
        return true;
      }
    }
    // Overlap by not skipping the entire peekLength.
    input.skipFully(peekLength - 3);
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:38,代码来源:DefaultOggSeeker.java

示例8: sniff

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
@Override
public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
  // Check if file starts with "FLV" tag
  input.peekFully(scratch.data, 0, 3);
  scratch.setPosition(0);
  if (scratch.readUnsignedInt24() != FLV_TAG) {
    return false;
  }

  // Checking reserved flags are set to 0
  input.peekFully(scratch.data, 0, 2);
  scratch.setPosition(0);
  if ((scratch.readUnsignedShort() & 0xFA) != 0) {
    return false;
  }

  // Read data offset
  input.peekFully(scratch.data, 0, 4);
  scratch.setPosition(0);
  int dataOffset = scratch.readInt();

  input.resetPeekPosition();
  input.advancePeekPosition(dataOffset);

  // Checking first "previous tag size" is set to 0
  input.peekFully(scratch.data, 0, 4);
  scratch.setPosition(0);

  return scratch.readInt() == 0;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:31,代码来源:FlvExtractor.java

示例9: readSample

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
private int readSample(ExtractorInput extractorInput) throws IOException, InterruptedException {
  if (sampleBytesRemaining == 0) {
    extractorInput.resetPeekPosition();
    if (!extractorInput.peekFully(scratch.data, 0, 4, true)) {
      return RESULT_END_OF_INPUT;
    }
    scratch.setPosition(0);
    int sampleHeaderData = scratch.readInt();
    if ((sampleHeaderData & HEADER_MASK) != (synchronizedHeaderData & HEADER_MASK)
        || MpegAudioHeader.getFrameSize(sampleHeaderData) == C.LENGTH_UNSET) {
      // We have lost synchronization, so attempt to resynchronize starting at the next byte.
      extractorInput.skipFully(1);
      synchronizedHeaderData = 0;
      return RESULT_CONTINUE;
    }
    MpegAudioHeader.populateHeader(sampleHeaderData, synchronizedHeader);
    if (basisTimeUs == C.TIME_UNSET) {
      basisTimeUs = seeker.getTimeUs(extractorInput.getPosition());
      if (forcedFirstSampleTimestampUs != C.TIME_UNSET) {
        long embeddedFirstSampleTimestampUs = seeker.getTimeUs(0);
        basisTimeUs += forcedFirstSampleTimestampUs - embeddedFirstSampleTimestampUs;
      }
    }
    sampleBytesRemaining = synchronizedHeader.frameSize;
  }
  int bytesAppended = trackOutput.sampleData(extractorInput, sampleBytesRemaining, true);
  if (bytesAppended == C.RESULT_END_OF_INPUT) {
    return RESULT_END_OF_INPUT;
  }
  sampleBytesRemaining -= bytesAppended;
  if (sampleBytesRemaining > 0) {
    return RESULT_CONTINUE;
  }
  long timeUs = basisTimeUs + (samplesRead * C.MICROS_PER_SECOND / synchronizedHeader.sampleRate);
  trackOutput.sampleMetadata(timeUs, C.BUFFER_FLAG_KEY_FRAME, synchronizedHeader.frameSize, 0,
      null);
  samplesRead += synchronizedHeader.samplesPerFrame;
  sampleBytesRemaining = 0;
  return RESULT_CONTINUE;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:41,代码来源:Mp3Extractor.java

示例10: peekId3Data

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
/**
 * Peeks ID3 data from the input, including gapless playback information.
 *
 * @param input The {@link ExtractorInput} from which data should be peeked.
 * @throws IOException If an error occurred peeking from the input.
 * @throws InterruptedException If the thread was interrupted.
 */
private void peekId3Data(ExtractorInput input) throws IOException, InterruptedException {
  int peekedId3Bytes = 0;
  while (true) {
    input.peekFully(scratch.data, 0, Id3Decoder.ID3_HEADER_LENGTH);
    scratch.setPosition(0);
    if (scratch.readUnsignedInt24() != Id3Decoder.ID3_TAG) {
      // Not an ID3 tag.
      break;
    }
    scratch.skipBytes(3); // Skip major version, minor version and flags.
    int framesLength = scratch.readSynchSafeInt();
    int tagLength = Id3Decoder.ID3_HEADER_LENGTH + framesLength;

    if (metadata == null) {
      byte[] id3Data = new byte[tagLength];
      System.arraycopy(scratch.data, 0, id3Data, 0, Id3Decoder.ID3_HEADER_LENGTH);
      input.peekFully(id3Data, Id3Decoder.ID3_HEADER_LENGTH, framesLength);
      // We need to parse enough ID3 metadata to retrieve any gapless playback information even
      // if ID3 metadata parsing is disabled.
      Id3Decoder.FramePredicate id3FramePredicate = (flags & FLAG_DISABLE_ID3_METADATA) != 0
          ? GaplessInfoHolder.GAPLESS_INFO_ID3_FRAME_PREDICATE : null;
      metadata = new Id3Decoder(id3FramePredicate).decode(id3Data, tagLength);
      if (metadata != null) {
        gaplessInfoHolder.setFromMetadata(metadata);
      }
    } else {
      input.advancePeekPosition(framesLength);
    }

    peekedId3Bytes += tagLength;
  }

  input.resetPeekPosition();
  input.advancePeekPosition(peekedId3Bytes);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:43,代码来源:Mp3Extractor.java

示例11: parseId3

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
/**
 * Peeks data from the input and parses ID3 metadata.
 *
 * @param input The {@link ExtractorInput} from which data should be peeked.
 * @param out The {@link GaplessInfoHolder} to populate.
 * @throws IOException If an error occurred peeking from the input.
 * @throws InterruptedException If the thread was interrupted.
 */
public static void parseId3(ExtractorInput input, GaplessInfoHolder out)
    throws IOException, InterruptedException {
  ParsableByteArray scratch = new ParsableByteArray(10);
  int peekedId3Bytes = 0;
  while (true) {
    input.peekFully(scratch.data, 0, 10);
    scratch.setPosition(0);
    if (scratch.readUnsignedInt24() != ID3_TAG) {
      break;
    }

    int majorVersion = scratch.readUnsignedByte();
    int minorVersion = scratch.readUnsignedByte();
    int flags = scratch.readUnsignedByte();
    int length = scratch.readSynchSafeInt();
    if (!out.hasGaplessInfo() && canParseMetadata(majorVersion, minorVersion, flags, length)) {
      byte[] frame = new byte[length];
      input.peekFully(frame, 0, length);
      parseGaplessInfo(new ParsableByteArray(frame), majorVersion, flags, out);
    } else {
      input.advancePeekPosition(length);
    }

    peekedId3Bytes += 10 + length;
  }
  input.resetPeekPosition();
  input.advancePeekPosition(peekedId3Bytes);
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:37,代码来源:Id3Util.java

示例12: sniff

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
@Override
public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
  // Skip any ID3 headers.
  ParsableByteArray scratch = new ParsableByteArray(10);
  ParsableBitArray scratchBits = new ParsableBitArray(scratch.data);
  int startPosition = 0;
  while (true) {
    input.peekFully(scratch.data, 0, 10);
    scratch.setPosition(0);
    if (scratch.readUnsignedInt24() != ID3_TAG) {
      break;
    }
    scratch.skipBytes(3);
    int length = scratch.readSynchSafeInt();
    startPosition += 10 + length;
    input.advancePeekPosition(length);
  }
  input.resetPeekPosition();
  input.advancePeekPosition(startPosition);

  // Try to find four or more consecutive AAC audio frames, exceeding the MPEG TS packet size.
  int headerPosition = startPosition;
  int validFramesSize = 0;
  int validFramesCount = 0;
  while (true) {
    input.peekFully(scratch.data, 0, 2);
    scratch.setPosition(0);
    int syncBytes = scratch.readUnsignedShort();
    if ((syncBytes & 0xFFF6) != 0xFFF0) {
      validFramesCount = 0;
      validFramesSize = 0;
      input.resetPeekPosition();
      if (++headerPosition - startPosition >= MAX_SNIFF_BYTES) {
        return false;
      }
      input.advancePeekPosition(headerPosition);
    } else {
      if (++validFramesCount >= 4 && validFramesSize > 188) {
        return true;
      }

      // Skip the frame.
      input.peekFully(scratch.data, 0, 4);
      scratchBits.setPosition(14);
      int frameSize = scratchBits.readBits(13);
      // Either the stream is malformed OR we're not parsing an ADTS stream.
      if (frameSize <= 6) {
        return false;
      }
      input.advancePeekPosition(frameSize - 6);
      validFramesSize += frameSize;
    }
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:55,代码来源:AdtsExtractor.java

示例13: sniff

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
@Override
public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
  // Skip any ID3 headers.
  ParsableByteArray scratch = new ParsableByteArray(10);
  int startPosition = 0;
  while (true) {
    input.peekFully(scratch.data, 0, 10);
    scratch.setPosition(0);
    if (scratch.readUnsignedInt24() != ID3_TAG) {
      break;
    }
    scratch.skipBytes(3);
    int length = scratch.readSynchSafeInt();
    startPosition += 10 + length;
    input.advancePeekPosition(length);
  }
  input.resetPeekPosition();
  input.advancePeekPosition(startPosition);

  int headerPosition = startPosition;
  int validFramesCount = 0;
  while (true) {
    input.peekFully(scratch.data, 0, 5);
    scratch.setPosition(0);
    int syncBytes = scratch.readUnsignedShort();
    if (syncBytes != AC3_SYNC_WORD) {
      validFramesCount = 0;
      input.resetPeekPosition();
      if (++headerPosition - startPosition >= MAX_SNIFF_BYTES) {
        return false;
      }
      input.advancePeekPosition(headerPosition);
    } else {
      if (++validFramesCount >= 4) {
        return true;
      }
      int frameSize = Ac3Util.parseAc3SyncframeSize(scratch.data);
      if (frameSize == C.LENGTH_UNSET) {
        return false;
      }
      input.advancePeekPosition(frameSize - 5);
    }
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:45,代码来源:Ac3Extractor.java

示例14: populate

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
/**
 * Peeks an Ogg page header and updates this {@link OggPageHeader}.
 *
 * @param input the {@link ExtractorInput} to read from.
 * @param quiet if {@code true} no Exceptions are thrown but {@code false} is return if something
 *    goes wrong.
 * @return {@code true} if the read was successful. {@code false} if the end of the input was
 *    encountered having read no data.
 * @throws IOException thrown if reading data fails or the stream is invalid.
 * @throws InterruptedException thrown if thread is interrupted when reading/peeking.
 */
public boolean populate(ExtractorInput input, boolean quiet)
    throws IOException, InterruptedException {
  scratch.reset();
  reset();
  boolean hasEnoughBytes = input.getLength() == C.LENGTH_UNSET
      || input.getLength() - input.getPeekPosition() >= EMPTY_PAGE_HEADER_SIZE;
  if (!hasEnoughBytes || !input.peekFully(scratch.data, 0, EMPTY_PAGE_HEADER_SIZE, true)) {
    if (quiet) {
      return false;
    } else {
      throw new EOFException();
    }
  }
  if (scratch.readUnsignedInt() != TYPE_OGGS) {
    if (quiet) {
      return false;
    } else {
      throw new ParserException("expected OggS capture pattern at begin of page");
    }
  }

  revision = scratch.readUnsignedByte();
  if (revision != 0x00) {
    if (quiet) {
      return false;
    } else {
      throw new ParserException("unsupported bit stream revision");
    }
  }
  type = scratch.readUnsignedByte();

  granulePosition = scratch.readLittleEndianLong();
  streamSerialNumber = scratch.readLittleEndianUnsignedInt();
  pageSequenceNumber = scratch.readLittleEndianUnsignedInt();
  pageChecksum = scratch.readLittleEndianUnsignedInt();
  pageSegmentCount = scratch.readUnsignedByte();
  headerSize = EMPTY_PAGE_HEADER_SIZE + pageSegmentCount;

  // calculate total size of header including laces
  scratch.reset();
  input.peekFully(scratch.data, 0, pageSegmentCount);
  for (int i = 0; i < pageSegmentCount; i++) {
    laces[i] = scratch.readUnsignedByte();
    bodySize += laces[i];
  }

  return true;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:60,代码来源:OggPageHeader.java

示例15: sniffInternal

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入方法依赖的package包/类
private static boolean sniffInternal(ExtractorInput input, boolean fragmented)
    throws IOException, InterruptedException {
  long inputLength = input.getLength();
  int bytesToSearch = (int) (inputLength == C.LENGTH_UNSET || inputLength > SEARCH_LENGTH
      ? SEARCH_LENGTH : inputLength);

  ParsableByteArray buffer = new ParsableByteArray(64);
  int bytesSearched = 0;
  boolean foundGoodFileType = false;
  boolean isFragmented = false;
  while (bytesSearched < bytesToSearch) {
    // Read an atom header.
    int headerSize = Atom.HEADER_SIZE;
    buffer.reset(headerSize);
    input.peekFully(buffer.data, 0, headerSize);
    long atomSize = buffer.readUnsignedInt();
    int atomType = buffer.readInt();
    if (atomSize == Atom.LONG_SIZE_PREFIX) {
      headerSize = Atom.LONG_HEADER_SIZE;
      input.peekFully(buffer.data, Atom.HEADER_SIZE, Atom.LONG_HEADER_SIZE - Atom.HEADER_SIZE);
      buffer.setLimit(Atom.LONG_HEADER_SIZE);
      atomSize = buffer.readUnsignedLongToLong();
    }

    if (atomSize < headerSize) {
      // The file is invalid because the atom size is too small for its header.
      return false;
    }
    bytesSearched += headerSize;

    if (atomType == Atom.TYPE_moov) {
      // Check for an mvex atom inside the moov atom to identify whether the file is fragmented.
      continue;
    }

    if (atomType == Atom.TYPE_moof || atomType == Atom.TYPE_mvex) {
      // The movie is fragmented. Stop searching as we must have read any ftyp atom already.
      isFragmented = true;
      break;
    }

    if (bytesSearched + atomSize - headerSize >= bytesToSearch) {
      // Stop searching as peeking this atom would exceed the search limit.
      break;
    }

    int atomDataSize = (int) (atomSize - headerSize);
    bytesSearched += atomDataSize;
    if (atomType == Atom.TYPE_ftyp) {
      // Parse the atom and check the file type/brand is compatible with the extractors.
      if (atomDataSize < 8) {
        return false;
      }
      buffer.reset(atomDataSize);
      input.peekFully(buffer.data, 0, atomDataSize);
      int brandsCount = atomDataSize / 4;
      for (int i = 0; i < brandsCount; i++) {
        if (i == 1) {
          // This index refers to the minorVersion, not a brand, so skip it.
          buffer.skipBytes(4);
        } else if (isCompatibleBrand(buffer.readInt())) {
          foundGoodFileType = true;
          break;
        }
      }
      if (!foundGoodFileType) {
        // The types were not compatible and there is only one ftyp atom, so reject the file.
        return false;
      }
    } else if (atomDataSize != 0) {
      // Skip the atom.
      input.advancePeekPosition(atomDataSize);
    }
  }
  return foundGoodFileType && fragmented == isFragmented;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:77,代码来源:Sniffer.java


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