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 MEETING, | |
33 HANGOUT, | |
34 GENERIC | |
35 }; | |
36 | |
37 MediaSink(const MediaSink::Id& sink_id, | |
38 const std::string& name, | |
39 const IconType icon_type); | |
40 MediaSink(const MediaSink& other); | |
41 MediaSink(); | |
42 | |
43 ~MediaSink(); | |
44 | |
45 void set_sink_id(const MediaSink::Id& sink_id) { sink_id_ = sink_id; } | |
46 const MediaSink::Id& id() const { return sink_id_; } | |
47 | |
48 void set_name(const std::string& name) { name_ = name; } | |
49 const std::string& name() const { return name_; } | |
50 | |
51 void set_description(const std::string& description) { | |
52 description_ = description; | |
53 } | |
54 const base::Optional<std::string>& description() const { | |
55 return description_; | |
56 } | |
57 | |
58 void set_domain(const std::string& domain) { domain_ = domain; } | |
59 const base::Optional<std::string>& domain() const { return domain_; } | |
60 | |
61 void set_icon_type(IconType icon_type) { icon_type_ = icon_type; } | |
62 IconType icon_type() const { return icon_type_; } | |
63 | |
64 // This method only compares IDs. | |
65 bool Equals(const MediaSink& other) const; | |
66 | |
67 // This method compares all fields. | |
68 bool operator==(const MediaSink& other) const; | |
69 bool operator!=(const MediaSink& other) const; | |
70 | |
71 // Compares |this| to |other| first by their icon types, then their names | |
72 // using |collator|, and finally their IDs. | |
73 bool CompareUsingCollator(const MediaSink& other, | |
74 const icu::Collator* collator) const; | |
75 | |
76 // For storing in sets and in maps as keys. | |
77 struct Compare { | |
78 bool operator()(const MediaSink& sink1, const MediaSink& sink2) const { | |
79 return sink1.id() < sink2.id(); | |
80 } | |
81 }; | |
82 | |
83 private: | |
84 // Unique identifier for the MediaSink. | |
85 MediaSink::Id sink_id_; | |
86 | |
87 // Descriptive name of the MediaSink. | |
88 std::string name_; | |
89 | |
90 // Optional description of the MediaSink. | |
91 base::Optional<std::string> description_; | |
92 | |
93 // Optional domain of the MediaSink. | |
94 base::Optional<std::string> domain_; | |
95 | |
96 // The type of icon that corresponds with the MediaSink. | |
97 IconType icon_type_ = IconType::GENERIC; | |
98 }; | |
99 | |
100 } // namespace media_router | |
101 | |
102 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ | |
OLD | NEW |