OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ | |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/optional.h" | |
11 #include "third_party/icu/source/common/unicode/uversion.h" | |
12 | |
13 namespace U_ICU_NAMESPACE { | |
14 class Collator; | |
15 } // namespace U_ICU_NAMESPACE | |
16 | |
17 namespace media_router { | |
18 | |
19 // Represents a sink to which media can be routed. | |
20 // TODO(zhaobin): convert MediaSink into a struct. | |
21 class MediaSink { | |
22 public: | |
23 using Id = std::string; | |
24 | |
25 // IconTypes are listed in the order in which sinks should be sorted. | |
26 // The order must stay in sync with | |
27 // chrome/browser/resources/media_router/media_router_data.js. | |
28 enum IconType { | |
29 CAST, | |
30 CAST_AUDIO_GROUP, | |
31 CAST_AUDIO, | |
32 HANGOUT, | |
33 GENERIC | |
34 }; | |
35 | |
36 MediaSink(const MediaSink::Id& sink_id, | |
37 const std::string& name, | |
38 const IconType icon_type); | |
39 MediaSink(const MediaSink& other); | |
40 MediaSink(); | |
41 | |
42 ~MediaSink(); | |
43 | |
44 void set_sink_id(const MediaSink::Id& sink_id) { sink_id_ = sink_id; } | |
45 const MediaSink::Id& id() const { return sink_id_; } | |
46 | |
47 void set_name(const std::string& name) { name_ = name; } | |
48 const std::string& name() const { return name_; } | |
49 | |
50 void set_description(const std::string& description) { | |
51 description_ = description; | |
52 } | |
53 const base::Optional<std::string>& description() const { | |
54 return description_; | |
55 } | |
56 | |
57 void set_domain(const std::string& domain) { domain_ = domain; } | |
58 const base::Optional<std::string>& domain() const { return domain_; } | |
59 | |
60 void set_icon_type(IconType icon_type) { icon_type_ = icon_type; } | |
61 IconType icon_type() const { return icon_type_; } | |
62 | |
63 // This method only compares IDs. | |
64 bool Equals(const MediaSink& other) const; | |
65 | |
66 // This method compares all fields. | |
67 bool operator==(const MediaSink& other) const; | |
68 bool operator!=(const MediaSink& other) const; | |
69 | |
70 // Compares |this| to |other| first by their icon types, then their names | |
71 // using |collator|, and finally their IDs. | |
72 bool CompareUsingCollator(const MediaSink& other, | |
73 const icu::Collator* collator) const; | |
74 | |
75 // For storing in sets and in maps as keys. | |
76 struct Compare { | |
77 bool operator()(const MediaSink& sink1, const MediaSink& sink2) const { | |
78 return sink1.id() < sink2.id(); | |
79 } | |
80 }; | |
81 | |
82 private: | |
83 // Unique identifier for the MediaSink. | |
84 MediaSink::Id sink_id_; | |
85 | |
86 // Descriptive name of the MediaSink. | |
87 std::string name_; | |
88 | |
89 // Optional description of the MediaSink. | |
90 base::Optional<std::string> description_; | |
91 | |
92 // Optional domain of the MediaSink. | |
93 base::Optional<std::string> domain_; | |
94 | |
95 // The type of icon that corresponds with the MediaSink. | |
96 IconType icon_type_ = IconType::GENERIC; | |
97 }; | |
98 | |
99 } // namespace media_router | |
100 | |
101 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ | |
OLD | NEW |