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 // An interface acting as the Chrome endpoint for communication between |
| 21 // Media Router in Chrome and Media Route Provider Manager (MRPM). |
| 22 class MediaRouteProviderManagerHost { |
| 23 public: |
| 24 virtual ~MediaRouteProviderManagerHost() {} |
| 25 |
| 26 // Interface for handling responses from the MRPM. |
| 27 class Delegate { |
| 28 public: |
| 29 virtual ~Delegate() {} |
| 30 |
| 31 // Called from MediaRouteProviderManagerHost when results from a media |
| 32 // sinks query have been received. |
| 33 // |source|: Media source of the query. |
| 34 // |sinks|: List of sinks compatible with the source. |
| 35 // |routes|: Currently active routes on |sinks|. |
| 36 virtual void OnSinksReceived(const MediaSource& source, |
| 37 const std::vector<MediaSink>& sinks) = 0; |
| 38 |
| 39 // Called from MediaRouteProviderManagerHost when there is a message from |
| 40 // a route. |
| 41 // |route_id|: The route ID. |
| 42 // |message|: The message. |
| 43 virtual void OnMessage(const MediaRouteId& route_id, |
| 44 const std::string& message) = 0; |
| 45 |
| 46 // Called from MediaRouteProviderManagerHost when a response to a route |
| 47 // request has been received and a route has been established. |
| 48 // |request_id|: ID of original request. |
| 49 // |route|: Description of the established route. |
| 50 virtual void OnRouteResponseReceived(const RouteRequestId& request_id, |
| 51 const MediaRoute& route) = 0; |
| 52 |
| 53 // Called from MediaRouteProviderManagerHost when an error occurred while |
| 54 // establishing a route. |
| 55 // |request_id|: ID of original request. |
| 56 // |error_text|: Text describing the error. |
| 57 virtual void OnRouteResponseError(const RouteRequestId& request_id, |
| 58 const std::string& error_text) = 0; |
| 59 |
| 60 // Called from MediaRouteProviderManagerHost when the list of currently |
| 61 // MediaRoutes and their MediaSinks have been updated. |
| 62 // |routes|: List of MediaRoutes. |
| 63 // |sinks|: List of MediaSinks associated with the routes. |
| 64 virtual void OnRoutesUpdated( |
| 65 const std::vector<MediaRoute>& routes, |
| 66 const std::vector<MediaSink>& sinks) = 0; |
| 67 |
| 68 // Called when the MRPMHost is being destroyed. |
| 69 virtual void OnHostDestroyed(MediaRouteProviderManagerHost* host) = 0; |
| 70 }; |
| 71 |
| 72 // The following functions are called from Media Router to MRPM. |
| 73 |
| 74 // Instructs MRPM to start a query for compatible media sinks for |source|. |
| 75 // Results from the query and subsequent updates will be received via |
| 76 // |Delegate::OnSinksReceived| until the query is removed from MRPM |
| 77 // via |RemoveMediaSinksQuery|. |
| 78 virtual void AddMediaSinksQuery(const MediaSource& source) = 0; |
| 79 |
| 80 // Instructs MRPM to stop a query for compatible media sinks for |source|. |
| 81 virtual void RemoveMediaSinksQuery(const MediaSource& source) = 0; |
| 82 |
| 83 // Requests MRPM to establish a route between |source| and a media sink given |
| 84 // by |sink_id|. |request_id| is generated by Media Router and passed |
| 85 // to MRPM to identify the request. |
| 86 virtual void RequestRoute(const RouteRequestId& request_id, |
| 87 const MediaSource& source, |
| 88 const MediaSinkId& sink_id) = 0; |
| 89 |
| 90 // Requests MRPM to close a route specified by |route_id|. |
| 91 virtual void CloseRoute(const MediaRouteId& route_id) = 0; |
| 92 |
| 93 // Requests MRPM to post |message| with optional |extra_info| to a MediaSink |
| 94 // connected by MediaRoute with |route_id|. |
| 95 virtual void PostMessage(const MediaRouteId& route_id, |
| 96 const std::string& message, |
| 97 const std::string& extra_info_json) = 0; |
| 98 |
| 99 // Requests MRPM to send updates on all MediaRoutes and their MediaSinks. |
| 100 // The updated lists will be received via |
| 101 // |Delegate::OnActiveSinksAndRoutesReceived|. |
| 102 virtual void StartMediaRoutesQuery() = 0; |
| 103 |
| 104 // Requests MRPM to stop sending updates on MediaRoutes. |
| 105 virtual void StopMediaRoutesQuery() = 0; |
| 106 }; |
| 107 |
| 108 } // namespace media_router |
| 109 |
| 110 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_PROVIDER_MANAGER_HOST_H_ |
OLD | NEW |