Chromium Code Reviews| Index: media/video/capture/video_capture_proxy.cc |
| diff --git a/media/video/capture/video_capture_proxy.cc b/media/video/capture/video_capture_proxy.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..98962d1fb12e21ca9e87768c60f6968b75affa7b |
| --- /dev/null |
| +++ b/media/video/capture/video_capture_proxy.cc |
| @@ -0,0 +1,136 @@ |
| +// Copyright (c) 2011 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 "media/video/capture/video_capture_proxy.h" |
| + |
| +#include "base/message_loop_proxy.h" |
| + |
| +namespace { |
| + |
| +// Called on VC thread: extracts the state out of the VideoCapture, and |
| +// serialize it into a VideoCaptureState. |
| +media::VideoCaptureHandlerProxy::VideoCaptureState GetState( |
| + media::VideoCapture* capture) { |
| + media::VideoCaptureHandlerProxy::VideoCaptureState state; |
| + state.started = capture->CaptureStarted(); |
| + state.width = capture->CaptureWidth(); |
| + state.height = capture->CaptureHeight(); |
| + state.frame_rate = capture->CaptureFrameRate(); |
| + return state; |
| +} |
| + |
| +} // anonymous namespace |
| + |
| +namespace media { |
| + |
| +VideoCaptureHandlerProxy::VideoCaptureHandlerProxy( |
| + VideoCapture::EventHandler* proxied) |
| + : proxied_(proxied), |
| + main_message_loop_(base::MessageLoopProxy::CreateForCurrentThread()) { |
|
wjia(left Chromium)
2011/08/02 00:10:39
how about passing in main_message_loop as an argum
piman
2011/08/02 01:08:55
I did that, if that is helpful to create this clas
|
| +} |
| + |
| +VideoCaptureHandlerProxy::~VideoCaptureHandlerProxy() { |
| +} |
| + |
| +void VideoCaptureHandlerProxy::OnStarted(VideoCapture* capture) { |
| + main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| + this, |
|
wjia(left Chromium)
2011/08/02 00:10:39
indentation.
piman
2011/08/02 01:08:55
Done (here and below).
|
| + &VideoCaptureHandlerProxy::OnStartedOnMainThread, |
| + capture, |
| + GetState(capture))); |
| +} |
| + |
| +void VideoCaptureHandlerProxy::OnStopped(VideoCapture* capture) { |
| + main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| + this, |
| + &VideoCaptureHandlerProxy::OnStoppedOnMainThread, |
| + capture, |
| + GetState(capture))); |
| +} |
| + |
| +void VideoCaptureHandlerProxy::OnPaused(VideoCapture* capture) { |
| + main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| + this, |
| + &VideoCaptureHandlerProxy::OnPausedOnMainThread, |
| + capture, |
| + GetState(capture))); |
| +} |
| + |
| +void VideoCaptureHandlerProxy::OnError(VideoCapture* capture, int error_code) { |
| + main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| + this, |
| + &VideoCaptureHandlerProxy::OnErrorOnMainThread, |
| + capture, |
| + GetState(capture), |
| + error_code)); |
| +} |
| + |
| +void VideoCaptureHandlerProxy::OnBufferReady( |
| + VideoCapture* capture, |
| + scoped_refptr<VideoCapture::VideoFrameBuffer> buffer) { |
| + main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| + this, |
| + &VideoCaptureHandlerProxy::OnBufferReadyOnMainThread, |
| + capture, |
| + GetState(capture), |
| + buffer)); |
| +} |
| + |
| +void VideoCaptureHandlerProxy::OnDeviceInfoReceived( |
| + VideoCapture* capture, |
| + const VideoCaptureParams& device_info) { |
| + main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| + this, |
| + &VideoCaptureHandlerProxy::OnDeviceInfoReceivedOnMainThread, |
| + capture, |
| + GetState(capture), |
| + device_info)); |
| +} |
| + |
| +void VideoCaptureHandlerProxy::OnStartedOnMainThread( |
| + VideoCapture* capture, |
| + const VideoCaptureState& state) { |
| + state_ = state; |
| + proxied_->OnStarted(capture); |
| +} |
| + |
| +void VideoCaptureHandlerProxy::OnStoppedOnMainThread( |
| + VideoCapture* capture, |
| + const VideoCaptureState& state) { |
| + state_ = state; |
| + proxied_->OnStopped(capture); |
| +} |
| + |
| +void VideoCaptureHandlerProxy::OnPausedOnMainThread( |
| + VideoCapture* capture, |
| + const VideoCaptureState& state) { |
| + state_ = state; |
| + proxied_->OnPaused(capture); |
| +} |
| + |
| +void VideoCaptureHandlerProxy::OnErrorOnMainThread( |
| + VideoCapture* capture, |
| + const VideoCaptureState& state, |
| + int error_code) { |
| + state_ = state; |
| + proxied_->OnError(capture, error_code); |
| +} |
| + |
| +void VideoCaptureHandlerProxy::OnBufferReadyOnMainThread( |
| + VideoCapture* capture, |
| + const VideoCaptureState& state, |
| + scoped_refptr<VideoCapture::VideoFrameBuffer> buffer) { |
| + state_ = state; |
| + proxied_->OnBufferReady(capture, buffer); |
| +} |
| + |
| +void VideoCaptureHandlerProxy::OnDeviceInfoReceivedOnMainThread( |
| + VideoCapture* capture, |
| + const VideoCaptureState& state, |
| + const VideoCaptureParams& device_info) { |
| + state_ = state; |
| + proxied_->OnDeviceInfoReceived(capture, device_info); |
| +} |
| + |
| +} // namespace media |