function createAlternateSegmentIndex(baseStream, alternateStream) {
    const closeSegmentIndexSpy = Util.funcSpy(
        /** @type {!function()} */ (alternateStream.closeSegmentIndex));
    const createSegmentIndexSpy =
        Util.funcSpy(alternateStream.createSegmentIndex);

    createSegmentIndexSpy.and.callFake(() => {
      const altSegmentIndex = new shaka.test.FakeSegmentIndex();

      altSegmentIndex.find.and.callFake(
          (time) => baseStream.segmentIndex.find(time));

      altSegmentIndex.getNumReferences.and.callFake(
          () => baseStream.segmentIndex.getNumReferences());

      altSegmentIndex.get.and.callFake((pos) => {
        const ref = baseStream.segmentIndex.get(pos);

        if (ref) {
          const altInitUri = ref.initSegmentReference.getUris()[0] + '_alt';
          const altSegmentUri = ref.getUris()[0] + '_alt';

          ref.initSegmentReference.getUris = () => [altInitUri];
          ref.getUris = () => [altSegmentUri];
          return ref;
        }

        return null;
      });
      alternateStream.segmentIndex = altSegmentIndex;
      return Promise.resolve();
    });
    closeSegmentIndexSpy.and.callFake(() => {
      if (alternateStream.segmentIndex) {
        alternateStream.segmentIndex.release();
      }
      alternateStream.segmentIndex = null;
      return Promise.resolve();
    });
  }
Create a valid segment index for |alternateStream| based on |baseStream|
segment index.

@param {shaka.extern.Stream} baseStream
@param {shaka.extern.Stream} alternateStream