[M120 Migration][MM] Merge HDR and use RM API to get Codec resolution 41/307041/4
authorwuxiaoliang <xliang.wu@samsung.com>
Mon, 4 Mar 2024 06:40:43 +0000 (14:40 +0800)
committerBot Blink <blinkbot@samsung.com>
Tue, 5 Mar 2024 04:19:17 +0000 (04:19 +0000)
1. Add max codec resolution for Sero TV.
2. Update VP9* codec info.
3. Set HDR info.
4. Not support spatial rendering feature.

* Multiview resource allocation depends on left/right launch, and limitations are:
  - not support trick play
  - not support HDR
  - not support 360 video

Migration from:
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/290344/
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/297093/
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/290415/

Change-Id: If91d6130281ac10cc0dc5b414f819d1ff557b9a2
Signed-off-by: wuxiaoliang <xliang.wu@samsung.com>
15 files changed:
media/base/video_decoder_config.h
media/filters/stream_parser_factory.cc
media/formats/webm/webm_colour_parser.cc
media/formats/webm/webm_colour_parser.h
media/formats/webm/webm_video_client.cc
media/mojo/mojom/media_types.mojom
media/mojo/mojom/video_decoder_config_mojom_traits.cc
media/mojo/mojom/video_decoder_config_mojom_traits.h
packaging/chromium-efl.spec [changed mode: 0755->0644]
third_party/blink/renderer/modules/media_capabilities/media_capabilities.cc
third_party/blink/renderer/modules/mediasource/media_source.cc
tizen_src/build/BUILD.gn
tizen_src/chromium_impl/media/filters/esplusplayer_util.cc
tizen_src/chromium_impl/media/filters/esplusplayer_util.h
tizen_src/chromium_impl/media/media_efl.gni

index 2cdcc8a..32d882d 100644 (file)
@@ -164,6 +164,11 @@ class MEDIA_EXPORT VideoDecoderConfig {
   void set_is_rtc(bool is_rtc) { is_rtc_ = is_rtc; }
   bool is_rtc() const { return is_rtc_; }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  void set_hdr_info(const std::string& hdr_info) { hdr_info_ = hdr_info; }
+  const std::string& hdr_info() const { return hdr_info_; }
+#endif
+
  private:
   VideoCodec codec_ = VideoCodec::kUnknown;
   VideoCodecProfile profile_ = VIDEO_CODEC_PROFILE_UNKNOWN;
@@ -191,6 +196,10 @@ class MEDIA_EXPORT VideoDecoderConfig {
   absl::optional<gfx::HDRMetadata> hdr_metadata_;
   bool is_rtc_ = false;
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  std::string hdr_info_;
+#endif
+
   // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
   // generated copy constructor and assignment operator. Since the extra data is
   // typically small, the performance impact is minimal.
index 4cc65d1..aca8dff 100644 (file)
@@ -94,7 +94,7 @@ struct SupportedTypeInfo {
 
 static const CodecInfo kVP8CodecInfo = {"vp8", CodecInfo::VIDEO, nullptr,
                                         CodecInfo::HISTOGRAM_VP8};
-static const CodecInfo kLegacyVP9CodecInfo = {"vp9", CodecInfo::VIDEO, nullptr,
+static const CodecInfo kLegacyVP9CodecInfo = {"vp9*", CodecInfo::VIDEO, nullptr,
                                               CodecInfo::HISTOGRAM_VP9};
 static const CodecInfo kVP9CodecInfo = {"vp09.*", CodecInfo::VIDEO, nullptr,
                                         CodecInfo::HISTOGRAM_VP9};
index 7680593..43c2a69 100644 (file)
@@ -221,4 +221,45 @@ WebMColorMetadata WebMColourParser::GetWebMColorMetadata() const {
   return color_metadata;
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+#define DEFAULT_ZERO(x) ((x == -1) ? 0 : x)
+const std::string WebMColourParser::GetWebMHdrInfo() {
+  std::ostringstream s;
+  s << "matrixCoefficients:" << DEFAULT_ZERO(matrix_coefficients_)
+    << " bitsPerChannel:" << DEFAULT_ZERO(bits_per_channel_)
+    << " chromaSubsamplingHorz:" << DEFAULT_ZERO(chroma_subsampling_horz_)
+    << " chromaSubsamplingVert:" << DEFAULT_ZERO(chroma_subsampling_vert_)
+    << " cbSubsamplingHorz:" << DEFAULT_ZERO(cb_subsampling_horz_)
+    << " cbSubsamplingVert:" << DEFAULT_ZERO(cb_subsampling_vert_)
+    << " chromaSitingHorz:" << DEFAULT_ZERO(chroma_siting_horz_)
+    << " chromaSitingVert:" << DEFAULT_ZERO(chroma_siting_vert_)
+    << " range:" << DEFAULT_ZERO(range_)
+    << " transferCharacteristics:" << DEFAULT_ZERO(transfer_characteristics_)
+    << " primaries:" << DEFAULT_ZERO(primaries_)
+    << " maxCLL:" << DEFAULT_ZERO(max_content_light_level_)
+    << " maxFALL:" << DEFAULT_ZERO(max_content_light_level_) << " RX:"
+    << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fRX
+    << " RY:"
+    << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fRY
+    << " GX:"
+    << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fGX
+    << " GY:"
+    << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fGY
+    << " BX:"
+    << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fBX
+    << " BY:"
+    << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fBY
+    << " wX:"
+    << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fWX
+    << " wY:"
+    << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fWY
+    << " luminanceMax:"
+    << color_volume_metadata_parser_.GetColorVolumeMetadata().luminance_max
+    << " luminanceMin:"
+    << color_volume_metadata_parser_.GetColorVolumeMetadata().luminance_min;
+
+  return s.str();
+}
+#endif
+
 }  // namespace media
index cb568a2..49db1e5 100644 (file)
@@ -69,6 +69,10 @@ class WebMColourParser : public WebMParserClient {
 
   WebMColorMetadata GetWebMColorMetadata() const;
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  const std::string GetWebMHdrInfo();
+#endif
+
  private:
   // WebMParserClient implementation.
   WebMParserClient* OnListStart(int id) override;
index 37d223d..15347cb 100644 (file)
@@ -166,6 +166,11 @@ bool WebMVideoClient::InitializeConfig(
                      color_space, kNoTransformation, coded_size, visible_rect,
                      natural_size, codec_private, encryption_scheme);
 
+#if defined(IS_TIZEN_TV)
+  if (colour_parsed_)
+    config->set_hdr_info(colour_parser_.GetWebMHdrInfo());
+#endif
+
   return config->IsValidConfig();
 }
 
index 5f8a149..57eccec 100644 (file)
@@ -196,6 +196,8 @@ struct VideoDecoderConfig {
   EncryptionScheme encryption_scheme;
   VideoColorSpace color_space_info;
   gfx.mojom.HDRMetadata? hdr_metadata;
+  [EnableIf=is_tizen_tv]
+  string hdr_info;
 };
 
 // Native struct media::SubsampleEntry;
index fbb3712..a292413 100644 (file)
@@ -63,6 +63,13 @@ bool StructTraits<media::mojom::VideoDecoderConfigDataView,
 
   output->set_level(input.level());
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  std::string hdr;
+  if (!input.ReadHdrInfo(&hdr))
+    return false;
+  output->set_hdr_info(hdr.c_str());
+#endif
+
   if (!output->IsValidConfig())
     return false;
 
index f79c60f..072da54 100644 (file)
@@ -74,6 +74,12 @@ struct StructTraits<media::mojom::VideoDecoderConfigDataView,
     return input.level();
   }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  static std::string hdr_info(const media::VideoDecoderConfig& input) {
+    return input.hdr_info();
+  }
+#endif
+
   static bool Read(media::mojom::VideoDecoderConfigDataView input,
                    media::VideoDecoderConfig* output);
 };
old mode 100755 (executable)
new mode 100644 (file)
index bf7feab..02b919f
@@ -192,6 +192,9 @@ BuildRequires: pkgconfig(tv-resource-manager)
 BuildRequires: pkgconfig(tv-resource-information)
 BuildRequires: pkgconfig(vd-win-util)
 BuildRequires: pkgconfig(WebProduct)
+%if %{tizen_version} >= 60
+BuildRequires: pkgconfig(resource-center-api)
+%endif
 %endif
 
 %if "%{__enable_capi_thread_booster}" == "1"
index 550bff3..af9d7a2 100644 (file)
@@ -430,6 +430,11 @@ WebAudioConfiguration ToWebAudioConfiguration(
   if (configuration->hasSamplerate())
     web_configuration.samplerate = configuration->samplerate();
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (configuration->hasSpatialRendering())
+    web_configuration.spatialRendering = configuration->spatialRendering();
+#endif
+
   return web_configuration;
 }
 
@@ -683,6 +688,12 @@ bool IsAudioConfigurationSupported(
   if (audio_config->hasSpatialRendering())
     is_spatial_rendering = audio_config->spatialRendering();
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Currently there is no support for spatial rendering feature
+  if (is_spatial_rendering)
+    return false;
+#endif
+
   return media::IsSupportedAudioType(
       {audio_codec, audio_profile, is_spatial_rendering});
 }
index d66cc97..4a8adf9 100644 (file)
@@ -694,9 +694,9 @@ bool MediaSource::IsTypeSupportedInternal(ExecutionContext* context,
 
   bool result = supported == MIMETypeRegistry::kSupported;
 
-  DVLOG(2) << __func__ << "(" << type << ", "
-           << (enforce_codec_specificity ? "true" : "false") << ") -> "
-           << (result ? "true" : "false");
+  LOG(INFO) << __func__ << "(" << type << ", "
+            << (enforce_codec_specificity ? "true" : "false") << ") -> "
+            << (result ? "true" : "false");
   RecordIdentifiabilityMetric(context, type, result);
   return result;
 }
index c57dcd9..f05af15 100644 (file)
@@ -55,6 +55,19 @@ config("ecore-x-public") {
   }
 }
 
+config("resource-center-api") {
+  if (tizen_product_tv && tizen_version >= 60) {
+    ldflags = [ "-lresource-center-api" ]
+  }
+}
+
+tizen_pkg_config("libresource-center-api") {
+  packages = []
+  if (tizen_product_tv && tizen_version >= 60) {
+    packages = [ "resource-center-api" ]
+  }
+}
+
 config("ecore-wayland") {
   if (is_tizen && use_wayland) {
     if (tizen_version >= 50) {
index 6094401..13cb234 100644 (file)
@@ -4,9 +4,23 @@
 
 #include "tizen_src/chromium_impl/media/filters/esplusplayer_util.h"
 
+#include <vconf/vconf.h>
+
+#include "base/json/json_reader.h"
 #include "base/logging.h"
+#include "tizen_src/chromium_impl/build/tizen_version.h"
 
 #if BUILDFLAG(IS_TIZEN_TV)
+#include <resource_center.h>
+#include <ri-common-type.h>
+#include <ri-module-api.h>
+#include <tv-resource-information/ri-api.h>
+#include <tv-resource-manager/rm_module_api.h>
+#include "base/command_line.h"
+#include "base/memory/ptr_util.h"
+#include "content/public/common/content_switches.h"
+#include "ewk/efl_integration/common/application_type.h"
+#include "ewk/efl_integration/common/content_switches_efl.h"
 #include "tizen_src/chromium_impl/tizen/tizen_tv_platform.h"
 #endif
 
@@ -185,22 +199,149 @@ PipelineStatus GetPipelineError(const esplusplayer_error_type error) {
   return PIPELINE_ERROR_DECODE;
 }
 
+bool isProductTypeSero() {
+  bool is_sero = false;
+#if BUILDFLAG(IS_TIZEN_TV)
+  is_sero = isTVRotated();
+#endif
+
+  LOG(INFO) << "This product type is " << (is_sero ? "a Sero" : "not a Sero");
+  return is_sero;
+}
+
+#if BUILDFLAG(IS_TIZEN_TV) && TIZEN_VERSION_AT_LEAST(6, 0, 0)
+gfx::Size GetDynamicMaxCodecResolution() {
+  int max_width = 0;
+  int max_height = 0;
+  int max_framerate = 0;
+  std::string app_id =
+      base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+          switches::kTizenAppId);
+
+  // resource center returns decodeer ability not resolution (ex.1088)
+  // http://wiki.vd.sec.samsung.net/display/OSS/02.+Max+Resolution
+  if (rc_get_max_video_resolution(app_id.c_str(), &max_width, &max_height,
+                                  &max_framerate) < 0) {
+    LOG(ERROR) << "Getting max video resolution failed in multiview mode.";
+    return {kFHDVideoMaxWidth, kFHDVideoMaxHeight};
+  }
+
+  // H.264 has to be decoded by 4K decoder(dvde) in multiview mode
+  // to support below scenario.
+  // Left FHD@30 (TVPlus) | Right FHD@60 (AirPlay is placed at right always)
+  // Refer to http://wiki.vd.sec.samsung.net/display/OSS/10.+Resource+table
+  if (max_width >= k8KVideoMaxWidth) {
+    return k8KVideoMaxSize;
+  } else if (max_width >= k4KVideoMaxWidth && max_width < k8KVideoMaxWidth) {
+    return k4KVideoMaxSize;
+  } else {
+    return kFHDVideoMaxSize;
+  }
+}
+
+const char* GetRIVideoCodecName(esplusplayer_video_mime_type mime_type) {
+  switch (mime_type) {
+    case ESPLUSPLAYER_VIDEO_MIME_TYPE_AV1:
+      return RI_CODEC_NAME_AV1;
+    case ESPLUSPLAYER_VIDEO_MIME_TYPE_VP8:
+      return RI_CODEC_NAME_VP8;
+    case ESPLUSPLAYER_VIDEO_MIME_TYPE_VP9:
+      return RI_CODEC_NAME_VP9;
+    case ESPLUSPLAYER_VIDEO_MIME_TYPE_HEVC:
+      return RI_CODEC_NAME_HEVC;
+    case ESPLUSPLAYER_VIDEO_MIME_TYPE_H264:
+      return RI_CODEC_NAME_H264;
+    case ESPLUSPLAYER_VIDEO_MIME_TYPE_MJPEG:
+      return RI_CODEC_NAME_MJPEG;
+    default:
+      break;
+  }
+  return "";
+}
+
+gfx::Size GetMaxCodecResolutionRI(esplusplayer_video_mime_type mime_type,
+                                  bool is_video_hole) {
+  int max_width = 0;
+  int max_height = 0;
+  int max_framerate = 0;
+  const char* ri_video_codec = GetRIVideoCodecName(mime_type);
+
+  // In portrait mode adaptive streaming has some problem
+  // when changing a resolution so Sero uses dvde decoder
+  // for all kind of codecs.
+  // The dvde decoder doesn't support VP8 and WMV. It is Sero product spec.
+  if (!*ri_video_codec) {
+    if (isProductTypeSero()) {
+      return k4KVideoMaxSize;
+    } else {
+      return kFHDVideoMaxSize;
+    }
+  }
+
+  if (ri_video_codec == RI_CODEC_NAME_H264) {
+    if (is_video_hole && isProductTypeSero())
+      return k4KVideoMaxSize;
+    else
+      return kFHDVideoMaxSize;
+  }
+
+  if (ri_get_max_resolution(ri_video_codec, &max_width, &max_height,
+                            &max_framerate) != RI_OK) {
+    LOG(WARNING) << "Failed to get video max information";
+    const auto panel_resolution = GetPanelResolution();
+    return {panel_resolution.width(), panel_resolution.height()};
+  }
+
+  if (max_width >= k8KVideoMaxWidth) {
+    max_width = k8KVideoMaxWidth;
+    max_height = k8KVideoMaxHeight;
+  } else if (max_width >= k4KVideoMaxWidth && max_width < k8KVideoMaxWidth) {
+    max_width = k4KVideoMaxWidth;
+    max_height = k4KVideoMaxHeight;
+  } else if (max_width >= kFHDVideoMaxWidth && max_width < k4KVideoMaxWidth) {
+    max_width = kFHDVideoMaxWidth;
+    max_height = kFHDVideoMaxHeight;
+  }
+  return {max_width, max_height};
+}
+#endif
+
 gfx::Size GetMaxCodecResolution(esplusplayer_video_mime_type mime_type,
                                 bool is_video_hole) {
+#if BUILDFLAG(IS_TIZEN_TV) && TIZEN_VERSION_AT_LEAST(6, 0, 0)
+  if (media::IsMultiviewMode()) {
+    // Multiview specification:
+    // http://wiki.vd.sec.samsung.net/pages/viewpage.action?pageId=79211942
+    return GetDynamicMaxCodecResolution();
+  }
+  return GetMaxCodecResolutionRI(mime_type, is_video_hole);
+#else
   switch (mime_type) {
     case ESPLUSPLAYER_VIDEO_MIME_TYPE_AV1:
     case ESPLUSPLAYER_VIDEO_MIME_TYPE_HEVC:
     case ESPLUSPLAYER_VIDEO_MIME_TYPE_VP9:
       return k8KVideoMaxSize;
     case ESPLUSPLAYER_VIDEO_MIME_TYPE_H264:
-      if (is_video_hole)
+      // H.264 has to be decoded by dvde decoder in multiview mode
+      // to support below scenario.
+      // Left FHD@30 (TVPlus) | Right FHD@60 (AirPlay)
+      // Refer to http://wiki.vd.sec.samsung.net/display/OSS/10.+Resource+table
+      if (is_video_hole && isProductTypeSero())
         return k4KVideoMaxSize;
       else
         return kFHDVideoMaxSize;
     case ESPLUSPLAYER_VIDEO_MIME_TYPE_VP8:
     default:
-      return kFHDVideoMaxSize;
+      // In portrait mode adaptive streaming has some problem
+      // when changing a resolution so Sero uses dvde decoder
+      // for all kind of codecs.
+      // The dvde decoder doesn't support VP8 and WMV. It is Sero product spec.
+      if (isProductTypeSero())
+        return k4KVideoMaxSize;
+      else
+        return kFHDVideoMaxSize;
   }
+#endif
 }
 
 gfx::Size GetPanelResolution() {
@@ -234,4 +375,30 @@ esplusplayer_display_rotation_type ConvertToESPlusPlayerDisplayRotation(
   }
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+bool IsMultiviewMode() {
+  const char vconf_multiview_info[] = "memory/multiscreen/info";
+
+  char* multiview_info = vconf_get_str(vconf_multiview_info);
+  if (multiview_info) {
+    auto multiview_info_value = base::JSONReader::Read(multiview_info);
+    free(multiview_info);
+    if (!multiview_info_value || !multiview_info_value->is_dict()) {
+      LOG(ERROR) << "read vconf multiview info failed";
+      return false;
+    }
+
+    base::Value::Dict& dict = multiview_info_value->GetDict();
+
+    const std::string* mode_value = dict.FindString("mode");
+    if (mode_value && *mode_value == "on") {
+      LOG(INFO) << "It is in multiview mode.";
+      return true;
+    }
+  }
+
+  return false;
+}
+#endif
+
 }  // namespace media
index 5086de1..0208cd8 100644 (file)
 #include "tizen_src/chromium_impl/media/filters/buffer_observer.h"
 #include "ui/gfx/geometry/size.h"
 
+constexpr auto kFHDVideoMaxWidth = 1920;
+constexpr auto kFHDVideoMaxHeight = 1080;
+constexpr auto kQHDVideoMaxWidth = 2560;
+constexpr auto kQHDVideoMaxHeight = 1440;
+constexpr auto k4KVideoMaxWidth = 3840;
+constexpr auto k4KVideoMaxHeight = 2160;
+constexpr auto k4KDCIVideoMaxWidth = 4096;
+constexpr auto k4KDCIVideoMaxHeight = 2160;
+constexpr auto k8KVideoMaxWidth = 7680;
+constexpr auto k8KVideoMaxHeight = 4320;
+
 namespace media {
 constexpr int kElementryStreamCount = 2;  // Audio, Video only.
 constexpr int kVideoFramerateDen = 100;
@@ -43,6 +54,10 @@ gfx::Size GetMaxResolution(esplusplayer_video_mime_type mime_type,
 esplusplayer_display_rotation_type ConvertToESPlusPlayerDisplayRotation(
     int rotation);
 
+#if BUILDFLAG(IS_TIZEN_TV)
+bool IsMultiviewMode();
+#endif
+
 }  // namespace media
 
 #endif  // MEDIA_FILTERS_ESPP_PLAYER_UTIL_H_
index e50eeba..edaf05c 100644 (file)
@@ -24,8 +24,23 @@ if (tizen_multimedia) {
     "//tizen_src/build:esplusplayer",
     "//tizen_src/build:libesplusplayer",
     "//tizen_src/chromium_impl/media:media_efl_config",
+    "//tizen_src/build:tizen-tv-resource-manager-config",
   ]
 
+  if(tizen_product_tv) {
+    external_media_video_decode_config += [
+    "//tizen_src/build:hdmicec-api",
+    "//tizen_src/build:libhdmicec-api",
+    ]
+  }
+
+  if(tizen_product_tv) {
+    external_media_video_decode_config += [
+      "//tizen_src/build:resource-center-api",
+      "//tizen_src/build:libresource-center-api",
+    ]
+  }
+
   if (use_wayland) {
     external_media_video_decode_config += [
       "//tizen_src/build:ecore-wayland",