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

Unified Diff: content/browser/renderer_host/media/video_capture_manager.cc

Issue 2169013002: Change class VideoCaptureDevice::Name to struct VideoCaptureDeviceDescriptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactoring of VideoCaptureDeviceFactory interface Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/media/video_capture_manager.cc
diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc
index 310c8f8ba844aacc3efad9da0009807ee13bd6b4..7a8560878e5658d14ee4752b6088810ced054c6e 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -281,7 +281,7 @@ void VideoCaptureManager::EnumerateDevices(MediaStreamType stream_type) {
// Bind a callback to ConsolidateDevicesInfoOnDeviceThread() with an argument
// for another callback to OnDevicesInfoEnumerated() to be run in the current
// loop, i.e. IO loop. Pass a timer for UMA histogram collection.
- base::Callback<void(std::unique_ptr<VideoCaptureDevice::Names>)>
+ base::Callback<void(std::unique_ptr<VideoCaptureDeviceDescriptors>)>
devices_enumerated_callback = base::Bind(
&VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread, this,
media::BindToCurrentLoop(
@@ -290,8 +290,9 @@ void VideoCaptureManager::EnumerateDevices(MediaStreamType stream_type) {
stream_type, devices_info_cache_);
// OK to use base::Unretained() since we own the VCDFactory and |this| is
// bound in |devices_enumerated_callback|.
- device_task_runner_->PostTask(FROM_HERE,
- base::Bind(&media::VideoCaptureDeviceFactory::EnumerateDeviceNames,
+ device_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&media::VideoCaptureDeviceFactory::EnumerateDeviceDescriptors,
base::Unretained(video_capture_device_factory_.get()),
devices_enumerated_callback));
}
@@ -432,14 +433,15 @@ void VideoCaptureManager::HandleQueuedStartRequest() {
// held in the browser-side VideoCaptureDevice::Name structure.
const media::VideoCaptureDeviceInfo* found = GetDeviceInfoById(entry->id);
if (found) {
- entry->video_capture_controller()->DoLogOnIOThread(base::StringPrintf(
- "Starting device: id: %s, name: %s, api: %s",
- found->name.id().c_str(), found->name.GetNameAndModel().c_str(),
- found->name.GetCaptureApiTypeString()));
+ entry->video_capture_controller()->DoLogOnIOThread(
+ base::StringPrintf("Starting device: id: %s, name: %s, api: %s",
+ found->descriptor.device_id.c_str(),
+ found->GetNameAndModel().c_str(),
+ found->descriptor.GetCaptureApiTypeString()));
start_capture_function = base::Bind(
&VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread, this,
- found->name, request->params(),
+ found->descriptor, request->params(),
base::Passed(entry->video_capture_controller()->NewDeviceClient()));
} else {
// Errors from DoStartDeviceCaptureOnDeviceThread go via
@@ -524,14 +526,14 @@ void VideoCaptureManager::OnDeviceStarted(
std::unique_ptr<media::VideoCaptureDevice>
VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread(
- const VideoCaptureDevice::Name& name,
+ const VideoCaptureDeviceDescriptor& descriptor,
const media::VideoCaptureParams& params,
std::unique_ptr<VideoCaptureDevice::Client> device_client) {
SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime");
DCHECK(IsOnDeviceThread());
std::unique_ptr<VideoCaptureDevice> video_capture_device;
- video_capture_device = video_capture_device_factory_->Create(name);
+ video_capture_device = video_capture_device_factory_->Create(descriptor);
if (!video_capture_device) {
device_client->OnError(FROM_HERE, "Could not create capture device");
@@ -925,8 +927,8 @@ void VideoCaptureManager::OnDevicesInfoEnumerated(
// StreamDeviceInfo for return purposes.
StreamDeviceInfoArray devices;
for (const auto& it : devices_info_cache_) {
- devices.push_back(StreamDeviceInfo(
- stream_type, it.name.GetNameAndModel(), it.name.id()));
+ devices.push_back(StreamDeviceInfo(stream_type, it.GetNameAndModel(),
emircan 2016/07/25 22:56:40 Use emplace_back().
+ it.descriptor.device_id));
}
listener_->DevicesEnumerated(stream_type, devices);
}
@@ -940,28 +942,28 @@ void VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread(
on_devices_enumerated_callback,
MediaStreamType stream_type,
const media::VideoCaptureDeviceInfos& old_device_info_cache,
- std::unique_ptr<VideoCaptureDevice::Names> names_snapshot) {
+ std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors_snapshot) {
DCHECK(IsOnDeviceThread());
// Construct |new_devices_info_cache| with the cached devices that are still
// present in the system, and remove their names from |names_snapshot|, so we
// keep there the truly new devices.
media::VideoCaptureDeviceInfos new_devices_info_cache;
for (const auto& device_info : old_device_info_cache) {
- for (VideoCaptureDevice::Names::iterator it = names_snapshot->begin();
- it != names_snapshot->end(); ++it) {
- if (device_info.name.id() == it->id()) {
+ for (VideoCaptureDeviceDescriptors::iterator it =
+ descriptors_snapshot->begin();
+ it != descriptors_snapshot->end(); ++it) {
+ if (device_info.descriptor.device_id == it->device_id) {
new_devices_info_cache.push_back(device_info);
- names_snapshot->erase(it);
+ descriptors_snapshot->erase(it);
break;
}
}
}
- // Get the supported capture formats for the new devices in |names_snapshot|.
- for (const auto& it : *names_snapshot) {
- media::VideoCaptureDeviceInfo device_info(it, media::VideoCaptureFormats());
- video_capture_device_factory_->GetDeviceSupportedFormats(
- it, &(device_info.supported_formats));
+ // Get the device info for the new devices in |names_snapshot|.
+ for (const auto& it : *descriptors_snapshot) {
+ media::VideoCaptureDeviceInfo device_info;
+ video_capture_device_factory_->GetDeviceInfo(it, &device_info);
ConsolidateCaptureFormats(&device_info.supported_formats);
new_devices_info_cache.push_back(device_info);
}
@@ -1044,7 +1046,7 @@ VideoCaptureManager::DeviceEntry* VideoCaptureManager::GetDeviceEntryBySerialId(
media::VideoCaptureDeviceInfo* VideoCaptureManager::GetDeviceInfoById(
const std::string& id) {
for (auto& it : devices_info_cache_) {
- if (it.name.id() == id)
+ if (it.descriptor.device_id == id)
return &it;
}
return nullptr;

Powered by Google App Engine
This is Rietveld 408576698