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_ROUTE_H_ | |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/gtest_prod_util.h" | |
11 #include "base/logging.h" | |
12 #include "base/values.h" | |
13 #include "chrome/browser/media/router/media_route_id.h" | |
14 #include "chrome/browser/media/router/media_sink.h" | |
15 #include "chrome/browser/media/router/media_source.h" | |
16 #include "url/gurl.h" | |
17 | |
18 namespace media_router { | |
19 | |
20 using RouteRequestId = int64; | |
21 | |
22 extern const RouteRequestId kInvalidRouteRequestId; | |
23 | |
24 class MediaRouteFactory; | |
25 | |
26 // For now, a simple transition graph: NEW -> CONNECTED -> CLOSED. | |
27 enum MediaRouteState { | |
28 // The route is new and not yet connected to a sink. | |
29 MEDIA_ROUTE_STATE_NEW, | |
30 // The route is active and connected to a sink. | |
31 MEDIA_ROUTE_STATE_CONNECTED, | |
32 // The route has been disconnected. | |
33 MEDIA_ROUTE_STATE_CLOSED | |
34 }; | |
35 | |
36 // A MediaRoute encapsulates an application's means of routing media from a | |
37 // source to a sink. | |
38 class MediaRoute { | |
39 public: | |
40 ~MediaRoute(); | |
41 | |
42 // The media route identifier. | |
43 const MediaRouteId& media_route_id() const { return media_route_id_; } | |
44 | |
45 // The state of the media route. | |
46 MediaRouteState state() const { return state_; } | |
47 | |
48 // The media source being routed. | |
49 const MediaSource& media_source() const { return media_source_; } | |
imcheng
2015/03/03 22:53:09
It's not hard to misuse a getter that returns by r
Kevin M
2015/03/03 23:28:05
I think returning field const references is widesp
| |
50 | |
51 // The ID of the sink being routed to. | |
52 const MediaSinkId& sink_id() const { return sink_id_; } | |
53 | |
54 // The description of the media route activity, for example | |
55 // "Playing Foo Bar Music All Access." | |
56 // TODO(kmarshall): Does this need to be localized? | |
mark a. foltz
2015/03/04 06:22:59
Per discussion, the browser is not responsible for
Kevin M
2015/03/04 23:33:32
I hadn't considered the bidi aspect. OK, TODO adde
| |
57 const std::string& description() const { return description_; } | |
58 | |
59 // Returns |true| if the route is created locally (versus diescovered | |
mark a. foltz
2015/03/04 06:22:59
discovered
Kevin M
2015/03/04 23:33:32
Done.
| |
60 // by a media route provider.) | |
61 bool is_local() const { return is_local_; } | |
62 | |
63 bool operator==(const MediaRoute& other) const; | |
64 bool operator!=(const MediaRoute& other) const; | |
65 | |
66 private: | |
67 friend class MediaRouteFactory; | |
68 FRIEND_TEST_ALL_PREFIXES(MediaRouteTest, Equals); | |
69 | |
70 // |media_route_id|: Uniquely identifies the route among active | |
71 // instances for this media source. | |
72 // |type|: Type of media route. | |
73 // |media_source|: Description of source of the route. | |
74 // |sink_id|: ID of the MediaSink of the route. | |
75 // |description|: Description of the route to be displayed. | |
76 // |is_local|: true if the route was created from this browser. | |
77 MediaRoute(const MediaRouteId& media_route_id, | |
78 const MediaSource& media_source, | |
79 const MediaSinkId& sink_id, | |
80 const std::string& description, | |
81 bool is_local); | |
82 | |
83 const MediaRouteId media_route_id_; | |
84 const MediaSource media_source_; | |
85 const MediaSinkId sink_id_; | |
86 const std::string description_; | |
87 const bool is_local_; | |
88 const MediaRouteState state_; | |
89 }; | |
90 | |
91 } // namespace media_router | |
92 | |
93 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_ | |
OLD | NEW |