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_MEDIA_SINK_INTERNAL_H_ | |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_INTERNAL_H_ | |
7 | |
8 #include "chrome/browser/media/router/media_sink.h" | |
9 #include "url/gurl.h" | |
10 | |
11 namespace media_router { | |
12 | |
13 // Extra data for dial media sink. | |
14 struct DialSinkExtraData { | |
15 std::string ip_address; | |
16 | |
17 // Model name of the sink, if it represents a physical device. | |
18 base::Optional<std::string> model_name; | |
19 | |
20 // The base URL used for DIAL operations. | |
21 GURL app_url; | |
22 | |
23 DialSinkExtraData(); | |
24 DialSinkExtraData(const DialSinkExtraData& other); | |
25 ~DialSinkExtraData(); | |
26 }; | |
27 | |
28 // Extra data for cast media sink. | |
29 struct CastSinkExtraData { | |
30 std::string ip_address; | |
31 | |
32 // Model name of the sink, if it represents a physical device. | |
33 base::Optional<std::string> model_name; | |
34 | |
35 // A bit vector representing the capabilities of the sink. | |
mark a. foltz
2017/02/25 01:10:24
Can you mention that the values are defined in the
zhaobin
2017/02/27 21:45:14
Done.
| |
36 int capabilities = 0; | |
mark a. foltz
2017/02/25 01:10:24
Is the default a valid set of capabilities, or mus
zhaobin
2017/02/27 21:45:15
Done.
| |
37 | |
38 // ID of Cast channel opened for the sink. | |
39 int cast_channel_id = 0; | |
mark a. foltz
2017/02/25 01:10:23
Similar question - document that the caller must s
zhaobin
2017/02/27 21:45:14
Done.
| |
40 | |
41 CastSinkExtraData(); | |
42 CastSinkExtraData(const CastSinkExtraData& other); | |
43 ~CastSinkExtraData(); | |
44 }; | |
45 | |
46 // Represents a media sink discovered by MediaSinkService. | |
imcheng
2017/02/24 23:54:20
You may also mention that it is used by MediaSinkS
zhaobin
2017/02/27 21:45:14
Done.
| |
47 class MediaSinkInternal { | |
mark a. foltz
2017/02/25 01:10:23
This is really an implementation detail of the med
zhaobin
2017/02/27 21:45:15
Done.
| |
48 public: | |
49 // SinkType indicates if sink is discovered by DIAL / CAST media sink | |
50 // services. | |
51 enum class SinkType { | |
mark a. foltz
2017/02/25 01:10:24
This can be inferred from which of the optional fi
zhaobin
2017/02/27 21:45:14
Done.
| |
52 GENERIC = 0, | |
53 DIAL, | |
54 CAST, | |
55 }; | |
56 | |
57 explicit MediaSinkInternal(const MediaSink& sink); | |
58 MediaSinkInternal(const MediaSink& sink, const DialSinkExtraData& dial_data); | |
59 MediaSinkInternal(const MediaSink& sink, const CastSinkExtraData& cast_data); | |
60 MediaSinkInternal(); | |
61 MediaSinkInternal(const MediaSinkInternal& other); | |
mark a. foltz
2017/02/25 01:10:24
Define operator== as well? Especially helpful for
zhaobin
2017/02/27 21:45:14
Done.
| |
62 ~MediaSinkInternal(); | |
63 | |
64 // Set |sink_| and invalidate extra data. | |
65 void set_sink(const MediaSink& sink); | |
66 const MediaSink& sink() const { return sink_; } | |
67 | |
68 void set_dial_data(const DialSinkExtraData& dial_data); | |
69 const DialSinkExtraData& dial_data() const; | |
70 void set_cast_data(const CastSinkExtraData& cast_data); | |
71 const CastSinkExtraData& cast_data() const; | |
72 | |
73 bool is_dial_sink() const { return type_ == SinkType::DIAL; } | |
74 bool is_cast_sink() const { return type_ == SinkType::CAST; } | |
75 | |
76 private: | |
77 MediaSink sink_; | |
78 | |
79 // Type of the MediaSink. | |
80 SinkType type_; | |
81 | |
82 // Set this field if |type_| == DIAL. | |
zhaobin
2017/02/24 02:19:15
Tried to use union, but cannot store DialSinkExtra
imcheng
2017/02/24 23:54:20
I think it is fine to not use union as our code is
imcheng
2017/02/24 23:54:20
s/this field// here and below.
mark a. foltz
2017/02/25 01:10:23
base::Optional<> is a good solution here. It's wh
zhaobin
2017/02/27 21:45:15
Done.
| |
83 base::Optional<DialSinkExtraData> dial_data_; | |
84 | |
85 // Set this field if |type_| == CAST. | |
86 base::Optional<CastSinkExtraData> cast_data_; | |
87 }; | |
88 | |
89 } // namespace media_router | |
90 | |
91 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_INTERNAL_H_ | |
OLD | NEW |