summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwjia@google.com <wjia@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-01 02:18:45 +0000
committerwjia@google.com <wjia@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-01 02:18:45 +0000
commit2de9a47758e975de610d246ee4e333c2898ea504 (patch)
tree0b41741d0c0cee5a3e7f6f2aabbaeaee64b77b4e
parent8d8ecda2c73279b23a0ada26ecf53334b87a3554 (diff)
downloadchromium_src-2de9a47758e975de610d246ee4e333c2898ea504.zip
chromium_src-2de9a47758e975de610d246ee4e333c2898ea504.tar.gz
chromium_src-2de9a47758e975de610d246ee4e333c2898ea504.tar.bz2
move EventHandler out of VideoCaptureController to make VS2005 happy
BUG=none TEST=try bots Review URL: http://codereview.chromium.org/7101001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87417 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/renderer_host/video_capture_controller.cc4
-rw-r--r--content/browser/renderer_host/video_capture_controller.h47
-rw-r--r--content/browser/renderer_host/video_capture_controller_event_handler.cc20
-rw-r--r--content/browser/renderer_host/video_capture_controller_event_handler.h51
-rw-r--r--content/browser/renderer_host/video_capture_host.cc38
-rw-r--r--content/browser/renderer_host/video_capture_host.h18
-rw-r--r--content/browser/renderer_host/video_capture_host_unittest.cc2
-rw-r--r--content/content_browser.gypi2
8 files changed, 114 insertions, 68 deletions
diff --git a/content/browser/renderer_host/video_capture_controller.cc b/content/browser/renderer_host/video_capture_controller.cc
index 9232087..dce342d 100644
--- a/content/browser/renderer_host/video_capture_controller.cc
+++ b/content/browser/renderer_host/video_capture_controller.cc
@@ -18,9 +18,9 @@
static const size_t kNoOfDIBS = 3;
VideoCaptureController::VideoCaptureController(
- ControllerId id,
+ const VideoCaptureControllerID& id,
base::ProcessHandle render_process,
- EventHandler* event_handler)
+ VideoCaptureControllerEventHandler* event_handler)
: render_handle_(render_process),
report_ready_to_delete_(false),
event_handler_(event_handler),
diff --git a/content/browser/renderer_host/video_capture_controller.h b/content/browser/renderer_host/video_capture_controller.h
index 18341ad..9eae8c7 100644
--- a/content/browser/renderer_host/video_capture_controller.h
+++ b/content/browser/renderer_host/video_capture_controller.h
@@ -22,6 +22,7 @@
#include "base/process.h"
#include "base/synchronization/lock.h"
#include "base/task.h"
+#include "content/browser/renderer_host/video_capture_controller_event_handler.h"
#include "media/video/capture/video_capture_device.h"
#include "media/video/capture/video_capture_types.h"
#include "ui/gfx/surface/transport_dib.h"
@@ -30,51 +31,27 @@ class VideoCaptureController
: public base::RefCountedThreadSafe<VideoCaptureController>,
public media::VideoCaptureDevice::EventHandler {
public:
- // Id used for identifying an object of VideoCaptureController.
- typedef std::pair<int32, int> ControllerId;
- class EventHandler {
- public:
- // An Error have occurred in the VideoCaptureDevice.
- virtual void OnError(ControllerId id) = 0;
-
- // An TransportDIB have been filled with I420 video.
- virtual void OnBufferReady(ControllerId id,
- TransportDIB::Handle handle,
- base::Time timestamp) = 0;
-
- // The frame resolution the VideoCaptureDevice capture video in.
- virtual void OnFrameInfo(ControllerId id,
- int width,
- int height,
- int frame_rate) = 0;
-
- // Report that this object can be deleted.
- virtual void OnReadyToDelete(ControllerId id) = 0;
-
- protected:
- virtual ~EventHandler() {}
- };
-
- VideoCaptureController(ControllerId id,
+ VideoCaptureController(const VideoCaptureControllerID& id,
base::ProcessHandle render_process,
- EventHandler* event_handler);
+ VideoCaptureControllerEventHandler* event_handler);
virtual ~VideoCaptureController();
// Starts video capturing and tries to use the resolution specified in
// params.
- // When capturing has started EventHandler::OnFrameInfo is called with
- // resolution that best matches the requested that the video capture device
- // support.
+ // When capturing has started VideoCaptureControllerEventHandler::OnFrameInfo
+ // is called with resolution that best matches the requested that the video
+ // capture device support.
void StartCapture(const media::VideoCaptureParams& params);
// Stop video capture.
// When the capture is stopped and all TransportDIBS have been returned
- // EventHandler::OnReadyToDelete will be called.
+ // VideoCaptureControllerEventHandler::OnReadyToDelete will be called.
// stopped_task may be null but it can be used to get a notification when the
// device is stopped.
void StopCapture(Task* stopped_task);
- // Return a DIB previously given in EventHandler::OnBufferReady.
+ // Return a DIB previously given in
+ // VideoCaptureControllerEventHandler::OnBufferReady.
void ReturnTransportDIB(TransportDIB::Handle handle);
// Implement media::VideoCaptureDevice::EventHandler.
@@ -101,13 +78,13 @@ class VideoCaptureController
// All DIBS created by this object.
DIBMap owned_dibs_;
- EventHandler* event_handler_;
+ VideoCaptureControllerEventHandler* event_handler_;
// The parameter that was requested when starting the capture device.
media::VideoCaptureParams params_;
- // Id used for identifying this object.
- ControllerId id_;
+ // ID used for identifying this object.
+ VideoCaptureControllerID id_;
media::VideoCaptureDevice::Capability frame_info_;
DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureController);
diff --git a/content/browser/renderer_host/video_capture_controller_event_handler.cc b/content/browser/renderer_host/video_capture_controller_event_handler.cc
new file mode 100644
index 0000000..ca6e348
--- /dev/null
+++ b/content/browser/renderer_host/video_capture_controller_event_handler.cc
@@ -0,0 +1,20 @@
+// 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 "content/browser/renderer_host/video_capture_controller_event_handler.h"
+
+VideoCaptureControllerID::VideoCaptureControllerID()
+ :routing_id(0),
+ device_id(0) {}
+
+VideoCaptureControllerID::VideoCaptureControllerID(int32 rid, int did)
+ :routing_id(rid),
+ device_id(did) {}
+
+VideoCaptureControllerID::~VideoCaptureControllerID() {}
+
+bool VideoCaptureControllerID::operator<(
+ const VideoCaptureControllerID& vc) const {
+ return this->routing_id < vc.routing_id && this->device_id < vc.device_id;
+}
diff --git a/content/browser/renderer_host/video_capture_controller_event_handler.h b/content/browser/renderer_host/video_capture_controller_event_handler.h
new file mode 100644
index 0000000..74f4d24
--- /dev/null
+++ b/content/browser/renderer_host/video_capture_controller_event_handler.h
@@ -0,0 +1,51 @@
+// 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.
+
+#ifndef CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_CONTROLLER_EVENT_HANDLER_H_
+#define CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_CONTROLLER_EVENT_HANDLER_H_
+
+#include <map>
+
+#include "base/time.h"
+#include "ui/gfx/surface/transport_dib.h"
+
+// ID used for identifying an object of VideoCaptureController.
+struct VideoCaptureControllerID {
+ public:
+ VideoCaptureControllerID();
+ VideoCaptureControllerID(int32 rid, int did);
+ ~VideoCaptureControllerID();
+ bool operator<(const VideoCaptureControllerID& vc) const;
+
+ int32 routing_id;
+ int device_id;
+};
+
+// VideoCaptureControllerEventHandler is the interface for
+// VideoCaptureController to notify clients about the events such as
+// BufferReady, FrameInfo, Error, etc.
+class VideoCaptureControllerEventHandler {
+ public:
+ // An Error have occurred in the VideoCaptureDevice.
+ virtual void OnError(const VideoCaptureControllerID& id) = 0;
+
+ // An TransportDIB have been filled with I420 video.
+ virtual void OnBufferReady(const VideoCaptureControllerID& id,
+ TransportDIB::Handle handle,
+ base::Time timestamp) = 0;
+
+ // The frame resolution the VideoCaptureDevice capture video in.
+ virtual void OnFrameInfo(const VideoCaptureControllerID& id,
+ int width,
+ int height,
+ int frame_rate) = 0;
+
+ // Report that this object can be deleted.
+ virtual void OnReadyToDelete(const VideoCaptureControllerID& id) = 0;
+
+ protected:
+ virtual ~VideoCaptureControllerEventHandler() {}
+};
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_CONTROLLER_EVENT_HANDLER_H_
diff --git a/content/browser/renderer_host/video_capture_host.cc b/content/browser/renderer_host/video_capture_host.cc
index f5b9924..8f7fa4a 100644
--- a/content/browser/renderer_host/video_capture_host.cc
+++ b/content/browser/renderer_host/video_capture_host.cc
@@ -31,36 +31,35 @@ void VideoCaptureHost::OnDestruct() const {
///////////////////////////////////////////////////////////////////////////////
-// Implements VideoCaptureController::EventHandler.
-void VideoCaptureHost::OnError(VideoCaptureController::ControllerId id) {
+// Implements VideoCaptureControllerEventHandler.
+void VideoCaptureHost::OnError(const VideoCaptureControllerID& id) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this, &VideoCaptureHost::DoHandleError, id.first,
- id.second));
+ NewRunnableMethod(this, &VideoCaptureHost::DoHandleError, id.routing_id,
+ id.device_id));
}
void VideoCaptureHost::OnBufferReady(
- VideoCaptureController::ControllerId id,
+ const VideoCaptureControllerID& id,
TransportDIB::Handle handle,
base::Time timestamp) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this, &VideoCaptureHost::DoSendFilledBuffer, id.first,
- id.second, handle, timestamp));
+ NewRunnableMethod(this, &VideoCaptureHost::DoSendFilledBuffer,
+ id.routing_id, id.device_id, handle, timestamp));
}
-void VideoCaptureHost::OnFrameInfo(VideoCaptureController::ControllerId id,
+void VideoCaptureHost::OnFrameInfo(const VideoCaptureControllerID& id,
int width,
int height,
int frame_per_second) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this, &VideoCaptureHost::DoSendFrameInfo, id.first,
- id.second, width, height, frame_per_second));
+ NewRunnableMethod(this, &VideoCaptureHost::DoSendFrameInfo, id.routing_id,
+ id.device_id, width, height, frame_per_second));
}
-void VideoCaptureHost::OnReadyToDelete(
- VideoCaptureController::ControllerId id) {
+void VideoCaptureHost::OnReadyToDelete(const VideoCaptureControllerID& id) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(this, &VideoCaptureHost::DoDeleteVideoCaptureController,
@@ -83,7 +82,7 @@ void VideoCaptureHost::DoHandleError(int32 routing_id, int device_id) {
Send(new VideoCaptureMsg_StateChanged(routing_id, device_id,
media::VideoCapture::kError));
- VideoCaptureController::ControllerId id(routing_id, device_id);
+ VideoCaptureControllerID id(routing_id, device_id);
EntryMap::iterator it = entries_.find(id);
if (it != entries_.end()) {
VideoCaptureController* controller = it->second;
@@ -127,8 +126,7 @@ void VideoCaptureHost::OnStartCapture(const IPC::Message& msg, int device_id,
const media::VideoCaptureParams& params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- VideoCaptureController::ControllerId controller_id(msg.routing_id(),
- device_id);
+ VideoCaptureControllerID controller_id(msg.routing_id(), device_id);
DCHECK(entries_.find(controller_id) == entries_.end());
@@ -141,8 +139,7 @@ void VideoCaptureHost::OnStartCapture(const IPC::Message& msg, int device_id,
void VideoCaptureHost::OnStopCapture(const IPC::Message& msg, int device_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- VideoCaptureController::ControllerId controller_id(msg.routing_id(),
- device_id);
+ VideoCaptureControllerID controller_id(msg.routing_id(), device_id);
EntryMap::iterator it = entries_.find(controller_id);
if (it != entries_.end()) {
scoped_refptr<VideoCaptureController> controller = it->second;
@@ -166,8 +163,7 @@ void VideoCaptureHost::OnReceiveEmptyBuffer(const IPC::Message& msg,
TransportDIB::Handle handle) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- VideoCaptureController::ControllerId controller_id(msg.routing_id(),
- device_id);
+ VideoCaptureControllerID controller_id(msg.routing_id(), device_id);
EntryMap::iterator it = entries_.find(controller_id);
if (it != entries_.end()) {
scoped_refptr<VideoCaptureController> controller = it->second;
@@ -176,11 +172,11 @@ void VideoCaptureHost::OnReceiveEmptyBuffer(const IPC::Message& msg,
}
void VideoCaptureHost::DoDeleteVideoCaptureController(
- VideoCaptureController::ControllerId id) {
+ const VideoCaptureControllerID& id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// Report that the device have successfully been stopped.
- Send(new VideoCaptureMsg_StateChanged(id.first, id.second,
+ Send(new VideoCaptureMsg_StateChanged(id.routing_id, id.device_id,
media::VideoCapture::kStopped));
entries_.erase(id);
}
diff --git a/content/browser/renderer_host/video_capture_host.h b/content/browser/renderer_host/video_capture_host.h
index 3ee7717..d907944 100644
--- a/content/browser/renderer_host/video_capture_host.h
+++ b/content/browser/renderer_host/video_capture_host.h
@@ -44,7 +44,7 @@
#include "ipc/ipc_message.h"
class VideoCaptureHost : public BrowserMessageFilter,
- public VideoCaptureController::EventHandler {
+ public VideoCaptureControllerEventHandler {
public:
VideoCaptureHost();
@@ -54,16 +54,16 @@ class VideoCaptureHost : public BrowserMessageFilter,
virtual bool OnMessageReceived(const IPC::Message& message,
bool* message_was_ok);
- // VideoCaptureController::EventHandler implementation.
- virtual void OnError(VideoCaptureController::ControllerId id);
- virtual void OnBufferReady(VideoCaptureController::ControllerId id,
+ // VideoCaptureControllerEventHandler implementation.
+ virtual void OnError(const VideoCaptureControllerID& id);
+ virtual void OnBufferReady(const VideoCaptureControllerID& id,
TransportDIB::Handle handle,
base::Time timestamp);
- virtual void OnFrameInfo(VideoCaptureController::ControllerId id,
+ virtual void OnFrameInfo(const VideoCaptureControllerID& id,
int width,
int height,
int frame_per_second);
- virtual void OnReadyToDelete(VideoCaptureController::ControllerId id);
+ virtual void OnReadyToDelete(const VideoCaptureControllerID& id);
private:
friend class BrowserThread;
@@ -95,7 +95,7 @@ class VideoCaptureHost : public BrowserMessageFilter,
// Called on the IO thread when VideoCaptureController have
// reported that all DIBs have been returned.
- void DoDeleteVideoCaptureController(VideoCaptureController::ControllerId id);
+ void DoDeleteVideoCaptureController(const VideoCaptureControllerID& id);
// Send a filled buffer to the VideoCaptureMessageFilter.
void DoSendFilledBuffer(int32 routing_id,
@@ -114,10 +114,10 @@ class VideoCaptureHost : public BrowserMessageFilter,
// Handle error coming from VideoCaptureDevice.
void DoHandleError(int32 routing_id, int device_id);
- typedef std::map<VideoCaptureController::ControllerId,
+ typedef std::map<VideoCaptureControllerID,
scoped_refptr<VideoCaptureController> >EntryMap;
- // A map of VideoCaptureController::ControllerId to VideoCaptureController
+ // A map of VideoCaptureControllerID to VideoCaptureController
// objects that is currently active.
EntryMap entries_;
diff --git a/content/browser/renderer_host/video_capture_host_unittest.cc b/content/browser/renderer_host/video_capture_host_unittest.cc
index 7b029d6..8751ec4 100644
--- a/content/browser/renderer_host/video_capture_host_unittest.cc
+++ b/content/browser/renderer_host/video_capture_host_unittest.cc
@@ -322,7 +322,7 @@ class VideoCaptureHostTest : public testing::Test {
EXPECT_CALL(*host_, OnStateChanged(kRouteId, kDeviceId,
media::VideoCapture::kError))
.Times(1);
- VideoCaptureController::ControllerId id(kRouteId, kDeviceId);
+ VideoCaptureControllerID id(kRouteId, kDeviceId);
host_->OnError(id);
SyncWithVideoCaptureManagerThread();
}
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 8da029e..9793f01 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -283,6 +283,8 @@
'browser/renderer_host/x509_user_cert_resource_handler.h',
'browser/renderer_host/video_capture_controller.cc',
'browser/renderer_host/video_capture_controller.h',
+ 'browser/renderer_host/video_capture_controller_event_handler.cc',
+ 'browser/renderer_host/video_capture_controller_event_handler.h',
'browser/renderer_host/video_capture_host.cc',
'browser/renderer_host/video_capture_host.h',
'browser/resolve_proxy_msg_helper.cc',