createStream_(downloader, estimator, manifest, stream, config, toDownload) {
    /** @type {shaka.extern.StreamDB} */
    const streamDb = {
      id: stream.id,
      originalId: stream.originalId,
      groupId: stream.groupId,
      primary: stream.primary,
      type: stream.type,
      mimeType: stream.mimeType,
      codecs: stream.codecs,
      frameRate: stream.frameRate,
      pixelAspectRatio: stream.pixelAspectRatio,
      hdr: stream.hdr,
      colorGamut: stream.colorGamut,
      videoLayout: stream.videoLayout,
      kind: stream.kind,
      language: stream.language,
      originalLanguage: stream.originalLanguage,
      label: stream.label,
      width: stream.width || null,
      height: stream.height || null,
      encrypted: stream.encrypted,
      keyIds: stream.keyIds,
      segments: [],
      variantIds: [],
      roles: stream.roles,
      forced: stream.forced,
      channelsCount: stream.channelsCount,
      audioSamplingRate: stream.audioSamplingRate,
      spatialAudio: stream.spatialAudio,
      closedCaptions: stream.closedCaptions,
      tilesLayout: stream.tilesLayout,
      mssPrivateData: stream.mssPrivateData,
      external: stream.external,
      fastSwitching: stream.fastSwitching,
      isAudioMuxedInVideo: stream.isAudioMuxedInVideo,
    };

    const startTime =
        manifest.presentationTimeline.getSegmentAvailabilityStart();

    const numberOfParallelDownloads = config.offline.numberOfParallelDownloads;
    let groupId = numberOfParallelDownloads === 0 ? stream.id : 0;

    shaka.offline.Storage.forEachSegment_(stream, startTime, (segment, pos) => {
      const pendingSegmentRefId =
          shaka.offline.DownloadInfo.idForSegmentRef(segment);
      let pendingInitSegmentRefId = undefined;

      // Set up the download for the segment, which will be downloaded later,
      // perhaps in a service worker.
      if (!toDownload.has(pendingSegmentRefId)) {
        const estimateId = downloader.addDownloadEstimate(
            estimator.getSegmentEstimate(stream.id, segment));
        const segmentDownload = new shaka.offline.DownloadInfo(
            segment,
            estimateId,
            groupId,
            /* isInitSegment= */ false,
            pos);
        toDownload.set(pendingSegmentRefId, segmentDownload);
      }

      // Set up the download for the init segment, similarly, if there is one.
      if (segment.initSegmentReference) {
        pendingInitSegmentRefId = shaka.offline.DownloadInfo.idForSegmentRef(
            segment.initSegmentReference);
        if (!toDownload.has(pendingInitSegmentRefId)) {
          const estimateId = downloader.addDownloadEstimate(
              estimator.getInitSegmentEstimate(stream.id));
          const initDownload = new shaka.offline.DownloadInfo(
              segment.initSegmentReference,
              estimateId,
              groupId,
              /* isInitSegment= */ true,
              pos);
          toDownload.set(pendingInitSegmentRefId, initDownload);
        }
      }

      /** @type {!shaka.extern.SegmentDB} */
      const segmentDB = {
        pendingInitSegmentRefId,
        initSegmentKey: pendingInitSegmentRefId ? 0 : null,
        startTime: segment.startTime,
        endTime: segment.endTime,
        appendWindowStart: segment.appendWindowStart,
        appendWindowEnd: segment.appendWindowEnd,
        timestampOffset: segment.timestampOffset,
        tilesLayout: segment.tilesLayout,
        pendingSegmentRefId,
        dataKey: 0,
        mimeType: segment.mimeType,
        codecs: segment.codecs,
        thumbnailSprite: segment.thumbnailSprite,
      };
      streamDb.segments.push(segmentDB);
      if (numberOfParallelDownloads !== 0) {
        groupId = (groupId + 1) % numberOfParallelDownloads;
      }
    });

    return streamDb;
  }
Converts a manifest stream to a database stream.  This will search the
segment index and add all the segments to the download infos.

@param {!shaka.offline.DownloadManager} downloader
@param {shaka.offline.StreamBandwidthEstimator} estimator
@param {shaka.extern.Manifest} manifest
@param {shaka.extern.Stream} stream
@param {shaka.extern.PlayerConfiguration} config
@param {!Map<string, !shaka.offline.DownloadInfo>} toDownload
@return {shaka.extern.StreamDB}
@private