Bump libaddressinput version.
[chromium-blink-merge.git] / chromecast / renderer / media / media_channel_proxy.cc
blob2ef1d251d9255843c77e16b4287c916797f578ef
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
3 // found in the LICENSE file.
5 #include "chromecast/renderer/media/media_channel_proxy.h"
7 #include "base/logging.h"
8 #include "chromecast/common/media/cma_messages.h"
10 namespace chromecast {
11 namespace media {
13 MediaChannelProxy::MediaChannelProxy()
14 : is_open_(false),
15 id_(0) {
16 filter_ = CmaMessageFilterProxy::Get();
17 DCHECK(filter_.get());
20 MediaChannelProxy::~MediaChannelProxy() {
23 void MediaChannelProxy::Open(LoadType load_type) {
24 CHECK(!is_open_);
25 // Renderer side.
26 id_ = filter_->CreateChannel();
27 is_open_ = true;
29 // Browser side.
30 bool success = Send(
31 scoped_ptr<IPC::Message>(new CmaHostMsg_CreateMedia(id_, load_type)));
32 if (!success) {
33 is_open_ = false;
34 id_ = 0;
38 void MediaChannelProxy::Close() {
39 if (!is_open_)
40 return;
42 // Browser side.
43 Send(scoped_ptr<IPC::Message>(new CmaHostMsg_DestroyMedia(id_)));
45 // Renderer side.
46 is_open_ = false;
47 filter_->DestroyChannel(id_);
48 id_ = 0;
51 bool MediaChannelProxy::SetMediaDelegate(
52 const CmaMessageFilterProxy::MediaDelegate& media_delegate) {
53 if (!is_open_)
54 return false;
55 return filter_->SetMediaDelegate(id_, media_delegate);
58 bool MediaChannelProxy::SetAudioDelegate(
59 const CmaMessageFilterProxy::AudioDelegate& audio_delegate) {
60 if (!is_open_)
61 return false;
62 return filter_->SetAudioDelegate(id_, audio_delegate);
65 bool MediaChannelProxy::SetVideoDelegate(
66 const CmaMessageFilterProxy::VideoDelegate& video_delegate) {
67 if (!is_open_)
68 return false;
69 return filter_->SetVideoDelegate(id_, video_delegate);
72 bool MediaChannelProxy::Send(scoped_ptr<IPC::Message> message) {
73 if (!is_open_)
74 return false;
75 return filter_->Send(message.Pass());
78 } // namespace media
79 } // namespace chromecast