summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/media/video_capture_host.cc
diff options
context:
space:
mode:
authornick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-12 22:21:51 +0000
committernick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-12 22:21:51 +0000
commit8f5815242ddd4e395a4fa8259c578e66eacd7b5e (patch)
treef532faee488b39097ccc0afbb731eb21f7ab26a2 /content/browser/renderer_host/media/video_capture_host.cc
parentf800f9b964b97c62d905d7fc63676b9361b70b42 (diff)
downloadchromium_src-8f5815242ddd4e395a4fa8259c578e66eacd7b5e.zip
chromium_src-8f5815242ddd4e395a4fa8259c578e66eacd7b5e.tar.gz
chromium_src-8f5815242ddd4e395a4fa8259c578e66eacd7b5e.tar.bz2
Rewrite VideoCaptureManager to streamline the lifetimes of
VideoCaptureController vs. VideoCaptureDevice. The goal of this change is to eliminate code and statefulness from VCM, VCC and VCD and to move towards more consistent threading behavior. Move most of the state of the VCM to the IO thread only. Track both the VCC and the VCD objects in a single collection that lives on the IO thread. Move the allocation of the Controller to the IO thread. Always allocate a Controller before a Device, and have the Controller outlive its Device. Device creation and destruction is farmed out to the device thread, but the decision to create or destroy occurs on the IO thread. VCM::Open() no longer creates the device but instead just records the ID of the device to be created. De-duplication of active devices will occur when a client actually Starts() a session. From the Controller, the changes to the VCM enable some simplifications here. Remove the notion of pending_clients_ and device restart. This is possible to do because the decision of which devices are open lives on the IO thread, so we don't have to worry about inconsistencies. Grant the Controller sole responsibility for tracking its clients, rather than having the Manager maintain a parallel list of handlers. In turn, the Manager asks the Controller how many clients remain, and takes on responsibility for actually starting and stopping the Device. Removing the Controller's calls into the manager enables some new unit tests on the public API of the Controller. Two small, subtle bugfixes are included: [1] In VCC, we were sometimes still delivering events to clients after |session_close|. This was uncovered by unit tests. [2] In VCM, the "in_use" state of devices (meaning whether any client had opened the device) was being returned to the MediaStreamManager in the devices-enumerated event. This change sets it to always be false, as it would appear that the MSM intends |in_use| to indicate per- session, not a systemwide per- device, bit. Several new unit tests are included. TEST=Manual tests of windows webcam creation, basic tests of chromecast mirroring BUG=284829,289731,289684 Review URL: https://chromiumcodereview.appspot.com/22866015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222883 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host/media/video_capture_host.cc')
-rw-r--r--content/browser/renderer_host/media/video_capture_host.cc23
1 files changed, 10 insertions, 13 deletions
diff --git a/content/browser/renderer_host/media/video_capture_host.cc b/content/browser/renderer_host/media/video_capture_host.cc
index f623d7d..9d3c634 100644
--- a/content/browser/renderer_host/media/video_capture_host.cc
+++ b/content/browser/renderer_host/media/video_capture_host.cc
@@ -32,14 +32,13 @@ VideoCaptureHost::~VideoCaptureHost() {}
void VideoCaptureHost::OnChannelClosing() {
BrowserMessageFilter::OnChannelClosing();
- // Since the IPC channel is gone, close all requested VideCaptureDevices.
+ // Since the IPC channel is gone, close all requested VideoCaptureDevices.
for (EntryMap::iterator it = entries_.begin(); it != entries_.end(); it++) {
VideoCaptureController* controller = it->second->controller.get();
if (controller) {
VideoCaptureControllerID controller_id(it->first);
- controller->StopCapture(controller_id, this);
- media_stream_manager_->video_capture_manager()->RemoveController(
- controller, this);
+ media_stream_manager_->video_capture_manager()->StopCaptureForClient(
+ controller, controller_id, this);
}
}
STLDeleteValues(&entries_);
@@ -224,9 +223,9 @@ void VideoCaptureHost::OnStartCapture(int device_id,
DCHECK(entries_.find(controller_id) == entries_.end());
entries_[controller_id] = new Entry(NULL);
- media_stream_manager_->video_capture_manager()->AddController(
- params, this, base::Bind(&VideoCaptureHost::OnControllerAdded, this,
- device_id, params));
+ media_stream_manager_->video_capture_manager()->StartCaptureForClient(
+ params, PeerHandle(), controller_id, this, base::Bind(
+ &VideoCaptureHost::OnControllerAdded, this, device_id, params));
}
void VideoCaptureHost::OnControllerAdded(
@@ -246,8 +245,8 @@ void VideoCaptureHost::DoControllerAddedOnIOThread(
EntryMap::iterator it = entries_.find(controller_id);
if (it == entries_.end()) {
if (controller) {
- media_stream_manager_->video_capture_manager()->RemoveController(
- controller, this);
+ media_stream_manager_->video_capture_manager()->StopCaptureForClient(
+ controller, controller_id, this);
}
return;
}
@@ -261,7 +260,6 @@ void VideoCaptureHost::DoControllerAddedOnIOThread(
}
it->second->controller = controller;
- controller->StartCapture(controller_id, this, PeerHandle(), params);
}
void VideoCaptureHost::OnStopCapture(int device_id) {
@@ -304,9 +302,8 @@ void VideoCaptureHost::DeleteVideoCaptureControllerOnIOThread(
VideoCaptureController* controller = it->second->controller.get();
if (controller) {
- controller->StopCapture(controller_id, this);
- media_stream_manager_->video_capture_manager()->RemoveController(
- controller, this);
+ media_stream_manager_->video_capture_manager()->StopCaptureForClient(
+ controller, controller_id, this);
}
delete it->second;
entries_.erase(controller_id);