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

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

Issue 263323003: Revert of Refactor video capturing code in the render process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/bind.h"
8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h"
10 #include "media/base/video_frame.h"
11
12 namespace {
13
14 // Called on VC thread: extracts the state out of the VideoCapture, and
15 // serialize it into a VideoCaptureState.
16 media::VideoCaptureHandlerProxy::VideoCaptureState GetState(
17 media::VideoCapture* capture) {
18 media::VideoCaptureHandlerProxy::VideoCaptureState state;
19 state.started = capture->CaptureStarted();
20 state.frame_rate = capture->CaptureFrameRate();
21 return state;
22 }
23
24 } // anonymous namespace
25
26 namespace media {
27
28 VideoCaptureHandlerProxy::VideoCaptureHandlerProxy(
29 VideoCapture::EventHandler* proxied,
30 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner)
31 : proxied_(proxied),
32 main_task_runner_(main_task_runner) {
33 }
34
35 VideoCaptureHandlerProxy::~VideoCaptureHandlerProxy() {
36 }
37
38 void VideoCaptureHandlerProxy::OnStarted(VideoCapture* capture) {
39 main_task_runner_->PostTask(FROM_HERE, base::Bind(
40 &VideoCaptureHandlerProxy::OnStartedOnMainThread,
41 base::Unretained(this),
42 capture,
43 GetState(capture)));
44 }
45
46 void VideoCaptureHandlerProxy::OnStopped(VideoCapture* capture) {
47 main_task_runner_->PostTask(FROM_HERE, base::Bind(
48 &VideoCaptureHandlerProxy::OnStoppedOnMainThread,
49 base::Unretained(this),
50 capture,
51 GetState(capture)));
52 }
53
54 void VideoCaptureHandlerProxy::OnPaused(VideoCapture* capture) {
55 main_task_runner_->PostTask(FROM_HERE, base::Bind(
56 &VideoCaptureHandlerProxy::OnPausedOnMainThread,
57 base::Unretained(this),
58 capture,
59 GetState(capture)));
60 }
61
62 void VideoCaptureHandlerProxy::OnError(VideoCapture* capture, int error_code) {
63 main_task_runner_->PostTask(FROM_HERE, base::Bind(
64 &VideoCaptureHandlerProxy::OnErrorOnMainThread,
65 base::Unretained(this),
66 capture,
67 GetState(capture),
68 error_code));
69 }
70
71 void VideoCaptureHandlerProxy::OnRemoved(VideoCapture* capture) {
72 main_task_runner_->PostTask(FROM_HERE, base::Bind(
73 &VideoCaptureHandlerProxy::OnRemovedOnMainThread,
74 base::Unretained(this),
75 capture,
76 GetState(capture)));
77 }
78
79 void VideoCaptureHandlerProxy::OnFrameReady(
80 VideoCapture* capture,
81 const scoped_refptr<VideoFrame>& frame) {
82 main_task_runner_->PostTask(
83 FROM_HERE,
84 base::Bind(&VideoCaptureHandlerProxy::OnFrameReadyOnMainThread,
85 base::Unretained(this),
86 capture,
87 GetState(capture),
88 frame));
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::OnRemovedOnMainThread(
121 VideoCapture* capture,
122 const VideoCaptureState& state) {
123 state_ = state;
124 proxied_->OnRemoved(capture);
125 }
126
127 void VideoCaptureHandlerProxy::OnFrameReadyOnMainThread(
128 VideoCapture* capture,
129 const VideoCaptureState& state,
130 const scoped_refptr<VideoFrame>& frame) {
131 state_ = state;
132 proxied_->OnFrameReady(capture, frame);
133 }
134
135 } // 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