summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-18 01:34:54 +0000
committerxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-18 01:34:54 +0000
commitebdb2eca64c263b1b3eff023546d7e06e0432131 (patch)
tree742c398f65e106e13de37cef2822a1f0f6f3c51e /content
parentffcf2f9b4acd11504a770dbb4efd5810f6387c1c (diff)
downloadchromium_src-ebdb2eca64c263b1b3eff023546d7e06e0432131.zip
chromium_src-ebdb2eca64c263b1b3eff023546d7e06e0432131.tar.gz
chromium_src-ebdb2eca64c263b1b3eff023546d7e06e0432131.tar.bz2
StreamDeviceInfo is basically a MediaStreamDevice but with two extra variables, and we can remove lots of code by letting StreamDeviceInfo have a MediaStreamDevice as a member variable instead.
Also MediaStreamType is typedef of MediaStreamDeviceType, I remember the reason for doing it is simply using a shorter name for MediaStreamDeviceType. We can also merge them to make the code more readable. BUG=137645 TEST=content_unittests Review URL: https://chromiumcodereview.appspot.com/11530007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173613 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/renderer_host/media/audio_input_device_manager.cc14
-rw-r--r--content/browser/renderer_host/media/audio_input_device_manager.h4
-rw-r--r--content/browser/renderer_host/media/audio_input_device_manager_unittest.cc4
-rw-r--r--content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc6
-rw-r--r--content/browser/renderer_host/media/media_stream_manager.cc53
-rw-r--r--content/browser/renderer_host/media/media_stream_ui_controller.cc2
-rw-r--r--content/browser/renderer_host/media/video_capture_manager.cc28
-rw-r--r--content/browser/renderer_host/media/video_capture_manager.h12
-rw-r--r--content/common/media/media_stream_messages.h6
-rw-r--r--content/common/media/media_stream_options.cc13
-rw-r--r--content/common/media/media_stream_options.h10
-rw-r--r--content/public/common/media_stream_request.cc16
-rw-r--r--content/public/common/media_stream_request.h27
-rw-r--r--content/renderer/media/media_stream_dependency_factory.cc2
-rw-r--r--content/renderer/media/media_stream_dependency_factory_unittest.cc8
-rw-r--r--content/renderer/media/media_stream_dispatcher.cc4
-rw-r--r--content/renderer/media/media_stream_dispatcher_unittest.cc44
-rw-r--r--content/renderer/media/media_stream_impl.cc4
-rw-r--r--content/renderer/media/mock_media_stream_dispatcher.cc12
-rw-r--r--content/renderer/pepper/pepper_device_enumeration_event_handler.cc6
20 files changed, 130 insertions, 145 deletions
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 6a89517..b42c541 100644
--- a/content/browser/renderer_host/media/audio_input_device_manager.cc
+++ b/content/browser/renderer_host/media/audio_input_device_manager.cc
@@ -107,7 +107,7 @@ void AudioInputDeviceManager::Start(
if (event_handlers_.insert(std::make_pair(session_id, handler)).second) {
StreamDeviceMap::const_iterator it = devices_.find(session_id);
if (it != devices_.end())
- device_id = it->second.device_id;
+ device_id = it->second.device.id;
}
// Post a callback through the AudioInputRendererHost to notify the renderer
@@ -175,7 +175,7 @@ void AudioInputDeviceManager::OpenOnDeviceThread(
FROM_HERE,
base::Bind(&AudioInputDeviceManager::OpenedOnIOThread,
this,
- device.stream_type, session_id));
+ device.device.type, session_id));
}
void AudioInputDeviceManager::CloseOnDeviceThread(int session_id) {
@@ -184,7 +184,7 @@ void AudioInputDeviceManager::CloseOnDeviceThread(int session_id) {
StreamDeviceMap::iterator it = devices_.find(session_id);
if (it == devices_.end())
return;
- const MediaStreamDeviceType stream_type = it->second.stream_type;
+ const MediaStreamType stream_type = it->second.device.type;
devices_.erase(it);
// Post a callback through the listener on IO thread since
@@ -207,15 +207,15 @@ void AudioInputDeviceManager::DevicesEnumeratedOnIOThread(
}
}
-void AudioInputDeviceManager::OpenedOnIOThread(
- MediaStreamDeviceType stream_type, int session_id) {
+void AudioInputDeviceManager::OpenedOnIOThread(MediaStreamType stream_type,
+ int session_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (listener_)
listener_->Opened(stream_type, session_id);
}
-void AudioInputDeviceManager::ClosedOnIOThread(
- MediaStreamDeviceType stream_type, int session_id) {
+void AudioInputDeviceManager::ClosedOnIOThread(MediaStreamType stream_type,
+ int session_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (listener_)
listener_->Closed(stream_type, session_id);
diff --git a/content/browser/renderer_host/media/audio_input_device_manager.h b/content/browser/renderer_host/media/audio_input_device_manager.h
index ffb16e4..86887d7 100644
--- a/content/browser/renderer_host/media/audio_input_device_manager.h
+++ b/content/browser/renderer_host/media/audio_input_device_manager.h
@@ -73,10 +73,10 @@ class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider {
void DevicesEnumeratedOnIOThread(StreamDeviceInfoArray* devices);
// Callback used by OpenOnDeviceThread(), called with the session_id
// referencing the opened device on IO thread.
- void OpenedOnIOThread(MediaStreamDeviceType type, int session_id);
+ void OpenedOnIOThread(MediaStreamType type, int session_id);
// Callback used by CloseOnDeviceThread(), called with the session_id
// referencing the closed device on IO thread.
- void ClosedOnIOThread(MediaStreamDeviceType type, int session_id);
+ void ClosedOnIOThread(MediaStreamType type, int session_id);
// Verifies that the calling thread is media stream device thread.
bool IsOnDeviceThread() const;
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 1f50184..11685af 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
@@ -290,7 +290,7 @@ TEST_F(AudioInputDeviceManagerTest, StartAndStopSession) {
manager_->Start(session_id[index], audio_input_event_handler.get());
EXPECT_CALL(*audio_input_event_handler,
- DeviceStarted(session_id[index], iter->device_id))
+ DeviceStarted(session_id[index], iter->device.id))
.Times(1);
message_loop_->RunUntilIdle();
@@ -335,7 +335,7 @@ TEST_F(AudioInputDeviceManagerTest, CloseWithoutStopSession) {
manager_->Start(session_id[index], audio_input_event_handler.get());
EXPECT_CALL(*audio_input_event_handler,
- DeviceStarted(session_id[index], iter->device_id))
+ DeviceStarted(session_id[index], iter->device.id))
.Times(1);
message_loop_->RunUntilIdle();
diff --git a/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc b/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc
index d50462f..951383e6 100644
--- a/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc
+++ b/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc
@@ -229,7 +229,7 @@ TEST_F(MediaStreamDispatcherHostTest, GenerateThreeStreams) {
EXPECT_EQ(host_->audio_devices_.size(), 0u);
EXPECT_EQ(host_->video_devices_.size(), 1u);
std::string label1 = host_->label_;
- std::string device_id1 = host_->video_devices_.front().device_id;
+ std::string device_id1 = host_->video_devices_.front().device.id;
// Check that we now have one opened streams.
EXPECT_EQ(host_->NumberOfStreams(), 1u);
@@ -246,7 +246,7 @@ TEST_F(MediaStreamDispatcherHostTest, GenerateThreeStreams) {
EXPECT_EQ(host_->audio_devices_.size(), 0u);
EXPECT_EQ(host_->video_devices_.size(), 1u);
std::string label2 = host_->label_;
- std::string device_id2 = host_->video_devices_.front().device_id;
+ std::string device_id2 = host_->video_devices_.front().device.id;
EXPECT_EQ(device_id1, device_id2);
EXPECT_NE(label1, label2);
@@ -267,7 +267,7 @@ TEST_F(MediaStreamDispatcherHostTest, GenerateThreeStreams) {
EXPECT_EQ(host_->audio_devices_.size(), 0u);
EXPECT_EQ(host_->video_devices_.size(), 1u);
std::string label3 = host_->label_;
- std::string device_id3 = host_->video_devices_.front().device_id;
+ std::string device_id3 = host_->video_devices_.front().device.id;
EXPECT_EQ(device_id1, device_id3);
EXPECT_NE(label1, label3);
EXPECT_NE(label2, label3);
diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc
index 062423a..31a15f4 100644
--- a/content/browser/renderer_host/media/media_stream_manager.cc
+++ b/content/browser/renderer_host/media/media_stream_manager.cc
@@ -311,7 +311,7 @@ void MediaStreamManager::CancelRequest(const std::string& label) {
for (StreamDeviceInfoArray::const_iterator device_it =
request->devices.begin();
device_it != request->devices.end(); ++device_it) {
- if (device_it->stream_type == stream_type) {
+ if (device_it->device.type == stream_type) {
GetDeviceManager(stream_type)->Close(device_it->session_id);
}
}
@@ -337,7 +337,7 @@ void MediaStreamManager::StopGeneratedStream(const std::string& label) {
for (StreamDeviceInfoArray::const_iterator device_it =
request->devices.begin();
device_it != request->devices.end(); ++device_it) {
- GetDeviceManager(device_it->stream_type)->Close(device_it->session_id);
+ GetDeviceManager(device_it->device.type)->Close(device_it->session_id);
}
if (request->type == MEDIA_GENERATE_STREAM &&
RequestDone(*request)) {
@@ -650,7 +650,7 @@ void MediaStreamManager::Opened(MediaStreamType stream_type,
devices = &(request_it->second->devices);
for (StreamDeviceInfoArray::iterator device_it = devices->begin();
device_it != devices->end(); ++device_it) {
- if (device_it->stream_type == stream_type &&
+ if (device_it->device.type == stream_type &&
device_it->session_id == capture_session_id) {
// We've found the request.
device_it->in_use = true;
@@ -671,7 +671,7 @@ void MediaStreamManager::Opened(MediaStreamType stream_type,
// they are.
for (StreamDeviceInfoArray::iterator device_it = devices->begin();
device_it != devices->end(); ++device_it) {
- if (device_it->stream_type != stream_type) {
+ if (device_it->device.type != stream_type) {
continue;
}
if (device_it->in_use == false) {
@@ -696,9 +696,9 @@ void MediaStreamManager::Opened(MediaStreamType stream_type,
StreamDeviceInfoArray audio_devices, video_devices;
for (StreamDeviceInfoArray::const_iterator device_it = devices->begin();
device_it != devices->end(); ++device_it) {
- if (IsAudioMediaType(device_it->stream_type)) {
+ if (IsAudioMediaType(device_it->device.type)) {
audio_devices.push_back(*device_it);
- } else if (IsVideoMediaType(device_it->stream_type)) {
+ } else if (IsVideoMediaType(device_it->device.type)) {
video_devices.push_back(*device_it);
} else {
NOTREACHED();
@@ -802,15 +802,15 @@ void MediaStreamManager::Error(MediaStreamType stream_type,
int video_device_idx = -1;
for (StreamDeviceInfoArray::iterator device_it = devices.begin();
device_it != devices.end(); ++device_it) {
- if (IsAudioMediaType(device_it->stream_type)) {
+ if (IsAudioMediaType(device_it->device.type)) {
++audio_device_idx;
- } else if (IsVideoMediaType(device_it->stream_type)) {
+ } else if (IsVideoMediaType(device_it->device.type)) {
++video_device_idx;
} else {
NOTREACHED();
continue;
}
- if (device_it->stream_type != stream_type ||
+ if (device_it->device.type != stream_type ||
device_it->session_id != capture_session_id) {
continue;
}
@@ -855,8 +855,7 @@ void MediaStreamManager::DevicesAccepted(const std::string& label,
MediaStreamDevices selected_devices;
for (StreamDeviceInfoArray::const_iterator it = devices.begin();
it != devices.end(); ++it) {
- selected_devices.push_back(MediaStreamDevice(
- it->stream_type, it->device_id, it->name));
+ selected_devices.push_back(it->device);
}
request->callback.Run(label, selected_devices);
@@ -875,26 +874,26 @@ void MediaStreamManager::DevicesAccepted(const std::string& label,
StreamDeviceInfo device_info = *device_it; // Make a copy.
// TODO(justinlin): Nicer way to do this?
- // Re-append the device_id since we lost it when posting request to UI.
- if (device_info.stream_type == content::MEDIA_TAB_VIDEO_CAPTURE ||
- device_info.stream_type == content::MEDIA_TAB_AUDIO_CAPTURE)
- device_info.device_id = request->requested_device_id;
+ // Re-append the device's id since we lost it when posting request to UI.
+ if (device_info.device.type == content::MEDIA_TAB_VIDEO_CAPTURE ||
+ device_info.device.type == content::MEDIA_TAB_AUDIO_CAPTURE)
+ device_info.device.id = request->requested_device_id;
// Set in_use to false to be able to track if this device has been
// opened. in_use might be true if the device type can be used in more
// than one session.
- DCHECK_EQ(request->state(device_it->stream_type),
+ DCHECK_EQ(request->state(device_it->device.type),
MEDIA_REQUEST_STATE_PENDING_APPROVAL);
device_info.in_use = false;
device_info.session_id =
- GetDeviceManager(device_info.stream_type)->Open(device_info);
- request->SetState(device_it->stream_type, MEDIA_REQUEST_STATE_OPENING);
+ GetDeviceManager(device_info.device.type)->Open(device_info);
+ request->SetState(device_it->device.type, MEDIA_REQUEST_STATE_OPENING);
request->devices.push_back(device_info);
- if (device_info.stream_type == request->options.audio_type) {
+ if (device_info.device.type == request->options.audio_type) {
found_audio = true;
- } else if (device_info.stream_type == request->options.video_type) {
+ } else if (device_info.device.type == request->options.video_type) {
found_video = true;
}
}
@@ -936,9 +935,7 @@ void MediaStreamManager::GetAvailableDevices(MediaStreamDevices* devices) {
audio_enumeration_cache_.devices.begin();
it != audio_enumeration_cache_.devices.end();
++it) {
- devices->push_back(MediaStreamDevice(it->stream_type,
- it->device_id,
- it->name));
+ devices->push_back(it->device);
}
}
@@ -947,9 +944,7 @@ void MediaStreamManager::GetAvailableDevices(MediaStreamDevices* devices) {
video_enumeration_cache_.devices.begin();
it != video_enumeration_cache_.devices.end();
++it) {
- devices->push_back(MediaStreamDevice(it->stream_type,
- it->device_id,
- it->name));
+ devices->push_back(it->device);
}
}
}
@@ -1006,8 +1001,7 @@ void MediaStreamManager::DevicesFromRequest(
const DeviceRequest& request, MediaStreamDevices* devices) {
for (StreamDeviceInfoArray::const_iterator it = request.devices.begin();
it != request.devices.end(); ++it) {
- devices->push_back(MediaStreamDevice(
- it->stream_type, it->device_id, it->name));
+ devices->push_back(it->device);
}
}
@@ -1024,8 +1018,7 @@ void MediaStreamManager::NotifyDevicesChanged(
MediaStreamDevices new_devices;
for (StreamDeviceInfoArray::const_iterator it = devices.begin();
it != devices.end(); ++it) {
- new_devices.push_back(MediaStreamDevice(
- it->stream_type, it->device_id, it->name));
+ new_devices.push_back(it->device);
}
if (IsAudioMediaType(stream_type)) {
diff --git a/content/browser/renderer_host/media/media_stream_ui_controller.cc b/content/browser/renderer_host/media/media_stream_ui_controller.cc
index 03ffaff..6ee8661 100644
--- a/content/browser/renderer_host/media/media_stream_ui_controller.cc
+++ b/content/browser/renderer_host/media/media_stream_ui_controller.cc
@@ -200,7 +200,7 @@ void MediaStreamUIController::PostResponse(
for (MediaStreamDevices::const_iterator dev = devices.begin();
dev != devices.end(); ++dev) {
device_list.push_back(StreamDeviceInfo(
- dev->type, dev->name, dev->device_id, false));
+ dev->type, dev->name, dev->id, false));
}
requester_->DevicesAccepted(label, device_list);
diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc
index 495b1f2..695ee4b 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -148,22 +148,22 @@ void VideoCaptureManager::OnOpen(int capture_session_id,
media::VideoCaptureDevice* video_capture_device = GetOpenedDevice(device);
if (video_capture_device) {
DeviceEntry& new_entry = devices_[capture_session_id];
- new_entry.stream_type = device.stream_type;
+ new_entry.stream_type = device.device.type;
new_entry.capture_device = video_capture_device;
- PostOnOpened(device.stream_type, capture_session_id);
+ PostOnOpened(device.device.type, capture_session_id);
return;
}
// Open the device.
media::VideoCaptureDevice::Name vc_device_name;
- vc_device_name.device_name = device.name;
- vc_device_name.unique_id = device.device_id;
+ vc_device_name.device_name = device.device.name;
+ vc_device_name.unique_id = device.device.id;
if (use_fake_device_) {
video_capture_device =
media::FakeVideoCaptureDevice::Create(vc_device_name);
} else {
- switch (device.stream_type) {
+ switch (device.device.type) {
case MEDIA_DEVICE_VIDEO_CAPTURE:
video_capture_device =
media::VideoCaptureDevice::Create(vc_device_name);
@@ -183,9 +183,9 @@ void VideoCaptureManager::OnOpen(int capture_session_id,
}
DeviceEntry& new_entry = devices_[capture_session_id];
- new_entry.stream_type = device.stream_type;
+ new_entry.stream_type = device.device.type;
new_entry.capture_device = video_capture_device;
- PostOnOpened(device.stream_type, capture_session_id);
+ PostOnOpened(device.device.type, capture_session_id);
}
void VideoCaptureManager::OnClose(int capture_session_id) {
@@ -286,7 +286,7 @@ void VideoCaptureManager::OnStop(
}
}
-void VideoCaptureManager::OnOpened(MediaStreamDeviceType stream_type,
+void VideoCaptureManager::OnOpened(MediaStreamType stream_type,
int capture_session_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!listener_) {
@@ -296,7 +296,7 @@ void VideoCaptureManager::OnOpened(MediaStreamDeviceType stream_type,
listener_->Opened(stream_type, capture_session_id);
}
-void VideoCaptureManager::OnClosed(MediaStreamDeviceType stream_type,
+void VideoCaptureManager::OnClosed(MediaStreamType stream_type,
int capture_session_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!listener_) {
@@ -317,7 +317,7 @@ void VideoCaptureManager::OnDevicesEnumerated(
listener_->DevicesEnumerated(MEDIA_DEVICE_VIDEO_CAPTURE, devices);
}
-void VideoCaptureManager::OnError(MediaStreamDeviceType stream_type,
+void VideoCaptureManager::OnError(MediaStreamType stream_type,
int capture_session_id,
MediaStreamProviderError error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
@@ -329,7 +329,7 @@ void VideoCaptureManager::OnError(MediaStreamDeviceType stream_type,
}
void VideoCaptureManager::PostOnOpened(
- MediaStreamDeviceType stream_type, int capture_session_id) {
+ MediaStreamType stream_type, int capture_session_id) {
DCHECK(IsOnDeviceThread());
BrowserThread::PostTask(BrowserThread::IO,
FROM_HERE,
@@ -338,7 +338,7 @@ void VideoCaptureManager::PostOnOpened(
}
void VideoCaptureManager::PostOnClosed(
- MediaStreamDeviceType stream_type, int capture_session_id) {
+ MediaStreamType stream_type, int capture_session_id) {
DCHECK(IsOnDeviceThread());
BrowserThread::PostTask(BrowserThread::IO,
FROM_HERE,
@@ -358,7 +358,7 @@ void VideoCaptureManager::PostOnDevicesEnumerated(
void VideoCaptureManager::PostOnError(int capture_session_id,
MediaStreamProviderError error) {
DCHECK(IsOnDeviceThread());
- MediaStreamDeviceType stream_type = MEDIA_DEVICE_VIDEO_CAPTURE;
+ MediaStreamType stream_type = MEDIA_DEVICE_VIDEO_CAPTURE;
VideoCaptureDevices::const_iterator it = devices_.find(capture_session_id);
if (it != devices_.end())
stream_type = it->second.stream_type;
@@ -404,7 +404,7 @@ media::VideoCaptureDevice* VideoCaptureManager::GetOpenedDevice(
for (VideoCaptureDevices::iterator it = devices_.begin();
it != devices_.end(); it++) {
- if (device_info.device_id ==
+ if (device_info.device.id ==
it->second.capture_device->device_name().unique_id) {
return it->second.capture_device;
}
diff --git a/content/browser/renderer_host/media/video_capture_manager.h b/content/browser/renderer_host/media/video_capture_manager.h
index acb6ddb..76fd120 100644
--- a/content/browser/renderer_host/media/video_capture_manager.h
+++ b/content/browser/renderer_host/media/video_capture_manager.h
@@ -103,16 +103,16 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
VideoCaptureControllerEventHandler* handler);
// Executed on Browser::IO thread to call Listener.
- void OnOpened(MediaStreamDeviceType type, int capture_session_id);
- void OnClosed(MediaStreamDeviceType type, int capture_session_id);
+ void OnOpened(MediaStreamType type, int capture_session_id);
+ void OnClosed(MediaStreamType type, int capture_session_id);
void OnDevicesEnumerated(const StreamDeviceInfoArray& devices);
- void OnError(MediaStreamDeviceType type, int capture_session_id,
+ void OnError(MediaStreamType type, int capture_session_id,
MediaStreamProviderError error);
// Executed on device thread to make sure Listener is called from
// Browser::IO thread.
- void PostOnOpened(MediaStreamDeviceType type, int capture_session_id);
- void PostOnClosed(MediaStreamDeviceType type, int capture_session_id);
+ void PostOnOpened(MediaStreamType type, int capture_session_id);
+ void PostOnClosed(MediaStreamType type, int capture_session_id);
void PostOnDevicesEnumerated(const StreamDeviceInfoArray& devices);
void PostOnError(int capture_session_id, MediaStreamProviderError error);
@@ -136,7 +136,7 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
// VideoCaptureManager owns all VideoCaptureDevices and is responsible for
// deleting the instances when they are not used any longer.
struct DeviceEntry {
- MediaStreamDeviceType stream_type;
+ MediaStreamType stream_type;
media::VideoCaptureDevice* capture_device; // Maybe shared across sessions.
};
typedef std::map<int, DeviceEntry> VideoCaptureDevices;
diff --git a/content/common/media/media_stream_messages.h b/content/common/media/media_stream_messages.h
index 658eb48..6e0fb9f 100644
--- a/content/common/media/media_stream_messages.h
+++ b/content/common/media/media_stream_messages.h
@@ -26,9 +26,9 @@ IPC_STRUCT_TRAITS_BEGIN(content::StreamOptions)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::StreamDeviceInfo)
- IPC_STRUCT_TRAITS_MEMBER(stream_type)
- IPC_STRUCT_TRAITS_MEMBER(name)
- IPC_STRUCT_TRAITS_MEMBER(device_id)
+ IPC_STRUCT_TRAITS_MEMBER(device.type)
+ IPC_STRUCT_TRAITS_MEMBER(device.name)
+ IPC_STRUCT_TRAITS_MEMBER(device.id)
IPC_STRUCT_TRAITS_MEMBER(in_use)
IPC_STRUCT_TRAITS_MEMBER(session_id)
IPC_STRUCT_TRAITS_END()
diff --git a/content/common/media/media_stream_options.cc b/content/common/media/media_stream_options.cc
index d4a872b..95ced6f 100644
--- a/content/common/media/media_stream_options.cc
+++ b/content/common/media/media_stream_options.cc
@@ -27,26 +27,23 @@ StreamOptions::StreamOptions(MediaStreamType audio_type,
const int StreamDeviceInfo::kNoId = -1;
StreamDeviceInfo::StreamDeviceInfo()
- : stream_type(MEDIA_NO_SERVICE),
- in_use(false),
+ : in_use(false),
session_id(kNoId) {}
StreamDeviceInfo::StreamDeviceInfo(MediaStreamType service_param,
const std::string& name_param,
const std::string& device_param,
bool opened)
- : stream_type(service_param),
- name(name_param),
- device_id(device_param),
+ : device(service_param, device_param, name_param),
in_use(opened),
session_id(kNoId) {}
// static
bool StreamDeviceInfo::IsEqual(const StreamDeviceInfo& first,
const StreamDeviceInfo& second) {
- return first.stream_type == second.stream_type &&
- first.name == second.name &&
- first.device_id == second.device_id &&
+ return first.device.type == second.device.type &&
+ first.device.name == second.device.name &&
+ first.device.id == second.device.id &&
first.in_use == second.in_use &&
first.session_id == second.session_id;
}
diff --git a/content/common/media/media_stream_options.h b/content/common/media/media_stream_options.h
index c268398..2856a48 100644
--- a/content/common/media/media_stream_options.h
+++ b/content/common/media/media_stream_options.h
@@ -19,8 +19,6 @@ CONTENT_EXPORT extern const char kMediaStreamSource[];
CONTENT_EXPORT extern const char kMediaStreamSourceId[];
CONTENT_EXPORT extern const char kMediaStreamSourceTab[];
-typedef MediaStreamDeviceType MediaStreamType;
-
// Callback to deliver the result of a media request. |label| is the string
// to identify the request,
typedef base::Callback< void(const std::string&, const MediaStreamDevices&) >
@@ -54,13 +52,7 @@ struct CONTENT_EXPORT StreamDeviceInfo {
static bool IsEqual(const StreamDeviceInfo& first,
const StreamDeviceInfo& second);
- // Describes the capture type.
- MediaStreamType stream_type;
- // Friendly name of the device.
- std::string name;
- // Unique name of a device. Even if there are multiple devices with the same
- // friendly name connected to the computer, this will be unique.
- std::string device_id;
+ MediaStreamDevice device;
// Set to true if the device has been opened, false otherwise.
bool in_use;
// Id for this capture session. Unique for all sessions of the same type.
diff --git a/content/public/common/media_stream_request.cc b/content/public/common/media_stream_request.cc
index 3113ddb..016807c 100644
--- a/content/public/common/media_stream_request.cc
+++ b/content/public/common/media_stream_request.cc
@@ -6,22 +6,24 @@
namespace content {
-bool IsAudioMediaType(MediaStreamDeviceType type) {
+bool IsAudioMediaType(MediaStreamType type) {
return (type == content::MEDIA_DEVICE_AUDIO_CAPTURE ||
type == content::MEDIA_TAB_AUDIO_CAPTURE);
}
-bool IsVideoMediaType(MediaStreamDeviceType type) {
+bool IsVideoMediaType(MediaStreamType type) {
return (type == content::MEDIA_DEVICE_VIDEO_CAPTURE ||
type == content::MEDIA_TAB_VIDEO_CAPTURE);
}
+MediaStreamDevice::MediaStreamDevice() : type(MEDIA_NO_SERVICE) {}
+
MediaStreamDevice::MediaStreamDevice(
- MediaStreamDeviceType type,
- const std::string& device_id,
+ MediaStreamType type,
+ const std::string& id,
const std::string& name)
: type(type),
- device_id(device_id),
+ id(id),
name(name) {
}
@@ -32,8 +34,8 @@ MediaStreamRequest::MediaStreamRequest(
int render_view_id,
const GURL& security_origin,
MediaStreamRequestType request_type,
- MediaStreamDeviceType audio_type,
- MediaStreamDeviceType video_type)
+ MediaStreamType audio_type,
+ MediaStreamType video_type)
: render_process_id(render_process_id),
render_view_id(render_view_id),
security_origin(security_origin),
diff --git a/content/public/common/media_stream_request.h b/content/public/common/media_stream_request.h
index 497a163..e50d4e9 100644
--- a/content/public/common/media_stream_request.h
+++ b/content/public/common/media_stream_request.h
@@ -16,7 +16,7 @@
namespace content {
// Types of media streams.
-enum MediaStreamDeviceType {
+enum MediaStreamType {
MEDIA_NO_SERVICE = 0,
// A device provided by the operating system (e.g., webcam input).
@@ -40,24 +40,26 @@ enum MediaStreamRequestType {
// Convenience predicates to determine whether the given type represents some
// audio or some video device.
-CONTENT_EXPORT bool IsAudioMediaType(MediaStreamDeviceType type);
-CONTENT_EXPORT bool IsVideoMediaType(MediaStreamDeviceType type);
+CONTENT_EXPORT bool IsAudioMediaType(MediaStreamType type);
+CONTENT_EXPORT bool IsVideoMediaType(MediaStreamType type);
// TODO(xians): Change the structs to classes.
// Represents one device in a request for media stream(s).
struct CONTENT_EXPORT MediaStreamDevice {
+ MediaStreamDevice();
+
MediaStreamDevice(
- MediaStreamDeviceType type,
- const std::string& device_id,
+ MediaStreamType type,
+ const std::string& id,
const std::string& name);
~MediaStreamDevice();
// The device's type.
- MediaStreamDeviceType type;
+ MediaStreamType type;
// The device's unique ID.
- std::string device_id;
+ std::string id;
// The device's "friendly" name. Not guaranteed to be unique.
std::string name;
@@ -65,8 +67,7 @@ struct CONTENT_EXPORT MediaStreamDevice {
typedef std::vector<MediaStreamDevice> MediaStreamDevices;
-typedef std::map<MediaStreamDeviceType, MediaStreamDevices>
- MediaStreamDeviceMap;
+typedef std::map<MediaStreamType, MediaStreamDevices> MediaStreamDeviceMap;
// Represents a request for media streams (audio/video).
struct CONTENT_EXPORT MediaStreamRequest {
@@ -75,8 +76,8 @@ struct CONTENT_EXPORT MediaStreamRequest {
int render_view_id,
const GURL& security_origin,
MediaStreamRequestType request_type,
- MediaStreamDeviceType audio_type,
- MediaStreamDeviceType video_type);
+ MediaStreamType audio_type,
+ MediaStreamType video_type);
~MediaStreamRequest();
@@ -96,10 +97,10 @@ struct CONTENT_EXPORT MediaStreamRequest {
MediaStreamRequestType request_type;
// Flag to indicate if the request contains audio.
- MediaStreamDeviceType audio_type;
+ MediaStreamType audio_type;
// Flag to indicate if the request contains video.
- MediaStreamDeviceType video_type;
+ MediaStreamType video_type;
};
} // namespace content
diff --git a/content/renderer/media/media_stream_dependency_factory.cc b/content/renderer/media/media_stream_dependency_factory.cc
index 1e55519..69a3572 100644
--- a/content/renderer/media/media_stream_dependency_factory.cc
+++ b/content/renderer/media/media_stream_dependency_factory.cc
@@ -215,7 +215,7 @@ void MediaStreamDependencyFactory::CreateNativeMediaSources(
NOTIMPLEMENTED();
continue;
}
- const bool is_screencast = (source_data->device_info().stream_type ==
+ const bool is_screencast = (source_data->device_info().device.type ==
content::MEDIA_TAB_VIDEO_CAPTURE);
source_data->SetVideoSource(
CreateVideoSource(source_data->device_info().session_id,
diff --git a/content/renderer/media/media_stream_dependency_factory_unittest.cc b/content/renderer/media/media_stream_dependency_factory_unittest.cc
index 8c97bd9..2e99cad 100644
--- a/content/renderer/media/media_stream_dependency_factory_unittest.cc
+++ b/content/renderer/media/media_stream_dependency_factory_unittest.cc
@@ -58,8 +58,8 @@ class MediaStreamDependencyFactoryTest : public ::testing::Test {
if (audio) {
StreamDeviceInfo info;
- info.stream_type = content::MEDIA_DEVICE_AUDIO_CAPTURE;
- info.name = "audio";
+ info.device.type = content::MEDIA_DEVICE_AUDIO_CAPTURE;
+ info.device.name = "audio";
info.session_id = 99;
audio_sources[0].initialize("audio",
WebKit::WebMediaStreamSource::TypeAudio,
@@ -69,8 +69,8 @@ class MediaStreamDependencyFactoryTest : public ::testing::Test {
}
if (video) {
StreamDeviceInfo info;
- info.stream_type = content::MEDIA_DEVICE_VIDEO_CAPTURE;
- info.name = "video";
+ info.device.type = content::MEDIA_DEVICE_VIDEO_CAPTURE;
+ info.device.name = "video";
info.session_id = 98;
video_sources[0].initialize("video",
WebKit::WebMediaStreamSource::TypeVideo,
diff --git a/content/renderer/media/media_stream_dispatcher.cc b/content/renderer/media/media_stream_dispatcher.cc
index dcf9d09..d5eafe8 100644
--- a/content/renderer/media/media_stream_dispatcher.cc
+++ b/content/renderer/media/media_stream_dispatcher.cc
@@ -331,9 +331,9 @@ void MediaStreamDispatcher::OnDeviceOpened(
if (request.ipc_request == request_id) {
Stream new_stream;
new_stream.handler = request.handler;
- if (IsAudioMediaType(device_info.stream_type)) {
+ if (IsAudioMediaType(device_info.device.type)) {
new_stream.audio_array.push_back(device_info);
- } else if (IsVideoMediaType(device_info.stream_type)) {
+ } else if (IsVideoMediaType(device_info.device.type)) {
new_stream.video_array.push_back(device_info);
} else {
NOTREACHED();
diff --git a/content/renderer/media/media_stream_dispatcher_unittest.cc b/content/renderer/media/media_stream_dispatcher_unittest.cc
index f080fea..d272f43 100644
--- a/content/renderer/media/media_stream_dispatcher_unittest.cc
+++ b/content/renderer/media/media_stream_dispatcher_unittest.cc
@@ -26,9 +26,9 @@ const int kRequestId3 = 30;
const int kRequestId4 = 40;
static const char kLabel[] = "test";
-const MediaStreamDeviceType kAudioType = MEDIA_DEVICE_AUDIO_CAPTURE;
-const MediaStreamDeviceType kVideoType = MEDIA_DEVICE_VIDEO_CAPTURE;
-const MediaStreamDeviceType kNoAudioType = MEDIA_NO_SERVICE;
+const MediaStreamType kAudioType = MEDIA_DEVICE_AUDIO_CAPTURE;
+const MediaStreamType kVideoType = MEDIA_DEVICE_VIDEO_CAPTURE;
+const MediaStreamType kNoAudioType = MEDIA_NO_SERVICE;
class MockMediaStreamDispatcherEventHandler
: public MediaStreamDispatcherEventHandler,
@@ -99,15 +99,15 @@ TEST(MediaStreamDispatcherTest, BasicStream) {
StreamDeviceInfoArray audio_device_array(1);
StreamDeviceInfo audio_device_info;
- audio_device_info.name = "Microphone";
- audio_device_info.stream_type = kAudioType;
+ audio_device_info.device.name = "Microphone";
+ audio_device_info.device.type = kAudioType;
audio_device_info.session_id = kAudioSessionId;
audio_device_array[0] = audio_device_info;
StreamDeviceInfoArray video_device_array(1);
StreamDeviceInfo video_device_info;
- video_device_info.name = "Camera";
- video_device_info.stream_type = kVideoType;
+ video_device_info.device.name = "Camera";
+ video_device_info.device.type = kVideoType;
video_device_info.session_id = kVideoSessionId;
video_device_array[0] = video_device_info;
@@ -180,8 +180,8 @@ TEST(MediaStreamDispatcherTest, BasicStreamForDevice) {
StreamDeviceInfoArray video_device_array(1);
StreamDeviceInfo video_device_info;
- video_device_info.name = "Fake Video Capture Device";
- video_device_info.stream_type = kVideoType;
+ video_device_info.device.name = "Fake Video Capture Device";
+ video_device_info.device.type = kVideoType;
video_device_info.session_id = kVideoSessionId;
video_device_array[0] = video_device_info;
@@ -251,9 +251,9 @@ TEST(MediaStreamDispatcherTest, BasicVideoDevice) {
StreamDeviceInfoArray video_device_array(1);
StreamDeviceInfo video_device_info;
- video_device_info.name = "Camera";
- video_device_info.device_id = "device_path";
- video_device_info.stream_type = kVideoType;
+ video_device_info.device.name = "Camera";
+ video_device_info.device.id = "device_path";
+ video_device_info.device.type = kVideoType;
video_device_info.session_id = kVideoSessionId;
video_device_array[0] = video_device_info;
@@ -268,13 +268,13 @@ TEST(MediaStreamDispatcherTest, BasicVideoDevice) {
int ipc_request_id3 = dispatcher->next_ipc_id_;
dispatcher->OpenDevice(kRequestId3, handler1.get()->AsWeakPtr(),
- video_device_info.device_id,
+ video_device_info.device.id,
kVideoType,
security_origin);
int ipc_request_id4 = dispatcher->next_ipc_id_;
EXPECT_NE(ipc_request_id3, ipc_request_id4);
dispatcher->OpenDevice(kRequestId4, handler1.get()->AsWeakPtr(),
- video_device_info.device_id,
+ video_device_info.device.id,
kVideoType,
security_origin);
EXPECT_EQ(dispatcher->requests_.size(), size_t(2));
@@ -340,15 +340,15 @@ TEST(MediaStreamDispatcherTest, TestFailure) {
StreamDeviceInfoArray audio_device_array(1);
StreamDeviceInfo audio_device_info;
- audio_device_info.name = "Microphone";
- audio_device_info.stream_type = kAudioType;
+ audio_device_info.device.name = "Microphone";
+ audio_device_info.device.type = kAudioType;
audio_device_info.session_id = kAudioSessionId;
audio_device_array[0] = audio_device_info;
StreamDeviceInfoArray video_device_array(1);
StreamDeviceInfo video_device_info;
- video_device_info.name = "Camera";
- video_device_info.stream_type = kVideoType;
+ video_device_info.device.name = "Camera";
+ video_device_info.device.type = kVideoType;
video_device_info.session_id = kVideoSessionId;
video_device_array[0] = video_device_info;
@@ -385,15 +385,15 @@ TEST(MediaStreamDispatcherTest, CancelGenerateStream) {
// Complete the creation of stream1.
StreamDeviceInfo audio_device_info;
- audio_device_info.name = "Microphone";
- audio_device_info.stream_type = kAudioType;
+ audio_device_info.device.name = "Microphone";
+ audio_device_info.device.type = kAudioType;
audio_device_info.session_id = kAudioSessionId;
StreamDeviceInfoArray audio_device_array(1);
audio_device_array[0] = audio_device_info;
StreamDeviceInfo video_device_info;
- video_device_info.name = "Camera";
- video_device_info.stream_type = kVideoType;
+ video_device_info.device.name = "Camera";
+ video_device_info.device.type = kVideoType;
video_device_info.session_id = kVideoSessionId;
StreamDeviceInfoArray video_device_array(1);
video_device_array[0] = video_device_info;
diff --git a/content/renderer/media/media_stream_impl.cc b/content/renderer/media/media_stream_impl.cc
index d100f5f..b7a935c 100644
--- a/content/renderer/media/media_stream_impl.cc
+++ b/content/renderer/media/media_stream_impl.cc
@@ -93,7 +93,7 @@ static int GetSessionId(const WebKit::WebMediaStreamDescriptor& descriptor) {
return -1;
}
DVLOG(1) << "local audio track source name: "
- << source_data->device_info().name;
+ << source_data->device_info().device.name;
return source_data->device_info().session_id;
}
@@ -117,7 +117,7 @@ void CreateWebKitSourceVector(
webkit_sources[i].initialize(
UTF8ToUTF16(source_id),
type,
- UTF8ToUTF16(devices[i].name));
+ UTF8ToUTF16(devices[i].device.name));
webkit_sources[i].setExtraData(
new content::MediaStreamSourceExtraData(devices[i]));
}
diff --git a/content/renderer/media/mock_media_stream_dispatcher.cc b/content/renderer/media/mock_media_stream_dispatcher.cc
index 142cf09..ac8963a 100644
--- a/content/renderer/media/mock_media_stream_dispatcher.cc
+++ b/content/renderer/media/mock_media_stream_dispatcher.cc
@@ -32,17 +32,17 @@ void MockMediaStreamDispatcher::GenerateStream(
if (IsAudioMediaType(components.audio_type)) {
StreamDeviceInfo audio;
- audio.device_id = "audio_device_id";
- audio.name = "microphone";
- audio.stream_type = components.audio_type;
+ audio.device.id = "audio_device_id";
+ audio.device.name = "microphone";
+ audio.device.type = components.audio_type;
audio.session_id = request_id;
audio_array_.push_back(audio);
}
if (IsVideoMediaType(components.video_type)) {
StreamDeviceInfo video;
- video.device_id = "video_device_id";
- video.name = "usb video camera";
- video.stream_type = components.video_type;
+ video.device.id = "video_device_id";
+ video.device.name = "usb video camera";
+ video.device.type = components.video_type;
video.session_id = request_id;
video_array_.push_back(video);
}
diff --git a/content/renderer/pepper/pepper_device_enumeration_event_handler.cc b/content/renderer/pepper/pepper_device_enumeration_event_handler.cc
index 42634df..b23df8a 100644
--- a/content/renderer/pepper/pepper_device_enumeration_event_handler.cc
+++ b/content/renderer/pepper/pepper_device_enumeration_event_handler.cc
@@ -13,10 +13,10 @@ namespace {
ppapi::DeviceRefData FromStreamDeviceInfo(const StreamDeviceInfo& info) {
ppapi::DeviceRefData data;
- data.id = info.device_id;
- data.name = info.name;
+ data.id = info.device.id;
+ data.name = info.device.name;
data.type = PepperDeviceEnumerationEventHandler::FromMediaStreamType(
- info.stream_type);
+ info.device.type);
return data;
}