blob: d79e1ce930e12747e494fcd9f82d4cf8dad4530b [file] [log] [blame]
// Copyright 2014 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.
#include "base/compiler_specific.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "content/common/content_export.h"
#include "content/public/browser/web_contents_observer.h"
namespace content {
class BrowserCdmManager;
class BrowserMediaPlayerManager;
class RenderViewHost;
// This class manages all RenderFrame based media related managers at the
// browser side. It receives IPC messages from media RenderFrameObservers and
// forwards them to the corresponding managers. The managers are responsible
// for sending IPCs back to the RenderFrameObservers at the render side.
class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver {
explicit MediaWebContentsObserver(RenderViewHost* render_view_host);
virtual ~MediaWebContentsObserver();
// WebContentsObserver implementations.
virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
#if defined(OS_ANDROID)
virtual bool OnMessageReceived(const IPC::Message& message,
RenderFrameHost* render_frame_host) override;
// Helper functions to handle media player IPC messages. Returns whether the
// |message| is handled in the function.
bool OnMediaPlayerMessageReceived(const IPC::Message& message,
RenderFrameHost* render_frame_host);
bool OnMediaPlayerSetCdmMessageReceived(const IPC::Message& message,
RenderFrameHost* render_frame_host);
// Gets the media player manager associated with |render_frame_host|. Creates
// a new one if it doesn't exist. The caller doesn't own the returned pointer.
BrowserMediaPlayerManager* GetMediaPlayerManager(
RenderFrameHost* render_frame_host);
void OnSetCdm(RenderFrameHost* render_frame_host, int player_id, int cdm_id);
#if defined(VIDEO_HOLE)
void OnFrameInfoUpdated();
#endif // defined(VIDEO_HOLE)
// Map from RenderFrameHost* to BrowserMediaPlayerManager.
typedef base::ScopedPtrHashMap<uintptr_t, BrowserMediaPlayerManager>
MediaPlayerManagerMap media_player_managers_;
#endif // defined(OS_ANDROID)
} // namespace content