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/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.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_route_id.h" | 13 #include "chrome/browser/media/router/media_route_id.h" |
14 #include "chrome/browser/media/router/media_sink.h" | 14 #include "chrome/browser/media/router/media_sink.h" |
15 #include "chrome/browser/media/router/media_source.h" | 15 #include "chrome/browser/media/router/media_source.h" |
16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
17 | 17 |
18 namespace media_router { | 18 namespace media_router { |
19 | 19 |
20 using RouteRequestId = int64; | 20 using RouteRequestId = int64; |
21 | 21 const RouteRequestId kInvalidRouteRequestId = -1; |
22 class MediaRouteFactory; | |
23 | 22 |
24 // For now, a simple transition graph: NEW -> CONNECTED -> CLOSED. | 23 // For now, a simple transition graph: NEW -> CONNECTED -> CLOSED. |
25 enum MediaRouteState { | 24 enum MediaRouteState { |
26 // The route is new and not yet connected to a sink. | 25 // The route is new and not yet connected to a sink. |
27 MEDIA_ROUTE_STATE_NEW, | 26 MEDIA_ROUTE_STATE_NEW, |
28 // The route is active and connected to a sink. | 27 // The route is active and connected to a sink. |
29 MEDIA_ROUTE_STATE_CONNECTED, | 28 MEDIA_ROUTE_STATE_CONNECTED, |
30 // The route has been disconnected. | 29 // The route has been disconnected. |
31 MEDIA_ROUTE_STATE_CLOSED | 30 MEDIA_ROUTE_STATE_CLOSED |
32 }; | 31 }; |
33 | 32 |
34 // MediaRoute objects contain the status and metadata of a routing | 33 // MediaRoute objects contain the status and metadata of a routing |
35 // operation. The fields are immutable and reflect the route status | 34 // operation. The fields are immutable and reflect the route status |
36 // only at the time of object creation. Updated route statuses must | 35 // only at the time of object creation. Updated route statuses must |
37 // be retrieved as new MediaRoute objects from the Media Router. | 36 // be retrieved as new MediaRoute objects from the Media Router. |
38 class MediaRoute { | 37 class MediaRoute { |
39 public: | 38 public: |
40 // |media_route_id|: ID of the route. New route IDs should be created | 39 // |media_route_id|: ID of the route. New route IDs should be created |
41 // by the RouteIdManager class. | 40 // by the RouteIdManager class. |
42 // |media_source|: Description of source of the route. | 41 // |media_source|: Description of source of the route. |
43 // |media_sink|: The sink that is receiving the media. | 42 // |media_sink|: The sink that is receiving the media. |
44 // |description|: Description of the route to be displayed. | 43 // |description|: Description of the route to be displayed. |
45 // |is_local|: true if the route was created from this browser. | 44 // |is_local|: true if the route was created from this browser. |
46 MediaRoute(const MediaRouteId& media_route_id, | 45 MediaRoute(const MediaRouteId& media_route_id, |
47 const MediaSource& media_source, | 46 const MediaSource& media_source, |
48 const MediaSink& media_sink, | 47 const MediaSink& media_sink, |
49 const std::string& description, | 48 const std::string& description, |
50 bool is_local); | 49 bool is_local); |
51 | 50 |
51 // Constructs an empty route. Typically we use an empty MediaRoute rather | |
52 // than nullptr in situations where route is absent. | |
xhwang
2015/04/02 17:13:02
What's the use case for this? Personally I feel nu
imcheng
2015/04/02 23:05:23
Reverted back to nullptr. Since a MediaRoute conta
| |
53 MediaRoute(); | |
54 | |
52 ~MediaRoute(); | 55 ~MediaRoute(); |
53 | 56 |
57 bool Empty() const; | |
58 | |
54 // The media route identifier. | 59 // The media route identifier. |
55 const MediaRouteId& media_route_id() const { return media_route_id_; } | 60 const MediaRouteId& media_route_id() const { return media_route_id_; } |
56 | 61 |
57 // The state of the media route. | 62 // The state of the media route. |
58 MediaRouteState state() const { return state_; } | 63 MediaRouteState state() const { return state_; } |
59 | 64 |
60 // The media source being routed. | 65 // The media source being routed. |
61 const MediaSource& media_source() const { return media_source_; } | 66 const MediaSource& media_source() const { return media_source_; } |
62 | 67 |
63 // The sink being routed to. | 68 // The sink being routed to. |
64 const MediaSink& media_sink() const { return media_sink_; } | 69 const MediaSink& media_sink() const { return media_sink_; } |
65 | 70 |
66 // The description of the media route activity, for example | 71 // The description of the media route activity, for example |
67 // "Playing Foo Bar Music All Access." | 72 // "Playing Foo Bar Music All Access." |
68 // TODO(kmarshall): Do we need to pass locale for bidi rendering? | 73 // TODO(kmarshall): Do we need to pass locale for bidi rendering? |
69 const std::string& description() const { return description_; } | 74 const std::string& description() const { return description_; } |
70 | 75 |
71 // Returns |true| if the route is created locally (versus discovered | 76 // Returns |true| if the route is created locally (versus discovered |
72 // by a media route provider.) | 77 // by a media route provider.) |
73 bool is_local() const { return is_local_; } | 78 bool is_local() const { return is_local_; } |
74 | 79 |
75 bool Equals(const MediaRoute& other) const; | 80 bool Equals(const MediaRoute& other) const; |
76 | 81 |
77 private: | 82 private: |
78 const MediaRouteId media_route_id_; | 83 MediaRouteId media_route_id_; |
79 const MediaSource media_source_; | 84 MediaSource media_source_; |
80 const MediaSink media_sink_; | 85 MediaSink media_sink_; |
81 const std::string description_; | 86 std::string description_; |
82 const bool is_local_; | 87 bool is_local_; |
83 const MediaRouteState state_; | 88 MediaRouteState state_; |
84 }; | 89 }; |
85 | 90 |
86 } // namespace media_router | 91 } // namespace media_router |
87 | 92 |
88 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_ | 93 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_ |
OLD | NEW |