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 updates |
| 27 // as well as handling route requests/responses. |
| 28 class MediaRouter { |
| 29 public: |
| 30 virtual ~MediaRouter(); |
| 31 |
| 32 // Requests a media route from |source| to |sink_id|. |
| 33 // |callback| is invoked with a response indicating success or failure. |
| 34 virtual RouteRequestId StartRouteRequest( |
| 35 const MediaSource& source, |
| 36 const MediaSinkId& sink_id, |
| 37 const MediaRouteResponseCallback& callback) = 0; |
| 38 |
| 39 // Unregisters a pending media route request, e.g. when the MR UI is closed. |
| 40 virtual void UnregisterMediaRouteResponseCallback( |
| 41 const RouteRequestId& request_id) = 0; |
| 42 |
| 43 // Closes a media route specified by |route_id|. |
| 44 virtual void CloseRoute(const MediaRouteId& route_id) = 0; |
| 45 |
| 46 // Registers |observer| with MediaRouter so that it will receive updates on |
| 47 // sinks that are compatible with the source specified in it. |
| 48 // Initial set of updates may be returned synchronously to |observer|. |
| 49 // NOTE: This class does not assume ownership of |observer|. Callers must |
| 50 // manage |observer| and make sure |UnregisterObserver()| is called |
| 51 // before the observer is destroyed. |
| 52 // Returns true if registration succeeded or the |observer| already exists. |
| 53 // If the MRPM Host is not available, the registration request will fail |
| 54 // immediately. |
| 55 virtual bool RegisterObserver(MediaSinksObserver* observer) = 0; |
| 56 |
| 57 // Unregisters |observer| from MediaRouter. |
| 58 virtual void UnregisterObserver(MediaSinksObserver* observer) = 0; |
| 59 |
| 60 // Posts |message| with optional |extra_info_json| to a MediaSink connected |
| 61 // via MediaRoute with |route_id|. |
| 62 virtual void PostMessage(const MediaRouteId& route_id, |
| 63 const std::string& message, |
| 64 const std::string& extra_info_json) = 0; |
| 65 |
| 66 // Adds a MediaRoutesObserver to listen for updates on MediaRoutes. |
| 67 // MediaRouter does not own |observer|. |RemoveMediaRoutesObserver| should |
| 68 // be called before |observer| is destroyed. |
| 69 virtual void AddMediaRoutesObserver(MediaRoutesObserver* observer) = 0; |
| 70 |
| 71 // Removes a previously added MediaRoutesObserver. |observer| will stop |
| 72 // receiving updates from MediaRouter. |
| 73 virtual void RemoveMediaRoutesObserver(MediaRoutesObserver* observer) = 0; |
| 74 }; |
| 75 |
| 76 } // namespace media_router |
| 77 |
| 78 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ |
OLD | NEW |