discardReferenceByBoundary_(mediaState, reference) {
    const ContentType = shaka.util.ManifestParserUtils.ContentType;
    if (mediaState.type === ContentType.TEXT) {
      return false;
    }

    const lastInitRef = mediaState.lastInitSegmentReference;
    if (!lastInitRef) {
      return false;
    }

    const CrossBoundaryStrategy = shaka.config.CrossBoundaryStrategy;
    const logPrefix = shaka.media.StreamingEngine.logPrefix_(mediaState);

    const initRef = reference.initSegmentReference;
    let discard = lastInitRef.boundaryEnd !== initRef.boundaryEnd;
    // Some devices can play plain data when initialized with an encrypted
    // init segment. We can keep the MediaSource in this case.
    if (this.config_.crossBoundaryStrategy ===
          CrossBoundaryStrategy.RESET_TO_ENCRYPTED) {
      if (!lastInitRef.encrypted && !initRef.encrypted) {
        // We're crossing a plain to plain boundary, allow the reference.
        discard = false;
      }
      if (lastInitRef.encrypted) {
        // We initialized MediaSource with an encrypted init segment, from
        // now on, we can keep the buffer.
        shaka.log.debug(logPrefix, 'stream is encrypted, ' +
          'discard crossBoundaryStrategy');
        this.config_.crossBoundaryStrategy = CrossBoundaryStrategy.KEEP;
      }
    }
    if (this.config_.crossBoundaryStrategy ===
          CrossBoundaryStrategy.RESET_ON_ENCRYPTION_CHANGE) {
      if (lastInitRef.encrypted == initRef.encrypted) {
        // We're crossing a plain to plain boundary or we're crossing a
        // encrypted to encrypted boundary, allow the reference.
        discard = false;
      }
    }
    // If discarded & seeked across a boundary, reset MediaSource.
    if (discard && mediaState.seeked) {
      shaka.log.debug(logPrefix, 'reset mediaSource',
          'from=', mediaState.lastInitSegmentReference,
          'to=', reference.initSegmentReference);

      const video = this.playerInterface_.video;
      const pausedBeforeReset = video.paused;
      this.resetMediaSource(/* force= */ true).then(() => {
        const eventName = shaka.util.FakeEvent.EventName.BoundaryCrossed;
        const data = new Map()
            .set('oldEncrypted', lastInitRef.encrypted)
            .set('newEncrypted', initRef.encrypted);
        this.playerInterface_.onEvent(
            new shaka.util.FakeEvent(eventName, data));
        if (!pausedBeforeReset) {
          video.play();
        }
      });
    }
    return discard;
  }
Returns whether the reference should be discarded. If the segment crosses
a boundary, we'll discard it based on the crossBoundaryStrategy.

@param {!shaka.media.StreamingEngine.MediaState_} mediaState
@param {!shaka.media.SegmentReference} reference
@private