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 <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
11 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
12 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
13 #include "chromecast/common/media/cma_ipc_common.h" | 15 #include "chromecast/common/media/cma_ipc_common.h" |
14 #include "chromecast/common/media/cma_messages.h" | 16 #include "chromecast/common/media/cma_messages.h" |
15 #include "chromecast/common/media/shared_memory_chunk.h" | 17 #include "chromecast/common/media/shared_memory_chunk.h" |
16 #include "chromecast/media/cma/base/buffering_defs.h" | 18 #include "chromecast/media/cma/base/buffering_defs.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 base::Bind(&VideoPipelineProxy::OnPipeRead, weak_this_)); | 224 base::Bind(&VideoPipelineProxy::OnPipeRead, weak_this_)); |
223 FORWARD_ON_IO_THREAD(SetClient, pipe_read_cb, video_client); | 225 FORWARD_ON_IO_THREAD(SetClient, pipe_read_cb, video_client); |
224 } | 226 } |
225 | 227 |
226 void VideoPipelineProxy::Initialize( | 228 void VideoPipelineProxy::Initialize( |
227 const std::vector<::media::VideoDecoderConfig>& configs, | 229 const std::vector<::media::VideoDecoderConfig>& configs, |
228 scoped_ptr<CodedFrameProvider> frame_provider, | 230 scoped_ptr<CodedFrameProvider> frame_provider, |
229 const ::media::PipelineStatusCB& status_cb) { | 231 const ::media::PipelineStatusCB& status_cb) { |
230 CMALOG(kLogControl) << "VideoPipelineProxy::Initialize"; | 232 CMALOG(kLogControl) << "VideoPipelineProxy::Initialize"; |
231 DCHECK(thread_checker_.CalledOnValidThread()); | 233 DCHECK(thread_checker_.CalledOnValidThread()); |
232 video_streamer_->SetCodedFrameProvider(frame_provider.Pass()); | 234 video_streamer_->SetCodedFrameProvider(std::move(frame_provider)); |
233 | 235 |
234 VideoPipelineProxyInternal::SharedMemCB shared_mem_cb = | 236 VideoPipelineProxyInternal::SharedMemCB shared_mem_cb = |
235 ::media::BindToCurrentLoop(base::Bind( | 237 ::media::BindToCurrentLoop(base::Bind( |
236 &VideoPipelineProxy::OnAvPipeCreated, weak_this_, | 238 &VideoPipelineProxy::OnAvPipeCreated, weak_this_, |
237 configs, status_cb)); | 239 configs, status_cb)); |
238 FORWARD_ON_IO_THREAD(CreateAvPipe, shared_mem_cb); | 240 FORWARD_ON_IO_THREAD(CreateAvPipe, shared_mem_cb); |
239 } | 241 } |
240 | 242 |
241 void VideoPipelineProxy::OnAvPipeCreated( | 243 void VideoPipelineProxy::OnAvPipeCreated( |
242 const std::vector<::media::VideoDecoderConfig>& configs, | 244 const std::vector<::media::VideoDecoderConfig>& configs, |
243 const ::media::PipelineStatusCB& status_cb, | 245 const ::media::PipelineStatusCB& status_cb, |
244 scoped_ptr<base::SharedMemory> shared_memory) { | 246 scoped_ptr<base::SharedMemory> shared_memory) { |
245 CMALOG(kLogControl) << "VideoPipelineProxy::OnAvPipeCreated"; | 247 CMALOG(kLogControl) << "VideoPipelineProxy::OnAvPipeCreated"; |
246 DCHECK(thread_checker_.CalledOnValidThread()); | 248 DCHECK(thread_checker_.CalledOnValidThread()); |
247 if (!shared_memory || | 249 if (!shared_memory || |
248 !shared_memory->Map(kAppVideoBufferSize)) { | 250 !shared_memory->Map(kAppVideoBufferSize)) { |
249 status_cb.Run(::media::PIPELINE_ERROR_INITIALIZATION_FAILED); | 251 status_cb.Run(::media::PIPELINE_ERROR_INITIALIZATION_FAILED); |
250 return; | 252 return; |
251 } | 253 } |
252 CHECK(shared_memory->memory()); | 254 CHECK(shared_memory->memory()); |
253 | 255 |
254 scoped_ptr<MediaMemoryChunk> shared_memory_chunk( | 256 scoped_ptr<MediaMemoryChunk> shared_memory_chunk( |
255 new SharedMemoryChunk(shared_memory.Pass(), kAppVideoBufferSize)); | 257 new SharedMemoryChunk(std::move(shared_memory), kAppVideoBufferSize)); |
256 scoped_ptr<MediaMessageFifo> video_pipe( | 258 scoped_ptr<MediaMessageFifo> video_pipe( |
257 new MediaMessageFifo(shared_memory_chunk.Pass(), false)); | 259 new MediaMessageFifo(std::move(shared_memory_chunk), false)); |
258 video_pipe->ObserveWriteActivity( | 260 video_pipe->ObserveWriteActivity( |
259 base::Bind(&VideoPipelineProxy::OnPipeWrite, weak_this_)); | 261 base::Bind(&VideoPipelineProxy::OnPipeWrite, weak_this_)); |
260 | 262 |
261 video_streamer_->SetMediaMessageFifo(video_pipe.Pass()); | 263 video_streamer_->SetMediaMessageFifo(std::move(video_pipe)); |
262 | 264 |
263 // Now proceed to the decoder/renderer initialization. | 265 // Now proceed to the decoder/renderer initialization. |
264 FORWARD_ON_IO_THREAD(Initialize, configs, status_cb); | 266 FORWARD_ON_IO_THREAD(Initialize, configs, status_cb); |
265 } | 267 } |
266 | 268 |
267 void VideoPipelineProxy::StartFeeding() { | 269 void VideoPipelineProxy::StartFeeding() { |
268 DCHECK(thread_checker_.CalledOnValidThread()); | 270 DCHECK(thread_checker_.CalledOnValidThread()); |
269 DCHECK(video_streamer_); | 271 DCHECK(video_streamer_); |
270 video_streamer_->Start(); | 272 video_streamer_->Start(); |
271 } | 273 } |
(...skipping 17 matching lines...) Expand all Loading... |
289 } | 291 } |
290 | 292 |
291 void VideoPipelineProxy::OnPipeRead() { | 293 void VideoPipelineProxy::OnPipeRead() { |
292 DCHECK(thread_checker_.CalledOnValidThread()); | 294 DCHECK(thread_checker_.CalledOnValidThread()); |
293 if (video_streamer_) | 295 if (video_streamer_) |
294 video_streamer_->OnFifoReadEvent(); | 296 video_streamer_->OnFifoReadEvent(); |
295 } | 297 } |
296 | 298 |
297 } // namespace media | 299 } // namespace media |
298 } // namespace chromecast | 300 } // namespace chromecast |
OLD | NEW |