Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: chrome/browser/media/router/discovery/media_sink_internal.h

Issue 2675033002: [Media Router] Add MediaSink subtypes (Closed)
Patch Set: resolve code review comments from Derek and Mark Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 <utility>
9
10 #include "base/memory/manual_constructor.h"
11 #include "chrome/browser/media/router/media_sink.h"
12 #include "net/base/ip_address.h"
13 #include "url/gurl.h"
14
15 namespace media_router {
16
17 // Extra data for DIAL media sink.
18 struct DialSinkExtraData {
19 net::IPAddress ip_address;
20
21 // Model name of the sink.
22 std::string model_name;
23
24 // The base URL used for DIAL operations.
25 GURL app_url;
26
27 DialSinkExtraData();
28 DialSinkExtraData(const DialSinkExtraData& other);
29 ~DialSinkExtraData();
30
31 bool operator==(const DialSinkExtraData& other) const;
32 };
33
34 // Extra data for Cast media sink.
35 struct CastSinkExtraData {
36 net::IPAddress ip_address;
37
38 // Model name of the sink.
39 std::string model_name;
40
41 // A bit vector representing the capabilities of the sink. The values are
42 // defined in media_router.mojom.
43 uint8_t capabilities = 0;
44
45 // 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
47 // browser reconnects to a device.
48 int cast_channel_id = 0;
49
50 CastSinkExtraData();
51 CastSinkExtraData(const CastSinkExtraData& other);
52 ~CastSinkExtraData();
53
54 bool operator==(const CastSinkExtraData& other) const;
55 };
56
57 // Represents a media sink discovered by MediaSinkService. It is used by
58 // MediaSinkService to push MediaSinks with extra data to the
59 // MediaRouteProvider, and it is not exposed to users of MediaRouter.
60 class MediaSinkInternal {
61 public:
62 // Used by mojo.
63 MediaSinkInternal();
64
65 // Used by MediaSinkService to create media sinks.
66 MediaSinkInternal(const MediaSink& sink, const DialSinkExtraData& dial_data);
67 MediaSinkInternal(const MediaSink& sink, const CastSinkExtraData& cast_data);
68
69 // Used to push instance of this class into vector.
70 MediaSinkInternal(const MediaSinkInternal& other);
71
72 ~MediaSinkInternal();
73
74 MediaSinkInternal& operator=(const MediaSinkInternal& other);
75 bool operator==(const MediaSinkInternal& other) const;
76
77 // Used by mojo.
78 void set_sink_id(const MediaSink::Id& sink_id) { sink_.set_sink_id(sink_id); }
79 void set_name(const std::string& name) { sink_.set_name(name); }
80 void set_description(const std::string& description) {
81 sink_.set_description(description);
82 }
83 void set_domain(const std::string& domain) { sink_.set_domain(domain); }
84 void set_icon_type(MediaSink::IconType icon_type) {
85 sink_.set_icon_type(icon_type);
86 }
87
88 void set_sink(const MediaSink& sink);
89 const MediaSink& sink() const { return sink_; }
90
91 void set_dial_data(const DialSinkExtraData& dial_data);
92
93 // Must only be called if the sink is a DIAL sink.
94 const DialSinkExtraData& dial_data() const;
95
96 void set_cast_data(const CastSinkExtraData& cast_data);
97
98 // Must only be called if the sink is a Cast sink.
99 const CastSinkExtraData& cast_data() const;
100
101 bool is_dial_sink() const { return sink_type_ == SinkType::DIAL; }
102 bool is_cast_sink() const { return sink_type_ == SinkType::CAST; }
103
104 static bool IsValidSinkId(const std::string& sink_id);
105
106 private:
107 void InternalCopyAssignFrom(const MediaSinkInternal& other);
108 void InternalCopyConstructFrom(const MediaSinkInternal& other);
109 void InternalCleanup();
110
111 enum class SinkType { GENERIC, DIAL, CAST };
112
113 MediaSink sink_;
114
115 SinkType sink_type_;
116
117 union {
118 // Set if sink is DIAL sink.
119 base::ManualConstructor<DialSinkExtraData> dial_data_;
120
121 // Set if sink is Cast sink.
122 base::ManualConstructor<CastSinkExtraData> cast_data_;
123 };
124 };
125
126 } // namespace media_router
127
128 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_INTERNAL_H_
OLDNEW
« no previous file with comments | « chrome/browser/media/router/BUILD.gn ('k') | chrome/browser/media/router/discovery/media_sink_internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698