Java 类com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SingleSegmentBase 实例源码

项目:K-Sonic    文件:DashManifestParser.java   
protected SingleSegmentBase parseSegmentBase(XmlPullParser xpp, 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 : 0;
  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 (XmlPullParserUtil.isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentBase"));

  return buildSingleSegmentBase(initialization, timescale, presentationTimeOffset, indexStart,
      indexLength);
}
项目:K-Sonic    文件: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 baseUrl The base URL of the representation.
 * @param segmentBase A segment base element for the representation.
 * @param inbandEventStreams The in-band event streams in the representation. May be null.
 * @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null. This
 *     parameter is ignored if {@code segmentBase} consists of multiple segments.
 * @return The constructed instance.
 */
public static Representation newInstance(String contentId, long revisionId, Format format,
    String baseUrl, SegmentBase segmentBase, List<SchemeValuePair> inbandEventStreams,
    String customCacheKey) {
  if (segmentBase instanceof SingleSegmentBase) {
    return new SingleSegmentRepresentation(contentId, revisionId, format, baseUrl,
        (SingleSegmentBase) segmentBase, inbandEventStreams, customCacheKey, C.LENGTH_UNSET);
  } else if (segmentBase instanceof MultiSegmentBase) {
    return new MultiSegmentRepresentation(contentId, revisionId, format, baseUrl,
        (MultiSegmentBase) segmentBase, inbandEventStreams);
  } else {
    throw new IllegalArgumentException("segmentBase must be of type SingleSegmentBase or "
        + "MultiSegmentBase");
  }
}
项目:K-Sonic    文件: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 baseUrl The base URL of the representation.
 * @param segmentBase The segment base underlying the representation.
 * @param inbandEventStreams The in-band event streams in the representation. May be null.
 * @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null.
 * @param contentLength The content length, or {@link C#LENGTH_UNSET} if unknown.
 */
public SingleSegmentRepresentation(String contentId, long revisionId, Format format,
    String baseUrl, SingleSegmentBase segmentBase, List<SchemeValuePair> inbandEventStreams,
    String customCacheKey, long contentLength) {
  super(contentId, revisionId, format, baseUrl, segmentBase, inbandEventStreams);
  this.uri = Uri.parse(baseUrl);
  this.indexUri = segmentBase.getIndex();
  this.cacheKey = customCacheKey != null ? customCacheKey
      : contentId != null ? contentId + "." + format.id + "." + revisionId : null;
  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 SingleSegmentIndex(new RangedUri(null, 0, contentLength));
}
项目:videoPickPlayer    文件:DashManifestParser.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 : 0;
  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 (XmlPullParserUtil.isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp, baseUrl);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentBase"));

  return buildSingleSegmentBase(initialization, timescale, presentationTimeOffset, baseUrl,
      indexStart, indexLength);
}
项目:videoPickPlayer    文件: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, C.LENGTH_UNSET);
  } 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");
  }
}
项目:videoPickPlayer    文件: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 {@link C#LENGTH_UNSET} 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 SingleSegmentIndex(new RangedUri(segmentBase.uri, null, 0, contentLength));
}
项目:videoPickPlayer    文件: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 = Format.createVideoContainerFormat("0", MimeTypes.APPLICATION_MP4, null,
      MimeTypes.VIDEO_H264, 2500000, 1920, 1080, Format.NO_VALUE, null);
  Representation representation = Representation.newInstance("test_stream_1", 3, format, base);
  assertEquals("test_stream_1.0.3", representation.getCacheKey());

  format = Format.createVideoContainerFormat("150", MimeTypes.APPLICATION_MP4, null,
      MimeTypes.VIDEO_H264, 2500000, 1920, 1080, Format.NO_VALUE, null);
  representation = Representation.newInstance("test_stream_1", Representation.REVISION_ID_DEFAULT,
      format, base);
  assertEquals("test_stream_1.150.-1", representation.getCacheKey());
}
项目:transistor    文件:DashManifestParser.java   
protected SingleSegmentBase parseSegmentBase(XmlPullParser xpp, 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 : 0;
  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 (XmlPullParserUtil.isStartTag(xpp, "Initialization")) {
      initialization = parseInitialization(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentBase"));

  return buildSingleSegmentBase(initialization, timescale, presentationTimeOffset, indexStart,
      indexLength);
}
项目:transistor    文件: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 baseUrl The base URL of the representation.
 * @param segmentBase A segment base element for the representation.
 * @param inbandEventStreams The in-band event streams in the representation. May be null.
 * @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null. This
 *     parameter is ignored if {@code segmentBase} consists of multiple segments.
 * @return The constructed instance.
 */
public static Representation newInstance(String contentId, long revisionId, Format format,
    String baseUrl, SegmentBase segmentBase, List<Descriptor> inbandEventStreams,
    String customCacheKey) {
  if (segmentBase instanceof SingleSegmentBase) {
    return new SingleSegmentRepresentation(contentId, revisionId, format, baseUrl,
        (SingleSegmentBase) segmentBase, inbandEventStreams, customCacheKey, C.LENGTH_UNSET);
  } else if (segmentBase instanceof MultiSegmentBase) {
    return new MultiSegmentRepresentation(contentId, revisionId, format, baseUrl,
        (MultiSegmentBase) segmentBase, inbandEventStreams);
  } else {
    throw new IllegalArgumentException("segmentBase must be of type SingleSegmentBase or "
        + "MultiSegmentBase");
  }
}
项目:transistor    文件: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 baseUrl The base URL of the representation.
 * @param segmentBase The segment base underlying the representation.
 * @param inbandEventStreams The in-band event streams in the representation. May be null.
 * @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null.
 * @param contentLength The content length, or {@link C#LENGTH_UNSET} if unknown.
 */
public SingleSegmentRepresentation(String contentId, long revisionId, Format format,
    String baseUrl, SingleSegmentBase segmentBase, List<Descriptor> inbandEventStreams,
    String customCacheKey, long contentLength) {
  super(contentId, revisionId, format, baseUrl, segmentBase, inbandEventStreams);
  this.uri = Uri.parse(baseUrl);
  this.indexUri = segmentBase.getIndex();
  this.cacheKey = customCacheKey != null ? customCacheKey
      : contentId != null ? contentId + "." + format.id + "." + revisionId : null;
  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 SingleSegmentIndex(new RangedUri(null, 0, contentLength));
}
项目:transistor    文件:RepresentationTest.java   
public void testGetCacheKey() {
  String uri = "http://www.google.com";
  SegmentBase base = new SingleSegmentBase(new RangedUri(null, 0, 1), 1, 0, 1, 1);
  Format format = Format.createVideoContainerFormat("0", MimeTypes.APPLICATION_MP4, null,
      MimeTypes.VIDEO_H264, 2500000, 1920, 1080, Format.NO_VALUE, null, 0);
  Representation representation = Representation.newInstance("test_stream_1", 3, format, uri,
      base);
  assertEquals("test_stream_1.0.3", representation.getCacheKey());

  format = Format.createVideoContainerFormat("150", MimeTypes.APPLICATION_MP4, null,
      MimeTypes.VIDEO_H264, 2500000, 1920, 1080, Format.NO_VALUE, null, 0);
  representation = Representation.newInstance("test_stream_1", Representation.REVISION_ID_DEFAULT,
      format, uri, base);
  assertEquals("test_stream_1.150.-1", representation.getCacheKey());
}
项目:transistor    文件:DashUtilTest.java   
private static Representation newRepresentations(DrmInitData drmInitData) {
  Format format = Format.createVideoContainerFormat("id", MimeTypes.VIDEO_MP4,
      MimeTypes.VIDEO_H264, "", Format.NO_VALUE, 1024, 768, Format.NO_VALUE, null, 0);
  if (drmInitData != null) {
    format = format.copyWithDrmInitData(drmInitData);
  }
  return Representation.newInstance("", 0, format, "", new SingleSegmentBase());
}
项目:K-Sonic    文件:DashManifestParser.java   
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String baseUrl,
    SegmentBase segmentBase) throws XmlPullParserException, IOException {
  int id = parseInt(xpp, "id", AdaptationSet.ID_UNSET);
  int contentType = parseContentType(xpp);

  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String codecs = xpp.getAttributeValue(null, "codecs");
  int width = parseInt(xpp, "width", Format.NO_VALUE);
  int height = parseInt(xpp, "height", Format.NO_VALUE);
  float frameRate = parseFrameRate(xpp, Format.NO_VALUE);
  int audioChannels = Format.NO_VALUE;
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate", Format.NO_VALUE);
  String language = xpp.getAttributeValue(null, "lang");
  ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();
  ArrayList<SchemeValuePair> inbandEventStreams = new ArrayList<>();
  ArrayList<SchemeValuePair> accessibilityDescriptors = new ArrayList<>();
  List<RepresentationInfo> representationInfos = new ArrayList<>();
  @C.SelectionFlags int selectionFlags = 0;

  boolean seenFirstBaseUrl = false;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "BaseURL")) {
      if (!seenFirstBaseUrl) {
        baseUrl = parseBaseUrl(xpp, baseUrl);
        seenFirstBaseUrl = true;
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "ContentProtection")) {
      SchemeData contentProtection = parseContentProtection(xpp);
      if (contentProtection != null) {
        drmSchemeDatas.add(contentProtection);
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "ContentComponent")) {
      language = checkLanguageConsistency(language, xpp.getAttributeValue(null, "lang"));
      contentType = checkContentTypeConsistency(contentType, parseContentType(xpp));
    } else if (XmlPullParserUtil.isStartTag(xpp, "Role")) {
      selectionFlags |= parseRole(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "AudioChannelConfiguration")) {
      audioChannels = parseAudioChannelConfiguration(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "Accessibility")) {
      accessibilityDescriptors.add(parseAccessibility(xpp));
    } else if (XmlPullParserUtil.isStartTag(xpp, "Representation")) {
      RepresentationInfo representationInfo = parseRepresentation(xpp, baseUrl, mimeType, codecs,
          width, height, frameRate, audioChannels, audioSamplingRate, language,
          selectionFlags, accessibilityDescriptors, segmentBase);
      contentType = checkContentTypeConsistency(contentType,
          getContentType(representationInfo.format));
      representationInfos.add(representationInfo);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, (SingleSegmentBase) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, (SegmentList) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, (SegmentTemplate) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "InbandEventStream")) {
      inbandEventStreams.add(parseInbandEventStream(xpp));
    } else if (XmlPullParserUtil.isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "AdaptationSet"));

  // Build the representations.
  List<Representation> representations = new ArrayList<>(representationInfos.size());
  for (int i = 0; i < representationInfos.size(); i++) {
    representations.add(buildRepresentation(representationInfos.get(i), contentId,
        drmSchemeDatas, inbandEventStreams));
  }

  return buildAdaptationSet(id, contentType, representations, accessibilityDescriptors);
}
项目:K-Sonic    文件:DashManifestParser.java   
protected RepresentationInfo parseRepresentation(XmlPullParser xpp, String baseUrl,
    String adaptationSetMimeType, String adaptationSetCodecs, int adaptationSetWidth,
    int adaptationSetHeight, float adaptationSetFrameRate, int adaptationSetAudioChannels,
    int adaptationSetAudioSamplingRate, String adaptationSetLanguage,
    @C.SelectionFlags int adaptationSetSelectionFlags,
    List<SchemeValuePair> adaptationSetAccessibilityDescriptors, SegmentBase segmentBase)
    throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth", Format.NO_VALUE);

  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);
  ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();
  ArrayList<SchemeValuePair> inbandEventStreams = new ArrayList<>();

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

  Format format = buildFormat(id, mimeType, width, height, frameRate, audioChannels,
      audioSamplingRate, bandwidth, adaptationSetLanguage, adaptationSetSelectionFlags,
      adaptationSetAccessibilityDescriptors, codecs);
  segmentBase = segmentBase != null ? segmentBase : new SingleSegmentBase();

  return new RepresentationInfo(format, baseUrl, segmentBase, drmSchemeDatas, inbandEventStreams);
}
项目:K-Sonic    文件:DashManifestParser.java   
protected SingleSegmentBase buildSingleSegmentBase(RangedUri initialization, long timescale,
    long presentationTimeOffset, long indexStart, long indexLength) {
  return new SingleSegmentBase(initialization, timescale, presentationTimeOffset, indexStart,
      indexLength);
}
项目:videoPickPlayer    文件:DashManifestParser.java   
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String baseUrl,
    SegmentBase segmentBase) throws XmlPullParserException, IOException {
  int id = parseInt(xpp, "id", AdaptationSet.UNSET_ID);
  int contentType = parseContentType(xpp);

  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String codecs = xpp.getAttributeValue(null, "codecs");
  int width = parseInt(xpp, "width", Format.NO_VALUE);
  int height = parseInt(xpp, "height", Format.NO_VALUE);
  float frameRate = parseFrameRate(xpp, Format.NO_VALUE);
  int audioChannels = Format.NO_VALUE;
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate", Format.NO_VALUE);
  String language = xpp.getAttributeValue(null, "lang");
  ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();
  List<RepresentationInfo> representationInfos = new ArrayList<>();

  boolean seenFirstBaseUrl = false;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "BaseURL")) {
      if (!seenFirstBaseUrl) {
        baseUrl = parseBaseUrl(xpp, baseUrl);
        seenFirstBaseUrl = true;
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "ContentProtection")) {
      SchemeData contentProtection = parseContentProtection(xpp);
      if (contentProtection != null) {
        drmSchemeDatas.add(contentProtection);
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "ContentComponent")) {
      language = checkLanguageConsistency(language, xpp.getAttributeValue(null, "lang"));
      contentType = checkContentTypeConsistency(contentType, parseContentType(xpp));
    } else if (XmlPullParserUtil.isStartTag(xpp, "Representation")) {
      RepresentationInfo representationInfo = parseRepresentation(xpp, baseUrl, mimeType, codecs,
          width, height, frameRate, audioChannels, audioSamplingRate, language, segmentBase);
      contentType = checkContentTypeConsistency(contentType,
          getContentType(representationInfo.format));
      representationInfos.add(representationInfo);
    } else if (XmlPullParserUtil.isStartTag(xpp, "AudioChannelConfiguration")) {
      audioChannels = parseAudioChannelConfiguration(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, baseUrl, (SingleSegmentBase) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, baseUrl, (SegmentList) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, baseUrl, (SegmentTemplate) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "AdaptationSet"));

  List<Representation> representations = new ArrayList<>(representationInfos.size());
  for (int i = 0; i < representationInfos.size(); i++) {
    representations.add(buildRepresentation(representationInfos.get(i), contentId,
        drmSchemeDatas));
  }

  return buildAdaptationSet(id, contentType, representations);
}
项目:videoPickPlayer    文件:DashManifestParser.java   
protected RepresentationInfo parseRepresentation(XmlPullParser xpp, String baseUrl,
    String adaptationSetMimeType, String adaptationSetCodecs, int adaptationSetWidth,
    int adaptationSetHeight, float adaptationSetFrameRate, int adaptationSetAudioChannels,
    int adaptationSetAudioSamplingRate, String adaptationSetLanguage, SegmentBase segmentBase)
    throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth", Format.NO_VALUE);

  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);
  ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();

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

  Format format = buildFormat(id, mimeType, width, height, frameRate, audioChannels,
      audioSamplingRate, bandwidth, adaptationSetLanguage, codecs);
  segmentBase = segmentBase != null ? segmentBase : new SingleSegmentBase(baseUrl);

  return new RepresentationInfo(format, segmentBase, drmSchemeDatas);
}
项目:videoPickPlayer    文件:DashManifestParser.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);
}
项目:transistor    文件:DashManifestParser.java   
protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String baseUrl,
    SegmentBase segmentBase) throws XmlPullParserException, IOException {
  int id = parseInt(xpp, "id", AdaptationSet.ID_UNSET);
  int contentType = parseContentType(xpp);

  String mimeType = xpp.getAttributeValue(null, "mimeType");
  String codecs = xpp.getAttributeValue(null, "codecs");
  int width = parseInt(xpp, "width", Format.NO_VALUE);
  int height = parseInt(xpp, "height", Format.NO_VALUE);
  float frameRate = parseFrameRate(xpp, Format.NO_VALUE);
  int audioChannels = Format.NO_VALUE;
  int audioSamplingRate = parseInt(xpp, "audioSamplingRate", Format.NO_VALUE);
  String language = xpp.getAttributeValue(null, "lang");
  String drmSchemeType = null;
  ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();
  ArrayList<Descriptor> inbandEventStreams = new ArrayList<>();
  ArrayList<Descriptor> accessibilityDescriptors = new ArrayList<>();
  ArrayList<Descriptor> supplementalProperties = new ArrayList<>();
  List<RepresentationInfo> representationInfos = new ArrayList<>();
  @C.SelectionFlags int selectionFlags = 0;

  boolean seenFirstBaseUrl = false;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "BaseURL")) {
      if (!seenFirstBaseUrl) {
        baseUrl = parseBaseUrl(xpp, baseUrl);
        seenFirstBaseUrl = true;
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "ContentProtection")) {
      Pair<String, SchemeData> contentProtection = parseContentProtection(xpp);
      if (contentProtection.first != null) {
        drmSchemeType = contentProtection.first;
      }
      if (contentProtection.second != null) {
        drmSchemeDatas.add(contentProtection.second);
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "ContentComponent")) {
      language = checkLanguageConsistency(language, xpp.getAttributeValue(null, "lang"));
      contentType = checkContentTypeConsistency(contentType, parseContentType(xpp));
    } else if (XmlPullParserUtil.isStartTag(xpp, "Role")) {
      selectionFlags |= parseRole(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "AudioChannelConfiguration")) {
      audioChannels = parseAudioChannelConfiguration(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "Accessibility")) {
      accessibilityDescriptors.add(parseDescriptor(xpp, "Accessibility"));
    } else if (XmlPullParserUtil.isStartTag(xpp, "SupplementalProperty")) {
      supplementalProperties.add(parseDescriptor(xpp, "SupplementalProperty"));
    } else if (XmlPullParserUtil.isStartTag(xpp, "Representation")) {
      RepresentationInfo representationInfo = parseRepresentation(xpp, baseUrl, mimeType, codecs,
          width, height, frameRate, audioChannels, audioSamplingRate, language,
          selectionFlags, accessibilityDescriptors, segmentBase);
      contentType = checkContentTypeConsistency(contentType,
          getContentType(representationInfo.format));
      representationInfos.add(representationInfo);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, (SingleSegmentBase) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, (SegmentList) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, (SegmentTemplate) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "InbandEventStream")) {
      inbandEventStreams.add(parseDescriptor(xpp, "InbandEventStream"));
    } else if (XmlPullParserUtil.isStartTag(xpp)) {
      parseAdaptationSetChild(xpp);
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "AdaptationSet"));

  // Build the representations.
  List<Representation> representations = new ArrayList<>(representationInfos.size());
  for (int i = 0; i < representationInfos.size(); i++) {
    representations.add(buildRepresentation(representationInfos.get(i), contentId,
        drmSchemeType, drmSchemeDatas, inbandEventStreams));
  }

  return buildAdaptationSet(id, contentType, representations, accessibilityDescriptors,
      supplementalProperties);
}
项目:transistor    文件:DashManifestParser.java   
protected RepresentationInfo parseRepresentation(XmlPullParser xpp, String baseUrl,
    String adaptationSetMimeType, String adaptationSetCodecs, int adaptationSetWidth,
    int adaptationSetHeight, float adaptationSetFrameRate, int adaptationSetAudioChannels,
    int adaptationSetAudioSamplingRate, String adaptationSetLanguage,
    @C.SelectionFlags int adaptationSetSelectionFlags,
    List<Descriptor> adaptationSetAccessibilityDescriptors, SegmentBase segmentBase)
    throws XmlPullParserException, IOException {
  String id = xpp.getAttributeValue(null, "id");
  int bandwidth = parseInt(xpp, "bandwidth", Format.NO_VALUE);

  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 drmSchemeType = null;
  ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();
  ArrayList<Descriptor> inbandEventStreams = new ArrayList<>();
  ArrayList<Descriptor> supplementalProperties = new ArrayList<>();

  boolean seenFirstBaseUrl = false;
  do {
    xpp.next();
    if (XmlPullParserUtil.isStartTag(xpp, "BaseURL")) {
      if (!seenFirstBaseUrl) {
        baseUrl = parseBaseUrl(xpp, baseUrl);
        seenFirstBaseUrl = true;
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "AudioChannelConfiguration")) {
      audioChannels = parseAudioChannelConfiguration(xpp);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentBase")) {
      segmentBase = parseSegmentBase(xpp, (SingleSegmentBase) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentList")) {
      segmentBase = parseSegmentList(xpp, (SegmentList) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
      segmentBase = parseSegmentTemplate(xpp, (SegmentTemplate) segmentBase);
    } else if (XmlPullParserUtil.isStartTag(xpp, "ContentProtection")) {
      Pair<String, SchemeData> contentProtection = parseContentProtection(xpp);
      if (contentProtection.first != null) {
        drmSchemeType = contentProtection.first;
      }
      if (contentProtection.second != null) {
        drmSchemeDatas.add(contentProtection.second);
      }
    } else if (XmlPullParserUtil.isStartTag(xpp, "InbandEventStream")) {
      inbandEventStreams.add(parseDescriptor(xpp, "InbandEventStream"));
    } else if (XmlPullParserUtil.isStartTag(xpp, "SupplementalProperty")) {
      supplementalProperties.add(parseDescriptor(xpp, "SupplementalProperty"));
    }
  } while (!XmlPullParserUtil.isEndTag(xpp, "Representation"));

  Format format = buildFormat(id, mimeType, width, height, frameRate, audioChannels,
      audioSamplingRate, bandwidth, adaptationSetLanguage, adaptationSetSelectionFlags,
      adaptationSetAccessibilityDescriptors, codecs, supplementalProperties);
  segmentBase = segmentBase != null ? segmentBase : new SingleSegmentBase();

  return new RepresentationInfo(format, baseUrl, segmentBase, drmSchemeType, drmSchemeDatas,
      inbandEventStreams, Representation.REVISION_ID_DEFAULT);
}
项目:transistor    文件:DashManifestParser.java   
protected SingleSegmentBase buildSingleSegmentBase(RangedUri initialization, long timescale,
    long presentationTimeOffset, long indexStart, long indexLength) {
  return new SingleSegmentBase(initialization, timescale, presentationTimeOffset, indexStart,
      indexLength);
}
项目:K-Sonic    文件: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 inbandEventStreams The in-band event streams in the representation. May be null.
 * @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null.
 * @param contentLength The content length, or {@link C#LENGTH_UNSET} if unknown.
 */
public static SingleSegmentRepresentation newInstance(String contentId, long revisionId,
    Format format, String uri, long initializationStart, long initializationEnd,
    long indexStart, long indexEnd, List<SchemeValuePair> inbandEventStreams,
    String customCacheKey, long contentLength) {
  RangedUri rangedUri = new RangedUri(null, initializationStart,
      initializationEnd - initializationStart + 1);
  SingleSegmentBase segmentBase = new SingleSegmentBase(rangedUri, 1, 0, indexStart,
      indexEnd - indexStart + 1);
  return new SingleSegmentRepresentation(contentId, revisionId,
      format, uri, segmentBase, inbandEventStreams, customCacheKey, contentLength);
}
项目:videoPickPlayer    文件: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 {@link C#LENGTH_UNSET} 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);
}
项目:transistor    文件: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 inbandEventStreams The in-band event streams in the representation. May be null.
 * @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null.
 * @param contentLength The content length, or {@link C#LENGTH_UNSET} if unknown.
 */
public static SingleSegmentRepresentation newInstance(String contentId, long revisionId,
    Format format, String uri, long initializationStart, long initializationEnd,
    long indexStart, long indexEnd, List<Descriptor> inbandEventStreams, String customCacheKey,
    long contentLength) {
  RangedUri rangedUri = new RangedUri(null, initializationStart,
      initializationEnd - initializationStart + 1);
  SingleSegmentBase segmentBase = new SingleSegmentBase(rangedUri, 1, 0, indexStart,
      indexEnd - indexStart + 1);
  return new SingleSegmentRepresentation(contentId, revisionId,
      format, uri, segmentBase, inbandEventStreams, customCacheKey, contentLength);
}