cef/libcef/browser/media_router/media_sink_impl.cc
Marshall Greenblatt ff0c36b465 Add CefMediaSink::GetIconType (see issue #2900)
This attribute is useful for identifying different classes of cast devices
without first requiring a connection (CAST, CAST_AUDIO, CAST_AUDIO_GROUP, etc).
2020-04-29 15:01:12 -04:00

56 lines
1.6 KiB
C++

// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/browser/media_router/media_sink_impl.h"
CefMediaSinkImpl::CefMediaSinkImpl(const media_router::MediaSink& sink)
: sink_(sink) {}
CefMediaSinkImpl::CefMediaSinkImpl(const media_router::MediaSink::Id& sink_id,
const std::string& sink_name)
: sink_(sink_id, sink_name, media_router::SinkIconType::GENERIC) {}
CefString CefMediaSinkImpl::GetId() {
return sink_.id();
}
bool CefMediaSinkImpl::IsValid() {
return true;
}
CefString CefMediaSinkImpl::GetName() {
return sink_.name();
}
CefString CefMediaSinkImpl::GetDescription() {
return sink_.description().value_or("");
}
CefMediaSink::IconType CefMediaSinkImpl::GetIconType() {
// Verify that our enum matches Chromium's values.
static_assert(static_cast<int>(CEF_MSIT_TOTAL_COUNT) ==
static_cast<int>(media_router::SinkIconType::TOTAL_COUNT),
"enum mismatch");
return static_cast<CefMediaSink::IconType>(sink_.icon_type());
}
bool CefMediaSinkImpl::IsCastSink() {
return sink_.provider_id() == media_router::CAST;
}
bool CefMediaSinkImpl::IsDialSink() {
return sink_.provider_id() == media_router::DIAL;
}
bool CefMediaSinkImpl::IsCompatibleWith(CefRefPtr<CefMediaSource> source) {
if (source) {
if (IsCastSink())
return source->IsCastSource();
if (IsDialSink())
return source->IsDialSource();
}
return false;
}