OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_INTERNAL_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_INTERNAL_H_ |
| 7 |
| 8 #include "chrome/browser/media/router/media_sink.h" |
| 9 #include "net/base/ip_address.h" |
| 10 #include "url/gurl.h" |
| 11 |
| 12 namespace media_router { |
| 13 |
| 14 // Extra data for DIAL media sink. |
| 15 struct DialSinkExtraData { |
| 16 net::IPAddress ip_address; |
| 17 |
| 18 // Model name of the sink |
| 19 std::string model_name; |
| 20 |
| 21 // The base URL used for DIAL operations. |
| 22 GURL app_url; |
| 23 |
| 24 DialSinkExtraData(); |
| 25 DialSinkExtraData(const DialSinkExtraData& other); |
| 26 ~DialSinkExtraData(); |
| 27 }; |
| 28 |
| 29 // Extra data for cast media sink. |
| 30 struct CastSinkExtraData { |
| 31 net::IPAddress ip_address; |
| 32 |
| 33 // Model name of the sink |
| 34 std::string model_name; |
| 35 |
| 36 // A bit vector representing the capabilities of the sink. The values are |
| 37 // defined in media_router.mojom. The caller must set this value to a valid |
| 38 // capacity set. |
| 39 int capabilities = 0; |
| 40 |
| 41 // ID of Cast channel opened for the sink. The caller must set this value to a |
| 42 // valid cast_channel_id. The cast_channel_id may change over time as the |
| 43 // browser reconnects to a device. |
| 44 int cast_channel_id = 0; |
| 45 |
| 46 CastSinkExtraData(); |
| 47 CastSinkExtraData(const CastSinkExtraData& other); |
| 48 ~CastSinkExtraData(); |
| 49 }; |
| 50 |
| 51 // Represents a media sink discovered by MediaSinkService. It is used by |
| 52 // MediaSinkService to push MediaSinks with extra data to the |
| 53 // MediaRouteProvider, and it is not exposed to users of MediaRouter. |
| 54 class MediaSinkInternal { |
| 55 public: |
| 56 // Used by mojo. |
| 57 MediaSinkInternal(); |
| 58 |
| 59 // Used by unit test. |
| 60 explicit MediaSinkInternal(const MediaSink& sink); |
| 61 |
| 62 // Used by MediaSinkService to create media sinks. |
| 63 MediaSinkInternal(const MediaSink& sink, const DialSinkExtraData& dial_data); |
| 64 MediaSinkInternal(const MediaSink& sink, const CastSinkExtraData& cast_data); |
| 65 |
| 66 // Used to push instance of this class into vector. |
| 67 MediaSinkInternal(const MediaSinkInternal& other); |
| 68 |
| 69 ~MediaSinkInternal(); |
| 70 |
| 71 MediaSinkInternal& operator=(const MediaSinkInternal& other); |
| 72 |
| 73 // Set |sink_| and invalidate extra data. |
| 74 void set_sink(const MediaSink& sink); |
| 75 const MediaSink& sink() const { return sink_; } |
| 76 |
| 77 void set_dial_data(const DialSinkExtraData& dial_data); |
| 78 |
| 79 // Must only be called if the sink is a DIAL sink. |
| 80 const DialSinkExtraData& dial_data() const; |
| 81 |
| 82 void set_cast_data(const CastSinkExtraData& cast_data); |
| 83 |
| 84 // Must only be called if the sink is a Cast sink. |
| 85 const CastSinkExtraData& cast_data() const; |
| 86 |
| 87 bool is_dial_sink() const { return dial_data_ && !cast_data_; } |
| 88 bool is_cast_sink() const { return cast_data_ && !dial_data_; } |
| 89 |
| 90 static bool IsValidSinkId(const std::string& sink_id); |
| 91 |
| 92 private: |
| 93 MediaSink sink_; |
| 94 |
| 95 // Set if sink is DIAL sink. |
| 96 base::Optional<DialSinkExtraData> dial_data_; |
| 97 |
| 98 // Set if sink is Cast sink. |
| 99 base::Optional<CastSinkExtraData> cast_data_; |
| 100 }; |
| 101 |
| 102 } // namespace media_router |
| 103 |
| 104 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_INTERNAL_H_ |
OLD | NEW |