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


Java ExtractorInput类代码示例

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


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

示例1: maybeLoadInitData

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
private void maybeLoadInitData() throws IOException, InterruptedException {
  if (previousExtractor == extractor || initLoadCompleted || initDataSpec == null) {
    // According to spec, for packed audio, initDataSpec is expected to be null.
    return;
  }
  DataSpec initSegmentDataSpec = Util.getRemainderDataSpec(initDataSpec, initSegmentBytesLoaded);
  try {
    ExtractorInput input = new DefaultExtractorInput(initDataSource,
        initSegmentDataSpec.absoluteStreamPosition, initDataSource.open(initSegmentDataSpec));
    try {
      int result = Extractor.RESULT_CONTINUE;
      while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
        result = extractor.read(input, null);
      }
    } finally {
      initSegmentBytesLoaded = (int) (input.getPosition() - initDataSpec.absoluteStreamPosition);
    }
  } finally {
    Util.closeQuietly(dataSource);
  }
  initLoadCompleted = true;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:23,代码来源:HlsMediaChunk.java

示例2: read

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
@Override
public int read(ExtractorInput input, PositionHolder seekPosition)
    throws IOException, InterruptedException {
  int currentFileSize = (int) input.getLength();

  // Increase the size of sampleData if necessary.
  if (sampleSize == sampleData.length) {
    sampleData = Arrays.copyOf(sampleData,
        (currentFileSize != C.LENGTH_UNSET ? currentFileSize : sampleData.length) * 3 / 2);
  }

  // Consume to the input.
  int bytesRead = input.read(sampleData, sampleSize, sampleData.length - sampleSize);
  if (bytesRead != C.RESULT_END_OF_INPUT) {
    sampleSize += bytesRead;
    if (currentFileSize == C.LENGTH_UNSET || sampleSize != currentFileSize) {
      return Extractor.RESULT_CONTINUE;
    }
  }

  // We've reached the end of the input, which corresponds to the end of the current file.
  processSample();
  return Extractor.RESULT_END_OF_INPUT;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:25,代码来源:WebvttExtractor.java

示例3: read

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
@Override
public int read(ExtractorInput input, PositionHolder seekPosition)
    throws IOException, InterruptedException {
  int bytesRead = input.read(packetBuffer.data, 0, MAX_PACKET_SIZE);
  if (bytesRead == C.RESULT_END_OF_INPUT) {
    return RESULT_END_OF_INPUT;
  }

  // Feed whatever data we have to the reader, regardless of whether the read finished or not.
  packetBuffer.setPosition(0);
  packetBuffer.setLimit(bytesRead);

  if (!startedPacket) {
    // Pass data to the reader as though it's contained within a single infinitely long packet.
    reader.packetStarted(firstSampleTimestampUs, true);
    startedPacket = true;
  }
  // TODO: Make it possible for reader to consume the dataSource directly, so that it becomes
  // unnecessary to copy the data through packetBuffer.
  reader.consume(packetBuffer);
  return RESULT_CONTINUE;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:23,代码来源:AdtsExtractor.java

示例4: read

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
@Override
public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException,
    InterruptedException {
  int bytesRead = input.read(sampleData.data, 0, MAX_SYNC_FRAME_SIZE);
  if (bytesRead == C.RESULT_END_OF_INPUT) {
    return RESULT_END_OF_INPUT;
  }

  // Feed whatever data we have to the reader, regardless of whether the read finished or not.
  sampleData.setPosition(0);
  sampleData.setLimit(bytesRead);

  if (!startedPacket) {
    // Pass data to the reader as though it's contained within a single infinitely long packet.
    reader.packetStarted(firstSampleTimestampUs, true);
    startedPacket = true;
  }
  // TODO: Make it possible for the reader to consume the dataSource directly, so that it becomes
  // unnecessary to copy the data through packetBuffer.
  reader.consume(sampleData);
  return RESULT_CONTINUE;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:23,代码来源:Ac3Extractor.java

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

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

示例7: read

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
/**
 * @see Extractor#read(ExtractorInput, PositionHolder)
 */
final int read(ExtractorInput input, PositionHolder seekPosition)
    throws IOException, InterruptedException {
  switch (state) {
    case STATE_READ_HEADERS:
      return readHeaders(input);
    case STATE_SKIP_HEADERS:
      input.skipFully((int) payloadStartPosition);
      state = STATE_READ_PAYLOAD;
      return Extractor.RESULT_CONTINUE;
    case STATE_READ_PAYLOAD:
      return readPayload(input, seekPosition);
    default:
      // Never happens.
      throw new IllegalStateException();
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:20,代码来源:StreamReader.java

示例8: read

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
@Override
public int read(ExtractorInput input, PositionHolder seekPosition)
    throws IOException, InterruptedException {
  while (true) {
    switch (parserState) {
      case STATE_READING_ATOM_HEADER:
        if (!readAtomHeader(input)) {
          return RESULT_END_OF_INPUT;
        }
        break;
      case STATE_READING_ATOM_PAYLOAD:
        if (readAtomPayload(input, seekPosition)) {
          return RESULT_SEEK;
        }
        break;
      case STATE_READING_SAMPLE:
        return readSample(input, seekPosition);
      default:
        throw new IllegalStateException();
    }
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:23,代码来源:Mp4Extractor.java

示例9: readAtomPayload

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
/**
 * Processes the atom payload. If {@link #atomData} is null and the size is at or above the
 * threshold {@link #RELOAD_MINIMUM_SEEK_DISTANCE}, {@code true} is returned and the caller should
 * restart loading at the position in {@code positionHolder}. Otherwise, the atom is read/skipped.
 */
private boolean readAtomPayload(ExtractorInput input, PositionHolder positionHolder)
    throws IOException, InterruptedException {
  long atomPayloadSize = atomSize - atomHeaderBytesRead;
  long atomEndPosition = input.getPosition() + atomPayloadSize;
  boolean seekRequired = false;
  if (atomData != null) {
    input.readFully(atomData.data, atomHeaderBytesRead, (int) atomPayloadSize);
    if (atomType == Atom.TYPE_ftyp) {
      isQuickTime = processFtypAtom(atomData);
    } else if (!containerAtoms.isEmpty()) {
      containerAtoms.peek().add(new Atom.LeafAtom(atomType, atomData));
    }
  } else {
    // We don't need the data. Skip or seek, depending on how large the atom is.
    if (atomPayloadSize < RELOAD_MINIMUM_SEEK_DISTANCE) {
      input.skipFully((int) atomPayloadSize);
    } else {
      positionHolder.position = input.getPosition() + atomPayloadSize;
      seekRequired = true;
    }
  }
  processAtomEnded(atomEndPosition);
  return seekRequired && parserState != STATE_READING_SAMPLE;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:30,代码来源:Mp4Extractor.java

示例10: read

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
@Override
public int read(ExtractorInput input, PositionHolder seekPosition)
    throws IOException, InterruptedException {
  while (true) {
    switch (parserState) {
      case STATE_READING_ATOM_HEADER:
        if (!readAtomHeader(input)) {
          return Extractor.RESULT_END_OF_INPUT;
        }
        break;
      case STATE_READING_ATOM_PAYLOAD:
        readAtomPayload(input);
        break;
      case STATE_READING_ENCRYPTION_DATA:
        readEncryptionData(input);
        break;
      default:
        if (readSample(input)) {
          return RESULT_CONTINUE;
        }
    }
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:24,代码来源:FragmentedMp4Extractor.java

示例11: readEncryptionData

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
private void readEncryptionData(ExtractorInput input) throws IOException, InterruptedException {
  TrackBundle nextTrackBundle = null;
  long nextDataOffset = Long.MAX_VALUE;
  int trackBundlesSize = trackBundles.size();
  for (int i = 0; i < trackBundlesSize; i++) {
    TrackFragment trackFragment = trackBundles.valueAt(i).fragment;
    if (trackFragment.sampleEncryptionDataNeedsFill
        && trackFragment.auxiliaryDataPosition < nextDataOffset) {
      nextDataOffset = trackFragment.auxiliaryDataPosition;
      nextTrackBundle = trackBundles.valueAt(i);
    }
  }
  if (nextTrackBundle == null) {
    parserState = STATE_READING_SAMPLE_START;
    return;
  }
  int bytesToSkip = (int) (nextDataOffset - input.getPosition());
  if (bytesToSkip < 0) {
    throw new ParserException("Offset to encryption data was negative.");
  }
  input.skipFully(bytesToSkip);
  nextTrackBundle.fragment.fillEncryptionData(input);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:24,代码来源:FragmentedMp4Extractor.java

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

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

示例14: read

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
@Override
public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException,
    InterruptedException {
  while (true) {
    switch (parserState) {
      case STATE_READING_FLV_HEADER:
        if (!readFlvHeader(input)) {
          return RESULT_END_OF_INPUT;
        }
        break;
      case STATE_SKIPPING_TO_TAG_HEADER:
        skipToTagHeader(input);
        break;
      case STATE_READING_TAG_HEADER:
        if (!readTagHeader(input)) {
          return RESULT_END_OF_INPUT;
        }
        break;
      case STATE_READING_TAG_DATA:
        if (readTagData(input)) {
          return RESULT_CONTINUE;
        }
        break;
    }
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:27,代码来源:FlvExtractor.java

示例15: readTagHeader

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
/**
 * Reads a tag header from the provided {@link ExtractorInput}.
 *
 * @param input The {@link ExtractorInput} from which to read.
 * @return True if tag header was read successfully. Otherwise, false.
 * @throws IOException If an error occurred reading or parsing data from the source.
 * @throws InterruptedException If the thread was interrupted.
 */
private boolean readTagHeader(ExtractorInput input) throws IOException, InterruptedException {
  if (!input.readFully(tagHeaderBuffer.data, 0, FLV_TAG_HEADER_SIZE, true)) {
    // We've reached the end of the stream.
    return false;
  }

  tagHeaderBuffer.setPosition(0);
  tagType = tagHeaderBuffer.readUnsignedByte();
  tagDataSize = tagHeaderBuffer.readUnsignedInt24();
  tagTimestampUs = tagHeaderBuffer.readUnsignedInt24();
  tagTimestampUs = ((tagHeaderBuffer.readUnsignedByte() << 24) | tagTimestampUs) * 1000L;
  tagHeaderBuffer.skipBytes(3); // streamId
  parserState = STATE_READING_TAG_DATA;
  return true;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:24,代码来源:FlvExtractor.java


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