Repository: xbmc/xbmc
File: xbmc/cores/VideoPlayer/MediaPipelineWebOS.cpp (C++)

Code before:
{
  m_subtitleDelay = delay;
}

bool CMediaPipelineWebOS::Load(CDVDStreamInfo videoHint, CDVDStreamInfo audioHint)
{
  std::scoped_lock videoLock(m_videoCriticalSection);
  std::scoped_lock audioLock(m_audioCriticalSection);

  CVariant p;

  if (videoHint.cryptoSession || audioHint.cryptoSession)
  {
    CryptoSessionSystem keySystem = CRYPTO_SESSION_SYSTEM_NONE;

    const int svpVersion = m_webOSVersion < 6 ? SVP_VERSION_40 : SVP_VERSION_30;

    if (audioHint.cryptoSession)
    {
      keySystem = audioHint.cryptoSession->keySystem;
    }

    if (videoHint.cryptoSession)
    {
      keySystem = videoHint.cryptoSession->keySystem;
    }

    switch (keySystem)
    {
      case CRYPTO_SESSION_SYSTEM_NONE:
        break;
      case CRYPTO_SESSION_SYSTEM_CLEARKEY:
        break;
      case CRYPTO_SESSION_SYSTEM_WIDEVINE:
        CLog::Log(LOGDEBUG, "Setting drm type to WIDEVINE_MODULAR with svpVersion {}", svpVersion);
        p["option"]["externalStreamingInfo"]["svpVersion"] = svpVersion;
        p["option"]["drm"]["type"] = "WIDEVINE_MODULAR";
        break;
      case CRYPTO_SESSION_SYSTEM_PLAYREADY:
        CLog::Log(LOGDEBUG, "Setting drm type to PLAYREADY with svpVersion {}", svpVersion);
        p["option"]["externalStreamingInfo"]["svpVersion"] = svpVersion;
        p["option"]["drm"]["type"] = "PLAYREADY";
        break;
      default:
        if (audioHint.cryptoSession && !videoHint.cryptoSession)
          CLog::LogF(LOGERROR, "CryptoSession (audio) unsupported: {}",
                     audioHint.cryptoSession->keySystem);
        else if (videoHint.cryptoSession)
          CLog::LogF(LOGERROR, "CryptoSession (video) unsupported: {}",
                     videoHint.cryptoSession->keySystem);
        return false;

Review comment (suggestion):
```suggestion
    const CryptoSessionSystem keySystem = videoHint.cryptoSession
                                              ? videoHint.cryptoSession->keySystem
                                              : audioHint.cryptoSession->keySystem;
```

Code after:
{
  std::scoped_lock videoLock(m_videoCriticalSection);
  std::scoped_lock audioLock(m_audioCriticalSection);

  CVariant p;

  if (videoHint.cryptoSession || audioHint.cryptoSession)
  {
    const CryptoSessionSystem keySystem = videoHint.cryptoSession
                                              ? videoHint.cryptoSession->keySystem
                                              : audioHint.cryptoSession->keySystem;

    const int svpVersion = m_webOSVersion > 4 ? SVP_VERSION_40 : SVP_VERSION_30;

    switch (keySystem)
    {
      case CRYPTO_SESSION_SYSTEM_NONE:
        break;
      case CRYPTO_SESSION_SYSTEM_CLEARKEY:
        break;
      case CRYPTO_SESSION_SYSTEM_WIDEVINE:
        CLog::Log(LOGDEBUG, "Setting drm type to WIDEVINE_MODULAR with svpVersion {}", svpVersion);
        p["option"]["externalStreamingInfo"]["svpVersion"] = svpVersion;
        p["option"]["drm"]["type"] = "WIDEVINE_MODULAR";
        break;
      case CRYPTO_SESSION_SYSTEM_PLAYREADY:
        CLog::Log(LOGDEBUG, "Setting drm type to PLAYREADY with svpVersion {}", svpVersion);
        p["option"]["externalStreamingInfo"]["svpVersion"] = svpVersion;
        p["option"]["drm"]["type"] = "PLAYREADY";
        break;
      default:
        if (audioHint.cryptoSession && !videoHint.cryptoSession)
          CLog::LogF(LOGERROR, "CryptoSession (audio) unsupported: {}",
                     audioHint.cryptoSession->keySystem);
        else if (videoHint.cryptoSession)
          CLog::LogF(LOGERROR, "CryptoSession (video) unsupported: {}",
                     videoHint.cryptoSession->keySystem);
        return false;
    }
  }

  if (!videoHint.width || !videoHint.height)
  {
    CLog::LogF(LOGERROR, "{}", "null size, cannot handle");
    return false;
  }

  CLog::LogF(LOGDEBUG,
             "hints: Width {} x Height {}, Fpsrate {} / Fpsscale {}, "
             "CodecID {}, Level {}, Profile {}, PTS_invalid {}, Tag {}, Extradata-Size: {}",
             videoHint.width, videoHint.height, videoHint.fpsrate, videoHint.fpsscale,