[M108 Aura Migration] Setting demuxer memory limit
[platform/framework/web/chromium-efl.git] / media / base / demuxer_memory_limit_product_tv.cc
1 // Copyright 2019 Samsung Electronics Inc. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "media/base/demuxer_memory_limit.h"
6 #include "media/base/video_decoder_config.h"
7
8 namespace media {
9
10 size_t UpdateDemuxerStreamVideoMemoryLimit(
11     const VideoDecoderConfig* video_config) {
12   static size_t demuxer_stream_video_memory_limit =
13       internal::kDemuxerStreamVideoMemoryLimitTvDefault;
14
15   if (!video_config)
16     return demuxer_stream_video_memory_limit;
17
18   const int kFHDWidth = 1920;
19   const int kFHDHeight = 1080;
20   bool isUHDResolution = video_config->coded_size().width() > kFHDWidth ||
21                          video_config->coded_size().height() > kFHDHeight;
22   if (isUHDResolution) {
23     demuxer_stream_video_memory_limit =
24         internal::kDemuxerStreamVideoMemoryLimitTvUHD;
25   }
26
27   return demuxer_stream_video_memory_limit;
28 }
29
30 size_t GetDemuxerStreamVideoMemoryLimit(
31     Demuxer::DemuxerTypes /*demuxer_type*/,
32     const VideoDecoderConfig* video_config) {
33   return UpdateDemuxerStreamVideoMemoryLimit(video_config);
34 }
35
36 size_t GetDemuxerStreamAudioMemoryLimit(
37     const AudioDecoderConfig* /*audio_config*/) {
38   return internal::kDemuxerStreamAudioMemoryLimitTvDefault;
39 }
40
41 size_t GetDemuxerMemoryLimit(Demuxer::DemuxerTypes demuxer_type) {
42   return GetDemuxerStreamAudioMemoryLimit(nullptr) +
43          GetDemuxerStreamVideoMemoryLimit(demuxer_type, nullptr);
44 }
45
46 }  // namespace media