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_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_INTERNAL_H_ | 5 #ifndef CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_INTERNAL_H_ |
6 #define CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_INTERNAL_H_ | 6 #define CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_INTERNAL_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/manual_constructor.h" | 10 #include "base/memory/manual_constructor.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 DialSinkExtraData(const DialSinkExtraData& other); | 28 DialSinkExtraData(const DialSinkExtraData& other); |
29 ~DialSinkExtraData(); | 29 ~DialSinkExtraData(); |
30 | 30 |
31 bool operator==(const DialSinkExtraData& other) const; | 31 bool operator==(const DialSinkExtraData& other) const; |
32 }; | 32 }; |
33 | 33 |
34 // Extra data for Cast media sink. | 34 // Extra data for Cast media sink. |
35 struct CastSinkExtraData { | 35 struct CastSinkExtraData { |
36 net::IPAddress ip_address; | 36 net::IPAddress ip_address; |
37 | 37 |
| 38 int port = 0; |
| 39 |
38 // Model name of the sink. | 40 // Model name of the sink. |
39 std::string model_name; | 41 std::string model_name; |
40 | 42 |
41 // A bit vector representing the capabilities of the sink. The values are | 43 // A bit vector representing the capabilities of the sink. The values are |
42 // defined in media_router.mojom. | 44 // defined in media_router.mojom. |
43 uint8_t capabilities = 0; | 45 uint8_t capabilities = 0; |
44 | 46 |
45 // ID of Cast channel opened for the sink. The caller must set this value to a | 47 // ID of Cast channel opened for the sink. The caller must set this value to a |
46 // valid cast_channel_id. The cast_channel_id may change over time as the | 48 // valid cast_channel_id. The cast_channel_id may change over time as the |
47 // browser reconnects to a device. | 49 // browser reconnects to a device. |
48 int cast_channel_id = 0; | 50 int cast_channel_id = 0; |
49 | 51 |
| 52 // True if Cast channel is opened from DIAL sink. |
| 53 bool discovered_by_dial = false; |
| 54 |
50 CastSinkExtraData(); | 55 CastSinkExtraData(); |
51 CastSinkExtraData(const CastSinkExtraData& other); | 56 CastSinkExtraData(const CastSinkExtraData& other); |
52 ~CastSinkExtraData(); | 57 ~CastSinkExtraData(); |
53 | 58 |
54 bool operator==(const CastSinkExtraData& other) const; | 59 bool operator==(const CastSinkExtraData& other) const; |
55 }; | 60 }; |
56 | 61 |
57 // Represents a media sink discovered by MediaSinkService. It is used by | 62 // Represents a media sink discovered by MediaSinkService. It is used by |
58 // MediaSinkService to push MediaSinks with extra data to the | 63 // MediaSinkService to push MediaSinks with extra data to the |
59 // MediaRouteProvider, and it is not exposed to users of MediaRouter. | 64 // MediaRouteProvider, and it is not exposed to users of MediaRouter. |
60 class MediaSinkInternal { | 65 class MediaSinkInternal { |
61 public: | 66 public: |
62 // Used by mojo. | 67 // Used by mojo. |
63 MediaSinkInternal(); | 68 MediaSinkInternal(); |
64 | 69 |
65 // Used by MediaSinkService to create media sinks. | 70 // Used by MediaSinkService to create media sinks. |
66 MediaSinkInternal(const MediaSink& sink, const DialSinkExtraData& dial_data); | 71 MediaSinkInternal(const MediaSink& sink, const DialSinkExtraData& dial_data); |
67 MediaSinkInternal(const MediaSink& sink, const CastSinkExtraData& cast_data); | 72 MediaSinkInternal(const MediaSink& sink, const CastSinkExtraData& cast_data); |
68 | 73 |
69 // Used to push instance of this class into vector. | 74 // Used to push instance of this class into vector. |
70 MediaSinkInternal(const MediaSinkInternal& other); | 75 MediaSinkInternal(const MediaSinkInternal& other); |
| 76 MediaSinkInternal(MediaSinkInternal&& other); |
71 | 77 |
72 ~MediaSinkInternal(); | 78 ~MediaSinkInternal(); |
73 | 79 |
74 MediaSinkInternal& operator=(const MediaSinkInternal& other); | 80 MediaSinkInternal& operator=(const MediaSinkInternal& other); |
| 81 MediaSinkInternal& operator=(MediaSinkInternal&& other); |
| 82 |
75 bool operator==(const MediaSinkInternal& other) const; | 83 bool operator==(const MediaSinkInternal& other) const; |
76 bool operator!=(const MediaSinkInternal& other) const; | 84 bool operator!=(const MediaSinkInternal& other) const; |
77 // Sorted by sink id. | 85 // Sorted by sink id. |
78 bool operator<(const MediaSinkInternal& other) const; | 86 bool operator<(const MediaSinkInternal& other) const; |
79 | 87 |
80 // Used by mojo. | 88 // Used by mojo. |
81 void set_sink_id(const MediaSink::Id& sink_id) { sink_.set_sink_id(sink_id); } | 89 void set_sink_id(const MediaSink::Id& sink_id) { sink_.set_sink_id(sink_id); } |
82 void set_name(const std::string& name) { sink_.set_name(name); } | 90 void set_name(const std::string& name) { sink_.set_name(name); } |
83 void set_description(const std::string& description) { | 91 void set_description(const std::string& description) { |
84 sink_.set_description(description); | 92 sink_.set_description(description); |
(...skipping 17 matching lines...) Expand all Loading... |
102 const CastSinkExtraData& cast_data() const; | 110 const CastSinkExtraData& cast_data() const; |
103 | 111 |
104 bool is_dial_sink() const { return sink_type_ == SinkType::DIAL; } | 112 bool is_dial_sink() const { return sink_type_ == SinkType::DIAL; } |
105 bool is_cast_sink() const { return sink_type_ == SinkType::CAST; } | 113 bool is_cast_sink() const { return sink_type_ == SinkType::CAST; } |
106 | 114 |
107 static bool IsValidSinkId(const std::string& sink_id); | 115 static bool IsValidSinkId(const std::string& sink_id); |
108 | 116 |
109 private: | 117 private: |
110 void InternalCopyAssignFrom(const MediaSinkInternal& other); | 118 void InternalCopyAssignFrom(const MediaSinkInternal& other); |
111 void InternalCopyConstructFrom(const MediaSinkInternal& other); | 119 void InternalCopyConstructFrom(const MediaSinkInternal& other); |
| 120 void InternalMoveConstructFrom(MediaSinkInternal&& other); |
112 void InternalCleanup(); | 121 void InternalCleanup(); |
113 | 122 |
114 enum class SinkType { GENERIC, DIAL, CAST }; | 123 enum class SinkType { GENERIC, DIAL, CAST }; |
115 | 124 |
116 MediaSink sink_; | 125 MediaSink sink_; |
117 | 126 |
118 SinkType sink_type_; | 127 SinkType sink_type_; |
119 | 128 |
120 union { | 129 union { |
121 // Set if sink is DIAL sink. | 130 // Set if sink is DIAL sink. |
122 base::ManualConstructor<DialSinkExtraData> dial_data_; | 131 base::ManualConstructor<DialSinkExtraData> dial_data_; |
123 | 132 |
124 // Set if sink is Cast sink. | 133 // Set if sink is Cast sink. |
125 base::ManualConstructor<CastSinkExtraData> cast_data_; | 134 base::ManualConstructor<CastSinkExtraData> cast_data_; |
126 }; | 135 }; |
127 }; | 136 }; |
128 | 137 |
129 } // namespace media_router | 138 } // namespace media_router |
130 | 139 |
131 #endif // CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_INTERNAL_H_ | 140 #endif // CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_INTERNAL_H_ |
OLD | NEW |