Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: chromecast/renderer/cast_content_renderer_client.cc

Issue 2712983004: Simplify/Cleanup MediaClient (Closed)
Patch Set: Fix test leak Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromecast/renderer/cast_content_renderer_client.h" 5 #include "chromecast/renderer/cast_content_renderer_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chromecast/base/chromecast_switches.h" 13 #include "chromecast/base/chromecast_switches.h"
14 #include "chromecast/common/media/cast_media_client.h"
15 #include "chromecast/crash/cast_crash_keys.h" 14 #include "chromecast/crash/cast_crash_keys.h"
15 #include "chromecast/media/base/media_caps.h"
16 #include "chromecast/media/base/media_codec_support.h"
16 #include "chromecast/media/base/supported_codec_profile_levels_memo.h" 17 #include "chromecast/media/base/supported_codec_profile_levels_memo.h"
18 #include "chromecast/public/media/media_capabilities_shlib.h"
17 #include "chromecast/renderer/cast_render_frame_action_deferrer.h" 19 #include "chromecast/renderer/cast_render_frame_action_deferrer.h"
18 #include "chromecast/renderer/key_systems_cast.h" 20 #include "chromecast/renderer/media/key_systems_cast.h"
19 #include "chromecast/renderer/media/media_caps_observer_impl.h" 21 #include "chromecast/renderer/media/media_caps_observer_impl.h"
20 #include "components/network_hints/renderer/prescient_networking_dispatcher.h" 22 #include "components/network_hints/renderer/prescient_networking_dispatcher.h"
21 #include "content/public/common/content_switches.h" 23 #include "content/public/common/content_switches.h"
22 #include "content/public/common/service_names.mojom.h" 24 #include "content/public/common/service_names.mojom.h"
23 #include "content/public/renderer/render_frame.h" 25 #include "content/public/renderer/render_frame.h"
24 #include "content/public/renderer/render_thread.h" 26 #include "content/public/renderer/render_thread.h"
25 #include "content/public/renderer/render_view.h" 27 #include "content/public/renderer/render_view.h"
26 #include "media/base/media.h" 28 #include "media/base/media.h"
27 #include "services/service_manager/public/cpp/connector.h" 29 #include "services/service_manager/public/cpp/connector.h"
28 #include "third_party/WebKit/public/platform/WebColor.h" 30 #include "third_party/WebKit/public/platform/WebColor.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // Register as observer for media capabilities 73 // Register as observer for media capabilities
72 content::RenderThread* thread = content::RenderThread::Get(); 74 content::RenderThread* thread = content::RenderThread::Get();
73 media::mojom::MediaCapsPtr media_caps; 75 media::mojom::MediaCapsPtr media_caps;
74 thread->GetConnector()->BindInterface(content::mojom::kBrowserServiceName, 76 thread->GetConnector()->BindInterface(content::mojom::kBrowserServiceName,
75 &media_caps); 77 &media_caps);
76 media::mojom::MediaCapsObserverPtr proxy; 78 media::mojom::MediaCapsObserverPtr proxy;
77 media_caps_observer_.reset( 79 media_caps_observer_.reset(
78 new media::MediaCapsObserverImpl(&proxy, supported_profiles_.get())); 80 new media::MediaCapsObserverImpl(&proxy, supported_profiles_.get()));
79 media_caps->AddObserver(std::move(proxy)); 81 media_caps->AddObserver(std::move(proxy));
80 82
81 chromecast::media::CastMediaClient::Initialize(supported_profiles_.get());
82
83 prescient_networking_dispatcher_.reset( 83 prescient_networking_dispatcher_.reset(
84 new network_hints::PrescientNetworkingDispatcher()); 84 new network_hints::PrescientNetworkingDispatcher());
85 85
86 std::string last_launched_app = 86 std::string last_launched_app =
87 command_line->GetSwitchValueNative(switches::kLastLaunchedApp); 87 command_line->GetSwitchValueNative(switches::kLastLaunchedApp);
88 if (!last_launched_app.empty()) 88 if (!last_launched_app.empty())
89 base::debug::SetCrashKeyValue(crash_keys::kLastApp, last_launched_app); 89 base::debug::SetCrashKeyValue(crash_keys::kLastApp, last_launched_app);
90 90
91 std::string previous_app = 91 std::string previous_app =
92 command_line->GetSwitchValueNative(switches::kPreviousApp); 92 command_line->GetSwitchValueNative(switches::kPreviousApp);
(...skipping 10 matching lines...) Expand all
103 103
104 // Disable application cache as Chromecast doesn't support off-line 104 // Disable application cache as Chromecast doesn't support off-line
105 // application running. 105 // application running.
106 webview->settings()->setOfflineWebApplicationCacheEnabled(false); 106 webview->settings()->setOfflineWebApplicationCacheEnabled(false);
107 } 107 }
108 } 108 }
109 109
110 void CastContentRendererClient::AddSupportedKeySystems( 110 void CastContentRendererClient::AddSupportedKeySystems(
111 std::vector<std::unique_ptr<::media::KeySystemProperties>>* 111 std::vector<std::unique_ptr<::media::KeySystemProperties>>*
112 key_systems_properties) { 112 key_systems_properties) {
113 AddChromecastKeySystems(key_systems_properties, 113 media::AddChromecastKeySystems(key_systems_properties,
114 false /* enable_persistent_license_support */, 114 false /* enable_persistent_license_support */,
115 false /* force_software_crypto */); 115 false /* force_software_crypto */);
116 }
117
118 bool CastContentRendererClient::IsSupportedAudioConfig(
119 const ::media::AudioConfig& config) {
120 #if defined(OS_ANDROID)
121 // TODO(sanfin): Implement this for Android.
122 return true;
123 #else
124 media::AudioCodec codec = media::ToCastAudioCodec(config.codec);
125 // Cast platform implements software decoding of Opus and FLAC, so only PCM
126 // support is necessary in order to support Opus and FLAC.
127 if (codec == media::kCodecOpus || codec == media::kCodecFLAC)
128 codec = media::kCodecPCM;
129
130 // If HDMI sink supports AC3/EAC3 codecs then we don't need the vendor backend
131 // to support these codec directly.
132 if (codec == media::kCodecEAC3 &&
133 media::MediaCapabilities::HdmiSinkSupportsEAC3())
134 return true;
135 if (codec == media::kCodecAC3 &&
136 media::MediaCapabilities::HdmiSinkSupportsAC3())
137 return true;
138
139 media::AudioConfig cast_audio_config;
140 cast_audio_config.codec = codec;
141 return media::MediaCapabilitiesShlib::IsSupportedAudioConfig(
142 cast_audio_config);
143 #endif
144 }
145
146 bool CastContentRendererClient::IsSupportedVideoConfig(
147 const ::media::VideoConfig& config) {
148 // TODO(servolk): make use of eotf.
149 #if defined(OS_ANDROID)
150 return supported_profiles_->IsSupportedVideoConfig(
151 media::ToCastVideoCodec(config.codec, config.profile),
152 media::ToCastVideoProfile(config.profile), config.level);
153 #else
154 return media::MediaCapabilitiesShlib::IsSupportedVideoConfig(
155 media::ToCastVideoCodec(config.codec, config.profile),
156 media::ToCastVideoProfile(config.profile), config.level);
157 #endif
116 } 158 }
117 159
118 blink::WebPrescientNetworking* 160 blink::WebPrescientNetworking*
119 CastContentRendererClient::GetPrescientNetworking() { 161 CastContentRendererClient::GetPrescientNetworking() {
120 return prescient_networking_dispatcher_.get(); 162 return prescient_networking_dispatcher_.get();
121 } 163 }
122 164
123 void CastContentRendererClient::DeferMediaLoad( 165 void CastContentRendererClient::DeferMediaLoad(
124 content::RenderFrame* render_frame, 166 content::RenderFrame* render_frame,
125 bool render_frame_has_played_media_before, 167 bool render_frame_has_played_media_before,
(...skipping 23 matching lines...) Expand all
149 } 191 }
150 192
151 void CastContentRendererClient:: 193 void CastContentRendererClient::
152 SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() { 194 SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() {
153 // Settings for ATV (Android defaults are not what we want). 195 // Settings for ATV (Android defaults are not what we want).
154 blink::WebRuntimeFeatures::enableMediaControlsOverlayPlayButton(false); 196 blink::WebRuntimeFeatures::enableMediaControlsOverlayPlayButton(false);
155 } 197 }
156 198
157 } // namespace shell 199 } // namespace shell
158 } // namespace chromecast 200 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/renderer/cast_content_renderer_client.h ('k') | chromecast/renderer/key_systems_cast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698