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


Java SeekMap类代码示例

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


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


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