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

项目:ExoPlayer    文件:DashChunkSourceTest.java   
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());
}
项目: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");
  }
}
项目: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.
 * @param contentLength The content length, or -1 if unknown.
 */
public SingleSegmentRepresentation(long periodStartMs, long periodDurationMs, String contentId,
    long revisionId, Format format, SingleSegmentBase segmentBase, long contentLength) {
  super(periodStartMs, periodDurationMs, contentId, revisionId, format, segmentBase);
  this.uri = Uri.parse(segmentBase.uri);
  this.indexUri = segmentBase.getIndex();
  this.contentLength = contentLength;
  // If we have an index uri then the index is defined externally, and we shouldn't return one
  // directly. If we don't, then we can't do better than an index defining a single segment.
  segmentIndex = indexUri != null ? null : new DashSingleSegmentIndex(periodStartMs * 1000,
      periodDurationMs * 1000, new RangedUri(segmentBase.uri, null, 0, -1));
}
项目:miku    文件:MediaPresentationDescriptionParser.java   
protected SingleSegmentBase parseSegmentBase(XmlPullParser xpp, String baseUrl,
    SingleSegmentBase parent) throws XmlPullParserException, IOException {

  long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1);
  long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset",
      parent != null ? parent.presentationTimeOffset : 0);

  long indexStart = parent != null ? parent.indexStart : 0;
  long indexLength = parent != null ? parent.indexLength : -1;
  String indexRangeText = xpp.getAttributeValue(null, "indexRange");
  if (indexRangeText != null) {
    String[] indexRange = indexRangeText.split("-");
    indexStart = Long.parseLong(indexRange[0]);
    indexLength = Long.parseLong(indexRange[1]) - indexStart + 1;
  }

  RangedUri initialization = parent != null ? parent.initialization : null;
  do {
    xpp.next();
    if (isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp, baseUrl);
    }
  } while (!isEndTag(xpp, "SegmentBase"));

  return buildSingleSegmentBase(initialization, timescale, presentationTimeOffset, baseUrl,
      indexStart, indexLength);
}
项目: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    文件: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.
 * @param contentLength The content length, or -1 if unknown.
 */
public SingleSegmentRepresentation(String contentId, long revisionId, Format format,
    SingleSegmentBase segmentBase, String customCacheKey, long contentLength) {
  super(contentId, revisionId, format, segmentBase, customCacheKey);
  this.uri = Uri.parse(segmentBase.uri);
  this.indexUri = segmentBase.getIndex();
  this.contentLength = contentLength;
  // If we have an index uri then the index is defined externally, and we shouldn't return one
  // directly. If we don't, then we can't do better than an index defining a single segment.
  segmentIndex = indexUri != null ? null
      : new DashSingleSegmentIndex(new RangedUri(segmentBase.uri, null, 0, contentLength));
}
项目:ExoPlayer-Demo    文件:MediaPresentationDescriptionParser.java   
protected SingleSegmentBase parseSegmentBase(XmlPullParser xpp, String baseUrl,
    SingleSegmentBase parent) throws XmlPullParserException, IOException {

  long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1);
  long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset",
      parent != null ? parent.presentationTimeOffset : 0);

  long indexStart = parent != null ? parent.indexStart : 0;
  long indexLength = parent != null ? parent.indexLength : -1;
  String indexRangeText = xpp.getAttributeValue(null, "indexRange");
  if (indexRangeText != null) {
    String[] indexRange = indexRangeText.split("-");
    indexStart = Long.parseLong(indexRange[0]);
    indexLength = Long.parseLong(indexRange[1]) - indexStart + 1;
  }

  RangedUri initialization = parent != null ? parent.initialization : null;
  do {
    xpp.next();
    if (ParserUtil.isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp, baseUrl);
    }
  } while (!ParserUtil.isEndTag(xpp, "SegmentBase"));

  return buildSingleSegmentBase(initialization, timescale, presentationTimeOffset, baseUrl,
      indexStart, indexLength);
}
项目: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");
  }
}
项目:android-exoplayer    文件:MediaPresentationDescriptionParser.java   
protected Representation parseRepresentation(XmlPullParser xpp, String contentId, Uri baseUrl,
    long periodStartMs, long periodDurationMs, String mimeType, String language,
    SegmentBase segmentBase) throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth");
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate");
  int width = parseInt(xpp, "width");
  int height = parseInt(xpp, "height");
  mimeType = parseString(xpp, "mimeType", mimeType);

  int numChannels = -1;
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "AudioChannelConfiguration")) {
      numChannels = Integer.parseInt(xpp.getAttributeValue(null, "value"));
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    }
  } while (!isEndTag(xpp, "Representation"));

  Format format = buildFormat(id, mimeType, width, height, numChannels, audioSamplingRate,
      bandwidth, language);
  return buildRepresentation(periodStartMs, periodDurationMs, contentId, -1, format,
      segmentBase);
}
项目:android-exoplayer    文件:MediaPresentationDescriptionParser.java   
protected SingleSegmentBase parseSegmentBase(XmlPullParser xpp, Uri baseUrl,
    SingleSegmentBase parent) throws XmlPullParserException, IOException {

  long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1);
  long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset",
      parent != null ? parent.presentationTimeOffset : 0);

  long indexStart = parent != null ? parent.indexStart : 0;
  long indexLength = parent != null ? parent.indexLength : -1;
  String indexRangeText = xpp.getAttributeValue(null, "indexRange");
  if (indexRangeText != null) {
    String[] indexRange = indexRangeText.split("-");
    indexStart = Long.parseLong(indexRange[0]);
    indexLength = Long.parseLong(indexRange[1]) - indexStart + 1;
  }

  RangedUri initialization = parent != null ? parent.initialization : null;
  do {
    xpp.next();
    if (isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp, baseUrl);
    }
  } while (!isEndTag(xpp, "SegmentBase"));

  return buildSingleSegmentBase(initialization, timescale, presentationTimeOffset, baseUrl,
      indexStart, indexLength);
}
项目: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");
  }
}
项目: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.
 * @param contentLength The content length, or -1 if unknown.
 */
public SingleSegmentRepresentation(long periodStartMs, long periodDurationMs, String contentId,
    long revisionId, Format format, SingleSegmentBase segmentBase, long contentLength) {
  super(periodStartMs, periodDurationMs, contentId, revisionId, format, segmentBase);
  this.uri = segmentBase.uri;
  this.indexUri = segmentBase.getIndex();
  this.contentLength = contentLength;
  // If we have an index uri then the index is defined externally, and we shouldn't return one
  // directly. If we don't, then we can't do better than an index defining a single segment.
  segmentIndex = indexUri != null ? null : new DashSingleSegmentIndex(periodStartMs * 1000,
      periodDurationMs * 1000, new RangedUri(uri, null, 0, -1));
}
项目:Exoplayer_VLC    文件:MediaPresentationDescriptionParser.java   
protected Representation parseRepresentation(XmlPullParser xpp, String contentId, Uri baseUrl,
    long periodStartMs, long periodDurationMs, String mimeType, String language,
    SegmentBase segmentBase) throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth");
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate");
  int width = parseInt(xpp, "width");
  int height = parseInt(xpp, "height");
  mimeType = parseString(xpp, "mimeType", mimeType);
  String codecs = parseString(xpp, "codecs", null);

  int numChannels = -1;
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "AudioChannelConfiguration")) {
      numChannels = Integer.parseInt(xpp.getAttributeValue(null, "value"));
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    }
  } while (!isEndTag(xpp, "Representation"));

  Format format = buildFormat(id, mimeType, width, height, numChannels, audioSamplingRate,
      bandwidth, language, codecs);
  return buildRepresentation(periodStartMs, periodDurationMs, contentId, -1, format,
      segmentBase != null ? segmentBase : new SingleSegmentBase(baseUrl));
}
项目:Exoplayer_VLC    文件:MediaPresentationDescriptionParser.java   
protected SingleSegmentBase parseSegmentBase(XmlPullParser xpp, Uri baseUrl,
    SingleSegmentBase parent) throws XmlPullParserException, IOException {

  long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1);
  long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset",
      parent != null ? parent.presentationTimeOffset : 0);

  long indexStart = parent != null ? parent.indexStart : 0;
  long indexLength = parent != null ? parent.indexLength : -1;
  String indexRangeText = xpp.getAttributeValue(null, "indexRange");
  if (indexRangeText != null) {
    String[] indexRange = indexRangeText.split("-");
    indexStart = Long.parseLong(indexRange[0]);
    indexLength = Long.parseLong(indexRange[1]) - indexStart + 1;
  }

  RangedUri initialization = parent != null ? parent.initialization : null;
  do {
    xpp.next();
    if (isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp, baseUrl);
    }
  } while (!isEndTag(xpp, "SegmentBase"));

  return buildSingleSegmentBase(initialization, timescale, presentationTimeOffset, baseUrl,
      indexStart, indexLength);
}
项目: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");
  }
}
项目:edx-app-android    文件:MediaPresentationDescriptionParser.java   
private Representation parseRepresentation(XmlPullParser xpp, String contentId, Uri baseUrl,
    long periodStartMs, long periodDurationMs, String mimeType, String language,
    SegmentBase segmentBase) throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth");
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate");
  int width = parseInt(xpp, "width");
  int height = parseInt(xpp, "height");
  mimeType = parseString(xpp, "mimeType", mimeType);

  int numChannels = -1;
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "AudioChannelConfiguration")) {
      numChannels = Integer.parseInt(xpp.getAttributeValue(null, "value"));
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    }
  } while (!isEndTag(xpp, "Representation"));

  Format format = new Format(id, mimeType, width, height, numChannels, audioSamplingRate,
      bandwidth, language);
  return Representation.newInstance(periodStartMs, periodDurationMs, contentId, -1, format,
      segmentBase);
}
项目:edx-app-android    文件:MediaPresentationDescriptionParser.java   
private SingleSegmentBase parseSegmentBase(XmlPullParser xpp, Uri baseUrl,
    SingleSegmentBase parent) throws XmlPullParserException, IOException {

  long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1);
  long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset",
      parent != null ? parent.presentationTimeOffset : 0);

  long indexStart = parent != null ? parent.indexStart : 0;
  long indexLength = parent != null ? parent.indexLength : -1;
  String indexRangeText = xpp.getAttributeValue(null, "indexRange");
  if (indexRangeText != null) {
    String[] indexRange = indexRangeText.split("-");
    indexStart = Long.parseLong(indexRange[0]);
    indexLength = Long.parseLong(indexRange[1]) - indexStart + 1;
  }

  RangedUri initialization = parent != null ? parent.initialization : null;
  do {
    xpp.next();
    if (isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp, baseUrl);
    }
  } while (!isEndTag(xpp, "SegmentBase"));

  return new SingleSegmentBase(initialization, timescale, presentationTimeOffset, baseUrl,
      indexStart, indexLength);
}
项目: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    文件: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.
 * @param contentLength The content length, or -1 if unknown.
 */
public SingleSegmentRepresentation(long periodStartMs, long periodDurationMs, String contentId,
    long revisionId, Format format, SingleSegmentBase segmentBase, long contentLength) {
  super(periodStartMs, periodDurationMs, contentId, revisionId, format, segmentBase);
  this.uri = Uri.parse(segmentBase.uri);
  this.indexUri = segmentBase.getIndex();
  this.contentLength = contentLength;
  // If we have an index uri then the index is defined externally, and we shouldn't return one
  // directly. If we don't, then we can't do better than an index defining a single segment.
  segmentIndex = indexUri != null ? null : new DashSingleSegmentIndex(periodStartMs * 1000,
      periodDurationMs * 1000, new RangedUri(segmentBase.uri, null, 0, -1));
}
项目:ExoPlayer    文件:MediaPresentationDescriptionParser.java   
protected SingleSegmentBase parseSegmentBase(XmlPullParser xpp, String baseUrl,
    SingleSegmentBase parent) throws XmlPullParserException, IOException {

  long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1);
  long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset",
      parent != null ? parent.presentationTimeOffset : 0);

  long indexStart = parent != null ? parent.indexStart : 0;
  long indexLength = parent != null ? parent.indexLength : -1;
  String indexRangeText = xpp.getAttributeValue(null, "indexRange");
  if (indexRangeText != null) {
    String[] indexRange = indexRangeText.split("-");
    indexStart = Long.parseLong(indexRange[0]);
    indexLength = Long.parseLong(indexRange[1]) - indexStart + 1;
  }

  RangedUri initialization = parent != null ? parent.initialization : null;
  do {
    xpp.next();
    if (isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp, baseUrl);
    }
  } while (!isEndTag(xpp, "SegmentBase"));

  return buildSingleSegmentBase(initialization, timescale, presentationTimeOffset, baseUrl,
      indexStart, indexLength);
}
项目:ExoPlayer    文件:RepresentationTest.java   
public void testGetCacheKey() {
  String uri = "http://www.google.com";
  SegmentBase base = new SingleSegmentBase(new RangedUri(uri, null, 0, 1), 1, 0, uri, 1, 1);
  Format format = new Format("0", MimeTypes.VIDEO_MP4, 1920, 1080, -1, 0, 0, 2500000);
  Representation representation = Representation.newInstance(-1, -1, "test_stream_1", 3,
      format, base);
  assertEquals("test_stream_1.0.3", representation.getCacheKey());

  format = new Format("150", MimeTypes.VIDEO_MP4, 1920, 1080, -1, 0, 0, 2500000);
  representation = Representation.newInstance(-1, -1, "test_stream_1", -1, format, base);
  assertEquals("test_stream_1.150.-1", representation.getCacheKey());
}
项目:miku    文件:MediaPresentationDescriptionParser.java   
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String baseUrl, long periodStartMs,
    long periodDurationMs, SegmentBase segmentBase) throws XmlPullParserException, IOException {

  int id = parseInt(xpp, "id", -1);
  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String language = xpp.getAttributeValue(null, "lang");
  int contentType = parseAdaptationSetType(xpp.getAttributeValue(null, "contentType"));
  if (contentType == AdaptationSet.TYPE_UNKNOWN) {
    contentType = parseAdaptationSetTypeFromMimeType(xpp.getAttributeValue(null, "mimeType"));
  }

  ContentProtectionsBuilder contentProtectionsBuilder = new ContentProtectionsBuilder();
  List<Representation> representations = new ArrayList<>();
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "ContentProtection")) {
      contentProtectionsBuilder.addAdaptationSetProtection(parseContentProtection(xpp));
    } else if (isStartTag(xpp, "ContentComponent")) {
      language = checkLanguageConsistency(language, xpp.getAttributeValue(null, "lang"));
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetType(xpp.getAttributeValue(null, "contentType")));
    } else if (isStartTag(xpp, "Representation")) {
      Representation representation = parseRepresentation(xpp, baseUrl, periodStartMs,
          periodDurationMs, mimeType, language, segmentBase, contentProtectionsBuilder);
      contentProtectionsBuilder.endRepresentation();
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetTypeFromMimeType(representation.format.mimeType));
      representations.add(representation);
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    } else if (isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!isEndTag(xpp, "AdaptationSet"));

  return buildAdaptationSet(id, contentType, representations, contentProtectionsBuilder.build());
}
项目:miku    文件:MediaPresentationDescriptionParser.java   
protected Representation parseRepresentation(XmlPullParser xpp, String baseUrl,
    long periodStartMs, long periodDurationMs, String mimeType, String language,
    SegmentBase segmentBase, ContentProtectionsBuilder contentProtectionsBuilder)
    throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth");
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate");
  int width = parseInt(xpp, "width");
  int height = parseInt(xpp, "height");

  float frameRate = -1;
  String frameRateAttribute = xpp.getAttributeValue(null, "frameRate");
  if (frameRateAttribute != null) {
    Matcher frameRateMatcher = FRAME_RATE_PATTERN.matcher(frameRateAttribute);
    if (frameRateMatcher.matches()) {
      int numerator = Integer.parseInt(frameRateMatcher.group(1));
      String denominatorString = frameRateMatcher.group(2);
      if (!TextUtils.isEmpty(denominatorString)) {
        frameRate = (float) numerator / Integer.parseInt(denominatorString);
      } else {
        frameRate = numerator;
      }
    }
  }

  mimeType = parseString(xpp, "mimeType", mimeType);
  String codecs = parseString(xpp, "codecs", null);

  int numChannels = -1;
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "AudioChannelConfiguration")) {
      numChannels = Integer.parseInt(xpp.getAttributeValue(null, "value"));
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    } else if (isStartTag(xpp, "ContentProtection")) {
      contentProtectionsBuilder.addRepresentationProtection(parseContentProtection(xpp));
    }
  } while (!isEndTag(xpp, "Representation"));

  Format format = buildFormat(id, mimeType, width, height, frameRate, numChannels,
      audioSamplingRate, bandwidth, language, codecs);
  return buildRepresentation(periodStartMs, periodDurationMs, contentId, -1, format,
      segmentBase != null ? segmentBase : new SingleSegmentBase(baseUrl));
}
项目:miku    文件:MediaPresentationDescriptionParser.java   
protected SingleSegmentBase buildSingleSegmentBase(RangedUri initialization, long timescale,
    long presentationTimeOffset, String baseUrl, long indexStart, long indexLength) {
  return new SingleSegmentBase(initialization, timescale, presentationTimeOffset, baseUrl,
      indexStart, indexLength);
}
项目:ExoPlayer-Demo    文件:MediaPresentationDescriptionParser.java   
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String baseUrl,
    SegmentBase segmentBase) throws XmlPullParserException, IOException {
  int id = parseInt(xpp, "id", -1);
  int contentType = parseContentType(xpp);

  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String codecs = xpp.getAttributeValue(null, "codecs");
  int width = parseInt(xpp, "width", -1);
  int height = parseInt(xpp, "height", -1);
  float frameRate = parseFrameRate(xpp, -1);
  int audioChannels = -1;
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate", -1);
  String language = xpp.getAttributeValue(null, "lang");

  ContentProtectionsBuilder contentProtectionsBuilder = new ContentProtectionsBuilder();
  List<Representation> representations = new ArrayList<>();
  boolean seenFirstBaseUrl = false;
  do {
    xpp.next();
    if (ParserUtil.isStartTag(xpp, "BaseURL")) {
      if (!seenFirstBaseUrl) {
        baseUrl = parseBaseUrl(xpp, baseUrl);
        seenFirstBaseUrl = true;
      }
    } else if (ParserUtil.isStartTag(xpp, "ContentProtection")) {
      ContentProtection contentProtection = parseContentProtection(xpp);
      if (contentProtection != null) {
        contentProtectionsBuilder.addAdaptationSetProtection(contentProtection);
      }
    } else if (ParserUtil.isStartTag(xpp, "ContentComponent")) {
      language = checkLanguageConsistency(language, xpp.getAttributeValue(null, "lang"));
      contentType = checkContentTypeConsistency(contentType, parseContentType(xpp));
    } else if (ParserUtil.isStartTag(xpp, "Representation")) {
      Representation representation = parseRepresentation(xpp, baseUrl, mimeType, codecs, width,
          height, frameRate, audioChannels, audioSamplingRate, language, segmentBase,
          contentProtectionsBuilder);
      contentProtectionsBuilder.endRepresentation();
      contentType = checkContentTypeConsistency(contentType, getContentType(representation));
      representations.add(representation);
    } else if (ParserUtil.isStartTag(xpp, "AudioChannelConfiguration")) {
      audioChannels = parseAudioChannelConfiguration(xpp);
    } else if (ParserUtil.isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (ParserUtil.isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase);
    } else if (ParserUtil.isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase);
    } else if (ParserUtil.isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!ParserUtil.isEndTag(xpp, "AdaptationSet"));

  return buildAdaptationSet(id, contentType, representations, contentProtectionsBuilder.build());
}
项目:ExoPlayer-Demo    文件:MediaPresentationDescriptionParser.java   
protected Representation parseRepresentation(XmlPullParser xpp, String baseUrl,
    String adaptationSetMimeType, String adaptationSetCodecs, int adaptationSetWidth,
    int adaptationSetHeight, float adaptationSetFrameRate, int adaptationSetAudioChannels,
    int adaptationSetAudioSamplingRate, String adaptationSetLanguage, SegmentBase segmentBase,
    ContentProtectionsBuilder contentProtectionsBuilder)
    throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth");

  String mimeType = parseString(xpp, "mimeType", adaptationSetMimeType);
  String codecs = parseString(xpp, "codecs", adaptationSetCodecs);
  int width = parseInt(xpp, "width", adaptationSetWidth);
  int height = parseInt(xpp, "height", adaptationSetHeight);
  float frameRate = parseFrameRate(xpp, adaptationSetFrameRate);
  int audioChannels = adaptationSetAudioChannels;
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate", adaptationSetAudioSamplingRate);
  String language = adaptationSetLanguage;

  boolean seenFirstBaseUrl = false;
  do {
    xpp.next();
    if (ParserUtil.isStartTag(xpp, "BaseURL")) {
      if (!seenFirstBaseUrl) {
        baseUrl = parseBaseUrl(xpp, baseUrl);
        seenFirstBaseUrl = true;
      }
    } else if (ParserUtil.isStartTag(xpp, "AudioChannelConfiguration")) {
      audioChannels = parseAudioChannelConfiguration(xpp);
    } else if (ParserUtil.isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (ParserUtil.isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase);
    } else if (ParserUtil.isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase);
    } else if (ParserUtil.isStartTag(xpp, "ContentProtection")) {
      ContentProtection contentProtection = parseContentProtection(xpp);
      if (contentProtection != null) {
        contentProtectionsBuilder.addAdaptationSetProtection(contentProtection);
      }
    }
  } while (!ParserUtil.isEndTag(xpp, "Representation"));

  Format format = buildFormat(id, mimeType, width, height, frameRate, audioChannels,
      audioSamplingRate, bandwidth, language, codecs);
  return buildRepresentation(contentId, -1, format,
      segmentBase != null ? segmentBase : new SingleSegmentBase(baseUrl));
}
项目:ExoPlayer-Demo    文件:MediaPresentationDescriptionParser.java   
protected SingleSegmentBase buildSingleSegmentBase(RangedUri initialization, long timescale,
    long presentationTimeOffset, String baseUrl, long indexStart, long indexLength) {
  return new SingleSegmentBase(initialization, timescale, presentationTimeOffset, baseUrl,
      indexStart, indexLength);
}
项目:ExoPlayer-Demo    文件:DashChunkSourceTest.java   
private static Representation buildVodRepresentation(Format format) {
  RangedUri rangedUri = new RangedUri("https://example.com/1.mp4", null, 0, 100);
  SingleSegmentBase segmentBase = new SingleSegmentBase(rangedUri, 1, 0,
      "https://example.com/1.mp4", 0, -1);
  return Representation.newInstance(null, 0, format, segmentBase);
}
项目:android-exoplayer    文件:MediaPresentationDescriptionParser.java   
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String contentId, Uri baseUrl,
    long periodStartMs, long periodDurationMs, SegmentBase segmentBase)
    throws XmlPullParserException, IOException {

  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String language = xpp.getAttributeValue(null, "lang");
  int contentType = parseAdaptationSetTypeFromMimeType(mimeType);

  int id = -1;
  List<ContentProtection> contentProtections = null;
  List<Representation> representations = new ArrayList<Representation>();
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "ContentProtection")) {
      if (contentProtections == null) {
        contentProtections = new ArrayList<ContentProtection>();
      }
      contentProtections.add(parseContentProtection(xpp));
    } else if (isStartTag(xpp, "ContentComponent")) {
      id = Integer.parseInt(xpp.getAttributeValue(null, "id"));
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetType(xpp.getAttributeValue(null, "contentType")));
    } else if (isStartTag(xpp, "Representation")) {
      Representation representation = parseRepresentation(xpp, contentId, baseUrl, periodStartMs,
          periodDurationMs, mimeType, language, segmentBase);
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetTypeFromMimeType(representation.format.mimeType));
      representations.add(representation);
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    } else if (isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!isEndTag(xpp, "AdaptationSet"));

  return buildAdaptationSet(id, contentType, representations, contentProtections);
}
项目:android-exoplayer    文件:MediaPresentationDescriptionParser.java   
protected SingleSegmentBase buildSingleSegmentBase(RangedUri initialization, long timescale,
    long presentationTimeOffset, Uri baseUrl, long indexStart, long indexLength) {
  return new SingleSegmentBase(initialization, timescale, presentationTimeOffset, baseUrl,
      indexStart, indexLength);
}
项目:Exoplayer_VLC    文件:MediaPresentationDescriptionParser.java   
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String contentId, Uri baseUrl,
    long periodStartMs, long periodDurationMs, SegmentBase segmentBase)
    throws XmlPullParserException, IOException {

  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String language = xpp.getAttributeValue(null, "lang");
  int contentType = parseAdaptationSetTypeFromMimeType(mimeType);

  int id = -1;
  List<ContentProtection> contentProtections = null;
  List<Representation> representations = new ArrayList<Representation>();
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "ContentProtection")) {
      if (contentProtections == null) {
        contentProtections = new ArrayList<ContentProtection>();
      }
      contentProtections.add(parseContentProtection(xpp));
    } else if (isStartTag(xpp, "ContentComponent")) {
      id = Integer.parseInt(xpp.getAttributeValue(null, "id"));
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetType(xpp.getAttributeValue(null, "contentType")));
    } else if (isStartTag(xpp, "Representation")) {
      Representation representation = parseRepresentation(xpp, contentId, baseUrl, periodStartMs,
          periodDurationMs, mimeType, language, segmentBase);
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetTypeFromMimeType(representation.format.mimeType));
      representations.add(representation);
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    } else if (isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!isEndTag(xpp, "AdaptationSet"));

  return buildAdaptationSet(id, contentType, representations, contentProtections);
}
项目:Exoplayer_VLC    文件:MediaPresentationDescriptionParser.java   
protected SingleSegmentBase buildSingleSegmentBase(RangedUri initialization, long timescale,
    long presentationTimeOffset, Uri baseUrl, long indexStart, long indexLength) {
  return new SingleSegmentBase(initialization, timescale, presentationTimeOffset, baseUrl,
      indexStart, indexLength);
}
项目:edx-app-android    文件:MediaPresentationDescriptionParser.java   
private AdaptationSet parseAdaptationSet(XmlPullParser xpp, String contentId, Uri baseUrl,
    long periodStartMs, long periodDurationMs, SegmentBase segmentBase)
    throws XmlPullParserException, IOException {

  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String language = xpp.getAttributeValue(null, "lang");
  int contentType = parseAdaptationSetTypeFromMimeType(mimeType);

  int id = -1;
  List<ContentProtection> contentProtections = null;
  List<Representation> representations = new ArrayList<Representation>();
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "ContentProtection")) {
      if (contentProtections == null) {
        contentProtections = new ArrayList<ContentProtection>();
      }
      contentProtections.add(parseContentProtection(xpp));
    } else if (isStartTag(xpp, "ContentComponent")) {
      id = Integer.parseInt(xpp.getAttributeValue(null, "id"));
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetType(xpp.getAttributeValue(null, "contentType")));
    } else if (isStartTag(xpp, "Representation")) {
      Representation representation = parseRepresentation(xpp, contentId, baseUrl, periodStartMs,
          periodDurationMs, mimeType, language, segmentBase);
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetTypeFromMimeType(representation.format.mimeType));
      representations.add(representation);
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    }
  } while (!isEndTag(xpp, "AdaptationSet"));

  return new AdaptationSet(id, contentType, representations, contentProtections);
}
项目:ExoPlayer    文件:MediaPresentationDescriptionParser.java   
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String baseUrl, long periodStartMs,
    long periodDurationMs, SegmentBase segmentBase) throws XmlPullParserException, IOException {

  int id = parseInt(xpp, "id", -1);
  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String language = xpp.getAttributeValue(null, "lang");
  int contentType = parseAdaptationSetType(xpp.getAttributeValue(null, "contentType"));
  if (contentType == AdaptationSet.TYPE_UNKNOWN) {
    contentType = parseAdaptationSetTypeFromMimeType(xpp.getAttributeValue(null, "mimeType"));
  }

  ContentProtectionsBuilder contentProtectionsBuilder = new ContentProtectionsBuilder();
  List<Representation> representations = new ArrayList<>();
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "ContentProtection")) {
      contentProtectionsBuilder.addAdaptationSetProtection(parseContentProtection(xpp));
    } else if (isStartTag(xpp, "ContentComponent")) {
      language = checkLanguageConsistency(language, xpp.getAttributeValue(null, "lang"));
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetType(xpp.getAttributeValue(null, "contentType")));
    } else if (isStartTag(xpp, "Representation")) {
      Representation representation = parseRepresentation(xpp, baseUrl, periodStartMs,
          periodDurationMs, mimeType, language, segmentBase, contentProtectionsBuilder);
      contentProtectionsBuilder.endRepresentation();
      contentType = checkAdaptationSetTypeConsistency(contentType,
          parseAdaptationSetTypeFromMimeType(representation.format.mimeType));
      representations.add(representation);
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    } else if (isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!isEndTag(xpp, "AdaptationSet"));

  return buildAdaptationSet(id, contentType, representations, contentProtectionsBuilder.build());
}
项目:ExoPlayer    文件:MediaPresentationDescriptionParser.java   
protected Representation parseRepresentation(XmlPullParser xpp, String baseUrl,
    long periodStartMs, long periodDurationMs, String mimeType, String language,
    SegmentBase segmentBase, ContentProtectionsBuilder contentProtectionsBuilder)
    throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth");
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate");
  int width = parseInt(xpp, "width");
  int height = parseInt(xpp, "height");

  float frameRate = -1;
  String frameRateAttribute = xpp.getAttributeValue(null, "frameRate");
  if (frameRateAttribute != null) {
    Matcher frameRateMatcher = FRAME_RATE_PATTERN.matcher(frameRateAttribute);
    if (frameRateMatcher.matches()) {
      int numerator = Integer.parseInt(frameRateMatcher.group(1));
      String denominatorString = frameRateMatcher.group(2);
      if (!TextUtils.isEmpty(denominatorString)) {
        frameRate = (float) numerator / Integer.parseInt(denominatorString);
      } else {
        frameRate = numerator;
      }
    }
  }

  mimeType = parseString(xpp, "mimeType", mimeType);
  String codecs = parseString(xpp, "codecs", null);

  int numChannels = -1;
  do {
    xpp.next();
    if (isStartTag(xpp, "BaseURL")) {
      baseUrl = parseBaseUrl(xpp, baseUrl);
    } else if (isStartTag(xpp, "AudioChannelConfiguration")) {
      numChannels = Integer.parseInt(xpp.getAttributeValue(null, "value"));
    } else if (isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase, periodDurationMs);
    } else if (isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase,
          periodDurationMs);
    } else if (isStartTag(xpp, "ContentProtection")) {
      contentProtectionsBuilder.addRepresentationProtection(parseContentProtection(xpp));
    }
  } while (!isEndTag(xpp, "Representation"));

  Format format = buildFormat(id, mimeType, width, height, frameRate, numChannels,
      audioSamplingRate, bandwidth, language, codecs);
  return buildRepresentation(periodStartMs, periodDurationMs, contentId, -1, format,
      segmentBase != null ? segmentBase : new SingleSegmentBase(baseUrl));
}
项目:ExoPlayer    文件:MediaPresentationDescriptionParser.java   
protected SingleSegmentBase buildSingleSegmentBase(RangedUri initialization, long timescale,
    long presentationTimeOffset, String baseUrl, long indexStart, long indexLength) {
  return new SingleSegmentBase(initialization, timescale, presentationTimeOffset, baseUrl,
      indexStart, indexLength);
}
项目:ExoPlayer    文件:DashChunkSourceTest.java   
private static Representation generateVodRepresentation(long startTimeMs, long duration,
    Format format) {
  SingleSegmentBase segmentBase = new SingleSegmentBase("https://example.com/1.mp4");
  return Representation.newInstance(startTimeMs, duration, null, 0, format, segmentBase);
}
项目: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 uri The uri of the media.
 * @param initializationStart The offset of the first byte of initialization data.
 * @param initializationEnd The offset of the last byte of initialization data.
 * @param indexStart The offset of the first byte of index data.
 * @param indexEnd The offset of the last byte of index data.
 * @param contentLength The content length, or -1 if unknown.
 */
public static SingleSegmentRepresentation newInstance(long periodStartMs, long periodDurationMs,
    String contentId, long revisionId, Format format, String uri, long initializationStart,
    long initializationEnd, long indexStart, long indexEnd, long contentLength) {
  RangedUri rangedUri = new RangedUri(uri, null, initializationStart,
      initializationEnd - initializationStart + 1);
  SingleSegmentBase segmentBase = new SingleSegmentBase(rangedUri, 1, 0, uri, indexStart,
      indexEnd - indexStart + 1);
  return new SingleSegmentRepresentation(periodStartMs, periodDurationMs, contentId, revisionId,
      format, segmentBase, contentLength);
}
项目: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 uri The uri of the media.
 * @param initializationStart The offset of the first byte of initialization data.
 * @param initializationEnd The offset of the last byte of initialization data.
 * @param indexStart The offset of the first byte of index data.
 * @param indexEnd The offset of the last byte of index data.
 * @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null.
 * @param contentLength The content length, or -1 if unknown.
 */
public static SingleSegmentRepresentation newInstance(String contentId, long revisionId,
    Format format, String uri, long initializationStart, long initializationEnd,
    long indexStart, long indexEnd, String customCacheKey, long contentLength) {
  RangedUri rangedUri = new RangedUri(uri, null, initializationStart,
      initializationEnd - initializationStart + 1);
  SingleSegmentBase segmentBase = new SingleSegmentBase(rangedUri, 1, 0, uri, indexStart,
      indexEnd - indexStart + 1);
  return new SingleSegmentRepresentation(contentId, revisionId,
      format, segmentBase, customCacheKey, contentLength);
}
项目: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 uri The uri of the media.
 * @param initializationStart The offset of the first byte of initialization data.
 * @param initializationEnd The offset of the last byte of initialization data.
 * @param indexStart The offset of the first byte of index data.
 * @param indexEnd The offset of the last byte of index data.
 * @param contentLength The content length, or -1 if unknown.
 */
public static SingleSegmentRepresentation newInstance(long periodStartMs, long periodDurationMs,
    String contentId, long revisionId, Format format, Uri uri, long initializationStart,
    long initializationEnd, long indexStart, long indexEnd, long contentLength) {
  RangedUri rangedUri = new RangedUri(uri, null, initializationStart,
      initializationEnd - initializationStart + 1);
  SingleSegmentBase segmentBase = new SingleSegmentBase(rangedUri, 1, 0, uri, indexStart,
      indexEnd - indexStart + 1);
  return new SingleSegmentRepresentation(periodStartMs, periodDurationMs, contentId, revisionId,
      format, segmentBase, contentLength);
}