| 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/video_pipeline_proxy.h" | 5 #include "chromecast/renderer/media/video_pipeline_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 // Notify the other side (browser process) of some activity on the video pipe. | 48 // Notify the other side (browser process) of some activity on the video pipe. |
| 49 // TODO(erickung): either send an IPC message or write a byte on the | 49 // TODO(erickung): either send an IPC message or write a byte on the |
| 50 // SyncSocket. | 50 // SyncSocket. |
| 51 void NotifyPipeWrite(); | 51 void NotifyPipeWrite(); |
| 52 | 52 |
| 53 // These functions are almost a one to one correspondence with VideoPipeline | 53 // These functions are almost a one to one correspondence with VideoPipeline |
| 54 // but this is an internal class and there is no reason to derive from | 54 // but this is an internal class and there is no reason to derive from |
| 55 // VideoPipeline. | 55 // VideoPipeline. |
| 56 void SetClient(const base::Closure& pipe_read_cb, | 56 void SetClient(const base::Closure& pipe_read_cb, |
| 57 const VideoPipelineClient& client); | 57 const RendererVideoPipelineClient& client); |
| 58 void CreateAvPipe(const SharedMemCB& shared_mem_cb); | 58 void CreateAvPipe(const SharedMemCB& shared_mem_cb); |
| 59 void Initialize(const std::vector<::media::VideoDecoderConfig>& configs, | 59 void Initialize(const std::vector<::media::VideoDecoderConfig>& configs, |
| 60 const ::media::PipelineStatusCB& status_cb); | 60 const ::media::PipelineStatusCB& status_cb); |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 void Shutdown(); | 63 void Shutdown(); |
| 64 | 64 |
| 65 // Callbacks for CmaMessageFilterHost::VideoDelegate. | 65 // Callbacks for CmaMessageFilterHost::VideoDelegate. |
| 66 void OnAvPipeCreated(bool status, | 66 void OnAvPipeCreated(bool status, |
| 67 base::SharedMemoryHandle shared_mem_handle, | 67 base::SharedMemoryHandle shared_mem_handle, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // TODO(damienv): An alternative way would be to use a dedicated socket for | 112 // TODO(damienv): An alternative way would be to use a dedicated socket for |
| 113 // this event. | 113 // this event. |
| 114 bool success = media_channel_proxy_->Send(scoped_ptr<IPC::Message>( | 114 bool success = media_channel_proxy_->Send(scoped_ptr<IPC::Message>( |
| 115 new CmaHostMsg_NotifyPipeWrite(media_channel_proxy_->GetId(), | 115 new CmaHostMsg_NotifyPipeWrite(media_channel_proxy_->GetId(), |
| 116 kVideoTrackId))); | 116 kVideoTrackId))); |
| 117 VLOG_IF(4, !success) << "Sending msg failed"; | 117 VLOG_IF(4, !success) << "Sending msg failed"; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void VideoPipelineProxyInternal::SetClient( | 120 void VideoPipelineProxyInternal::SetClient( |
| 121 const base::Closure& pipe_read_cb, | 121 const base::Closure& pipe_read_cb, |
| 122 const VideoPipelineClient& video_client) { | 122 const RendererVideoPipelineClient& video_client) { |
| 123 DCHECK(thread_checker_.CalledOnValidThread()); | 123 DCHECK(thread_checker_.CalledOnValidThread()); |
| 124 | 124 |
| 125 CmaMessageFilterProxy::VideoDelegate delegate; | 125 CmaMessageFilterProxy::VideoDelegate delegate; |
| 126 delegate.av_pipe_cb = | 126 delegate.av_pipe_cb = |
| 127 base::Bind(&VideoPipelineProxyInternal::OnAvPipeCreated, | 127 base::Bind(&VideoPipelineProxyInternal::OnAvPipeCreated, |
| 128 base::Unretained(this)); | 128 base::Unretained(this)); |
| 129 delegate.state_changed_cb = | 129 delegate.state_changed_cb = |
| 130 base::Bind(&VideoPipelineProxyInternal::OnStateChanged, | 130 base::Bind(&VideoPipelineProxyInternal::OnStateChanged, |
| 131 base::Unretained(this)); | 131 base::Unretained(this)); |
| 132 delegate.pipe_read_cb = pipe_read_cb; | 132 delegate.pipe_read_cb = pipe_read_cb; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 207 |
| 208 VideoPipelineProxy::~VideoPipelineProxy() { | 208 VideoPipelineProxy::~VideoPipelineProxy() { |
| 209 DCHECK(thread_checker_.CalledOnValidThread()); | 209 DCHECK(thread_checker_.CalledOnValidThread()); |
| 210 // Release the underlying object on the right thread. | 210 // Release the underlying object on the right thread. |
| 211 io_task_runner_->PostTask( | 211 io_task_runner_->PostTask( |
| 212 FROM_HERE, | 212 FROM_HERE, |
| 213 base::Bind(&VideoPipelineProxyInternal::Release, base::Passed(&proxy_))); | 213 base::Bind(&VideoPipelineProxyInternal::Release, base::Passed(&proxy_))); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void VideoPipelineProxy::SetClient( | 216 void VideoPipelineProxy::SetClient( |
| 217 const VideoPipelineClient& video_client) { | 217 const RendererVideoPipelineClient& video_client) { |
| 218 DCHECK(thread_checker_.CalledOnValidThread()); | 218 DCHECK(thread_checker_.CalledOnValidThread()); |
| 219 base::Closure pipe_read_cb = | 219 base::Closure pipe_read_cb = |
| 220 ::media::BindToCurrentLoop( | 220 ::media::BindToCurrentLoop( |
| 221 base::Bind(&VideoPipelineProxy::OnPipeRead, weak_this_)); | 221 base::Bind(&VideoPipelineProxy::OnPipeRead, weak_this_)); |
| 222 FORWARD_ON_IO_THREAD(SetClient, pipe_read_cb, video_client); | 222 FORWARD_ON_IO_THREAD(SetClient, pipe_read_cb, video_client); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void VideoPipelineProxy::Initialize( | 225 void VideoPipelineProxy::Initialize( |
| 226 const std::vector<::media::VideoDecoderConfig>& configs, | 226 const std::vector<::media::VideoDecoderConfig>& configs, |
| 227 scoped_ptr<CodedFrameProvider> frame_provider, | 227 scoped_ptr<CodedFrameProvider> frame_provider, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 FORWARD_ON_IO_THREAD(NotifyPipeWrite); | 287 FORWARD_ON_IO_THREAD(NotifyPipeWrite); |
| 288 } | 288 } |
| 289 | 289 |
| 290 void VideoPipelineProxy::OnPipeRead() { | 290 void VideoPipelineProxy::OnPipeRead() { |
| 291 DCHECK(thread_checker_.CalledOnValidThread()); | 291 DCHECK(thread_checker_.CalledOnValidThread()); |
| 292 if (video_streamer_) | 292 if (video_streamer_) |
| 293 video_streamer_->OnFifoReadEvent(); | 293 video_streamer_->OnFifoReadEvent(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // namespace media | 296 } // namespace media |
| 297 } // namespace chromecast | 297 } // namespace chromecast |
| OLD | NEW |