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

Unified Diff: chromecast/common/media/cast_media_client.cc

Issue 2156193003: [Chromecast] Add a custom CastMediaClient for Chromecast (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@codecs
Patch Set: Mark MediaCapShlib::IsSupportedVideoConfig as weak symbol Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chromecast/common/media/cast_media_client.cc
diff --git a/chromecast/common/media/cast_media_client.cc b/chromecast/common/media/cast_media_client.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a8ba24a3f323c6f4196ba04d6f12067c20062b58
--- /dev/null
+++ b/chromecast/common/media/cast_media_client.cc
@@ -0,0 +1,71 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// TODO(servolk): Is there a better way to override just IsSupportedVideoConfig
+// without duplicating content::RenderMediaClient implementation?
+// For now define MEDIA_IMPLEMENTATION to be able to access the default media
+// client via ::media::GetMediaClient.
+#define MEDIA_IMPLEMENTATION
halliwell 2016/07/27 14:23:17 does this break component build? Also, it's a pre
servolk 2016/07/27 18:56:34 The most recent trybot runs were all green, includ
halliwell 2016/07/27 19:58:48 There is no chromium trybot for component build of
servolk 2016/07/27 21:11:38 Ok, I'll try a component build locally.
+
+#include "chromecast/common/media/cast_media_client.h"
+
+#include "base/lazy_instance.h"
+#include "chromecast/media/base/media_codec_support.h"
+#include "chromecast/public/media_codec_support_shlib.h"
+
+namespace chromecast {
+namespace media {
+
+static base::LazyInstance<CastMediaClient>::Leaky g_cast_media_client =
+ LAZY_INSTANCE_INITIALIZER;
+
+void CastMediaClient::Initialize() {
+ g_cast_media_client.Get();
+}
+
+CastMediaClient::CastMediaClient() {
+ content_media_client_ = ::media::GetMediaClient();
+ // Ensure that CastMediaClient gets initialized after the
+ // content::RenderMediaClient.
+ DCHECK(content_media_client_);
+ ::media::SetMediaClient(this);
+}
+
+CastMediaClient::~CastMediaClient() {}
+
+void CastMediaClient::AddKeySystemsInfoForUMA(
+ std::vector<::media::KeySystemInfoForUMA>* key_systems_info_for_uma) {
+ content_media_client_->AddKeySystemsInfoForUMA(key_systems_info_for_uma);
+}
+
+bool CastMediaClient::IsKeySystemsUpdateNeeded() {
+ return content_media_client_->IsKeySystemsUpdateNeeded();
+}
+
+void CastMediaClient::AddSupportedKeySystems(
+ std::vector<std::unique_ptr<::media::KeySystemProperties>>*
+ key_systems_properties) {
+ content_media_client_->AddSupportedKeySystems(key_systems_properties);
+}
+
+void CastMediaClient::RecordRapporURL(const std::string& metric,
+ const GURL& url) {
+ content_media_client_->RecordRapporURL(metric, url);
+}
+
+// static
+bool CastMediaClient::IsSupportedVideoConfig(::media::VideoCodec codec,
+ ::media::VideoCodecProfile profile,
+ int level) {
+ if (MediaCapabilitiesShlib::IsSupportedVideoConfig) {
+ return MediaCapabilitiesShlib::IsSupportedVideoConfig(
+ ToCastVideoCodec(codec), ToCastVideoProfile(profile), level);
+ }
+ LOG(WARNING) << __FUNCTION__
+ << " using default MediaClient::IsSupportedVideoConfig";
+ return content_media_client_->IsSupportedVideoConfig(codec, profile, level);
+}
+
+} // namespace media
+} // namespace chromecast

Powered by Google App Engine
This is Rietveld 408576698