static createStreamInfo(context, streamMap, aesKey) {
    goog.asserts.assert(context.representation.segmentList,
        'Should only be called with SegmentList');
    const SegmentList = shaka.dash.SegmentList;

    const initSegmentReference = shaka.dash.SegmentBase.createInitSegment(
        context, SegmentList.fromInheritance_, aesKey);
    const info = SegmentList.parseSegmentListInfo_(context);

    SegmentList.checkSegmentListInfo_(context, info);

    /** @type {shaka.media.SegmentIndex} */
    let segmentIndex = null;
    let stream = null;
    if (context.period.id && context.representation.id) {
      // Only check/store the index if period and representation IDs are set.
      const id = context.period.id + ',' + context.representation.id;
      stream = streamMap.get(id);
      if (stream) {
        segmentIndex = stream.segmentIndex;
      }
    }

    const references = SegmentList.createSegmentReferences_(
        context.periodInfo.start, context.periodInfo.duration,
        info.startNumber, context.representation.getBaseUris, info,
        initSegmentReference, aesKey, context.representation.mimeType,
        context.representation.codecs, context.bandwidth, context.urlParams);

    const isNew = !segmentIndex;
    if (segmentIndex) {
      const start = context.presentationTimeline.getSegmentAvailabilityStart();
      segmentIndex.mergeAndEvict(references, start);
    } else {
      segmentIndex = new shaka.media.SegmentIndex(references);
    }
    context.presentationTimeline.notifySegments(references);

    if (!context.dynamic || !context.periodInfo.isLastPeriod) {
      const periodStart = context.periodInfo.start;
      const periodEnd = context.periodInfo.duration ?
          context.periodInfo.start + context.periodInfo.duration : Infinity;
      segmentIndex.fit(periodStart, periodEnd, isNew);
    }

    if (stream) {
      stream.segmentIndex = segmentIndex;
    }

    return {
      endTime: -1,
      timeline: -1,
      generateSegmentIndex: () => {
        if (!segmentIndex || segmentIndex.isEmpty()) {
          segmentIndex.merge(references);
        }
        return Promise.resolve(segmentIndex);
      },
      timescale: info.timescale,
    };
  }
Creates a new StreamInfo object.
Updates the existing SegmentIndex, if any.

@param {shaka.dash.DashParser.Context} context
@param {!Map<string, !shaka.extern.Stream>} streamMap
@param {shaka.extern.aesKey|undefined} aesKey
@return {shaka.dash.DashParser.StreamInfo}