Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/media/router/media_router.h

Issue 1020743003: [Media Router] Design MediaRouter interface with stub implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved On*() functions into a separate Delegate interface Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/media/router/media_route.h ('k') | chrome/browser/media/router/media_router.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "base/callback.h"
12 #include "chrome/browser/media/router/media_route.h"
13 #include "chrome/browser/media/router/media_route_id.h"
14 #include "chrome/browser/media/router/media_sink.h"
15
16 namespace media_router {
17
18 class MediaRouteResponse;
19 class MediaRoutesObserver;
20 class MediaSource;
21 class MediaSinksObserver;
22
23 using MediaRouteResponseCallback =
24 base::Callback<void(scoped_ptr<MediaRoute>, const std::string&)>;
25
26 // An interface for handling resources related to media routing.
27 // Responsible for registering observers for receiving sink availability
28 // updates, handling route requests/responses, and operating on routes (e.g.
29 // posting messages or closing).
30 class MediaRouter {
31 public:
32 virtual ~MediaRouter() {}
33
34 // Requests a media route from |source| to |sink_id|.
35 // |callback| is invoked with a response indicating success or failure.
36 virtual void RequestRoute(const MediaSource& source,
37 const MediaSinkId& sink_id,
38 const MediaRouteResponseCallback& callback) = 0;
39
40 // Closes the media route specified by |route_id|.
41 virtual void CloseRoute(const MediaRouteId& route_id) = 0;
42
43 // Posts |message| to a MediaSink connected via MediaRoute with |route_id|.
44 // TODO(imcheng): Support additional data types: Blob, ArrayBuffer,
45 // ArrayBufferView.
46 virtual void PostMessage(const MediaRouteId& route_id,
47 const std::string& message) = 0;
48
49 // Receives updates from a MediaRouter instance.
50 class Delegate {
51 // Called when results from a media sinks query have been received.
52 // |source|: Media source of the query.
53 // |sinks|: List of sinks compatible with the source.
54 virtual void OnSinksReceived(const MediaSource& source,
55 const std::vector<MediaSink>& sinks) = 0;
xhwang 2015/04/09 16:54:26 You have a duplication between this call and Media
imcheng 2015/04/09 17:06:37 Removed OnSinksreceived and OnRoutesUpdated from h
56
57 // Called when the list of current MediaRoutes and their MediaSinks
58 // has been updated.
59 // |routes|: List of MediaRoutes.
60 virtual void OnRoutesUpdated(const std::vector<MediaRoute>& routes) = 0;
61
62 // Called when there is a message from a route.
63 // |route_id|: The route ID.
64 // |message|: The message.
65 virtual void OnMessage(const MediaRouteId& route_id,
66 const std::string& message) = 0;
67 };
68
69 private:
70 friend class MediaSinksObserver;
71 friend class MediaRoutesObserver;
72
73 // The following APIs are called by MediaSinksObserver/MediaRoutesObserver
74 // only.
75
76 // Registers |observer| with this MediaRouter. |observer| specifies a media
77 // source and will receive updates with media sinks that are compatible with
78 // that source. The initial update may happen synchronously.
79 // NOTE: This class does not assume ownership of |observer|. Callers must
80 // manage |observer| and make sure |UnregisterObserver()| is called
81 // before the observer is destroyed.
82 // Returns true if registration succeeded.
83 // It is invalid to request the same observer more than once and will result
84 // in undefined behavior.
85 // If the MRPM Host is not available, the registration request will fail
86 // immediately.
87 virtual bool RegisterMediaSinksObserver(MediaSinksObserver* observer) = 0;
88
89 // Removes a previously added MediaSinksObserver. |observer| will stop
90 // receiving further updates.
91 virtual void UnregisterMediaSinksObserver(MediaSinksObserver* observer) = 0;
92
93 // Adds a MediaRoutesObserver to listen for updates on MediaRoutes.
94 // The initial update may happen synchronously.
95 // MediaRouter does not own |observer|. |RemoveMediaRoutesObserver| should
96 // be called before |observer| is destroyed.
97 virtual bool RegisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0;
98
99 // Removes a previously added MediaRoutesObserver. |observer| will stop
100 // receiving further updates.
101 virtual void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0;
102 };
103
104 } // namespace media_router
105
106 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_
OLDNEW
« no previous file with comments | « chrome/browser/media/router/media_route.h ('k') | chrome/browser/media/router/media_router.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698