[M108 Aura Migration] Setting demuxer memory limit 61/290461/9
authoryanting.hong <yanting.hong@samsung.com>
Mon, 27 Mar 2023 03:18:30 +0000 (11:18 +0800)
committerBot Blink <blinkbot@samsung.com>
Tue, 28 Mar 2023 03:14:24 +0000 (03:14 +0000)
Migrated from:
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/280160/

Change-Id: Ib78ab63a36ac9744313524baf884ac5cd6d5e1e6
Signed-off-by: yanting.hong <yanting.hong@samsung.com>
media/base/BUILD.gn
media/base/demuxer_memory_limit.h
media/base/demuxer_memory_limit_product_tv.cc [new file with mode: 0644]
media/filters/source_buffer_stream.cc

index 42dfa5d..40d4f92 100644 (file)
@@ -454,6 +454,8 @@ source_set("base") {
     sources += [ "demuxer_memory_limit_android.cc" ]
   } else if (is_castos) {
     sources += [ "demuxer_memory_limit_cast.cc" ]
+  } else if (tizen_product_tv) {
+    sources += [ "demuxer_memory_limit_product_tv.cc" ]
   } else if (is_fuchsia || tizen_multimedia) {
     sources += [ "demuxer_memory_limit_low.cc" ]
   } else {
index 10f6740..9bf2262 100644 (file)
@@ -23,6 +23,11 @@ MEDIA_EXPORT size_t
 GetDemuxerStreamVideoMemoryLimit(Demuxer::DemuxerTypes demuxer_type,
                                  const VideoDecoderConfig* video_config);
 
+#if BUILDFLAG(IS_TIZEN_TV)
+MEDIA_EXPORT size_t
+UpdateDemuxerStreamVideoMemoryLimit(const VideoDecoderConfig* video_config);
+#endif
+
 // The maximum amount of data (in bytes) a demuxer can keep in memory overall.
 MEDIA_EXPORT size_t GetDemuxerMemoryLimit(Demuxer::DemuxerTypes demuxer_type);
 
@@ -30,6 +35,11 @@ namespace internal {
 
 // These values should not be used directly, they are selected by functions
 // above based on platform capabilities.
+#if BUILDFLAG(IS_TIZEN_TV)
+constexpr size_t kDemuxerStreamVideoMemoryLimitTvUHD = 80 * 1024 * 1024;
+constexpr size_t kDemuxerStreamVideoMemoryLimitTvDefault = 40 * 1024 * 1024;
+constexpr size_t kDemuxerStreamAudioMemoryLimitTvDefault = 8 * 1024 * 1024;
+#endif
 
 // Default audio memory limit: 12MB (5 minutes of 320Kbps content).
 // Medium audio memory limit: 5MB.
diff --git a/media/base/demuxer_memory_limit_product_tv.cc b/media/base/demuxer_memory_limit_product_tv.cc
new file mode 100644 (file)
index 0000000..f480ce3
--- /dev/null
@@ -0,0 +1,46 @@
+// Copyright 2019 Samsung Electronics Inc. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/base/demuxer_memory_limit.h"
+#include "media/base/video_decoder_config.h"
+
+namespace media {
+
+size_t UpdateDemuxerStreamVideoMemoryLimit(
+    const VideoDecoderConfig* video_config) {
+  static size_t demuxer_stream_video_memory_limit =
+      internal::kDemuxerStreamVideoMemoryLimitTvDefault;
+
+  if (!video_config)
+    return demuxer_stream_video_memory_limit;
+
+  const int kFHDWidth = 1920;
+  const int kFHDHeight = 1080;
+  bool isUHDResolution = video_config->coded_size().width() > kFHDWidth ||
+                         video_config->coded_size().height() > kFHDHeight;
+  if (isUHDResolution) {
+    demuxer_stream_video_memory_limit =
+        internal::kDemuxerStreamVideoMemoryLimitTvUHD;
+  }
+
+  return demuxer_stream_video_memory_limit;
+}
+
+size_t GetDemuxerStreamVideoMemoryLimit(
+    Demuxer::DemuxerTypes /*demuxer_type*/,
+    const VideoDecoderConfig* video_config) {
+  return UpdateDemuxerStreamVideoMemoryLimit(video_config);
+}
+
+size_t GetDemuxerStreamAudioMemoryLimit(
+    const AudioDecoderConfig* /*audio_config*/) {
+  return internal::kDemuxerStreamAudioMemoryLimitTvDefault;
+}
+
+size_t GetDemuxerMemoryLimit(Demuxer::DemuxerTypes demuxer_type) {
+  return GetDemuxerStreamAudioMemoryLimit(nullptr) +
+         GetDemuxerStreamVideoMemoryLimit(demuxer_type, nullptr);
+}
+
+}  // namespace media
index 123a941..6c74451 100644 (file)
@@ -1864,6 +1864,10 @@ bool SourceBufferStream::UpdateVideoConfig(const VideoDecoderConfig& config,
   DVLOG(2) << "New video config - index: " << append_config_index_;
   video_configs_.resize(video_configs_.size() + 1);
   video_configs_[append_config_index_] = config;
+#if BUILDFLAG(IS_TIZEN_TV)
+  size_t updated_memory_limit = UpdateDemuxerStreamVideoMemoryLimit(&config);
+  memory_limit_ = std::max(memory_limit_, updated_memory_limit);
+#endif
   return true;
 }