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

Unified Diff: chromecast/renderer/media/media_channel_proxy.cc

Issue 814403002: [Chromecast] Add CmaMediaRendererFactory and IPC proxy components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « chromecast/renderer/media/media_channel_proxy.h ('k') | chromecast/renderer/media/media_pipeline_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromecast/renderer/media/media_channel_proxy.cc
diff --git a/chromecast/renderer/media/media_channel_proxy.cc b/chromecast/renderer/media/media_channel_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2ef1d251d9255843c77e16b4287c916797f578ef
--- /dev/null
+++ b/chromecast/renderer/media/media_channel_proxy.cc
@@ -0,0 +1,79 @@
+// Copyright 2014 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.
+
+#include "chromecast/renderer/media/media_channel_proxy.h"
+
+#include "base/logging.h"
+#include "chromecast/common/media/cma_messages.h"
+
+namespace chromecast {
+namespace media {
+
+MediaChannelProxy::MediaChannelProxy()
+ : is_open_(false),
+ id_(0) {
+ filter_ = CmaMessageFilterProxy::Get();
+ DCHECK(filter_.get());
+}
+
+MediaChannelProxy::~MediaChannelProxy() {
+}
+
+void MediaChannelProxy::Open(LoadType load_type) {
+ CHECK(!is_open_);
+ // Renderer side.
+ id_ = filter_->CreateChannel();
+ is_open_ = true;
+
+ // Browser side.
+ bool success = Send(
+ scoped_ptr<IPC::Message>(new CmaHostMsg_CreateMedia(id_, load_type)));
+ if (!success) {
+ is_open_ = false;
+ id_ = 0;
+ }
+}
+
+void MediaChannelProxy::Close() {
+ if (!is_open_)
+ return;
+
+ // Browser side.
+ Send(scoped_ptr<IPC::Message>(new CmaHostMsg_DestroyMedia(id_)));
+
+ // Renderer side.
+ is_open_ = false;
+ filter_->DestroyChannel(id_);
+ id_ = 0;
+}
+
+bool MediaChannelProxy::SetMediaDelegate(
+ const CmaMessageFilterProxy::MediaDelegate& media_delegate) {
+ if (!is_open_)
+ return false;
+ return filter_->SetMediaDelegate(id_, media_delegate);
+}
+
+bool MediaChannelProxy::SetAudioDelegate(
+ const CmaMessageFilterProxy::AudioDelegate& audio_delegate) {
+ if (!is_open_)
+ return false;
+ return filter_->SetAudioDelegate(id_, audio_delegate);
+}
+
+bool MediaChannelProxy::SetVideoDelegate(
+ const CmaMessageFilterProxy::VideoDelegate& video_delegate) {
+ if (!is_open_)
+ return false;
+ return filter_->SetVideoDelegate(id_, video_delegate);
+}
+
+bool MediaChannelProxy::Send(scoped_ptr<IPC::Message> message) {
+ if (!is_open_)
+ return false;
+ return filter_->Send(message.Pass());
+}
+
+} // namespace media
+} // namespace chromecast
« no previous file with comments | « chromecast/renderer/media/media_channel_proxy.h ('k') | chromecast/renderer/media/media_pipeline_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698