Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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. | |
| 4 | |
| 5 #include "media/video/capture/video_capture_proxy.h" | |
| 6 | |
| 7 #include "base/message_loop_proxy.h" | |
| 8 | |
| 9 namespace { | |
| 10 | |
| 11 // Called on VC thread: extracts the state out of the VideoCapture, and | |
| 12 // serialize it into a VideoCaptureState. | |
| 13 media::VideoCaptureHandlerProxy::VideoCaptureState GetState( | |
| 14 media::VideoCapture* capture) { | |
| 15 media::VideoCaptureHandlerProxy::VideoCaptureState state; | |
| 16 state.started = capture->CaptureStarted(); | |
| 17 state.width = capture->CaptureWidth(); | |
| 18 state.height = capture->CaptureHeight(); | |
| 19 state.frame_rate = capture->CaptureFrameRate(); | |
| 20 return state; | |
| 21 } | |
| 22 | |
| 23 } // anonymous namespace | |
| 24 | |
| 25 namespace media { | |
| 26 | |
| 27 VideoCaptureHandlerProxy::VideoCaptureHandlerProxy( | |
| 28 VideoCapture::EventHandler* proxied) | |
| 29 : proxied_(proxied), | |
| 30 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
| |
| 31 } | |
| 32 | |
| 33 VideoCaptureHandlerProxy::~VideoCaptureHandlerProxy() { | |
| 34 } | |
| 35 | |
| 36 void VideoCaptureHandlerProxy::OnStarted(VideoCapture* capture) { | |
| 37 main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( | |
| 38 this, | |
|
wjia(left Chromium)
2011/08/02 00:10:39
indentation.
piman
2011/08/02 01:08:55
Done (here and below).
| |
| 39 &VideoCaptureHandlerProxy::OnStartedOnMainThread, | |
| 40 capture, | |
| 41 GetState(capture))); | |
| 42 } | |
| 43 | |
| 44 void VideoCaptureHandlerProxy::OnStopped(VideoCapture* capture) { | |
| 45 main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( | |
| 46 this, | |
| 47 &VideoCaptureHandlerProxy::OnStoppedOnMainThread, | |
| 48 capture, | |
| 49 GetState(capture))); | |
| 50 } | |
| 51 | |
| 52 void VideoCaptureHandlerProxy::OnPaused(VideoCapture* capture) { | |
| 53 main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( | |
| 54 this, | |
| 55 &VideoCaptureHandlerProxy::OnPausedOnMainThread, | |
| 56 capture, | |
| 57 GetState(capture))); | |
| 58 } | |
| 59 | |
| 60 void VideoCaptureHandlerProxy::OnError(VideoCapture* capture, int error_code) { | |
| 61 main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( | |
| 62 this, | |
| 63 &VideoCaptureHandlerProxy::OnErrorOnMainThread, | |
| 64 capture, | |
| 65 GetState(capture), | |
| 66 error_code)); | |
| 67 } | |
| 68 | |
| 69 void VideoCaptureHandlerProxy::OnBufferReady( | |
| 70 VideoCapture* capture, | |
| 71 scoped_refptr<VideoCapture::VideoFrameBuffer> buffer) { | |
| 72 main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( | |
| 73 this, | |
| 74 &VideoCaptureHandlerProxy::OnBufferReadyOnMainThread, | |
| 75 capture, | |
| 76 GetState(capture), | |
| 77 buffer)); | |
| 78 } | |
| 79 | |
| 80 void VideoCaptureHandlerProxy::OnDeviceInfoReceived( | |
| 81 VideoCapture* capture, | |
| 82 const VideoCaptureParams& device_info) { | |
| 83 main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( | |
| 84 this, | |
| 85 &VideoCaptureHandlerProxy::OnDeviceInfoReceivedOnMainThread, | |
| 86 capture, | |
| 87 GetState(capture), | |
| 88 device_info)); | |
| 89 } | |
| 90 | |
| 91 void VideoCaptureHandlerProxy::OnStartedOnMainThread( | |
| 92 VideoCapture* capture, | |
| 93 const VideoCaptureState& state) { | |
| 94 state_ = state; | |
| 95 proxied_->OnStarted(capture); | |
| 96 } | |
| 97 | |
| 98 void VideoCaptureHandlerProxy::OnStoppedOnMainThread( | |
| 99 VideoCapture* capture, | |
| 100 const VideoCaptureState& state) { | |
| 101 state_ = state; | |
| 102 proxied_->OnStopped(capture); | |
| 103 } | |
| 104 | |
| 105 void VideoCaptureHandlerProxy::OnPausedOnMainThread( | |
| 106 VideoCapture* capture, | |
| 107 const VideoCaptureState& state) { | |
| 108 state_ = state; | |
| 109 proxied_->OnPaused(capture); | |
| 110 } | |
| 111 | |
| 112 void VideoCaptureHandlerProxy::OnErrorOnMainThread( | |
| 113 VideoCapture* capture, | |
| 114 const VideoCaptureState& state, | |
| 115 int error_code) { | |
| 116 state_ = state; | |
| 117 proxied_->OnError(capture, error_code); | |
| 118 } | |
| 119 | |
| 120 void VideoCaptureHandlerProxy::OnBufferReadyOnMainThread( | |
| 121 VideoCapture* capture, | |
| 122 const VideoCaptureState& state, | |
| 123 scoped_refptr<VideoCapture::VideoFrameBuffer> buffer) { | |
| 124 state_ = state; | |
| 125 proxied_->OnBufferReady(capture, buffer); | |
| 126 } | |
| 127 | |
| 128 void VideoCaptureHandlerProxy::OnDeviceInfoReceivedOnMainThread( | |
| 129 VideoCapture* capture, | |
| 130 const VideoCaptureState& state, | |
| 131 const VideoCaptureParams& device_info) { | |
| 132 state_ = state; | |
| 133 proxied_->OnDeviceInfoReceived(capture, device_info); | |
| 134 } | |
| 135 | |
| 136 } // namespace media | |
| OLD | NEW |