2011-04-06 Alexis Menard <alexis.menard@openbossa.org>

        Reviewed by Andreas Kling.

        [Qt] Implement fullscreen playback for the GStreamer backend.
        https://bugs.webkit.org/show_bug.cgi?id=56826

        Implement support for fullscreen playback when building the
        Qt port with the GStreamer backend (DEFINES+=USE_GSTREAMER=1).
        The implementation is done in FullScreenVideoQt alongside with
        the Qt Multimedia support.

        No new tests because layout tests cover it. They are not yet activated
        but will be any time soon.

        * platform/graphics/gstreamer/PlatformVideoWindowPrivate.h:
        * platform/graphics/gstreamer/PlatformVideoWindowQt.cpp:
        (FullScreenVideoWindow::FullScreenVideoWindow):
        (FullScreenVideoWindow::setVideoElement):
        (FullScreenVideoWindow::closeEvent):
        (FullScreenVideoWindow::keyPressEvent):
        (FullScreenVideoWindow::event):
        (FullScreenVideoWindow::showFullScreen):
        (FullScreenVideoWindow::hideCursor):
        (FullScreenVideoWindow::showCursor):
2011-04-06  Alexis Menard  <alexis.menard@openbossa.org>

        Reviewed by Andreas Kling.

        [Qt] Implement fullscreen playback for the GStreamer backend.
        https://bugs.webkit.org/show_bug.cgi?id=56826

        Implement support for fullscreen playback when building the
        Qt port with the GStreamer backend (DEFINES+=USE_GSTREAMER=1).
        The implementation is done in FullScreenVideoQt alongside with
        the Qt Multimedia support.

        No new tests because layout tests cover it. They are not yet activated
        but will be any time soon.

        * QtWebKit.pro:
        * WebCoreSupport/ChromeClientQt.cpp:
        (WebCore::ChromeClientQt::ChromeClientQt):
        (WebCore::ChromeClientQt::~ChromeClientQt):
        (WebCore::ChromeClientQt::enterFullscreenForNode):
        (WebCore::ChromeClientQt::exitFullscreenForNode):
        * WebCoreSupport/ChromeClientQt.h:
        * WebCoreSupport/FullScreenVideoQt.cpp:
        (WebCore::GStreamerFullScreenVideoHandler::GStreamerFullScreenVideoHandler):
        (WebCore::GStreamerFullScreenVideoHandler::setVideoElement):
        (WebCore::GStreamerFullScreenVideoHandler::enterFullScreen):
        (WebCore::GStreamerFullScreenVideoHandler::windowClosed):
        (WebCore::GStreamerFullScreenVideoHandler::exitFullScreen):
        (WebCore::DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler):
        (WebCore::FullScreenVideoQt::FullScreenVideoQt):
        (WebCore::FullScreenVideoQt::~FullScreenVideoQt):
        (WebCore::FullScreenVideoQt::enterFullScreenForNode):
        (WebCore::FullScreenVideoQt::exitFullScreenForNode):
        (WebCore::FullScreenVideoQt::requiresFullScreenForVideoPlayback):
        (WebCore::FullScreenVideoQt::isValid):
        * WebCoreSupport/FullScreenVideoQt.h:
        (WebCore::GStreamerFullScreenVideoHandler::~GStreamerFullScreenVideoHandler):

git-svn-id: svn://svn.chromium.org/blink/trunk@83078 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 1c7b79be
2011-04-06 Alexis Menard <alexis.menard@openbossa.org>
Reviewed by Andreas Kling.
[Qt] Implement fullscreen playback for the GStreamer backend.
https://bugs.webkit.org/show_bug.cgi?id=56826
Implement support for fullscreen playback when building the
Qt port with the GStreamer backend (DEFINES+=USE_GSTREAMER=1).
The implementation is done in FullScreenVideoQt alongside with
the Qt Multimedia support.
No new tests because layout tests cover it. They are not yet activated
but will be any time soon.
* platform/graphics/gstreamer/PlatformVideoWindowPrivate.h:
* platform/graphics/gstreamer/PlatformVideoWindowQt.cpp:
(FullScreenVideoWindow::FullScreenVideoWindow):
(FullScreenVideoWindow::setVideoElement):
(FullScreenVideoWindow::closeEvent):
(FullScreenVideoWindow::keyPressEvent):
(FullScreenVideoWindow::event):
(FullScreenVideoWindow::showFullScreen):
(FullScreenVideoWindow::hideCursor):
(FullScreenVideoWindow::showCursor):
2011-04-06 Ryosuke Niwa <rniwa@webkit.org> 2011-04-06 Ryosuke Niwa <rniwa@webkit.org>
Reviewed by Dimitri Glazkov. Reviewed by Dimitri Glazkov.
...@@ -20,21 +20,37 @@ ...@@ -20,21 +20,37 @@
#ifndef PlatformVideoWindowPrivate_h #ifndef PlatformVideoWindowPrivate_h
#define PlatformVideoWindowPrivate_h #define PlatformVideoWindowPrivate_h
#include <QTimer>
#include <QWidget> #include <QWidget>
class QKeyEvent; class QKeyEvent;
namespace WebCore { namespace WebCore {
class HTMLVideoElement;
class FullScreenVideoWindow: public QWidget { class FullScreenVideoWindow: public QWidget {
Q_OBJECT Q_OBJECT
public: public:
FullScreenVideoWindow(); FullScreenVideoWindow();
void setVideoElement(HTMLVideoElement*);
signals: signals:
void closed(); void closed();
protected: protected:
void keyPressEvent(QKeyEvent* ev); void closeEvent(QCloseEvent*);
bool event(QEvent* ev); void keyPressEvent(QKeyEvent*);
bool event(QEvent*);
public slots:
void showFullScreen();
private slots:
void hideCursor();
private:
void showCursor();
QTimer m_cursorTimer;
HTMLVideoElement* m_mediaElement;
}; };
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "config.h" #include "config.h"
#include "PlatformVideoWindow.h" #include "PlatformVideoWindow.h"
#include "HTMLVideoElement.h"
#include "PlatformVideoWindowPrivate.h" #include "PlatformVideoWindowPrivate.h"
#include <QApplication> #include <QApplication>
...@@ -28,29 +29,55 @@ ...@@ -28,29 +29,55 @@
#include <QPalette> #include <QPalette>
using namespace WebCore; using namespace WebCore;
static const int gHideMouseCursorDelay = 3000;
FullScreenVideoWindow::FullScreenVideoWindow() FullScreenVideoWindow::FullScreenVideoWindow()
: QWidget(0, Qt::Window) : QWidget(0, Qt::Window)
, m_mediaElement(0)
{ {
setAttribute(Qt::WA_NativeWindow); setAttribute(Qt::WA_NativeWindow);
// Setting these values ensures smooth resizing since it setWindowModality(Qt::ApplicationModal);
// will prevent the system from clearing the background.
setAttribute(Qt::WA_NoSystemBackground, true); setAttribute(Qt::WA_NoSystemBackground, true);
setAttribute(Qt::WA_PaintOnScreen, true); setAttribute(Qt::WA_PaintOnScreen, true);
m_cursorTimer.setSingleShot(true);
connect(&m_cursorTimer, SIGNAL(timeout()), this, SLOT(hideCursor()));
}
void FullScreenVideoWindow::setVideoElement(HTMLVideoElement* element)
{
m_mediaElement = element;
}
void FullScreenVideoWindow::closeEvent(QCloseEvent*)
{
m_cursorTimer.stop();
setMouseTracking(false);
releaseMouse();
QApplication::restoreOverrideCursor();
} }
void FullScreenVideoWindow::keyPressEvent(QKeyEvent* ev) void FullScreenVideoWindow::keyPressEvent(QKeyEvent* ev)
{ {
if (ev->key() == Qt::Key_Escape) { if (m_mediaElement && ev->key() == Qt::Key_Space) {
close(); if (!m_mediaElement->paused())
m_mediaElement->pause(true);
else
m_mediaElement->play(true);
} else if (ev->key() == Qt::Key_Escape)
emit closed(); emit closed();
} QWidget::keyPressEvent(ev);
} }
bool FullScreenVideoWindow::event(QEvent* ev) bool FullScreenVideoWindow::event(QEvent* ev)
{ {
switch (ev->type()) { switch (ev->type()) {
case QEvent::MouseMove:
showCursor();
ev->accept();
return true;
case QEvent::MouseButtonDblClick: case QEvent::MouseButtonDblClick:
close(); emit closed();
ev->accept(); ev->accept();
return true; return true;
default: default:
...@@ -58,6 +85,26 @@ bool FullScreenVideoWindow::event(QEvent* ev) ...@@ -58,6 +85,26 @@ bool FullScreenVideoWindow::event(QEvent* ev)
} }
} }
void FullScreenVideoWindow::showFullScreen()
{
QWidget::showFullScreen();
setMouseTracking(true);
raise();
setFocus();
hideCursor();
}
void FullScreenVideoWindow::hideCursor()
{
QApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
}
void FullScreenVideoWindow::showCursor()
{
QApplication::restoreOverrideCursor();
m_cursorTimer.start(gHideMouseCursorDelay);
}
PlatformVideoWindow::PlatformVideoWindow() PlatformVideoWindow::PlatformVideoWindow()
{ {
......
2011-04-06 Alexis Menard <alexis.menard@openbossa.org>
Reviewed by Andreas Kling.
[Qt] Implement fullscreen playback for the GStreamer backend.
https://bugs.webkit.org/show_bug.cgi?id=56826
Implement support for fullscreen playback when building the
Qt port with the GStreamer backend (DEFINES+=USE_GSTREAMER=1).
The implementation is done in FullScreenVideoQt alongside with
the Qt Multimedia support.
No new tests because layout tests cover it. They are not yet activated
but will be any time soon.
* QtWebKit.pro:
* WebCoreSupport/ChromeClientQt.cpp:
(WebCore::ChromeClientQt::ChromeClientQt):
(WebCore::ChromeClientQt::~ChromeClientQt):
(WebCore::ChromeClientQt::enterFullscreenForNode):
(WebCore::ChromeClientQt::exitFullscreenForNode):
* WebCoreSupport/ChromeClientQt.h:
* WebCoreSupport/FullScreenVideoQt.cpp:
(WebCore::GStreamerFullScreenVideoHandler::GStreamerFullScreenVideoHandler):
(WebCore::GStreamerFullScreenVideoHandler::setVideoElement):
(WebCore::GStreamerFullScreenVideoHandler::enterFullScreen):
(WebCore::GStreamerFullScreenVideoHandler::windowClosed):
(WebCore::GStreamerFullScreenVideoHandler::exitFullScreen):
(WebCore::DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler):
(WebCore::FullScreenVideoQt::FullScreenVideoQt):
(WebCore::FullScreenVideoQt::~FullScreenVideoQt):
(WebCore::FullScreenVideoQt::enterFullScreenForNode):
(WebCore::FullScreenVideoQt::exitFullScreenForNode):
(WebCore::FullScreenVideoQt::requiresFullScreenForVideoPlayback):
(WebCore::FullScreenVideoQt::isValid):
* WebCoreSupport/FullScreenVideoQt.h:
(WebCore::GStreamerFullScreenVideoHandler::~GStreamerFullScreenVideoHandler):
2011-04-06 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> 2011-04-06 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Reviewed by Kenneth Rohde Christiansen. Reviewed by Kenneth Rohde Christiansen.
......
...@@ -211,13 +211,13 @@ contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=1) { ...@@ -211,13 +211,13 @@ contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=1) {
contains(DEFINES, ENABLE_VIDEO=1) { contains(DEFINES, ENABLE_VIDEO=1) {
!contains(DEFINES, USE_GSTREAMER=1):contains(MOBILITY_CONFIG, multimedia) { !contains(DEFINES, USE_GSTREAMER=1):contains(MOBILITY_CONFIG, multimedia) {
HEADERS += \ HEADERS += $$PWD/WebCoreSupport/FullScreenVideoWidget.h
$$PWD/WebCoreSupport/FullScreenVideoQt.h \ SOURCES += $$PWD/WebCoreSupport/FullScreenVideoWidget.cpp
$$PWD/WebCoreSupport/FullScreenVideoWidget.h }
SOURCES += \ contains(DEFINES, USE_GSTREAMER=1) | contains(MOBILITY_CONFIG, multimedia) {
$$PWD/WebCoreSupport/FullScreenVideoQt.cpp \ HEADERS += $$PWD/WebCoreSupport/FullScreenVideoQt.h
$$PWD/WebCoreSupport/FullScreenVideoWidget.cpp SOURCES += $$PWD/WebCoreSupport/FullScreenVideoQt.cpp
} }
} }
......
...@@ -75,13 +75,15 @@ ...@@ -75,13 +75,15 @@
#include <qtooltip.h> #include <qtooltip.h>
#include <wtf/OwnPtr.h> #include <wtf/OwnPtr.h>
#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) #if ENABLE(VIDEO)
#include "FullScreenVideoQt.h" #include "FullScreenVideoQt.h"
#include "HTMLMediaElement.h" #include "HTMLMediaElement.h"
#include "HTMLNames.h" #include "HTMLNames.h"
#include "HTMLVideoElement.h" #include "HTMLVideoElement.h"
#if ENABLE(QT_MULTIMEDIA)
#include "MediaPlayerPrivateQt.h" #include "MediaPlayerPrivateQt.h"
#endif #endif
#endif
namespace WebCore { namespace WebCore {
...@@ -90,7 +92,7 @@ bool ChromeClientQt::dumpVisitedLinksCallbacks = false; ...@@ -90,7 +92,7 @@ bool ChromeClientQt::dumpVisitedLinksCallbacks = false;
ChromeClientQt::ChromeClientQt(QWebPage* webPage) ChromeClientQt::ChromeClientQt(QWebPage* webPage)
: m_webPage(webPage) : m_webPage(webPage)
, m_eventLoop(0) , m_eventLoop(0)
#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) #if ENABLE(VIDEO)
, m_fullScreenVideo(0) , m_fullScreenVideo(0)
#endif #endif
{ {
...@@ -102,7 +104,7 @@ ChromeClientQt::~ChromeClientQt() ...@@ -102,7 +104,7 @@ ChromeClientQt::~ChromeClientQt()
if (m_eventLoop) if (m_eventLoop)
m_eventLoop->exit(); m_eventLoop->exit();
#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) #if ENABLE(VIDEO)
delete m_fullScreenVideo; delete m_fullScreenVideo;
#endif #endif
} }
...@@ -650,7 +652,7 @@ IntRect ChromeClientQt::visibleRectForTiledBackingStore() const ...@@ -650,7 +652,7 @@ IntRect ChromeClientQt::visibleRectForTiledBackingStore() const
} }
#endif #endif
#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) #if ENABLE(VIDEO)
FullScreenVideoQt* ChromeClientQt::fullScreenVideo() FullScreenVideoQt* ChromeClientQt::fullScreenVideo()
{ {
if (!m_fullScreenVideo) if (!m_fullScreenVideo)
...@@ -673,13 +675,6 @@ void ChromeClientQt::enterFullscreenForNode(Node* node) ...@@ -673,13 +675,6 @@ void ChromeClientQt::enterFullscreenForNode(Node* node)
{ {
ASSERT(node && node->hasTagName(HTMLNames::videoTag)); ASSERT(node && node->hasTagName(HTMLNames::videoTag));
HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node);
PlatformMedia platformMedia = videoElement->platformMedia();
ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType);
if (platformMedia.type != PlatformMedia::QtMediaPlayerType)
return;
fullScreenVideo()->enterFullScreenForNode(node); fullScreenVideo()->enterFullScreenForNode(node);
} }
...@@ -687,13 +682,6 @@ void ChromeClientQt::exitFullscreenForNode(Node* node) ...@@ -687,13 +682,6 @@ void ChromeClientQt::exitFullscreenForNode(Node* node)
{ {
ASSERT(node && node->hasTagName(HTMLNames::videoTag)); ASSERT(node && node->hasTagName(HTMLNames::videoTag));
HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node);
PlatformMedia platformMedia = videoElement->platformMedia();
ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType);
if (platformMedia.type != PlatformMedia::QtMediaPlayerType)
return;
fullScreenVideo()->exitFullScreenForNode(node); fullScreenVideo()->exitFullScreenForNode(node);
} }
#endif #endif
......
...@@ -50,7 +50,7 @@ class Page; ...@@ -50,7 +50,7 @@ class Page;
struct FrameLoadRequest; struct FrameLoadRequest;
class QtAbstractWebPopup; class QtAbstractWebPopup;
struct ViewportArguments; struct ViewportArguments;
#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) #if ENABLE(VIDEO)
class FullScreenVideoQt; class FullScreenVideoQt;
#endif #endif
...@@ -163,7 +163,7 @@ public: ...@@ -163,7 +163,7 @@ public:
virtual void needTouchEvents(bool) { } virtual void needTouchEvents(bool) { }
#endif #endif
#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) #if ENABLE(VIDEO)
virtual bool supportsFullscreenForNode(const Node*); virtual bool supportsFullscreenForNode(const Node*);
virtual void enterFullscreenForNode(Node*); virtual void enterFullscreenForNode(Node*);
virtual void exitFullscreenForNode(Node*); virtual void exitFullscreenForNode(Node*);
...@@ -202,7 +202,7 @@ public: ...@@ -202,7 +202,7 @@ public:
bool menuBarVisible; bool menuBarVisible;
QEventLoop* m_eventLoop; QEventLoop* m_eventLoop;
#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA) #if ENABLE(VIDEO)
FullScreenVideoQt* m_fullScreenVideo; FullScreenVideoQt* m_fullScreenVideo;
#endif #endif
......
...@@ -22,18 +22,71 @@ ...@@ -22,18 +22,71 @@
#include "FullScreenVideoQt.h" #include "FullScreenVideoQt.h"
#include "ChromeClientQt.h" #include "ChromeClientQt.h"
#if ENABLE(QT_MULTIMEDIA)
#include "FullScreenVideoWidget.h" #include "FullScreenVideoWidget.h"
#include "MediaPlayerPrivateQt.h"
#endif
#include "HTMLNames.h" #include "HTMLNames.h"
#include "HTMLVideoElement.h" #include "HTMLVideoElement.h"
#include "MediaPlayerPrivateQt.h"
#include "Node.h" #include "Node.h"
#if USE(GSTREAMER)
#include "GStreamerGWorld.h"
#include "PlatformVideoWindowPrivate.h"
#endif
#if ENABLE(QT_MULTIMEDIA)
#include <QGraphicsVideoItem> #include <QGraphicsVideoItem>
#include <QMediaPlayer> #include <QMediaPlayer>
#endif
#include <QWidget>
namespace WebCore { namespace WebCore {
#if USE(GSTREAMER)
GStreamerFullScreenVideoHandler::GStreamerFullScreenVideoHandler()
: m_videoElement(0)
, m_fullScreenWidget(0)
{
}
void GStreamerFullScreenVideoHandler::setVideoElement(HTMLVideoElement* element)
{
m_videoElement = element;
}
void GStreamerFullScreenVideoHandler::enterFullScreen()
{
if (m_videoElement->platformMedia().type != WebCore::PlatformMedia::GStreamerGWorldType)
return;
GStreamerGWorld* gstreamerGWorld = m_videoElement->platformMedia().media.gstreamerGWorld;
if (!gstreamerGWorld->enterFullscreen())
return;
m_fullScreenWidget = reinterpret_cast<FullScreenVideoWindow*>(gstreamerGWorld->platformVideoWindow()->window());
m_fullScreenWidget->setVideoElement(m_videoElement);
connect(m_fullScreenWidget, SIGNAL(closed()), this, SLOT(windowClosed()));
m_fullScreenWidget->showFullScreen();
}
void GStreamerFullScreenVideoHandler::windowClosed()
{
m_videoElement->exitFullscreen();
}
void GStreamerFullScreenVideoHandler::exitFullScreen()
{
if (m_videoElement->platformMedia().type == WebCore::PlatformMedia::GStreamerGWorldType)
m_videoElement->platformMedia().media.gstreamerGWorld->exitFullscreen();
m_fullScreenWidget->setVideoElement(0);
m_fullScreenWidget->close();
}
#endif
#if ENABLE(QT_MULTIMEDIA)
bool DefaultFullScreenVideoHandler::s_shouldForceFullScreenVideoPlayback = false; bool DefaultFullScreenVideoHandler::s_shouldForceFullScreenVideoPlayback = false;
DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler() DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler()
...@@ -42,6 +95,8 @@ DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler() ...@@ -42,6 +95,8 @@ DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler()
{ {
connect(m_fullScreenWidget, SIGNAL(didExitFullScreen()), this, SIGNAL(fullScreenClosed())); connect(m_fullScreenWidget, SIGNAL(didExitFullScreen()), this, SIGNAL(fullScreenClosed()));
m_fullScreenWidget->hide(); m_fullScreenWidget->hide();
m_fullScreenWidget->close();
} }
DefaultFullScreenVideoHandler::~DefaultFullScreenVideoHandler() DefaultFullScreenVideoHandler::~DefaultFullScreenVideoHandler()
...@@ -72,24 +127,36 @@ void DefaultFullScreenVideoHandler::exitFullScreen() ...@@ -72,24 +127,36 @@ void DefaultFullScreenVideoHandler::exitFullScreen()
{ {
m_fullScreenWidget->close(); m_fullScreenWidget->close();
} }
#endif
FullScreenVideoQt::FullScreenVideoQt(ChromeClientQt* chromeClient) FullScreenVideoQt::FullScreenVideoQt(ChromeClientQt* chromeClient)
: m_chromeClient(chromeClient) : m_chromeClient(chromeClient)
, m_videoElement(0) , m_videoElement(0)
{ {
Q_ASSERT(m_chromeClient); Q_ASSERT(m_chromeClient);
m_FullScreenVideoHandler = m_chromeClient->m_platformPlugin.createFullScreenVideoHandler();
#if ENABLE(QT_MULTIMEDIA)
m_FullScreenVideoHandler = m_chromeClient->m_platformPlugin.createFullScreenVideoHandler();
if (!m_FullScreenVideoHandler) if (!m_FullScreenVideoHandler)
m_FullScreenVideoHandler = new DefaultFullScreenVideoHandler; m_FullScreenVideoHandler = new DefaultFullScreenVideoHandler;
if (m_FullScreenVideoHandler) if (m_FullScreenVideoHandler)
connect(m_FullScreenVideoHandler, SIGNAL(fullScreenClosed()), this, SLOT(aboutToClose())); connect(m_FullScreenVideoHandler, SIGNAL(fullScreenClosed()), this, SLOT(aboutToClose()));
#endif
#if USE(GSTREAMER)
m_FullScreenVideoHandlerGStreamer = new GStreamerFullScreenVideoHandler;
#endif
} }
FullScreenVideoQt::~FullScreenVideoQt() FullScreenVideoQt::~FullScreenVideoQt()
{ {
#if ENABLE(QT_MULTIMEDIA)
delete m_FullScreenVideoHandler; delete m_FullScreenVideoHandler;
#endif
#if USE(GSTREAMER)
delete m_FullScreenVideoHandlerGStreamer;
#endif
} }
void FullScreenVideoQt::enterFullScreenForNode(Node* node) void FullScreenVideoQt::enterFullScreenForNode(Node* node)
...@@ -97,25 +164,54 @@ void FullScreenVideoQt::enterFullScreenForNode(Node* node) ...@@ -97,25 +164,54 @@ void FullScreenVideoQt::enterFullScreenForNode(Node* node)
Q_ASSERT(node); Q_ASSERT(node);
Q_ASSERT(m_FullScreenVideoHandler); Q_ASSERT(m_FullScreenVideoHandler);
m_videoElement = static_cast<HTMLVideoElement*>(node);
#if ENABLE(QT_MULTIMEDIA)
HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node);
PlatformMedia platformMedia = videoElement->platformMedia();
ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType);
if (platformMedia.type != PlatformMedia::QtMediaPlayerType)
return;
if (!m_FullScreenVideoHandler) if (!m_FullScreenVideoHandler)
return; return;
MediaPlayerPrivateQt* mediaPlayerQt = mediaPlayerForNode(node); MediaPlayerPrivateQt* mediaPlayerQt = mediaPlayer();
mediaPlayerQt->removeVideoItem(); mediaPlayerQt->removeVideoItem();
m_FullScreenVideoHandler->enterFullScreen(mediaPlayerQt->mediaPlayer()); m_FullScreenVideoHandler->enterFullScreen(mediaPlayerQt->mediaPlayer());
#endif
#if USE(GSTREAMER)
m_FullScreenVideoHandlerGStreamer->setVideoElement(m_videoElement);
m_FullScreenVideoHandlerGStreamer->enterFullScreen();
#endif
} }
void FullScreenVideoQt::exitFullScreenForNode(Node* node) void FullScreenVideoQt::exitFullScreenForNode(Node* node)
{ {
Q_ASSERT(node); Q_ASSERT(node);
#if ENABLE(QT_MULTIMEDIA)
HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node);
PlatformMedia platformMedia = videoElement->platformMedia();
ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType);
if (platformMedia.type != PlatformMedia::QtMediaPlayerType)
return;
Q_ASSERT(m_FullScreenVideoHandler); Q_ASSERT(m_FullScreenVideoHandler);
if (!m_FullScreenVideoHandler) if (!m_FullScreenVideoHandler)
return; return;
m_FullScreenVideoHandler->exitFullScreen(); m_FullScreenVideoHandler->exitFullScreen();
MediaPlayerPrivateQt* mediaPlayerQt = mediaPlayerForNode(node); MediaPlayerPrivateQt* mediaPlayerQt = mediaPlayer();
mediaPlayerQt->restoreVideoItem(); mediaPlayerQt->restoreVideoItem();
#endif
#if USE(GSTREAMER)
m_FullScreenVideoHandlerGStreamer->exitFullScreen();
#endif
} }
void FullScreenVideoQt::aboutToClose() void FullScreenVideoQt::aboutToClose()
...@@ -124,24 +220,33 @@ void FullScreenVideoQt::aboutToClose() ...@@ -124,24 +220,33 @@ void FullScreenVideoQt::aboutToClose()
m_videoElement->exitFullscreen(); m_videoElement->exitFullscreen();
} }
#if ENABLE(QT_MULTIMEDIA)
MediaPlayerPrivateQt* FullScreenVideoQt::mediaPlayer() MediaPlayerPrivateQt* FullScreenVideoQt::mediaPlayer()
{ {
Q_ASSERT(m_videoElement); Q_ASSERT(m_videoElement);
PlatformMedia platformMedia = m_videoElement->platformMedia(); PlatformMedia platformMedia = m_videoElement->platformMedia();
return static_cast<MediaPlayerPrivateQt*>(platformMedia.media.qtMediaPlayer); return static_cast<MediaPlayerPrivateQt*>(platformMedia.media.qtMediaPlayer);
} }
#endif
MediaPlayerPrivateQt* FullScreenVideoQt::mediaPlayerForNode(Node* node) bool FullScreenVideoQt::requiresFullScreenForVideoPlayback()
{ {
Q_ASSERT(node); #if ENABLE(QT_MULTIMEDIA)
if (node) return m_FullScreenVideoHandler ? m_FullScreenVideoHandler->requiresFullScreenForVideoPlayback() : false;
m_videoElement = static_cast<HTMLVideoElement*>(node); #endif
return mediaPlayer(); #if USE(GSTREAMER)
return false;
#endif
} }
bool FullScreenVideoQt::requiresFullScreenForVideoPlayback() bool FullScreenVideoQt::isValid() const
{ {
return m_FullScreenVideoHandler ? m_FullScreenVideoHandler->requiresFullScreenForVideoPlayback() : false; #if ENABLE(QT_MULTIMEDIA)
return m_FullScreenVideoHandler;
#endif
#if USE(GSTREAMER)
return m_FullScreenVideoHandlerGStreamer;
#endif
} }
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "qwebkitplatformplugin.h" #include "qwebkitplatformplugin.h"
#include <QObject> #include <QObject>
#include <wtf/Platform.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QGraphicsVideoItem; class QGraphicsVideoItem;
...@@ -34,8 +35,35 @@ class ChromeClientQt; ...@@ -34,8 +35,35 @@ class ChromeClientQt;
class FullScreenVideoWidget; class FullScreenVideoWidget;
class HTMLVideoElement; class HTMLVideoElement;
class Node; class Node;
#if ENABLE(QT_MULTIMEDIA)
class MediaPlayerPrivateQt; class MediaPlayerPrivateQt;
#endif
// We do not use ENABLE or USE because moc does not expand these macros.
#if defined(WTF_USE_GSTREAMER) && WTF_USE_GSTREAMER
class FullScreenVideoWindow;
class GStreamerFullScreenVideoHandler : public QObject {
Q_OBJECT
public:
GStreamerFullScreenVideoHandler();
~GStreamerFullScreenVideoHandler() { }
void setVideoElement(HTMLVideoElement*);
void enterFullScreen();
void exitFullScreen();
public Q_SLOTS:
void windowClosed();
private:
HTMLVideoElement* m_videoElement;
FullScreenVideoWindow* m_fullScreenWidget;
};
#endif
// We do not use ENABLE or USE because moc does not expand these macros.
#if defined(ENABLE_QT_MULTIMEDIA) && ENABLE_QT_MULTIMEDIA
class DefaultFullScreenVideoHandler : public QWebFullScreenVideoHandler { class DefaultFullScreenVideoHandler : public QWebFullScreenVideoHandler {
Q_OBJECT Q_OBJECT
public: public:
...@@ -51,6 +79,7 @@ private: ...@@ -51,6 +79,7 @@ private:
static bool s_shouldForceFullScreenVideoPlayback; static bool s_shouldForceFullScreenVideoPlayback;
FullScreenVideoWidget *m_fullScreenWidget; FullScreenVideoWidget *m_fullScreenWidget;
}; };
#endif
class FullScreenVideoQt : public QObject { class FullScreenVideoQt : public QObject {
Q_OBJECT Q_OBJECT
...@@ -61,11 +90,12 @@ public: ...@@ -61,11 +90,12 @@ public:
virtual void enterFullScreenForNode(Node*); virtual void enterFullScreenForNode(Node*);
virtual void exitFullScreenForNode(Node*); virtual void exitFullScreenForNode(Node*);
bool requiresFullScreenForVideoPlayback(); bool requiresFullScreenForVideoPlayback();
bool isValid() const { return m_FullScreenVideoHandler; } bool isValid() const;
private: private:
#if ENABLE(QT_MULTIMEDIA)
MediaPlayerPrivateQt* mediaPlayer(); MediaPlayerPrivateQt* mediaPlayer();
MediaPlayerPrivateQt* mediaPlayerForNode(Node* = 0); #endif
private slots: private slots:
void aboutToClose(); void aboutToClose();
...@@ -73,7 +103,12 @@ private slots: ...@@ -73,7 +103,12 @@ private slots:
private: private:
ChromeClientQt* m_chromeClient; ChromeClientQt* m_chromeClient;
HTMLVideoElement* m_videoElement; HTMLVideoElement* m_videoElement;
#if ENABLE(QT_MULTIMEDIA)
QWebFullScreenVideoHandler* m_FullScreenVideoHandler; QWebFullScreenVideoHandler* m_FullScreenVideoHandler;
#endif
#if USE(GSTREAMER)
GStreamerFullScreenVideoHandler* m_FullScreenVideoHandlerGStreamer;
#endif
}; };
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment