async extendExistingOutputStream_(
      outputStream, streamsPerPeriod, firstNewPeriodIndex, concat,
      unusedStreamsPerPeriod, periodsMissing) {
    this.findMatchesInAllPeriods_(streamsPerPeriod,
        outputStream, periodsMissing > 0);

    // This only exists where T == Stream, and this should only ever be called
    // on Stream types.  StreamDB should not have pre-existing output streams.
    goog.asserts.assert(outputStream.createSegmentIndex,
        'outputStream should be a Stream type!');

    if (!outputStream.matchedStreams) {
      // We were unable to extend this output stream.
      shaka.log.error('No matches extending output stream!',
          outputStream, streamsPerPeriod);
      return false;
    }
    // We need to create all the per-period segment indexes and append them to
    // the output's MetaSegmentIndex.
    if (outputStream.segmentIndex) {
      await shaka.util.PeriodCombiner.extendOutputSegmentIndex_(outputStream,
          firstNewPeriodIndex + periodsMissing);
    }

    shaka.util.PeriodCombiner.extendOutputStream_(outputStream,
        firstNewPeriodIndex, concat, unusedStreamsPerPeriod, periodsMissing);
    return true;
  }
@param {T} outputStream An existing output stream which needs to be
  extended into new periods.
@param {!Array<!Map<string, T>>} streamsPerPeriod A list of maps of Streams
  from each period.
@param {number} firstNewPeriodIndex An index into streamsPerPeriod which
  represents the first new period that hasn't been processed yet.
@param {function(T, T)} concat Concatenate the second stream onto the end
  of the first.
@param {!Array<!Set<T>>} unusedStreamsPerPeriod An array of sets of
  unused streams from each period.
@param {number} periodsMissing How many periods are missing in this update.

@return {!Promise<boolean>}

@template T
Should only be called with a Stream type in practice, but has call sites
from other templated functions that also accept a StreamDB.

@private