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

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

Issue 10912004: Begin adding support for tab mirroring via the MediaStream audio/video capturing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed MEDIA_USER_*_CAPTURE to MEDIA_*_DEVICE_CAPTURE, as suggested by wjia@. Created 8 years, 3 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 4e104b4cbcd1ac3ec29ca0e70adada1181d3fc38..c1f9e05c19b75eac5bf1092322c8119ac7ebe14d 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,24 @@ 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_VIDEO_DEVICE_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.
+ video_capture_device =
+ media::FakeVideoCaptureDevice::Create(vc_device_name);
+ break;
+ default:
+ NOTIMPLEMENTED();
+ break;
+ }
}
if (!video_capture_device) {
PostOnError(capture_session_id, kDeviceNotAvailable);
@@ -279,8 +296,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 +305,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 +315,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 +325,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 +371,25 @@ 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);
no longer working on chromium 2012/09/05 14:19:41 nit, early return here.
miu 2012/09/06 04:40:35 Done.
+ } else {
+ switch (device_type_) {
+ case content::MEDIA_VIDEO_DEVICE_CAPTURE:
+ media::VideoCaptureDevice::GetDeviceNames(device_names);
+ break;
+ case content::MEDIA_TAB_VIDEO_CAPTURE: {
+ // TODO(miu): Replace this stub with the actual implementation.
+ media::VideoCaptureDevice::Name name;
+ name.unique_id = "/dev/video0";
+ name.device_name = "Stub Tab Video Capture";
+ device_names->push_back(name);
+ break;
+ }
+ default:
+ NOTIMPLEMENTED();
+ break;
+ }
}
}
@@ -491,9 +519,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);

Powered by Google App Engine
This is Rietveld 408576698