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_PROVIDER_MANAGER_HOST_H_ | |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_PROVIDER_MANAGER_HOST_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/callback.h" | |
12 #include "chrome/browser/media/router/media_route.h" | |
13 #include "chrome/browser/media/router/media_sink.h" | |
14 #include "chrome/browser/media/router/media_source.h" | |
15 | |
16 namespace media_router { | |
17 | |
18 class MediaRoute; | |
19 | |
20 // Acts as the Chrome endpoint for communication between Media Router and | |
21 // Media Route Providers (via the Media Route Provider Manager). | |
22 class MediaRouteProviderManagerHost { | |
xhwang
2015/04/08 17:46:25
We don't have MediaRouteProvider and MediaRoutePro
imcheng
2015/04/08 19:21:31
Our implementation of MediaRouteProvider and Media
| |
23 public: | |
24 virtual ~MediaRouteProviderManagerHost() {} | |
25 | |
26 // Delegate called by the MediaRouteProviderManagerHost when a response is | |
27 // received from the MRPM. | |
28 class Delegate { | |
xhwang
2015/04/08 17:46:24
It seems not all methods of this class are respons
imcheng
2015/04/08 19:21:31
I changed the class level comment here. But, since
xhwang
2015/04/08 20:32:51
Ack. Thanks!
imcheng
2015/04/08 23:28:09
Discussed offline. Will merged the interfaces into
| |
29 public: | |
30 virtual ~Delegate() {} | |
31 | |
32 // Called when results from a media sinks query have been received. | |
33 // |source|: Media source of the query. | |
34 // |sinks|: List of sinks compatible with the source. | |
35 virtual void OnSinksReceived(const MediaSource& source, | |
36 const std::vector<MediaSink>& sinks) = 0; | |
37 | |
38 // Called when there is a message from a route. | |
39 // |route_id|: The route ID. | |
40 // |message|: The message. | |
41 virtual void OnMessage(const MediaRouteId& route_id, | |
42 const std::string& message) = 0; | |
43 | |
44 // Called when a response to a route request has been received and | |
45 // a route has been established. | |
46 // |request_id|: ID of original request. | |
47 // |route|: Description of the established route. | |
48 virtual void OnRouteResponseReceived(const RouteRequestId& request_id, | |
49 const MediaRoute& route) = 0; | |
50 | |
51 // Called when an error occurred while establishing a route. | |
52 // |request_id|: ID of original request. | |
53 // |error_text|: Text describing the error. | |
54 virtual void OnRouteResponseError(const RouteRequestId& request_id, | |
55 const std::string& error_text) = 0; | |
xhwang
2015/04/08 17:46:24
OnRouteResponseReceived() or OnRouteResponseError(
imcheng
2015/04/08 19:21:30
Done.
| |
56 | |
57 // Called when the list of currently MediaRoutes and their MediaSinks | |
xhwang
2015/04/08 17:46:24
nit: s/currently/current
imcheng
2015/04/08 19:21:31
Done.
| |
58 // has been updated. | |
59 // |routes|: List of MediaRoutes. | |
60 // |sinks|: List of MediaSinks associated with the routes. | |
61 virtual void OnRoutesUpdated(const std::vector<MediaRoute>& routes, | |
62 const std::vector<MediaSink>& sinks) = 0; | |
xhwang
2015/04/08 17:46:24
Ditto. |routes| contains sinks. What's the relatio
imcheng
2015/04/08 19:21:30
Removed |sinks|.
| |
63 | |
64 // Called when the MRPMHost is being destroyed. | |
65 virtual void OnHostDestroyed(MediaRouteProviderManagerHost* host) = 0; | |
66 }; | |
67 | |
68 // The following APIs allow the media router to send commands to the MRPM. | |
69 | |
70 // Instructs MRPM to start a query for compatible media sinks for |source|. | |
71 // Results from the query and subsequent updates will be received via | |
72 // |Delegate::OnSinksReceived| until the query is removed from MRPM | |
73 // via |RemoveMediaSinksQuery|. | |
74 virtual void AddMediaSinksQuery(const MediaSource& source) = 0; | |
75 | |
76 // Instructs MRPM to stop a query for compatible media sinks for |source|. | |
77 // The delegate will no longer receive updates. | |
78 virtual void RemoveMediaSinksQuery(const MediaSource& source) = 0; | |
79 | |
80 // Requests MRPM to establish a route between |source| and a media sink given | |
81 // by |sink_id|. |request_id| is generated by Media Router and passed | |
82 // to MRPM to identify the request. | |
83 // Result of the request will be received via either | |
84 // |Delegate::OnRouteResponseReceived| or |OnRouteResponseError|. | |
85 virtual void RequestRoute(const RouteRequestId& request_id, | |
86 const MediaSource& source, | |
87 const MediaSinkId& sink_id) = 0; | |
xhwang
2015/04/08 17:46:24
If you use a callback for the response, you should
imcheng
2015/04/08 19:21:31
See uniformity comment above.
| |
88 | |
89 // Requests MRPM to close a route specified by |route_id|. | |
90 virtual void CloseRoute(const MediaRouteId& route_id) = 0; | |
91 | |
92 // Requests MRPM to post |message| to a MediaSink connected by MediaRoute | |
93 // with |route_id|. | |
94 virtual void PostMessage(const MediaRouteId& route_id, | |
95 const std::string& message) = 0; | |
96 | |
97 // Requests MRPM to start a query for all MediaRoutes and their MediaSinks. | |
98 // The result and subsequent updates will be received via | |
99 // |Delegate::OnRoutesUpdated|. | |
xhwang
2015/04/08 17:46:24
Please see my comments above on callbacks.
imcheng
2015/04/08 19:21:30
Acknowledged.
| |
100 virtual void StartMediaRoutesQuery() = 0; | |
101 | |
102 // Requests MRPM to stop the query. The delegate will no longer receive | |
103 // updates. | |
104 virtual void StopMediaRoutesQuery() = 0; | |
105 }; | |
106 | |
107 } // namespace media_router | |
108 | |
109 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_PROVIDER_MANAGER_HOST_H_ | |
OLD | NEW |