Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: media/video/capture/video_capture_proxy.cc

Issue 7537037: Add a proxy for thread-hopping VideoCapture::EventHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/video/capture/video_capture_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 scoped_refptr<base::MessageLoopProxy> main_message_loop)
30 : proxied_(proxied),
31 main_message_loop_(main_message_loop) {
32 }
33
34 VideoCaptureHandlerProxy::~VideoCaptureHandlerProxy() {
35 }
36
37 void VideoCaptureHandlerProxy::OnStarted(VideoCapture* capture) {
38 main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
39 this,
40 &VideoCaptureHandlerProxy::OnStartedOnMainThread,
41 capture,
42 GetState(capture)));
43 }
44
45 void VideoCaptureHandlerProxy::OnStopped(VideoCapture* capture) {
46 main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
47 this,
48 &VideoCaptureHandlerProxy::OnStoppedOnMainThread,
49 capture,
50 GetState(capture)));
51 }
52
53 void VideoCaptureHandlerProxy::OnPaused(VideoCapture* capture) {
54 main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
55 this,
56 &VideoCaptureHandlerProxy::OnPausedOnMainThread,
57 capture,
58 GetState(capture)));
59 }
60
61 void VideoCaptureHandlerProxy::OnError(VideoCapture* capture, int error_code) {
62 main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
63 this,
64 &VideoCaptureHandlerProxy::OnErrorOnMainThread,
65 capture,
66 GetState(capture),
67 error_code));
68 }
69
70 void VideoCaptureHandlerProxy::OnBufferReady(
71 VideoCapture* capture,
72 scoped_refptr<VideoCapture::VideoFrameBuffer> buffer) {
73 main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
74 this,
75 &VideoCaptureHandlerProxy::OnBufferReadyOnMainThread,
76 capture,
77 GetState(capture),
78 buffer));
79 }
80
81 void VideoCaptureHandlerProxy::OnDeviceInfoReceived(
82 VideoCapture* capture,
83 const VideoCaptureParams& device_info) {
84 main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
85 this,
86 &VideoCaptureHandlerProxy::OnDeviceInfoReceivedOnMainThread,
87 capture,
88 GetState(capture),
89 device_info));
90 }
91
92 void VideoCaptureHandlerProxy::OnStartedOnMainThread(
93 VideoCapture* capture,
94 const VideoCaptureState& state) {
95 state_ = state;
96 proxied_->OnStarted(capture);
97 }
98
99 void VideoCaptureHandlerProxy::OnStoppedOnMainThread(
100 VideoCapture* capture,
101 const VideoCaptureState& state) {
102 state_ = state;
103 proxied_->OnStopped(capture);
104 }
105
106 void VideoCaptureHandlerProxy::OnPausedOnMainThread(
107 VideoCapture* capture,
108 const VideoCaptureState& state) {
109 state_ = state;
110 proxied_->OnPaused(capture);
111 }
112
113 void VideoCaptureHandlerProxy::OnErrorOnMainThread(
114 VideoCapture* capture,
115 const VideoCaptureState& state,
116 int error_code) {
117 state_ = state;
118 proxied_->OnError(capture, error_code);
119 }
120
121 void VideoCaptureHandlerProxy::OnBufferReadyOnMainThread(
122 VideoCapture* capture,
123 const VideoCaptureState& state,
124 scoped_refptr<VideoCapture::VideoFrameBuffer> buffer) {
125 state_ = state;
126 proxied_->OnBufferReady(capture, buffer);
127 }
128
129 void VideoCaptureHandlerProxy::OnDeviceInfoReceivedOnMainThread(
130 VideoCapture* capture,
131 const VideoCaptureState& state,
132 const VideoCaptureParams& device_info) {
133 state_ = state;
134 proxied_->OnDeviceInfoReceived(capture, device_info);
135 }
136
137 } // namespace media
OLDNEW
« no previous file with comments | « media/video/capture/video_capture_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698