OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_SINK_SERVICE_H_ | 5 #ifndef CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_SERVICE_H_ | 6 #define CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "chrome/common/media_router/discovery/media_sink_internal.h" | |
12 #include "chrome/common/media_router/media_sink.h" | 13 #include "chrome/common/media_router/media_sink.h" |
13 | 14 |
14 namespace media_router { | 15 namespace media_router { |
15 | 16 |
16 class MediaSinksObserver; | 17 class MediaSinksObserver; |
17 | 18 |
18 // A service which can be used to start background discovery and resolution of | 19 // A service which can be used to start background discovery and resolution of |
19 // MediaSinks. Often these are remote devices, like Chromecast. In addition, the | 20 // MediaSinks. Often these are remote devices, like Chromecast. In addition, the |
20 // service is capable of answering MediaSink queries using the sinks that it | 21 // service is capable of answering MediaSink queries using the sinks that it |
21 // generated. | 22 // generated. |
22 // This class is not thread safe. All methods must be called from the IO thread. | 23 // This class is not thread safe. All methods must be called from the IO thread. |
23 class MediaSinkService { | 24 class MediaSinkService { |
24 public: | 25 public: |
25 // Callback to be invoked when this class finishes sink discovering. | 26 // Callback to be invoked when this class finishes sink discovering. |
26 // Arg 0: Sinks discovered and resolved by the service. | 27 // Arg 0: Sinks discovered and resolved by the service. |
27 using OnSinksDiscoveredCallback = | 28 using OnSinksDiscoveredCallback = |
28 base::Callback<void(const std::vector<MediaSink>&)>; | 29 base::Callback<void(const std::vector<MediaSinkInternal>&)>; |
29 | 30 |
30 explicit MediaSinkService( | 31 explicit MediaSinkService( |
31 const OnSinksDiscoveredCallback& sinks_discovered_callback); | 32 const OnSinksDiscoveredCallback& sink_discovery_callback); |
32 | 33 |
33 virtual ~MediaSinkService(); | 34 virtual ~MediaSinkService(); |
34 | 35 |
35 // Starts sink discovery. No-ops if already started. | 36 // Starts sink discovery. No-ops if already started. |
36 // Sinks discovered and resolved are continuously passed to | 37 // Sinks discovered and resolved are continuously passed to |
37 // |callback|. | 38 // |callback|. |
38 virtual void Start() = 0; | 39 virtual void Start() = 0; |
39 | 40 |
40 // Adds a sink query to observe for MediaSink updates. | 41 // Adds a sink query to observe for MediaSink updates. |
41 // Multiple observers can be added for a given MediaSource. | 42 // Multiple observers can be added for a given MediaSource. |
42 // Start() must be called first. This class does not take | 43 // Start() must be called first. This class does not take |
43 // ownership of |observer|. | 44 // ownership of |observer|. |
44 virtual void AddSinkQuery(MediaSinksObserver* observer) = 0; | 45 virtual void AddSinkQuery(MediaSinksObserver* observer) = 0; |
imcheng
2017/04/26 22:52:16
This will be a problem when we implement this, bec
zhaobin
2017/04/27 01:41:20
Done.
| |
45 | 46 |
46 // Removes a sink query and stops observing MediaSink updates. No-op if | 47 // Removes a sink query and stops observing MediaSink updates. No-op if |
47 // |observer| is not registered with this class. | 48 // |observer| is not registered with this class. |
48 virtual void RemoveSinkQuery(MediaSinksObserver* observer) = 0; | 49 virtual void RemoveSinkQuery(MediaSinksObserver* observer) = 0; |
49 | 50 |
50 protected: | 51 protected: |
51 OnSinksDiscoveredCallback sinks_discovered_callback_; | 52 OnSinksDiscoveredCallback sink_discovery_callback_; |
52 | 53 |
53 DISALLOW_COPY_AND_ASSIGN(MediaSinkService); | 54 DISALLOW_COPY_AND_ASSIGN(MediaSinkService); |
54 }; | 55 }; |
55 | 56 |
56 } // namespace media_router | 57 } // namespace media_router |
57 | 58 |
58 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_SERVICE_H_ | 59 #endif // CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_H_ |
OLD | NEW |