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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/video/capture/video_capture_proxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c5528198a1f977dceea3402832f548948355ba53
--- /dev/null
+++ b/media/video/capture/video_capture_proxy.cc
@@ -0,0 +1,135 @@
+// 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/bind.h"
+#include "base/location.h"
+#include "base/single_thread_task_runner.h"
+#include "media/base/video_frame.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.frame_rate = capture->CaptureFrameRate();
+ return state;
+}
+
+} // anonymous namespace
+
+namespace media {
+
+VideoCaptureHandlerProxy::VideoCaptureHandlerProxy(
+ VideoCapture::EventHandler* proxied,
+ const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner)
+ : proxied_(proxied),
+ main_task_runner_(main_task_runner) {
+}
+
+VideoCaptureHandlerProxy::~VideoCaptureHandlerProxy() {
+}
+
+void VideoCaptureHandlerProxy::OnStarted(VideoCapture* capture) {
+ main_task_runner_->PostTask(FROM_HERE, base::Bind(
+ &VideoCaptureHandlerProxy::OnStartedOnMainThread,
+ base::Unretained(this),
+ capture,
+ GetState(capture)));
+}
+
+void VideoCaptureHandlerProxy::OnStopped(VideoCapture* capture) {
+ main_task_runner_->PostTask(FROM_HERE, base::Bind(
+ &VideoCaptureHandlerProxy::OnStoppedOnMainThread,
+ base::Unretained(this),
+ capture,
+ GetState(capture)));
+}
+
+void VideoCaptureHandlerProxy::OnPaused(VideoCapture* capture) {
+ main_task_runner_->PostTask(FROM_HERE, base::Bind(
+ &VideoCaptureHandlerProxy::OnPausedOnMainThread,
+ base::Unretained(this),
+ capture,
+ GetState(capture)));
+}
+
+void VideoCaptureHandlerProxy::OnError(VideoCapture* capture, int error_code) {
+ main_task_runner_->PostTask(FROM_HERE, base::Bind(
+ &VideoCaptureHandlerProxy::OnErrorOnMainThread,
+ base::Unretained(this),
+ capture,
+ GetState(capture),
+ error_code));
+}
+
+void VideoCaptureHandlerProxy::OnRemoved(VideoCapture* capture) {
+ main_task_runner_->PostTask(FROM_HERE, base::Bind(
+ &VideoCaptureHandlerProxy::OnRemovedOnMainThread,
+ base::Unretained(this),
+ capture,
+ GetState(capture)));
+}
+
+void VideoCaptureHandlerProxy::OnFrameReady(
+ VideoCapture* capture,
+ const scoped_refptr<VideoFrame>& frame) {
+ main_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&VideoCaptureHandlerProxy::OnFrameReadyOnMainThread,
+ base::Unretained(this),
+ capture,
+ GetState(capture),
+ frame));
+}
+
+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::OnRemovedOnMainThread(
+ VideoCapture* capture,
+ const VideoCaptureState& state) {
+ state_ = state;
+ proxied_->OnRemoved(capture);
+}
+
+void VideoCaptureHandlerProxy::OnFrameReadyOnMainThread(
+ VideoCapture* capture,
+ const VideoCaptureState& state,
+ const scoped_refptr<VideoFrame>& frame) {
+ state_ = state;
+ proxied_->OnFrameReady(capture, frame);
+}
+
+} // namespace media
« 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