• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ExtractorInput类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: readTagData

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
/**
 * Reads the body of a tag from the provided {@link ExtractorInput}.
 *
 * @param input The {@link ExtractorInput} from which to read.
 * @return True if the data was consumed by a reader. False if it was skipped.
 * @throws IOException If an error occurred reading or parsing data from the source.
 * @throws InterruptedException If the thread was interrupted.
 */
private boolean readTagData(ExtractorInput input) throws IOException, InterruptedException {
  boolean wasConsumed = true;
  if (tagType == TAG_TYPE_AUDIO && audioReader != null) {
    audioReader.consume(prepareTagData(input), tagTimestampUs);
  } else if (tagType == TAG_TYPE_VIDEO && videoReader != null) {
    videoReader.consume(prepareTagData(input), tagTimestampUs);
  } else if (tagType == TAG_TYPE_SCRIPT_DATA && metadataReader != null) {
    metadataReader.consume(prepareTagData(input), tagTimestampUs);
  } else {
    input.skipFully(tagDataSize);
    wasConsumed = false;
  }
  bytesToNextTagHeader = 4; // There's a 4 byte previous tag size before the next header.
  parserState = STATE_SKIPPING_TO_TAG_HEADER;
  return wasConsumed;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:25,代码来源:FlvExtractor.java


示例17: parseTimestampAndSampleCount

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
private boolean parseTimestampAndSampleCount(ExtractorInput input) throws IOException,
    InterruptedException {
  dataScratch.reset();
  if (version == 0) {
    if (!input.readFully(dataScratch.data, 0, TIMESTAMP_SIZE_V0 + 1, true)) {
      return false;
    }
    // version 0 timestamps are 45kHz, so we need to convert them into us
    timestampUs = dataScratch.readUnsignedInt() * 1000 / 45;
  } else if (version == 1) {
    if (!input.readFully(dataScratch.data, 0, TIMESTAMP_SIZE_V1 + 1, true)) {
      return false;
    }
    timestampUs = dataScratch.readLong();
  } else {
    throw new ParserException("Unsupported version number: " + version);
  }

  remainingSampleCount = dataScratch.readUnsignedByte();
  sampleBytesWritten = 0;
  return true;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:23,代码来源:RawCcExtractor.java


示例18: read

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
@Override
public int read(ExtractorInput input, PositionHolder seekPosition)
    throws IOException, InterruptedException {
  if (synchronizedHeaderData == 0) {
    try {
      synchronize(input, false);
    } catch (EOFException e) {
      return RESULT_END_OF_INPUT;
    }
  }
  if (seeker == null) {
    seeker = setupSeeker(input);
    extractorOutput.seekMap(seeker);
    trackOutput.format(Format.createAudioSampleFormat(null, synchronizedHeader.mimeType, null,
        Format.NO_VALUE, MpegAudioHeader.MAX_FRAME_SIZE_BYTES, synchronizedHeader.channels,
        synchronizedHeader.sampleRate, Format.NO_VALUE, gaplessInfoHolder.encoderDelay,
        gaplessInfoHolder.encoderPadding, null, null, 0, null,
        (flags & FLAG_DISABLE_ID3_METADATA) != 0 ? null : metadata));
  }
  return readSample(input);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:22,代码来源:Mp3Extractor.java


示例19: load

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
@SuppressWarnings("NonAtomicVolatileUpdate")
@Override
public void load() throws IOException, InterruptedException {
  DataSpec loadDataSpec = Util.getRemainderDataSpec(dataSpec, bytesLoaded);
  try {
    // Create and open the input.
    ExtractorInput input = new DefaultExtractorInput(dataSource,
        loadDataSpec.absoluteStreamPosition, dataSource.open(loadDataSpec));
    if (bytesLoaded == 0) {
      extractorWrapper.init(null);
    }
    // Load and decode the initialization data.
    try {
      Extractor extractor = extractorWrapper.extractor;
      int result = Extractor.RESULT_CONTINUE;
      while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
        result = extractor.read(input, null);
      }
      Assertions.checkState(result != Extractor.RESULT_SEEK);
    } finally {
      bytesLoaded = (int) (input.getPosition() - dataSpec.absoluteStreamPosition);
    }
  } finally {
    Util.closeQuietly(dataSource);
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:27,代码来源:InitializationChunk.java


示例20: assertEvents

import com.google.android.exoplayer2.extractor.ExtractorInput; //导入依赖的package包/类
private static void assertEvents(ExtractorInput input, List<String> expectedEvents)
    throws IOException, InterruptedException {
  DefaultEbmlReader reader = new DefaultEbmlReader();
  TestOutput output = new TestOutput();
  reader.init(output);

  // We expect the number of successful reads to equal the number of expected events.
  for (int i = 0; i < expectedEvents.size(); i++) {
    assertTrue(reader.read(input));
  }
  // The next read should be unsuccessful.
  assertFalse(reader.read(input));
  // Check that we really did get to the end of input.
  assertFalse(input.readFully(new byte[1], 0, 1, true));

  assertEquals(expectedEvents.size(), output.events.size());
  for (int i = 0; i < expectedEvents.size(); i++) {
    assertEquals(expectedEvents.get(i), output.events.get(i));
  }
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:21,代码来源:DefaultEbmlReaderTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RollingUpgradeActionProto类代码示例发布时间:2022-05-23
下一篇:
Java Arguments类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap