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_ROUTER_H_ | |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "chrome/browser/media/router/media_route_id.h" | |
12 #include "chrome/browser/media/router/media_sink.h" | |
13 | |
14 namespace media_router { | |
15 | |
16 class MediaRoute; | |
17 class MediaRouteResponse; | |
18 class MediaRoutesObserver; | |
19 class MediaSource; | |
20 class MediaSinksObserver; | |
21 | |
22 using MediaRouteResponseCallback = | |
23 base::Callback<void(const MediaRouteResponse&)>; | |
24 | |
25 // An interface for handling resources related to media routing. | |
26 // Responsible for registering observers for receiving sink availability | |
27 // updates, handling route requests/responses, and operating on routes (e.g. | |
28 // posting messages or closing). | |
29 class MediaRouter { | |
30 public: | |
31 virtual ~MediaRouter() {} | |
32 | |
33 // Requests a media route from |source| to |sink_id|. | |
34 // |callback| is invoked with a response indicating success or failure. | |
35 // If it is not possible to request a route, returns kInvalidRouteRequestId. | |
36 // Otherwise a valid RouteRequestId will be returned, which can be used with | |
37 // |UnregisterMediaRouteResponseCallback()| if the caller no longer wants | |
38 // the callback invoked when a response comes back. | |
39 virtual RouteRequestId StartRouteRequest( | |
40 const MediaSource& source, | |
41 const MediaSinkId& sink_id, | |
42 const MediaRouteResponseCallback& callback) = 0; | |
43 | |
44 // Unregisters a callback registered with a pending media route request, | |
45 // e.g., when the user has canceled presentation by closing the media router | |
46 // dialog. | |
47 // It does NOT cancel the route request, only the callback previously | |
mark a. foltz
2015/03/31 22:10:24
Do we need an API to cancel a pending route reques
imcheng
2015/04/01 00:55:16
We could add one when we need it. I can file a fea
| |
48 // registered via |StartRouteRequest|. | |
49 // |request_id|: A valid request ID returned by |StartRouteRequest()|. | |
50 virtual void UnregisterMediaRouteResponseCallback( | |
51 const RouteRequestId& request_id) = 0; | |
52 | |
53 // Closes the media route specified by |route_id|. | |
54 virtual void CloseRoute(const MediaRouteId& route_id) = 0; | |
55 | |
56 // Registers |observer| with this MediaRouter. |observer| specifies a media | |
57 // source and will receive updates with media sinks that are compatible with | |
58 // that source. The initial update may happen synchronously. | |
59 // NOTE: This class does not assume ownership of |observer|. Callers must | |
60 // manage |observer| and make sure |UnregisterObserver()| is called | |
61 // before the observer is destroyed. | |
62 // Returns true if registration succeeded or the |observer| already exists. | |
63 // If the MRPM Host is not available, the registration request will fail | |
64 // immediately. | |
65 virtual bool RegisterObserver(MediaSinksObserver* observer) = 0; | |
66 | |
67 // Unregisters |observer| from MediaRouter. |observer| will stop receiving | |
68 // further updates. | |
69 virtual void UnregisterObserver(MediaSinksObserver* observer) = 0; | |
70 | |
71 // Posts |message| to a MediaSink connected via MediaRoute with |route_id|. | |
72 virtual void PostMessage(const MediaRouteId& route_id, | |
73 const std::string& message) = 0; | |
74 | |
75 // Adds a MediaRoutesObserver to listen for updates on MediaRoutes. | |
76 // The initial update may happen synchronously. | |
77 // MediaRouter does not own |observer|. |RemoveMediaRoutesObserver| should | |
78 // be called before |observer| is destroyed. | |
79 virtual void RegisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0; | |
80 | |
81 // Removes a previously added MediaRoutesObserver. |observer| will stop | |
82 // receiving further updates. | |
83 virtual void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0; | |
84 }; | |
85 | |
86 } // namespace media_router | |
87 | |
88 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ | |
OLD | NEW |