summaryrefslogtreecommitdiffstats
path: root/content/public
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-09 06:53:28 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-09 06:53:28 +0000
commita6cb8bca67f3cf4daf2a9ef86ade994efb7554d4 (patch)
treebc2f769ee81bc9a97be48e8f6e45f5713fceb42f /content/public
parent6eb4d94bf5cb9c8896c2544eeea9e81c800e38b9 (diff)
downloadchromium_src-a6cb8bca67f3cf4daf2a9ef86ade994efb7554d4.zip
chromium_src-a6cb8bca67f3cf4daf2a9ef86ade994efb7554d4.tar.gz
chromium_src-a6cb8bca67f3cf4daf2a9ef86ade994efb7554d4.tar.bz2
Add DesktopMediaId type to identify desktop media source.
Also replaced content::MEDIA_SCREEN_VIDEO_CAPTURE with content::MEDIA_DESKTOP_VIDEO_CAPTURE which will be used to identify all types of desktop media sources. BUG=237907 R=jam@chromium.org, xians@chromium.org Review URL: https://codereview.chromium.org/22370010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216617 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/public')
-rw-r--r--content/public/common/desktop_media_id.cc41
-rw-r--r--content/public/common/desktop_media_id.h57
-rw-r--r--content/public/common/media_stream_request.cc3
-rw-r--r--content/public/common/media_stream_request.h8
4 files changed, 105 insertions, 4 deletions
diff --git a/content/public/common/desktop_media_id.cc b/content/public/common/desktop_media_id.cc
new file mode 100644
index 0000000..82ebe9c
--- /dev/null
+++ b/content/public/common/desktop_media_id.cc
@@ -0,0 +1,41 @@
+// Copyright 2013 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 "content/public/common/desktop_media_id.h"
+
+namespace content {
+
+// static
+DesktopMediaID DesktopMediaID::Parse(const std::string& str) {
+ if (str == "screen")
+ return DesktopMediaID(TYPE_SCREEN, 0);
+
+ std::string window_prefix("window:");
+ if (StartsWithASCII(str, window_prefix, true)) {
+ int64 id;
+ if (!base::StringToInt64(str.substr(window_prefix.size()), &id))
+ return DesktopMediaID(TYPE_NONE, 0);
+ return DesktopMediaID(TYPE_WINDOW, id);
+ }
+
+ return DesktopMediaID(TYPE_NONE, 0);
+}
+
+std::string DesktopMediaID::ToString() {
+ switch (type) {
+ case TYPE_NONE:
+ NOTREACHED();
+ return std::string();
+
+ case TYPE_SCREEN:
+ return "screen";
+
+ case TYPE_WINDOW:
+ return "window:" + base::Int64ToString(id);
+ }
+ NOTREACHED();
+ return std::string();
+}
+
+} // namespace content
diff --git a/content/public/common/desktop_media_id.h b/content/public/common/desktop_media_id.h
new file mode 100644
index 0000000..a863872
--- /dev/null
+++ b/content/public/common/desktop_media_id.h
@@ -0,0 +1,57 @@
+// Copyright 2013 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.
+
+#ifndef CONTENT_PUBLIC_COMMON_DESKTOP_MEDIA_ID_H_
+#define CONTENT_PUBLIC_COMMON_DESKTOP_MEDIA_ID_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+// Type used to identify desktop media sources. It's converted to string and
+// stored in MediaStreamRequest::requested_video_device_id .
+struct CONTENT_EXPORT DesktopMediaID {
+ public:
+ enum Type {
+ TYPE_NONE,
+ TYPE_SCREEN,
+ TYPE_WINDOW,
+ };
+ typedef intptr_t Id;
+
+ static DesktopMediaID Parse(const std::string& str);
+
+ DesktopMediaID()
+ : type(TYPE_NONE),
+ id(0) {
+ }
+ DesktopMediaID(Type type, Id id)
+ : type(type),
+ id(id) {
+ }
+
+ // Operators so that DesktopMediaID can be used with STL containers.
+ bool operator<(const DesktopMediaID& other) const {
+ return type < other.type || (type == other.type && id < other.id);
+ }
+ bool operator==(const DesktopMediaID& other) const {
+ return type == other.type && id == other.id;
+ }
+
+ bool is_null() { return type == TYPE_NONE; }
+
+ std::string ToString();
+
+ Type type;
+ Id id;
+};
+
+} // namespace content
+
+#endif // CONTENT_PUBLIC_COMMON_DESKTOP_MEDIA_ID_H_
diff --git a/content/public/common/media_stream_request.cc b/content/public/common/media_stream_request.cc
index 2c2f9d8..e3ad35b 100644
--- a/content/public/common/media_stream_request.cc
+++ b/content/public/common/media_stream_request.cc
@@ -17,8 +17,7 @@ bool IsAudioMediaType(MediaStreamType type) {
bool IsVideoMediaType(MediaStreamType type) {
return (type == content::MEDIA_DEVICE_VIDEO_CAPTURE ||
type == content::MEDIA_TAB_VIDEO_CAPTURE ||
- type == content::MEDIA_SCREEN_VIDEO_CAPTURE ||
- type == content::MEDIA_WINDOW_VIDEO_CAPTURE);
+ type == content::MEDIA_DESKTOP_VIDEO_CAPTURE);
}
MediaStreamDevice::MediaStreamDevice() : type(MEDIA_NO_SERVICE) {}
diff --git a/content/public/common/media_stream_request.h b/content/public/common/media_stream_request.h
index d01e7a8..cbbf232 100644
--- a/content/public/common/media_stream_request.h
+++ b/content/public/common/media_stream_request.h
@@ -26,14 +26,18 @@ enum MediaStreamType {
MEDIA_DEVICE_VIDEO_CAPTURE,
// Mirroring of a browser tab.
+ //
+ // TODO(serygeu): Remove these values and use MEDIA_DESKTOP_VIDEO_CAPTURE and
+ // MEDIA_DESKTOP_AUDIO_CAPTURE.
MEDIA_TAB_AUDIO_CAPTURE,
MEDIA_TAB_VIDEO_CAPTURE,
// Desktop media sources.
- MEDIA_SCREEN_VIDEO_CAPTURE,
- MEDIA_WINDOW_VIDEO_CAPTURE,
+ MEDIA_DESKTOP_VIDEO_CAPTURE,
// Capture system audio (post-mix loopback stream).
+ //
+ // TODO(sergeyu): Replace with MEDIA_DESKTOP_AUDIO_CAPTURE.
MEDIA_SYSTEM_AUDIO_CAPTURE,
NUM_MEDIA_TYPES