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

Java SeekMap类代码示例

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

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



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

示例1: onChunkLoadCompleted

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void onChunkLoadCompleted(Chunk chunk) {
  if (chunk instanceof InitializationChunk) {
    InitializationChunk initializationChunk = (InitializationChunk) chunk;
    RepresentationHolder representationHolder =
        representationHolders[trackSelection.indexOf(initializationChunk.trackFormat)];
    // The null check avoids overwriting an index obtained from the manifest with one obtained
    // from the stream. If the manifest defines an index then the stream shouldn't, but in cases
    // where it does we should ignore it.
    if (representationHolder.segmentIndex == null) {
      SeekMap seekMap = representationHolder.extractorWrapper.getSeekMap();
      if (seekMap != null) {
        representationHolder.segmentIndex = new DashWrappingSegmentIndex((ChunkIndex) seekMap);
      }
    }
  }
}
 
开发者ID:jcodeing,项目名称:K-Sonic,代码行数:18,代码来源:DefaultDashChunkSource.java


示例2: onChunkLoadCompleted

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void onChunkLoadCompleted(Chunk chunk) {
  if (chunk instanceof InitializationChunk) {
    InitializationChunk initializationChunk = (InitializationChunk) chunk;
    RepresentationHolder representationHolder =
        representationHolders[trackSelection.indexOf(initializationChunk.trackFormat)];
    Format sampleFormat = initializationChunk.getSampleFormat();
    if (sampleFormat != null) {
      representationHolder.setSampleFormat(sampleFormat);
    }
    // The null check avoids overwriting an index obtained from the manifest with one obtained
    // from the stream. If the manifest defines an index then the stream shouldn't, but in cases
    // where it does we should ignore it.
    if (representationHolder.segmentIndex == null) {
      SeekMap seekMap = initializationChunk.getSeekMap();
      if (seekMap != null) {
        representationHolder.segmentIndex = new DashWrappingSegmentIndex((ChunkIndex) seekMap,
            initializationChunk.dataSpec.uri.toString());
      }
    }
  }
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:23,代码来源:DefaultDashChunkSource.java


示例3: readTagData

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的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) {
    ensureReadyForMediaOutput();
    audioReader.consume(prepareTagData(input), mediaTagTimestampOffsetUs + tagTimestampUs);
  } else if (tagType == TAG_TYPE_VIDEO && videoReader != null) {
    ensureReadyForMediaOutput();
    videoReader.consume(prepareTagData(input), mediaTagTimestampOffsetUs + tagTimestampUs);
  } else if (tagType == TAG_TYPE_SCRIPT_DATA && !outputSeekMap) {
    metadataReader.consume(prepareTagData(input), tagTimestampUs);
    long durationUs = metadataReader.getDurationUs();
    if (durationUs != C.TIME_UNSET) {
      extractorOutput.seekMap(new SeekMap.Unseekable(durationUs));
      outputSeekMap = true;
    }
  } else {
    input.skipFully(tagDataSize);
    wasConsumed = false;
  }
  bytesToNextTagHeader = 4; // There's a 4 byte previous tag size before the next header.
  state = STATE_SKIPPING_TO_TAG_HEADER;
  return wasConsumed;
}
 
开发者ID:y20k,项目名称:transistor,代码行数:32,代码来源:FlvExtractor.java


示例4: assertOutput

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
/**
 * Asserts that {@code extractor} consumes {@code sampleFile} successfully and its output equals
 * to a prerecorded output dump file with the name {@code sampleFile} + "{@value
 * #DUMP_EXTENSION}". If {@code simulateUnknownLength} is true and {@code sampleFile} + "{@value
 * #UNKNOWN_LENGTH_EXTENSION}" exists, it's preferred.
 *
 * @param extractor The {@link Extractor} to be tested.
 * @param sampleFile The path to the input sample.
 * @param fileData Content of the input file.
 * @param instrumentation To be used to load the sample file.
 * @param simulateIOErrors If true simulates IOErrors.
 * @param simulateUnknownLength If true simulates unknown input length.
 * @param simulatePartialReads If true simulates partial reads.
 * @return The {@link FakeExtractorOutput} used in the test.
 * @throws IOException If reading from the input fails.
 * @throws InterruptedException If interrupted while reading from the input.
 */
public static FakeExtractorOutput assertOutput(Extractor extractor, String sampleFile,
    byte[] fileData, Instrumentation instrumentation, boolean simulateIOErrors,
    boolean simulateUnknownLength, boolean simulatePartialReads) throws IOException,
    InterruptedException {
  FakeExtractorInput input = new FakeExtractorInput.Builder().setData(fileData)
      .setSimulateIOErrors(simulateIOErrors)
      .setSimulateUnknownLength(simulateUnknownLength)
      .setSimulatePartialReads(simulatePartialReads).build();

  Assert.assertTrue(sniffTestData(extractor, input));
  input.resetPeekPosition();
  FakeExtractorOutput extractorOutput = consumeTestData(extractor, input, 0, true);

  if (simulateUnknownLength
      && assetExists(instrumentation, sampleFile + UNKNOWN_LENGTH_EXTENSION)) {
    extractorOutput.assertOutput(instrumentation, sampleFile + UNKNOWN_LENGTH_EXTENSION);
  } else {
    extractorOutput.assertOutput(instrumentation, sampleFile + ".0" + DUMP_EXTENSION);
  }

  SeekMap seekMap = extractorOutput.seekMap;
  if (seekMap.isSeekable()) {
    long durationUs = seekMap.getDurationUs();
    for (int j = 0; j < 4; j++) {
      long timeUs = (durationUs * j) / 3;
      long position = seekMap.getPosition(timeUs);
      input.setPosition((int) position);
      for (int i = 0; i < extractorOutput.numberOfTracks; i++) {
        extractorOutput.trackOutputs.valueAt(i).clear();
      }

      consumeTestData(extractor, input, timeUs, extractorOutput, false);
      extractorOutput.assertOutput(instrumentation, sampleFile + '.' + j + DUMP_EXTENSION);
    }
  }

  return extractorOutput;
}
 
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:56,代码来源:TestUtil.java


示例5: init

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void init(ExtractorOutput output) {
  reader = new AdtsReader(true);
  reader.createTracks(output, new TrackIdGenerator(0, 1));
  output.endTracks();
  output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:8,代码来源:AdtsExtractor.java


示例6: init

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void init(ExtractorOutput output) {
  reader = new Ac3Reader(); // TODO: Add support for embedded ID3.
  reader.createTracks(output, new TrackIdGenerator(0, 1));
  output.endTracks();
  output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:8,代码来源:Ac3Extractor.java


示例7: readPayload

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
private int readPayload(ExtractorInput input, PositionHolder seekPosition)
    throws IOException, InterruptedException {
  long position = oggSeeker.read(input);
  if (position >= 0) {
    seekPosition.position = position;
    return Extractor.RESULT_SEEK;
  } else if (position < -1) {
    onSeekEnd(-(position + 2));
  }
  if (!seekMapSet) {
    SeekMap seekMap = oggSeeker.createSeekMap();
    extractorOutput.seekMap(seekMap);
    seekMapSet = true;
  }

  if (lengthOfReadPacket > 0 || oggPacket.populate(input)) {
    lengthOfReadPacket = 0;
    ParsableByteArray payload = oggPacket.getPayload();
    long granulesInPacket = preparePayload(payload);
    if (granulesInPacket >= 0 && currentGranule + granulesInPacket >= targetGranule) {
      // calculate time and send payload data to codec
      long timeUs = convertGranuleToTime(currentGranule);
      trackOutput.sampleData(payload, payload.limit());
      trackOutput.sampleMetadata(timeUs, C.BUFFER_FLAG_KEY_FRAME, payload.limit(), 0, null);
      targetGranule = -1;
    }
    currentGranule += granulesInPacket;
  } else {
    state = STATE_END_OF_INPUT;
    return Extractor.RESULT_END_OF_INPUT;
  }
  return Extractor.RESULT_CONTINUE;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:34,代码来源:StreamReader.java


示例8: buildSeekMap

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
/**
 * Builds a {@link SeekMap} from the recently gathered Cues information.
 *
 * @return The built {@link SeekMap}. The returned {@link SeekMap} may be unseekable if cues
 *     information was missing or incomplete.
 */
private SeekMap buildSeekMap() {
  if (segmentContentPosition == C.POSITION_UNSET || durationUs == C.TIME_UNSET
      || cueTimesUs == null || cueTimesUs.size() == 0
      || cueClusterPositions == null || cueClusterPositions.size() != cueTimesUs.size()) {
    // Cues information is missing or incomplete.
    cueTimesUs = null;
    cueClusterPositions = null;
    return new SeekMap.Unseekable(durationUs);
  }
  int cuePointsSize = cueTimesUs.size();
  int[] sizes = new int[cuePointsSize];
  long[] offsets = new long[cuePointsSize];
  long[] durationsUs = new long[cuePointsSize];
  long[] timesUs = new long[cuePointsSize];
  for (int i = 0; i < cuePointsSize; i++) {
    timesUs[i] = cueTimesUs.get(i);
    offsets[i] = segmentContentPosition + cueClusterPositions.get(i);
  }
  for (int i = 0; i < cuePointsSize - 1; i++) {
    sizes[i] = (int) (offsets[i + 1] - offsets[i]);
    durationsUs[i] = timesUs[i + 1] - timesUs[i];
  }
  sizes[cuePointsSize - 1] =
      (int) (segmentContentPosition + segmentContentSize - offsets[cuePointsSize - 1]);
  durationsUs[cuePointsSize - 1] = durationUs - timesUs[cuePointsSize - 1];
  cueTimesUs = null;
  cueClusterPositions = null;
  return new ChunkIndex(sizes, offsets, durationsUs, timesUs);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:36,代码来源:MatroskaExtractor.java


示例9: init

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void init(ExtractorOutput output) {
  output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
  trackOutput = output.track(0, C.TRACK_TYPE_TEXT);
  output.endTracks();
  trackOutput.format(format);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:8,代码来源:RawCcExtractor.java


示例10: init

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void init(ExtractorOutput output) {
  reader = new AdtsReader(true);
  reader.init(output, new TrackIdGenerator(0, 1));
  output.endTracks();
  output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:8,代码来源:AdtsExtractor.java


示例11: init

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void init(ExtractorOutput output) {
  reader = new Ac3Reader(); // TODO: Add support for embedded ID3.
  reader.init(output, new TrackIdGenerator(0, 1));
  output.endTracks();
  output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:8,代码来源:Ac3Extractor.java


示例12: readPayload

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
private int readPayload(ExtractorInput input, PositionHolder seekPosition)
    throws IOException, InterruptedException {
  long position = oggSeeker.read(input);
  if (position >= 0) {
    seekPosition.position = position;
    return Extractor.RESULT_SEEK;
  } else if (position < -1) {
    onSeekEnd(-position - 2);
  }
  if (!seekMapSet) {
    SeekMap seekMap = oggSeeker.createSeekMap();
    extractorOutput.seekMap(seekMap);
    seekMapSet = true;
  }

  if (lengthOfReadPacket > 0 || oggPacket.populate(input)) {
    lengthOfReadPacket = 0;
    ParsableByteArray payload = oggPacket.getPayload();
    long granulesInPacket = preparePayload(payload);
    if (granulesInPacket >= 0 && currentGranule + granulesInPacket >= targetGranule) {
      // calculate time and send payload data to codec
      long timeUs = convertGranuleToTime(currentGranule);
      trackOutput.sampleData(payload, payload.limit());
      trackOutput.sampleMetadata(timeUs, C.BUFFER_FLAG_KEY_FRAME, payload.limit(), 0, null);
      targetGranule = -1;
    }
    currentGranule += granulesInPacket;
  } else {
    state = STATE_END_OF_INPUT;
    return Extractor.RESULT_END_OF_INPUT;
  }
  return Extractor.RESULT_CONTINUE;
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:34,代码来源:StreamReader.java


示例13: init

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void init(ExtractorOutput output) {
  this.extractorOutput = output;
  extractorOutput.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
  trackOutput = extractorOutput.track(0);
  extractorOutput.endTracks();

  trackOutput.format(Format.createTextSampleFormat(null, MimeTypes.APPLICATION_CEA608,
      null, Format.NO_VALUE, 0, null, null));
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:11,代码来源:RawCcExtractor.java


示例14: ensureReadyForMediaOutput

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
private void ensureReadyForMediaOutput() {
  if (!outputSeekMap) {
    extractorOutput.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
    outputSeekMap = true;
  }
  if (mediaTagTimestampOffsetUs == C.TIME_UNSET) {
    mediaTagTimestampOffsetUs =
        metadataReader.getDurationUs() == C.TIME_UNSET ? -tagTimestampUs : 0;
  }
}
 
开发者ID:y20k,项目名称:transistor,代码行数:11,代码来源:FlvExtractor.java


示例15: init

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public void init(ExtractorOutput output) {
  this.output = output;
  output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:6,代码来源:WebvttExtractor.java


示例16: createSeekMap

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public SeekMap createSeekMap() {
  return new SeekMap.Unseekable(C.TIME_UNSET);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:5,代码来源:StreamReader.java


示例17: createSeekMap

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
@Override
public SeekMap createSeekMap() {
  return this;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:5,代码来源:FlacReader.java


示例18: readAtomHeader

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
private boolean readAtomHeader(ExtractorInput input) throws IOException, InterruptedException {
  if (atomHeaderBytesRead == 0) {
    // Read the standard length atom header.
    if (!input.readFully(atomHeader.data, 0, Atom.HEADER_SIZE, true)) {
      return false;
    }
    atomHeaderBytesRead = Atom.HEADER_SIZE;
    atomHeader.setPosition(0);
    atomSize = atomHeader.readUnsignedInt();
    atomType = atomHeader.readInt();
  }

  if (atomSize == Atom.LONG_SIZE_PREFIX) {
    // Read the extended atom size.
    int headerBytesRemaining = Atom.LONG_HEADER_SIZE - Atom.HEADER_SIZE;
    input.readFully(atomHeader.data, Atom.HEADER_SIZE, headerBytesRemaining);
    atomHeaderBytesRead += headerBytesRemaining;
    atomSize = atomHeader.readUnsignedLongToLong();
  }

  if (atomSize < atomHeaderBytesRead) {
    throw new ParserException("Atom size less than header length (unsupported).");
  }

  long atomPosition = input.getPosition() - atomHeaderBytesRead;
  if (atomType == Atom.TYPE_moof) {
    // The data positions may be updated when parsing the tfhd/trun.
    int trackCount = trackBundles.size();
    for (int i = 0; i < trackCount; i++) {
      TrackFragment fragment = trackBundles.valueAt(i).fragment;
      fragment.atomPosition = atomPosition;
      fragment.auxiliaryDataPosition = atomPosition;
      fragment.dataPosition = atomPosition;
    }
  }

  if (atomType == Atom.TYPE_mdat) {
    currentTrackBundle = null;
    endOfMdatPosition = atomPosition + atomSize;
    if (!haveOutputSeekMap) {
      extractorOutput.seekMap(new SeekMap.Unseekable(durationUs));
      haveOutputSeekMap = true;
    }
    parserState = STATE_READING_ENCRYPTION_DATA;
    return true;
  }

  if (shouldParseContainerAtom(atomType)) {
    long endPosition = input.getPosition() + atomSize - Atom.HEADER_SIZE;
    containerAtoms.add(new ContainerAtom(atomType, endPosition));
    if (atomSize == atomHeaderBytesRead) {
      processAtomEnded(endPosition);
    } else {
      // Start reading the first child atom.
      enterReadingAtomHeaderState();
    }
  } else if (shouldParseLeafAtom(atomType)) {
    if (atomHeaderBytesRead != Atom.HEADER_SIZE) {
      throw new ParserException("Leaf atom defines extended atom size (unsupported).");
    }
    if (atomSize > Integer.MAX_VALUE) {
      throw new ParserException("Leaf atom with length > 2147483647 (unsupported).");
    }
    atomData = new ParsableByteArray((int) atomSize);
    System.arraycopy(atomHeader.data, 0, atomData.data, 0, Atom.HEADER_SIZE);
    parserState = STATE_READING_ATOM_PAYLOAD;
  } else {
    if (atomSize > Integer.MAX_VALUE) {
      throw new ParserException("Skipping atom with length > 2147483647 (unsupported).");
    }
    atomData = null;
    parserState = STATE_READING_ATOM_PAYLOAD;
  }

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


示例19: startMasterElement

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
void startMasterElement(int id, long contentPosition, long contentSize)
    throws ParserException {
  switch (id) {
    case ID_SEGMENT:
      if (segmentContentPosition != C.POSITION_UNSET
          && segmentContentPosition != contentPosition) {
        throw new ParserException("Multiple Segment elements not supported");
      }
      segmentContentPosition = contentPosition;
      segmentContentSize = contentSize;
      break;
    case ID_SEEK:
      seekEntryId = UNSET_ENTRY_ID;
      seekEntryPosition = C.POSITION_UNSET;
      break;
    case ID_CUES:
      cueTimesUs = new LongArray();
      cueClusterPositions = new LongArray();
      break;
    case ID_CUE_POINT:
      seenClusterPositionForCurrentCuePoint = false;
      break;
    case ID_CLUSTER:
      if (!sentSeekMap) {
        // We need to build cues before parsing the cluster.
        if (seekForCuesEnabled && cuesContentPosition != C.POSITION_UNSET) {
          // We know where the Cues element is located. Seek to request it.
          seekForCues = true;
        } else {
          // We don't know where the Cues element is located. It's most likely omitted. Allow
          // playback, but disable seeking.
          extractorOutput.seekMap(new SeekMap.Unseekable(durationUs));
          sentSeekMap = true;
        }
      }
      break;
    case ID_BLOCK_GROUP:
      sampleSeenReferenceBlock = false;
      break;
    case ID_CONTENT_ENCODING:
      // TODO: check and fail if more than one content encoding is present.
      break;
    case ID_CONTENT_ENCRYPTION:
      currentTrack.hasContentEncryption = true;
      break;
    case ID_TRACK_ENTRY:
      currentTrack = new Track();
      break;
    case ID_MASTERING_METADATA:
      currentTrack.hasColorInfo = true;
      break;
    default:
      break;
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:56,代码来源:MatroskaExtractor.java


示例20: getSeekMap

import com.google.android.exoplayer2.extractor.SeekMap; //导入依赖的package包/类
/**
 * Returns the {@link SeekMap} most recently output by the extractor, or null.
 */
public SeekMap getSeekMap() {
  return seekMap;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:7,代码来源:ChunkExtractorWrapper.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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