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

Code before:
    optInfo["dtsInfo"]["frequency"] = audioHint.samplerate / 1000.0;

    if (audioHint.profile == AV_PROFILE_DTS_ES)
      codecName = "DTSE";
    if (audioHint.profile == AV_PROFILE_DTS_HD_MA_X ||
        audioHint.profile == AV_PROFILE_DTS_HD_MA_X_IMAX)
      codecName = "DTSX";
  }
  else if (audioHint.codec == AV_CODEC_ID_OPUS)
  {
    optInfo["opusInfo"]["channels"] = audioHint.channels;
    optInfo["opusInfo"]["frequency"] = audioHint.samplerate / 1000.0;
    optInfo["opusInfo"]["streamHeader"] =
        Base64::Encode(reinterpret_cast<const char*>(audioHint.extradata.GetData()),
                       audioHint.extradata.GetSize());
  }
  else if (audioHint.codec == AV_CODEC_ID_AAC || audioHint.codec == AV_CODEC_ID_AAC_LATM)
  {
    optInfo["aacInfo"]["channels"] = audioHint.channels;
    optInfo["aacInfo"]["frequency"] = audioHint.samplerate / 1000.0;
    optInfo["aacInfo"]["profile"] = audioHint.profile;

    if (audioHint.extradata)
      optInfo["aacInfo"]["format"] = "MP4";
    else
      optInfo["aacInfo"]["format"] = "adts";
  }
  return codecName;
}

void CMediaPipelineWebOS::SetupBitstreamConverter(CDVDStreamInfo& hint)
{
  const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings();
  const bool convertDovi =
      hint.dovi.el_present_flag || settings->GetBool(CSettings::SETTING_VIDEOPLAYER_CONVERTDOVI);

  const std::shared_ptr allowedHdrFormatsSetting(std::dynamic_pointer_cast<CSettingList>(
      settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_ALLOWEDHDRFORMATS)));
  const bool removeDovi = !CSettingUtils::FindIntInList(
      allowedHdrFormatsSetting, CSettings::VIDEOPLAYER_ALLOWED_HDR_TYPE_DOLBY_VISION);

  if (hint.codec == AV_CODEC_ID_AVS || hint.codec == AV_CODEC_ID_CAVS ||
      hint.codec == AV_CODEC_ID_H264 || hint.codec == AV_CODEC_ID_HEVC)
  {
    if (hint.extradata && !hint.cryptoSession)
    {
      m_bitstream = std::make_unique<CBitstreamConverter>();
      if (m_bitstream->Open(hint.codec, hint.extradata.GetData(),
                            static_cast<int>(hint.extradata.GetSize()), true))
      {
        if (hint.codec == AV_CODEC_ID_HEVC)

Review comment (suggestion):
```suggestion
   optInfo["aacInfo"]["format"] = audioHint.extradata ? "MP4" : "adts";
```

Code after:
      allowedHdrFormatsSetting, CSettings::VIDEOPLAYER_ALLOWED_HDR_TYPE_DOLBY_VISION);

  if (hint.codec == AV_CODEC_ID_AVS || hint.codec == AV_CODEC_ID_CAVS ||
      hint.codec == AV_CODEC_ID_H264 || hint.codec == AV_CODEC_ID_HEVC)
  {
    if (hint.extradata && !hint.cryptoSession)
    {
      m_bitstream = std::make_unique<CBitstreamConverter>();
      if (m_bitstream->Open(hint.codec, hint.extradata.GetData(),
                            static_cast<int>(hint.extradata.GetSize()), true))
      {
        if (hint.codec == AV_CODEC_ID_HEVC)
        {
          m_bitstream->SetRemoveDovi(removeDovi);

          // webOS doesn't support HDR10+ and it can cause issues
          m_bitstream->SetRemoveHdr10Plus(true);

          // Only set for profile 7, container hint allows to skip parsing unnecessarily
          // set profile 8 and single layer when converting
          if (!removeDovi && convertDovi && hint.dovi.dv_profile == 7)
          {
            m_bitstream->SetConvertDovi(true);
            hint.dovi.dv_profile = 8;
            hint.dovi.el_present_flag = false;
          }

          bool isDvhe = hint.codec_tag == MKTAG('d', 'v', 'h', 'e');
          bool isDvh1 = hint.codec_tag == MKTAG('d', 'v', 'h', '1');

          // some files don't have dvhe or dvh1 tag set up but have Dolby Vision side data
          if (!isDvhe && !isDvh1 && hint.hdrType == StreamHdrType::HDR_TYPE_DOLBYVISION)
          {
            // page 10, table 2 from https://professional.dolby.com/siteassets/content-creation/dolby-vision-for-content-creators/dolby-vision-streams-within-the-http-live-streaming-format-v2.0-13-november-2018.pdf
            if (hint.codec_tag == MKTAG('h', 'v', 'c', '1'))
              isDvh1 = true;
            else
              isDvhe = true;
          }

          if (removeDovi && (isDvhe || isDvh1))
            hint.hdrType = StreamHdrType::HDR_TYPE_HDR10;
        }
      }
      else
      {
        m_bitstream.reset();
      }
    }
  }
}