Chromium Code Reviews| Index: chrome/browser/media/router/typed_media_sink.h |
| diff --git a/chrome/browser/media/router/typed_media_sink.h b/chrome/browser/media/router/typed_media_sink.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e15390020fe2012f02e70276e54b8469cce767de |
| --- /dev/null |
| +++ b/chrome/browser/media/router/typed_media_sink.h |
| @@ -0,0 +1,87 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_MEDIA_ROUTER_TYPED_MEDIA_SINK_H_ |
| +#define CHROME_BROWSER_MEDIA_ROUTER_TYPED_MEDIA_SINK_H_ |
| + |
| +#include "chrome/browser/media/router/media_sink.h" |
| +#include "url/gurl.h" |
| + |
| +namespace media_router { |
| + |
| +// Extra data for dial media sink. |
| +struct DialSinkExtraData { |
| + // The base URL used for DIAL operations. |
| + GURL app_url; |
| +}; |
| + |
| +// Extra data for cast media sink. |
| +struct CastSinkExtraData { |
| + // A bit vector representing the capabilities of the sink. |
| + int capabilities; |
|
imcheng
2017/02/11 01:00:22
= 0;
zhaobin
2017/02/14 02:08:49
Done.
|
| + |
| + // ID of Cast channel opened for the sink. |
| + int cast_channel_id; |
|
imcheng
2017/02/11 01:00:22
ditto
zhaobin
2017/02/14 02:08:49
Done.
|
| +}; |
| + |
| +// Represents a media sink discovered by MediaSinkService. |
|
imcheng
2017/02/11 01:00:22
Comment that this is only used by MediaSinkService
zhaobin
2017/02/14 02:08:49
Done.
|
| +class TypedMediaSink { |
| + public: |
| + // SinkType indicates if sink is discovered by DIAL / CAST media sink |
| + // services. |
| + enum class SinkType { |
| + UNKNOWN = 0, |
| + DIAL, |
| + CAST, |
| + }; |
| + |
| + TypedMediaSink(const MediaSink::Id& sink_id, |
|
imcheng
2017/02/11 01:00:22
How about these two ctors in addition to the empty
zhaobin
2017/02/14 02:08:49
Done.
|
| + const std::string& name, |
| + const MediaSink::IconType icon_type); |
| + TypedMediaSink(); |
| + ~TypedMediaSink(); |
| + |
| + TypedMediaSink& operator=(const TypedMediaSink& other); |
| + |
| + void set_sink(const MediaSink& sink) { sink_ = sink; } |
| + const MediaSink& sink() const { return sink_; } |
| + void set_ip_address(const std::string& ip_address) { |
| + ip_address_ = ip_address; |
| + } |
| + const std::string& ip_address() const { return ip_address_; } |
| + void set_model_name(const std::string& model_name) { |
| + model_name_ = model_name; |
| + } |
| + const base::Optional<std::string>& model_name() const { return model_name_; } |
| + |
| + void set_dial_sink_extra_data(const DialSinkExtraData& dial_sink_extra_data); |
| + const DialSinkExtraData* dial_sink_extra_data() const; |
| + void set_cast_sink_extra_data(const CastSinkExtraData& cast_sink_extra_data); |
| + const CastSinkExtraData* cast_sink_extra_data() const; |
| + |
| + bool is_dial_sink() const { return type_ == SinkType::DIAL; } |
| + bool is_cast_sink() const { return type_ == SinkType::CAST; } |
| + |
| + private: |
| + MediaSink sink_; |
| + |
| + std::string ip_address_; |
| + |
| + // Model name of the sink, if it represents a physical device. |
| + base::Optional<std::string> model_name_; |
| + |
| + // Type of the MediaSink. |
| + SinkType type_; |
| + |
| + union { |
| + // Set this field if |type_| == DIAL. |
| + DialSinkExtraData dial_sink_extra_data_; |
| + // Set this field if |type_| == CAST. |
| + CastSinkExtraData cast_sink_extra_data_; |
| + }; |
| +}; |
| + |
| +} // namespace media_router |
| + |
| +#endif // CHROME_BROWSER_MEDIA_ROUTER_TYPED_MEDIA_SINK_H_ |