| 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 4e104b4cbcd1ac3ec29ca0e70adada1181d3fc38..061a4984c5befb07e7c2d7ff29a51a84ee2c052d 100644
|
| --- a/content/browser/renderer_host/media/video_capture_manager.cc
|
| +++ b/content/browser/renderer_host/media/video_capture_manager.cc
|
| @@ -7,10 +7,12 @@
|
| #include <set>
|
|
|
| #include "base/bind.h"
|
| +#include "base/logging.h"
|
| #include "base/stl_util.h"
|
| #include "content/browser/renderer_host/media/video_capture_controller.h"
|
| #include "content/browser/renderer_host/media/video_capture_controller_event_handler.h"
|
| #include "content/public/browser/browser_thread.h"
|
| +#include "content/public/common/media_stream_request.h"
|
| #include "media/video/capture/fake_video_capture_device.h"
|
| #include "media/video/capture/video_capture_device.h"
|
|
|
| @@ -38,10 +40,13 @@ struct VideoCaptureManager::Controller {
|
| Handlers handlers;
|
| };
|
|
|
| -VideoCaptureManager::VideoCaptureManager()
|
| - : listener_(NULL),
|
| +VideoCaptureManager::VideoCaptureManager(
|
| + media_stream::MediaStreamType device_type)
|
| + : device_type_(device_type),
|
| + listener_(NULL),
|
| new_capture_session_id_(kFirstSessionId),
|
| use_fake_device_(false) {
|
| + DCHECK(content::IsVideoMediaType(device_type_));
|
| }
|
|
|
| VideoCaptureManager::~VideoCaptureManager() {
|
| @@ -134,8 +139,7 @@ void VideoCaptureManager::OnEnumerateDevices() {
|
| device_names.begin(); it != device_names.end(); ++it) {
|
| bool opened = DeviceOpened(*it);
|
| devices.push_back(StreamDeviceInfo(
|
| - content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE, it->device_name,
|
| - it->unique_id, opened));
|
| + device_type_, it->device_name, it->unique_id, opened));
|
| }
|
|
|
| PostOnDevicesEnumerated(devices);
|
| @@ -161,11 +165,25 @@ void VideoCaptureManager::OnOpen(int capture_session_id,
|
| vc_device_name.device_name = device.name;
|
| vc_device_name.unique_id = device.device_id;
|
|
|
| - if (!use_fake_device_) {
|
| - video_capture_device = media::VideoCaptureDevice::Create(vc_device_name);
|
| - } else {
|
| + if (use_fake_device_) {
|
| video_capture_device =
|
| media::FakeVideoCaptureDevice::Create(vc_device_name);
|
| + } else {
|
| + switch (device_type_) {
|
| + case content::MEDIA_DEVICE_VIDEO_CAPTURE:
|
| + video_capture_device =
|
| + media::VideoCaptureDevice::Create(vc_device_name);
|
| + break;
|
| + case content::MEDIA_TAB_VIDEO_CAPTURE:
|
| + // TODO(miu): Replace this stub with the actual implementation in a
|
| + // later change.
|
| + video_capture_device =
|
| + media::FakeVideoCaptureDevice::Create(vc_device_name);
|
| + break;
|
| + default:
|
| + NOTIMPLEMENTED();
|
| + break;
|
| + }
|
| }
|
| if (!video_capture_device) {
|
| PostOnError(capture_session_id, kDeviceNotAvailable);
|
| @@ -279,8 +297,7 @@ void VideoCaptureManager::OnOpened(int capture_session_id) {
|
| // Listener has been removed.
|
| return;
|
| }
|
| - listener_->Opened(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE,
|
| - capture_session_id);
|
| + listener_->Opened(device_type_, capture_session_id);
|
| }
|
|
|
| void VideoCaptureManager::OnClosed(int capture_session_id) {
|
| @@ -289,8 +306,7 @@ void VideoCaptureManager::OnClosed(int capture_session_id) {
|
| // Listener has been removed.
|
| return;
|
| }
|
| - listener_->Closed(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE,
|
| - capture_session_id);
|
| + listener_->Closed(device_type_, capture_session_id);
|
| }
|
|
|
| void VideoCaptureManager::OnDevicesEnumerated(
|
| @@ -300,8 +316,7 @@ void VideoCaptureManager::OnDevicesEnumerated(
|
| // Listener has been removed.
|
| return;
|
| }
|
| - listener_->DevicesEnumerated(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE,
|
| - devices);
|
| + listener_->DevicesEnumerated(device_type_, devices);
|
| }
|
|
|
| void VideoCaptureManager::OnError(int capture_session_id,
|
| @@ -311,8 +326,7 @@ void VideoCaptureManager::OnError(int capture_session_id,
|
| // Listener has been removed.
|
| return;
|
| }
|
| - listener_->Error(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE,
|
| - capture_session_id, error);
|
| + listener_->Error(device_type_, capture_session_id, error);
|
| }
|
|
|
| void VideoCaptureManager::PostOnOpened(int capture_session_id) {
|
| @@ -358,10 +372,21 @@ void VideoCaptureManager::GetAvailableDevices(
|
| media::VideoCaptureDevice::Names* device_names) {
|
| DCHECK(IsOnDeviceThread());
|
|
|
| - if (!use_fake_device_) {
|
| - media::VideoCaptureDevice::GetDeviceNames(device_names);
|
| - } else {
|
| + if (use_fake_device_) {
|
| media::FakeVideoCaptureDevice::GetDeviceNames(device_names);
|
| + return;
|
| + }
|
| +
|
| + switch (device_type_) {
|
| + case content::MEDIA_DEVICE_VIDEO_CAPTURE:
|
| + media::VideoCaptureDevice::GetDeviceNames(device_names);
|
| + break;
|
| + case content::MEDIA_TAB_VIDEO_CAPTURE:
|
| + NOTREACHED() << "enumeration of tab video devices";
|
| + break;
|
| + default:
|
| + NOTIMPLEMENTED();
|
| + break;
|
| }
|
| }
|
|
|
| @@ -491,9 +516,9 @@ media::VideoCaptureDevice* VideoCaptureManager::GetDeviceInternal(
|
| // No devices available.
|
| return NULL;
|
| }
|
| - StreamDeviceInfo device(content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE,
|
| - device_names.front().device_name,
|
| - device_names.front().unique_id, false);
|
| + StreamDeviceInfo device(
|
| + device_type_, device_names.front().device_name,
|
| + device_names.front().unique_id, false);
|
|
|
| // Call OnOpen to open using the first device in the list.
|
| OnOpen(capture_session_id, device);
|
|
|