static variantToTrack(variant) {
    const ManifestParserUtils = shaka.util.ManifestParserUtils;
    const ContentType = shaka.util.ManifestParserUtils.ContentType;

    /** @type {?shaka.extern.Stream} */
    const audio = variant.audio;
    /** @type {?shaka.extern.Stream} */
    const video = variant.video;

    /** @type {?string} */
    const audioMimeType = audio ? audio.mimeType : null;
    /** @type {?string} */
    const videoMimeType = video ? video.mimeType : null;

    /** @type {?string} */
    const audioCodec = audio ? audio.codecs : null;
    /** @type {?string} */
    const videoCodec = video ? video.codecs : null;

    /** @type {?string} */
    const audioGroupId = audio ? audio.groupId : null;

    /** @type {!Array<string>} */
    const mimeTypes = [];
    if (video) {
      mimeTypes.push(video.mimeType);
    }
    if (audio) {
      mimeTypes.push(audio.mimeType);
    }
    /** @type {?string} */
    const mimeType = mimeTypes[0] || null;

    /** @type {!Array<string>} */
    const kinds = [];
    if (audio) {
      kinds.push(audio.kind);
    }
    if (video) {
      kinds.push(video.kind);
    }
    /** @type {?string} */
    const kind = kinds[0] || null;

    /** @type {!Set<string>} */
    const roles = new Set();
    if (audio) {
      for (const role of audio.roles) {
        roles.add(role);
      }
    }
    if (video) {
      for (const role of video.roles) {
        roles.add(role);
      }
    }

    /** @type {shaka.extern.Track} */
    const track = {
      id: variant.id,
      active: false,
      type: 'variant',
      bandwidth: variant.bandwidth,
      language: variant.language,
      label: null,
      kind: kind,
      width: null,
      height: null,
      frameRate: null,
      pixelAspectRatio: null,
      hdr: null,
      colorGamut: null,
      videoLayout: null,
      mimeType: mimeType,
      audioMimeType: audioMimeType,
      videoMimeType: videoMimeType,
      codecs: '',
      audioCodec: audioCodec,
      videoCodec: videoCodec,
      primary: variant.primary,
      roles: Array.from(roles),
      audioRoles: null,
      forced: false,
      videoId: null,
      audioId: null,
      audioGroupId: audioGroupId,
      channelsCount: null,
      audioSamplingRate: null,
      spatialAudio: false,
      tilesLayout: null,
      audioBandwidth: null,
      videoBandwidth: null,
      originalVideoId: null,
      originalAudioId: null,
      originalTextId: null,
      originalImageId: null,
      accessibilityPurpose: null,
      originalLanguage: null,
    };

    if (video) {
      track.videoId = video.id;
      track.originalVideoId = video.originalId;
      track.width = video.width || null;
      track.height = video.height || null;
      track.frameRate = video.frameRate || null;
      track.pixelAspectRatio = video.pixelAspectRatio || null;
      track.videoBandwidth = video.bandwidth || null;
      track.hdr = video.hdr || null;
      track.colorGamut = video.colorGamut || null;
      track.videoLayout = video.videoLayout || null;

      const dependencyStream = video.dependencyStream;
      if (dependencyStream) {
        track.width = dependencyStream.width || track.width;
        track.height = dependencyStream.height || track.height;
        track.videoCodec = dependencyStream.codecs || track.videoCodec;
      }

      if (videoCodec.includes(',')) {
        track.channelsCount = video.channelsCount;
        track.audioSamplingRate = video.audioSamplingRate;
        track.spatialAudio = video.spatialAudio;
        track.originalLanguage = video.originalLanguage;
        track.audioMimeType = videoMimeType;
        const allCodecs = videoCodec.split(',');
        try {
          track.videoCodec = ManifestParserUtils.guessCodecs(
              ContentType.VIDEO, allCodecs);
          track.audioCodec = ManifestParserUtils.guessCodecs(
              ContentType.AUDIO, allCodecs);
        } catch (e) {
          // Ignore this error.
        }
      }
    }

    if (audio) {
      track.audioId = audio.id;
      track.originalAudioId = audio.originalId;
      track.channelsCount = audio.channelsCount;
      track.audioSamplingRate = audio.audioSamplingRate;
      track.audioBandwidth = audio.bandwidth || null;
      track.spatialAudio = audio.spatialAudio;
      track.label = audio.label;
      track.audioRoles = audio.roles;
      track.accessibilityPurpose = audio.accessibilityPurpose;
      track.originalLanguage = audio.originalLanguage;

      const dependencyStream = audio.dependencyStream;
      if (dependencyStream) {
        track.audioCodec = dependencyStream.codecs || track.audioCodec;
      }
    }

    /** @type {!Array<string>} */
    const codecs = [];
    if (track.videoCodec) {
      codecs.push(track.videoCodec);
    }
    if (track.audioCodec) {
      codecs.push(track.audioCodec);
    }
    track.codecs = codecs.join(', ');

    return track;
  }
@param {shaka.extern.Variant} variant
@return {shaka.extern.Track}