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_ROUTE_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/containers/small_map.h" | 10 #include "base/containers/small_map.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/media/router/media_sink.h" | 13 #include "chrome/browser/media/router/media_sink.h" |
14 #include "chrome/browser/media/router/media_source.h" | 14 #include "chrome/browser/media/router/media_source.h" |
15 #include "content/public/common/presentation_session.h" | 15 #include "content/public/common/presentation_session.h" |
16 | 16 |
17 namespace media_router { | 17 namespace media_router { |
18 | 18 |
19 // MediaRoute objects contain the status and metadata of a routing | 19 // MediaRoute objects contain the status and metadata of a routing |
mark a. foltz
2017/02/09 22:53:51
Optional to fix: it might be helpful to describe e
| |
20 // operation. The fields are immutable and reflect the route status | 20 // operation. The fields are immutable and reflect the route status |
mark a. foltz
2017/02/09 22:53:51
The comments about immutability need to be removed
| |
21 // only at the time of object creation. Updated route statuses must | 21 // only at the time of object creation. Updated route statuses must |
22 // be retrieved as new MediaRoute objects from the Media Router. | 22 // be retrieved as new MediaRoute objects from the Media Router. |
23 // | 23 // |
24 // TODO(mfoltz): Convert to a simple struct and remove uncommon parameters from | 24 // TODO(mfoltz): Convert to a simple struct and remove uncommon parameters from |
mark a. foltz
2017/02/09 22:53:51
If you are committed to keeping this design, then
| |
25 // the ctor. | 25 // the ctor. |
26 class MediaRoute { | 26 class MediaRoute { |
27 public: | 27 public: |
28 using Id = std::string; | 28 using Id = std::string; |
29 | 29 |
30 // |media_route_id|: ID of the route. | 30 // |media_route_id|: ID of the route. |
31 // |media_source|: Description of source of the route. | 31 // |media_source|: Description of source of the route. |
32 // |media_sink|: The sink that is receiving the media. | 32 // |media_sink|: The sink that is receiving the media. |
33 // |description|: Description of the route to be displayed. | 33 // |description|: Description of the route to be displayed. |
34 // |is_local|: true if the route was created from this browser. | 34 // |is_local|: true if the route was created from this browser. |
35 // |custom_controller_path|: custom controller path if it is given by route | 35 // |custom_controller_path|: custom controller path if it is given by route |
36 // provider. empty otherwise. | 36 // provider. empty otherwise. |
37 // |for_display|: Set to true if this route should be displayed for | 37 // |for_display|: Set to true if this route should be displayed for |
38 // |media_sink_id| in UI. | 38 // |media_sink_id| in UI. |
39 MediaRoute(const MediaRoute::Id& media_route_id, | 39 MediaRoute(const MediaRoute::Id& media_route_id, |
40 const MediaSource& media_source, | 40 const MediaSource& media_source, |
41 const MediaSink::Id& media_sink_id, | 41 const MediaSink::Id& media_sink_id, |
42 const std::string& description, | 42 const std::string& description, |
43 bool is_local, | 43 bool is_local, |
44 const std::string& custom_controller_path, | 44 const std::string& custom_controller_path, |
45 bool for_display); | 45 bool for_display); |
46 MediaRoute(const MediaRoute& other); | 46 MediaRoute(const MediaRoute& other); |
47 MediaRoute(); | |
48 | |
47 ~MediaRoute(); | 49 ~MediaRoute(); |
48 | 50 |
49 // The media route identifier. | 51 void set_media_route_id(const MediaRoute::Id& media_route_id) { |
52 media_route_id_ = media_route_id; | |
53 } | |
50 const MediaRoute::Id& media_route_id() const { return media_route_id_; } | 54 const MediaRoute::Id& media_route_id() const { return media_route_id_; } |
51 | 55 |
52 // The media source being routed. | 56 void set_media_source(const MediaSource& media_source) { |
57 media_source_ = media_source; | |
58 } | |
53 const MediaSource& media_source() const { return media_source_; } | 59 const MediaSource& media_source() const { return media_source_; } |
54 | 60 |
55 // The ID of sink being routed to. | 61 void set_media_sink_id(const MediaSink::Id& media_sink_id) { |
62 media_sink_id_ = media_sink_id; | |
63 } | |
56 const MediaSink::Id& media_sink_id() const { return media_sink_id_; } | 64 const MediaSink::Id& media_sink_id() const { return media_sink_id_; } |
57 | 65 |
58 // The description of the media route activity, for example | 66 void set_description(const std::string& description) { |
59 // "Playing Foo Bar Music All Access." | 67 description_ = description; |
68 } | |
69 | |
60 // TODO(kmarshall): Do we need to pass locale for bidi rendering? | 70 // TODO(kmarshall): Do we need to pass locale for bidi rendering? |
61 const std::string& description() const { return description_; } | 71 const std::string& description() const { return description_; } |
62 | 72 |
63 // Returns |true| if the route is created locally (versus discovered | 73 void set_local(bool is_local) { is_local_ = is_local; } |
64 // by a media route provider.) | |
65 bool is_local() const { return is_local_; } | 74 bool is_local() const { return is_local_; } |
66 | 75 |
67 // The custom controller path. This allows route provider to have custom route | 76 void set_custom_controller_path(const std::string& custom_controller_path) { |
68 // detail as well as its own route control features route control features in | 77 custom_controller_path_ = custom_controller_path; |
69 // the media router dialog. | 78 } |
70 const std::string& custom_controller_path() const { | 79 const std::string& custom_controller_path() const { |
71 return custom_controller_path_; | 80 return custom_controller_path_; |
72 } | 81 } |
73 | 82 |
83 void set_for_display(bool for_display) { for_display_ = for_display; } | |
74 bool for_display() const { return for_display_; } | 84 bool for_display() const { return for_display_; } |
75 | 85 |
76 // Set this to true when the route was created by an incognito profile. | |
77 void set_incognito(bool is_incognito) { is_incognito_ = is_incognito; } | 86 void set_incognito(bool is_incognito) { is_incognito_ = is_incognito; } |
78 | |
79 bool is_incognito() const { return is_incognito_; } | 87 bool is_incognito() const { return is_incognito_; } |
80 | 88 |
81 // Set to |true| if the presentation associated with this route is an | |
82 // offscreen presentation. | |
83 void set_offscreen_presentation(bool is_offscreen_presentation) { | 89 void set_offscreen_presentation(bool is_offscreen_presentation) { |
84 is_offscreen_presentation_ = is_offscreen_presentation; | 90 is_offscreen_presentation_ = is_offscreen_presentation; |
85 } | 91 } |
86 | |
87 bool is_offscreen_presentation() const { return is_offscreen_presentation_; } | 92 bool is_offscreen_presentation() const { return is_offscreen_presentation_; } |
88 | 93 |
89 bool Equals(const MediaRoute& other) const; | 94 bool Equals(const MediaRoute& other) const; |
90 | 95 |
91 private: | 96 private: |
97 // The media route identifier. | |
92 MediaRoute::Id media_route_id_; | 98 MediaRoute::Id media_route_id_; |
99 | |
100 // The media source being routed. | |
93 MediaSource media_source_; | 101 MediaSource media_source_; |
102 | |
103 // The ID of sink being routed to. | |
94 MediaSink::Id media_sink_id_; | 104 MediaSink::Id media_sink_id_; |
105 | |
106 // The description of the media route activity, for example | |
107 // "Playing Foo Bar Music All Access." | |
95 std::string description_; | 108 std::string description_; |
96 bool is_local_; | 109 |
110 // |true| if the route is created locally (versus discovered by a media route | |
111 // provider.) | |
112 bool is_local_ = false; | |
113 | |
114 // The custom controller path. This allows route provider to have custom route | |
115 // detail as well as its own route control features route control features in | |
mark a. foltz
2017/02/09 22:53:51
"route control features" is duplicated.
| |
116 // the media router dialog. | |
97 std::string custom_controller_path_; | 117 std::string custom_controller_path_; |
98 bool for_display_; | 118 |
99 bool is_incognito_; | 119 // |true| if the route can be displayed in the UI. |
mark a. foltz
2017/02/09 22:53:51
s/UI/media router dialog/
| |
100 bool is_offscreen_presentation_; | 120 bool for_display_ = false; |
121 | |
122 // |true| if the route was created by an incognito profile. | |
123 bool is_incognito_ = false; | |
124 | |
125 // |true| if the presentation associated with this route is an offscreen | |
126 // presentation. | |
127 bool is_offscreen_presentation_ = false; | |
101 }; | 128 }; |
102 | 129 |
103 } // namespace media_router | 130 } // namespace media_router |
104 | 131 |
105 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_ | 132 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_ |
OLD | NEW |