Java 类com.google.android.exoplayer.dash.mpd.SegmentBase.MultiSegmentBase 实例源码

项目:ExoPlayer-Demo    文件:DashChunkSourceTest.java   
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);
}
项目:ExoPlayer    文件:DashChunkSourceTest.java   
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);
}
项目:miku    文件:Representation.java   
/**
 * Constructs a new instance.
 *
 * @param periodStartMs The start time of the enclosing period in milliseconds.
 * @param periodDurationMs The duration of the enclosing period in milliseconds, or -1 if the
 *     duration is unknown.
 * @param contentId Identifies the piece of content to which this representation belongs.
 * @param revisionId Identifies the revision of the content.
 * @param format The format of the representation.
 * @param segmentBase A segment base element for the representation.
 * @return The constructed instance.
 */
public static Representation newInstance(long periodStartMs, long periodDurationMs,
    String contentId, long revisionId, Format format, SegmentBase segmentBase) {
  if (segmentBase instanceof SingleSegmentBase) {
    return new SingleSegmentRepresentation(periodStartMs, periodDurationMs, contentId, revisionId,
        format, (SingleSegmentBase) segmentBase, -1);
  } else if (segmentBase instanceof MultiSegmentBase) {
    return new MultiSegmentRepresentation(periodStartMs, periodDurationMs, contentId, revisionId,
        format, (MultiSegmentBase) segmentBase);
  } else {
    throw new IllegalArgumentException("segmentBase must be of type SingleSegmentBase or "
        + "MultiSegmentBase");
  }
}
项目:ExoPlayer-Demo    文件:Representation.java   
/**
 * Constructs a new instance.
 *
 * @param contentId Identifies the piece of content to which this representation belongs.
 * @param revisionId Identifies the revision of the content.
 * @param format The format of the representation.
 * @param segmentBase A segment base element for the representation.
 * @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null.
 * @return The constructed instance.
 */
public static Representation newInstance(String contentId, long revisionId, Format format,
    SegmentBase segmentBase, String customCacheKey) {
  if (segmentBase instanceof SingleSegmentBase) {
    return new SingleSegmentRepresentation(contentId, revisionId, format,
        (SingleSegmentBase) segmentBase, customCacheKey, -1);
  } else if (segmentBase instanceof MultiSegmentBase) {
    return new MultiSegmentRepresentation(contentId, revisionId, format,
        (MultiSegmentBase) segmentBase, customCacheKey);
  } else {
    throw new IllegalArgumentException("segmentBase must be of type SingleSegmentBase or "
        + "MultiSegmentBase");
  }
}
项目:ExoPlayer-Demo    文件:DashChunkSourceTest.java   
private static Representation buildSegmentTemplateRepresentation() {
  UrlTemplate initializationTemplate = null;
  UrlTemplate mediaTemplate = UrlTemplate.compile("$RepresentationID$/$Number$");
  MultiSegmentBase segmentBase = new SegmentTemplate(null, 1000, 0, 0, LIVE_SEGMENT_DURATION_MS,
      null, initializationTemplate, mediaTemplate, "http://www.youtube.com");
  return Representation.newInstance(null, 0, REGULAR_VIDEO, segmentBase);
}
项目:android-exoplayer    文件:Representation.java   
/**
 * Constructs a new instance.
 *
 * @param periodStartMs The start time of the enclosing period in milliseconds.
 * @param periodDurationMs The duration of the enclosing period in milliseconds, or -1 if the
 *     duration is unknown.
 * @param contentId Identifies the piece of content to which this representation belongs.
 * @param revisionId Identifies the revision of the content.
 * @param format The format of the representation.
 * @param segmentBase A segment base element for the representation.
 * @return The constructed instance.
 */
public static Representation newInstance(long periodStartMs, long periodDurationMs,
    String contentId, long revisionId, Format format, SegmentBase segmentBase) {
  if (segmentBase instanceof SingleSegmentBase) {
    return new SingleSegmentRepresentation(periodStartMs, periodDurationMs, contentId, revisionId,
        format, (SingleSegmentBase) segmentBase, -1);
  } else if (segmentBase instanceof MultiSegmentBase) {
    return new MultiSegmentRepresentation(periodStartMs, periodDurationMs, contentId, revisionId,
        format, (MultiSegmentBase) segmentBase);
  } else {
    throw new IllegalArgumentException("segmentBase must be of type SingleSegmentBase or "
        + "MultiSegmentBase");
  }
}
项目:Exoplayer_VLC    文件:Representation.java   
/**
 * Constructs a new instance.
 *
 * @param periodStartMs The start time of the enclosing period in milliseconds.
 * @param periodDurationMs The duration of the enclosing period in milliseconds, or -1 if the
 *     duration is unknown.
 * @param contentId Identifies the piece of content to which this representation belongs.
 * @param revisionId Identifies the revision of the content.
 * @param format The format of the representation.
 * @param segmentBase A segment base element for the representation.
 * @return The constructed instance.
 */
public static Representation newInstance(long periodStartMs, long periodDurationMs,
    String contentId, long revisionId, Format format, SegmentBase segmentBase) {
  if (segmentBase instanceof SingleSegmentBase) {
    return new SingleSegmentRepresentation(periodStartMs, periodDurationMs, contentId, revisionId,
        format, (SingleSegmentBase) segmentBase, -1);
  } else if (segmentBase instanceof MultiSegmentBase) {
    return new MultiSegmentRepresentation(periodStartMs, periodDurationMs, contentId, revisionId,
        format, (MultiSegmentBase) segmentBase);
  } else {
    throw new IllegalArgumentException("segmentBase must be of type SingleSegmentBase or "
        + "MultiSegmentBase");
  }
}
项目:edx-app-android    文件:Representation.java   
/**
 * Constructs a new instance.
 *
 * @param periodStartMs The start time of the enclosing period in milliseconds.
 * @param periodDurationMs The duration of the enclosing period in milliseconds, or -1 if the
 *     duration is unknown.
 * @param contentId Identifies the piece of content to which this representation belongs.
 * @param revisionId Identifies the revision of the content.
 * @param format The format of the representation.
 * @param segmentBase A segment base element for the representation.
 * @return The constructed instance.
 */
public static Representation newInstance(long periodStartMs, long periodDurationMs,
    String contentId, long revisionId, Format format, SegmentBase segmentBase) {
  if (segmentBase instanceof SingleSegmentBase) {
    return new SingleSegmentRepresentation(periodStartMs, periodDurationMs, contentId, revisionId,
        format, (SingleSegmentBase) segmentBase, -1);
  } else if (segmentBase instanceof MultiSegmentBase) {
    return new MultiSegmentRepresentation(periodStartMs, periodDurationMs, contentId, revisionId,
        format, (MultiSegmentBase) segmentBase);
  } else {
    throw new IllegalArgumentException("segmentBase must be of type SingleSegmentBase or "
        + "MultiSegmentBase");
  }
}
项目:ExoPlayer    文件:Representation.java   
/**
 * Constructs a new instance.
 *
 * @param periodStartMs The start time of the enclosing period in milliseconds.
 * @param periodDurationMs The duration of the enclosing period in milliseconds, or -1 if the
 *     duration is unknown.
 * @param contentId Identifies the piece of content to which this representation belongs.
 * @param revisionId Identifies the revision of the content.
 * @param format The format of the representation.
 * @param segmentBase A segment base element for the representation.
 * @return The constructed instance.
 */
public static Representation newInstance(long periodStartMs, long periodDurationMs,
    String contentId, long revisionId, Format format, SegmentBase segmentBase) {
  if (segmentBase instanceof SingleSegmentBase) {
    return new SingleSegmentRepresentation(periodStartMs, periodDurationMs, contentId, revisionId,
        format, (SingleSegmentBase) segmentBase, -1);
  } else if (segmentBase instanceof MultiSegmentBase) {
    return new MultiSegmentRepresentation(periodStartMs, periodDurationMs, contentId, revisionId,
        format, (MultiSegmentBase) segmentBase);
  } else {
    throw new IllegalArgumentException("segmentBase must be of type SingleSegmentBase or "
        + "MultiSegmentBase");
  }
}
项目:ExoPlayer    文件:DashChunkSourceTest.java   
private static MediaPresentationDescription generateLiveMpdWithTemplate(
    boolean limitTimeshiftBuffer) {
  List<Representation> representations = new ArrayList<>();

  UrlTemplate initializationTemplate = null;
  UrlTemplate mediaTemplate = UrlTemplate.compile("$RepresentationID$/$Number$");
  MultiSegmentBase segmentBase = new SegmentTemplate(null, 1000, 0,
      TrackRenderer.UNKNOWN_TIME_US, 0, LIVE_SEGMENT_DURATION_MS, null,
      initializationTemplate, mediaTemplate, "http://www.youtube.com");
  Representation representation = Representation.newInstance(0, TrackRenderer.UNKNOWN_TIME_US,
      null, 0, REGULAR_VIDEO, segmentBase);
  representations.add(representation);

  return generateMpd(true, representations, limitTimeshiftBuffer);
}
项目:miku    文件:Representation.java   
/**
 * @param periodStartMs The start time of the enclosing period in milliseconds.
 * @param periodDurationMs The duration of the enclosing period in milliseconds, or -1 if the
 *     duration is unknown.
 * @param contentId Identifies the piece of content to which this representation belongs.
 * @param revisionId Identifies the revision of the content.
 * @param format The format of the representation.
 * @param segmentBase The segment base underlying the representation.
 */
public MultiSegmentRepresentation(long periodStartMs, long periodDurationMs, String contentId,
    long revisionId, Format format, MultiSegmentBase segmentBase) {
  super(periodStartMs, periodDurationMs, contentId, revisionId, format, segmentBase);
  this.segmentBase = segmentBase;
}
项目:ExoPlayer-Demo    文件:Representation.java   
/**
 * @param contentId Identifies the piece of content to which this representation belongs.
 * @param revisionId Identifies the revision of the content.
 * @param format The format of the representation.
 * @param segmentBase The segment base underlying the representation.
 * @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null.
 */
public MultiSegmentRepresentation(String contentId, long revisionId, Format format,
    MultiSegmentBase segmentBase, String customCacheKey) {
  super(contentId, revisionId, format, segmentBase, customCacheKey);
  this.segmentBase = segmentBase;
}
项目:android-exoplayer    文件:Representation.java   
/**
 * @param periodStartMs The start time of the enclosing period in milliseconds.
 * @param periodDurationMs The duration of the enclosing period in milliseconds, or -1 if the
 *     duration is unknown.
 * @param contentId Identifies the piece of content to which this representation belongs.
 * @param revisionId Identifies the revision of the content.
 * @param format The format of the representation.
 * @param segmentBase The segment base underlying the representation.
 */
public MultiSegmentRepresentation(long periodStartMs, long periodDurationMs, String contentId,
    long revisionId, Format format, MultiSegmentBase segmentBase) {
  super(periodStartMs, periodDurationMs, contentId, revisionId, format, segmentBase);
  this.segmentBase = segmentBase;
}
项目:Exoplayer_VLC    文件:Representation.java   
/**
 * @param periodStartMs The start time of the enclosing period in milliseconds.
 * @param periodDurationMs The duration of the enclosing period in milliseconds, or -1 if the
 *     duration is unknown.
 * @param contentId Identifies the piece of content to which this representation belongs.
 * @param revisionId Identifies the revision of the content.
 * @param format The format of the representation.
 * @param segmentBase The segment base underlying the representation.
 */
public MultiSegmentRepresentation(long periodStartMs, long periodDurationMs, String contentId,
    long revisionId, Format format, MultiSegmentBase segmentBase) {
  super(periodStartMs, periodDurationMs, contentId, revisionId, format, segmentBase);
  this.segmentBase = segmentBase;
}
项目:edx-app-android    文件:Representation.java   
/**
 * @param periodStartMs The start time of the enclosing period in milliseconds.
 * @param periodDurationMs The duration of the enclosing period in milliseconds, or -1 if the
 *     duration is unknown.
 * @param contentId Identifies the piece of content to which this representation belongs.
 * @param revisionId Identifies the revision of the content.
 * @param format The format of the representation.
 * @param segmentBase The segment base underlying the representation.
 */
public MultiSegmentRepresentation(long periodStartMs, long periodDurationMs, String contentId,
    long revisionId, Format format, MultiSegmentBase segmentBase) {
  super(periodStartMs, periodDurationMs, contentId, revisionId, format, segmentBase);
  this.segmentBase = segmentBase;
}
项目:ExoPlayer    文件:Representation.java   
/**
 * @param periodStartMs The start time of the enclosing period in milliseconds.
 * @param periodDurationMs The duration of the enclosing period in milliseconds, or -1 if the
 *     duration is unknown.
 * @param contentId Identifies the piece of content to which this representation belongs.
 * @param revisionId Identifies the revision of the content.
 * @param format The format of the representation.
 * @param segmentBase The segment base underlying the representation.
 */
public MultiSegmentRepresentation(long periodStartMs, long periodDurationMs, String contentId,
    long revisionId, Format format, MultiSegmentBase segmentBase) {
  super(periodStartMs, periodDurationMs, contentId, revisionId, format, segmentBase);
  this.segmentBase = segmentBase;
}