async codecSwitchIfNecessary_(contentType, mimeType, codecs, streamsByType) {
    const ContentType = shaka.util.ManifestParserUtils.ContentType;
    if (contentType == ContentType.TEXT) {
      return false;
    }
    const MimeUtils = shaka.util.MimeUtils;
    const currentCodec = MimeUtils.getNormalizedCodec(
        MimeUtils.getCodecs(this.sourceBufferTypes_.get(contentType)));
    const currentBasicType = MimeUtils.getBasicType(
        this.sourceBufferTypes_.get(contentType));

    const realInfo = this.getRealInfo_(contentType, mimeType, codecs);
    const transmuxer = realInfo.transmuxer;
    const transmuxerMuxed = realInfo.transmuxerMuxed;
    const newBasicType = realInfo.basicType;
    const newCodec = realInfo.codec;
    const newMimeType = realInfo.mimeType;

    let muxedContentCheck = true;
    if (transmuxerMuxed &&
        this.sourceBufferTypes_.has(ContentType.AUDIO)) {
      const muxedRealInfo =
          this.getRealInfo_(ContentType.AUDIO, mimeType, codecs);
      const muxedCurrentCodec = MimeUtils.getNormalizedCodec(
          MimeUtils.getCodecs(this.sourceBufferTypes_.get(ContentType.AUDIO)));
      const muxedCurrentBasicType = MimeUtils.getBasicType(
          this.sourceBufferTypes_.get(ContentType.AUDIO));
      muxedContentCheck = muxedCurrentCodec == muxedRealInfo.codec &&
        muxedCurrentBasicType == muxedRealInfo.basicType;
      if (muxedRealInfo.transmuxer) {
        muxedRealInfo.transmuxer.destroy();
      }
    }

    // Current/new codecs base and basic type match then no need to switch
    if (currentCodec === newCodec && currentBasicType === newBasicType &&
        muxedContentCheck) {
      if (this.transmuxers_.has(contentType) && !transmuxer) {
        this.transmuxers_.get(contentType).destroy();
        this.transmuxers_.delete(contentType);
      } else if (!this.transmuxers_.has(contentType) && transmuxer) {
        this.transmuxers_.set(contentType, transmuxer);
      } else if (transmuxer) {
        // Compare if the transmuxer is different
        if (this.transmuxers_.has(contentType) &&
            this.transmuxers_.get(contentType).transmux !=
              transmuxer.transmux) {
          this.transmuxers_.get(contentType).destroy();
          this.transmuxers_.delete(contentType);
          this.transmuxers_.set(contentType, transmuxer);
        } else {
          transmuxer.destroy();
        }
      }
      return false;
    }

    let allowChangeType = true;
    if (this.needSplitMuxedContent_ || (transmuxerMuxed &&
        transmuxer && !this.transmuxers_.has(contentType))) {
      allowChangeType = false;
    }

    if (allowChangeType && this.config_.codecSwitchingStrategy ===
        shaka.config.CodecSwitchingStrategy.SMOOTH &&
          shaka.media.Capabilities.isChangeTypeSupported()) {
      await this.changeType(contentType, newMimeType, transmuxer);
    } else {
      if (transmuxer) {
        transmuxer.destroy();
      }
      await this.reset(streamsByType);
    }
    return true;
  }
Codec switch if necessary, this will not resolve until the codec
switch is over.
@param {shaka.util.ManifestParserUtils.ContentType} contentType
@param {string} mimeType
@param {string} codecs
@param {!Map<shaka.util.ManifestParserUtils.ContentType,
              shaka.extern.Stream>} streamsByType
@return {!Promise<boolean>} true if there was a codec switch,
                             false otherwise.
@private