Index: chrome/browser/media/router/discovery/mdns/cast_media_sink_service.h |
diff --git a/chrome/browser/media/router/discovery/mdns/cast_media_sink_service.h b/chrome/browser/media/router/discovery/mdns/cast_media_sink_service.h |
index 2030c055fb8ae148ab6724d52968c79c34f86a9f..471ddaeccadd58baf75fd68cb3f1e40b3e309a7c 100644 |
--- a/chrome/browser/media/router/discovery/mdns/cast_media_sink_service.h |
+++ b/chrome/browser/media/router/discovery/mdns/cast_media_sink_service.h |
@@ -46,10 +46,19 @@ class CastMediaSinkService |
// mDNS service types. |
static const char kCastServiceType[]; |
+ // Default Cast control port to open Cast Socket from DIAL sink. |
+ static const int kCastControlPort; |
+ |
// MediaSinkService implementation |
void Start() override; |
void Stop() override; |
+ // Invoked when |sink| is added to DialMediaSinkServiceImpl instance. |
+ void OnDialSinkAdded(const MediaSinkInternal& sink); |
+ |
+ // Invoked when dial sinks are removed from DialMediaSinkServiceImpl instance. |
+ void OnDialSinksRemoved(); |
+ |
protected: |
// Used to mock out the DnsSdRegistry for testing. |
void SetDnsSdRegistryForTest(DnsSdRegistry* registry); |
@@ -85,39 +94,53 @@ class CastMediaSinkService |
FRIEND_TEST_ALL_PREFIXES(CastMediaSinkServiceTest, TestOnDnsSdEvent); |
FRIEND_TEST_ALL_PREFIXES(CastMediaSinkServiceTest, TestMultipleOnDnsSdEvent); |
FRIEND_TEST_ALL_PREFIXES(CastMediaSinkServiceTest, TestTimer); |
+ FRIEND_TEST_ALL_PREFIXES(CastMediaSinkServiceTest, TestOnDialSinkAdded); |
+ FRIEND_TEST_ALL_PREFIXES(CastMediaSinkServiceTest, TestOnFetchCompleted); |
+ |
+ // MediaSinkServiceBase implementation |
+ void OnFetchCompleted() override; |
+ |
+ // Returns cast sinks from |current_sinks_by_mdns_map_| and |
+ // |current_sinks_by_dial_map_|. |
+ std::set<MediaSinkInternal> GetCastSinksOnIOThread(); |
+ |
+ // Stores |cast_sinks| in |current_sinks_| and invokes |
+ // MediaSinkServiceBase::OnFetchCompleted on the UI thread. |
+ void OnFetchCompletedOnUIThread(std::set<MediaSinkInternal> cast_sinks); |
// DnsSdRegistry::DnsSdObserver implementation |
void OnDnsSdEvent(const std::string& service_type, |
const DnsSdRegistry::DnsSdServiceList& services) override; |
+ // Opens cast channels on the IO thread. |
+ void OpenChannelsOnIOThread(std::vector<MediaSinkInternal> cast_sinks); |
+ |
// Opens cast channel on IO thread. |
- // |service|: mDNS service description. |
// |ip_endpoint|: cast channel's target IP endpoint. |
- void OpenChannelOnIOThread(const DnsSdService& service, |
- const net::IPEndPoint& ip_endpoint); |
+ // |cast_sink|: Cast sink created from mDNS service description or DIAL sink. |
+ void OpenChannelOnIOThread(const net::IPEndPoint& ip_endpoint, |
+ const MediaSinkInternal& cast_sink); |
// Invoked when opening cast channel on IO thread completes. |
- // |service|: mDNS service description. |
+ // |cast_sink|: Cast sink created from mDNS service description or DIAL sink. |
// |channel_id|: channel id of newly created cast channel. |
// |channel_error|: error encounted when opending cast channel. |
- void OnChannelOpenedOnIOThread(const DnsSdService& service, |
+ void OnChannelOpenedOnIOThread(MediaSinkInternal cast_sink, |
int channel_id, |
cast_channel::ChannelError channel_error); |
- // Invoked by |OnChannelOpenedOnIOThread| to post task on UI thread. |
- // |service|: mDNS service description. |
- // |channel_id|: channel id of newly created cast channel. |
- // |audio_only|: if cast channel is audio only or not. |
- void OnChannelOpenedOnUIThread(const DnsSdService& service, |
- int channel_id, |
- bool audio_only); |
- |
// Raw pointer to DnsSdRegistry instance, which is a global leaky singleton |
// and lives as long as the browser process. |
DnsSdRegistry* dns_sd_registry_ = nullptr; |
- // Service list from current round of discovery. |
- DnsSdRegistry::DnsSdServiceList current_services_; |
+ // Set of mDNS service ip addresses from current round of discovery. |
+ std::set<net::IPEndPoint> current_service_ip_endpoints_; |
mark a. foltz
2017/07/11 23:52:51
Can this be derived by iterating over current_sink
|
+ |
+ // Map of sinks from current round of mDNS discovery keyed by IP address. |
+ std::map<net::IPEndPoint, MediaSinkInternal> current_sinks_by_mdns_map_; |
mark a. foltz
2017/07/11 23:52:51
Nit: I would drop the 'map_' at end.
|
+ |
+ // Map of sinks from current round of DIAL discovery keyed by IP address. |
+ std::map<net::IPEndPoint, MediaSinkInternal> current_sinks_by_dial_map_; |
mark a. foltz
2017/07/11 23:52:51
Consider defining a type alias (e.g. MediaSinkInte
|
// Service managing creating and removing cast channels. |
scoped_refptr<cast_channel::CastSocketService> cast_socket_service_; |