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


Java Representation类代码示例

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


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

示例1: newInitializationChunk

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
private Chunk newInitializationChunk(RangedUri initializationUri, RangedUri indexUri,
    Representation representation, ChunkExtractorWrapper extractor, DataSource dataSource,
    int trigger) {
  RangedUri requestUri;
  if (initializationUri != null) {
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri);
    if (requestUri == null) {
      requestUri = initializationUri;
    }
  } else {
    requestUri = indexUri;
  }
  DataSpec dataSpec = new DataSpec(requestUri.getUri(), requestUri.start, requestUri.length,
      representation.getCacheKey());
  return new InitializationChunk(dataSource, dataSpec, trigger, representation.format, extractor);
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:19,代码来源:DashChunkSource.java

示例2: newInitializationChunk

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
private Chunk newInitializationChunk(RangedUri initializationUri, RangedUri indexUri,
    Representation representation, ChunkExtractorWrapper extractor, DataSource dataSource,
    int manifestIndex, int trigger) {
  RangedUri requestUri;
  if (initializationUri != null) {
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri);
    if (requestUri == null) {
      requestUri = initializationUri;
    }
  } else {
    requestUri = indexUri;
  }
  DataSpec dataSpec = new DataSpec(requestUri.getUri(), requestUri.start, requestUri.length,
      representation.getCacheKey());
  return new InitializationChunk(dataSource, dataSpec, trigger, representation.format,
      extractor, manifestIndex);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:20,代码来源:DashChunkSource.java

示例3: newMediaChunk

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
protected Chunk newMediaChunk(
    PeriodHolder periodHolder, RepresentationHolder representationHolder, DataSource dataSource,
    MediaFormat mediaFormat, ExposedTrack enabledTrack, int segmentNum, int trigger) {
  Representation representation = representationHolder.representation;
  Format format = representation.format;
  long startTimeUs = representationHolder.getSegmentStartTimeUs(segmentNum);
  long endTimeUs = representationHolder.getSegmentEndTimeUs(segmentNum);
  RangedUri segmentUri = representationHolder.getSegmentUrl(segmentNum);
  DataSpec dataSpec = new DataSpec(segmentUri.getUri(), segmentUri.start, segmentUri.length,
      representation.getCacheKey());

  long sampleOffsetUs = periodHolder.startTimeUs - representation.presentationTimeOffsetUs;
  if (mimeTypeIsRawText(format.mimeType)) {
    return new SingleSampleMediaChunk(dataSource, dataSpec, Chunk.TRIGGER_INITIAL, format,
        startTimeUs, endTimeUs, segmentNum, enabledTrack.trackFormat, null,
        periodHolder.localIndex);
  } else {
    boolean isMediaFormatFinal = (mediaFormat != null);
    return new ContainerMediaChunk(dataSource, dataSpec, trigger, format, startTimeUs, endTimeUs,
        segmentNum, sampleOffsetUs, representationHolder.extractorWrapper, mediaFormat,
        enabledTrack.adaptiveMaxWidth, enabledTrack.adaptiveMaxHeight, periodHolder.drmInitData,
        isMediaFormatFinal, periodHolder.localIndex);
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:25,代码来源:DashChunkSource.java

示例4: updateRepresentationIndependentProperties

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
private void updateRepresentationIndependentProperties(long periodDurationUs,
    Representation arbitaryRepresentation) {
  DashSegmentIndex segmentIndex = arbitaryRepresentation.getIndex();
  if (segmentIndex != null) {
    int firstSegmentNum = segmentIndex.getFirstSegmentNum();
    int lastSegmentNum = segmentIndex.getLastSegmentNum(periodDurationUs);
    indexIsUnbounded = lastSegmentNum == DashSegmentIndex.INDEX_UNBOUNDED;
    indexIsExplicit = segmentIndex.isExplicit();
    availableStartTimeUs = startTimeUs + segmentIndex.getTimeUs(firstSegmentNum);
    if (!indexIsUnbounded) {
      availableEndTimeUs = startTimeUs + segmentIndex.getTimeUs(lastSegmentNum)
          + segmentIndex.getDurationUs(lastSegmentNum, periodDurationUs);
    }
  } else {
    indexIsUnbounded = false;
    indexIsExplicit = true;
    availableStartTimeUs = startTimeUs;
    availableEndTimeUs = startTimeUs + periodDurationUs;
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:21,代码来源:DashChunkSource.java

示例5: buildSegmentTimelineRepresentation

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
private static Representation buildSegmentTimelineRepresentation(long timelineDurationMs,
    long timelineStartTimeMs) {
  List<SegmentTimelineElement> segmentTimeline = new ArrayList<>();
  List<RangedUri> mediaSegments = new ArrayList<>();
  long segmentStartTimeMs = timelineStartTimeMs;
  long byteStart = 0;
  // Create all but the last segment with LIVE_SEGMENT_DURATION_MS.
  int segmentCount = (int) Util.ceilDivide(timelineDurationMs, LIVE_SEGMENT_DURATION_MS);
  for (int i = 0; i < segmentCount - 1; i++) {
    segmentTimeline.add(new SegmentTimelineElement(segmentStartTimeMs, LIVE_SEGMENT_DURATION_MS));
    mediaSegments.add(new RangedUri("", "", byteStart, 500L));
    segmentStartTimeMs += LIVE_SEGMENT_DURATION_MS;
    byteStart += 500;
  }
  // The final segment duration is calculated so that the total duration is timelineDurationMs.
  long finalSegmentDurationMs = (timelineStartTimeMs + timelineDurationMs) - segmentStartTimeMs;
  segmentTimeline.add(new SegmentTimelineElement(segmentStartTimeMs, finalSegmentDurationMs));
  mediaSegments.add(new RangedUri("", "", byteStart, 500L));
  segmentStartTimeMs += finalSegmentDurationMs;
  byteStart += 500;
  // Construct the list.
  MultiSegmentBase segmentBase = new SegmentList(null, 1000, 0, 0, 0, segmentTimeline,
      mediaSegments);
  return Representation.newInstance(null, 0, REGULAR_VIDEO, segmentBase);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:26,代码来源:DashChunkSourceTest.java

示例6: testMaxVideoDimensionsLegacy

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
public void testMaxVideoDimensionsLegacy() {
  SingleSegmentBase segmentBase1 = new SingleSegmentBase("https://example.com/1.mp4");
  Representation representation1 =
      Representation.newInstance(0, 0, null, 0, TALL_VIDEO, segmentBase1);

  SingleSegmentBase segmentBase2 = new SingleSegmentBase("https://example.com/2.mp4");
  Representation representation2 =
      Representation.newInstance(0, 0, null, 0, WIDE_VIDEO, segmentBase2);

  DashChunkSource chunkSource = new DashChunkSource(null, null, representation1, representation2);
  MediaFormat out = MediaFormat.createVideoFormat("video/h264", 1, 1, 1, 1, null);
  chunkSource.getMaxVideoDimensions(out);

  assertEquals(WIDE_WIDTH, out.getMaxVideoWidth());
  assertEquals(TALL_HEIGHT, out.getMaxVideoHeight());
}
 
开发者ID:raphanda,项目名称:ExoPlayer,代码行数:17,代码来源:DashChunkSourceTest.java

示例7: generateSegmentTimelineRepresentation

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
private static Representation generateSegmentTimelineRepresentation(long segmentStartMs,
    long periodStartMs, long duration) {
  List<SegmentTimelineElement> segmentTimeline = new ArrayList<>();
  List<RangedUri> mediaSegments = new ArrayList<>();
  long segmentStartTimeMs = segmentStartMs;
  long byteStart = 0;
  for (int i = 0; i < (duration / LIVE_SEGMENT_DURATION_MS); i++) {
    segmentTimeline.add(new SegmentTimelineElement(segmentStartTimeMs, LIVE_SEGMENT_DURATION_MS));
    mediaSegments.add(new RangedUri("", "", byteStart, 500L));
    segmentStartTimeMs += LIVE_SEGMENT_DURATION_MS;
    byteStart += 500;
  }

  int startNumber = (int) ((periodStartMs + segmentStartMs) / LIVE_SEGMENT_DURATION_MS);
  MultiSegmentBase segmentBase = new SegmentList(null, 1000, 0,
      TrackRenderer.UNKNOWN_TIME_US, startNumber, TrackRenderer.UNKNOWN_TIME_US, segmentTimeline,
      mediaSegments);
  return Representation.newInstance(periodStartMs, TrackRenderer.UNKNOWN_TIME_US, null, 0,
      REGULAR_VIDEO, segmentBase);
}
 
开发者ID:raphanda,项目名称:ExoPlayer,代码行数:21,代码来源:DashChunkSourceTest.java

示例8: loadDrmInitData

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
private void loadDrmInitData(Representation representation) throws IOException {
    Uri initFile = representation.getInitializationUri().getUri();
    
    FileDataSource initChunkSource = new FileDataSource();
    DataSpec initDataSpec = new DataSpec(initFile);
    int trigger = 2;
    ChunkExtractorWrapper extractorWrapper = new ChunkExtractorWrapper(new FragmentedMp4Extractor());
    InitializationChunk chunk = new InitializationChunk(initChunkSource, initDataSpec, trigger, format, extractorWrapper);
    try {
        chunk.load();
    } catch (InterruptedException e) {
        Log.d(TAG, "Interrupted!", e);
    }
    if (!chunk.isLoadCanceled()) {
        drmInitData = chunk.getDrmInitData();
    }
    
    if (drmInitData != null) {
        DrmInitData.SchemeInitData schemeInitData = OfflineDrmManager.getWidevineInitData(drmInitData);
        if (schemeInitData != null) {
            widevineInitData = schemeInitData.data;
        }
    }
}
 
开发者ID:kaltura,项目名称:player-sdk-native-android,代码行数:25,代码来源:SimpleDashParser.java

示例9: newMediaChunk

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
private Chunk newMediaChunk(RepresentationHolder representationHolder, DataSource dataSource,
    int segmentNum, int trigger) {
  Representation representation = representationHolder.representation;
  DashSegmentIndex segmentIndex = representationHolder.segmentIndex;

  long startTimeUs = segmentIndex.getTimeUs(segmentNum);
  long endTimeUs = startTimeUs + segmentIndex.getDurationUs(segmentNum);

  int absoluteSegmentNum = segmentNum + representationHolder.segmentNumShift;
  boolean isLastSegment = !currentManifest.dynamic
      && segmentNum == segmentIndex.getLastSegmentNum();

  RangedUri segmentUri = segmentIndex.getSegmentUrl(segmentNum);
  DataSpec dataSpec = new DataSpec(segmentUri.getUri(), segmentUri.start, segmentUri.length,
      representation.getCacheKey());

  long sampleOffsetUs = representation.periodStartMs * 1000
      - representation.presentationTimeOffsetUs;
  if (representation.format.mimeType.equals(MimeTypes.TEXT_VTT)) {
    if (representationHolder.vttHeaderOffsetUs != sampleOffsetUs) {
      // Update the VTT header.
      headerBuilder.setLength(0);
      headerBuilder.append(C.WEBVTT_EXO_HEADER).append("=")
          .append(C.WEBVTT_EXO_HEADER_OFFSET).append(sampleOffsetUs)
          .append("\n");
      representationHolder.vttHeader = headerBuilder.toString().getBytes();
      representationHolder.vttHeaderOffsetUs = sampleOffsetUs;
    }
    return new SingleSampleMediaChunk(dataSource, dataSpec, Chunk.TRIGGER_INITIAL,
        representation.format, startTimeUs, endTimeUs, absoluteSegmentNum, isLastSegment,
        MediaFormat.createTextFormat(MimeTypes.TEXT_VTT), null, representationHolder.vttHeader);
  } else {
    return new ContainerMediaChunk(dataSource, dataSpec, trigger, representation.format,
        startTimeUs, endTimeUs, absoluteSegmentNum, isLastSegment, sampleOffsetUs,
        representationHolder.extractorWrapper, representationHolder.format, drmInitData, true);
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:38,代码来源:DashChunkSource.java

示例10: buildManifest

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
private static MediaPresentationDescription buildManifest(List<Representation> representations) {
  Representation firstRepresentation = representations.get(0);
  AdaptationSet adaptationSet = new AdaptationSet(0, AdaptationSet.TYPE_UNKNOWN, representations);
  Period period = new Period(null, firstRepresentation.periodStartMs,
      firstRepresentation.periodDurationMs, Collections.singletonList(adaptationSet));
  long duration = firstRepresentation.periodDurationMs - firstRepresentation.periodStartMs;
  return new MediaPresentationDescription(-1, duration, -1, false, -1, -1, null, null,
      Collections.singletonList(period));
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:10,代码来源:DashChunkSource.java

示例11: getRepresentationIndices

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
private static int[] getRepresentationIndices(AdaptationSet adaptationSet,
    String[] representationIds, boolean canIncludeAdditionalVideoRepresentations)
    throws IOException {
  List<Representation> availableRepresentations = adaptationSet.representations;
  List<Integer> selectedRepresentationIndices = new ArrayList<>();

  // Always select explicitly listed representations, failing if they're missing.
  for (int i = 0; i < representationIds.length; i++) {
    String representationId = representationIds[i];
    boolean foundIndex = false;
    for (int j = 0; j < availableRepresentations.size() && !foundIndex; j++) {
      if (availableRepresentations.get(j).format.id.equals(representationId)) {
        selectedRepresentationIndices.add(j);
        foundIndex = true;
      }
    }
    if (!foundIndex) {
      throw new IllegalStateException("Representation " + representationId + " not found.");
    }
  }

  // Select additional video representations, if supported by the device.
  if (canIncludeAdditionalVideoRepresentations) {
     int[] supportedVideoRepresentationIndices = VideoFormatSelectorUtil.selectVideoFormats(
         availableRepresentations, null, false, true, -1, -1);
     for (int i = 0; i < supportedVideoRepresentationIndices.length; i++) {
       int representationIndex = supportedVideoRepresentationIndices[i];
       if (!selectedRepresentationIndices.contains(representationIndex)) {
         Log.d(TAG, "Adding video format: " + availableRepresentations.get(i).format.id);
         selectedRepresentationIndices.add(representationIndex);
       }
     }

  }

  return Util.toArray(selectedRepresentationIndices);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:38,代码来源:DashTest.java

示例12: buildManifest

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
private static MediaPresentationDescription buildManifest(long durationMs,
    int adaptationSetType, List<Representation> representations) {
  AdaptationSet adaptationSet = new AdaptationSet(0, adaptationSetType, representations);
  Period period = new Period(null, 0, Collections.singletonList(adaptationSet));
  return new MediaPresentationDescription(-1, durationMs, -1, false, -1, -1, null, null,
      Collections.singletonList(period));
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:8,代码来源:DashChunkSource.java

示例13: RepresentationHolder

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
public RepresentationHolder(long periodStartTimeUs, long periodDurationUs,
    Representation representation) {
  this.periodStartTimeUs = periodStartTimeUs;
  this.periodDurationUs = periodDurationUs;
  this.representation = representation;
  String mimeType = representation.format.mimeType;
  mimeTypeIsRawText = mimeTypeIsRawText(mimeType);
  extractorWrapper = mimeTypeIsRawText ? null : new ChunkExtractorWrapper(
      mimeTypeIsWebm(mimeType) ? new WebmExtractor() : new FragmentedMp4Extractor());
  segmentIndex = representation.getIndex();
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:12,代码来源:DashChunkSource.java

示例14: updateRepresentation

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
public void updateRepresentation(long newPeriodDurationUs, Representation newRepresentation)
    throws BehindLiveWindowException{
  DashSegmentIndex oldIndex = representation.getIndex();
  DashSegmentIndex newIndex = newRepresentation.getIndex();

  periodDurationUs = newPeriodDurationUs;
  representation = newRepresentation;
  if (oldIndex == null) {
    // Segment numbers cannot shift if the index isn't defined by the manifest.
    return;
  }

  segmentIndex = newIndex;
  if (!oldIndex.isExplicit()) {
    // Segment numbers cannot shift if the index isn't explicit.
    return;
  }

  int oldIndexLastSegmentNum = oldIndex.getLastSegmentNum(periodDurationUs);
  long oldIndexEndTimeUs = oldIndex.getTimeUs(oldIndexLastSegmentNum)
      + oldIndex.getDurationUs(oldIndexLastSegmentNum, periodDurationUs);
  int newIndexFirstSegmentNum = newIndex.getFirstSegmentNum();
  long newIndexStartTimeUs = newIndex.getTimeUs(newIndexFirstSegmentNum);
  if (oldIndexEndTimeUs == newIndexStartTimeUs) {
    // The new index continues where the old one ended, with no overlap.
    segmentNumShift += oldIndex.getLastSegmentNum(periodDurationUs) + 1
        - newIndexFirstSegmentNum;
  } else if (oldIndexEndTimeUs < newIndexStartTimeUs) {
    // There's a gap between the old index and the new one which means we've slipped behind the
    // live window and can't proceed.
    throw new BehindLiveWindowException();
  } else {
    // The new index overlaps with the old one.
    segmentNumShift += oldIndex.getSegmentNum(newIndexStartTimeUs, periodDurationUs)
        - newIndexFirstSegmentNum;
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:38,代码来源:DashChunkSource.java

示例15: PeriodHolder

import com.google.android.exoplayer.dash.mpd.Representation; //导入依赖的package包/类
public PeriodHolder(int localIndex, MediaPresentationDescription manifest, int manifestIndex,
    ExposedTrack selectedTrack) {
  this.localIndex = localIndex;

  Period period = manifest.getPeriod(manifestIndex);
  long periodDurationUs = getPeriodDurationUs(manifest, manifestIndex);
  AdaptationSet adaptationSet = period.adaptationSets.get(selectedTrack.adaptationSetIndex);
  List<Representation> representations = adaptationSet.representations;

  startTimeUs = period.startMs * 1000;
  drmInitData = getDrmInitData(adaptationSet);

  if (!selectedTrack.isAdaptive()) {
    representationIndices = new int[] {
        getRepresentationIndex(representations, selectedTrack.fixedFormat.id)};
  } else {
    representationIndices = new int[selectedTrack.adaptiveFormats.length];
    for (int j = 0; j < selectedTrack.adaptiveFormats.length; j++) {
      representationIndices[j] = getRepresentationIndex(
          representations, selectedTrack.adaptiveFormats[j].id);
    }
  }

  representationHolders = new HashMap<>();
  for (int i = 0; i < representationIndices.length; i++) {
    Representation representation = representations.get(representationIndices[i]);
    RepresentationHolder representationHolder = new RepresentationHolder(startTimeUs,
        periodDurationUs, representation);
    representationHolders.put(representation.format.id, representationHolder);
  }
  updateRepresentationIndependentProperties(periodDurationUs,
      representations.get(representationIndices[0]));
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:34,代码来源:DashChunkSource.java


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