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_
10 #include "base/basictypes.h"
11 #include "content/common/content_export.h"
17 #endif // defined(USE_AURA)
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
{
33 // Represents an "unset" value for either |id| or |aura_id|.
34 static const Id kNullId
= 0;
37 // Assigns integer identifier to the |window| and returns its DesktopMediaID.
38 static DesktopMediaID
RegisterAuraWindow(Type type
, aura::Window
* window
);
40 // Returns the Window that was previously registered using
41 // RegisterAuraWindow(), else nullptr.
42 static aura::Window
* GetAuraWindowById(const DesktopMediaID
& id
);
43 #endif // defined(USE_AURA)
45 static DesktopMediaID
Parse(const std::string
& str
);
47 // TODO(hans): Maybe move inline again after crbug.com/488634.
50 DesktopMediaID(Type type
, Id id
)
55 // Operators so that DesktopMediaID can be used with STL containers.
56 bool operator<(const DesktopMediaID
& other
) const {
58 return (type
< other
.type
||
59 (type
== other
.type
&&
60 (id
< other
.id
|| (id
== other
.id
&&
61 aura_id
< other
.aura_id
))));
63 return type
< other
.type
|| (type
== other
.type
&& id
< other
.id
);
66 bool operator==(const DesktopMediaID
& other
) const {
68 return type
== other
.type
&& id
== other
.id
&& aura_id
== other
.aura_id
;
70 return type
== other
.type
&& id
== other
.id
;
74 bool is_null() { return type
== TYPE_NONE
; }
76 std::string
ToString();
78 Type type
= TYPE_NONE
;
80 // The IDs referring to the target native screen or window. |id| will be
81 // non-null if and only if it refers to a native screen/window. |aura_id|
82 // will be non-null if and only if it refers to an Aura window. Note that is
83 // it possible for both of these to be non-null, which means both IDs are
84 // referring to the same logical window.
87 // TODO(miu): Make this an int, after clean-up for http://crbug.com/513490.
92 } // namespace content
94 #endif // CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_