OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/optional.h" | |
10 #include "third_party/icu/source/common/unicode/uversion.h" | 11 #include "third_party/icu/source/common/unicode/uversion.h" |
11 | 12 |
12 namespace U_ICU_NAMESPACE { | 13 namespace U_ICU_NAMESPACE { |
13 class Collator; | 14 class Collator; |
14 } // namespace U_ICU_NAMESPACE | 15 } // namespace U_ICU_NAMESPACE |
15 | 16 |
16 namespace media_router { | 17 namespace media_router { |
17 | 18 |
18 // Represents a sink to which media can be routed. | 19 // Represents a sink to which media can be routed. |
20 // TODO(zhaobin): convert MediaSink into a struct. | |
19 class MediaSink { | 21 class MediaSink { |
20 public: | 22 public: |
21 using Id = std::string; | 23 using Id = std::string; |
22 | 24 |
23 // IconTypes are listed in the order in which sinks should be sorted. | 25 // IconTypes are listed in the order in which sinks should be sorted. |
24 // The order must stay in sync with | 26 // The order must stay in sync with |
25 // chrome/browser/resources/media_router/media_router_data.js. | 27 // chrome/browser/resources/media_router/media_router_data.js. |
26 enum IconType { | 28 enum IconType { |
27 CAST, | 29 CAST, |
28 CAST_AUDIO_GROUP, | 30 CAST_AUDIO_GROUP, |
29 CAST_AUDIO, | 31 CAST_AUDIO, |
30 HANGOUT, | 32 HANGOUT, |
31 GENERIC | 33 GENERIC |
32 }; | 34 }; |
33 | 35 |
36 // SinkType indicates if sink is discovered by DIAL / CAST / other (e.g. | |
37 // cloud) media sink services. Each SinkType value, with the exception of | |
38 // GENERIC, corresponds to a subtype of MediaSink. | |
39 enum class SinkType { | |
imcheng
2017/02/11 01:00:21
Can be removed.
zhaobin
2017/02/14 02:08:49
Done.
| |
40 DIAL, // DialMediaSink | |
41 CAST, // CastMediaSink | |
42 GENERIC | |
43 }; | |
44 | |
34 MediaSink(const MediaSink::Id& sink_id, | 45 MediaSink(const MediaSink::Id& sink_id, |
35 const std::string& name, | 46 const std::string& name, |
36 const IconType icon_type); | 47 const IconType icon_type); |
48 MediaSink(); | |
37 | 49 |
38 MediaSink(const MediaSink& other); | 50 MediaSink(const MediaSink& other); |
39 | 51 |
40 ~MediaSink(); | 52 virtual ~MediaSink(); |
imcheng
2017/02/11 01:00:21
revert virtual
zhaobin
2017/02/14 02:08:49
Done.
| |
41 | 53 |
54 SinkType type() const { return type_; } | |
55 void set_sink_id(const MediaSink::Id& sink_id) { sink_id_ = sink_id; } | |
42 const MediaSink::Id& id() const { return sink_id_; } | 56 const MediaSink::Id& id() const { return sink_id_; } |
57 | |
58 void set_name(const std::string& name) { name_ = name; } | |
43 const std::string& name() const { return name_; } | 59 const std::string& name() const { return name_; } |
44 void set_description(const std::string& description) { | 60 void set_description(const std::string& description) { |
45 description_ = description; | 61 description_ = description; |
46 } | 62 } |
47 const std::string& description() const { return description_; } | 63 const base::Optional<std::string>& description() const { |
64 return description_; | |
65 } | |
48 void set_domain(const std::string& domain) { domain_ = domain; } | 66 void set_domain(const std::string& domain) { domain_ = domain; } |
49 const std::string& domain() const { return domain_; } | 67 const base::Optional<std::string>& domain() const { return domain_; } |
68 void set_icon_type(IconType icon_type) { icon_type_ = icon_type; } | |
50 IconType icon_type() const { return icon_type_; } | 69 IconType icon_type() const { return icon_type_; } |
51 | 70 |
71 // void set_model_name(const std::string& model_name) { | |
imcheng
2017/02/11 01:00:21
Remove
zhaobin
2017/02/14 02:08:48
Done.
| |
72 // model_name_ = model_name; | |
73 // } | |
74 // const base::Optional<std::string>& model_name() const { return model_name_; | |
75 // } | |
76 | |
77 // This method only compares IDs. | |
52 bool Equals(const MediaSink& other) const; | 78 bool Equals(const MediaSink& other) const; |
53 | 79 |
54 // Compares |this| to |other| first by their icon types, then their names | 80 // Compares |this| to |other| first by their icon types, then their names |
55 // using |collator|, and finally their IDs. | 81 // using |collator|, and finally their IDs. |
56 bool CompareUsingCollator(const MediaSink& other, | 82 bool CompareUsingCollator(const MediaSink& other, |
57 const icu::Collator* collator) const; | 83 const icu::Collator* collator) const; |
58 | 84 |
59 // For storing in sets and in maps as keys. | 85 // For storing in sets and in maps as keys. |
60 struct Compare { | 86 struct Compare { |
61 bool operator()(const MediaSink& sink1, const MediaSink& sink2) const { | 87 bool operator()(const MediaSink& sink1, const MediaSink& sink2) const { |
62 return sink1.id() < sink2.id(); | 88 return sink1.id() < sink2.id(); |
63 } | 89 } |
64 }; | 90 }; |
65 | 91 |
92 protected: | |
imcheng
2017/02/11 01:00:21
Remove ctor and SinkType
zhaobin
2017/02/14 02:08:48
Done.
| |
93 MediaSink(const MediaSink::Id& sink_id, | |
94 const std::string& name, | |
95 const IconType icon_type, | |
96 const SinkType sink_type); | |
97 | |
98 // Type of the MediaSink. | |
99 SinkType type_; | |
100 | |
66 private: | 101 private: |
67 // Unique identifier for the MediaSink. | 102 // Unique identifier for the MediaSink. |
68 MediaSink::Id sink_id_; | 103 MediaSink::Id sink_id_; |
69 | 104 |
70 // Descriptive name of the MediaSink. | 105 // Descriptive name of the MediaSink. |
71 std::string name_; | 106 std::string name_; |
72 | 107 |
73 // Optional description of the MediaSink. | 108 base::Optional<std::string> description_; |
74 std::string description_; | |
75 | 109 |
76 // Optional domain of the MediaSink. | 110 base::Optional<std::string> domain_; |
77 std::string domain_; | |
78 | 111 |
79 // The type of icon that corresponds with the MediaSink. | 112 // The type of icon that corresponds with the MediaSink. |
80 IconType icon_type_; | 113 IconType icon_type_; |
114 | |
115 // Model name of the sink, if it represents a physical device. | |
116 base::Optional<std::string> model_name_; | |
imcheng
2017/02/11 01:00:21
This can be removed as it is now in TypedMediaSink
zhaobin
2017/02/14 02:08:48
Done.
| |
81 }; | 117 }; |
82 | 118 |
83 } // namespace media_router | 119 } // namespace media_router |
84 | 120 |
85 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ | 121 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ |
OLD | NEW |