OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 // request failed. | 28 // request failed. |
29 using MediaRouteResponseCallback = | 29 using MediaRouteResponseCallback = |
30 base::Callback<void(scoped_ptr<MediaRoute>, const std::string&)>; | 30 base::Callback<void(scoped_ptr<MediaRoute>, const std::string&)>; |
31 | 31 |
32 // An interface for handling resources related to media routing. | 32 // An interface for handling resources related to media routing. |
33 // Responsible for registering observers for receiving sink availability | 33 // Responsible for registering observers for receiving sink availability |
34 // updates, handling route requests/responses, and operating on routes (e.g. | 34 // updates, handling route requests/responses, and operating on routes (e.g. |
35 // posting messages or closing). | 35 // posting messages or closing). |
36 class MediaRouter { | 36 class MediaRouter { |
37 public: | 37 public: |
| 38 using SendRouteMessageCallback = base::Callback<void(bool sent)>; |
| 39 |
38 virtual ~MediaRouter() {} | 40 virtual ~MediaRouter() {} |
39 | 41 |
40 // Creates a media route from |source_id| to |sink_id|. | 42 // Creates a media route from |source_id| to |sink_id|. |
41 // |callback| is invoked with a response indicating success or failure. | 43 // |callback| is invoked with a response indicating success or failure. |
42 virtual void CreateRoute(const MediaSource::Id& source_id, | 44 virtual void CreateRoute(const MediaSource::Id& source_id, |
43 const MediaSink::Id& sink_id, | 45 const MediaSink::Id& sink_id, |
44 const MediaRouteResponseCallback& callback) = 0; | 46 const MediaRouteResponseCallback& callback) = 0; |
45 | 47 |
46 // Closes the media route specified by |route_id|. | 48 // Closes the media route specified by |route_id|. |
47 virtual void CloseRoute(const MediaRoute::Id& route_id) = 0; | 49 virtual void CloseRoute(const MediaRoute::Id& route_id) = 0; |
48 | 50 |
49 // Posts |message| to a MediaSink connected via MediaRoute with |route_id|. | 51 // Posts |message| to a MediaSink connected via MediaRoute with |route_id|. |
50 // TODO(imcheng): Support additional data types: Blob, ArrayBuffer, | 52 // TODO(imcheng): Support additional data types: Blob, ArrayBuffer, |
51 // ArrayBufferView. | 53 // ArrayBufferView. |
52 virtual void PostMessage(const MediaRoute::Id& route_id, | 54 virtual void SendRouteMessage(const MediaRoute::Id& route_id, |
53 const std::string& message) = 0; | 55 const std::string& message, |
| 56 const SendRouteMessageCallback& callback) = 0; |
54 | 57 |
55 // Clears the issue with the id |issue_id|. | 58 // Clears the issue with the id |issue_id|. |
56 virtual void ClearIssue(const Issue::Id& issue_id) = 0; | 59 virtual void ClearIssue(const Issue::Id& issue_id) = 0; |
57 | 60 |
58 // Receives updates from a MediaRouter instance. | 61 // Receives updates from a MediaRouter instance. |
59 class Delegate { | 62 class Delegate { |
60 public: | 63 public: |
61 // Called when there is a message from a route. | 64 // Called when there is a message from a route. |
62 // |route_id|: The route ID. | 65 // |route_id|: The route ID. |
63 // |message|: The message. | 66 // |message|: The message. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // in undefined behavior. | 109 // in undefined behavior. |
107 virtual void AddIssuesObserver(IssuesObserver* observer) = 0; | 110 virtual void AddIssuesObserver(IssuesObserver* observer) = 0; |
108 | 111 |
109 // Removes the IssuesObserver |observer|. | 112 // Removes the IssuesObserver |observer|. |
110 virtual void RemoveIssuesObserver(IssuesObserver* observer) = 0; | 113 virtual void RemoveIssuesObserver(IssuesObserver* observer) = 0; |
111 }; | 114 }; |
112 | 115 |
113 } // namespace media_router | 116 } // namespace media_router |
114 | 117 |
115 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ | 118 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ |
OLD | NEW |