VideoFullscreenManager.h [plain text]
#pragma once
#if ENABLE(VIDEO_PRESENTATION_MODE)
#include "Connection.h"
#include "MessageReceiver.h"
#include "PlaybackSessionContextIdentifier.h"
#include "VideoFullscreenManagerMessagesReplies.h"
#include <WebCore/EventListener.h>
#include <WebCore/HTMLMediaElementEnums.h>
#include <WebCore/PlatformCALayer.h>
#include <WebCore/VideoFullscreenModelVideoElement.h>
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
namespace IPC {
class Attachment;
class Connection;
class Decoder;
class MessageReceiver;
}
namespace WebCore {
class FloatSize;
class Node;
}
namespace WebKit {
class LayerHostingContext;
class WebPage;
class PlaybackSessionInterfaceContext;
class PlaybackSessionManager;
class VideoFullscreenManager;
class VideoFullscreenInterfaceContext
: public RefCounted<VideoFullscreenInterfaceContext>
, public WebCore::VideoFullscreenModelClient {
public:
static Ref<VideoFullscreenInterfaceContext> create(VideoFullscreenManager& manager, PlaybackSessionContextIdentifier contextId)
{
return adoptRef(*new VideoFullscreenInterfaceContext(manager, contextId));
}
virtual ~VideoFullscreenInterfaceContext();
void invalidate() { m_manager = nullptr; }
LayerHostingContext* layerHostingContext() { return m_layerHostingContext.get(); }
void setLayerHostingContext(std::unique_ptr<LayerHostingContext>&&);
enum class AnimationType { None, IntoFullscreen, FromFullscreen };
AnimationType animationState() const { return m_animationType; }
void setAnimationState(AnimationType flag) { m_animationType = flag; }
bool targetIsFullscreen() const { return m_targetIsFullscreen; }
void setTargetIsFullscreen(bool flag) { m_targetIsFullscreen = flag; }
WebCore::HTMLMediaElementEnums::VideoFullscreenMode fullscreenMode() const { return m_fullscreenMode; }
void setFullscreenMode(WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode) { m_fullscreenMode = mode; }
bool fullscreenStandby() const { return m_fullscreenStandby; }
void setFullscreenStandby(bool value) { m_fullscreenStandby = value; }
bool isFullscreen() const { return m_isFullscreen; }
void setIsFullscreen(bool flag) { m_isFullscreen = flag; }
private:
void hasVideoChanged(bool) override;
void videoDimensionsChanged(const WebCore::FloatSize&) override;
VideoFullscreenInterfaceContext(VideoFullscreenManager&, PlaybackSessionContextIdentifier);
VideoFullscreenManager* m_manager;
PlaybackSessionContextIdentifier m_contextId;
std::unique_ptr<LayerHostingContext> m_layerHostingContext;
AnimationType m_animationType { false };
bool m_targetIsFullscreen { false };
WebCore::HTMLMediaElementEnums::VideoFullscreenMode m_fullscreenMode { WebCore::HTMLMediaElementEnums::VideoFullscreenModeNone };
bool m_fullscreenStandby { false };
bool m_isFullscreen { false };
};
class VideoFullscreenManager : public RefCounted<VideoFullscreenManager>, private IPC::MessageReceiver {
public:
static Ref<VideoFullscreenManager> create(WebPage&, PlaybackSessionManager&);
virtual ~VideoFullscreenManager();
void invalidate();
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
bool supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) const;
bool supportsVideoFullscreenStandby() const;
void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool standby);
void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&);
void exitVideoFullscreenToModeWithoutAnimation(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
protected:
friend class VideoFullscreenInterfaceContext;
explicit VideoFullscreenManager(WebPage&, PlaybackSessionManager&);
typedef std::tuple<RefPtr<WebCore::VideoFullscreenModelVideoElement>, RefPtr<VideoFullscreenInterfaceContext>> ModelInterfaceTuple;
ModelInterfaceTuple createModelAndInterface(PlaybackSessionContextIdentifier);
ModelInterfaceTuple& ensureModelAndInterface(PlaybackSessionContextIdentifier);
WebCore::VideoFullscreenModelVideoElement& ensureModel(PlaybackSessionContextIdentifier);
VideoFullscreenInterfaceContext& ensureInterface(PlaybackSessionContextIdentifier);
void removeContext(PlaybackSessionContextIdentifier);
void addClientForContext(PlaybackSessionContextIdentifier);
void removeClientForContext(PlaybackSessionContextIdentifier);
void hasVideoChanged(PlaybackSessionContextIdentifier, bool hasVideo);
void videoDimensionsChanged(PlaybackSessionContextIdentifier, const WebCore::FloatSize&);
void requestFullscreenMode(PlaybackSessionContextIdentifier, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool finishedWithMedia);
void requestUpdateInlineRect(PlaybackSessionContextIdentifier);
void requestVideoContentLayer(PlaybackSessionContextIdentifier);
void returnVideoContentLayer(PlaybackSessionContextIdentifier);
void didSetupFullscreen(PlaybackSessionContextIdentifier);
void willExitFullscreen(PlaybackSessionContextIdentifier);
void didExitFullscreen(PlaybackSessionContextIdentifier);
void didEnterFullscreen(PlaybackSessionContextIdentifier);
void didCleanupFullscreen(PlaybackSessionContextIdentifier);
void setVideoLayerFrameFenced(PlaybackSessionContextIdentifier, WebCore::FloatRect bounds, IPC::Attachment fencePort);
void setVideoLayerGravityEnum(PlaybackSessionContextIdentifier, unsigned gravity);
void fullscreenModeChanged(PlaybackSessionContextIdentifier, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
void fullscreenWillReturnToInline(PlaybackSessionContextIdentifier, bool isPageVisible);
void requestRouteSharingPolicyAndContextUID(PlaybackSessionContextIdentifier, Messages::VideoFullscreenManager::RequestRouteSharingPolicyAndContextUIDAsyncReply&&);
WebPage* m_page;
Ref<PlaybackSessionManager> m_playbackSessionManager;
HashMap<WebCore::HTMLVideoElement*, PlaybackSessionContextIdentifier> m_videoElements;
HashMap<PlaybackSessionContextIdentifier, ModelInterfaceTuple> m_contextMap;
PlaybackSessionContextIdentifier m_controlsManagerContextId;
HashMap<PlaybackSessionContextIdentifier, int> m_clientCounts;
};
}
#endif // ENABLE(VIDEO_PRESENTATION_MODE)