OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. 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 "chromecast/common/media/cast_media_client.h" | |
6 | |
7 #include "chromecast/media/base/media_caps.h" | |
8 #include "chromecast/media/base/media_codec_support.h" | |
9 #include "chromecast/media/base/supported_codec_profile_levels_memo.h" | |
10 #include "chromecast/public/media/media_capabilities_shlib.h" | |
11 | |
12 // TODO(servolk): Is there a better way to override just IsSupportedVideoConfig | |
13 // without duplicating content::RenderMediaClient implementation? | |
14 // For now use this to allow access to the ::media::GetMediaClient. | |
15 namespace media { | |
16 MEDIA_EXPORT MediaClient* GetMediaClient(); | |
17 } | |
18 | |
19 namespace chromecast { | |
20 namespace media { | |
21 | |
22 void CastMediaClient::Initialize( | |
23 SupportedCodecProfileLevelsMemo* supported_profiles) { | |
24 ::media::SetMediaClient( | |
25 new CastMediaClient(::media::GetMediaClient(), supported_profiles)); | |
26 } | |
27 | |
28 CastMediaClient::CastMediaClient( | |
29 ::media::MediaClient* content_media_client, | |
30 SupportedCodecProfileLevelsMemo* supported_profiles) { | |
31 // Ensure that CastMediaClient gets initialized after the | |
32 // content::RenderMediaClient. | |
33 DCHECK(content_media_client); | |
34 content_media_client_ = content_media_client; | |
35 supported_profiles_ = supported_profiles; | |
36 } | |
37 | |
38 CastMediaClient::~CastMediaClient() {} | |
39 | |
40 void CastMediaClient::AddKeySystemsInfoForUMA( | |
41 std::vector<::media::KeySystemInfoForUMA>* key_systems_info_for_uma) { | |
42 content_media_client_->AddKeySystemsInfoForUMA(key_systems_info_for_uma); | |
43 } | |
44 | |
45 bool CastMediaClient::IsKeySystemsUpdateNeeded() { | |
46 return content_media_client_->IsKeySystemsUpdateNeeded(); | |
47 } | |
48 | |
49 void CastMediaClient::AddSupportedKeySystems( | |
50 std::vector<std::unique_ptr<::media::KeySystemProperties>>* | |
51 key_systems_properties) { | |
52 content_media_client_->AddSupportedKeySystems(key_systems_properties); | |
53 } | |
54 | |
55 void CastMediaClient::RecordRapporURL(const std::string& metric, | |
56 const GURL& url) { | |
57 content_media_client_->RecordRapporURL(metric, url); | |
58 } | |
59 | |
60 // static | |
61 bool CastMediaClient::IsSupportedVideoConfig( | |
62 const ::media::VideoConfig& config) { | |
63 // TODO(servolk): make use of eotf. | |
64 #if defined(OS_ANDROID) | |
65 return supported_profiles_->IsSupportedVideoConfig( | |
66 ToCastVideoCodec(config.codec, config.profile), | |
67 ToCastVideoProfile(config.profile), config.level); | |
68 #else | |
69 return MediaCapabilitiesShlib::IsSupportedVideoConfig( | |
70 ToCastVideoCodec(config.codec, config.profile), | |
71 ToCastVideoProfile(config.profile), config.level); | |
72 #endif | |
73 } | |
74 | |
75 bool CastMediaClient::IsSupportedAudioConfig( | |
76 const ::media::AudioConfig& config) { | |
77 #if defined(OS_ANDROID) | |
78 // TODO(sanfin): Implement this for Android. | |
79 return true; | |
80 #else | |
81 AudioCodec codec = ToCastAudioCodec(config.codec); | |
82 // Cast platform implements software decoding of Opus and FLAC, so only PCM | |
83 // support is necessary in order to support Opus and FLAC. | |
84 if (codec == kCodecOpus || codec == kCodecFLAC) | |
85 codec = kCodecPCM; | |
86 | |
87 // If HDMI sink supports AC3/EAC3 codecs then we don't need the vendor backend | |
88 // to support these codec directly. | |
89 if (codec == kCodecEAC3 && MediaCapabilities::HdmiSinkSupportsEAC3()) | |
90 return true; | |
91 if (codec == kCodecAC3 && MediaCapabilities::HdmiSinkSupportsAC3()) | |
92 return true; | |
93 | |
94 AudioConfig cast_audio_config; | |
95 cast_audio_config.codec = codec; | |
96 return MediaCapabilitiesShlib::IsSupportedAudioConfig(cast_audio_config); | |
97 #endif | |
98 } | |
99 | |
100 } // namespace media | |
101 } // namespace chromecast | |
OLD | NEW |