Make sure webrtc::VideoSourceInterface is released on the main render thread.
[chromium-blink-merge.git] / content / public / browser / desktop_media_id.h
blob639a3c8d43054299e098fa289fdf7a4e8d9bc2ab
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_
6 #define CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h"
13 #include "content/common/content_export.h"
15 namespace aura {
16 class Window;
17 } // namespace aura
19 namespace content {
21 // Type used to identify desktop media sources. It's converted to string and
22 // stored in MediaStreamRequest::requested_video_device_id .
23 struct CONTENT_EXPORT DesktopMediaID {
24 public:
25 enum Type {
26 TYPE_NONE,
27 TYPE_SCREEN,
28 TYPE_WINDOW,
29 TYPE_AURA_WINDOW,
31 typedef intptr_t Id;
33 #if defined(USE_AURA)
34 // Assigns integer identifier to the |window| and returns DesktopMediaID of
35 // type TYPE_AURA_WINDOW that corresponds to that |window|.
36 static DesktopMediaID RegisterAuraWindow(aura::Window* window);
38 // For DesktopMediaID of type TYPE_AURA_WINDOW returns the |window| that was
39 // previously registered using RegisterAuraWindow().
40 static aura::Window* GetAuraWindowById(const DesktopMediaID& id);
41 #endif // defined(USE_AURA)
43 static DesktopMediaID Parse(const std::string& str);
45 DesktopMediaID()
46 : type(TYPE_NONE),
47 id(0) {
49 DesktopMediaID(Type type, Id id)
50 : type(type),
51 id(id) {
54 // Operators so that DesktopMediaID can be used with STL containers.
55 bool operator<(const DesktopMediaID& other) const {
56 return type < other.type || (type == other.type && id < other.id);
58 bool operator==(const DesktopMediaID& other) const {
59 return type == other.type && id == other.id;
62 bool is_null() { return type == TYPE_NONE; }
64 std::string ToString();
66 Type type;
67 Id id;
70 } // namespace content
72 #endif // CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_