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

Unified Diff: extensions/shell/browser/media_capture_util.cc

Issue 493453004: app_shell: Add audio and video capture support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (video-capture) audio and video work Created 6 years, 4 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: extensions/shell/browser/media_capture_util.cc
diff --git a/extensions/shell/browser/media_capture_util.cc b/extensions/shell/browser/media_capture_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fb0e870e65b25cc86dde5e674bc63813df1d8721
--- /dev/null
+++ b/extensions/shell/browser/media_capture_util.cc
@@ -0,0 +1,58 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "extensions/shell/browser/media_capture_util.h"
+
+#include "base/callback.h"
+#include "base/logging.h"
+#include "content/public/browser/media_capture_devices.h"
+
+using content::MediaCaptureDevices;
+using content::MediaStreamDevices;
+using content::MediaStreamUI;
+
+namespace extensions {
+namespace media_capture_util {
+
+// See also Chrome's MediaCaptureDevicesDispatcher.
James Cook 2014/08/20 18:17:16 I looked at refactoring MediaCaptureDevicesDispatc
+void GrantMediaStreamRequestWithFirstDevice(
+ content::WebContents* web_contents,
+ const content::MediaStreamRequest& request,
+ const content::MediaResponseCallback& callback) {
+ // app_shell only supports audio and video capture, not tab or screen capture.
+ DCHECK(request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE ||
+ request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE);
+
+ // app_shell does not support requesting a specific device ID.
+ DCHECK(request.requested_audio_device_id.empty() &&
+ request.requested_video_device_id.empty());
+
+ MediaStreamDevices devices;
+
+ if (request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE) {
+ // Use first available audio capture device.
+ const MediaStreamDevices& audio_devices =
+ MediaCaptureDevices::GetInstance()->GetAudioCaptureDevices();
+ if (!audio_devices.empty())
+ devices.push_back(audio_devices[0]);
+ }
+
+ if (request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE) {
+ // Use first available video capture device.
+ const MediaStreamDevices& video_devices =
+ MediaCaptureDevices::GetInstance()->GetVideoCaptureDevices();
+ if (!video_devices.empty())
+ devices.push_back(video_devices[0]);
+ }
+
+ // Don't show UI.
+ scoped_ptr<MediaStreamUI> ui;
+ callback.Run(devices,
+ devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE
+ : content::MEDIA_DEVICE_OK,
+ ui.Pass());
+}
+
+} // namespace media_capture_util
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698