當前位置: 首頁>>代碼示例>>Java>>正文


Java ChunkIndex類代碼示例

本文整理匯總了Java中com.google.android.exoplayer.extractor.ChunkIndex的典型用法代碼示例。如果您正苦於以下問題:Java ChunkIndex類的具體用法?Java ChunkIndex怎麽用?Java ChunkIndex使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ChunkIndex類屬於com.google.android.exoplayer.extractor包,在下文中一共展示了ChunkIndex類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onChunkLoadCompleted

import com.google.android.exoplayer.extractor.ChunkIndex; //導入依賴的package包/類
@Override
public void onChunkLoadCompleted(Chunk chunk) {
  if (chunk instanceof InitializationChunk) {
    InitializationChunk initializationChunk = (InitializationChunk) chunk;
    String formatId = initializationChunk.format.id;
    RepresentationHolder representationHolder = representationHolders.get(formatId);
    if (initializationChunk.hasFormat()) {
      representationHolder.format = initializationChunk.getFormat();
    }
    if (initializationChunk.hasSeekMap()) {
      representationHolder.segmentIndex = new DashWrappingSegmentIndex(
          (ChunkIndex) initializationChunk.getSeekMap(),
          initializationChunk.dataSpec.uri.toString(),
          representationHolder.representation.periodStartMs * 1000);
    }
    // The null check avoids overwriting drmInitData obtained from the manifest with drmInitData
    // obtained from the stream, as per DASH IF Interoperability Recommendations V3.0, 7.5.3.
    if (drmInitData == null && initializationChunk.hasDrmInitData()) {
      drmInitData = initializationChunk.getDrmInitData();
    }
  }
}
 
開發者ID:XueyanLiu,項目名稱:miku,代碼行數:23,代碼來源:DashChunkSource.java

示例2: assertIndex

import com.google.android.exoplayer.extractor.ChunkIndex; //導入依賴的package包/類
private void assertIndex(int timecodeScale, int cuePointCount) {
  ChunkIndex index = (ChunkIndex) extractorOutput.seekMap;
  assertEquals(cuePointCount, index.length);
  for (int i = 0; i < cuePointCount - 1; i++) {
    assertEquals(Util.scaleLargeTimestamp(10 * i, timecodeScale, 1000), index.timesUs[i]);
    assertEquals(Util.scaleLargeTimestamp(10, timecodeScale, 1000), index.durationsUs[i]);
    assertEquals(0, index.sizes[i]);
  }
  int lastIndex = cuePointCount - 1;
  long lastTimecode = 10 * lastIndex;
  long lastDurationTimecode = TEST_DURATION_TIMECODE - lastTimecode;
  assertEquals(Util.scaleLargeTimestamp(lastTimecode, timecodeScale, 1000),
      index.timesUs[lastIndex]);
  assertEquals(Util.scaleLargeTimestamp(lastDurationTimecode, timecodeScale, 1000),
      index.durationsUs[lastIndex]);
}
 
開發者ID:asifkhan11,項目名稱:ExoPlayer-Demo,代碼行數:17,代碼來源:WebmExtractorTest.java

示例3: onLeafAtomRead

import com.google.android.exoplayer.extractor.ChunkIndex; //導入依賴的package包/類
private void onLeafAtomRead(LeafAtom leaf, long inputPosition) {
  if (!containerAtoms.isEmpty()) {
    containerAtoms.peek().add(leaf);
  } else if (leaf.type == Atom.TYPE_sidx) {
    ChunkIndex segmentIndex = parseSidx(leaf.data, inputPosition);
    extractorOutput.seekMap(segmentIndex);
    haveOutputSeekMap = true;
  }
}
 
開發者ID:XueyanLiu,項目名稱:miku,代碼行數:10,代碼來源:FragmentedMp4Extractor.java

示例4: buildSeekMap

import com.google.android.exoplayer.extractor.ChunkIndex; //導入依賴的package包/類
/**
 * Builds a {@link SeekMap} from the recently gathered Cues information.
 *
 * @return The built {@link SeekMap}. May be {@link SeekMap#UNSEEKABLE} if cues information was
 *     missing or incomplete.
 */
private SeekMap buildSeekMap() {
  if (segmentContentPosition == UNKNOWN || durationUs == C.UNKNOWN_TIME_US
      || cueTimesUs == null || cueTimesUs.size() == 0
      || cueClusterPositions == null || cueClusterPositions.size() != cueTimesUs.size()) {
    // Cues information is missing or incomplete.
    cueTimesUs = null;
    cueClusterPositions = null;
    return SeekMap.UNSEEKABLE;
  }
  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:XueyanLiu,項目名稱:miku,代碼行數:36,代碼來源:WebmExtractor.java

示例5: onLeafAtomRead

import com.google.android.exoplayer.extractor.ChunkIndex; //導入依賴的package包/類
private void onLeafAtomRead(LeafAtom leaf, long inputPosition) throws ParserException {
  if (!containerAtoms.isEmpty()) {
    containerAtoms.peek().add(leaf);
  } else if (leaf.type == Atom.TYPE_sidx) {
    ChunkIndex segmentIndex = parseSidx(leaf.data, inputPosition);
    extractorOutput.seekMap(segmentIndex);
    haveOutputSeekMap = true;
  } else if (leaf.type == Atom.TYPE_emsg) {
    parseEmsg(leaf.data, inputPosition);
  }
}
 
開發者ID:asifkhan11,項目名稱:ExoPlayer-Demo,代碼行數:12,代碼來源:FragmentedMp4Extractor.java

示例6: onChunkLoadCompleted

import com.google.android.exoplayer.extractor.ChunkIndex; //導入依賴的package包/類
@Override
public void onChunkLoadCompleted(Chunk chunk) {
  if (chunk instanceof InitializationChunk) {
    InitializationChunk initializationChunk = (InitializationChunk) chunk;
    String formatId = initializationChunk.format.id;
    PeriodHolder periodHolder = periodHolders.get(initializationChunk.parentId);
    if (periodHolder == null) {
      // period for this initialization chunk may no longer be on the manifest
      return;
    }

    RepresentationHolder representationHolder = periodHolder.representationHolders.get(formatId);
    if (initializationChunk.hasFormat()) {
      representationHolder.mediaFormat = initializationChunk.getFormat();
    }
    // 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 && initializationChunk.hasSeekMap()) {
      representationHolder.segmentIndex = new DashWrappingSegmentIndex(
          (ChunkIndex) initializationChunk.getSeekMap(),
          initializationChunk.dataSpec.uri.toString());
    }
    // The null check avoids overwriting drmInitData obtained from the manifest with drmInitData
    // obtained from the stream, as per DASH IF Interoperability Recommendations V3.0, 7.5.3.
    if (periodHolder.drmInitData == null && initializationChunk.hasDrmInitData()) {
      periodHolder.drmInitData = initializationChunk.getDrmInitData();
    }
  }
}
 
開發者ID:asifkhan11,項目名稱:ExoPlayer-Demo,代碼行數:31,代碼來源:DashChunkSource.java

示例7: parseSidx

import com.google.android.exoplayer.extractor.ChunkIndex; //導入依賴的package包/類
/**
 * Parses a sidx atom (defined in 14496-12).
 */
private static ChunkIndex parseSidx(ParsableByteArray atom, long inputPosition) {
  atom.setPosition(Atom.HEADER_SIZE);
  int fullAtom = atom.readInt();
  int version = Atom.parseFullAtomVersion(fullAtom);

  atom.skipBytes(4);
  long timescale = atom.readUnsignedInt();
  long earliestPresentationTime;
  long offset = inputPosition;
  if (version == 0) {
    earliestPresentationTime = atom.readUnsignedInt();
    offset += atom.readUnsignedInt();
  } else {
    earliestPresentationTime = atom.readUnsignedLongToLong();
    offset += atom.readUnsignedLongToLong();
  }

  atom.skipBytes(2);

  int referenceCount = atom.readUnsignedShort();
  int[] sizes = new int[referenceCount];
  long[] offsets = new long[referenceCount];
  long[] durationsUs = new long[referenceCount];
  long[] timesUs = new long[referenceCount];

  long time = earliestPresentationTime;
  long timeUs = Util.scaleLargeTimestamp(time, C.MICROS_PER_SECOND, timescale);
  for (int i = 0; i < referenceCount; i++) {
    int firstInt = atom.readInt();

    int type = 0x80000000 & firstInt;
    if (type != 0) {
      throw new IllegalStateException("Unhandled indirect reference");
    }
    long referenceDuration = atom.readUnsignedInt();

    sizes[i] = 0x7fffffff & firstInt;
    offsets[i] = offset;

    // Calculate time and duration values such that any rounding errors are consistent. i.e. That
    // timesUs[i] + durationsUs[i] == timesUs[i + 1].
    timesUs[i] = timeUs;
    time += referenceDuration;
    timeUs = Util.scaleLargeTimestamp(time, C.MICROS_PER_SECOND, timescale);
    durationsUs[i] = timeUs - timesUs[i];

    atom.skipBytes(4);
    offset += sizes[i];
  }

  return new ChunkIndex(sizes, offsets, durationsUs, timesUs);
}
 
開發者ID:XueyanLiu,項目名稱:miku,代碼行數:56,代碼來源:FragmentedMp4Extractor.java

示例8: DashWrappingSegmentIndex

import com.google.android.exoplayer.extractor.ChunkIndex; //導入依賴的package包/類
/**
 * @param chunkIndex The {@link ChunkIndex} to wrap.
 * @param uri The URI where the data is located.
 * @param startTimeUs The start time of the index, in microseconds.
 */
public DashWrappingSegmentIndex(ChunkIndex chunkIndex, String uri, long startTimeUs) {
  this.chunkIndex = chunkIndex;
  this.uri = uri;
  this.startTimeUs = startTimeUs;
}
 
開發者ID:XueyanLiu,項目名稱:miku,代碼行數:11,代碼來源:DashWrappingSegmentIndex.java

示例9: parseSidx

import com.google.android.exoplayer.extractor.ChunkIndex; //導入依賴的package包/類
/**
 * Parses a sidx atom (defined in 14496-12).
 */
private static ChunkIndex parseSidx(ParsableByteArray atom, long inputPosition)
    throws ParserException {
  atom.setPosition(Atom.HEADER_SIZE);
  int fullAtom = atom.readInt();
  int version = Atom.parseFullAtomVersion(fullAtom);

  atom.skipBytes(4);
  long timescale = atom.readUnsignedInt();
  long earliestPresentationTime;
  long offset = inputPosition;
  if (version == 0) {
    earliestPresentationTime = atom.readUnsignedInt();
    offset += atom.readUnsignedInt();
  } else {
    earliestPresentationTime = atom.readUnsignedLongToLong();
    offset += atom.readUnsignedLongToLong();
  }

  atom.skipBytes(2);

  int referenceCount = atom.readUnsignedShort();
  int[] sizes = new int[referenceCount];
  long[] offsets = new long[referenceCount];
  long[] durationsUs = new long[referenceCount];
  long[] timesUs = new long[referenceCount];

  long time = earliestPresentationTime;
  long timeUs = Util.scaleLargeTimestamp(time, C.MICROS_PER_SECOND, timescale);
  for (int i = 0; i < referenceCount; i++) {
    int firstInt = atom.readInt();

    int type = 0x80000000 & firstInt;
    if (type != 0) {
      throw new ParserException("Unhandled indirect reference");
    }
    long referenceDuration = atom.readUnsignedInt();

    sizes[i] = 0x7FFFFFFF & firstInt;
    offsets[i] = offset;

    // Calculate time and duration values such that any rounding errors are consistent. i.e. That
    // timesUs[i] + durationsUs[i] == timesUs[i + 1].
    timesUs[i] = timeUs;
    time += referenceDuration;
    timeUs = Util.scaleLargeTimestamp(time, C.MICROS_PER_SECOND, timescale);
    durationsUs[i] = timeUs - timesUs[i];

    atom.skipBytes(4);
    offset += sizes[i];
  }

  return new ChunkIndex(sizes, offsets, durationsUs, timesUs);
}
 
開發者ID:asifkhan11,項目名稱:ExoPlayer-Demo,代碼行數:57,代碼來源:FragmentedMp4Extractor.java

示例10: DashWrappingSegmentIndex

import com.google.android.exoplayer.extractor.ChunkIndex; //導入依賴的package包/類
/**
 * @param chunkIndex The {@link ChunkIndex} to wrap.
 * @param uri The URI where the data is located.
 */
public DashWrappingSegmentIndex(ChunkIndex chunkIndex, String uri) {
  this.chunkIndex = chunkIndex;
  this.uri = uri;
}
 
開發者ID:asifkhan11,項目名稱:ExoPlayer-Demo,代碼行數:9,代碼來源:DashWrappingSegmentIndex.java


注:本文中的com.google.android.exoplayer.extractor.ChunkIndex類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。