OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "media/video/capture/video_capture_proxy.h" | 5 #include "media/video/capture/video_capture_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 // Called on VC thread: extracts the state out of the VideoCapture, and | 13 // Called on VC thread: extracts the state out of the VideoCapture, and |
14 // serialize it into a VideoCaptureState. | 14 // serialize it into a VideoCaptureState. |
15 media::VideoCaptureHandlerProxy::VideoCaptureState GetState( | 15 media::VideoCaptureHandlerProxy::VideoCaptureState GetState( |
16 media::VideoCapture* capture) { | 16 media::VideoCapture* capture) { |
17 media::VideoCaptureHandlerProxy::VideoCaptureState state; | 17 media::VideoCaptureHandlerProxy::VideoCaptureState state; |
18 state.started = capture->CaptureStarted(); | 18 state.started = capture->CaptureStarted(); |
19 state.width = capture->CaptureWidth(); | |
20 state.height = capture->CaptureHeight(); | |
21 state.frame_rate = capture->CaptureFrameRate(); | 19 state.frame_rate = capture->CaptureFrameRate(); |
22 return state; | 20 return state; |
23 } | 21 } |
24 | 22 |
25 } // anonymous namespace | 23 } // anonymous namespace |
26 | 24 |
27 namespace media { | 25 namespace media { |
28 | 26 |
29 VideoCaptureHandlerProxy::VideoCaptureHandlerProxy( | 27 VideoCaptureHandlerProxy::VideoCaptureHandlerProxy( |
30 VideoCapture::EventHandler* proxied, | 28 VideoCapture::EventHandler* proxied, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 const scoped_refptr<VideoFrame>& frame) { | 80 const scoped_refptr<VideoFrame>& frame) { |
83 main_message_loop_->PostTask( | 81 main_message_loop_->PostTask( |
84 FROM_HERE, | 82 FROM_HERE, |
85 base::Bind(&VideoCaptureHandlerProxy::OnFrameReadyOnMainThread, | 83 base::Bind(&VideoCaptureHandlerProxy::OnFrameReadyOnMainThread, |
86 base::Unretained(this), | 84 base::Unretained(this), |
87 capture, | 85 capture, |
88 GetState(capture), | 86 GetState(capture), |
89 frame)); | 87 frame)); |
90 } | 88 } |
91 | 89 |
92 void VideoCaptureHandlerProxy::OnDeviceInfoReceived( | |
93 VideoCapture* capture, | |
94 const VideoCaptureParams& device_info) { | |
95 main_message_loop_->PostTask(FROM_HERE, base::Bind( | |
96 &VideoCaptureHandlerProxy::OnDeviceInfoReceivedOnMainThread, | |
97 base::Unretained(this), | |
98 capture, | |
99 GetState(capture), | |
100 device_info)); | |
101 } | |
102 | |
103 void VideoCaptureHandlerProxy::OnStartedOnMainThread( | 90 void VideoCaptureHandlerProxy::OnStartedOnMainThread( |
104 VideoCapture* capture, | 91 VideoCapture* capture, |
105 const VideoCaptureState& state) { | 92 const VideoCaptureState& state) { |
106 state_ = state; | 93 state_ = state; |
107 proxied_->OnStarted(capture); | 94 proxied_->OnStarted(capture); |
108 } | 95 } |
109 | 96 |
110 void VideoCaptureHandlerProxy::OnStoppedOnMainThread( | 97 void VideoCaptureHandlerProxy::OnStoppedOnMainThread( |
111 VideoCapture* capture, | 98 VideoCapture* capture, |
112 const VideoCaptureState& state) { | 99 const VideoCaptureState& state) { |
(...skipping 24 matching lines...) Expand all Loading... |
137 } | 124 } |
138 | 125 |
139 void VideoCaptureHandlerProxy::OnFrameReadyOnMainThread( | 126 void VideoCaptureHandlerProxy::OnFrameReadyOnMainThread( |
140 VideoCapture* capture, | 127 VideoCapture* capture, |
141 const VideoCaptureState& state, | 128 const VideoCaptureState& state, |
142 const scoped_refptr<VideoFrame>& frame) { | 129 const scoped_refptr<VideoFrame>& frame) { |
143 state_ = state; | 130 state_ = state; |
144 proxied_->OnFrameReady(capture, frame); | 131 proxied_->OnFrameReady(capture, frame); |
145 } | 132 } |
146 | 133 |
147 void VideoCaptureHandlerProxy::OnDeviceInfoReceivedOnMainThread( | |
148 VideoCapture* capture, | |
149 const VideoCaptureState& state, | |
150 const VideoCaptureParams& device_info) { | |
151 state_ = state; | |
152 proxied_->OnDeviceInfoReceived(capture, device_info); | |
153 } | |
154 | |
155 } // namespace media | 134 } // namespace media |
OLD | NEW |