Index: chrome/browser/media/router/media_router.h |
diff --git a/chrome/browser/media/router/media_router.h b/chrome/browser/media/router/media_router.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..446d49a16b4e50f40bb72f8193256c8b70764798 |
--- /dev/null |
+++ b/chrome/browser/media/router/media_router.h |
@@ -0,0 +1,78 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ |
+#define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "chrome/browser/media/router/media_route_id.h" |
+#include "chrome/browser/media/router/media_sink.h" |
+ |
+namespace media_router { |
+ |
+class MediaRoute; |
+class MediaRouteResponse; |
+class MediaRoutesObserver; |
+class MediaSource; |
+class MediaSinksObserver; |
+ |
+using MediaRouteResponseCallback = |
+ base::Callback<void(const MediaRouteResponse&)>; |
+ |
+// An interface for handling resources related to media routing. |
+// Responsible for registering observers for receiving sink availability updates |
+// as well as handling route requests/responses. |
+class MediaRouter { |
+ public: |
+ virtual ~MediaRouter(); |
+ |
+ // Requests a media route from |source| to |sink_id|. |
+ // |callback| is invoked with a response indicating success or failure. |
+ virtual RouteRequestId StartRouteRequest( |
+ const MediaSource& source, |
+ const MediaSinkId& sink_id, |
+ const MediaRouteResponseCallback& callback) = 0; |
+ |
+ // Unregisters a pending media route request, e.g. when the MR UI is closed. |
+ virtual void UnregisterMediaRouteResponseCallback( |
+ const RouteRequestId& request_id) = 0; |
+ |
+ // Closes a media route specified by |route_id|. |
+ virtual void CloseRoute(const MediaRouteId& route_id) = 0; |
+ |
+ // Registers |observer| with MediaRouter so that it will receive updates on |
+ // sinks that are compatible with the source specified in it. |
+ // Initial set of updates may be returned synchronously to |observer|. |
+ // NOTE: This class does not assume ownership of |observer|. Callers must |
+ // manage |observer| and make sure |UnregisterObserver()| is called |
+ // before the observer is destroyed. |
+ // Returns true if registration succeeded or the |observer| already exists. |
+ // If the MRPM Host is not available, the registration request will fail |
+ // immediately. |
+ virtual bool RegisterObserver(MediaSinksObserver* observer) = 0; |
+ |
+ // Unregisters |observer| from MediaRouter. |
+ virtual void UnregisterObserver(MediaSinksObserver* observer) = 0; |
+ |
+ // Posts |message| with optional |extra_info_json| to a MediaSink connected |
+ // via MediaRoute with |route_id|. |
+ virtual void PostMessage(const MediaRouteId& route_id, |
+ const std::string& message, |
+ const std::string& extra_info_json) = 0; |
+ |
+ // Adds a MediaRoutesObserver to listen for updates on MediaRoutes. |
+ // MediaRouter does not own |observer|. |RemoveMediaRoutesObserver| should |
+ // be called before |observer| is destroyed. |
+ virtual void AddMediaRoutesObserver(MediaRoutesObserver* observer) = 0; |
+ |
+ // Removes a previously added MediaRoutesObserver. |observer| will stop |
+ // receiving updates from MediaRouter. |
+ virtual void RemoveMediaRoutesObserver(MediaRoutesObserver* observer) = 0; |
+}; |
+ |
+} // namespace media_router |
+ |
+#endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ |