Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / media / video_capture_manager.cc
index 28242f4..a547037 100644 (file)
@@ -65,13 +65,14 @@ VideoCaptureManager::~VideoCaptureManager() {
   DCHECK(devices_.empty());
 }
 
-void VideoCaptureManager::Register(MediaStreamProviderListener* listener,
-                                   base::MessageLoopProxy* device_thread_loop) {
+void VideoCaptureManager::Register(
+    MediaStreamProviderListener* listener,
+    const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner) {
   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
   DCHECK(!listener_);
-  DCHECK(!device_loop_.get());
+  DCHECK(!device_task_runner_.get());
   listener_ = listener;
-  device_loop_ = device_thread_loop;
+  device_task_runner_ = device_task_runner;
 }
 
 void VideoCaptureManager::Unregister() {
@@ -84,7 +85,7 @@ void VideoCaptureManager::EnumerateDevices(MediaStreamType stream_type) {
   DVLOG(1) << "VideoCaptureManager::EnumerateDevices, type " << stream_type;
   DCHECK(listener_);
   base::PostTaskAndReplyWithResult(
-      device_loop_, FROM_HERE,
+      device_task_runner_, FROM_HERE,
       base::Bind(&VideoCaptureManager::GetAvailableDevicesInfoOnDeviceThread,
                  this, stream_type, devices_info_cache_),
       base::Bind(&VideoCaptureManager::OnDevicesInfoEnumerated, this,
@@ -246,7 +247,7 @@ void VideoCaptureManager::StartCaptureForClient(
     DVLOG(1) << "VideoCaptureManager starting device (type = "
              << entry->stream_type << ", id = " << entry->id << ")";
 
-    device_loop_->PostTask(
+    device_task_runner_->PostTask(
         FROM_HERE,
         base::Bind(
             &VideoCaptureManager::DoStartDeviceOnDeviceThread,
@@ -305,24 +306,26 @@ bool VideoCaptureManager::GetDeviceSupportedFormats(
   return true;
 }
 
-bool VideoCaptureManager::GetDeviceFormatInUse(
+bool VideoCaptureManager::GetDeviceFormatsInUse(
     media::VideoCaptureSessionId capture_session_id,
-    media::VideoCaptureFormat* format_in_use) {
+    media::VideoCaptureFormats* formats_in_use) {
   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+  DCHECK(formats_in_use->empty());
 
   std::map<media::VideoCaptureSessionId, MediaStreamDevice>::iterator it =
       sessions_.find(capture_session_id);
   if (it == sessions_.end())
     return false;
-  DVLOG(1) << "GetDeviceFormatInUse for device: " << it->second.name;
+  DVLOG(1) << "GetDeviceFormatsInUse for device: " << it->second.name;
 
-  // Return the currently in-use format of the device, if it's started.
+  // Return the currently in-use format(s) of the device, if it's started.
   DeviceEntry* device_in_use =
       GetDeviceEntryForMediaStreamDevice(it->second);
-  if (!device_in_use)
-    return false;
-  *format_in_use =
-      device_in_use->video_capture_controller->GetVideoCaptureFormat();
+  if (device_in_use) {
+    // Currently only one format-in-use is supported at the VCC level.
+    formats_in_use->push_back(
+        device_in_use->video_capture_controller->GetVideoCaptureFormat());
+  }
   return true;
 }
 
@@ -380,7 +383,7 @@ void VideoCaptureManager::OnDevicesInfoEnumerated(
 }
 
 bool VideoCaptureManager::IsOnDeviceThread() const {
-  return device_loop_->BelongsToCurrentThread();
+  return device_task_runner_->BelongsToCurrentThread();
 }
 
 VideoCaptureManager::DeviceInfos
@@ -503,7 +506,7 @@ void VideoCaptureManager::DestroyDeviceEntryIfNoClients(DeviceEntry* entry) {
     // DeviceEntry, VideoCaptureController, and VideoCaptureDevice.
     devices_.erase(entry);
     entry->video_capture_controller.reset();
-    device_loop_->PostTask(
+    device_task_runner_->PostTask(
         FROM_HERE,
         base::Bind(&VideoCaptureManager::DoStopDeviceOnDeviceThread, this,
                    base::Owned(entry)));