summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authormacourteau@chromium.org <macourteau@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 03:46:39 +0000
committermacourteau@chromium.org <macourteau@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 03:46:39 +0000
commita93670ab34b8f1cea9a9126f2bc97e3b4c4ec7dc (patch)
tree837b9b846183d7f010a1aa85751cd1d353200fb3 /content/browser
parent5b8978d2a2e4a10872d53133b4ea4a1341cfb00d (diff)
downloadchromium_src-a93670ab34b8f1cea9a9126f2bc97e3b4c4ec7dc.zip
chromium_src-a93670ab34b8f1cea9a9126f2bc97e3b4c4ec7dc.tar.gz
chromium_src-a93670ab34b8f1cea9a9126f2bc97e3b4c4ec7dc.tar.bz2
Preparation work for adding the Media Stream infobar. The behaviour is the same
as without this patch (and everything is still behind a flag). BUG=105115 TEST= Review URL: http://codereview.chromium.org/9360018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123418 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/mock_content_browser_client.cc5
-rw-r--r--content/browser/mock_content_browser_client.h3
-rw-r--r--content/browser/renderer_host/media/audio_input_device_manager.cc20
-rw-r--r--content/browser/renderer_host/media/audio_input_device_manager_unittest.cc93
-rw-r--r--content/browser/renderer_host/media/media_stream_device_settings.cc189
-rw-r--r--content/browser/renderer_host/media/media_stream_device_settings.h22
-rw-r--r--content/browser/renderer_host/media/media_stream_manager.cc85
-rw-r--r--content/browser/renderer_host/media/video_capture_manager.cc19
-rw-r--r--content/browser/renderer_host/media/video_capture_manager_unittest.cc69
9 files changed, 351 insertions, 154 deletions
diff --git a/content/browser/mock_content_browser_client.cc b/content/browser/mock_content_browser_client.cc
index b7aab7b..8c2be43 100644
--- a/content/browser/mock_content_browser_client.cc
+++ b/content/browser/mock_content_browser_client.cc
@@ -196,6 +196,11 @@ void MockContentBrowserClient::AddNewCertificate(
int render_view_id) {
}
+void MockContentBrowserClient::RequestMediaAccessPermission(
+ const content::MediaStreamRequest* request,
+ const content::MediaResponseCallback& callback) {
+}
+
void MockContentBrowserClient::RequestDesktopNotificationPermission(
const GURL& source_origin,
int callback_context,
diff --git a/content/browser/mock_content_browser_client.h b/content/browser/mock_content_browser_client.h
index 515d315..5c5bfdd 100644
--- a/content/browser/mock_content_browser_client.h
+++ b/content/browser/mock_content_browser_client.h
@@ -105,6 +105,9 @@ class MockContentBrowserClient : public ContentBrowserClient {
net::X509Certificate* cert,
int render_process_id,
int render_view_id) OVERRIDE;
+ virtual void RequestMediaAccessPermission(
+ const content::MediaStreamRequest* request,
+ const content::MediaResponseCallback& callback) OVERRIDE;
virtual void RequestDesktopNotificationPermission(
const GURL& source_origin,
int callback_context,
diff --git a/content/browser/renderer_host/media/audio_input_device_manager.cc b/content/browser/renderer_host/media/audio_input_device_manager.cc
index b664090..606a508 100644
--- a/content/browser/renderer_host/media/audio_input_device_manager.cc
+++ b/content/browser/renderer_host/media/audio_input_device_manager.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -53,8 +53,9 @@ void AudioInputDeviceManager::EnumerateDevices() {
for (media::AudioDeviceNames::iterator it = device_names.begin();
it != device_names.end();
++it) {
- devices->push_back(StreamDeviceInfo(kAudioCapture, it->device_name,
- it->unique_id, false));
+ devices->push_back(StreamDeviceInfo(
+ content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, it->device_name,
+ it->unique_id, false));
}
// Returns the device list through the listener by posting a task on
@@ -158,20 +159,25 @@ void AudioInputDeviceManager::DevicesEnumeratedOnIOThread(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// Ensures that |devices| gets deleted on exit.
scoped_ptr<StreamDeviceInfoArray> devices_array(devices);
- if (listener_)
- listener_->DevicesEnumerated(kAudioCapture, *devices_array);
+ if (listener_) {
+ listener_->DevicesEnumerated(
+ content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ *devices_array);
+ }
}
void AudioInputDeviceManager::OpenedOnIOThread(int session_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (listener_)
- listener_->Opened(kAudioCapture, session_id);
+ listener_->Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id);
}
void AudioInputDeviceManager::ClosedOnIOThread(int session_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (listener_)
- listener_->Closed(kAudioCapture, session_id);
+ listener_->Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id);
}
} // namespace media_stream
diff --git a/content/browser/renderer_host/media/audio_input_device_manager_unittest.cc b/content/browser/renderer_host/media/audio_input_device_manager_unittest.cc
index 6d9fcda..eb86e81 100644
--- a/content/browser/renderer_host/media/audio_input_device_manager_unittest.cc
+++ b/content/browser/renderer_host/media/audio_input_device_manager_unittest.cc
@@ -37,7 +37,7 @@ class MockAudioInputDeviceManagerListener
virtual void DevicesEnumerated(MediaStreamType service_type,
const StreamDeviceInfoArray& devices) {
- if (service_type != kAudioCapture)
+ if (service_type != content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE)
return;
devices_ = devices;
@@ -151,9 +151,13 @@ TEST_F(AudioInputDeviceManagerTest, OpenAndCloseDevice) {
manager_->Close(session_id);
// Expected mock call with expected return value.
- EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture, session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id))
.Times(1);
- EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id))
.Times(1);
// Waits for the callback.
@@ -182,8 +186,9 @@ TEST_F(AudioInputDeviceManagerTest, OpenMultipleDevices) {
session_id[index] = manager_->Open(*iter);
// Expected mock call with expected returned value.
- EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture,
- session_id[index]))
+ EXPECT_CALL(*audio_input_listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id[index]))
.Times(1);
// Waits for the callback.
@@ -200,7 +205,9 @@ TEST_F(AudioInputDeviceManagerTest, OpenMultipleDevices) {
for (int i = 0; i < kDeviceSize; ++i) {
// Closes the devices.
manager_->Close(session_id[i]);
- EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, session_id[i]))
+ EXPECT_CALL(*audio_input_listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id[i]))
.Times(1);
// Waits for the callback.
@@ -214,13 +221,15 @@ TEST_F(AudioInputDeviceManagerTest, OpenNotExistingDevice) {
return;
InSequence s;
- MediaStreamType stream_type = kAudioCapture;
+ MediaStreamType stream_type = content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE;
std::string device_name("device_doesnt_exist");
std::string device_id("id_doesnt_exist");
StreamDeviceInfo dummy_device(stream_type, device_name, device_id, false);
int session_id = manager_->Open(dummy_device);
- EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture, session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id))
.Times(1);
// Waits for the callback.
@@ -246,13 +255,21 @@ TEST_F(AudioInputDeviceManagerTest, OpenDeviceTwice) {
// Expected mock calls with expected returned values.
EXPECT_NE(first_session_id, second_session_id);
- EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture, first_session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ first_session_id))
.Times(1);
- EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture, second_session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ second_session_id))
.Times(1);
- EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, first_session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ first_session_id))
.Times(1);
- EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, second_session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ second_session_id))
.Times(1);
// Waits for the callback.
@@ -285,8 +302,9 @@ TEST_F(AudioInputDeviceManagerTest, StartAndStopSession) {
// Note that no DeviceStopped() notification for Event Handler as we have
// stopped the device before calling close.
session_id[index] = manager_->Open(*iter);
- EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture,
- session_id[index]))
+ EXPECT_CALL(*audio_input_listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id[index]))
.Times(1);
message_loop_->RunAllPending();
@@ -298,8 +316,9 @@ TEST_F(AudioInputDeviceManagerTest, StartAndStopSession) {
manager_->Stop(session_id[index]);
manager_->Close(session_id[index]);
- EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture,
- session_id[index]))
+ EXPECT_CALL(*audio_input_listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id[index]))
.Times(1);
message_loop_->RunAllPending();
}
@@ -330,8 +349,9 @@ TEST_F(AudioInputDeviceManagerTest, CloseWithoutStopSession) {
iter != audio_input_listener_->devices_.end(); ++iter, ++index) {
// Calls Open()/Start()/Close() for each device.
session_id[index] = manager_->Open(*iter);
- EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture,
- session_id[index]))
+ EXPECT_CALL(*audio_input_listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id[index]))
.Times(1);
message_loop_->RunAllPending();
@@ -347,8 +367,9 @@ TEST_F(AudioInputDeviceManagerTest, CloseWithoutStopSession) {
EXPECT_CALL(*audio_input_event_handler,
DeviceStopped(session_id[index]))
.Times(1);
- EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture,
- session_id[index]))
+ EXPECT_CALL(*audio_input_listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id[index]))
.Times(1);
message_loop_->RunAllPending();
}
@@ -377,9 +398,13 @@ TEST_F(AudioInputDeviceManagerTest, StartDeviceTwice) {
int first_session_id = manager_->Open(*iter);
int second_session_id = manager_->Open(*iter);
EXPECT_NE(first_session_id, second_session_id);
- EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture, first_session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ first_session_id))
.Times(1);
- EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture, second_session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ second_session_id))
.Times(1);
message_loop_->RunAllPending();
@@ -400,9 +425,13 @@ TEST_F(AudioInputDeviceManagerTest, StartDeviceTwice) {
manager_->Stop(second_session_id);
manager_->Close(first_session_id);
manager_->Close(second_session_id);
- EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, first_session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ first_session_id))
.Times(1);
- EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, second_session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ second_session_id))
.Times(1);
message_loop_->RunAllPending();
}
@@ -422,7 +451,9 @@ TEST_F(AudioInputDeviceManagerTest, StartInvalidSession) {
StreamDeviceInfoArray::const_iterator iter =
audio_input_listener_->devices_.begin();
int session_id = manager_->Open(*iter);
- EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture, session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id))
.Times(1);
message_loop_->RunAllPending();
@@ -437,7 +468,9 @@ TEST_F(AudioInputDeviceManagerTest, StartInvalidSession) {
message_loop_->RunAllPending();
manager_->Close(session_id);
- EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id))
.Times(1);
message_loop_->RunAllPending();
}
@@ -458,7 +491,9 @@ TEST_F(AudioInputDeviceManagerTest, StartSessionTwice) {
StreamDeviceInfoArray::const_iterator iter =
audio_input_listener_->devices_.begin();
int session_id = manager_->Open(*iter);
- EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture, session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id))
.Times(1);
message_loop_->RunAllPending();
@@ -479,7 +514,9 @@ TEST_F(AudioInputDeviceManagerTest, StartSessionTwice) {
manager_->Stop(session_id);
manager_->Close(session_id);
- EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, session_id))
+ EXPECT_CALL(*audio_input_listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
+ session_id))
.Times(1);
message_loop_->RunAllPending();
}
diff --git a/content/browser/renderer_host/media/media_stream_device_settings.cc b/content/browser/renderer_host/media/media_stream_device_settings.cc
index cb101f4..3347480 100644
--- a/content/browser/renderer_host/media/media_stream_device_settings.cc
+++ b/content/browser/renderer_host/media/media_stream_device_settings.cc
@@ -4,44 +4,106 @@
#include "content/browser/renderer_host/media/media_stream_device_settings.h"
+#include <algorithm>
+
+#include "base/bind.h"
+#include "base/callback.h"
#include "base/stl_util.h"
#include "content/browser/renderer_host/media/media_stream_settings_requester.h"
#include "content/common/media/media_stream_options.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/content_browser_client.h"
+#include "content/public/common/media_stream_request.h"
using content::BrowserThread;
+using content::MediaStreamDevice;
+using content::MediaStreamRequest;
+
+namespace {
+
+// Helper class to handle the callbacks to a MediaStreamDeviceSettings instance.
+// This class will make sure that the call to PostResponse is executed on the IO
+// thread (and that the instance of MediaStreamDeviceSettings still exists).
+// This allows us to pass a simple base::Callback object to any class that needs
+// to post a response to the MediaStreamDeviceSettings object. This logic cannot
+// be implemented inside MediaStreamDeviceSettings::PostResponse since that
+// would imply that the WeakPtr<MediaStreamDeviceSettings> pointer has been
+// dereferenced already (which would cause an error in the ThreadChecker before
+// we even get there).
+class ResponseCallbackHelper
+ : public base::RefCountedThreadSafe<ResponseCallbackHelper> {
+ public:
+ explicit ResponseCallbackHelper(
+ base::WeakPtr<media_stream::MediaStreamDeviceSettings> settings)
+ : settings_(settings) {
+ }
+
+ void PostResponse(const std::string& label,
+ const content::MediaStreamDeviceArray& devices) {
+ if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&media_stream::MediaStreamDeviceSettings::PostResponse,
+ settings_, label, devices));
+ return;
+ } else if (settings_) {
+ settings_->PostResponse(label, devices);
+ }
+ }
+
+ private:
+ base::WeakPtr<media_stream::MediaStreamDeviceSettings> settings_;
+
+ DISALLOW_COPY_AND_ASSIGN(ResponseCallbackHelper);
+};
+
+// Predicate used in find_if below to find a device with a given ID.
+class DeviceIdEquals {
+ public:
+ explicit DeviceIdEquals(const std::string& device_id)
+ : device_id_(device_id) {
+ }
+
+ bool operator() (const media_stream::StreamDeviceInfo& device) {
+ return (device.device_id == device_id_);
+ }
+
+ private:
+ std::string device_id_;
+};
+
+} // namespace
namespace media_stream {
-typedef std::map<MediaStreamType, StreamDeviceInfoArray> DeviceMap;
+typedef std::map< MediaStreamType, StreamDeviceInfoArray > DeviceMap;
// Device request contains all data needed to keep track of requests between the
// different calls.
-struct MediaStreamDeviceSettings::SettingsRequest {
- SettingsRequest(int render_pid, int render_vid, const std::string& origin,
- StreamOptions request_options)
- : render_process_id(render_pid),
- render_view_id(render_vid),
- security_origin(origin),
- options(request_options) {}
-
- // The render process id generating this request, needed for UI.
- int render_process_id;
- // The render view id generating this request, needed for UI.
- int render_view_id;
- // Security origin generated by WebKit.
- std::string security_origin;
+class MediaStreamDeviceSettingsRequest : public MediaStreamRequest {
+ public:
+ MediaStreamDeviceSettingsRequest(
+ int render_pid,
+ int render_vid,
+ const std::string& origin,
+ const StreamOptions& request_options)
+ : MediaStreamRequest(render_pid, render_vid, origin),
+ options(request_options) {}
+
+ ~MediaStreamDeviceSettingsRequest() {}
+
// Request options.
StreamOptions options;
// Map containing available devices for the requested capture types.
- DeviceMap devices;
+ DeviceMap devices_full;
};
+typedef std::map<MediaStreamType, StreamDeviceInfoArray> DeviceMap;
+
MediaStreamDeviceSettings::MediaStreamDeviceSettings(
SettingsRequester* requester)
: requester_(requester),
- // TODO(macourteau) Change to false when UI exists.
- use_fake_ui_(true) {
+ use_fake_ui_(false) {
DCHECK(requester_);
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
}
@@ -62,27 +124,22 @@ void MediaStreamDeviceSettings::RequestCaptureDeviceUsage(
}
// Create a new request.
- requests_.insert(std::make_pair(label, new SettingsRequest(render_process_id,
- render_view_id,
- security_origin,
- request_options)));
+ requests_.insert(std::make_pair(label, new MediaStreamDeviceSettingsRequest(
+ render_process_id, render_view_id, security_origin, request_options)));
}
void MediaStreamDeviceSettings::AvailableDevices(
- const std::string& label, MediaStreamType stream_type,
+ const std::string& label,
+ MediaStreamType stream_type,
const StreamDeviceInfoArray& devices) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
SettingsRequests::iterator request_it = requests_.find(label);
- if (request_it == requests_.end()) {
- // Request with this id doesn't exist.
- requester_->SettingsError(label);
- return;
- }
+ DCHECK(request_it != requests_.end());
// Add the answer for the request.
- SettingsRequest* request = request_it->second;
- request->devices[stream_type] = devices;
+ MediaStreamDeviceSettingsRequest* request = request_it->second;
+ request->devices_full[stream_type] = devices;
// Check if we're done.
size_t num_media_requests = 0;
@@ -93,21 +150,38 @@ void MediaStreamDeviceSettings::AvailableDevices(
num_media_requests++;
}
- if (request->devices.size() == num_media_requests) {
+ if (request->devices_full.size() == num_media_requests) {
// We have all answers needed.
if (!use_fake_ui_) {
- // TODO(macourteau)
- // This is the place to:
- // - Choose what devices to use from some kind of settings, user dialog or
- // default device.
- // - Request user permission / show we're using devices.
- DCHECK(false);
+ // Create the simplified list of devices.
+ for (DeviceMap::iterator it = request->devices_full.begin();
+ it != request->devices_full.end(); ++it) {
+ request->devices[it->first].clear();
+ for (StreamDeviceInfoArray::iterator device = it->second.begin();
+ device != it->second.end(); ++device) {
+ request->devices[it->first].push_back(MediaStreamDevice(
+ it->first, device->device_id, device->name));
+ }
+ }
+
+ // Send the permission request to the content client.
+ scoped_refptr<ResponseCallbackHelper> helper =
+ new ResponseCallbackHelper(AsWeakPtr());
+ content::MediaResponseCallback callback =
+ base::Bind(&ResponseCallbackHelper::PostResponse,
+ helper.get(), label);
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(
+ &content::ContentBrowserClient::RequestMediaAccessPermission,
+ base::Unretained(content::GetContentClient()->browser()),
+ request, callback));
} else {
// Used to fake UI, which is needed for server based testing.
// Choose first non-opened device for each media type.
StreamDeviceInfoArray devices_to_use;
- for (DeviceMap::iterator it = request->devices.begin();
- it != request->devices.end(); ++it) {
+ for (DeviceMap::iterator it = request->devices_full.begin();
+ it != request->devices_full.end(); ++it) {
for (StreamDeviceInfoArray::iterator device_it = it->second.begin();
device_it != it->second.end(); ++device_it) {
if (!device_it->in_use) {
@@ -116,13 +190,17 @@ void MediaStreamDeviceSettings::AvailableDevices(
}
}
}
- if (!request->devices[kVideoCapture].empty() &&
+
+ if (!request->devices_full[
+ content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE].empty() &&
num_media_requests != devices_to_use.size()) {
// Not all requested device types were opened. This happens if all
// video capture devices are already opened, |in_use| isn't set for
// audio devices. Allow the first video capture device in the list to be
// opened for this user too.
- StreamDeviceInfoArray device_array = (request->devices[kVideoCapture]);
+ StreamDeviceInfoArray device_array =
+ request->devices_full[
+ content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE];
devices_to_use.push_back(*(device_array.begin()));
}
@@ -134,6 +212,35 @@ void MediaStreamDeviceSettings::AvailableDevices(
}
}
+void MediaStreamDeviceSettings::PostResponse(
+ const std::string& label,
+ const content::MediaStreamDeviceArray& devices) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
+ SettingsRequests::iterator req = requests_.find(label);
+ DCHECK(req != requests_.end()) << "Invalid request label.";
+
+ DCHECK(requester_);
+ if (devices.size() > 0) {
+ // Build a list of "full" device objects for the accepted devices.
+ StreamDeviceInfoArray deviceList;
+ for (content::MediaStreamDeviceArray::const_iterator dev = devices.begin();
+ dev != devices.end(); ++dev) {
+ DeviceMap::iterator subList = req->second->devices_full.find(dev->type);
+ DCHECK(subList != req->second->devices_full.end());
+
+ deviceList.push_back(*std::find_if(subList->second.begin(),
+ subList->second.end(), DeviceIdEquals(dev->device_id)));
+ }
+ requester_->DevicesAccepted(label, deviceList);
+ } else {
+ requester_->SettingsError(label);
+ }
+
+ delete req->second;
+ requests_.erase(req);
+}
+
void MediaStreamDeviceSettings::UseFakeUI() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
use_fake_ui_ = true;
diff --git a/content/browser/renderer_host/media/media_stream_device_settings.h b/content/browser/renderer_host/media/media_stream_device_settings.h
index d740116..55b6d44 100644
--- a/content/browser/renderer_host/media/media_stream_device_settings.h
+++ b/content/browser/renderer_host/media/media_stream_device_settings.h
@@ -30,19 +30,21 @@
#include <string>
#include "base/basictypes.h"
+#include "base/memory/weak_ptr.h"
#include "content/browser/renderer_host/media/media_stream_provider.h"
namespace media_stream {
+class MediaStreamDeviceSettingsRequest;
class SettingsRequester;
-struct StreamOptions;
// MediaStreamDeviceSettings is responsible for getting user permission to use
// a media capture device as well as selecting what device to use.
-class MediaStreamDeviceSettings {
+class CONTENT_EXPORT MediaStreamDeviceSettings
+ : public base::SupportsWeakPtr<MediaStreamDeviceSettings> {
public:
explicit MediaStreamDeviceSettings(SettingsRequester* requester);
- ~MediaStreamDeviceSettings();
+ virtual ~MediaStreamDeviceSettings();
// Called when a new request of capture device usage is made.
void RequestCaptureDeviceUsage(const std::string& label,
@@ -56,19 +58,27 @@ class MediaStreamDeviceSettings {
void AvailableDevices(const std::string& label, MediaStreamType stream_type,
const StreamDeviceInfoArray& devices);
+ // Called by the InfoBar when the user grants/denies access to some devices
+ // to the webpage. This is placed here, so the request can be cleared from the
+ // list of pending requests, instead of letting the InfoBar itself respond to
+ // the requester. An empty list of devices means that access has been denied.
+ // This method must be called on the IO thread.
+ void PostResponse(const std::string& label,
+ const content::MediaStreamDeviceArray& devices);
+
// Used for testing only. This function is called to use faked UI, which is
// needed for server based tests. The first non-opened device(s) will be
// picked.
void UseFakeUI();
private:
- struct SettingsRequest;
+ typedef std::map< std::string, MediaStreamDeviceSettingsRequest* >
+ SettingsRequests;
SettingsRequester* requester_;
-
- typedef std::map<std::string, SettingsRequest*> SettingsRequests;
SettingsRequests requests_;
+ // See comment above for method UseFakeUI. Used for automated testing.
bool use_fake_ui_;
DISALLOW_COPY_AND_ASSIGN(MediaStreamDeviceSettings);
diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc
index 894426a..6f0adb9 100644
--- a/content/browser/renderer_host/media/media_stream_manager.cc
+++ b/content/browser/renderer_host/media/media_stream_manager.cc
@@ -44,10 +44,11 @@ static std::string RandomLabel() {
// Helper to verify if a media stream type is part of options or not.
static bool Requested(const StreamOptions& options,
MediaStreamType stream_type) {
- if (stream_type == kVideoCapture &&
+ if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE &&
(options.video_option != StreamOptions::kNoCamera)) {
return true;
- } else if (stream_type == kAudioCapture && options.audio == true) {
+ } else if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE &&
+ options.audio == true) {
return true;
}
return false;
@@ -70,7 +71,7 @@ struct MediaStreamManager::DeviceRequest {
DeviceRequest()
: requester(NULL),
- state(kNumMediaStreamTypes, kNotRequested),
+ state(content::NUM_MEDIA_STREAM_DEVICE_TYPES, kNotRequested),
type(kGenerateStream) {
options.audio = false;
options.video_option = StreamOptions::kNoCamera;
@@ -80,7 +81,7 @@ struct MediaStreamManager::DeviceRequest {
const StreamOptions& request_options)
: requester(requester),
options(request_options),
- state(kNumMediaStreamTypes, kNotRequested),
+ state(content::NUM_MEDIA_STREAM_DEVICE_TYPES, kNotRequested),
type(kGenerateStream) {
DCHECK(requester);
}
@@ -112,7 +113,7 @@ MediaStreamManager* MediaStreamManager::GetForResourceContext(
MediaStreamManager::MediaStreamManager(AudioManager* audio_manager)
: ALLOW_THIS_IN_INITIALIZER_LIST(
device_settings_(new MediaStreamDeviceSettings(this))),
- enumeration_in_progress_(kNumMediaStreamTypes, false),
+ enumeration_in_progress_(content::NUM_MEDIA_STREAM_DEVICE_TYPES, false),
audio_manager_(audio_manager) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
}
@@ -162,7 +163,8 @@ void MediaStreamManager::CancelRequests(MediaStreamRequester* requester) {
// The request isn't complete, but there might be some devices already
// opened -> close them.
DeviceRequest* request = &(it->second);
- if (request->state[kAudioCapture] == DeviceRequest::kOpening) {
+ if (request->state[content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE] ==
+ DeviceRequest::kOpening) {
for (StreamDeviceInfoArray::iterator it =
request->audio_devices.begin(); it != request->audio_devices.end();
++it) {
@@ -171,7 +173,8 @@ void MediaStreamManager::CancelRequests(MediaStreamRequester* requester) {
}
}
}
- if (request->state[kVideoCapture] == DeviceRequest::kOpening) {
+ if (request->state[content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE] ==
+ DeviceRequest::kOpening) {
for (StreamDeviceInfoArray::iterator it =
request->video_devices.begin(); it != request->video_devices.end();
++it) {
@@ -218,7 +221,7 @@ void MediaStreamManager::EnumerateDevices(
// Create a new request.
StreamOptions options;
- if (type == media_stream::kAudioCapture)
+ if (type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE)
options.audio = true;
else
options.video_option = StreamOptions::kFacingUser;
@@ -242,7 +245,7 @@ void MediaStreamManager::OpenDevice(
// Create a new request.
StreamOptions options;
- if (type == media_stream::kAudioCapture)
+ if (type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE)
options.audio = true;
else
options.video_option = StreamOptions::kFacingUser;
@@ -263,18 +266,20 @@ void MediaStreamManager::StartEnumeration(
std::string* label) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- if (Requested(new_request->options, kAudioCapture)) {
- new_request->state[kAudioCapture] = DeviceRequest::kRequested;
- if (!enumeration_in_progress_[kAudioCapture]) {
- enumeration_in_progress_[kAudioCapture] = true;
- GetDeviceManager(kAudioCapture)->EnumerateDevices();
+ MediaStreamType stream_type = content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE;
+ if (Requested(new_request->options, stream_type)) {
+ new_request->state[stream_type] = DeviceRequest::kRequested;
+ if (!enumeration_in_progress_[stream_type]) {
+ enumeration_in_progress_[stream_type] = true;
+ GetDeviceManager(stream_type)->EnumerateDevices();
}
}
- if (Requested(new_request->options, kVideoCapture)) {
- new_request->state[kVideoCapture] = DeviceRequest::kRequested;
- if (!enumeration_in_progress_[kVideoCapture]) {
- enumeration_in_progress_[kVideoCapture] = true;
- GetDeviceManager(kVideoCapture)->EnumerateDevices();
+ stream_type = content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE;
+ if (Requested(new_request->options, stream_type)) {
+ new_request->state[stream_type] = DeviceRequest::kRequested;
+ if (!enumeration_in_progress_[stream_type]) {
+ enumeration_in_progress_[stream_type] = true;
+ GetDeviceManager(stream_type)->EnumerateDevices();
}
}
@@ -312,9 +317,9 @@ void MediaStreamManager::Opened(MediaStreamType stream_type,
std::string label;
for (DeviceRequests::iterator request_it = requests_.begin();
request_it != requests_.end() && request == NULL; ++request_it) {
- if (stream_type == kAudioCapture) {
+ if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE) {
devices = &(request_it->second.audio_devices);
- } else if (stream_type == kVideoCapture) {
+ } else if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) {
devices = &(request_it->second.video_devices);
} else {
NOTREACHED();
@@ -405,7 +410,7 @@ void MediaStreamManager::DevicesEnumerated(
device.session_id =
GetDeviceManager(device_it->stream_type)->Open(device);
request.state[device_it->stream_type] = DeviceRequest::kOpening;
- if (stream_type == kAudioCapture)
+ if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE)
request.audio_devices.push_back(device);
else
request.video_devices.push_back(device);
@@ -433,9 +438,9 @@ void MediaStreamManager::Error(MediaStreamType stream_type,
for (DeviceRequests::iterator it = requests_.begin(); it != requests_.end();
++it) {
StreamDeviceInfoArray* devices = NULL;
- if (stream_type == kAudioCapture) {
+ if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE) {
devices = &(it->second.audio_devices);
- } else if (stream_type == kVideoCapture) {
+ } else if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) {
devices = &(it->second.video_devices);
} else {
NOTREACHED();
@@ -450,9 +455,10 @@ void MediaStreamManager::Error(MediaStreamType stream_type,
// 1. Already opened -> signal device failure and close device.
// Use device_idx to signal which of the devices encountered an
// error.
- if (stream_type == kAudioCapture) {
+ if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE) {
it->second.requester->AudioDeviceFailed(it->first, device_idx);
- } else if (stream_type == kVideoCapture) {
+ } else if (stream_type ==
+ content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) {
it->second.requester->VideoDeviceFailed(it->first, device_idx);
}
GetDeviceManager(stream_type)->Close(capture_session_id);
@@ -499,22 +505,27 @@ void MediaStreamManager::DevicesAccepted(const std::string& label,
GetDeviceManager(device_info.stream_type)->Open(device_info);
request_it->second.state[device_it->stream_type] =
DeviceRequest::kOpening;
- if (device_info.stream_type == kAudioCapture) {
+ if (device_info.stream_type ==
+ content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE) {
request_it->second.audio_devices.push_back(device_info);
- } else if (device_info.stream_type == kVideoCapture) {
+ } else if (device_info.stream_type ==
+ content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) {
request_it->second.video_devices.push_back(device_info);
} else {
NOTREACHED();
}
}
// Check if we received all stream types requested.
- if (Requested(request_it->second.options, kAudioCapture) &&
+ MediaStreamType stream_type =
+ content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE;
+ if (Requested(request_it->second.options, stream_type) &&
request_it->second.audio_devices.size() == 0) {
- request_it->second.state[kAudioCapture] = DeviceRequest::kError;
+ request_it->second.state[stream_type] = DeviceRequest::kError;
}
- if (Requested(request_it->second.options, kVideoCapture) &&
+ stream_type = content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE;
+ if (Requested(request_it->second.options, stream_type) &&
request_it->second.video_devices.size() == 0) {
- request_it->second.state[kVideoCapture] = DeviceRequest::kError;
+ request_it->second.state[stream_type] = DeviceRequest::kError;
}
return;
}
@@ -541,7 +552,8 @@ void MediaStreamManager::UseFakeDevice() {
bool MediaStreamManager::RequestDone(const DeviceRequest& request) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// Check if all devices are opened.
- if (Requested(request.options, kAudioCapture)) {
+ if (Requested(request.options,
+ content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE)) {
for (StreamDeviceInfoArray::const_iterator it =
request.audio_devices.begin(); it != request.audio_devices.end();
++it) {
@@ -550,7 +562,8 @@ bool MediaStreamManager::RequestDone(const DeviceRequest& request) const {
}
}
}
- if (Requested(request.options, kVideoCapture)) {
+ if (Requested(request.options,
+ content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE)) {
for (StreamDeviceInfoArray::const_iterator it =
request.video_devices.begin(); it != request.video_devices.end();
++it) {
@@ -565,9 +578,9 @@ bool MediaStreamManager::RequestDone(const DeviceRequest& request) const {
// Called to get media capture device manager of specified type.
MediaStreamProvider* MediaStreamManager::GetDeviceManager(
MediaStreamType stream_type) {
- if (stream_type == kVideoCapture) {
+ if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE) {
return video_capture_manager();
- } else if (stream_type == kAudioCapture) {
+ } else if (stream_type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE) {
return audio_input_device_manager();
}
NOTREACHED();
diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc
index 37ec5f7..4efcae5 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -144,8 +144,9 @@ void VideoCaptureManager::OnEnumerateDevices() {
for (media::VideoCaptureDevice::Names::iterator it =
device_names.begin(); it != device_names.end(); ++it) {
bool opened = DeviceOpened(*it);
- devices.push_back(StreamDeviceInfo(kVideoCapture, it->device_name,
- it->unique_id, opened));
+ devices.push_back(StreamDeviceInfo(
+ content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, it->device_name,
+ it->unique_id, opened));
}
PostOnDevicesEnumerated(devices);
@@ -272,7 +273,8 @@ void VideoCaptureManager::OnOpened(int capture_session_id) {
// Listener has been removed.
return;
}
- listener_->Opened(kVideoCapture, capture_session_id);
+ listener_->Opened(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE,
+ capture_session_id);
}
void VideoCaptureManager::OnClosed(int capture_session_id) {
@@ -281,7 +283,8 @@ void VideoCaptureManager::OnClosed(int capture_session_id) {
// Listener has been removed.
return;
}
- listener_->Closed(kVideoCapture, capture_session_id);
+ listener_->Closed(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE,
+ capture_session_id);
}
void VideoCaptureManager::OnDevicesEnumerated(
@@ -291,7 +294,8 @@ void VideoCaptureManager::OnDevicesEnumerated(
// Listener has been removed.
return;
}
- listener_->DevicesEnumerated(kVideoCapture, devices);
+ listener_->DevicesEnumerated(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE,
+ devices);
}
void VideoCaptureManager::OnError(int capture_session_id,
@@ -301,7 +305,8 @@ void VideoCaptureManager::OnError(int capture_session_id,
// Listener has been removed.
return;
}
- listener_->Error(kVideoCapture, capture_session_id, error);
+ listener_->Error(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE,
+ capture_session_id, error);
}
void VideoCaptureManager::PostOnOpened(int capture_session_id) {
@@ -485,7 +490,7 @@ media::VideoCaptureDevice* VideoCaptureManager::GetDeviceInternal(
// No devices available.
return NULL;
}
- StreamDeviceInfo device(kVideoCapture,
+ StreamDeviceInfo device(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE,
device_names.front().device_name,
device_names.front().unique_id, false);
diff --git a/content/browser/renderer_host/media/video_capture_manager_unittest.cc b/content/browser/renderer_host/media/video_capture_manager_unittest.cc
index 6700f9c..16a85a5 100644
--- a/content/browser/renderer_host/media/video_capture_manager_unittest.cc
+++ b/content/browser/renderer_host/media/video_capture_manager_unittest.cc
@@ -137,11 +137,13 @@ class VideoCaptureManagerTest : public testing::Test {
TEST_F(VideoCaptureManagerTest, CreateAndClose) {
InSequence s;
EXPECT_CALL(*listener_, DevicesEnumerated(_))
- .Times(1);
- EXPECT_CALL(*listener_, Opened(media_stream::kVideoCapture, _))
- .Times(1);
- EXPECT_CALL(*listener_, Closed(media_stream::kVideoCapture, _))
- .Times(1);
+ .Times(1);
+ EXPECT_CALL(*listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, _))
+ .Times(1);
+ EXPECT_CALL(*listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, _))
+ .Times(1);
vcm_->EnumerateDevices();
@@ -169,11 +171,13 @@ TEST_F(VideoCaptureManagerTest, CreateAndClose) {
TEST_F(VideoCaptureManagerTest, OpenTwice) {
InSequence s;
EXPECT_CALL(*listener_, DevicesEnumerated(_))
- .Times(1);
- EXPECT_CALL(*listener_, Opened(media_stream::kVideoCapture, _))
- .Times(2);
- EXPECT_CALL(*listener_, Closed(media_stream::kVideoCapture, _))
- .Times(2);
+ .Times(1);
+ EXPECT_CALL(*listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, _))
+ .Times(2);
+ EXPECT_CALL(*listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, _))
+ .Times(2);
vcm_->EnumerateDevices();
@@ -199,11 +203,13 @@ TEST_F(VideoCaptureManagerTest, OpenTwice) {
TEST_F(VideoCaptureManagerTest, OpenTwo) {
InSequence s;
EXPECT_CALL(*listener_, DevicesEnumerated(_))
- .Times(1);
- EXPECT_CALL(*listener_, Opened(media_stream::kVideoCapture, _))
- .Times(2);
- EXPECT_CALL(*listener_, Closed(media_stream::kVideoCapture, _))
- .Times(2);
+ .Times(1);
+ EXPECT_CALL(*listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, _))
+ .Times(2);
+ EXPECT_CALL(*listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, _))
+ .Times(2);
vcm_->EnumerateDevices();
@@ -229,17 +235,18 @@ TEST_F(VideoCaptureManagerTest, OpenTwo) {
TEST_F(VideoCaptureManagerTest, OpenNotExisting) {
InSequence s;
EXPECT_CALL(*listener_, DevicesEnumerated(_))
- .Times(1);
- EXPECT_CALL(*listener_, Error(media_stream::kVideoCapture, _,
- media_stream::kDeviceNotAvailable))
- .Times(1);
+ .Times(1);
+ EXPECT_CALL(*listener_, Error(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE,
+ _, media_stream::kDeviceNotAvailable))
+ .Times(1);
vcm_->EnumerateDevices();
// Wait to get device callback.
SyncWithVideoCaptureManagerThread();
- media_stream::MediaStreamType stream_type = media_stream::kVideoCapture;
+ media_stream::MediaStreamType stream_type =
+ content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE;
std::string device_name("device_doesnt_exist");
std::string device_id("id_doesnt_exist");
media_stream::StreamDeviceInfo dummy_device(stream_type, device_name,
@@ -256,10 +263,12 @@ TEST_F(VideoCaptureManagerTest, OpenNotExisting) {
// Start a device using "magic" id, i.e. call Start without calling Open.
TEST_F(VideoCaptureManagerTest, StartUsingId) {
InSequence s;
- EXPECT_CALL(*listener_, Opened(media_stream::kVideoCapture, _))
- .Times(1);
- EXPECT_CALL(*listener_, Closed(media_stream::kVideoCapture, _))
- .Times(1);
+ EXPECT_CALL(*listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, _))
+ .Times(1);
+ EXPECT_CALL(*listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, _))
+ .Times(1);
media::VideoCaptureParams capture_params;
capture_params.session_id =
@@ -284,11 +293,13 @@ TEST_F(VideoCaptureManagerTest, StartUsingId) {
TEST_F(VideoCaptureManagerTest, CloseWithoutStop) {
InSequence s;
EXPECT_CALL(*listener_, DevicesEnumerated(_))
- .Times(1);
- EXPECT_CALL(*listener_, Opened(media_stream::kVideoCapture, _))
- .Times(1);
- EXPECT_CALL(*listener_, Closed(media_stream::kVideoCapture, _))
- .Times(1);
+ .Times(1);
+ EXPECT_CALL(*listener_,
+ Opened(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, _))
+ .Times(1);
+ EXPECT_CALL(*listener_,
+ Closed(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, _))
+ .Times(1);
vcm_->EnumerateDevices();