123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- /*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
- #include "config.h"
- #include "FullScreenVideoQt.h"
- #include "ChromeClientQt.h"
- #if USE(QT_MULTIMEDIA)
- #include "MediaPlayerPrivateQt.h"
- #endif
- #include "HTMLNames.h"
- #include "HTMLVideoElement.h"
- #include "Node.h"
- #if USE(GSTREAMER)
- #include "GStreamerGWorld.h"
- #include "PlatformVideoWindowPrivate.h"
- #endif
- #if USE(QT_MULTIMEDIA)
- #include <QMediaPlayer>
- #endif
- namespace WebCore {
- #if USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
- 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
- FullScreenVideoQt::FullScreenVideoQt(ChromeClientQt* chromeClient)
- : m_chromeClient(chromeClient)
- , m_videoElement(0)
- {
- Q_ASSERT(m_chromeClient);
- #if USE(QT_MULTIMEDIA)
- m_FullScreenVideoHandler = m_chromeClient->createFullScreenVideoHandler();
- if (m_FullScreenVideoHandler)
- connect(m_FullScreenVideoHandler, SIGNAL(fullScreenClosed()), this, SLOT(aboutToClose()));
- #endif
- #if USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
- m_FullScreenVideoHandlerGStreamer = new GStreamerFullScreenVideoHandler;
- #endif
- }
- FullScreenVideoQt::~FullScreenVideoQt()
- {
- #if USE(QT_MULTIMEDIA)
- delete m_FullScreenVideoHandler;
- #endif
- #if USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
- delete m_FullScreenVideoHandlerGStreamer;
- #endif
- }
- void FullScreenVideoQt::enterFullScreenForNode(Node* node)
- {
- Q_ASSERT(node);
- m_videoElement = static_cast<HTMLVideoElement*>(node);
- #if USE(QT_MULTIMEDIA)
- Q_ASSERT(m_FullScreenVideoHandler);
- HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node);
- PlatformMedia platformMedia = videoElement->platformMedia();
- ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType);
- if (platformMedia.type != PlatformMedia::QtMediaPlayerType)
- return;
- if (!m_FullScreenVideoHandler)
- return;
- MediaPlayerPrivateQt* mediaPlayerQt = mediaPlayer();
- mediaPlayerQt->removeVideoItem();
- m_FullScreenVideoHandler->enterFullScreen(mediaPlayerQt->mediaPlayer());
- #endif
- #if USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
- m_FullScreenVideoHandlerGStreamer->setVideoElement(m_videoElement);
- m_FullScreenVideoHandlerGStreamer->enterFullScreen();
- #endif
- }
- void FullScreenVideoQt::exitFullScreenForNode(Node* node)
- {
- Q_ASSERT(node);
- #if USE(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);
- if (!m_FullScreenVideoHandler)
- return;
- m_FullScreenVideoHandler->exitFullScreen();
- MediaPlayerPrivateQt* mediaPlayerQt = mediaPlayer();
- mediaPlayerQt->restoreVideoItem();
- #endif
- #if USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
- m_FullScreenVideoHandlerGStreamer->exitFullScreen();
- #endif
- }
- void FullScreenVideoQt::aboutToClose()
- {
- Q_ASSERT(m_videoElement);
- m_videoElement->exitFullscreen();
- }
- #if USE(QT_MULTIMEDIA)
- MediaPlayerPrivateQt* FullScreenVideoQt::mediaPlayer()
- {
- Q_ASSERT(m_videoElement);
- PlatformMedia platformMedia = m_videoElement->platformMedia();
- return static_cast<MediaPlayerPrivateQt*>(platformMedia.media.qtMediaPlayer);
- }
- #endif
- bool FullScreenVideoQt::requiresFullScreenForVideoPlayback()
- {
- #if USE(QT_MULTIMEDIA)
- return m_FullScreenVideoHandler ? m_FullScreenVideoHandler->requiresFullScreenForVideoPlayback() : false;
- #else
- return false;
- #endif
- }
- bool FullScreenVideoQt::isValid() const
- {
- #if USE(QT_MULTIMEDIA)
- return m_FullScreenVideoHandler;
- #endif
- #if USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
- return m_FullScreenVideoHandlerGStreamer;
- #else
- return 0;
- #endif
- }
- }
|