summaryrefslogtreecommitdiffstats
path: root/src/plugins/mediaservices/gstreamer
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/mediaservices/gstreamer')
-rw-r--r--src/plugins/mediaservices/gstreamer/gstreamer.pro59
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/mediaplayer.pri17
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp209
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.h83
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp501
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h138
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.cpp149
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.h101
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp924
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h176
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamerbushelper.cpp206
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamerbushelper.h87
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamermessage.cpp97
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamermessage.h76
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.cpp192
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.h76
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp165
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.h85
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.cpp77
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.h86
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp230
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.h114
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.cpp88
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.h78
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.cpp52
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.h69
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp340
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h110
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstvideobuffer.cpp101
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstvideobuffer.h80
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.cpp282
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.h131
-rw-r--r--src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp713
-rw-r--r--src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.h163
-rw-r--r--src/plugins/mediaservices/gstreamer/qx11videosurface.cpp523
-rw-r--r--src/plugins/mediaservices/gstreamer/qx11videosurface.h120
36 files changed, 0 insertions, 6698 deletions
diff --git a/src/plugins/mediaservices/gstreamer/gstreamer.pro b/src/plugins/mediaservices/gstreamer/gstreamer.pro
deleted file mode 100644
index 6e05120..0000000
--- a/src/plugins/mediaservices/gstreamer/gstreamer.pro
+++ /dev/null
@@ -1,59 +0,0 @@
-TARGET = qgstengine
-include(../../qpluginbase.pri)
-
-QT += mediaservices
-
-unix:contains(QT_CONFIG, alsa) {
- DEFINES += HAVE_ALSA
- LIBS += -lasound
-}
-
-QMAKE_CXXFLAGS += $$QT_CFLAGS_GSTREAMER
-LIBS += $$QT_LIBS_GSTREAMER -lgstinterfaces-0.10 -lgstvideo-0.10 -lgstbase-0.10 -lgstaudio-0.10
-
-# Input
-HEADERS += \
- qgstreamermessage.h \
- qgstreamerbushelper.h \
- qgstreamervideooutputcontrol.h \
- qgstreamervideorendererinterface.h \
- qgstreamerserviceplugin.h \
- qgstreamervideoinputdevicecontrol.h \
- qgstreamervideorenderer.h \
- qgstvideobuffer.h \
- qvideosurfacegstsink.h
-
-
-SOURCES += \
- qgstreamermessage.cpp \
- qgstreamerbushelper.cpp \
- qgstreamervideooutputcontrol.cpp \
- qgstreamervideorendererinterface.cpp \
- qgstreamerserviceplugin.cpp \
- qgstreamervideoinputdevicecontrol.cpp \
- qgstreamervideorenderer.cpp \
- qgstvideobuffer.cpp \
- qvideosurfacegstsink.cpp
-
-
-!win32:!embedded:!mac:!symbian {
- LIBS += -lXv
-
- HEADERS += \
- qgstreamervideooverlay.h \
- qgstreamervideowidget.h \
- qx11videosurface.h \
- qgstxvimagebuffer.h
-
- SOURCES += \
- qgstreamervideooverlay.cpp \
- qgstreamervideowidget.cpp \
- qx11videosurface.cpp \
- qgstxvimagebuffer.cpp
-}
-
-include(mediaplayer/mediaplayer.pri)
-
-QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mediaservices
-target.path = $$[QT_INSTALL_PLUGINS]/mediaservices
-INSTALLS += target
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/mediaplayer.pri b/src/plugins/mediaservices/gstreamer/mediaplayer/mediaplayer.pri
deleted file mode 100644
index 19ff034..0000000
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/mediaplayer.pri
+++ /dev/null
@@ -1,17 +0,0 @@
-INCLUDEPATH += $$PWD
-
-DEFINES += QMEDIA_GSTREAMER_PLAYER
-
-HEADERS += \
- $$PWD/qgstreamerplayercontrol.h \
- $$PWD/qgstreamerplayerservice.h \
- $$PWD/qgstreamerplayersession.h \
- $$PWD/qgstreamermetadataprovider.h
-
-SOURCES += \
- $$PWD/qgstreamerplayercontrol.cpp \
- $$PWD/qgstreamerplayerservice.cpp \
- $$PWD/qgstreamerplayersession.cpp \
- $$PWD/qgstreamermetadataprovider.cpp
-
-
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp
deleted file mode 100644
index f51d024..0000000
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgstreamermetadataprovider.h"
-#include "qgstreamerplayersession.h"
-#include <QtCore/qdebug.h>
-
-#include <gst/gstversion.h>
-
-QT_BEGIN_NAMESPACE
-
-struct QGstreamerMetaDataKeyLookup
-{
- QtMediaServices::MetaData key;
- const char *token;
-};
-
-static const QGstreamerMetaDataKeyLookup qt_gstreamerMetaDataKeys[] =
-{
- { QtMediaServices::Title, GST_TAG_TITLE },
- //{ QtMediaServices::SubTitle, 0 },
- //{ QtMediaServices::Author, 0 },
- { QtMediaServices::Comment, GST_TAG_COMMENT },
- { QtMediaServices::Description, GST_TAG_DESCRIPTION },
- //{ QtMediaServices::Category, 0 },
- { QtMediaServices::Genre, GST_TAG_GENRE },
- { QtMediaServices::Year, "year" },
- //{ QtMediaServices::UserRating, 0 },
-
- { QtMediaServices::Language, GST_TAG_LANGUAGE_CODE },
-
- { QtMediaServices::Publisher, GST_TAG_ORGANIZATION },
- { QtMediaServices::Copyright, GST_TAG_COPYRIGHT },
- //{ QtMediaServices::ParentalRating, 0 },
- //{ QtMediaServices::RatingOrganisation, 0 },
-
- // Media
- //{ QtMediaServices::Size, 0 },
- //{ QtMediaServices::MediaType, 0 },
- { QtMediaServices::Duration, GST_TAG_DURATION },
-
- // Audio
- { QtMediaServices::AudioBitRate, GST_TAG_BITRATE },
- { QtMediaServices::AudioCodec, GST_TAG_AUDIO_CODEC },
- //{ QtMediaServices::ChannelCount, 0 },
- //{ QtMediaServices::Frequency, 0 },
-
- // Music
- { QtMediaServices::AlbumTitle, GST_TAG_ALBUM },
- { QtMediaServices::AlbumArtist, GST_TAG_ARTIST},
- { QtMediaServices::ContributingArtist, GST_TAG_PERFORMER },
-#if (GST_VERSION_MAJOR >= 0) && (GST_VERSION_MINOR >= 10) && (GST_VERSION_MICRO >= 19)
- { QtMediaServices::Composer, GST_TAG_COMPOSER },
-#endif
- //{ QtMediaServices::Conductor, 0 },
- //{ QtMediaServices::Lyrics, 0 },
- //{ QtMediaServices::Mood, 0 },
- { QtMediaServices::TrackNumber, GST_TAG_TRACK_NUMBER },
-
- //{ QtMediaServices::CoverArtUrlSmall, 0 },
- //{ QtMediaServices::CoverArtUrlLarge, 0 },
-
- // Image/Video
- //{ QtMediaServices::Resolution, 0 },
- //{ QtMediaServices::PixelAspectRatio, 0 },
-
- // Video
- //{ QtMediaServices::VideoFrameRate, 0 },
- //{ QtMediaServices::VideoBitRate, 0 },
- { QtMediaServices::VideoCodec, GST_TAG_VIDEO_CODEC },
-
- //{ QtMediaServices::PosterUrl, 0 },
-
- // Movie
- //{ QtMediaServices::ChapterNumber, 0 },
- //{ QtMediaServices::Director, 0 },
- { QtMediaServices::LeadPerformer, GST_TAG_PERFORMER },
- //{ QtMediaServices::Writer, 0 },
-
- // Photos
- //{ QtMediaServices::CameraManufacturer, 0 },
- //{ QtMediaServices::CameraModel, 0 },
- //{ QtMediaServices::Event, 0 },
- //{ QtMediaServices::Subject, 0 }
-};
-
-QGstreamerMetaDataProvider::QGstreamerMetaDataProvider(QGstreamerPlayerSession *session, QObject *parent)
- :QMetaDataControl(parent), m_session(session)
-{
- connect(m_session, SIGNAL(tagsChanged()), SLOT(updateTags()));
-}
-
-QGstreamerMetaDataProvider::~QGstreamerMetaDataProvider()
-{
-}
-
-bool QGstreamerMetaDataProvider::isMetaDataAvailable() const
-{
- return !m_session->tags().isEmpty();
-}
-
-bool QGstreamerMetaDataProvider::isWritable() const
-{
- return false;
-}
-
-QVariant QGstreamerMetaDataProvider::metaData(QtMediaServices::MetaData key) const
-{
- static const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup);
-
- for (int i = 0; i < count; ++i) {
- if (qt_gstreamerMetaDataKeys[i].key == key) {
- return m_session->tags().value(QByteArray(qt_gstreamerMetaDataKeys[i].token));
- }
- }
- return QVariant();
-}
-
-void QGstreamerMetaDataProvider::setMetaData(QtMediaServices::MetaData key, QVariant const &value)
-{
- Q_UNUSED(key);
- Q_UNUSED(value);
-}
-
-QList<QtMediaServices::MetaData> QGstreamerMetaDataProvider::availableMetaData() const
-{
- static QMap<QByteArray, QtMediaServices::MetaData> keysMap;
- if (keysMap.isEmpty()) {
- const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup);
- for (int i = 0; i < count; ++i) {
- keysMap[QByteArray(qt_gstreamerMetaDataKeys[i].token)] = qt_gstreamerMetaDataKeys[i].key;
- }
- }
-
- QList<QtMediaServices::MetaData> res;
- foreach (const QByteArray &key, m_session->tags().keys()) {
- QtMediaServices::MetaData tag = keysMap.value(key, QtMediaServices::MetaData(-1));
- if (tag != -1)
- res.append(tag);
- }
-
- return res;
-}
-
-QVariant QGstreamerMetaDataProvider::extendedMetaData(const QString &key) const
-{
- return m_session->tags().value(key.toLatin1());
-}
-
-void QGstreamerMetaDataProvider::setExtendedMetaData(const QString &key, QVariant const &value)
-{
- Q_UNUSED(key);
- Q_UNUSED(value);
-}
-
-QStringList QGstreamerMetaDataProvider::availableExtendedMetaData() const
-{
- QStringList res;
- foreach (const QByteArray &key, m_session->tags().keys())
- res.append(QString(key));
-
- return res;
-}
-
-void QGstreamerMetaDataProvider::updateTags()
-{
- emit metaDataChanged();
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.h b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.h
deleted file mode 100644
index 4cf716a..0000000
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERMETADATAPROVIDER_H
-#define QGSTREAMERMETADATAPROVIDER_H
-
-#include <QtMediaServices/qmetadatacontrol.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGstreamerPlayerSession;
-
-class QGstreamerMetaDataProvider : public QMetaDataControl
-{
- Q_OBJECT
-public:
- QGstreamerMetaDataProvider( QGstreamerPlayerSession *session, QObject *parent );
- virtual ~QGstreamerMetaDataProvider();
-
- bool isMetaDataAvailable() const;
- bool isWritable() const;
-
- QVariant metaData(QtMediaServices::MetaData key) const;
- void setMetaData(QtMediaServices::MetaData key, const QVariant &value);
- QList<QtMediaServices::MetaData> availableMetaData() const;
-
- QVariant extendedMetaData(const QString &key) const ;
- void setExtendedMetaData(const QString &key, const QVariant &value);
- QStringList availableExtendedMetaData() const;
-
-private slots:
- void updateTags();
-
-private:
- QGstreamerPlayerSession *m_session;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGSTREAMERMETADATAPROVIDER_H
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp
deleted file mode 100644
index 6dd914a..0000000
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp
+++ /dev/null
@@ -1,501 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgstreamerplayercontrol.h"
-#include "qgstreamerplayersession.h"
-
-#include <qmediaplaylistnavigator.h>
-
-#include <QtCore/qdir.h>
-#include <QtCore/qsocketnotifier.h>
-#include <QtCore/qurl.h>
-#include <QtCore/qdebug.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-QT_BEGIN_NAMESPACE
-
-QGstreamerPlayerControl::QGstreamerPlayerControl(QGstreamerPlayerSession *session, QObject *parent)
- : QMediaPlayerControl(parent)
- , m_session(session)
- , m_state(QMediaPlayer::StoppedState)
- , m_mediaStatus(QMediaPlayer::NoMedia)
- , m_bufferProgress(-1)
- , m_seekToStartPending(false)
- , m_stream(0)
- , m_fifoNotifier(0)
- , m_fifoCanWrite(false)
- , m_bufferSize(0)
- , m_bufferOffset(0)
-{
- m_fifoFd[0] = -1;
- m_fifoFd[1] = -1;
-
- connect(m_session, SIGNAL(positionChanged(qint64)),
- this, SIGNAL(positionChanged(qint64)));
- connect(m_session, SIGNAL(durationChanged(qint64)),
- this, SIGNAL(durationChanged(qint64)));
- connect(m_session, SIGNAL(mutedStateChanged(bool)),
- this, SIGNAL(mutedChanged(bool)));
- connect(m_session, SIGNAL(volumeChanged(int)),
- this, SIGNAL(volumeChanged(int)));
- connect(m_session, SIGNAL(stateChanged(QMediaPlayer::State)),
- this, SLOT(updateState(QMediaPlayer::State)));
- connect(m_session,SIGNAL(bufferingProgressChanged(int)),
- this, SLOT(setBufferProgress(int)));
- connect(m_session, SIGNAL(playbackFinished()),
- this, SLOT(processEOS()));
- connect(m_session, SIGNAL(audioAvailableChanged(bool)),
- this, SIGNAL(audioAvailableChanged(bool)));
- connect(m_session, SIGNAL(videoAvailableChanged(bool)),
- this, SIGNAL(videoAvailableChanged(bool)));
- connect(m_session, SIGNAL(seekableChanged(bool)),
- this, SIGNAL(seekableChanged(bool)));
- connect(m_session, SIGNAL(error(int,QString)),
- this, SIGNAL(error(int,QString)));
-}
-
-QGstreamerPlayerControl::~QGstreamerPlayerControl()
-{
- if (m_fifoFd[0] >= 0) {
- ::close(m_fifoFd[0]);
- ::close(m_fifoFd[1]);
- m_fifoFd[0] = -1;
- m_fifoFd[1] = -1;
- }
-}
-
-qint64 QGstreamerPlayerControl::position() const
-{
- return m_seekToStartPending ? 0 : m_session->position();
-}
-
-qint64 QGstreamerPlayerControl::duration() const
-{
- return m_session->duration();
-}
-
-QMediaPlayer::State QGstreamerPlayerControl::state() const
-{
- return m_state;
-}
-
-QMediaPlayer::MediaStatus QGstreamerPlayerControl::mediaStatus() const
-{
- return m_mediaStatus;
-}
-
-int QGstreamerPlayerControl::bufferStatus() const
-{
- if (m_bufferProgress == -1) {
- return m_session->state() == QMediaPlayer::StoppedState ? 0 : 100;
- } else
- return m_bufferProgress;
-}
-
-int QGstreamerPlayerControl::volume() const
-{
- return m_session->volume();
-}
-
-bool QGstreamerPlayerControl::isMuted() const
-{
- return m_session->isMuted();
-}
-
-bool QGstreamerPlayerControl::isSeekable() const
-{
- return m_session->isSeekable();
-}
-
-QMediaTimeRange QGstreamerPlayerControl::availablePlaybackRanges() const
-{
- QMediaTimeRange ranges;
-
- if (m_session->isSeekable())
- ranges.addInterval(0, m_session->duration());
-
- return ranges;
-}
-
-qreal QGstreamerPlayerControl::playbackRate() const
-{
- return m_session->playbackRate();
-}
-
-void QGstreamerPlayerControl::setPlaybackRate(qreal rate)
-{
- m_session->setPlaybackRate(rate);
-}
-
-void QGstreamerPlayerControl::setPosition(qint64 pos)
-{
- if (m_mediaStatus == QMediaPlayer::EndOfMedia) {
- m_mediaStatus = QMediaPlayer::LoadedMedia;
- emit mediaStatusChanged(m_mediaStatus);
- }
-
- if (m_session->seek(pos))
- m_seekToStartPending = false;
-}
-
-void QGstreamerPlayerControl::play()
-{
- playOrPause(QMediaPlayer::PlayingState);
-}
-
-void QGstreamerPlayerControl::pause()
-{
- playOrPause(QMediaPlayer::PausedState);
-}
-
-void QGstreamerPlayerControl::playOrPause(QMediaPlayer::State newState)
-{
- QMediaPlayer::State oldState = m_state;
- QMediaPlayer::MediaStatus oldMediaStatus = m_mediaStatus;
-
- if (m_mediaStatus == QMediaPlayer::EndOfMedia)
- m_mediaStatus = QMediaPlayer::BufferedMedia;
-
- if (m_seekToStartPending) {
- m_session->pause();
- if (!m_session->seek(0)) {
- m_bufferProgress = -1;
- m_session->stop();
- m_mediaStatus = QMediaPlayer::LoadingMedia;
- }
- m_seekToStartPending = false;
- }
-
- bool ok = false;
- if (newState == QMediaPlayer::PlayingState)
- ok = m_session->play();
- else
- ok = m_session->pause();
-
- if (!ok)
- return;
-
- m_state = newState;
-
- if (m_mediaStatus == QMediaPlayer::EndOfMedia || m_mediaStatus == QMediaPlayer::LoadedMedia) {
- if (m_bufferProgress == -1 || m_bufferProgress == 100)
- m_mediaStatus = QMediaPlayer::BufferedMedia;
- else
- m_mediaStatus = QMediaPlayer::BufferingMedia;
- }
-
- if (m_state != oldState)
- emit stateChanged(m_state);
- if (m_mediaStatus != oldMediaStatus)
- emit mediaStatusChanged(m_mediaStatus);
-
-}
-
-void QGstreamerPlayerControl::stop()
-{
- if (m_state != QMediaPlayer::StoppedState) {
- m_state = QMediaPlayer::StoppedState;
- m_session->pause();
- m_seekToStartPending = true;
- updateState(m_session->state());
- emit positionChanged(0);
- emit stateChanged(m_state);
- }
-}
-
-void QGstreamerPlayerControl::setVolume(int volume)
-{
- m_session->setVolume(volume);
-}
-
-void QGstreamerPlayerControl::setMuted(bool muted)
-{
- m_session->setMuted(muted);
-}
-
-QMediaContent QGstreamerPlayerControl::media() const
-{
- return m_currentResource;
-}
-
-const QIODevice *QGstreamerPlayerControl::mediaStream() const
-{
- return m_stream;
-}
-
-void QGstreamerPlayerControl::setMedia(const QMediaContent &content, QIODevice *stream)
-{
- QMediaPlayer::State oldState = m_state;
- m_state = QMediaPlayer::StoppedState;
- m_session->stop();
-
- if (m_bufferProgress != -1) {
- m_bufferProgress = -1;
- emit bufferStatusChanged(0);
- }
-
- if (m_stream) {
- closeFifo();
-
- disconnect(m_stream, SIGNAL(readyRead()), this, SLOT(writeFifo()));
- m_stream = 0;
- }
-
- m_currentResource = content;
- m_stream = stream;
- m_seekToStartPending = false;
-
- QUrl url;
-
- if (m_stream) {
- if (m_stream->isReadable() && openFifo()) {
- url = QUrl(QString(QLatin1String("fd://%1")).arg(m_fifoFd[0]));
- }
- } else if (!content.isNull()) {
- url = content.canonicalUrl();
- }
-
- m_session->load(url);
-
- if (m_fifoFd[1] >= 0) {
- m_fifoCanWrite = true;
-
- writeFifo();
- }
-
- if (!url.isEmpty()) {
- if (m_mediaStatus != QMediaPlayer::LoadingMedia)
- emit mediaStatusChanged(m_mediaStatus = QMediaPlayer::LoadingMedia);
- m_session->pause();
- } else {
- if (m_mediaStatus != QMediaPlayer::NoMedia)
- emit mediaStatusChanged(m_mediaStatus = QMediaPlayer::NoMedia);
- setBufferProgress(0);
- }
-
- emit mediaChanged(m_currentResource);
- if (m_state != oldState)
- emit stateChanged(m_state);
-}
-
-void QGstreamerPlayerControl::setVideoOutput(QObject *output)
-{
- m_session->setVideoRenderer(output);
-}
-
-bool QGstreamerPlayerControl::isAudioAvailable() const
-{
- return m_session->isAudioAvailable();
-}
-
-bool QGstreamerPlayerControl::isVideoAvailable() const
-{
- return m_session->isVideoAvailable();
-}
-
-void QGstreamerPlayerControl::updateState(QMediaPlayer::State state)
-{
- QMediaPlayer::MediaStatus oldStatus = m_mediaStatus;
- QMediaPlayer::State oldState = m_state;
-
- switch (state) {
- case QMediaPlayer::StoppedState:
- m_state = QMediaPlayer::StoppedState;
- if (m_currentResource.isNull())
- m_mediaStatus = QMediaPlayer::NoMedia;
- else
- m_mediaStatus = QMediaPlayer::LoadingMedia;
- break;
-
- case QMediaPlayer::PlayingState:
- case QMediaPlayer::PausedState:
- if (m_state == QMediaPlayer::StoppedState) {
- m_mediaStatus = QMediaPlayer::LoadedMedia;
- } else {
- if (m_bufferProgress == -1 || m_bufferProgress == 100)
- m_mediaStatus = QMediaPlayer::BufferedMedia;
- }
- break;
- }
-
- //EndOfMedia status should be kept, until reset by pause, play or setMedia
- if (oldStatus == QMediaPlayer::EndOfMedia)
- m_mediaStatus = QMediaPlayer::EndOfMedia;
-
- if (m_state != oldState)
- emit stateChanged(m_state);
- if (m_mediaStatus != oldStatus)
- emit mediaStatusChanged(m_mediaStatus);
-}
-
-void QGstreamerPlayerControl::processEOS()
-{
- m_mediaStatus = QMediaPlayer::EndOfMedia;
- stop();
- emit mediaStatusChanged(m_mediaStatus);
-}
-
-void QGstreamerPlayerControl::setBufferProgress(int progress)
-{
- if (m_bufferProgress == progress || m_mediaStatus == QMediaPlayer::NoMedia)
- return;
-
- QMediaPlayer::MediaStatus oldStatus = m_mediaStatus;
-
- m_bufferProgress = progress;
-
- if (m_state == QMediaPlayer::StoppedState) {
- m_mediaStatus = QMediaPlayer::LoadedMedia;
- } else {
- if (m_bufferProgress < 100) {
- m_mediaStatus = QMediaPlayer::StalledMedia;
- m_session->pause();
- } else {
- m_mediaStatus = QMediaPlayer::BufferedMedia;
- if (m_state == QMediaPlayer::PlayingState)
- m_session->play();
- }
- }
-
- if (m_mediaStatus != oldStatus)
- emit mediaStatusChanged(m_mediaStatus);
-
- emit bufferStatusChanged(m_bufferProgress);
-}
-
-void QGstreamerPlayerControl::writeFifo()
-{
- if (m_fifoCanWrite) {
- qint64 bytesToRead = qMin<qint64>(
- m_stream->bytesAvailable(), PIPE_BUF - m_bufferSize);
-
- if (bytesToRead > 0) {
- int bytesRead = m_stream->read(&m_buffer[m_bufferOffset + m_bufferSize], bytesToRead);
-
- if (bytesRead > 0)
- m_bufferSize += bytesRead;
- }
-
- if (m_bufferSize > 0) {
- int bytesWritten = ::write(m_fifoFd[1], &m_buffer[m_bufferOffset], size_t(m_bufferSize));
-
- if (bytesWritten > 0) {
- m_bufferOffset += bytesWritten;
- m_bufferSize -= bytesWritten;
-
- if (m_bufferSize == 0)
- m_bufferOffset = 0;
- } else if (errno == EAGAIN) {
- m_fifoCanWrite = false;
- } else {
- closeFifo();
- }
- }
- }
-
- m_fifoNotifier->setEnabled(m_stream->bytesAvailable() > 0);
-}
-
-void QGstreamerPlayerControl::fifoReadyWrite(int socket)
-{
- if (socket == m_fifoFd[1]) {
- m_fifoCanWrite = true;
-
- writeFifo();
- }
-}
-
-bool QGstreamerPlayerControl::openFifo()
-{
- Q_ASSERT(m_fifoFd[0] < 0);
- Q_ASSERT(m_fifoFd[1] < 0);
-
- if (::pipe(m_fifoFd) == 0) {
- int flags = ::fcntl(m_fifoFd[1], F_GETFD);
-
- if (::fcntl(m_fifoFd[1], F_SETFD, flags | O_NONBLOCK) >= 0) {
- m_fifoNotifier = new QSocketNotifier(m_fifoFd[1], QSocketNotifier::Write);
-
- connect(m_fifoNotifier, SIGNAL(activated(int)), this, SLOT(fifoReadyWrite(int)));
-
- return true;
- } else {
- qWarning("Failed to make pipe non blocking %d", errno);
-
- ::close(m_fifoFd[0]);
- ::close(m_fifoFd[1]);
-
- m_fifoFd[0] = -1;
- m_fifoFd[1] = -1;
-
- return false;
- }
- } else {
- qWarning("Failed to create pipe %d", errno);
-
- return false;
- }
-}
-
-void QGstreamerPlayerControl::closeFifo()
-{
- if (m_fifoFd[0] >= 0) {
- delete m_fifoNotifier;
- m_fifoNotifier = 0;
-
- ::close(m_fifoFd[0]);
- ::close(m_fifoFd[1]);
- m_fifoFd[0] = -1;
- m_fifoFd[1] = -1;
-
- m_fifoCanWrite = false;
-
- m_bufferSize = 0;
- m_bufferOffset = 0;
- }
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h
deleted file mode 100644
index c95f37a..0000000
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERPLAYERCONTROL_H
-#define QGSTREAMERPLAYERCONTROL_H
-
-#include <QtCore/qobject.h>
-
-#include <QtMediaServices/qmediaplayercontrol.h>
-#include <QtMediaServices/qmediaplayer.h>
-
-#include <limits.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QMediaPlaylist;
-class QGstreamerPlayerSession;
-class QGstreamerPlayerService;
-class QMediaPlaylistNavigator;
-class QSocketNotifier;
-
-class QGstreamerPlayerControl : public QMediaPlayerControl
-{
- Q_OBJECT
-
-public:
- QGstreamerPlayerControl(QGstreamerPlayerSession *session, QObject *parent = 0);
- ~QGstreamerPlayerControl();
-
- QMediaPlayer::State state() const;
- QMediaPlayer::MediaStatus mediaStatus() const;
-
- qint64 position() const;
- qint64 duration() const;
-
- int bufferStatus() const;
-
- int volume() const;
- bool isMuted() const;
-
- bool isAudioAvailable() const;
- bool isVideoAvailable() const;
- void setVideoOutput(QObject *output);
-
- bool isSeekable() const;
- QMediaTimeRange availablePlaybackRanges() const;
-
- qreal playbackRate() const;
- void setPlaybackRate(qreal rate);
-
- QMediaContent media() const;
- const QIODevice *mediaStream() const;
- void setMedia(const QMediaContent&, QIODevice *);
-
-public Q_SLOTS:
- void setPosition(qint64 pos);
-
- void play();
- void pause();
- void stop();
-
- void setVolume(int volume);
- void setMuted(bool muted);
-
-private Q_SLOTS:
- void writeFifo();
- void fifoReadyWrite(int socket);
-
- void updateState(QMediaPlayer::State);
- void processEOS();
- void setBufferProgress(int progress);
-
-private:
- bool openFifo();
- void closeFifo();
- void playOrPause(QMediaPlayer::State state);
-
- QGstreamerPlayerSession *m_session;
- QMediaPlayer::State m_state;
- QMediaPlayer::MediaStatus m_mediaStatus;
- int m_bufferProgress;
- bool m_seekToStartPending;
- QMediaContent m_currentResource;
- QIODevice *m_stream;
- QSocketNotifier *m_fifoNotifier;
- int m_fifoFd[2];
- bool m_fifoCanWrite;
- int m_bufferSize;
- int m_bufferOffset;
- char m_buffer[PIPE_BUF];
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.cpp
deleted file mode 100644
index 3228722..0000000
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/qvariant.h>
-#include <QtCore/qdebug.h>
-#include <QtGui/qwidget.h>
-
-#include "qgstreamerplayerservice.h"
-#include "qgstreamerplayercontrol.h"
-#include "qgstreamerplayersession.h"
-#include "qgstreamermetadataprovider.h"
-#include "qgstreamervideooutputcontrol.h"
-
-#include "qgstreamervideooverlay.h"
-#include "qgstreamervideorenderer.h"
-
-#include "qgstreamervideowidget.h"
-//#include "qgstreamerstreamscontrol.h"
-
-#include <qmediaplaylistnavigator.h>
-#include <qmediaplaylist.h>
-
-
-QT_BEGIN_NAMESPACE
-
-
-QGstreamerPlayerService::QGstreamerPlayerService(QObject *parent):
- QMediaService(parent),
- m_videoRenderer(0),
- m_videoWindow(0),
- m_videoWidget(0)
-{
- m_session = new QGstreamerPlayerSession(this);
- m_control = new QGstreamerPlayerControl(m_session, this);
- m_metaData = new QGstreamerMetaDataProvider(m_session, this);
- m_videoOutput = new QGstreamerVideoOutputControl(this);
-// m_streamsControl = new QGstreamerStreamsControl(m_session,this);
-
- connect(m_videoOutput, SIGNAL(outputChanged(QVideoOutputControl::Output)),
- this, SLOT(videoOutputChanged(QVideoOutputControl::Output)));
- m_videoRenderer = new QGstreamerVideoRenderer(this);
-
-#ifdef Q_WS_X11
- m_videoWindow = new QGstreamerVideoOverlay(this);
- m_videoWidget = new QGstreamerVideoWidgetControl(this);
-#endif
-
- QList<QVideoOutputControl::Output> outputs;
-
- if (m_videoRenderer)
- outputs << QVideoOutputControl::RendererOutput;
- if (m_videoWidget)
- outputs << QVideoOutputControl::WidgetOutput;
- if (m_videoWindow)
- outputs << QVideoOutputControl::WindowOutput;
-
- m_videoOutput->setAvailableOutputs(outputs);
-}
-
-QGstreamerPlayerService::~QGstreamerPlayerService()
-{
-}
-
-QMediaControl *QGstreamerPlayerService::control(const char *name) const
-{
- if (qstrcmp(name,QMediaPlayerControl_iid) == 0)
- return m_control;
-
- if (qstrcmp(name,QMetaDataControl_iid) == 0)
- return m_metaData;
-
-// if (qstrcmp(name,QMediaStreamsControl_iid) == 0)
-// return m_streamsControl;
-
- if (qstrcmp(name, QVideoOutputControl_iid) == 0)
- return m_videoOutput;
-
- if (qstrcmp(name, QVideoWidgetControl_iid) == 0)
- return m_videoWidget;
-
- if (qstrcmp(name, QVideoRendererControl_iid) == 0)
- return m_videoRenderer;
-
- if (qstrcmp(name, QVideoWindowControl_iid) == 0)
- return m_videoWindow;
-
- return 0;
-}
-
-void QGstreamerPlayerService::videoOutputChanged(QVideoOutputControl::Output output)
-{
- switch (output) {
- case QVideoOutputControl::NoOutput:
- m_control->setVideoOutput(0);
- break;
- case QVideoOutputControl::RendererOutput:
- m_control->setVideoOutput(m_videoRenderer);
- break;
- case QVideoOutputControl::WindowOutput:
- m_control->setVideoOutput(m_videoWindow);
- break;
- case QVideoOutputControl::WidgetOutput:
- m_control->setVideoOutput(m_videoWidget);
- break;
- default:
- qWarning("Invalid video output selection");
- break;
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.h b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.h
deleted file mode 100644
index 1283966..0000000
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERPLAYERSERVICE_H
-#define QGSTREAMERPLAYERSERVICE_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qiodevice.h>
-
-#include <QtMediaServices/qmediaservice.h>
-
-#include "qgstreamervideooutputcontrol.h"
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QMediaMetaData;
-class QMediaPlayerControl;
-class QMediaPlaylist;
-class QMediaPlaylistNavigator;
-class QGstreamerMetaData;
-class QGstreamerPlayerControl;
-class QGstreamerPlayerSession;
-class QGstreamerMetaDataProvider;
-class QGstreamerStreamsControl;
-class QGstreamerVideoRenderer;
-class QGstreamerVideoOverlay;
-class QGstreamerVideoWidgetControl;
-
-
-class QGstreamerPlayerService : public QMediaService
-{
- Q_OBJECT
-public:
- QGstreamerPlayerService(QObject *parent = 0);
- ~QGstreamerPlayerService();
-
- //void setVideoOutput(QObject *output);
-
- QMediaControl *control(const char *name) const;
-
-private slots:
- void videoOutputChanged(QVideoOutputControl::Output output);
-
-private:
- QGstreamerPlayerControl *m_control;
- QGstreamerPlayerSession *m_session;
- QGstreamerMetaDataProvider *m_metaData;
- QGstreamerVideoOutputControl *m_videoOutput;
- QGstreamerStreamsControl *m_streamsControl;
-
- QGstreamerVideoRenderer *m_videoRenderer;
- QGstreamerVideoOverlay *m_videoWindow;
- QGstreamerVideoWidgetControl *m_videoWidget;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp
deleted file mode 100644
index 6a44aa1..0000000
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp
+++ /dev/null
@@ -1,924 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgstreamerplayersession.h"
-#include "qgstreamerbushelper.h"
-
-#include "qgstreamervideorendererinterface.h"
-
-#include <gst/gstvalue.h>
-
-#include <QtCore/qdatetime.h>
-#include <QtCore/qdebug.h>
-
-//#define USE_PLAYBIN2
-
-//#define DEBUG_VO_BIN_DUMP
-//#define DEBUG_PLAYBIN_STATES
-
-
-QT_BEGIN_NAMESPACE
-
-QGstreamerPlayerSession::QGstreamerPlayerSession(QObject *parent)
- :QObject(parent),
- m_state(QMediaPlayer::StoppedState),
- m_busHelper(0),
- m_playbin(0),
- m_videoSink(0),
- m_pendingVideoSink(0),
- m_nullVideoSink(0),
- m_bus(0),
- m_renderer(0),
- m_volume(100),
- m_playbackRate(1.0),
- m_muted(false),
- m_audioAvailable(false),
- m_videoAvailable(false),
- m_seekable(false),
- m_lastPosition(0),
- m_duration(-1)
-{
- static bool initialized = false;
- if (!initialized) {
- initialized = true;
- gst_init(NULL, NULL);
- }
-
-#ifdef USE_PLAYBIN2
- m_playbin = gst_element_factory_make("playbin2", NULL);
-#else
- m_playbin = gst_element_factory_make("playbin", NULL);
-#endif
-
- m_videoOutputBin = gst_bin_new("video-output-bin");
- gst_object_ref(GST_OBJECT(m_videoOutputBin));
-
- m_videoIdentity = gst_element_factory_make("identity", "identity-vo");
- m_colorSpace = gst_element_factory_make("ffmpegcolorspace", "ffmpegcolorspace-vo");
- m_videoScale = gst_element_factory_make("videoscale","videoscale-vo");
- m_nullVideoSink = gst_element_factory_make("fakesink", NULL);
- gst_object_ref(GST_OBJECT(m_nullVideoSink));
- gst_bin_add_many(GST_BIN(m_videoOutputBin), m_videoIdentity, m_colorSpace, m_videoScale, m_nullVideoSink, NULL);
- gst_element_link_many(m_videoIdentity, m_colorSpace, m_videoScale, m_nullVideoSink, NULL);
-
- m_videoSink = m_nullVideoSink;
-
- // add ghostpads
- GstPad *pad = gst_element_get_static_pad(m_videoIdentity,"sink");
- gst_element_add_pad(GST_ELEMENT(m_videoOutputBin), gst_ghost_pad_new("videosink", pad));
- gst_object_unref(GST_OBJECT(pad));
-
-
- if (m_playbin != 0) {
- // Sort out messages
- m_bus = gst_element_get_bus(m_playbin);
- m_busHelper = new QGstreamerBusHelper(m_bus, this);
- connect(m_busHelper, SIGNAL(message(QGstreamerMessage)), SLOT(busMessage(QGstreamerMessage)));
- m_busHelper->installSyncEventFilter(this);
-
- g_object_set(G_OBJECT(m_playbin), "video-sink", m_videoOutputBin, NULL);
-
- // Initial volume
- double volume = 1.0;
- g_object_get(G_OBJECT(m_playbin), "volume", &volume, NULL);
- m_volume = int(volume*100);
- }
-}
-
-QGstreamerPlayerSession::~QGstreamerPlayerSession()
-{
- if (m_playbin) {
- stop();
-
- delete m_busHelper;
- gst_object_unref(GST_OBJECT(m_bus));
- gst_object_unref(GST_OBJECT(m_playbin));
- gst_object_unref(GST_OBJECT(m_nullVideoSink));
- gst_object_unref(GST_OBJECT(m_videoOutputBin));
- }
-}
-
-void QGstreamerPlayerSession::load(const QUrl &url)
-{
- m_url = url;
-
- if (m_playbin) {
- m_tags.clear();
- emit tagsChanged();
-
- g_object_set(G_OBJECT(m_playbin), "uri", m_url.toEncoded().constData(), NULL);
-
-// if (!m_streamTypes.isEmpty()) {
-// m_streamProperties.clear();
-// m_streamTypes.clear();
-//
-// emit streamsChanged();
-// }
- }
-}
-
-qint64 QGstreamerPlayerSession::duration() const
-{
- return m_duration;
-}
-
-qint64 QGstreamerPlayerSession::position() const
-{
- GstFormat format = GST_FORMAT_TIME;
- gint64 position = 0;
-
- if ( m_playbin && gst_element_query_position(m_playbin, &format, &position))
- return position / 1000000;
- else
- return 0;
-}
-
-qreal QGstreamerPlayerSession::playbackRate() const
-{
- return m_playbackRate;
-}
-
-void QGstreamerPlayerSession::setPlaybackRate(qreal rate)
-{
- if (!qFuzzyCompare(m_playbackRate, rate)) {
- m_playbackRate = rate;
- if (m_playbin) {
- gst_element_seek(m_playbin, rate, GST_FORMAT_TIME,
- GstSeekFlags(GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH),
- GST_SEEK_TYPE_NONE,0,
- GST_SEEK_TYPE_NONE,0 );
- }
- }
-}
-
-
-//int QGstreamerPlayerSession::activeStream(QMediaStreamsControl::StreamType streamType) const
-//{
-// int streamNumber = -1;
-// if (m_playbin) {
-// switch (streamType) {
-// case QMediaStreamsControl::AudioStream:
-// g_object_set(G_OBJECT(m_playbin), "current-audio", streamNumber, NULL);
-// break;
-// case QMediaStreamsControl::VideoStream:
-// g_object_set(G_OBJECT(m_playbin), "current-video", streamNumber, NULL);
-// break;
-// case QMediaStreamsControl::SubPictureStream:
-// g_object_set(G_OBJECT(m_playbin), "current-text", streamNumber, NULL);
-// break;
-// default:
-// break;
-// }
-// }
-//
-//#ifdef USE_PLAYBIN2
-// streamNumber += m_playbin2StreamOffset.value(streamType,0);
-//#endif
-//
-// return streamNumber;
-//}
-
-//void QGstreamerPlayerSession::setActiveStream(QMediaStreamsControl::StreamType streamType, int streamNumber)
-//{
-//#ifdef USE_PLAYBIN2
-// streamNumber -= m_playbin2StreamOffset.value(streamType,0);
-//#endif
-//
-// if (m_playbin) {
-// switch (streamType) {
-// case QMediaStreamsControl::AudioStream:
-// g_object_get(G_OBJECT(m_playbin), "current-audio", &streamNumber, NULL);
-// break;
-// case QMediaStreamsControl::VideoStream:
-// g_object_get(G_OBJECT(m_playbin), "current-video", &streamNumber, NULL);
-// break;
-// case QMediaStreamsControl::SubPictureStream:
-// g_object_get(G_OBJECT(m_playbin), "current-text", &streamNumber, NULL);
-// break;
-// default:
-// break;
-// }
-// }
-//}
-
-
-bool QGstreamerPlayerSession::isBuffering() const
-{
- return false;
-}
-
-int QGstreamerPlayerSession::bufferingProgress() const
-{
- return 0;
-}
-
-int QGstreamerPlayerSession::volume() const
-{
- return m_volume;
-}
-
-bool QGstreamerPlayerSession::isMuted() const
-{
- return m_muted;
-}
-
-bool QGstreamerPlayerSession::isAudioAvailable() const
-{
- return m_audioAvailable;
-}
-
-static void block_pad_cb(GstPad *pad, gboolean blocked, gpointer user_data)
-{
- Q_UNUSED(pad);
- //qDebug() << "block_pad_cb" << blocked;
-
- if (blocked && user_data) {
- QGstreamerPlayerSession *session = reinterpret_cast<QGstreamerPlayerSession*>(user_data);
- QMetaObject::invokeMethod(session, "finishVideoOutputChange", Qt::QueuedConnection);
- }
-}
-
-#ifdef DEBUG_VO_BIN_DUMP
- static int dumpNum = 0;
-#endif
-
-void QGstreamerPlayerSession::setVideoRenderer(QObject *videoOutput)
-{
- QGstreamerVideoRendererInterface* renderer = qobject_cast<QGstreamerVideoRendererInterface*>(videoOutput);
-
- if (m_renderer == renderer)
- return;
-
-#ifdef DEBUG_VO_BIN_DUMP
- dumpNum++;
-
- _gst_debug_bin_to_dot_file(GST_BIN(m_videoOutputBin),
- GstDebugGraphDetails(GST_DEBUG_GRAPH_SHOW_ALL /* GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE | GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS | GST_DEBUG_GRAPH_SHOW_STATES*/),
- QString("video_output_change_%1_set").arg(dumpNum).toAscii().constData());
-#endif
-
- m_renderer = renderer;
-
- GstElement *videoSink = m_renderer ? m_renderer->videoSink() : m_nullVideoSink;
-
- if (m_state == QMediaPlayer::StoppedState) {
- m_pendingVideoSink = 0;
- gst_element_unlink(m_videoScale, m_videoSink);
-
- gst_bin_remove(GST_BIN(m_videoOutputBin), m_videoSink);
-
- m_videoSink = videoSink;
-
- gst_bin_add(GST_BIN(m_videoOutputBin), m_videoSink);
- gst_element_link(m_videoScale, m_videoSink);
-
- } else {
- if (m_pendingVideoSink) {
- m_pendingVideoSink = videoSink;
- return;
- }
-
- m_pendingVideoSink = videoSink;
-
- //block pads, async to avoid locking in paused state
- GstPad *srcPad = gst_element_get_static_pad(m_videoIdentity, "src");
- gst_pad_set_blocked_async(srcPad, true, &block_pad_cb, this);
- gst_object_unref(GST_OBJECT(srcPad));
- }
-}
-
-void QGstreamerPlayerSession::finishVideoOutputChange()
-{
- if (!m_pendingVideoSink)
- return;
-
- GstPad *srcPad = gst_element_get_static_pad(m_videoIdentity, "src");
-
- if (!gst_pad_is_blocked(srcPad)) {
- //pad is not blocked, it's possible to swap outputs only in the null state
- GstState identityElementState = GST_STATE_NULL;
- gst_element_get_state(m_videoIdentity, &identityElementState, NULL, GST_CLOCK_TIME_NONE);
- if (identityElementState != GST_STATE_NULL) {
- gst_object_unref(GST_OBJECT(srcPad));
- return; //can't change vo yet, received async call from the previous change
- }
-
- }
-
- if (m_pendingVideoSink == m_videoSink) {
- //video output was change back to the current one,
- //no need to torment the pipeline, just unblock the pad
- if (gst_pad_is_blocked(srcPad))
- gst_pad_set_blocked_async(srcPad, false, &block_pad_cb, 0);
-
- m_pendingVideoSink = 0;
- gst_object_unref(GST_OBJECT(srcPad));
- return;
- }
-
- gst_element_set_state(m_colorSpace, GST_STATE_NULL);
- gst_element_set_state(m_videoScale, GST_STATE_NULL);
- gst_element_set_state(m_videoSink, GST_STATE_NULL);
-
- gst_element_unlink(m_videoScale, m_videoSink);
-
- gst_bin_remove(GST_BIN(m_videoOutputBin), m_videoSink);
-
- m_videoSink = m_pendingVideoSink;
- m_pendingVideoSink = 0;
-
- gst_bin_add(GST_BIN(m_videoOutputBin), m_videoSink);
- if (!gst_element_link(m_videoScale, m_videoSink))
- qWarning() << "Linking video output element failed";
-
- GstState state;
-
- switch (m_state) {
- case QMediaPlayer::StoppedState:
- state = GST_STATE_NULL;
- break;
- case QMediaPlayer::PausedState:
- state = GST_STATE_PAUSED;
- break;
- case QMediaPlayer::PlayingState:
- state = GST_STATE_PLAYING;
- break;
- }
-
- gst_element_set_state(m_colorSpace, state);
- gst_element_set_state(m_videoScale, state);
- gst_element_set_state(m_videoSink, state);
-
- //don't have to wait here, it will unblock eventually
- if (gst_pad_is_blocked(srcPad))
- gst_pad_set_blocked_async(srcPad, false, &block_pad_cb, 0);
- gst_object_unref(GST_OBJECT(srcPad));
-
-#ifdef DEBUG_VO_BIN_DUMP
- dumpNum++;
-
- _gst_debug_bin_to_dot_file(GST_BIN(m_videoOutputBin),
- GstDebugGraphDetails(/*GST_DEBUG_GRAPH_SHOW_ALL */ GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE | GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS | GST_DEBUG_GRAPH_SHOW_STATES),
- QString("video_output_change_%1_finish").arg(dumpNum).toAscii().constData());
-#endif
-
-}
-
-bool QGstreamerPlayerSession::isVideoAvailable() const
-{
- return m_videoAvailable;
-}
-
-bool QGstreamerPlayerSession::isSeekable() const
-{
- return m_seekable;
-}
-
-bool QGstreamerPlayerSession::play()
-{
- if (m_playbin) {
- if (gst_element_set_state(m_playbin, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
- qWarning() << "GStreamer; Unable to play -" << m_url.toString();
- m_state = QMediaPlayer::StoppedState;
-
- emit stateChanged(m_state);
- emit error(int(QMediaPlayer::ResourceError), tr("Unable to play %1").arg(m_url.path()));
- } else
- return true;
- }
-
- return false;
-}
-
-bool QGstreamerPlayerSession::pause()
-{
- if (m_playbin) {
- if (gst_element_set_state(m_playbin, GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE) {
- qWarning() << "GStreamer; Unable to play -" << m_url.toString();
- m_state = QMediaPlayer::StoppedState;
-
- emit stateChanged(m_state);
- emit error(int(QMediaPlayer::ResourceError), tr("Unable to play %1").arg(m_url.path()));
- } else
- return true;
- }
-
- return false;
-}
-
-void QGstreamerPlayerSession::stop()
-{
- if (m_playbin) {
- gst_element_set_state(m_playbin, GST_STATE_NULL);
-
- QMediaPlayer::State oldState = QMediaPlayer::StoppedState;
- m_state = QMediaPlayer::StoppedState;
-
- finishVideoOutputChange();
-
- //we have to do it here, since gstreamer will not emit bus messages any more
- if (oldState != m_state)
- emit stateChanged(m_state);
- }
-}
-
-bool QGstreamerPlayerSession::seek(qint64 ms)
-{
- //seek locks when the video output sink is changing and pad is blocked
- if (m_playbin && !m_pendingVideoSink && m_state != QMediaPlayer::StoppedState) {
-
- gint64 position = qMax(ms,qint64(0)) * 1000000;
- return gst_element_seek(m_playbin,
- m_playbackRate,
- GST_FORMAT_TIME,
- GstSeekFlags(GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH),
- GST_SEEK_TYPE_SET,
- position,
- GST_SEEK_TYPE_NONE,
- 0);
- }
-
- return false;
-}
-
-void QGstreamerPlayerSession::setVolume(int volume)
-{
- if (m_volume != volume) {
- m_volume = volume;
-
- if (m_playbin) {
-#ifndef USE_PLAYBIN2
- if(!m_muted)
-#endif
- g_object_set(G_OBJECT(m_playbin), "volume", m_volume/100.0, NULL);
- }
-
- emit volumeChanged(m_volume);
- }
-
-}
-
-void QGstreamerPlayerSession::setMuted(bool muted)
-{
- if (m_muted != muted) {
- m_muted = muted;
-
-#ifdef USE_PLAYBIN2
- g_object_set(G_OBJECT(m_playbin), "mute", m_muted, NULL);
-#else
- g_object_set(G_OBJECT(m_playbin), "volume", (m_muted ? 0 : m_volume/100.0), NULL);
-#endif
- emit mutedStateChanged(m_muted);
- }
-}
-
-static void addTagToMap(const GstTagList *list,
- const gchar *tag,
- gpointer user_data)
-{
- QMap<QByteArray, QVariant> *map = reinterpret_cast<QMap<QByteArray, QVariant>* >(user_data);
-
- GValue val;
- val.g_type = 0;
- gst_tag_list_copy_value(&val,list,tag);
-
- switch( G_VALUE_TYPE(&val) ) {
- case G_TYPE_STRING:
- {
- const gchar *str_value = g_value_get_string(&val);
- map->insert(QByteArray(tag), QString::fromUtf8(str_value));
- break;
- }
- case G_TYPE_INT:
- map->insert(QByteArray(tag), g_value_get_int(&val));
- break;
- case G_TYPE_UINT:
- map->insert(QByteArray(tag), g_value_get_uint(&val));
- break;
- case G_TYPE_LONG:
- map->insert(QByteArray(tag), qint64(g_value_get_long(&val)));
- break;
- case G_TYPE_BOOLEAN:
- map->insert(QByteArray(tag), g_value_get_boolean(&val));
- break;
- case G_TYPE_CHAR:
- map->insert(QByteArray(tag), g_value_get_char(&val));
- break;
- case G_TYPE_DOUBLE:
- map->insert(QByteArray(tag), g_value_get_double(&val));
- break;
- default:
- // GST_TYPE_DATE is a function, not a constant, so pull it out of the switch
- if (G_VALUE_TYPE(&val) == GST_TYPE_DATE) {
- const GDate *date = gst_value_get_date(&val);
- if (g_date_valid(date)) {
- int year = g_date_get_year(date);
- int month = g_date_get_month(date);
- int day = g_date_get_day(date);
- map->insert(QByteArray(tag), QDate(year,month,day));
- if (!map->contains("year"))
- map->insert("year", year);
- }
- } else if (G_VALUE_TYPE(&val) == GST_TYPE_FRACTION) {
- int nom = gst_value_get_fraction_numerator(&val);
- int denom = gst_value_get_fraction_denominator(&val);
-
- if (denom > 0) {
- map->insert(QByteArray(tag), double(nom)/denom);
- }
- }
- break;
- }
-
- g_value_unset(&val);
-}
-
-void QGstreamerPlayerSession::setSeekable(bool seekable)
-{
- if (seekable != m_seekable) {
- m_seekable = seekable;
- emit seekableChanged(m_seekable);
- }
-}
-
-bool QGstreamerPlayerSession::processSyncMessage(const QGstreamerMessage &message)
-{
- GstMessage* gm = message.rawMessage();
-
- if (gm &&
- GST_MESSAGE_TYPE(gm) == GST_MESSAGE_ELEMENT &&
- gst_structure_has_name(gm->structure, "prepare-xwindow-id"))
- {
- if (m_renderer)
- m_renderer->precessNewStream();
- return true;
- }
-
- return false;
-}
-
-void QGstreamerPlayerSession::busMessage(const QGstreamerMessage &message)
-{
- GstMessage* gm = message.rawMessage();
-
- if (gm == 0) {
- // Null message, query current position
- quint32 newPos = position();
-
- if (newPos/1000 != m_lastPosition) {
- m_lastPosition = newPos/1000;
- emit positionChanged(newPos);
- }
-
- } else {
- //tag message comes from elements inside playbin, not from playbin itself
- if (GST_MESSAGE_TYPE(gm) == GST_MESSAGE_TAG) {
- //qDebug() << "tag message";
- GstTagList *tag_list;
- gst_message_parse_tag(gm, &tag_list);
- gst_tag_list_foreach(tag_list, addTagToMap, &m_tags);
-
- //qDebug() << m_tags;
-
- emit tagsChanged();
- }
-
- if (GST_MESSAGE_SRC(gm) == GST_OBJECT_CAST(m_playbin)) {
- switch (GST_MESSAGE_TYPE(gm)) {
- case GST_MESSAGE_STATE_CHANGED:
- {
- GstState oldState;
- GstState newState;
- GstState pending;
-
- gst_message_parse_state_changed(gm, &oldState, &newState, &pending);
-
-#ifdef DEBUG_PLAYBIN_STATES
- QStringList states;
- states << "GST_STATE_VOID_PENDING" << "GST_STATE_NULL" << "GST_STATE_READY" << "GST_STATE_PAUSED" << "GST_STATE_PLAYING";
-
- qDebug() << QString("state changed: old: %1 new: %2 pending: %3") \
- .arg(states[oldState]) \
- .arg(states[newState]) \
- .arg(states[pending]);
-#endif
-
- switch (newState) {
- case GST_STATE_VOID_PENDING:
- case GST_STATE_NULL:
- setSeekable(false);
- if (m_state != QMediaPlayer::StoppedState)
- emit stateChanged(m_state = QMediaPlayer::StoppedState);
- break;
- case GST_STATE_READY:
- setSeekable(false);
- if (m_state != QMediaPlayer::StoppedState)
- emit stateChanged(m_state = QMediaPlayer::StoppedState);
- break;
- case GST_STATE_PAUSED:
- if (m_state != QMediaPlayer::PausedState)
- emit stateChanged(m_state = QMediaPlayer::PausedState);
-
- //check for seekable
- if (oldState == GST_STATE_READY) {
- /*
- //gst_element_seek_simple doesn't work reliably here, have to find a better solution
-
- GstFormat format = GST_FORMAT_TIME;
- gint64 position = 0;
- bool seekable = false;
- if (gst_element_query_position(m_playbin, &format, &position)) {
- seekable = gst_element_seek_simple(m_playbin, format, GST_SEEK_FLAG_NONE, position);
- }
-
- setSeekable(seekable);
- */
-
- setSeekable(true);
-
- if (!qFuzzyCompare(m_playbackRate, qreal(1.0))) {
- qreal rate = m_playbackRate;
- m_playbackRate = 1.0;
- setPlaybackRate(rate);
- }
-
- if (m_renderer)
- m_renderer->precessNewStream();
-
- }
-
-
- break;
- case GST_STATE_PLAYING:
- if (oldState == GST_STATE_PAUSED)
- getStreamsInfo();
-
- if (m_state != QMediaPlayer::PlayingState)
- emit stateChanged(m_state = QMediaPlayer::PlayingState);
-
- break;
- }
- }
- break;
-
- case GST_MESSAGE_EOS:
- emit playbackFinished();
- break;
-
- case GST_MESSAGE_TAG:
- case GST_MESSAGE_STREAM_STATUS:
- case GST_MESSAGE_UNKNOWN:
- break;
- case GST_MESSAGE_ERROR:
- {
- GError *err;
- gchar *debug;
- gst_message_parse_error (gm, &err, &debug);
- emit error(int(QMediaPlayer::ResourceError), QString::fromUtf8(err->message));
- qWarning() << "Error:" << QString::fromUtf8(err->message);
- g_error_free (err);
- g_free (debug);
- }
- break;
- case GST_MESSAGE_WARNING:
- case GST_MESSAGE_INFO:
- break;
- case GST_MESSAGE_BUFFERING:
- {
- int progress = 0;
- gst_message_parse_buffering(gm, &progress);
- emit bufferingProgressChanged(progress);
- }
- break;
- case GST_MESSAGE_STATE_DIRTY:
- case GST_MESSAGE_STEP_DONE:
- case GST_MESSAGE_CLOCK_PROVIDE:
- case GST_MESSAGE_CLOCK_LOST:
- case GST_MESSAGE_NEW_CLOCK:
- case GST_MESSAGE_STRUCTURE_CHANGE:
- case GST_MESSAGE_APPLICATION:
- case GST_MESSAGE_ELEMENT:
- break;
- case GST_MESSAGE_SEGMENT_START:
- {
- const GstStructure *structure = gst_message_get_structure(gm);
- qint64 position = g_value_get_int64(gst_structure_get_value(structure, "position"));
- position /= 1000000;
- m_lastPosition = position;
- emit positionChanged(position);
- }
- break;
- case GST_MESSAGE_SEGMENT_DONE:
- break;
- case GST_MESSAGE_DURATION:
- {
- GstFormat format = GST_FORMAT_TIME;
- gint64 duration = 0;
-
- if (gst_element_query_duration(m_playbin, &format, &duration)) {
- int newDuration = duration / 1000000;
- if (m_duration != newDuration) {
- m_duration = newDuration;
- emit durationChanged(m_duration);
- }
- }
- }
- break;
- case GST_MESSAGE_LATENCY:
-#if (GST_VERSION_MAJOR >= 0) && (GST_VERSION_MINOR >= 10) && (GST_VERSION_MICRO >= 13)
- case GST_MESSAGE_ASYNC_START:
- case GST_MESSAGE_ASYNC_DONE:
-#if GST_VERSION_MICRO >= 23
- case GST_MESSAGE_REQUEST_STATE:
-#endif
-#endif
- case GST_MESSAGE_ANY:
- break;
- }
- }
- }
-}
-
-void QGstreamerPlayerSession::getStreamsInfo()
-{
- GstFormat format = GST_FORMAT_TIME;
- gint64 duration = 0;
-
- if (gst_element_query_duration(m_playbin, &format, &duration)) {
- int newDuration = duration / 1000000;
- if (m_duration != newDuration) {
- m_duration = newDuration;
- emit durationChanged(m_duration);
- }
- }
-
- //check if video is available:
- bool haveAudio = false;
- bool haveVideo = false;
-// m_streamProperties.clear();
-// m_streamTypes.clear();
-
-#ifdef USE_PLAYBIN2
- gint audioStreamsCount = 0;
- gint videoStreamsCount = 0;
- gint textStreamsCount = 0;
-
- g_object_get(G_OBJECT(m_playbin), "n-audio", &audioStreamsCount, NULL);
- g_object_get(G_OBJECT(m_playbin), "n-video", &videoStreamsCount, NULL);
- g_object_get(G_OBJECT(m_playbin), "n-text", &textStreamsCount, NULL);
-
- haveAudio = audioStreamsCount > 0;
- haveVideo = videoStreamsCount > 0;
-
- /*m_playbin2StreamOffset[QMediaStreamsControl::AudioStream] = 0;
- m_playbin2StreamOffset[QMediaStreamsControl::VideoStream] = audioStreamsCount;
- m_playbin2StreamOffset[QMediaStreamsControl::SubPictureStream] = audioStreamsCount+videoStreamsCount;
-
- for (int i=0; i<audioStreamsCount; i++)
- m_streamTypes.append(QMediaStreamsControl::AudioStream);
-
- for (int i=0; i<videoStreamsCount; i++)
- m_streamTypes.append(QMediaStreamsControl::VideoStream);
-
- for (int i=0; i<textStreamsCount; i++)
- m_streamTypes.append(QMediaStreamsControl::SubPictureStream);
-
- for (int i=0; i<m_streamTypes.count(); i++) {
- QMediaStreamsControl::StreamType streamType = m_streamTypes[i];
- QMap<QtMediaServices::MetaData, QVariant> streamProperties;
-
- int streamIndex = i - m_playbin2StreamOffset[streamType];
-
- GstTagList *tags = 0;
- switch (streamType) {
- case QMediaStreamsControl::AudioStream:
- g_signal_emit_by_name(G_OBJECT(m_playbin), "get-audio-tags", streamIndex, &tags);
- break;
- case QMediaStreamsControl::VideoStream:
- g_signal_emit_by_name(G_OBJECT(m_playbin), "get-video-tags", streamIndex, &tags);
- break;
- case QMediaStreamsControl::SubPictureStream:
- g_signal_emit_by_name(G_OBJECT(m_playbin), "get-text-tags", streamIndex, &tags);
- break;
- default:
- break;
- }
-
- if (tags && gst_is_tag_list(tags)) {
- gchar *languageCode = 0;
- if (gst_tag_list_get_string(tags, GST_TAG_LANGUAGE_CODE, &languageCode))
- streamProperties[QtMediaServices::Language] = QString::fromUtf8(languageCode);
-
- //qDebug() << "language for setream" << i << QString::fromUtf8(languageCode);
- g_free (languageCode);
- }
-
- m_streamProperties.append(streamProperties);
-
- }
- */
-
-#else
- enum {
- GST_STREAM_TYPE_UNKNOWN,
- GST_STREAM_TYPE_AUDIO,
- GST_STREAM_TYPE_VIDEO,
- GST_STREAM_TYPE_TEXT,
- GST_STREAM_TYPE_SUBPICTURE,
- GST_STREAM_TYPE_ELEMENT
- };
-
- GList* streamInfo;
- g_object_get(G_OBJECT(m_playbin), "stream-info", &streamInfo, NULL);
-
- for (; streamInfo != 0; streamInfo = g_list_next(streamInfo)) {
- gint type;
- gchar *languageCode = 0;
-
- GObject* obj = G_OBJECT(streamInfo->data);
-
- g_object_get(obj, "type", &type, NULL);
- g_object_get(obj, "language-code", &languageCode, NULL);
-
- if (type == GST_STREAM_TYPE_VIDEO)
- haveVideo = true;
- else if (type == GST_STREAM_TYPE_AUDIO)
- haveAudio = true;
-
-// QMediaStreamsControl::StreamType streamType = QMediaStreamsControl::UnknownStream;
-//
-// switch (type) {
-// case GST_STREAM_TYPE_VIDEO:
-// streamType = QMediaStreamsControl::VideoStream;
-// break;
-// case GST_STREAM_TYPE_AUDIO:
-// streamType = QMediaStreamsControl::AudioStream;
-// break;
-// case GST_STREAM_TYPE_SUBPICTURE:
-// streamType = QMediaStreamsControl::SubPictureStream;
-// break;
-// default:
-// streamType = QMediaStreamsControl::UnknownStream;
-// break;
-// }
-//
-// QMap<QtMediaServices::MetaData, QVariant> streamProperties;
-// streamProperties[QtMediaServices::Language] = QString::fromUtf8(languageCode);
-//
-// m_streamProperties.append(streamProperties);
-// m_streamTypes.append(streamType);
- }
-#endif
-
- if (haveAudio != m_audioAvailable) {
- m_audioAvailable = haveAudio;
- emit audioAvailableChanged(m_audioAvailable);
- }
- if (haveVideo != m_videoAvailable) {
- m_videoAvailable = haveVideo;
- emit videoAvailableChanged(m_videoAvailable);
- }
-
- emit streamsChanged();
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h
deleted file mode 100644
index 6499a84..0000000
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERPLAYERSESSION_H
-#define QGSTREAMERPLAYERSESSION_H
-
-#include <QObject>
-#include <QUrl>
-#include "qgstreamerplayercontrol.h"
-#include "qgstreamerbushelper.h"
-#include <QtMediaServices/qmediaplayer.h>
-//#include <qmediastreamscontrol.h>
-
-#include <gst/gst.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGstreamerBusHelper;
-class QGstreamerMessage;
-class QGstreamerVideoRendererInterface;
-
-class QGstreamerPlayerSession : public QObject, public QGstreamerSyncEventFilter
-{
-Q_OBJECT
-
-public:
- QGstreamerPlayerSession(QObject *parent);
- virtual ~QGstreamerPlayerSession();
-
- QUrl url() const;
-
- QMediaPlayer::State state() const { return m_state; }
-
- qint64 duration() const;
- qint64 position() const;
-
- bool isBuffering() const;
-
- int bufferingProgress() const;
-
- int volume() const;
- bool isMuted() const;
-
- void setVideoRenderer(QObject *renderer);
- bool isAudioAvailable() const;
- bool isVideoAvailable() const;
-
- bool isSeekable() const;
-
- qreal playbackRate() const;
- void setPlaybackRate(qreal rate);
-
- QMap<QByteArray ,QVariant> tags() const { return m_tags; }
- QMap<QtMediaServices::MetaData,QVariant> streamProperties(int streamNumber) const { return m_streamProperties[streamNumber]; }
-// int streamCount() const { return m_streamProperties.count(); }
-// QMediaStreamsControl::StreamType streamType(int streamNumber) { return m_streamTypes.value(streamNumber, QMediaStreamsControl::UnknownStream); }
-//
-// int activeStream(QMediaStreamsControl::StreamType streamType) const;
-// void setActiveStream(QMediaStreamsControl::StreamType streamType, int streamNumber);
-
- bool processSyncMessage(const QGstreamerMessage &message);
-
-public slots:
- void load(const QUrl &url);
-
- bool play();
- bool pause();
- void stop();
-
- bool seek(qint64 pos);
-
- void setVolume(int volume);
- void setMuted(bool muted);
-
-signals:
- void durationChanged(qint64 duration);
- void positionChanged(qint64 position);
- void stateChanged(QMediaPlayer::State state);
- void volumeChanged(int volume);
- void mutedStateChanged(bool muted);
- void audioAvailableChanged(bool audioAvailable);
- void videoAvailableChanged(bool videoAvailable);
- void bufferingChanged(bool buffering);
- void bufferingProgressChanged(int percentFilled);
- void playbackFinished();
- void tagsChanged();
- void streamsChanged();
- void seekableChanged(bool);
- void error(int error, const QString &errorString);
-
-private slots:
- void busMessage(const QGstreamerMessage &message);
- void getStreamsInfo();
- void setSeekable(bool);
- void finishVideoOutputChange();
-
-private:
- QUrl m_url;
- QMediaPlayer::State m_state;
- QGstreamerBusHelper* m_busHelper;
- GstElement* m_playbin;
-
- GstElement* m_videoOutputBin;
- GstElement* m_videoIdentity;
- GstElement* m_colorSpace;
- GstElement* m_videoScale;
- GstElement* m_videoSink;
- GstElement* m_pendingVideoSink;
- GstElement* m_nullVideoSink;
-
- GstBus* m_bus;
- QGstreamerVideoRendererInterface *m_renderer;
-
- QMap<QByteArray, QVariant> m_tags;
- QList< QMap<QtMediaServices::MetaData,QVariant> > m_streamProperties;
-// QList<QMediaStreamsControl::StreamType> m_streamTypes;
-// QMap<QMediaStreamsControl::StreamType, int> m_playbin2StreamOffset;
-
-
- int m_volume;
- qreal m_playbackRate;
- bool m_muted;
- bool m_audioAvailable;
- bool m_videoAvailable;
- bool m_seekable;
-
- qint64 m_lastPosition;
- qint64 m_duration;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGSTREAMERPLAYERSESSION_H
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.cpp b/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.cpp
deleted file mode 100644
index 5049fa1..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QMap>
-#include <QTimer>
-#include <QMutex>
-
-#include "qgstreamerbushelper.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_GLIB
-class QGstreamerBusHelperPrivate : public QObject
-{
- Q_OBJECT
-
-public:
- void addWatch(GstBus* bus, QGstreamerBusHelper* helper)
- {
- setParent(helper);
- m_tag = gst_bus_add_watch_full(bus, 0, busCallback, this, NULL);
- m_helper = helper;
- filter = 0;
- }
-
- void removeWatch(QGstreamerBusHelper* helper)
- {
- Q_UNUSED(helper);
- g_source_remove(m_tag);
- }
-
- static QGstreamerBusHelperPrivate* instance()
- {
- return new QGstreamerBusHelperPrivate;
- }
-
-private:
- void processMessage(GstBus* bus, GstMessage* message)
- {
- Q_UNUSED(bus);
- emit m_helper->message(message);
- }
-
- static gboolean busCallback(GstBus *bus, GstMessage *message, gpointer data)
- {
- reinterpret_cast<QGstreamerBusHelperPrivate*>(data)->processMessage(bus, message);
- return TRUE;
- }
-
- guint m_tag;
- QGstreamerBusHelper* m_helper;
-
-public:
- GstBus* bus;
- QGstreamerSyncEventFilter *filter;
- QMutex filterMutex;
-};
-
-#else
-
-class QGstreamerBusHelperPrivate : public QObject
-{
- Q_OBJECT
- typedef QMap<QGstreamerBusHelper*, GstBus*> HelperMap;
-
-public:
- void addWatch(GstBus* bus, QGstreamerBusHelper* helper)
- {
- m_helperMap.insert(helper, bus);
-
- if (m_helperMap.size() == 1)
- m_intervalTimer->start();
- }
-
- void removeWatch(QGstreamerBusHelper* helper)
- {
- m_helperMap.remove(helper);
-
- if (m_helperMap.size() == 0)
- m_intervalTimer->stop();
- }
-
- static QGstreamerBusHelperPrivate* instance()
- {
- static QGstreamerBusHelperPrivate self;
-
- return &self;
- }
-
-private slots:
- void interval()
- {
- for (HelperMap::iterator it = m_helperMap.begin(); it != m_helperMap.end(); ++it) {
- GstMessage* message;
-
- while ((message = gst_bus_poll(it.value(), GST_MESSAGE_ANY, 0)) != 0) {
- emit it.key()->message(message);
- gst_message_unref(message);
- }
-
- emit it.key()->message(QGstreamerMessage());
- }
- }
-
-private:
- QGstreamerBusHelperPrivate()
- {
- m_intervalTimer = new QTimer(this);
- m_intervalTimer->setInterval(250);
-
- connect(m_intervalTimer, SIGNAL(timeout()), SLOT(interval()));
- }
-
- HelperMap m_helperMap;
- QTimer* m_intervalTimer;
-
-public:
- GstBus* bus;
- QGstreamerSyncEventFilter *filter;
- QMutex filterMutex;
-};
-#endif
-
-
-static GstBusSyncReply syncGstBusFilter(GstBus* bus, GstMessage* message, QGstreamerBusHelperPrivate *d)
-{
- Q_UNUSED(bus);
- QMutexLocker lock(&d->filterMutex);
-
- bool res = false;
-
- if (d->filter)
- res = d->filter->processSyncMessage(QGstreamerMessage(message));
-
- return res ? GST_BUS_DROP : GST_BUS_PASS;
-}
-
-
-/*!
- \class QGstreamerBusHelper
- \internal
-*/
-
-QGstreamerBusHelper::QGstreamerBusHelper(GstBus* bus, QObject* parent):
- QObject(parent),
- d(QGstreamerBusHelperPrivate::instance())
-{
- d->bus = bus;
- d->addWatch(bus, this);
-
- gst_bus_set_sync_handler(bus, (GstBusSyncHandler)syncGstBusFilter, d);
-}
-
-QGstreamerBusHelper::~QGstreamerBusHelper()
-{
- d->removeWatch(this);
- gst_bus_set_sync_handler(d->bus,0,0);
-}
-
-void QGstreamerBusHelper::installSyncEventFilter(QGstreamerSyncEventFilter *filter)
-{
- QMutexLocker lock(&d->filterMutex);
- d->filter = filter;
-}
-
-QT_END_NAMESPACE
-
-#include "qgstreamerbushelper.moc"
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.h b/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.h
deleted file mode 100644
index 8600015..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERBUSHELPER_H
-#define QGSTREAMERBUSHELPER_H
-
-#include <QObject>
-
-#include <qgstreamermessage.h>
-#include <gst/gst.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGstreamerSyncEventFilter {
-public:
- //returns true if message was processed and should be dropped, false otherwise
- virtual bool processSyncMessage(const QGstreamerMessage &message) = 0;
-};
-
-class QGstreamerBusHelperPrivate;
-
-class QGstreamerBusHelper : public QObject
-{
- Q_OBJECT
- friend class QGstreamerBusHelperPrivate;
-
-public:
- QGstreamerBusHelper(GstBus* bus, QObject* parent = 0);
- ~QGstreamerBusHelper();
-
- void installSyncEventFilter(QGstreamerSyncEventFilter *filter);
-
-signals:
- void message(QGstreamerMessage const& message);
-
-
-private:
- QGstreamerBusHelperPrivate* d;
-};
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamermessage.cpp b/src/plugins/mediaservices/gstreamer/qgstreamermessage.cpp
deleted file mode 100644
index d52aa75..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamermessage.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <gst/gst.h>
-
-#include "qgstreamermessage.h"
-
-
-QT_BEGIN_NAMESPACE
-
-static int wuchi = qRegisterMetaType<QGstreamerMessage>();
-
-
-/*!
- \class QGstreamerMessage
- \internal
-*/
-
-QGstreamerMessage::QGstreamerMessage():
- m_message(0)
-{
-}
-
-QGstreamerMessage::QGstreamerMessage(GstMessage* message):
- m_message(message)
-{
- gst_message_ref(m_message);
-}
-
-QGstreamerMessage::QGstreamerMessage(QGstreamerMessage const& m):
- m_message(m.m_message)
-{
- gst_message_ref(m_message);
-}
-
-
-QGstreamerMessage::~QGstreamerMessage()
-{
- if (m_message != 0)
- gst_message_unref(m_message);
-}
-
-GstMessage* QGstreamerMessage::rawMessage() const
-{
- return m_message;
-}
-
-QGstreamerMessage& QGstreamerMessage::operator=(QGstreamerMessage const& rhs)
-{
- if (m_message != 0)
- gst_message_unref(m_message);
-
- if ((m_message = rhs.m_message) != 0)
- gst_message_ref(m_message);
-
- return *this;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamermessage.h b/src/plugins/mediaservices/gstreamer/qgstreamermessage.h
deleted file mode 100644
index 4680903..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamermessage.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERMESSAGE_H
-#define QGSTREAMERMESSAGE_H
-
-#include <QMetaType>
-
-#include <gst/gst.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGstreamerMessage
-{
-public:
- QGstreamerMessage();
- QGstreamerMessage(GstMessage* message);
- QGstreamerMessage(QGstreamerMessage const& m);
- ~QGstreamerMessage();
-
- GstMessage* rawMessage() const;
-
- QGstreamerMessage& operator=(QGstreamerMessage const& rhs);
-
-private:
- GstMessage* m_message;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGstreamerMessage);
-
-QT_END_HEADER
-
-#endif
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.cpp b/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.cpp
deleted file mode 100644
index 0ca7d54..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/qstring.h>
-#include <QtCore/qdebug.h>
-#include <QtGui/QIcon>
-#include <QtCore/QDir>
-
-#include "qgstreamerserviceplugin.h"
-
-#ifdef QMEDIA_GSTREAMER_PLAYER
-#include "qgstreamerplayerservice.h"
-#endif
-#ifdef QMEDIA_GSTREAMER_CAPTURE
-#include "qgstreamercaptureservice.h"
-#endif
-#include <QtMediaServices/qmediaserviceprovider.h>
-
-#ifdef QMEDIA_GSTREAMER_CAPTURE
-#include <linux/types.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/poll.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/mman.h>
-#include <linux/videodev2.h>
-#endif
-
-
-QT_BEGIN_NAMESPACE
-
-
-QStringList QGstreamerServicePlugin::keys() const
-{
- return QStringList()
-#ifdef QMEDIA_GSTREAMER_PLAYER
- << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)
-#endif
-#ifdef QMEDIA_GSTREAMER_CAPTURE
- << QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE)
- << QLatin1String(Q_MEDIASERVICE_CAMERA)
-#endif
- ;
-}
-
-QMediaService* QGstreamerServicePlugin::create(const QString &key)
-{
-#ifdef QMEDIA_GSTREAMER_PLAYER
- if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER))
- return new QGstreamerPlayerService;
-#endif
-#ifdef QMEDIA_GSTREAMER_CAPTURE
- if (key == QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE))
- return new QGstreamerCaptureService(key);
-
- if (key == QLatin1String(Q_MEDIASERVICE_CAMERA))
- return new QGstreamerCaptureService(key);
-#endif
-
- qWarning() << "GStreamer service plugin: unsupported service -" << key;
- return 0;
-}
-
-void QGstreamerServicePlugin::release(QMediaService *service)
-{
- delete service;
-}
-
-QList<QByteArray> QGstreamerServicePlugin::devices(const QByteArray &service) const
-{
-#ifdef QMEDIA_GSTREAMER_CAPTURE
- if (service == Q_MEDIASERVICE_CAMERA) {
- if (m_cameraDevices.isEmpty())
- updateDevices();
-
- return m_cameraDevices;
- }
-#endif
-
- return QList<QByteArray>();
-}
-
-QString QGstreamerServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device)
-{
-#ifdef QMEDIA_GSTREAMER_CAPTURE
- if (service == Q_MEDIASERVICE_CAMERA) {
- if (m_cameraDevices.isEmpty())
- updateDevices();
-
- for (int i=0; i<m_cameraDevices.count(); i++)
- if (m_cameraDevices[i] == device)
- return m_cameraDescriptions[i];
- }
-#endif
-
- return QString();
-}
-
-void QGstreamerServicePlugin::updateDevices() const
-{
-#ifdef QMEDIA_GSTREAMER_CAPTURE
- m_cameraDevices.clear();
- m_cameraDescriptions.clear();
-
- QDir devDir("/dev");
- devDir.setFilter(QDir::System);
-
- QFileInfoList entries = devDir.entryInfoList(QStringList() << "video*");
-
- foreach( const QFileInfo &entryInfo, entries ) {
-// qDebug() << "Try" << entryInfo.filePath();
-
- int fd = ::open(entryInfo.filePath().toLatin1().constData(), O_RDWR );
- if (fd == -1)
- continue;
-
- bool isCamera = false;
-
- v4l2_input input;
- memset(&input, 0, sizeof(input));
- for (; ::ioctl(fd, VIDIOC_ENUMINPUT, &input) >= 0; ++input.index) {
- if(input.type == V4L2_INPUT_TYPE_CAMERA || input.type == 0) {
- isCamera = ::ioctl(fd, VIDIOC_S_INPUT, input.index) != 0;
- break;
- }
- }
-
- if (isCamera) {
- // find out its driver "name"
- QString name;
- struct v4l2_capability vcap;
- memset(&vcap, 0, sizeof(struct v4l2_capability));
-
- if (ioctl(fd, VIDIOC_QUERYCAP, &vcap) != 0)
- name = entryInfo.fileName();
- else
- name = QString((const char*)vcap.card);
-// qDebug() << "found camera: " << name;
-
- m_cameraDevices.append(entryInfo.filePath().toLocal8Bit());
- m_cameraDescriptions.append(name);
- }
- ::close(fd);
- }
-#endif
-}
-
-Q_EXPORT_PLUGIN2(gstengine, QGstreamerServicePlugin);
-
-QT_END_NAMESPACE
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.h b/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.h
deleted file mode 100644
index e0a5dfd..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#ifndef QGSTREAMERSERVICEPLUGIN_H
-#define QGSTREAMERSERVICEPLUGIN_H
-
-#include <QtMediaServices/qmediaserviceproviderplugin.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGstreamerServicePlugin : public QMediaServiceProviderPlugin, public QMediaServiceSupportedDevicesInterface
-{
- Q_OBJECT
- Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
-public:
- QStringList keys() const;
- QMediaService* create(QString const& key);
- void release(QMediaService *service);
-
- QList<QByteArray> devices(const QByteArray &service) const;
- QString deviceDescription(const QByteArray &service, const QByteArray &device);
-
-private:
- void updateDevices() const;
-
- mutable QList<QByteArray> m_cameraDevices;
- mutable QStringList m_cameraDescriptions;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGSTREAMERSERVICEPLUGIN_H
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp
deleted file mode 100644
index 4ecf10b..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgstreamervideoinputdevicecontrol.h"
-
-#include <QtGui/QIcon>
-#include <QtCore/QDir>
-#include <QtCore/QDebug>
-
-#include <linux/types.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/poll.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/mman.h>
-#include <linux/videodev2.h>
-
-
-QT_BEGIN_NAMESPACE
-
-QGstreamerVideoInputDeviceControl::QGstreamerVideoInputDeviceControl(QObject *parent)
- :QVideoDeviceControl(parent), m_selectedDevice(0)
-{
- update();
-}
-
-QGstreamerVideoInputDeviceControl::~QGstreamerVideoInputDeviceControl()
-{
-}
-
-int QGstreamerVideoInputDeviceControl::deviceCount() const
-{
- return m_names.size();
-}
-
-QString QGstreamerVideoInputDeviceControl::deviceName(int index) const
-{
- return m_names[index];
-}
-
-QString QGstreamerVideoInputDeviceControl::deviceDescription(int index) const
-{
- return m_descriptions[index];
-}
-
-QIcon QGstreamerVideoInputDeviceControl::deviceIcon(int index) const
-{
- Q_UNUSED(index);
- return QIcon();
-}
-
-int QGstreamerVideoInputDeviceControl::defaultDevice() const
-{
- return 0;
-}
-
-int QGstreamerVideoInputDeviceControl::selectedDevice() const
-{
- return m_selectedDevice;
-}
-
-
-void QGstreamerVideoInputDeviceControl::setSelectedDevice(int index)
-{
- if (index != m_selectedDevice) {
- m_selectedDevice = index;
- emit selectedDeviceChanged(index);
- emit selectedDeviceChanged(deviceName(index));
- }
-}
-
-
-void QGstreamerVideoInputDeviceControl::update()
-{
- m_names.clear();
- m_descriptions.clear();
-
-#ifdef QMEDIA_GSTREAMER_CAPTURE
- QDir devDir("/dev");
- devDir.setFilter(QDir::System);
-
- QFileInfoList entries = devDir.entryInfoList(QStringList() << "video*");
-
- foreach( const QFileInfo &entryInfo, entries ) {
-// qDebug() << "Try" << entryInfo.filePath();
-
- int fd = ::open(entryInfo.filePath().toLatin1().constData(), O_RDWR );
- if (fd == -1)
- continue;
-
- bool isCamera = false;
-
- v4l2_input input;
- memset(&input, 0, sizeof(input));
- for (; ::ioctl(fd, VIDIOC_ENUMINPUT, &input) >= 0; ++input.index) {
- if(input.type == V4L2_INPUT_TYPE_CAMERA || input.type == 0) {
- isCamera = ::ioctl(fd, VIDIOC_S_INPUT, input.index) != 0;
- break;
- }
- }
-
- if (isCamera) {
- // find out its driver "name"
- QString name;
- struct v4l2_capability vcap;
- memset(&vcap, 0, sizeof(struct v4l2_capability));
-
- if (ioctl(fd, VIDIOC_QUERYCAP, &vcap) != 0)
- name = entryInfo.fileName();
- else
- name = QString((const char*)vcap.card);
-// qDebug() << "found camera: " << name;
-
- m_names.append(entryInfo.filePath());
- m_descriptions.append(name);
- }
- ::close(fd);
- }
-#endif
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.h b/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.h
deleted file mode 100644
index 7994f9c..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERVIDEOINPUTDEVICECONTROL_H
-#define QGSTREAMERVIDEOINPUTDEVICECONTROL_H
-
-#include <QtMediaServices/qvideodevicecontrol.h>
-#include <QtCore/qstringlist.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QGstreamerVideoInputDeviceControl : public QVideoDeviceControl
-{
-Q_OBJECT
-public:
- QGstreamerVideoInputDeviceControl(QObject *parent);
- ~QGstreamerVideoInputDeviceControl();
-
- int deviceCount() const;
-
- QString deviceName(int index) const;
- QString deviceDescription(int index) const;
- QIcon deviceIcon(int index) const;
-
- int defaultDevice() const;
- int selectedDevice() const;
-
-public Q_SLOTS:
- void setSelectedDevice(int index);
-
-private:
- void update();
-
- int m_selectedDevice;
- QStringList m_names;
- QStringList m_descriptions;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGSTREAMERAUDIOINPUTDEVICECONTROL_H
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.cpp
deleted file mode 100644
index f406bff..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgstreamervideooutputcontrol.h"
-
-QT_BEGIN_NAMESPACE
-
-QGstreamerVideoOutputControl::QGstreamerVideoOutputControl(QObject *parent)
- : QVideoOutputControl(parent)
- , m_output(NoOutput)
-{
-}
-
-QList<QVideoOutputControl::Output> QGstreamerVideoOutputControl::availableOutputs() const
-{
- return m_outputs;
-}
-
-void QGstreamerVideoOutputControl::setAvailableOutputs(const QList<Output> &outputs)
-{
- emit availableOutputsChanged(m_outputs = outputs);
-}
-
-QVideoOutputControl::Output QGstreamerVideoOutputControl::output() const
-{
- return m_output;
-}
-
-void QGstreamerVideoOutputControl::setOutput(Output output)
-{
- if (!m_outputs.contains(output))
- output = NoOutput;
-
- if (m_output != output)
- emit outputChanged(m_output = output);
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.h b/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.h
deleted file mode 100644
index 6d7d47f..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERVIDEOOUTPUTCONTROL_H
-#define QGSTREAMERVIDEOOUTPUTCONTROL_H
-
-#include <QtMediaServices/qvideooutputcontrol.h>
-
-#include <gst/gst.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGstreamerVideoRendererInterface
-{
-public:
- virtual ~QGstreamerVideoRendererInterface();
- virtual GstElement *videoSink() = 0;
- virtual void precessNewStream() {}
-};
-
-class QGstreamerVideoOutputControl : public QVideoOutputControl
-{
- Q_OBJECT
-public:
- QGstreamerVideoOutputControl(QObject *parent = 0);
-
- QList<Output> availableOutputs() const;
- void setAvailableOutputs(const QList<Output> &outputs);
-
- Output output() const;
- void setOutput(Output output);
-
-Q_SIGNALS:
- void outputChanged(QVideoOutputControl::Output output);
-
-private:
- QList<Output> m_outputs;
- Output m_output;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp
deleted file mode 100644
index f381f7f..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp
+++ /dev/null
@@ -1,230 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgstreamervideooverlay.h"
-#include "qvideosurfacegstsink.h"
-
-#include <QtMultimedia/qvideosurfaceformat.h>
-
-#include "qx11videosurface.h"
-
-QT_BEGIN_NAMESPACE
-
-QGstreamerVideoOverlay::QGstreamerVideoOverlay(QObject *parent)
- : QVideoWindowControl(parent)
- , m_surface(new QX11VideoSurface)
- , m_videoSink(reinterpret_cast<GstElement*>(QVideoSurfaceGstSink::createSink(m_surface)))
- , m_aspectRatioMode(Qt::KeepAspectRatio)
- , m_fullScreen(false)
-{
- if (m_videoSink) {
- gst_object_ref(GST_OBJECT(m_videoSink)); //Take ownership
- gst_object_sink(GST_OBJECT(m_videoSink));
- }
-
- connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)),
- this, SLOT(surfaceFormatChanged()));
-}
-
-QGstreamerVideoOverlay::~QGstreamerVideoOverlay()
-{
- if (m_videoSink)
- gst_object_unref(GST_OBJECT(m_videoSink));
-
- delete m_surface;
-}
-
-WId QGstreamerVideoOverlay::winId() const
-{
- return m_surface->winId();
-}
-
-void QGstreamerVideoOverlay::setWinId(WId id)
-{
- m_surface->setWinId(id);
-}
-
-QRect QGstreamerVideoOverlay::displayRect() const
-{
- return m_displayRect;
-}
-
-void QGstreamerVideoOverlay::setDisplayRect(const QRect &rect)
-{
- m_displayRect = rect;
-
- setScaledDisplayRect();
-}
-
-Qt::AspectRatioMode QGstreamerVideoOverlay::aspectRatioMode() const
-{
- return m_aspectRatioMode;
-}
-
-void QGstreamerVideoOverlay::setAspectRatioMode(Qt::AspectRatioMode mode)
-{
- m_aspectRatioMode = mode;
-
- setScaledDisplayRect();
-}
-
-void QGstreamerVideoOverlay::repaint()
-{
-}
-
-int QGstreamerVideoOverlay::brightness() const
-{
- return m_surface->brightness();
-}
-
-void QGstreamerVideoOverlay::setBrightness(int brightness)
-{
- m_surface->setBrightness(brightness);
-
- emit brightnessChanged(m_surface->brightness());
-}
-
-int QGstreamerVideoOverlay::contrast() const
-{
- return m_surface->contrast();
-}
-
-void QGstreamerVideoOverlay::setContrast(int contrast)
-{
- m_surface->setContrast(contrast);
-
- emit contrastChanged(m_surface->contrast());
-}
-
-int QGstreamerVideoOverlay::hue() const
-{
- return m_surface->hue();
-}
-
-void QGstreamerVideoOverlay::setHue(int hue)
-{
- m_surface->setHue(hue);
-
- emit hueChanged(m_surface->hue());
-}
-
-int QGstreamerVideoOverlay::saturation() const
-{
- return m_surface->saturation();
-}
-
-void QGstreamerVideoOverlay::setSaturation(int saturation)
-{
- m_surface->setSaturation(saturation);
-
- emit saturationChanged(m_surface->saturation());
-}
-
-bool QGstreamerVideoOverlay::isFullScreen() const
-{
- return m_fullScreen;
-}
-
-void QGstreamerVideoOverlay::setFullScreen(bool fullScreen)
-{
- emit fullScreenChanged(m_fullScreen = fullScreen);
-}
-
-QSize QGstreamerVideoOverlay::nativeSize() const
-{
- return m_surface->surfaceFormat().sizeHint();
-}
-
-QAbstractVideoSurface *QGstreamerVideoOverlay::surface() const
-{
- return m_surface;
-}
-
-GstElement *QGstreamerVideoOverlay::videoSink()
-{
- return m_videoSink;
-}
-
-void QGstreamerVideoOverlay::surfaceFormatChanged()
-{
- setScaledDisplayRect();
-
- emit nativeSizeChanged();
-}
-
-void QGstreamerVideoOverlay::setScaledDisplayRect()
-{
- QRect formatViewport = m_surface->surfaceFormat().viewport();
-
- switch (m_aspectRatioMode) {
- case Qt::KeepAspectRatio:
- {
- QSize size = m_surface->surfaceFormat().sizeHint();
- size.scale(m_displayRect.size(), Qt::KeepAspectRatio);
-
- QRect rect(QPoint(0, 0), size);
- rect.moveCenter(m_displayRect.center());
-
- m_surface->setDisplayRect(rect);
- m_surface->setViewport(formatViewport);
- }
- break;
- case Qt::IgnoreAspectRatio:
- m_surface->setDisplayRect(m_displayRect);
- m_surface->setViewport(formatViewport);
- break;
- case Qt::KeepAspectRatioByExpanding:
- {
- QSize size = m_displayRect.size();
- size.scale(m_surface->surfaceFormat().sizeHint(), Qt::KeepAspectRatio);
-
- QRect viewport(QPoint(0, 0), size);
- viewport.moveCenter(formatViewport.center());
-
- m_surface->setDisplayRect(m_displayRect);
- m_surface->setViewport(viewport);
- }
- break;
- };
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.h b/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.h
deleted file mode 100644
index f44c25b..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERVIDEOOVERLAY_H
-#define QGSTREAMERVIDEOOVERLAY_H
-
-#include <QtMediaServices/qvideowindowcontrol.h>
-
-#include "qgstreamervideorendererinterface.h"
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QAbstractVideoSurface;
-class QX11VideoSurface;
-
-class QGstreamerVideoOverlay : public QVideoWindowControl, public QGstreamerVideoRendererInterface
-{
- Q_OBJECT
- Q_INTERFACES(QGstreamerVideoRendererInterface)
-public:
- QGstreamerVideoOverlay(QObject *parent = 0);
- ~QGstreamerVideoOverlay();
-
- WId winId() const;
- void setWinId(WId id);
-
- QRect displayRect() const;
- void setDisplayRect(const QRect &rect);
-
- bool isFullScreen() const;
- void setFullScreen(bool fullScreen);
-
- QSize nativeSize() const;
-
- Qt::AspectRatioMode aspectRatioMode() const;
- void setAspectRatioMode(Qt::AspectRatioMode mode);
-
- void repaint();
-
- int brightness() const;
- void setBrightness(int brightness);
-
- int contrast() const;
- void setContrast(int contrast);
-
- int hue() const;
- void setHue(int hue);
-
- int saturation() const;
- void setSaturation(int saturation);
-
- QAbstractVideoSurface *surface() const;
-
- GstElement *videoSink();
-
-private slots:
- void surfaceFormatChanged();
-
-private:
- void setScaledDisplayRect();
-
- QX11VideoSurface *m_surface;
- GstElement *m_videoSink;
- Qt::AspectRatioMode m_aspectRatioMode;
- QRect m_displayRect;
- bool m_fullScreen;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.cpp
deleted file mode 100644
index 1f03990..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgstreamervideorenderer.h"
-#include "qvideosurfacegstsink.h"
-
-#include <QEvent>
-#include <QApplication>
-
-#include <gst/gst.h>
-
-
-QT_BEGIN_NAMESPACE
-
-QGstreamerVideoRenderer::QGstreamerVideoRenderer(QObject *parent)
- :QVideoRendererControl(parent),m_videoSink(0)
-{
-}
-
-QGstreamerVideoRenderer::~QGstreamerVideoRenderer()
-{
- if (m_videoSink)
- gst_object_unref(GST_OBJECT(m_videoSink));
-}
-
-GstElement *QGstreamerVideoRenderer::videoSink()
-{
- if (!m_videoSink) {
- m_videoSink = reinterpret_cast<GstElement*>(QVideoSurfaceGstSink::createSink(m_surface));
- gst_object_ref(GST_OBJECT(m_videoSink)); //Take ownership
- gst_object_sink(GST_OBJECT(m_videoSink));
- }
-
- return m_videoSink;
-}
-
-
-QAbstractVideoSurface *QGstreamerVideoRenderer::surface() const
-{
- return m_surface;
-}
-
-void QGstreamerVideoRenderer::setSurface(QAbstractVideoSurface *surface)
-{
- m_surface = surface;
-}
-
-QT_END_NAMESPACE
-
-
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.h b/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.h
deleted file mode 100644
index 0fbbd63..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERVIDEORENDERER_H
-#define QGSTREAMERVIDEORENDERER_H
-
-#include <QtMediaServices/qvideorenderercontrol.h>
-#include "qvideosurfacegstsink.h"
-
-#include "qgstreamervideorendererinterface.h"
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGstreamerVideoRenderer : public QVideoRendererControl, public QGstreamerVideoRendererInterface
-{
- Q_OBJECT
- Q_INTERFACES(QGstreamerVideoRendererInterface)
-public:
- QGstreamerVideoRenderer(QObject *parent = 0);
- virtual ~QGstreamerVideoRenderer();
-
- QAbstractVideoSurface *surface() const;
- void setSurface(QAbstractVideoSurface *surface);
-
- GstElement *videoSink();
- void precessNewStream() {}
-
-private:
- GstElement *m_videoSink;
- QAbstractVideoSurface *m_surface;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGSTREAMERVIDEORENDRER_H
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.cpp
deleted file mode 100644
index 886a064..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgstreamervideorendererinterface.h"
-
-
-QT_BEGIN_NAMESPACE
-
-QGstreamerVideoRendererInterface::~QGstreamerVideoRendererInterface()
-{
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.h b/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.h
deleted file mode 100644
index c63a757..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERVIDEOOUTPUTCONTROL_H
-#define QGSTREAMERVIDEOOUTPUTCONTROL_H
-
-#include <gst/gst.h>
-
-#include <QtCore/qobject.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGstreamerVideoRendererInterface
-{
-public:
- virtual ~QGstreamerVideoRendererInterface();
- virtual GstElement *videoSink() = 0;
- virtual void precessNewStream() {}
-};
-
-#define QGstreamerVideoRendererInterface_iid "com.nokia.Qt.QGstreamerVideoRendererInterface/1.0"
-Q_DECLARE_INTERFACE(QGstreamerVideoRendererInterface, QGstreamerVideoRendererInterface_iid)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp
deleted file mode 100644
index 763f7f1..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp
+++ /dev/null
@@ -1,340 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgstreamervideowidget.h"
-
-#include <QtCore/qcoreevent.h>
-#include <QtCore/qdebug.h>
-#include <QtGui/qapplication.h>
-#include <QtGui/qpainter.h>
-
-#include <X11/Xlib.h>
-#include <gst/gst.h>
-#include <gst/interfaces/xoverlay.h>
-#include <gst/interfaces/propertyprobe.h>
-
-
-QT_BEGIN_NAMESPACE
-
-class QGstreamerVideoWidget : public QWidget
-{
-public:
- QGstreamerVideoWidget(QWidget *parent = 0)
- :QWidget(parent)
- {
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- QPalette palette;
- palette.setColor(QPalette::Background, Qt::black);
- setPalette(palette);
- }
-
- virtual ~QGstreamerVideoWidget() {}
-
- QSize sizeHint() const
- {
- return m_nativeSize;
- }
-
- void setNativeSize( const QSize &size)
- {
- if (size != m_nativeSize) {
- m_nativeSize = size;
- if (size.isEmpty())
- setMinimumSize(0,0);
- else
- setMinimumSize(160,120);
-
- updateGeometry();
- }
- }
-
-protected:
- void paintEvent(QPaintEvent *)
- {
- QPainter painter(this);
- painter.fillRect(rect(), palette().background());
- }
-
- QSize m_nativeSize;
-};
-
-QGstreamerVideoWidgetControl::QGstreamerVideoWidgetControl(QObject *parent)
- : QVideoWidgetControl(parent)
- , m_videoSink(0)
- , m_widget(0)
- , m_fullScreen(false)
-{
-}
-
-QGstreamerVideoWidgetControl::~QGstreamerVideoWidgetControl()
-{
- if (m_videoSink)
- gst_object_unref(GST_OBJECT(m_videoSink));
-
- delete m_widget;
-}
-
-void QGstreamerVideoWidgetControl::createVideoWidget()
-{
- if (m_widget)
- return;
-
- m_widget = new QGstreamerVideoWidget;
-
- m_widget->installEventFilter(this);
- m_windowId = m_widget->winId();
-
- m_videoSink = gst_element_factory_make ("xvimagesink", NULL);
- if (m_videoSink) {
- // Check if the xv sink is usable
- if (gst_element_set_state(m_videoSink, GST_STATE_READY) != GST_STATE_CHANGE_SUCCESS) {
- gst_object_unref(GST_OBJECT(m_videoSink));
- m_videoSink = 0;
- } else {
- gst_element_set_state(m_videoSink, GST_STATE_NULL);
-
- g_object_set(G_OBJECT(m_videoSink), "force-aspect-ratio", 1, (const char*)NULL);
- }
- }
-
- if (!m_videoSink)
- m_videoSink = gst_element_factory_make ("ximagesink", NULL);
-
- gst_object_ref (GST_OBJECT (m_videoSink)); //Take ownership
- gst_object_sink (GST_OBJECT (m_videoSink));
-}
-
-GstElement *QGstreamerVideoWidgetControl::videoSink()
-{
- createVideoWidget();
- return m_videoSink;
-}
-
-bool QGstreamerVideoWidgetControl::eventFilter(QObject *object, QEvent *e)
-{
- if (m_widget && object == m_widget) {
- if (e->type() == QEvent::ParentChange || e->type() == QEvent::Show) {
- WId newWId = m_widget->winId();
- if (newWId != m_windowId) {
- m_windowId = newWId;
- // Even if we have created a winId at this point, other X applications
- // need to be aware of it.
- QApplication::syncX();
- setOverlay();
- }
- }
-
- if (e->type() == QEvent::Show) {
- // Setting these values ensures smooth resizing since it
- // will prevent the system from clearing the background
- m_widget->setAttribute(Qt::WA_NoSystemBackground, true);
- m_widget->setAttribute(Qt::WA_PaintOnScreen, true);
- } else if (e->type() == QEvent::Resize) {
- // This is a workaround for missing background repaints
- // when reducing window size
- windowExposed();
- }
- }
-
- return false;
-}
-
-void QGstreamerVideoWidgetControl::precessNewStream()
-{
- setOverlay();
- QMetaObject::invokeMethod(this, "updateNativeVideoSize", Qt::QueuedConnection);
-}
-
-void QGstreamerVideoWidgetControl::setOverlay()
-{
- if (m_videoSink && GST_IS_X_OVERLAY(m_videoSink)) {
- gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(m_videoSink), m_windowId);
- }
-}
-
-void QGstreamerVideoWidgetControl::updateNativeVideoSize()
-{
- if (m_videoSink) {
- //find video native size to update video widget size hint
- GstPad *pad = gst_element_get_static_pad(m_videoSink,"sink");
- GstCaps *caps = gst_pad_get_negotiated_caps(pad);
-
- if (caps) {
- GstStructure *str;
- gint width, height;
-
- if ((str = gst_caps_get_structure (caps, 0))) {
- if (gst_structure_get_int (str, "width", &width) && gst_structure_get_int (str, "height", &height)) {
- gint aspectNum = 0;
- gint aspectDenum = 0;
- if (gst_structure_get_fraction(str, "pixel-aspect-ratio", &aspectNum, &aspectDenum)) {
- if (aspectDenum > 0)
- width = width*aspectNum/aspectDenum;
- }
- m_widget->setNativeSize(QSize(width, height));
- }
- }
- gst_caps_unref(caps);
- }
- } else {
- if (m_widget)
- m_widget->setNativeSize(QSize());
- }
-}
-
-
-void QGstreamerVideoWidgetControl::windowExposed()
-{
- if (m_videoSink && GST_IS_X_OVERLAY(m_videoSink))
- gst_x_overlay_expose(GST_X_OVERLAY(m_videoSink));
-}
-
-QWidget *QGstreamerVideoWidgetControl::videoWidget()
-{
- createVideoWidget();
- return m_widget;
-}
-
-Qt::AspectRatioMode QGstreamerVideoWidgetControl::aspectRatioMode() const
-{
- return m_aspectRatioMode;
-}
-
-void QGstreamerVideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode mode)
-{
- if (m_videoSink) {
- g_object_set(G_OBJECT(m_videoSink),
- "force-aspect-ratio",
- (mode == Qt::KeepAspectRatio),
- (const char*)NULL);
- }
-
- m_aspectRatioMode = mode;
-}
-
-bool QGstreamerVideoWidgetControl::isFullScreen() const
-{
- return m_fullScreen;
-}
-
-void QGstreamerVideoWidgetControl::setFullScreen(bool fullScreen)
-{
- emit fullScreenChanged(m_fullScreen = fullScreen);
-}
-
-int QGstreamerVideoWidgetControl::brightness() const
-{
- int brightness = 0;
-
- if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness"))
- g_object_get(G_OBJECT(m_videoSink), "brightness", &brightness, NULL);
-
- return brightness / 10;
-}
-
-void QGstreamerVideoWidgetControl::setBrightness(int brightness)
-{
- if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness")) {
- g_object_set(G_OBJECT(m_videoSink), "brightness", brightness * 10, NULL);
-
- emit brightnessChanged(brightness);
- }
-}
-
-int QGstreamerVideoWidgetControl::contrast() const
-{
- int contrast = 0;
-
- if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast"))
- g_object_get(G_OBJECT(m_videoSink), "contrast", &contrast, NULL);
-
- return contrast / 10;
-}
-
-void QGstreamerVideoWidgetControl::setContrast(int contrast)
-{
- if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast")) {
- g_object_set(G_OBJECT(m_videoSink), "contrast", contrast * 10, NULL);
-
- emit contrastChanged(contrast);
- }
-}
-
-int QGstreamerVideoWidgetControl::hue() const
-{
- int hue = 0;
-
- if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue"))
- g_object_get(G_OBJECT(m_videoSink), "hue", &hue, NULL);
-
- return hue / 10;
-}
-
-void QGstreamerVideoWidgetControl::setHue(int hue)
-{
- if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue")) {
- g_object_set(G_OBJECT(m_videoSink), "hue", hue * 10, NULL);
-
- emit hueChanged(hue);
- }
-}
-
-int QGstreamerVideoWidgetControl::saturation() const
-{
- int saturation = 0;
-
- if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation"))
- g_object_get(G_OBJECT(m_videoSink), "saturation", &saturation, NULL);
-
- return saturation / 10;
-}
-
-void QGstreamerVideoWidgetControl::setSaturation(int saturation)
-{
- if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation")) {
- g_object_set(G_OBJECT(m_videoSink), "saturation", saturation * 10, NULL);
-
- emit saturationChanged(saturation);
- }
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h b/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h
deleted file mode 100644
index d54a1fc..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGSTREAMERVIDEOWIDGET_H
-#define QGSTREAMERVIDEOWIDGET_H
-
-#include <QtMediaServices/qvideowidgetcontrol.h>
-
-#include "qgstreamervideorendererinterface.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGstreamerVideoWidget;
-
-class QGstreamerVideoWidgetControl
- : public QVideoWidgetControl
- , public QGstreamerVideoRendererInterface
-{
- Q_OBJECT
- Q_INTERFACES(QGstreamerVideoRendererInterface)
-public:
- QGstreamerVideoWidgetControl(QObject *parent = 0);
- virtual ~QGstreamerVideoWidgetControl();
-
- GstElement *videoSink();
- void precessNewStream();
-
- QWidget *videoWidget();
-
- Qt::AspectRatioMode aspectRatioMode() const;
- void setAspectRatioMode(Qt::AspectRatioMode mode);
-
- bool isFullScreen() const;
- void setFullScreen(bool fullScreen);
-
- int brightness() const;
- void setBrightness(int brightness);
-
- int contrast() const;
- void setContrast(int contrast);
-
- int hue() const;
- void setHue(int hue);
-
- int saturation() const;
- void setSaturation(int saturation);
-
- void setOverlay();
-
- bool eventFilter(QObject *object, QEvent *event);
-
-public slots:
- void updateNativeVideoSize();
-
-private:
- void createVideoWidget();
- void windowExposed();
-
- GstElement *m_videoSink;
- QGstreamerVideoWidget *m_widget;
- WId m_windowId;
- Qt::AspectRatioMode m_aspectRatioMode;
- bool m_fullScreen;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGSTREAMERVIDEOWIDGET_H
diff --git a/src/plugins/mediaservices/gstreamer/qgstvideobuffer.cpp b/src/plugins/mediaservices/gstreamer/qgstvideobuffer.cpp
deleted file mode 100644
index 76289bf..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstvideobuffer.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgstvideobuffer.h"
-
-
-QT_BEGIN_NAMESPACE
-
-QGstVideoBuffer::QGstVideoBuffer(GstBuffer *buffer, int bytesPerLine)
- : QAbstractVideoBuffer(NoHandle)
- , m_buffer(buffer)
- , m_bytesPerLine(bytesPerLine)
- , m_mode(NotMapped)
-{
- gst_buffer_ref(m_buffer);
-}
-
-QGstVideoBuffer::QGstVideoBuffer(GstBuffer *buffer, int bytesPerLine,
- QGstVideoBuffer::HandleType handleType,
- const QVariant &handle)
- : QAbstractVideoBuffer(handleType)
- , m_buffer(buffer)
- , m_bytesPerLine(bytesPerLine)
- , m_mode(NotMapped)
- , m_handle(handle)
-{
- gst_buffer_ref(m_buffer);
-}
-
-QGstVideoBuffer::~QGstVideoBuffer()
-{
- gst_buffer_unref(m_buffer);
-}
-
-
-QAbstractVideoBuffer::MapMode QGstVideoBuffer::mapMode() const
-{
- return m_mode;
-}
-
-uchar *QGstVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine)
-{
- if (mode != NotMapped && m_mode == NotMapped) {
- if (numBytes)
- *numBytes = m_buffer->size;
-
- if (bytesPerLine)
- *bytesPerLine = m_bytesPerLine;
-
- m_mode = mode;
-
- return m_buffer->data;
- } else {
- return 0;
- }
-}
-void QGstVideoBuffer::unmap()
-{
- m_mode = NotMapped;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/plugins/mediaservices/gstreamer/qgstvideobuffer.h b/src/plugins/mediaservices/gstreamer/qgstvideobuffer.h
deleted file mode 100644
index 5133e2e..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstvideobuffer.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGSTVIDEOBUFFER_H
-#define QGSTVIDEOBUFFER_H
-
-#include <QtMultimedia/QAbstractVideoBuffer>
-#include <QtCore/qvariant.h>
-
-#include <gst/gst.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGstVideoBuffer : public QAbstractVideoBuffer
-{
-public:
- QGstVideoBuffer(GstBuffer *buffer, int bytesPerLine);
- QGstVideoBuffer(GstBuffer *buffer, int bytesPerLine,
- HandleType handleType, const QVariant &handle);
- ~QGstVideoBuffer();
-
- MapMode mapMode() const;
-
- uchar *map(MapMode mode, int *numBytes, int *bytesPerLine);
- void unmap();
-
- QVariant handle() const { return m_handle; }
-private:
- GstBuffer *m_buffer;
- int m_bytesPerLine;
- MapMode m_mode;
- QVariant m_handle;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.cpp b/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.cpp
deleted file mode 100644
index b2e633d..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qthread.h>
-#include <QtCore/qvariant.h>
-#include <QtGui/qx11info_x11.h>
-
-#include "qgstxvimagebuffer.h"
-#include "qvideosurfacegstsink.h"
-
-
-QT_BEGIN_NAMESPACE
-
-GstBufferClass *QGstXvImageBuffer::parent_class = NULL;
-
-GType QGstXvImageBuffer::get_type(void)
-{
- static GType buffer_type = 0;
-
- if (buffer_type == 0) {
- static const GTypeInfo buffer_info = {
- sizeof (GstBufferClass),
- NULL,
- NULL,
- QGstXvImageBuffer::class_init,
- NULL,
- NULL,
- sizeof(QGstXvImageBuffer),
- 0,
- (GInstanceInitFunc)QGstXvImageBuffer::buffer_init,
- NULL
- };
- buffer_type = g_type_register_static(GST_TYPE_BUFFER,
- "QGstXvImageBuffer", &buffer_info, GTypeFlags(0));
- }
- return buffer_type;
-}
-
-void QGstXvImageBuffer::class_init(gpointer g_class, gpointer class_data)
-{
- Q_UNUSED(class_data);
- GST_MINI_OBJECT_CLASS(g_class)->finalize =
- (GstMiniObjectFinalizeFunction)buffer_finalize;
- parent_class = (GstBufferClass*)g_type_class_peek_parent(g_class);
-}
-
-void QGstXvImageBuffer::buffer_init(QGstXvImageBuffer *xvImage, gpointer g_class)
-{
- Q_UNUSED(g_class);
- xvImage->pool = 0;
- xvImage->shmInfo.shmaddr = ((char *) -1);
- xvImage->shmInfo.shmid = -1;
- xvImage->markedForDeletion = false;
-}
-
-void QGstXvImageBuffer::buffer_finalize(QGstXvImageBuffer * xvImage)
-{
- if (xvImage->pool) {
- if (xvImage->markedForDeletion)
- xvImage->pool->destroyBuffer(xvImage);
- else
- xvImage->pool->recycleBuffer(xvImage);
- }
-}
-
-
-QGstXvImageBufferPool::QGstXvImageBufferPool(QObject *parent)
- :QObject(parent)
-{
-}
-
-QGstXvImageBufferPool::~QGstXvImageBufferPool()
-{
-}
-
-bool QGstXvImageBufferPool::isFormatSupported(const QVideoSurfaceFormat &surfaceFormat)
-{
- bool ok = true;
- surfaceFormat.property("portId").toULongLong(&ok);
- if (!ok)
- return false;
-
- int xvFormatId = surfaceFormat.property("xvFormatId").toInt(&ok);
- if (!ok || xvFormatId < 0)
- return false;
-
- int dataSize = surfaceFormat.property("dataSize").toInt(&ok);
- if (!ok || dataSize<=0)
- return false;
-
- return true;
-}
-
-QGstXvImageBuffer *QGstXvImageBufferPool::takeBuffer(const QVideoSurfaceFormat &format, GstCaps *caps)
-{
- m_poolMutex.lock();
-
- m_caps = caps;
- if (format != m_format) {
- doClear();
- m_format = format;
- }
-
-
- if (m_pool.isEmpty()) {
- //qDebug() << "QGstXvImageBufferPool::takeBuffer: no buffer available, allocate the new one";
- if (QThread::currentThread() == thread()) {
- m_poolMutex.unlock();
- queuedAlloc();
- m_poolMutex.lock();
- } else {
- QMetaObject::invokeMethod(this, "queuedAlloc", Qt::QueuedConnection);
- m_allocWaitCondition.wait(&m_poolMutex, 300);
- }
- }
- QGstXvImageBuffer *res = 0;
-
- if (!m_pool.isEmpty()) {
- res = m_pool.takeLast();
- }
-
- m_poolMutex.unlock();
-
- return res;
-}
-
-void QGstXvImageBufferPool::queuedAlloc()
-{
- QMutexLocker lock(&m_poolMutex);
-
- Q_ASSERT(QThread::currentThread() == thread());
-
- QGstXvImageBuffer *xvBuffer = (QGstXvImageBuffer *)gst_mini_object_new(QGstXvImageBuffer::get_type());
-
- quint64 portId = m_format.property("portId").toULongLong();
- int xvFormatId = m_format.property("xvFormatId").toInt();
-
- xvBuffer->xvImage = XvShmCreateImage(
- QX11Info::display(),
- portId,
- xvFormatId,
- 0,
- m_format.frameWidth(),
- m_format.frameHeight(),
- &xvBuffer->shmInfo
- );
-
- if (!xvBuffer->xvImage) {
-// qDebug() << "QGstXvImageBufferPool: XvShmCreateImage failed";
- m_allocWaitCondition.wakeOne();
- return;
- }
-
- xvBuffer->shmInfo.shmid = shmget(IPC_PRIVATE, xvBuffer->xvImage->data_size, IPC_CREAT | 0777);
- xvBuffer->shmInfo.shmaddr = xvBuffer->xvImage->data = (char*)shmat(xvBuffer->shmInfo.shmid, 0, 0);
- xvBuffer->shmInfo.readOnly = False;
-
- if (!XShmAttach(QX11Info::display(), &xvBuffer->shmInfo)) {
-// qDebug() << "QGstXvImageBufferPool: XShmAttach failed";
- m_allocWaitCondition.wakeOne();
- return;
- }
-
- shmctl (xvBuffer->shmInfo.shmid, IPC_RMID, NULL);
-
- xvBuffer->pool = this;
- GST_MINI_OBJECT_CAST(xvBuffer)->flags = 0;
- gst_buffer_set_caps(GST_BUFFER_CAST(xvBuffer), m_caps);
- GST_BUFFER_DATA(xvBuffer) = (uchar*)xvBuffer->xvImage->data;
- GST_BUFFER_SIZE(xvBuffer) = xvBuffer->xvImage->data_size;
-
- m_allBuffers.append(xvBuffer);
- m_pool.append(xvBuffer);
-
- m_allocWaitCondition.wakeOne();
-}
-
-
-void QGstXvImageBufferPool::clear()
-{
- QMutexLocker lock(&m_poolMutex);
- doClear();
-}
-
-void QGstXvImageBufferPool::doClear()
-{
- foreach (QGstXvImageBuffer *xvBuffer, m_allBuffers) {
- xvBuffer->markedForDeletion = true;
- }
- m_allBuffers.clear();
-
- foreach (QGstXvImageBuffer *xvBuffer, m_pool) {
- gst_buffer_unref(GST_BUFFER(xvBuffer));
- }
- m_pool.clear();
-
- m_format = QVideoSurfaceFormat();
-}
-
-void QGstXvImageBufferPool::queuedDestroy()
-{
- QMutexLocker lock(&m_destroyMutex);
-
- foreach(XvShmImage xvImage, m_imagesToDestroy) {
- if (xvImage.shmInfo.shmaddr != ((void *) -1)) {
- XShmDetach(QX11Info::display(), &xvImage.shmInfo);
- XSync(QX11Info::display(), false);
-
- shmdt(xvImage.shmInfo.shmaddr);
- }
-
- if (xvImage.xvImage)
- XFree(xvImage.xvImage);
- }
-
- m_imagesToDestroy.clear();
-
- XSync(QX11Info::display(), false);
-}
-
-void QGstXvImageBufferPool::recycleBuffer(QGstXvImageBuffer *xvBuffer)
-{
- QMutexLocker lock(&m_poolMutex);
- gst_buffer_ref(GST_BUFFER_CAST(xvBuffer));
- m_pool.append(xvBuffer);
-}
-
-void QGstXvImageBufferPool::destroyBuffer(QGstXvImageBuffer *xvBuffer)
-{
- XvShmImage imageToDestroy;
- imageToDestroy.xvImage = xvBuffer->xvImage;
- imageToDestroy.shmInfo = xvBuffer->shmInfo;
-
- m_destroyMutex.lock();
- m_imagesToDestroy.append(imageToDestroy);
- m_destroyMutex.unlock();
-
- if (m_imagesToDestroy.size() == 1)
- QMetaObject::invokeMethod(this, "queuedDestroy", Qt::QueuedConnection);
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.h b/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.h
deleted file mode 100644
index 30f77d1..0000000
--- a/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGSTXVIMAGEBUFFER_H
-#define QGSTXVIMAGEBUFFER_H
-
-#include <QtMultimedia/qabstractvideobuffer.h>
-#include <QtMultimedia/qvideosurfaceformat.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qwaitcondition.h>
-#include <QtCore/qqueue.h>
-
-#include <X11/Xlib.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <X11/extensions/XShm.h>
-#include <X11/Xlib.h>
-#include <X11/extensions/Xv.h>
-#include <X11/extensions/Xvlib.h>
-
-#include <gst/gst.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGstXvImageBufferPool;
-
-struct QGstXvImageBuffer {
- GstBuffer buffer;
- QGstXvImageBufferPool *pool;
- XvImage *xvImage;
- XShmSegmentInfo shmInfo;
- bool markedForDeletion;
-
- static GType get_type(void);
- static void class_init(gpointer g_class, gpointer class_data);
- static void buffer_init(QGstXvImageBuffer *xvimage, gpointer g_class);
- static void buffer_finalize(QGstXvImageBuffer * xvimage);
- static GstBufferClass *parent_class;
-};
-
-const QAbstractVideoBuffer::HandleType XvHandleType = QAbstractVideoBuffer::HandleType(4);
-
-
-
-class QGstXvImageBufferPool : public QObject {
-Q_OBJECT
-friend class QGstXvImageBuffer;
-public:
- QGstXvImageBufferPool(QObject *parent = 0);
- virtual ~QGstXvImageBufferPool();
-
- bool isFormatSupported(const QVideoSurfaceFormat &format);
-
- QGstXvImageBuffer *takeBuffer(const QVideoSurfaceFormat &format, GstCaps *caps);
- void clear();
-
-private slots:
- void queuedAlloc();
- void queuedDestroy();
-
- void doClear();
-
- void recycleBuffer(QGstXvImageBuffer *);
- void destroyBuffer(QGstXvImageBuffer *);
-
-private:
- struct XvShmImage {
- XvImage *xvImage;
- XShmSegmentInfo shmInfo;
- };
-
- QMutex m_poolMutex;
- QMutex m_allocMutex;
- QWaitCondition m_allocWaitCondition;
- QMutex m_destroyMutex;
- QVideoSurfaceFormat m_format;
- GstCaps *m_caps;
- QList<QGstXvImageBuffer*> m_pool;
- QList<QGstXvImageBuffer*> m_allBuffers;
- QList<XvShmImage> m_imagesToDestroy;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(::XvImage*)
-
-QT_END_HEADER
-
-
-#endif
diff --git a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp b/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp
deleted file mode 100644
index 596e39d..0000000
--- a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp
+++ /dev/null
@@ -1,713 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtMultimedia/QAbstractVideoSurface>
-#include <QtMultimedia/QVideoFrame>
-#include <QtCore/qdebug.h>
-#include <QMap>
-#include <QThread>
-
-#include "qgstvideobuffer.h"
-
-#ifdef Q_WS_X11
-#include <QtGui/qx11info_x11.h>
-#include "qgstxvimagebuffer.h"
-#endif
-
-#include "qvideosurfacegstsink.h"
-
-
-
-
-Q_DECLARE_METATYPE(QVideoSurfaceFormat)
-
-QT_BEGIN_NAMESPACE
-
-QVideoSurfaceGstDelegate::QVideoSurfaceGstDelegate(QAbstractVideoSurface *surface)
- : m_surface(surface)
- , m_renderReturn(GST_FLOW_ERROR)
- , m_bytesPerLine(0)
-{
- m_supportedPixelFormats = m_surface->supportedPixelFormats();
-
- connect(m_surface, SIGNAL(supportedFormatsChanged()), this, SLOT(supportedFormatsChanged()));
-}
-
-QList<QVideoFrame::PixelFormat> QVideoSurfaceGstDelegate::supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const
-{
- QMutexLocker locker(const_cast<QMutex *>(&m_mutex));
-
- if (handleType == QAbstractVideoBuffer::NoHandle)
- return m_supportedPixelFormats;
- else
- return m_surface->supportedPixelFormats(handleType);
-}
-
-QVideoSurfaceFormat QVideoSurfaceGstDelegate::surfaceFormat() const
-{
- QMutexLocker locker(const_cast<QMutex *>(&m_mutex));
- return m_format;
-}
-
-bool QVideoSurfaceGstDelegate::start(const QVideoSurfaceFormat &format, int bytesPerLine)
-{
- QMutexLocker locker(&m_mutex);
-
- m_format = format;
- m_bytesPerLine = bytesPerLine;
-
- if (QThread::currentThread() == thread()) {
- m_started = !m_surface.isNull() ? m_surface->start(m_format) : false;
- } else {
- QMetaObject::invokeMethod(this, "queuedStart", Qt::QueuedConnection);
-
- m_setupCondition.wait(&m_mutex);
- }
-
- m_format = m_surface->surfaceFormat();
-
- return m_started;
-}
-
-void QVideoSurfaceGstDelegate::stop()
-{
- QMutexLocker locker(&m_mutex);
-
- if (QThread::currentThread() == thread()) {
- if (!m_surface.isNull())
- m_surface->stop();
- } else {
- QMetaObject::invokeMethod(this, "queuedStop", Qt::QueuedConnection);
-
- m_setupCondition.wait(&m_mutex);
- }
-
- m_started = false;
-}
-
-bool QVideoSurfaceGstDelegate::isActive()
-{
- QMutexLocker locker(&m_mutex);
- return m_surface->isActive();
-}
-
-GstFlowReturn QVideoSurfaceGstDelegate::render(GstBuffer *buffer)
-{
- QMutexLocker locker(&m_mutex);
-
- QGstVideoBuffer *videoBuffer = 0;
-
-#ifdef Q_WS_X11
- if (G_TYPE_CHECK_INSTANCE_TYPE(buffer, QGstXvImageBuffer::get_type())) {
- QGstXvImageBuffer *xvBuffer = reinterpret_cast<QGstXvImageBuffer *>(buffer);
- QVariant handle = QVariant::fromValue(xvBuffer->xvImage);
- videoBuffer = new QGstVideoBuffer(buffer, m_bytesPerLine, XvHandleType, handle);
- } else
-#endif
- videoBuffer = new QGstVideoBuffer(buffer, m_bytesPerLine);
-
- m_frame = QVideoFrame(
- videoBuffer,
- m_format.frameSize(),
- m_format.pixelFormat());
-
- qint64 startTime = GST_BUFFER_TIMESTAMP(buffer);
-
- if (startTime >= 0) {
- m_frame.setStartTime(startTime/G_GINT64_CONSTANT (1000000));
-
- qint64 duration = GST_BUFFER_DURATION(buffer);
-
- if (duration >= 0)
- m_frame.setEndTime((startTime + duration)/G_GINT64_CONSTANT (1000000));
- }
-
- QMetaObject::invokeMethod(this, "queuedRender", Qt::QueuedConnection);
-
- if (!m_renderCondition.wait(&m_mutex, 300)) {
- m_frame = QVideoFrame();
-
- return GST_FLOW_OK;
- } else {
- return m_renderReturn;
- }
-}
-
-void QVideoSurfaceGstDelegate::queuedStart()
-{
- QMutexLocker locker(&m_mutex);
-
- m_started = m_surface->start(m_format);
-
- m_setupCondition.wakeAll();
-}
-
-void QVideoSurfaceGstDelegate::queuedStop()
-{
- QMutexLocker locker(&m_mutex);
-
- m_surface->stop();
-
- m_setupCondition.wakeAll();
-}
-
-void QVideoSurfaceGstDelegate::queuedRender()
-{
- QMutexLocker locker(&m_mutex);
-
- if (m_surface.isNull()) {
- m_renderReturn = GST_FLOW_ERROR;
- } else if (m_surface->present(m_frame)) {
- m_renderReturn = GST_FLOW_OK;
- } else {
- switch (m_surface->error()) {
- case QAbstractVideoSurface::NoError:
- m_renderReturn = GST_FLOW_OK;
- break;
- case QAbstractVideoSurface::StoppedError:
- m_renderReturn = GST_FLOW_NOT_NEGOTIATED;
- break;
- default:
- m_renderReturn = GST_FLOW_ERROR;
- break;
- }
- }
-
- m_renderCondition.wakeAll();
-}
-
-void QVideoSurfaceGstDelegate::supportedFormatsChanged()
-{
- QMutexLocker locker(&m_mutex);
-
- m_supportedPixelFormats = m_surface->supportedPixelFormats();
-}
-
-struct YuvFormat
-{
- QVideoFrame::PixelFormat pixelFormat;
- guint32 fourcc;
- int bitsPerPixel;
-};
-
-static const YuvFormat qt_yuvColorLookup[] =
-{
- { QVideoFrame::Format_YUV420P, GST_MAKE_FOURCC('I','4','2','0'), 8 },
- { QVideoFrame::Format_YV12, GST_MAKE_FOURCC('Y','V','1','2'), 8 },
- { QVideoFrame::Format_UYVY, GST_MAKE_FOURCC('U','Y','V','Y'), 16 },
- { QVideoFrame::Format_YUYV, GST_MAKE_FOURCC('Y','U','Y','2'), 16 },
- { QVideoFrame::Format_NV12, GST_MAKE_FOURCC('N','V','1','2'), 8 },
- { QVideoFrame::Format_NV21, GST_MAKE_FOURCC('N','V','2','1'), 8 },
- { QVideoFrame::Format_AYUV444, GST_MAKE_FOURCC('A','Y','U','V'), 32 }
-};
-
-static int indexOfYuvColor(QVideoFrame::PixelFormat format)
-{
- const int count = sizeof(qt_yuvColorLookup) / sizeof(YuvFormat);
-
- for (int i = 0; i < count; ++i)
- if (qt_yuvColorLookup[i].pixelFormat == format)
- return i;
-
- return -1;
-}
-
-static int indexOfYuvColor(guint32 fourcc)
-{
- const int count = sizeof(qt_yuvColorLookup) / sizeof(YuvFormat);
-
- for (int i = 0; i < count; ++i)
- if (qt_yuvColorLookup[i].fourcc == fourcc)
- return i;
-
- return -1;
-}
-
-struct RgbFormat
-{
- QVideoFrame::PixelFormat pixelFormat;
- int bitsPerPixel;
- int depth;
- int endianness;
- int red;
- int green;
- int blue;
- int alpha;
-};
-
-static const RgbFormat qt_rgbColorLookup[] =
-{
- { QVideoFrame::Format_RGB32 , 32, 24, 4321, 0x0000FF00, 0x00FF0000, 0xFF000000, 0x00000000 },
- { QVideoFrame::Format_RGB32 , 32, 24, 1234, 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 },
- { QVideoFrame::Format_BGR32 , 32, 24, 4321, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x00000000 },
- { QVideoFrame::Format_BGR32 , 32, 24, 1234, 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 },
- { QVideoFrame::Format_ARGB32, 32, 24, 4321, 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF },
- { QVideoFrame::Format_ARGB32, 32, 24, 1234, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 },
- { QVideoFrame::Format_RGB24 , 24, 24, 4321, 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 },
- { QVideoFrame::Format_BGR24 , 24, 24, 4321, 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 },
- { QVideoFrame::Format_RGB565, 16, 16, 1234, 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }
-};
-
-static int indexOfRgbColor(
- int bits, int depth, int endianness, int red, int green, int blue, int alpha)
-{
- const int count = sizeof(qt_rgbColorLookup) / sizeof(RgbFormat);
-
- for (int i = 0; i < count; ++i) {
- if (qt_rgbColorLookup[i].bitsPerPixel == bits
- && qt_rgbColorLookup[i].depth == depth
- && qt_rgbColorLookup[i].endianness == endianness
- && qt_rgbColorLookup[i].red == red
- && qt_rgbColorLookup[i].green == green
- && qt_rgbColorLookup[i].blue == blue
- && qt_rgbColorLookup[i].alpha == alpha) {
- return i;
- }
- }
- return -1;
-}
-
-static GstVideoSinkClass *sink_parent_class;
-
-#define VO_SINK(s) QVideoSurfaceGstSink *sink(reinterpret_cast<QVideoSurfaceGstSink *>(s))
-
-QVideoSurfaceGstSink *QVideoSurfaceGstSink::createSink(QAbstractVideoSurface *surface)
-{
- QVideoSurfaceGstSink *sink = reinterpret_cast<QVideoSurfaceGstSink *>(
- g_object_new(QVideoSurfaceGstSink::get_type(), 0));
-
- sink->delegate = new QVideoSurfaceGstDelegate(surface);
-
- return sink;
-}
-
-GType QVideoSurfaceGstSink::get_type()
-{
- static GType type = 0;
-
- if (type == 0) {
- static const GTypeInfo info =
- {
- sizeof(QVideoSurfaceGstSinkClass), // class_size
- base_init, // base_init
- NULL, // base_finalize
- class_init, // class_init
- NULL, // class_finalize
- NULL, // class_data
- sizeof(QVideoSurfaceGstSink), // instance_size
- 0, // n_preallocs
- instance_init, // instance_init
- 0 // value_table
- };
-
- type = g_type_register_static(
- GST_TYPE_VIDEO_SINK, "QVideoSurfaceGstSink", &info, GTypeFlags(0));
- }
-
- return type;
-}
-
-void QVideoSurfaceGstSink::class_init(gpointer g_class, gpointer class_data)
-{
- Q_UNUSED(class_data);
-
- sink_parent_class = reinterpret_cast<GstVideoSinkClass *>(g_type_class_peek_parent(g_class));
-
- GstBaseSinkClass *base_sink_class = reinterpret_cast<GstBaseSinkClass *>(g_class);
- base_sink_class->get_caps = QVideoSurfaceGstSink::get_caps;
- base_sink_class->set_caps = QVideoSurfaceGstSink::set_caps;
- base_sink_class->buffer_alloc = QVideoSurfaceGstSink::buffer_alloc;
- base_sink_class->start = QVideoSurfaceGstSink::start;
- base_sink_class->stop = QVideoSurfaceGstSink::stop;
- // base_sink_class->unlock = QVideoSurfaceGstSink::unlock; // Not implemented.
- // base_sink_class->event = QVideoSurfaceGstSink::event; // Not implemented.
- base_sink_class->preroll = QVideoSurfaceGstSink::preroll;
- base_sink_class->render = QVideoSurfaceGstSink::render;
-
- GstElementClass *element_class = reinterpret_cast<GstElementClass *>(g_class);
- element_class->change_state = QVideoSurfaceGstSink::change_state;
-
- GObjectClass *object_class = reinterpret_cast<GObjectClass *>(g_class);
- object_class->finalize = QVideoSurfaceGstSink::finalize;
-}
-
-void QVideoSurfaceGstSink::base_init(gpointer g_class)
-{
- static GstStaticPadTemplate sink_pad_template = GST_STATIC_PAD_TEMPLATE(
- "sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS(
- "video/x-raw-rgb, "
- "framerate = (fraction) [ 0, MAX ], "
- "width = (int) [ 1, MAX ], "
- "height = (int) [ 1, MAX ]; "
- "video/x-raw-yuv, "
- "framerate = (fraction) [ 0, MAX ], "
- "width = (int) [ 1, MAX ], "
- "height = (int) [ 1, MAX ]"));
-
- gst_element_class_add_pad_template(
- GST_ELEMENT_CLASS(g_class), gst_static_pad_template_get(&sink_pad_template));
-}
-
-void QVideoSurfaceGstSink::instance_init(GTypeInstance *instance, gpointer g_class)
-{
- VO_SINK(instance);
-
- Q_UNUSED(g_class);
-
- sink->delegate = 0;
-#ifdef Q_WS_X11
- sink->pool = new QGstXvImageBufferPool();
-#endif
- sink->lastRequestedCaps = 0;
- sink->lastBufferCaps = 0;
- sink->lastSurfaceFormat = new QVideoSurfaceFormat;
-}
-
-void QVideoSurfaceGstSink::finalize(GObject *object)
-{
- VO_SINK(object);
-#ifdef Q_WS_X11
- delete sink->pool;
- sink->pool = 0;
-#endif
-
- delete sink->lastSurfaceFormat;
- sink->lastSurfaceFormat = 0;
-
- if (sink->lastBufferCaps)
- gst_caps_unref(sink->lastBufferCaps);
- sink->lastBufferCaps = 0;
-
- if (sink->lastRequestedCaps)
- gst_caps_unref(sink->lastRequestedCaps);
- sink->lastRequestedCaps = 0;
-}
-
-GstStateChangeReturn QVideoSurfaceGstSink::change_state(
- GstElement *element, GstStateChange transition)
-{
- Q_UNUSED(element);
-
- return GST_ELEMENT_CLASS(sink_parent_class)->change_state(
- element, transition);
-}
-
-GstCaps *QVideoSurfaceGstSink::get_caps(GstBaseSink *base)
-{
- VO_SINK(base);
-
- GstCaps *caps = gst_caps_new_empty();
-
- foreach (QVideoFrame::PixelFormat format, sink->delegate->supportedPixelFormats()) {
- int index = indexOfYuvColor(format);
-
- if (index != -1) {
- gst_caps_append_structure(caps, gst_structure_new(
- "video/x-raw-yuv",
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, INT_MAX, 1,
- "width" , GST_TYPE_INT_RANGE, 1, INT_MAX,
- "height" , GST_TYPE_INT_RANGE, 1, INT_MAX,
- "format" , GST_TYPE_FOURCC, qt_yuvColorLookup[index].fourcc,
- NULL));
- continue;
- }
-
- const int count = sizeof(qt_rgbColorLookup) / sizeof(RgbFormat);
-
- for (int i = 0; i < count; ++i) {
- if (qt_rgbColorLookup[i].pixelFormat == format) {
- GstStructure *structure = gst_structure_new(
- "video/x-raw-rgb",
- "framerate" , GST_TYPE_FRACTION_RANGE, 0, 1, INT_MAX, 1,
- "width" , GST_TYPE_INT_RANGE, 1, INT_MAX,
- "height" , GST_TYPE_INT_RANGE, 1, INT_MAX,
- "bpp" , G_TYPE_INT, qt_rgbColorLookup[i].bitsPerPixel,
- "depth" , G_TYPE_INT, qt_rgbColorLookup[i].depth,
- "endianness", G_TYPE_INT, qt_rgbColorLookup[i].endianness,
- "red_mask" , G_TYPE_INT, qt_rgbColorLookup[i].red,
- "green_mask", G_TYPE_INT, qt_rgbColorLookup[i].green,
- "blue_mask" , G_TYPE_INT, qt_rgbColorLookup[i].blue,
- NULL);
-
- if (qt_rgbColorLookup[i].alpha != 0) {
- gst_structure_set(
- structure, "alpha_mask", G_TYPE_INT, qt_rgbColorLookup[i].alpha, NULL);
- }
- gst_caps_append_structure(caps, structure);
- }
- }
- }
-
- return caps;
-}
-
-gboolean QVideoSurfaceGstSink::set_caps(GstBaseSink *base, GstCaps *caps)
-{
- VO_SINK(base);
-
- //qDebug() << "set_caps";
- //qDebug() << gst_caps_to_string(caps);
-
- if (!caps) {
- sink->delegate->stop();
-
- return TRUE;
- } else {
- int bytesPerLine = 0;
- QVideoSurfaceFormat format = formatForCaps(caps, &bytesPerLine);
-
- if (sink->delegate->isActive()) {
- QVideoSurfaceFormat surfaceFormst = sink->delegate->surfaceFormat();
-
- if (format.pixelFormat() == surfaceFormst.pixelFormat() &&
- format.frameSize() == surfaceFormst.frameSize())
- return TRUE;
- else
- sink->delegate->stop();
- }
-
- if (sink->lastRequestedCaps)
- gst_caps_unref(sink->lastRequestedCaps);
- sink->lastRequestedCaps = 0;
-
- //qDebug() << "Staring video surface:";
- //qDebug() << format;
- //qDebug() << bytesPerLine;
-
- if (sink->delegate->start(format, bytesPerLine))
- return TRUE;
-
- }
-
- return FALSE;
-}
-
-QVideoSurfaceFormat QVideoSurfaceGstSink::formatForCaps(GstCaps *caps, int *bytesPerLine)
-{
- const GstStructure *structure = gst_caps_get_structure(caps, 0);
-
- QVideoFrame::PixelFormat pixelFormat = QVideoFrame::Format_Invalid;
- int bitsPerPixel = 0;
-
- QSize size;
- gst_structure_get_int(structure, "width", &size.rwidth());
- gst_structure_get_int(structure, "height", &size.rheight());
-
- if (qstrcmp(gst_structure_get_name(structure), "video/x-raw-yuv") == 0) {
- guint32 fourcc = 0;
- gst_structure_get_fourcc(structure, "format", &fourcc);
-
- int index = indexOfYuvColor(fourcc);
- if (index != -1) {
- pixelFormat = qt_yuvColorLookup[index].pixelFormat;
- bitsPerPixel = qt_yuvColorLookup[index].bitsPerPixel;
- }
- } else if (qstrcmp(gst_structure_get_name(structure), "video/x-raw-rgb") == 0) {
- int depth = 0;
- int endianness = 0;
- int red = 0;
- int green = 0;
- int blue = 0;
- int alpha = 0;
-
- gst_structure_get_int(structure, "bpp", &bitsPerPixel);
- gst_structure_get_int(structure, "depth", &depth);
- gst_structure_get_int(structure, "endianness", &endianness);
- gst_structure_get_int(structure, "red_mask", &red);
- gst_structure_get_int(structure, "green_mask", &green);
- gst_structure_get_int(structure, "blue_mask", &blue);
- gst_structure_get_int(structure, "alpha_mask", &alpha);
-
- int index = indexOfRgbColor(bitsPerPixel, depth, endianness, red, green, blue, alpha);
-
- if (index != -1)
- pixelFormat = qt_rgbColorLookup[index].pixelFormat;
- }
-
- if (pixelFormat != QVideoFrame::Format_Invalid) {
- QVideoSurfaceFormat format(size, pixelFormat);
-
- QPair<int, int> rate;
- gst_structure_get_fraction(structure, "framerate", &rate.first, &rate.second);
-
- if (rate.second)
- format.setFrameRate(qreal(rate.first)/rate.second);
-
- gint aspectNum = 0;
- gint aspectDenum = 0;
- if (gst_structure_get_fraction(
- structure, "pixel-aspect-ratio", &aspectNum, &aspectDenum)) {
- if (aspectDenum > 0)
- format.setPixelAspectRatio(aspectNum, aspectDenum);
- }
-
- if (bytesPerLine)
- *bytesPerLine = ((size.width() * bitsPerPixel / 8) + 3) & ~3;
-
- return format;
- }
-
- return QVideoSurfaceFormat();
-}
-
-
-GstFlowReturn QVideoSurfaceGstSink::buffer_alloc(
- GstBaseSink *base, guint64 offset, guint size, GstCaps *caps, GstBuffer **buffer)
-{
- VO_SINK(base);
-
- Q_UNUSED(offset);
- Q_UNUSED(size);
-
- *buffer = 0;
-
-#ifdef Q_WS_X11
-
- if (sink->lastRequestedCaps && gst_caps_is_equal(sink->lastRequestedCaps, caps)) {
- //qDebug() << "reusing last caps";
- *buffer = GST_BUFFER(sink->pool->takeBuffer(*sink->lastSurfaceFormat, sink->lastBufferCaps));
- return GST_FLOW_OK;
- }
-
- if (sink->delegate->supportedPixelFormats(XvHandleType).isEmpty()) {
- //qDebug() << "sink doesn't support Xv buffers, skip buffers allocation";
- return GST_FLOW_OK;
- }
-
- GstCaps *intersection = gst_caps_intersect(get_caps(GST_BASE_SINK(sink)), caps);
-
- if (gst_caps_is_empty (intersection)) {
- gst_caps_unref(intersection);
- return GST_FLOW_NOT_NEGOTIATED;
- }
-
- if (sink->delegate->isActive()) {
- //if format was changed, restart the surface
- QVideoSurfaceFormat format = formatForCaps(intersection);
- QVideoSurfaceFormat surfaceFormat = sink->delegate->surfaceFormat();
-
- if (format.pixelFormat() != surfaceFormat.pixelFormat() ||
- format.frameSize() != surfaceFormat.frameSize()) {
- //qDebug() << "new format requested, restart video surface";
- sink->delegate->stop();
- }
- }
-
- if (!sink->delegate->isActive()) {
- int bytesPerLine = 0;
- QVideoSurfaceFormat format = formatForCaps(intersection, &bytesPerLine);
-
- if (!sink->delegate->start(format, bytesPerLine)) {
- qDebug() << "failed to start video surface";
- return GST_FLOW_NOT_NEGOTIATED;
- }
- }
-
- QVideoSurfaceFormat surfaceFormat = sink->delegate->surfaceFormat();
-
- if (!sink->pool->isFormatSupported(surfaceFormat)) {
- //qDebug() << "sink doesn't provide Xv buffer details, skip buffers allocation";
- return GST_FLOW_OK;
- }
-
- if (sink->lastRequestedCaps)
- gst_caps_unref(sink->lastRequestedCaps);
- sink->lastRequestedCaps = caps;
- gst_caps_ref(sink->lastRequestedCaps);
-
- if (sink->lastBufferCaps)
- gst_caps_unref(sink->lastBufferCaps);
- sink->lastBufferCaps = intersection;
- gst_caps_ref(sink->lastBufferCaps);
-
- *sink->lastSurfaceFormat = surfaceFormat;
-
- *buffer = GST_BUFFER(sink->pool->takeBuffer(surfaceFormat, intersection));
-
-#endif
- return GST_FLOW_OK;
-}
-
-gboolean QVideoSurfaceGstSink::start(GstBaseSink *base)
-{
- Q_UNUSED(base);
-
- return TRUE;
-}
-
-gboolean QVideoSurfaceGstSink::stop(GstBaseSink *base)
-{
- Q_UNUSED(base);
-
- return TRUE;
-}
-
-gboolean QVideoSurfaceGstSink::unlock(GstBaseSink *base)
-{
- Q_UNUSED(base);
-
- return TRUE;
-}
-
-gboolean QVideoSurfaceGstSink::event(GstBaseSink *base, GstEvent *event)
-{
- Q_UNUSED(base);
- Q_UNUSED(event);
-
- return TRUE;
-}
-
-GstFlowReturn QVideoSurfaceGstSink::preroll(GstBaseSink *base, GstBuffer *buffer)
-{
- VO_SINK(base);
-
- return sink->delegate->render(buffer);
-}
-
-GstFlowReturn QVideoSurfaceGstSink::render(GstBaseSink *base, GstBuffer *buffer)
-{
- VO_SINK(base);
- return sink->delegate->render(buffer);
-}
-
-QT_END_NAMESPACE
-
-
diff --git a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.h b/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.h
deleted file mode 100644
index 75fa854..0000000
--- a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef VIDEOSURFACEGSTSINK_H
-#define VIDEOSURFACEGSTSINK_H
-
-#include <gst/video/gstvideosink.h>
-
-#include <QtCore/qlist.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qpointer.h>
-#include <QtCore/qwaitcondition.h>
-#include <QtMultimedia/qvideosurfaceformat.h>
-#include <QtMultimedia/qvideoframe.h>
-#include <QtMultimedia/qabstractvideobuffer.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QAbstractVideoSurface;
-
-#ifdef Q_WS_X11
-class QGstXvImageBuffer;
-class QGstXvImageBufferPool;
-#endif
-
-
-class QVideoSurfaceGstDelegate : public QObject
-{
- Q_OBJECT
-public:
- QVideoSurfaceGstDelegate(QAbstractVideoSurface *surface);
-
- QList<QVideoFrame::PixelFormat> supportedPixelFormats(
- QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const;
-
- QVideoSurfaceFormat surfaceFormat() const;
-
-
- bool start(const QVideoSurfaceFormat &format, int bytesPerLine);
- void stop();
-
- bool isActive();
-
- GstFlowReturn render(GstBuffer *buffer);
-
-private slots:
- void queuedStart();
- void queuedStop();
- void queuedRender();
-
- void supportedFormatsChanged();
-
-private:
- QPointer<QAbstractVideoSurface> m_surface;
- QList<QVideoFrame::PixelFormat> m_supportedPixelFormats;
- QMutex m_mutex;
- QWaitCondition m_setupCondition;
- QWaitCondition m_renderCondition;
- QVideoSurfaceFormat m_format;
- QVideoFrame m_frame;
- GstFlowReturn m_renderReturn;
- int m_bytesPerLine;
- bool m_started;
-};
-
-class QVideoSurfaceGstSink
-{
-public:
- GstVideoSink parent;
-
- static QVideoSurfaceGstSink *createSink(QAbstractVideoSurface *surface);
- static QVideoSurfaceFormat formatForCaps(GstCaps *caps, int *bytesPerLine = 0);
-
-private:
- static GType get_type();
- static void class_init(gpointer g_class, gpointer class_data);
- static void base_init(gpointer g_class);
- static void instance_init(GTypeInstance *instance, gpointer g_class);
-
- static void finalize(GObject *object);
-
- static GstStateChangeReturn change_state(GstElement *element, GstStateChange transition);
-
- static GstCaps *get_caps(GstBaseSink *sink);
- static gboolean set_caps(GstBaseSink *sink, GstCaps *caps);
-
- static GstFlowReturn buffer_alloc(
- GstBaseSink *sink, guint64 offset, guint size, GstCaps *caps, GstBuffer **buffer);
-
- static gboolean start(GstBaseSink *sink);
- static gboolean stop(GstBaseSink *sink);
-
- static gboolean unlock(GstBaseSink *sink);
-
- static gboolean event(GstBaseSink *sink, GstEvent *event);
- static GstFlowReturn preroll(GstBaseSink *sink, GstBuffer *buffer);
- static GstFlowReturn render(GstBaseSink *sink, GstBuffer *buffer);
-
-private:
- QVideoSurfaceGstDelegate *delegate;
-
-#ifdef Q_WS_X11
- QGstXvImageBufferPool *pool;
-#endif
-
- GstCaps *lastRequestedCaps;
- GstCaps *lastBufferCaps;
- QVideoSurfaceFormat *lastSurfaceFormat;
-};
-
-
-class QVideoSurfaceGstSinkClass
-{
-public:
- GstVideoSinkClass parent_class;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp b/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp
deleted file mode 100644
index 70b8527..0000000
--- a/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp
+++ /dev/null
@@ -1,523 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/qvariant.h>
-#include <QtCore/qdebug.h>
-#include <QtGui/qx11info_x11.h>
-#include <QtMultimedia/qvideosurfaceformat.h>
-
-#include "qx11videosurface.h"
-
-Q_DECLARE_METATYPE(::XvImage*);
-
-QT_BEGIN_NAMESPACE
-
-static QAbstractVideoBuffer::HandleType XvHandleType = QAbstractVideoBuffer::HandleType(4);
-
-struct XvFormatRgb
-{
- QVideoFrame::PixelFormat pixelFormat;
- int bits_per_pixel;
- int format;
- int num_planes;
-
- int depth;
- unsigned int red_mask;
- unsigned int green_mask;
- unsigned int blue_mask;
-
-};
-
-bool operator ==(const XvImageFormatValues &format, const XvFormatRgb &rgb)
-{
- return format.type == XvRGB
- && format.bits_per_pixel == rgb.bits_per_pixel
- && format.format == rgb.format
- && format.num_planes == rgb.num_planes
- && format.depth == rgb.depth
- && format.red_mask == rgb.red_mask
- && format.blue_mask == rgb.blue_mask;
-}
-
-static const XvFormatRgb qt_xvRgbLookup[] =
-{
- { QVideoFrame::Format_ARGB32, 32, XvPacked, 1, 32, 0x00FF0000, 0x0000FF00, 0x000000FF },
- { QVideoFrame::Format_RGB32 , 32, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF },
- { QVideoFrame::Format_RGB24 , 24, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF },
- { QVideoFrame::Format_RGB565, 16, XvPacked, 1, 16, 0x0000F800, 0x000007E0, 0x0000001F },
- { QVideoFrame::Format_BGRA32, 32, XvPacked, 1, 32, 0xFF000000, 0x00FF0000, 0x0000FF00 },
- { QVideoFrame::Format_BGR32 , 32, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF },
- { QVideoFrame::Format_BGR24 , 24, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF },
- { QVideoFrame::Format_BGR565, 16, XvPacked, 1, 16, 0x0000F800, 0x000007E0, 0x0000001F }
-};
-
-struct XvFormatYuv
-{
- QVideoFrame::PixelFormat pixelFormat;
- int bits_per_pixel;
- int format;
- int num_planes;
-
- unsigned int y_sample_bits;
- unsigned int u_sample_bits;
- unsigned int v_sample_bits;
- unsigned int horz_y_period;
- unsigned int horz_u_period;
- unsigned int horz_v_period;
- unsigned int vert_y_period;
- unsigned int vert_u_period;
- unsigned int vert_v_period;
- char component_order[32];
-};
-
-bool operator ==(const XvImageFormatValues &format, const XvFormatYuv &yuv)
-{
- return format.type == XvYUV
- && format.bits_per_pixel == yuv.bits_per_pixel
- && format.format == yuv.format
- && format.num_planes == yuv.num_planes
- && format.y_sample_bits == yuv.y_sample_bits
- && format.u_sample_bits == yuv.u_sample_bits
- && format.v_sample_bits == yuv.v_sample_bits
- && format.horz_y_period == yuv.horz_y_period
- && format.horz_u_period == yuv.horz_u_period
- && format.horz_v_period == yuv.horz_v_period
- && format.horz_y_period == yuv.vert_y_period
- && format.vert_u_period == yuv.vert_u_period
- && format.vert_v_period == yuv.vert_v_period
- && qstrncmp(format.component_order, yuv.component_order, 32) == 0;
-}
-
-static const XvFormatYuv qt_xvYuvLookup[] =
-{
- { QVideoFrame::Format_YUV444 , 24, XvPacked, 1, 8, 8, 8, 1, 1, 1, 1, 1, 1, "YUV" },
- { QVideoFrame::Format_YUV420P, 12, XvPlanar, 3, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YUV" },
- { QVideoFrame::Format_YV12 , 12, XvPlanar, 3, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YVU" },
- { QVideoFrame::Format_UYVY , 16, XvPacked, 1, 8, 8, 8, 1, 2, 2, 1, 1, 1, "UYVY" },
- { QVideoFrame::Format_YUYV , 16, XvPacked, 1, 8, 8, 8, 1, 2, 2, 1, 1, 1, "YUY2" },
- { QVideoFrame::Format_YUYV , 16, XvPacked, 1, 8, 8, 8, 1, 2, 2, 1, 1, 1, "YUYV" },
- { QVideoFrame::Format_NV12 , 12, XvPlanar, 2, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YUV" },
- { QVideoFrame::Format_NV12 , 12, XvPlanar, 2, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YVU" },
- { QVideoFrame::Format_Y8 , 8 , XvPlanar, 1, 8, 0, 0, 1, 0, 0, 1, 0, 0, "Y" }
-};
-
-QX11VideoSurface::QX11VideoSurface(QObject *parent)
- : QAbstractVideoSurface(parent)
- , m_winId(0)
- , m_portId(0)
- , m_gc(0)
- , m_image(0)
-{
-}
-
-QX11VideoSurface::~QX11VideoSurface()
-{
- if (m_gc)
- XFreeGC(QX11Info::display(), m_gc);
-
- if (m_portId != 0)
- XvUngrabPort(QX11Info::display(), m_portId, 0);
-}
-
-WId QX11VideoSurface::winId() const
-{
- return m_winId;
-}
-
-void QX11VideoSurface::setWinId(WId id)
-{
- if (id == m_winId)
- return;
-
- if (m_image)
- XFree(m_image);
-
- if (m_gc) {
- XFreeGC(QX11Info::display(), m_gc);
- m_gc = 0;
- }
-
- if (m_portId != 0)
- XvUngrabPort(QX11Info::display(), m_portId, 0);
-
- m_supportedPixelFormats.clear();
- m_formatIds.clear();
-
- m_winId = id;
-
- if (m_winId && findPort()) {
- querySupportedFormats();
-
- m_gc = XCreateGC(QX11Info::display(), m_winId, 0, 0);
-
- if (m_image) {
- m_image = 0;
-
- if (!start(surfaceFormat()))
- QAbstractVideoSurface::stop();
- }
- } else if (m_image) {
- m_image = 0;
-
- QAbstractVideoSurface::stop();
- }
-
- emit supportedFormatsChanged();
-}
-
-QRect QX11VideoSurface::displayRect() const
-{
- return m_displayRect;
-}
-
-void QX11VideoSurface::setDisplayRect(const QRect &rect)
-{
- m_displayRect = rect;
-}
-
-QRect QX11VideoSurface::viewport() const
-{
- return m_viewport;
-}
-
-void QX11VideoSurface::setViewport(const QRect &rect)
-{
- m_viewport = rect;
-}
-
-int QX11VideoSurface::brightness() const
-{
- return getAttribute("XV_BRIGHTNESS", m_brightnessRange.first, m_brightnessRange.second);
-}
-
-void QX11VideoSurface::setBrightness(int brightness)
-{
- setAttribute("XV_BRIGHTNESS", brightness, m_brightnessRange.first, m_brightnessRange.second);
-}
-
-int QX11VideoSurface::contrast() const
-{
- return getAttribute("XV_CONTRAST", m_contrastRange.first, m_contrastRange.second);
-}
-
-void QX11VideoSurface::setContrast(int contrast)
-{
- setAttribute("XV_CONTRAST", contrast, m_contrastRange.first, m_contrastRange.second);
-}
-
-int QX11VideoSurface::hue() const
-{
- return getAttribute("XV_HUE", m_hueRange.first, m_hueRange.second);
-}
-
-void QX11VideoSurface::setHue(int hue)
-{
- setAttribute("XV_HUE", hue, m_hueRange.first, m_hueRange.second);
-}
-
-int QX11VideoSurface::saturation() const
-{
- return getAttribute("XV_SATURATION", m_saturationRange.first, m_saturationRange.second);
-}
-
-void QX11VideoSurface::setSaturation(int saturation)
-{
- setAttribute("XV_SATURATION", saturation, m_saturationRange.first, m_saturationRange.second);
-}
-
-int QX11VideoSurface::getAttribute(const char *attribute, int minimum, int maximum) const
-{
- if (m_portId != 0) {
- Display *display = QX11Info::display();
-
- Atom atom = XInternAtom(display, attribute, True);
-
- int value = 0;
-
- XvGetPortAttribute(display, m_portId, atom, &value);
-
- return redistribute(value, minimum, maximum, -100, 100);
- } else {
- return 0;
- }
-}
-
-void QX11VideoSurface::setAttribute(const char *attribute, int value, int minimum, int maximum)
-{
- if (m_portId != 0) {
- Display *display = QX11Info::display();
-
- Atom atom = XInternAtom(display, attribute, True);
-
- XvSetPortAttribute(
- display, m_portId, atom, redistribute(value, -100, 100, minimum, maximum));
- }
-}
-
-int QX11VideoSurface::redistribute(
- int value, int fromLower, int fromUpper, int toLower, int toUpper)
-{
- return fromUpper != fromLower
- ? ((value - fromLower) * (toUpper - toLower) / (fromUpper - fromLower)) + toLower
- : 0;
-}
-
-QList<QVideoFrame::PixelFormat> QX11VideoSurface::supportedPixelFormats(
- QAbstractVideoBuffer::HandleType handleType) const
-{
- return handleType == QAbstractVideoBuffer::NoHandle || handleType == XvHandleType
- ? m_supportedPixelFormats
- : QList<QVideoFrame::PixelFormat>();
-}
-
-bool QX11VideoSurface::start(const QVideoSurfaceFormat &format)
-{
- if (m_image)
- XFree(m_image);
-
- int xvFormatId = 0;
- for (int i = 0; i < m_supportedPixelFormats.count(); ++i) {
- if (m_supportedPixelFormats.at(i) == format.pixelFormat()) {
- xvFormatId = m_formatIds.at(i);
- break;
- }
- }
-
- if (xvFormatId == 0) {
- setError(UnsupportedFormatError);
- } else {
- XvImage *image = XvCreateImage(
- QX11Info::display(),
- m_portId,
- xvFormatId,
- 0,
- format.frameWidth(),
- format.frameHeight());
-
- if (!image) {
- setError(ResourceError);
- } else {
- m_viewport = format.viewport();
- m_image = image;
-
- QVideoSurfaceFormat newFormat = format;
- newFormat.setProperty("portId", QVariant(quint64(m_portId)));
- newFormat.setProperty("xvFormatId", xvFormatId);
- newFormat.setProperty("dataSize", image->data_size);
-
- return QAbstractVideoSurface::start(newFormat);
- }
- }
-
- if (m_image) {
- m_image = 0;
-
- QAbstractVideoSurface::stop();
- }
-
- return false;
-}
-
-void QX11VideoSurface::stop()
-{
- if (m_image) {
- XFree(m_image);
- m_image = 0;
-
- QAbstractVideoSurface::stop();
- }
-}
-
-bool QX11VideoSurface::present(const QVideoFrame &frame)
-{
- if (!m_image) {
- setError(StoppedError);
- return false;
- } else if (m_image->width != frame.width() || m_image->height != frame.height()) {
- setError(IncorrectFormatError);
- return false;
- } else {
- QVideoFrame frameCopy(frame);
-
- if (!frameCopy.map(QAbstractVideoBuffer::ReadOnly)) {
- setError(IncorrectFormatError);
- return false;
- } else {
- bool presented = false;
-
- if (frame.handleType() != XvHandleType &&
- m_image->data_size > frame.mappedBytes()) {
- qWarning("Insufficient frame buffer size");
- setError(IncorrectFormatError);
- } else if (frame.handleType() != XvHandleType &&
- m_image->num_planes > 0 &&
- m_image->pitches[0] != frame.bytesPerLine()) {
- qWarning("Incompatible frame pitches");
- setError(IncorrectFormatError);
- } else {
- if (frame.handleType() != XvHandleType) {
- m_image->data = reinterpret_cast<char *>(frameCopy.bits());
-
- //qDebug() << "copy frame";
- XvPutImage(
- QX11Info::display(),
- m_portId,
- m_winId,
- m_gc,
- m_image,
- m_viewport.x(),
- m_viewport.y(),
- m_viewport.width(),
- m_viewport.height(),
- m_displayRect.x(),
- m_displayRect.y(),
- m_displayRect.width(),
- m_displayRect.height());
-
- m_image->data = 0;
- } else {
- XvImage *img = frame.handle().value<XvImage*>();
-
- //qDebug() << "render directly";
- if (img)
- XvShmPutImage(
- QX11Info::display(),
- m_portId,
- m_winId,
- m_gc,
- img,
- m_viewport.x(),
- m_viewport.y(),
- m_viewport.width(),
- m_viewport.height(),
- m_displayRect.x(),
- m_displayRect.y(),
- m_displayRect.width(),
- m_displayRect.height(),
- false);
- }
-
- presented = true;
- }
-
- frameCopy.unmap();
-
- return presented;
- }
- }
-}
-
-bool QX11VideoSurface::findPort()
-{
- unsigned int count = 0;
- XvAdaptorInfo *adaptors = 0;
- bool portFound = false;
-
- if (XvQueryAdaptors(QX11Info::display(), m_winId, &count, &adaptors) == Success) {
- for (unsigned int i = 0; i < count && !portFound; ++i) {
- if (adaptors[i].type & XvImageMask) {
- m_portId = adaptors[i].base_id;
-
- for (unsigned int j = 0; j < adaptors[i].num_ports && !portFound; ++j, ++m_portId)
- portFound = XvGrabPort(QX11Info::display(), m_portId, 0) == Success;
- }
- }
- XvFreeAdaptorInfo(adaptors);
- }
-
- return portFound;
-}
-
-void QX11VideoSurface::querySupportedFormats()
-{
- int count = 0;
- if (XvImageFormatValues *imageFormats = XvListImageFormats(
- QX11Info::display(), m_portId, &count)) {
- const int rgbCount = sizeof(qt_xvRgbLookup) / sizeof(XvFormatRgb);
- const int yuvCount = sizeof(qt_xvYuvLookup) / sizeof(XvFormatYuv);
-
- for (int i = 0; i < count; ++i) {
- switch (imageFormats[i].type) {
- case XvRGB:
- for (int j = 0; j < rgbCount; ++j) {
- if (imageFormats[i] == qt_xvRgbLookup[j]) {
- m_supportedPixelFormats.append(qt_xvRgbLookup[j].pixelFormat);
- m_formatIds.append(imageFormats[i].id);
- break;
- }
- }
- break;
- case XvYUV:
- for (int j = 0; j < yuvCount; ++j) {
- if (imageFormats[i] == qt_xvYuvLookup[j]) {
- m_supportedPixelFormats.append(qt_xvYuvLookup[j].pixelFormat);
- m_formatIds.append(imageFormats[i].id);
- break;
- }
- }
- break;
- }
- }
- XFree(imageFormats);
- }
-
- m_brightnessRange = qMakePair(0, 0);
- m_contrastRange = qMakePair(0, 0);
- m_hueRange = qMakePair(0, 0);
- m_saturationRange = qMakePair(0, 0);
-
- if (XvAttribute *attributes = XvQueryPortAttributes(QX11Info::display(), m_portId, &count)) {
- for (int i = 0; i < count; ++i) {
- if (qstrcmp(attributes[i].name, "XV_BRIGHTNESS") == 0)
- m_brightnessRange = qMakePair(attributes[i].min_value, attributes[i].max_value);
- else if (qstrcmp(attributes[i].name, "XV_CONTRAST") == 0)
- m_contrastRange = qMakePair(attributes[i].min_value, attributes[i].max_value);
- else if (qstrcmp(attributes[i].name, "XV_HUE") == 0)
- m_hueRange = qMakePair(attributes[i].min_value, attributes[i].max_value);
- else if (qstrcmp(attributes[i].name, "XV_SATURATION") == 0)
- m_saturationRange = qMakePair(attributes[i].min_value, attributes[i].max_value);
- }
-
- XFree(attributes);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/mediaservices/gstreamer/qx11videosurface.h b/src/plugins/mediaservices/gstreamer/qx11videosurface.h
deleted file mode 100644
index 10f79a6..0000000
--- a/src/plugins/mediaservices/gstreamer/qx11videosurface.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QX11VIDEOSURFACE_H
-#define QX11VIDEOSURFACE_H
-
-#include <QtGui/qwidget.h>
-#include <QtMultimedia/qabstractvideosurface.h>
-
-#include <X11/Xlib.h>
-#include <X11/extensions/Xv.h>
-#include <X11/extensions/Xvlib.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QX11VideoSurface : public QAbstractVideoSurface
-{
- Q_OBJECT
-public:
- QX11VideoSurface(QObject *parent = 0);
- ~QX11VideoSurface();
-
- WId winId() const;
- void setWinId(WId id);
-
- QRect displayRect() const;
- void setDisplayRect(const QRect &rect);
-
- QRect viewport() const;
- void setViewport(const QRect &rect);
-
- int brightness() const;
- void setBrightness(int brightness);
-
- int contrast() const;
- void setContrast(int contrast);
-
- int hue() const;
- void setHue(int hue);
-
- int saturation() const;
- void setSaturation(int saturation);
-
- QList<QVideoFrame::PixelFormat> supportedPixelFormats(
- QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const;
-
- bool start(const QVideoSurfaceFormat &format);
- void stop();
-
- bool present(const QVideoFrame &frame);
-
-private:
- WId m_winId;
- XvPortID m_portId;
- GC m_gc;
- XvImage *m_image;
- QList<QVideoFrame::PixelFormat> m_supportedPixelFormats;
- QVector<int> m_formatIds;
- QRect m_viewport;
- QRect m_displayRect;
- QPair<int, int> m_brightnessRange;
- QPair<int, int> m_contrastRange;
- QPair<int, int> m_hueRange;
- QPair<int, int> m_saturationRange;
-
- bool findPort();
- void querySupportedFormats();
-
- int getAttribute(const char *attribute, int minimum, int maximum) const;
- void setAttribute(const char *attribute, int value, int minimum, int maximum);
-
- static int redistribute(int value, int fromLower, int fromUpper, int toLower, int toUpper);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif