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/logging.h" | |
11 #include "base/values.h" | |
12 #include "chrome/browser/media/router/media_route_id.h" | |
13 #include "chrome/browser/media/router/media_sink.h" | |
14 #include "chrome/browser/media/router/media_source.h" | |
15 #include "url/gurl.h" | |
16 | |
17 namespace media_router { | |
18 | |
19 typedef int64 RouteRequestId; | |
mark a. foltz
2015/03/02 21:40:09
using is now preferred for type aliasing.
http://
Kevin M
2015/03/03 21:53:18
Done.
Kevin M
2015/03/03 21:53:19
Done.
| |
20 extern const int64 kInvalidRouteRequestId; | |
mark a. foltz
2015/03/02 21:40:09
s/int64/RouteRequestId/
Kevin M
2015/03/03 21:53:19
Done.
| |
21 | |
22 // For now, a simple transition graph: NEW -> CONNECTED -> CLOSED. | |
23 enum MediaRouteState { | |
24 // The route is new and not yet connected to a sink. | |
25 MEDIA_ROUTE_STATE_NEW, | |
26 // The route is active and connected to a sink. | |
27 MEDIA_ROUTE_STATE_CONNECTED, | |
28 // The route has been disconnected. | |
29 MEDIA_ROUTE_STATE_CLOSED | |
30 }; | |
31 | |
32 // TODO(mfoltz): Add errors as needed. | |
mark a. foltz
2015/03/02 21:40:09
Please touch base with Derek and see if there is a
Kevin M
2015/03/03 21:53:19
Removed.
| |
33 enum MediaRouteError { | |
34 MEDIA_ROUTE_ERROR_NONE | |
35 }; | |
36 | |
37 // A MediaRoute encapsulates an application's means of routing media from a | |
38 // source to a sink. | |
39 class MediaRoute { | |
DaleCurtis
2015/03/02 23:14:33
You'll likely need EXPORT definitions if you plan
Kevin M
2015/03/03 21:53:18
I'm building with component=shared_library and hav
| |
40 public: | |
41 // Ctor. Do not call directly, use MediaRouteFactory instead. | |
42 // TODO(mfoltz): Make private and friend MRF | |
mark a. foltz
2015/03/02 21:40:09
Can we do this now?
I feel we should do this to c
Kevin M
2015/03/03 21:53:19
Done.
| |
43 // |media_route_id|: Uniquely identifies the route among active | |
mark a. foltz
2015/03/02 21:40:09
For this to be true the (to be implemented) factor
Kevin M
2015/03/03 21:53:19
Done.
| |
44 // instances. | |
45 // |type|: Type of media route. | |
46 // |media_source|: Description of source of the route. | |
47 // |sink_id|: ID of the MediaSink of the route. | |
48 // |description|: Description of the route to be displayed. | |
49 // |is_local|: true if the route was created initiated from this Chrome | |
mark a. foltz
2015/03/02 21:40:09
"created instantiated" seems redundant.
Can you c
Kevin M
2015/03/03 21:53:18
Per browser process. Done.
| |
50 // instance. | |
51 MediaRoute(const MediaRouteId& media_route_id, | |
52 const MediaSource& media_source, | |
53 const MediaSinkId& sink_id, | |
54 const std::string& description, | |
55 bool is_local); | |
56 | |
57 ~MediaRoute(); | |
58 | |
59 // The media route identifier. | |
60 const MediaRouteId& media_route_id() const { return media_route_id_; } | |
61 | |
62 // The state of the media route. | |
63 MediaRouteState state() const { return state_; } | |
64 | |
65 // The media source being routed. | |
66 const MediaSource& media_source() const { return media_source_; } | |
67 | |
68 // The sink being routed to. | |
mark a. foltz
2015/03/02 21:40:09
The ID of the sink...
Kevin M
2015/03/03 21:53:19
Done.
| |
69 const MediaSinkId& sink_id() const { return sink_id_; } | |
70 | |
71 // The description of the media route activity. | |
mark a. foltz
2015/03/02 21:40:08
An example would be helpful.
Will this need to be
Kevin M
2015/03/03 21:53:18
Good question - do you think we should push UI loc
Kevin M
2015/03/03 22:18:27
Talked with haibinlu@ about this - the description
| |
72 const std::string& description() const { return description_; } | |
73 | |
74 // Returns |true| if the route is initiated locally. | |
mark a. foltz
2015/03/02 21:40:09
I might elaborate a little:
"if the route was cre
Kevin M
2015/03/03 21:53:19
Done.
| |
75 bool is_local() const { return is_local_; } | |
76 | |
77 bool operator==(const MediaRoute& other) const; | |
78 bool operator!=(const MediaRoute& other) const; | |
79 | |
80 private: | |
81 MediaRouteId media_route_id_; | |
82 MediaSource media_source_; | |
83 MediaSinkId sink_id_; | |
84 std::string description_; | |
85 bool is_local_; | |
86 MediaRouteState state_; | |
87 // TODO(imcheng): Add icon URL. | |
mark a. foltz
2015/03/02 21:40:09
Still valid?
Kevin M
2015/03/03 21:53:18
Done.
| |
88 }; | |
89 | |
90 // Response to a media route request to the Media Route Provider. | |
mark a. foltz
2015/03/02 21:40:09
"...from a Media Route Provider"
Kevin M
2015/03/03 21:53:18
Done.
| |
91 class MediaRouteResponse { | |
92 public: | |
93 // Creates a MediaRouteResponse object that indicates success. | |
mark a. foltz
2015/03/02 21:40:08
Only Media Router implementations should be creati
Kevin M
2015/03/03 21:53:18
Done. Removed it from here. Will just ack the comm
| |
94 // |request_id|: ID of original request. | |
mark a. foltz
2015/03/02 21:40:09
s/request_id/route_request_id/g to be explicit abo
Kevin M
2015/03/03 21:53:18
Acknowledged.
| |
95 // |route|: Route created. | |
96 static scoped_ptr<MediaRouteResponse> Success( | |
97 const RouteRequestId& request_id, const MediaRoute& route); | |
98 // Creates a MediaRouteResponse object that indicates failure. | |
99 // |request_id|: ID of original request. | |
100 // |error|: Failure reason. | |
101 static scoped_ptr<MediaRouteResponse> Error( | |
102 const RouteRequestId& request_id, const std::string& error); | |
mark a. foltz
2015/03/02 21:40:09
Should we use a MediaRouteError instead of the err
Kevin M
2015/03/03 21:53:18
Acknowledged.
| |
103 | |
104 ~MediaRouteResponse(); | |
105 | |
106 const RouteRequestId& request_id() const { return request_id_; } | |
107 // Returns a pointer to the route created. Returns nullptr if response | |
108 // indicates error. | |
109 const MediaRoute* route() const { return route_.get(); } | |
110 const std::string& error() const { return error_; } | |
111 | |
112 private: | |
113 MediaRouteResponse( | |
114 const RouteRequestId& request_id, const MediaRoute& route); | |
115 MediaRouteResponse( | |
116 const RouteRequestId& request_id, const std::string& error); | |
117 MediaRouteResponse(const MediaRouteResponse& other); | |
118 | |
119 // ID of original request. Set in all MediaRouteResponse objects, regardless | |
120 // of success/failure. | |
121 RouteRequestId request_id_; | |
122 // The route created as a result of the request. Points to a valid MediaRoute | |
123 // iff the response indicates success, nullptr otherwise. | |
124 scoped_ptr<MediaRoute> route_; | |
mark a. foltz
2015/03/02 21:40:09
It's odd that the response object owns the lifetim
Kevin M
2015/03/03 21:53:19
Acknowledged.
| |
125 // Set to empty string if response indicates success, otherwise set to the | |
126 // failure reason. | |
127 std::string error_; | |
128 }; | |
129 | |
130 } // namespace media_router | |
131 | |
132 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_ | |
OLD | NEW |