getKeySystemAccessFromVariants_(variants, drmInfosByKeySystem) {
    for (const variant of variants) {
      // Get all the key systems in the variant that shouldHaveLicenseServer.
      const drmInfos = this.getVariantDrmInfos_(variant);
      for (const info of drmInfos) {
        if (!drmInfosByKeySystem.has(info.keySystem)) {
          drmInfosByKeySystem.set(info.keySystem, []);
        }
        drmInfosByKeySystem.get(info.keySystem).push(info);
      }
    }

    if (drmInfosByKeySystem.size == 1 && drmInfosByKeySystem.has('')) {
      throw new shaka.util.Error(
          shaka.util.Error.Severity.CRITICAL,
          shaka.util.Error.Category.DRM,
          shaka.util.Error.Code.NO_RECOGNIZED_KEY_SYSTEMS);
    }

    // If we have configured preferredKeySystems, choose a preferred keySystem
    // if available.
    let preferredKeySystems = this.config_.preferredKeySystems;
    if (!preferredKeySystems.length) {
      // If there is no preference set and we only have one license server, we
      // use this as preference. This is used to override manifests on those
      // that have the embedded license and the browser supports multiple DRMs.
      const servers = shaka.util.MapUtils.asMap(this.config_.servers);
      if (servers.size == 1) {
        preferredKeySystems = Array.from(servers.keys());
      }
    }
    for (const preferredKeySystem of preferredKeySystems) {
      for (const variant of variants) {
        const decodingInfo = variant.decodingInfos.find((decodingInfo) => {
          return decodingInfo.supported &&
              decodingInfo.keySystemAccess != null &&
              decodingInfo.keySystemAccess.keySystem == preferredKeySystem;
        });
        if (decodingInfo) {
          return decodingInfo.keySystemAccess;
        }
      }
    }

    // Try key systems with configured license servers first.  We only have to
    // try key systems without configured license servers for diagnostic
    // reasons, so that we can differentiate between "none of these key
    // systems are available" and "some are available, but you did not
    // configure them properly."  The former takes precedence.
    for (const shouldHaveLicenseServer of [true, false]) {
      for (const variant of variants) {
        for (const decodingInfo of variant.decodingInfos) {
          if (!decodingInfo.supported || !decodingInfo.keySystemAccess) {
            continue;
          }
          const originalKeySystem = decodingInfo.keySystemAccess.keySystem;
          if (preferredKeySystems.includes(originalKeySystem)) {
            continue;
          }
          let drmInfos = drmInfosByKeySystem.get(originalKeySystem);
          if (!drmInfos && this.config_.keySystemsMapping[originalKeySystem]) {
            drmInfos = drmInfosByKeySystem.get(
                this.config_.keySystemsMapping[originalKeySystem]);
          }
          for (const info of drmInfos) {
            if (!!info.licenseServerUri == shouldHaveLicenseServer) {
              return decodingInfo.keySystemAccess;
            }
          }
        }
      }
    }
    return null;
  }
Get the MediaKeySystemAccess from the decodingInfos of the variants.
@param {!Array<shaka.extern.Variant>} variants
@param {!Map<string, !Array<shaka.extern.DrmInfo>>} drmInfosByKeySystem
  A dictionary of drmInfos, indexed by key system.
@return {MediaKeySystemAccess}
@private