| OLD | NEW |
| 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/media/media_channel_proxy.h" | 5 #include "chromecast/renderer/media/media_channel_proxy.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chromecast/common/media/cma_messages.h" | 10 #include "chromecast/common/media/cma_messages.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 MediaChannelProxy::~MediaChannelProxy() { | 22 MediaChannelProxy::~MediaChannelProxy() { |
| 23 } | 23 } |
| 24 | 24 |
| 25 void MediaChannelProxy::Open(LoadType load_type) { | 25 void MediaChannelProxy::Open(LoadType load_type) { |
| 26 CHECK(!is_open_); | 26 CHECK(!is_open_); |
| 27 // Renderer side. | 27 // Renderer side. |
| 28 id_ = filter_->CreateChannel(); | 28 id_ = filter_->CreateChannel(); |
| 29 is_open_ = true; | 29 is_open_ = true; |
| 30 | 30 |
| 31 // Browser side. | 31 // Browser side. |
| 32 bool success = Send( | 32 bool success = Send(std::unique_ptr<IPC::Message>( |
| 33 scoped_ptr<IPC::Message>(new CmaHostMsg_CreateMedia(id_, load_type))); | 33 new CmaHostMsg_CreateMedia(id_, load_type))); |
| 34 if (!success) { | 34 if (!success) { |
| 35 is_open_ = false; | 35 is_open_ = false; |
| 36 id_ = 0; | 36 id_ = 0; |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 void MediaChannelProxy::Close() { | 40 void MediaChannelProxy::Close() { |
| 41 if (!is_open_) | 41 if (!is_open_) |
| 42 return; | 42 return; |
| 43 | 43 |
| 44 // Browser side. | 44 // Browser side. |
| 45 Send(scoped_ptr<IPC::Message>(new CmaHostMsg_DestroyMedia(id_))); | 45 Send(std::unique_ptr<IPC::Message>(new CmaHostMsg_DestroyMedia(id_))); |
| 46 | 46 |
| 47 // Renderer side. | 47 // Renderer side. |
| 48 is_open_ = false; | 48 is_open_ = false; |
| 49 filter_->DestroyChannel(id_); | 49 filter_->DestroyChannel(id_); |
| 50 id_ = 0; | 50 id_ = 0; |
| 51 } | 51 } |
| 52 | 52 |
| 53 bool MediaChannelProxy::SetMediaDelegate( | 53 bool MediaChannelProxy::SetMediaDelegate( |
| 54 const CmaMessageFilterProxy::MediaDelegate& media_delegate) { | 54 const CmaMessageFilterProxy::MediaDelegate& media_delegate) { |
| 55 if (!is_open_) | 55 if (!is_open_) |
| 56 return false; | 56 return false; |
| 57 return filter_->SetMediaDelegate(id_, media_delegate); | 57 return filter_->SetMediaDelegate(id_, media_delegate); |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool MediaChannelProxy::SetAudioDelegate( | 60 bool MediaChannelProxy::SetAudioDelegate( |
| 61 const CmaMessageFilterProxy::AudioDelegate& audio_delegate) { | 61 const CmaMessageFilterProxy::AudioDelegate& audio_delegate) { |
| 62 if (!is_open_) | 62 if (!is_open_) |
| 63 return false; | 63 return false; |
| 64 return filter_->SetAudioDelegate(id_, audio_delegate); | 64 return filter_->SetAudioDelegate(id_, audio_delegate); |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool MediaChannelProxy::SetVideoDelegate( | 67 bool MediaChannelProxy::SetVideoDelegate( |
| 68 const CmaMessageFilterProxy::VideoDelegate& video_delegate) { | 68 const CmaMessageFilterProxy::VideoDelegate& video_delegate) { |
| 69 if (!is_open_) | 69 if (!is_open_) |
| 70 return false; | 70 return false; |
| 71 return filter_->SetVideoDelegate(id_, video_delegate); | 71 return filter_->SetVideoDelegate(id_, video_delegate); |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool MediaChannelProxy::Send(scoped_ptr<IPC::Message> message) { | 74 bool MediaChannelProxy::Send(std::unique_ptr<IPC::Message> message) { |
| 75 if (!is_open_) | 75 if (!is_open_) |
| 76 return false; | 76 return false; |
| 77 return filter_->Send(std::move(message)); | 77 return filter_->Send(std::move(message)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace media | 80 } // namespace media |
| 81 } // namespace chromecast | 81 } // namespace chromecast |
| OLD | NEW |