async append_(mediaState, presentationTime, stream, reference, segment,
      isChunkedData = false, adaptation = false) {
    const logPrefix = shaka.media.StreamingEngine.logPrefix_(mediaState);

    const hasClosedCaptions = stream.closedCaptions &&
        stream.closedCaptions.size > 0;

    if (this.config_.shouldFixTimestampOffset) {
      const isMP4 = stream.mimeType == 'video/mp4' ||
              stream.mimeType == 'audio/mp4';
      let timescale = null;
      if (reference.initSegmentReference) {
        timescale = reference.initSegmentReference.timescale;
      }
      const shouldFixTimestampOffset = isMP4 && timescale &&
          stream.type === shaka.util.ManifestParserUtils.ContentType.VIDEO &&
          this.manifest_.type == shaka.media.ManifestParser.DASH;

      if (shouldFixTimestampOffset) {
        new shaka.util.Mp4Parser()
            .box('moof', shaka.util.Mp4Parser.children)
            .box('traf', shaka.util.Mp4Parser.children)
            .fullBox('tfdt', async (box) => {
              goog.asserts.assert(
                  box.version != null,
                  'TFDT is a full box and should have a valid version.');

              const parsedTFDT = shaka.util.Mp4BoxParsers.parseTFDTInaccurate(
                  box.reader, box.version);

              const baseMediaDecodeTime = parsedTFDT.baseMediaDecodeTime;

              // In case the time is 0, it is not updated
              if (!baseMediaDecodeTime) {
                return;
              }
              goog.asserts.assert(typeof(timescale) == 'number',
                  'Should be an number!');

              const scaledMediaDecodeTime = -baseMediaDecodeTime / timescale;

              const comparison1 = Number(mediaState.lastTimestampOffset) || 0;

              if (comparison1 < scaledMediaDecodeTime) {
                const lastAppendWindowStart = mediaState.lastAppendWindowStart;
                const lastAppendWindowEnd = mediaState.lastAppendWindowEnd;
                goog.asserts.assert(typeof(lastAppendWindowStart) == 'number',
                    'Should be an number!');
                goog.asserts.assert(typeof(lastAppendWindowEnd) == 'number',
                    'Should be an number!');
                await this.setProperties_(mediaState, scaledMediaDecodeTime,
                    lastAppendWindowStart, lastAppendWindowEnd, reference);
              }
            })
            .parse(segment, /* partialOkay= */ false, isChunkedData);
      }
    }

    await this.evict_(mediaState, presentationTime);
    this.destroyer_.ensureNotDestroyed();

    // 'seeked' or 'adaptation' triggered logic applies only to this
    // appendBuffer() call.
    const seeked = mediaState.seeked;
    mediaState.seeked = false;

    await this.playerInterface_.beforeAppendSegment(mediaState.type, segment);
    await this.playerInterface_.mediaSourceEngine.appendBuffer(
        mediaState.type,
        segment,
        reference,
        stream,
        hasClosedCaptions,
        seeked,
        adaptation,
        isChunkedData);
    this.destroyer_.ensureNotDestroyed();
    shaka.log.v2(logPrefix, 'appended media segment');
  }
Appends the given segment and evicts content if required to append.

@param {!shaka.media.StreamingEngine.MediaState_} mediaState
@param {number} presentationTime
@param {shaka.extern.Stream} stream
@param {!shaka.media.SegmentReference} reference
@param {BufferSource} segment
@param {boolean=} isChunkedData
@param {boolean=} adaptation
@return {!Promise}
@private