mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add support for media device discovery and messaging (fixes issue #2900)
Chromium supports communication with media devices on the local network via the Cast and DIAL protocols. This takes two primary forms: 1. Messaging, where strings representing state information are passed between the client and a dedicated receiver app on the media device. The receiver app communicates directly with an app-specific backend service to retrieve and possibly control media playback. 2. Tab/desktop mirroring, where the media contents are streamed directly from the browser to a generic streaming app on the media device and playback is controlled by the browser. This change adds support for device discovery and messaging (but not mirroring) with functionality exposed via the new CefMediaRouter interface. To test: Navigate to http://tests/media_router in cefclient and follow the on-screen instructions.
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/download_manager_delegate.h"
|
||||
#include "libcef/browser/extensions/extension_system.h"
|
||||
#include "libcef/browser/media_router/media_router_manager.h"
|
||||
#include "libcef/browser/prefs/browser_prefs.h"
|
||||
#include "libcef/browser/request_context_impl.h"
|
||||
#include "libcef/browser/ssl_host_state_delegate.h"
|
||||
@ -164,6 +165,11 @@ base::LazyInstance<ImplManager>::DestructorAtExit g_manager =
|
||||
base::LazyInstance<ImplManager>::Leaky g_manager = LAZY_INSTANCE_INITIALIZER;
|
||||
#endif
|
||||
|
||||
CefBrowserContext* GetSelf(base::WeakPtr<CefBrowserContext> self) {
|
||||
CEF_REQUIRE_UIT();
|
||||
return self.get();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Creates and manages VisitedLinkEventListener objects for each
|
||||
@ -220,8 +226,9 @@ class CefVisitedLinkListener : public visitedlink::VisitedLinkWriter::Listener {
|
||||
};
|
||||
|
||||
CefBrowserContext::CefBrowserContext(const CefRequestContextSettings& settings)
|
||||
: settings_(settings) {
|
||||
: settings_(settings), weak_ptr_factory_(this) {
|
||||
g_manager.Get().AddImpl(this);
|
||||
getter_ = base::BindRepeating(GetSelf, weak_ptr_factory_.GetWeakPtr());
|
||||
}
|
||||
|
||||
CefBrowserContext::~CefBrowserContext() {
|
||||
@ -233,6 +240,9 @@ CefBrowserContext::~CefBrowserContext() {
|
||||
// Unregister the context first to avoid re-entrancy during shutdown.
|
||||
g_manager.Get().RemoveImpl(this, cache_path_);
|
||||
|
||||
// Destroy objects that may hold references to the MediaRouter.
|
||||
media_router_manager_.reset();
|
||||
|
||||
// Send notifications to clean up objects associated with this Profile.
|
||||
MaybeSendDestroyedNotification();
|
||||
|
||||
@ -812,3 +822,11 @@ bool CefBrowserContext::IsPrintPreviewSupported() const {
|
||||
|
||||
return !GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled);
|
||||
}
|
||||
|
||||
CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!media_router_manager_) {
|
||||
media_router_manager_.reset(new CefMediaRouterManager(this));
|
||||
}
|
||||
return media_router_manager_.get();
|
||||
}
|
||||
|
Reference in New Issue
Block a user