aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Berres <armin.berres@basyskom.de>2010-11-18 15:37:45 +0100
committerStanislav Ionascu <stanislav.ionascu@nokia.com>2010-11-23 13:33:56 +0200
commitbe20186eba5106e05f7ee2baf6b78946a8bebf09 (patch)
treea4c0ee18673d18fb6a4d9ea9a6c8412f89cd34dd
parentbf756f665e355df3bffc10fdc24bc54132741fe8 (diff)
Changes: Remove MVideoWidget.
Fixes: NB#198570 - libmeegotouch libraries force gstreamer to every application RevBy: Stanislav Ionascu, Tomas Junnonen Details: MVideoWidget should not be used by anyone. Instead alternatives like the QGraphicsVideoItem should be used.
-rwxr-xr-xconfigure11
-rw-r--r--mkspecs/features/meegotouch_common.prf4
-rw-r--r--src/common_top.pri10
-rw-r--r--src/corelib/corelib.pro3
-rw-r--r--src/corelib/video/mvideo.h87
-rw-r--r--src/corelib/video/mvideowidget.cpp195
-rw-r--r--src/corelib/video/mvideowidget.h236
-rw-r--r--src/corelib/video/mvideowidgetmodel.h119
-rw-r--r--src/corelib/video/video.pri22
-rw-r--r--src/include/MVideoWidget1
-rw-r--r--src/include/MVideoWidgetView1
-rw-r--r--src/include/mvideo.h1
-rw-r--r--src/include/mvideowidget.h2
-rw-r--r--src/include/mvideowidgetmodel.h2
-rw-r--r--src/include/mvideowidgetstyle.h20
-rw-r--r--src/include/mvideowidgetview.h2
-rw-r--r--src/views/video/mgstvideo.cpp702
-rw-r--r--src/views/video/mgstvideo.h146
-rw-r--r--src/views/video/msink.c141
-rw-r--r--src/views/video/msink.h105
-rw-r--r--src/views/video/mvideowidgetview.cpp660
-rw-r--r--src/views/video/mvideowidgetview.h98
-rw-r--r--src/views/video/mvideowidgetview_p.h81
-rw-r--r--src/views/video/video.pri17
-rw-r--r--src/views/views.pro2
-rw-r--r--tests/tests.pro1
-rw-r--r--tests/ut_mvideowidget/.gitignore1
-rw-r--r--tests/ut_mvideowidget/test.movbin387656 -> 0 bytes
-rw-r--r--tests/ut_mvideowidget/ut_mvideowidget.cpp272
-rw-r--r--tests/ut_mvideowidget/ut_mvideowidget.h67
-rw-r--r--tests/ut_mvideowidget/ut_mvideowidget.pro10
31 files changed, 1 insertions, 3018 deletions
diff --git a/configure b/configure
index 16d0b71b..b4fa557c 100755
--- a/configure
+++ b/configure
@@ -74,7 +74,6 @@ CFG_MEEGOGRAPHICSSYSTEM=no
HAVE_ICU=no
HAVE_CONTEXTSUBSCRIBER=no
HAVE_GCONF=no
-HAVE_GSTREAMER=no
HAVE_DBUS=no
HAVE_CONTENTACTION=no
HAVE_XDAMAGE=no
@@ -407,11 +406,6 @@ if [ $? -eq 0 ]; then
fi
fi
- pkg-config --exists gstreamer-0.10
- if [ $? -eq 0 ]; then
- HAVE_GSTREAMER=yes
- fi
-
# Test for DBus
if [ "$CFG_DBUS" != "no" ]; then
pkg-config --exists QtDBus
@@ -621,10 +615,6 @@ if [ "$HAVE_GCONF" = "yes" ]; then
MEEGOTOUCHCONFIG_DEPS="$MEEGOTOUCHCONFIG_DEPS HAVE_GCONF"
fi
-if [ "$HAVE_GSTREAMER" = "yes" ]; then
- MEEGOTOUCHCONFIG_DEPS="$MEEGOTOUCHCONFIG_DEPS HAVE_GSTREAMER"
-fi
-
if [ "$HAVE_DBUS" = "yes" ]; then
MEEGOTOUCHCONFIG_DEPS="$MEEGOTOUCHCONFIG_DEPS HAVE_DBUS"
fi
@@ -834,7 +824,6 @@ echo "ICU ............................. $HAVE_ICU"
echo "Context Subscriber 1.0 .......... $HAVE_CONTEXTSUBSCRIBER"
echo "Content Action 0.1 .............. $HAVE_CONTENTACTION"
echo "GConf 2.0 ....................... $HAVE_GCONF"
-echo "GStreamer 0.10 .................. $HAVE_GSTREAMER"
echo "DBus (incl. QtDBus) ............. $HAVE_DBUS"
echo "XDamage ......................... $HAVE_XDAMAGE"
echo "Qt Mobility Service Framework ... $HAVE_QTM_SERVICEFRAMEWORK"
diff --git a/mkspecs/features/meegotouch_common.prf b/mkspecs/features/meegotouch_common.prf
index f2b291ed..e8403fdd 100644
--- a/mkspecs/features/meegotouch_common.prf
+++ b/mkspecs/features/meegotouch_common.prf
@@ -22,9 +22,7 @@ contains(TEMPLATE, app) {
M_INC_DIR = $$M_PREFIX/include/meegotouch
M_LIB_DIR = $$M_LIBDIR
- GSTREAMER_INC = /usr/include/gstreamer-0.10 /usr/include/glib-2.0 /usr/lib/glib-2.0/include /usr/include/libxml2
-
- INCLUDEPATH += $${M_INC_DIR} $${GSTREAMER_INC}
+ INCLUDEPATH += $${M_INC_DIR}
DEPENDPATH += $${M_INC_DIR}
LIBS += -L$${M_LIB_DIR}
diff --git a/src/common_top.pri b/src/common_top.pri
index da37aae2..4de3ae1e 100644
--- a/src/common_top.pri
+++ b/src/common_top.pri
@@ -85,16 +85,6 @@ contains(DEFINES, HAVE_CONTENTACTION) {
PKGCONFIG += contentaction-0.1
}
-contains(DEFINES, HAVE_GSTREAMER) {
- PKGCONFIG += gstreamer-0.10
- # TODO: Is this necessary?
- LIBS += -lgstbase-0.10 -lgstinterfaces-0.10 -lgstvideo-0.10
-
- # On Mac, GStreamer can be also in /opt if installed via macports.org or /usr/local if installed from sources
- macx:INCLUDEPATH += /opt/local/include/gstreamer-0.10 /opt/local/include/glib-2.0 /opt/local/lib/glib-2.0/include/ /opt/local/include/libxml2
- macx:LIBS += -L/opt/local/lib -lgstreamer-0.10.0 -lgstbase-0.10.0 -lgstinterfaces-0.10.0 -lgstvideo-0.10.0 -lglib-2.0.0 -lgobject-2.0.0
-}
-
contains(DEFINES, HAVE_GCONF) {
PKGCONFIG += gconf-2.0
# TODO: Why is this necessary?
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 756381cd..cecb4641 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -18,9 +18,6 @@ include(theme/theme.pri)
include(i18n/i18n.pri)
include(widgets/widgets.pri)
include(workspace/workspace.pri)
-contains(DEFINES, HAVE_GSTREAMER) {
- include(video/video.pri)
-}
contains(DEFINES, HAVE_DBUS) {
include(help/help.pri)
include(servicefwif/servicefwif.pri)
diff --git a/src/corelib/video/mvideo.h b/src/corelib/video/mvideo.h
deleted file mode 100644
index e5c58fdf..00000000
--- a/src/corelib/video/mvideo.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * This file is part of libmeegotouch *
- *
- * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- *
- * Contact: Tomas Junnonen <tomas.junnonen@nokia.com>
- *
- * This software, including documentation, is protected by copyright
- * controlled by Nokia Corporation. All rights are reserved. Copying,
- * including reproducing, storing, adapting or translating, any or all of
- * this material requires the prior written consent of Nokia Corporation.
- * This material also contains confidential information which may not be
- * disclosed to others without the prior written consent of Nokia.
- */
-#ifndef MVIDEO_H
-#define MVIDEO_H
-
-#include <QObject>
-#include <QSize>
-#include <MExport>
-
-class M_CORE_EXPORT MVideo : public QObject
-{
- Q_OBJECT
-
-public:
-
- //! Supported raw video data formats.
- enum DataFormat {
- //! 24bit RGB
- RGB = 0,
- //BGR,
- //RGBx,
- //BGRx,
- //! 12bit YUV (YV12, I420)
- YUV
- };
-
-
- //! States for the video playback
- enum State {
- //! Video is not ready yet, playback cannot be started.
- NotReady = 0,
- //! Video is paused.
- Paused,
- //! Video is playing.
- Playing,
- //! Video is stopped.
- Stopped
- };
-
- virtual bool open(const QString& filename) = 0;
-
- virtual bool isReady() const = 0;
-
- virtual void setVideoState(MVideo::State state) = 0;
- virtual MVideo::State videoState() const = 0;
-
- virtual void seek(quint64 time) = 0;
- virtual quint64 position() const = 0;
- virtual quint64 length() const = 0;
-
- virtual void setMuted(bool muted) = 0;
- virtual bool isMuted() const = 0;
- virtual void setVolume(qreal volume) = 0;
- virtual qreal volume() const = 0;
-
- virtual void setLooping(bool enabled) = 0;
- virtual bool isLooping() const = 0;
-
- virtual QSize resolution() const = 0;
-
- virtual uchar* frameData() const = 0;
- virtual MVideo::DataFormat frameDataFormat() const = 0;
-
- virtual bool lockFrameData() = 0;
- virtual void unlockFrameData() = 0;
-
-Q_SIGNALS:
-
- void videoReady();
- void frameReady();
- void stateChanged();
-};
-
-#endif
diff --git a/src/corelib/video/mvideowidget.cpp b/src/corelib/video/mvideowidget.cpp
deleted file mode 100644
index d31c7357..00000000
--- a/src/corelib/video/mvideowidget.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/* * This file is part of libmeegotouch *
- *
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- *
- * Contact: Tomas Junnonen <tomas.junnonen@nokia.com>
- *
- * This software, including documentation, is protected by copyright
- * controlled by Nokia Corporation. All rights are reserved. Copying,
- * including reproducing, storing, adapting or translating, any or all of
- * this material requires the prior written consent of Nokia Corporation.
- * This material also contains confidential information which may not be
- * disclosed to others without the prior written consent of Nokia.
- */
-#include "mvideowidget.h"
-#include "private/mwidgetcontroller_p.h"
-#include "mdebug.h"
-
-#include "mwidgetcreator.h"
-M_REGISTER_WIDGET(MVideoWidget)
-
-class MVideoWidgetPrivate : public MWidgetControllerPrivate
-{
-public:
-
- Q_DECLARE_PUBLIC(MVideoWidget)
-
- MVideoWidgetPrivate();
- virtual ~MVideoWidgetPrivate();
-
-
-};
-
-MVideoWidgetPrivate::MVideoWidgetPrivate()
-{
-}
-
-MVideoWidgetPrivate::~MVideoWidgetPrivate()
-{
-}
-
-MVideoWidget::MVideoWidget(QGraphicsItem *parent, MVideoWidgetModel* model)
- : MWidgetController(new MVideoWidgetPrivate, model == NULL ? new MVideoWidgetModel : model, parent)
-{
-}
-
-MVideoWidget::MVideoWidget(MVideoWidgetPrivate* dd, MVideoWidgetModel* model, QGraphicsItem* parent)
- : MWidgetController(dd, model, parent)
-{
-
-}
-
-MVideoWidget::~MVideoWidget()
-{
-}
-
-void MVideoWidget::open(const QString& filename)
-{
- model()->setFilename(filename);
-}
-
-MVideo::State MVideoWidget::state() const
-{
- return model()->state();
-}
-
-void MVideoWidget::seek(quint64 time)
-{
- if( time <= length() )
- model()->setPosition(time);
-}
-
-quint64 MVideoWidget::length() const
-{
- return model()->length();
-}
-
-quint64 MVideoWidget::position() const
-{
- return model()->position();
-}
-
-void MVideoWidget::setVolume(qreal volume)
-{
- volume = (volume < 0) ? 0.0 : ((volume > 10.0) ? 10.0 : volume);
- model()->setVolume(volume);
-}
-
-qreal MVideoWidget::volume() const
-{
- return model()->volume();
-}
-
-void MVideoWidget::setMuted(bool mute)
-{
- model()->setMuted(mute);
-}
-
-bool MVideoWidget::isMuted() const
-{
- return model()->muted();
-}
-
-/*QImage MVideoWidget::currentFrame() const
-{
- Q_D(MVideoWidget);
-#ifdef M_USE_OPENGL
- MGstVideoSink *msink = M_GST_VIDEO_SINK(d->gst_elem_videosink);
- return QImage(GST_BUFFER_DATA(d->gst_buffer), msink->w, msink->h, QImage::Format_RGB32);
-#else
- return d->image->copy();
-#endif
-
- return QImage();
-}*/
-
-void MVideoWidget::setScaleMode(MVideoWidgetModel::Scale mode)
-{
- model()->setScaleMode(mode);
-}
-
-MVideoWidgetModel::Scale MVideoWidget::scaleMode() const
-{
- return model()->scaleMode();
-}
-
-void MVideoWidget::setAspectRatioMode(MVideoWidgetModel::AspectRatio aspectRatio)
-{
- model()->setAspectRatioMode(aspectRatio);
-}
-
-MVideoWidgetModel::AspectRatio MVideoWidget::aspectRatioMode() const
-{
- return model()->aspectRatioMode();
-}
-
-void MVideoWidget::setLooping(bool enabled)
-{
- model()->setLooping(enabled);
-}
-
-bool MVideoWidget::isLooping() const
-{
- return model()->looping();
-}
-
-void MVideoWidget::setFullscreen(bool fullscreen)
-{
- model()->setFullscreen(fullscreen);
-}
-
-bool MVideoWidget::isFullscreen() const
-{
- return model()->fullscreen();
-}
-
-void MVideoWidget::play()
-{
- model()->setState(MVideo::Playing);
-}
-
-void MVideoWidget::pause()
-{
- model()->setState(MVideo::Paused);
-}
-
-void MVideoWidget::stop()
-{
- model()->setState(MVideo::Stopped);
-}
-
-void MVideoWidget::setupModel()
-{
- MWidgetController::setupModel();
-}
-
-void MVideoWidget::updateData(const QList<const char*>& modifications)
-{
- MWidgetController::updateData(modifications);
- mDebug("MVideoWidget::updateData()") << modifications;
-
- const char* member;
- foreach(member, modifications) {
- if( member == MVideoWidgetModel::State ) {
- mDebug("MVideoWidget::updateData()") << "State" << model()->state();
- }
- else if( member == MVideoWidgetModel::Position ) {
- mDebug("MVideoWidget::updateData()") << "Position" << model()->position() << "/" << model()->length();
- }
- else if( member == MVideoWidgetModel::Length ) {
- if( model()->length() > 0 && model()->state() != MVideo::NotReady )
- emit videoReady();
- }
- }
-}
diff --git a/src/corelib/video/mvideowidget.h b/src/corelib/video/mvideowidget.h
deleted file mode 100644
index 7c6c7f63..00000000
--- a/src/corelib/video/mvideowidget.h
+++ /dev/null
@@ -1,236 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (directui@nokia.com)
-**
-** This file is part of libmeegotouch.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at directui@nokia.com.
-**
-** This library is free software; you can redistribute it and/or
-** modify it 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.
-**
-****************************************************************************/
-
-#ifndef MVIDEOWIDGET_H
-#define MVIDEOWIDGET_H
-
-#include <mwidgetcontroller.h>
-#include <mvideowidgetmodel.h>
-
-class MVideoWidgetPrivate;
-
-
-/*!
- \class MVideoWidget
- \brief MVideoWidget provides functionality for playing videos.
-
- \ingroup widgets
-
- \section MVideoWidgetOverview Overview
- MVideoWidget supports following features:
-
- - Standard playback controlling through play(), pause(), stop(), seek()
- and setLooping() methods.
- - Volume controlling through the setVolume() and setMute() methods.
- - Automatic fitting and appearence of the video can be changed using the
- setScaleToFit(), setKeepAspectRatio() and setFullscreen()
- methods.
-
- \section MVideoWidgetUseGuidelines Usage guidelines
-
- \section MVideoWidgetVariants Variants
- \li \link MVideoWidgetView Default view. \endlink Standard view for
- displaying video frames without any visual controls.
-
- \section MVideoWidgetOpenIssues Open issues
-
- \section MVideoWidgetExamples Examples
-
- \sa MVideoWidgetModel
-*/
-class M_CORE_EXPORT MVideoWidget : public MWidgetController
-{
- Q_OBJECT
- M_CONTROLLER(MVideoWidget)
-
-public:
-
- /*!
- \brief Constructs a video widget.
- */
- MVideoWidget(QGraphicsItem *parent = 0, MVideoWidgetModel* model = 0);
-
- /*!
- \brief Destroys the video widget.
- */
- virtual ~MVideoWidget();
-
- /*!
- \brief Opens a video from a file.
- */
- void open(const QString& filename);
-
- /*!
- \brief Return the playback state.
- */
- MVideo::State state() const;
-
- /*!
- \brief Seek video to a wanted position/time.
-
- \a time is defined as milliseconds and it should be in a range of 0 to
- lenght of video.
- */
- void seek(quint64 time);
-
- /*!
- \brief Query length of the video.
-
- \return Length of video in milliseconds.
- */
- quint64 length() const;
-
- /*!
- \brief Query the current position of the video.
-
- \return Position of the video in milliseconds.
- */
- quint64 position() const;
-
- /*!
- \brief Set volume factor for the video's audio track.
-
- \a volume should be in a range of 0.0 -> 10.0. 1.0 means 100% volume.
- 1.0 -> 10.0 are gain through amplification.
- */
- void setVolume(qreal volume);
-
- /*!
- \brief Query current volume factor of the video's audio track.
-
- \returns Audio volume. 0.0 if video does not contain audio track.
- */
- qreal volume() const;
-
- /*!
- \brief Mute the video's audio.
- */
- void setMuted(bool mute);
-
- /*!
- \brief Query current mute status.
-
- \returns True if audio is muted or no audio track exists, false is audio is
- not muted.
- */
- bool isMuted() const;
-
- /*!
- * Snapshot the current video frame.
- * \returns image of current video frame
- */
- //QImage currentFrame() const;
-
- /*!
- \brief Set scaling mode to video.
-
- If \a mode is MVideoWidgetModel::ScaleToFit the video scaled to fit the widget size. If \a mode
- is MVideoWidgetModel::ScaleDisabled the video is rendered in it's native resolution into the middle
- of the widget.
- */
- void setScaleMode(MVideoWidgetModel::Scale mode);
-
- /*!
- \brief Returns video scaling mode.
- */
- MVideoWidgetModel::Scale scaleMode() const;
-
- /*!
- \brief Set aspect ratio
-
- If \a aspectRatio is MVideoWidgetModel::AspectRatioOriginal, the video is scaled without breaking the
- native aspect ratio. If \a aspectRatio is MVideoWidgetModel::AspectRatioScaled, the native aspect
- ratio is not preserved and the video is scaled to match the size of the widget.
- */
- void setAspectRatioMode(MVideoWidgetModel::AspectRatio aspectRatio);
-
- /*!
- \brief Return type of the aspect ratio.
- */
- MVideoWidgetModel::AspectRatio aspectRatioMode() const;
-
- /*!
- \brief Enable / disable automatic looping of the video.
- */
- void setLooping(bool enabled);
-
- /*!
- \brief Query looping mode.
-
- \returns looping mode.
- */
- bool isLooping() const;
-
- /*!
- \brief Enable / disable fullscreen mode.
- */
- void setFullscreen(bool fullscreen);
-
- /*!
- \brief Query fullscreen mode.
- */
- bool isFullscreen() const;
-
-Q_SIGNALS:
-
- void videoReady();
-
-public Q_SLOTS:
- /*!
- \brief Start video playback.
- */
- void play();
-
- /*!
- \brief Pause video playback.
-
- When resuming the video playback with call to MVideoWidget::play(),
- video continues to play from the position it was left when pausing.
- */
- void pause();
-
- /*!
- \brief Stop video playback.
-
- The video is rewinded to the beginning.
- */
- void stop();
-
-protected Q_SLOTS:
-
- //! \reimp
- virtual void updateData(const QList<const char*>& modifications);
- //! \reimp_end
-
-protected:
-
- //! \cond
- MVideoWidget(MVideoWidgetPrivate* dd, MVideoWidgetModel* model, QGraphicsItem *parent);
- //! \endcond
-
- //! \reimp
- virtual void setupModel();
- //! \reimp_end
-
-private:
-
- Q_DECLARE_PRIVATE(MVideoWidget)
- Q_DISABLE_COPY(MVideoWidget)
-};
-#endif // MVIDEOWIDGET_H
diff --git a/src/corelib/video/mvideowidgetmodel.h b/src/corelib/video/mvideowidgetmodel.h
deleted file mode 100644
index d61d2aae..00000000
--- a/src/corelib/video/mvideowidgetmodel.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/* * This file is part of libmeegotouch *
- *
- * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- *
- * Contact: Tomas Junnonen <tomas.junnonen@nokia.com>
- *
- * This software, including documentation, is protected by copyright
- * controlled by Nokia Corporation. All rights are reserved. Copying,
- * including reproducing, storing, adapting or translating, any or all of
- * this material requires the prior written consent of Nokia Corporation.
- * This material also contains confidential information which may not be
- * disclosed to others without the prior written consent of Nokia.
- */
-#ifndef MVIDEOWIDGETMODEL_H
-#define MVIDEOWIDGETMODEL_H
-
-#include <mwidgetmodel.h>
-#include "mvideo.h"
-
-/*!
- \class MVideoWidgetModel
- \brief Data model class for MVideoWidget.
-
- \ingroup models
- \sa MVideoWidget
-*/
-class M_CORE_EXPORT MVideoWidgetModel : public MWidgetModel
-{
- Q_OBJECT
- M_MODEL_INTERNAL(MVideoWidgetModel)
-
-public:
- enum Scale
- {
- ScaleDisabled,
- ScaleToFit
- };
-
- enum AspectRatio
- {
- AspectRatioOriginal,
- AspectRatioScaled
- };
-
- /*!
- \property MVideoWidgetModel::state
- \brief Current state of the video playback.
- */
- M_MODEL_PROPERTY(MVideo::State, state, State, true, MVideo::NotReady)
-
- /*!
- \property MVideoWidgetModel::filename
- \brief Name of the opened video file.
- */
- M_MODEL_PROPERTY(QString, filename, Filename, true, QString())
-
- /*!
- \property MVideoWidgetModel::length
- \brief Length of the opened video in milliseconds.
- */
- M_MODEL_PROPERTY(quint64, length, Length, true, 0)
-
- /*!
- \property MVideoWidgetModel::position
- \brief Current position of the played video in milliseconds.
- */
- M_MODEL_PROPERTY(quint64, position, Position, true, 0)
-
- /*!
- \property MVideoWidgetModel::looping
- \brief Boolean flag defining whether video is looping automatically.
- */
- M_MODEL_PROPERTY(bool, looping, Looping, true, true)
-
- /*!
- \property MVideoWidgetModel::scaleMode
- \brief Defines how the video is scaled to the canvas.
- */
- M_MODEL_PROPERTY(MVideoWidgetModel::Scale, scaleMode, ScaleMode, true, MVideoWidgetModel::ScaleToFit)
-
- /*!
- \property MVideoWidgetModel::aspectRatio
- \brief Defines how to set up aspect ratio for the video.
- */
- M_MODEL_PROPERTY(MVideoWidgetModel::AspectRatio, aspectRatioMode, AspectRatioMode, true, MVideoWidgetModel::AspectRatioOriginal)
-
- /*!
- \property MVideoWidgetModel::keepAspectRatio
- \brief Boolean flag defining if the video should be displayed in
- fullscreen mode.
- */
- M_MODEL_PROPERTY(bool, fullscreen, Fullscreen, true, false)
-
- /*!
- \property MVideoWidgetModel::mute
- \brief Boolean flag defining audio of video should be muted.
- */
- M_MODEL_PROPERTY(bool, muted, Muted, true, false)
-
- /*!
- \property MVideoWidgetModel::volume
- \brief Current audio volume of played video.
- */
- M_MODEL_PROPERTY(qreal, volume, Volume, true, 1.0)
-
-public:
-
- /*!
- \brief Update the MVideoWidgetModel::position property without emitting the change signal.
- */
- void setPositionNoEmit(const qint64& pos)
- {
- _position() = pos;
- }
-};
-
-#endif
-
diff --git a/src/corelib/video/video.pri b/src/corelib/video/video.pri
deleted file mode 100644
index cc057173..00000000
--- a/src/corelib/video/video.pri
+++ /dev/null
@@ -1,22 +0,0 @@
-###############################################################################
-# mvideowidget, Separated to video folder.
-###############################################################################
-VIDEO_SRC_DIR = ./video
-INCLUDEPATH +=./video
-
-contains( DEFINES, HAVE_GSTREAMER) {
- VIDEO_MODEL_HEADERS += \
- $$VIDEO_SRC_DIR/mvideowidgetmodel.h
-
- MODEL_HEADERS += $$VIDEO_MODEL_HEADERS
-
- PUBLIC_HEADERS += \
- $$VIDEO_SRC_DIR/mvideowidget.h \
- $$VIDEO_SRC_DIR/mvideo.h \
- $$VIDEO_MODEL_HEADERS \
-
- SOURCES += \
- $$VIDEO_SRC_DIR/mvideowidget.cpp \
-
-}
-
diff --git a/src/include/MVideoWidget b/src/include/MVideoWidget
deleted file mode 100644
index 8bef6025..00000000
--- a/src/include/MVideoWidget
+++ /dev/null
@@ -1 +0,0 @@
-#include "mvideowidget.h"
diff --git a/src/include/MVideoWidgetView b/src/include/MVideoWidgetView
deleted file mode 100644
index dd96c5a5..00000000
--- a/src/include/MVideoWidgetView
+++ /dev/null
@@ -1 +0,0 @@
-#include "mvideowidgetview.h"
diff --git a/src/include/mvideo.h b/src/include/mvideo.h
deleted file mode 100644
index 4b2389ef..00000000
--- a/src/include/mvideo.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "../corelib/video/mvideo.h"
diff --git a/src/include/mvideowidget.h b/src/include/mvideowidget.h
deleted file mode 100644
index 7d8f9505..00000000
--- a/src/include/mvideowidget.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "../corelib/video/mvideowidget.h"
-
diff --git a/src/include/mvideowidgetmodel.h b/src/include/mvideowidgetmodel.h
deleted file mode 100644
index 3b8ea0c1..00000000
--- a/src/include/mvideowidgetmodel.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "../corelib/video/mvideowidgetmodel.h"
-
diff --git a/src/include/mvideowidgetstyle.h b/src/include/mvideowidgetstyle.h
deleted file mode 100644
index 6c3421d1..00000000
--- a/src/include/mvideowidgetstyle.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (directui@nokia.com)
-**
-** This file is part of libmeegotouch.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at directui@nokia.com.
-**
-** This library is free software; you can redistribute it and/or
-** modify it 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.
-**
-****************************************************************************/
-
-#include "../views/style/mvideowidgetstyle.h"
diff --git a/src/include/mvideowidgetview.h b/src/include/mvideowidgetview.h
deleted file mode 100644
index 01535d43..00000000
--- a/src/include/mvideowidgetview.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "../views/video/mvideowidgetview.h"
-
diff --git a/src/views/video/mgstvideo.cpp b/src/views/video/mgstvideo.cpp
deleted file mode 100644
index 3004250d..00000000
--- a/src/views/video/mgstvideo.cpp
+++ /dev/null
@@ -1,702 +0,0 @@
-#include "mgstvideo.h"
-#include <gst/interfaces/xoverlay.h>
-#include <gst/video/gstvideosink.h>
-#include <gst/interfaces/propertyprobe.h>
-
-#include <QFileInfo>
-
-#include <mdebug.h>
-
-#include "msink.h"
-
-MGstVideo::MGstVideo()
- : gst_elem_pipeline(NULL),
- gst_elem_source(NULL),
- gst_elem_decoder(NULL),
- gst_elem_volume(NULL),
- gst_elem_audiosink(NULL),
- gst_elem_videosink(NULL),
- gst_elem_xvimagesink(NULL),
- gst_messagebus(NULL),
- gst_buffer(NULL),
- m_looping(true),
- m_seekable(false),
- m_ready(false),
- m_muted(false),
- m_volume(1.0),
- m_state(MVideo::NotReady),
- m_format(MVideo::RGB),
- m_renderTarget(MGstVideo::MSink),
- m_storedState(MVideo::NotReady),
- m_storedPosition(0),
- m_winId(0),
- m_colorKey(Qt::black),
- m_forceAspectRatio(true)
-{
- GError* error = NULL;
- if(!gst_init_check(NULL, NULL, &error)) {
- mWarning("MGstVideo") << "GStreamer initialization failed:" << (error ? error->message : "Unknown error");
- }
-}
-
-MGstVideo::~MGstVideo()
-{
- // It is normally not needed to call this function in a normal application
- // as the resources will automatically be freed when the program terminates.
- // gst_deinit();
-
- destroyPipeline();
-}
-
-bool MGstVideo::open(const QString& filename)
-{
- m_storedState = MVideo::NotReady;
- m_storedPosition = 0;
-
- //create absolute name for file including path
- QFileInfo info(filename);
- m_filename = info.absoluteFilePath();
-
- //check whether the file exists
- if (!info.exists() || !info.isReadable()) {
- mWarning("MGstVideo::openVideoFromFile()") << m_filename << "does not exist.";
- return false;
- }
-
- return constructPipeline();
-}
-
-bool MGstVideo::isReady() const
-{
- return m_state != MVideo::NotReady;
-}
-
-
-void MGstVideo::setVideoState(MVideo::State state)
-{
- MVideo::State new_state = m_state;
- if( gst_elem_pipeline ) {
- GstState current_gst_state;
- gst_element_get_state(gst_elem_pipeline, &current_gst_state, NULL, 0);
- if( (current_gst_state == GST_STATE_READY || current_gst_state == GST_STATE_PAUSED || current_gst_state == GST_STATE_PLAYING) && state != MVideo::NotReady ) {
- GstState new_gst_state = (state == MVideo::Paused || state == MVideo::Stopped) ? GST_STATE_PAUSED : GST_STATE_PLAYING;
- if( new_gst_state != current_gst_state ) {
- if( GST_STATE_CHANGE_FAILURE == gst_element_set_state(gst_elem_pipeline, new_gst_state) ) {
- mWarning("MGstVideo::setVideoState()") << "Failed to set state to" << state;
- new_state = MVideo::NotReady;
- }
- else {
- new_state = state;
- }
- }
- else {
- new_state = state;
- }
-
- //when moving to stopped state rewind the video to beginning
- if( new_state == MVideo::Stopped )
- seek(0);
- }
- else {
- mWarning("MGstVideo::setVideoState()") << "Video not ready yet, cannot set state to" << state;
- new_state = MVideo::NotReady;
- }
- }
- else if ( state != MVideo::NotReady ) {
- mWarning("MGstVideo::setVideoState()") << "Pipeline not created yet, cannot set state to" << state;
- new_state = MVideo::NotReady;
- } else
- new_state = MVideo::NotReady;
-
- //TODO: state changes should be emit in bus message method.
- if( m_state != new_state ) {
- m_state = new_state;
- emit stateChanged();
- }
-}
-
-MVideo::State MGstVideo::videoState() const
-{
- return m_state;
-}
-
-void MGstVideo::seek(quint64 time)
-{
- if( gst_elem_pipeline ) {
- if( !gst_element_seek_simple(gst_elem_pipeline, GST_FORMAT_TIME,
- (GstSeekFlags)(GST_SEEK_FLAG_FLUSH),// | GST_SEEK_FLAG_KEY_UNIT),
- time * GST_MSECOND) )
- mWarning("MGstVideo::seek()") << "FAILED.";
- /*gst_element_seek(gst_elem_pipeline, 1.0,
- GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
- GST_SEEK_TYPE_SET, time * GST_MSECOND,
- GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);*/
- }
-}
-
-quint64 MGstVideo::position() const
-{
- gint64 pos = 0;
- if( gst_elem_pipeline ) {
- GstFormat format = GST_FORMAT_TIME;
- if( gst_element_query_position(gst_elem_pipeline, &format, &pos) ) {
- pos /= 1000000;
- }
- }
- return (qint64)pos;
-}
-
-quint64 MGstVideo::length() const
-{
- gint64 length = 0;
- if( gst_elem_pipeline ) {
- GstFormat format = GST_FORMAT_TIME;
- if( gst_element_query_duration(gst_elem_pipeline, &format, &length) ) {
- length /= 1000000;
- }
- }
- return (qint64)length;
-}
-
-void MGstVideo::setMuted(bool muted)
-{
- if( gst_elem_volume ) {
- g_object_set(gst_elem_volume, "mute", muted, NULL);
- } else
- m_muted = muted;
-}
-
-bool MGstVideo::isMuted() const
-{
- gboolean muted = false;
- if( gst_elem_volume ) {
- g_object_get(gst_elem_volume, "mute", &muted, NULL);
- }
- return muted;
-}
-
-void MGstVideo::setVolume(qreal volume)
-{
- if( gst_elem_volume ) {
- g_object_set(gst_elem_volume, "volume", volume, NULL);
- } else
- m_volume = volume;
-}
-
-qreal MGstVideo::volume() const
-{
- gdouble volume = 0.0;
- if( gst_elem_volume ) {
- g_object_get(gst_elem_volume, "volume", &volume, NULL);
- }
- return volume;
-}
-
-
-QSize MGstVideo::resolution() const
-{
- if( m_renderTarget == MSink && gst_elem_videosink )
- return QSize(M_GST_VIDEO_SINK(gst_elem_videosink)->w, M_GST_VIDEO_SINK(gst_elem_videosink)->h);
- else if( gst_elem_xvimagesink )
- return QSize(GST_VIDEO_SINK_WIDTH(gst_elem_xvimagesink), GST_VIDEO_SINK_HEIGHT(gst_elem_xvimagesink));
- else
- return QSize(0,0);
-}
-
-uchar* MGstVideo::frameData() const
-{
- return gst_buffer ? GST_BUFFER_DATA(gst_buffer) : NULL;
-}
-
-MVideo::DataFormat MGstVideo::frameDataFormat() const
-{
- return m_format;
-}
-
-bool MGstVideo::lockFrameData()
-{
- return m_mutex.tryLock();
-}
-
-void MGstVideo::unlockFrameData()
-{
- m_mutex.unlock();
-}
-
-void MGstVideo::setRenderTarget(MGstVideo::RenderTarget targetSink)
-{
- //check if the change of the sink on fly is needed
- if( targetSink != m_renderTarget && isReady() ) {
- GstElement* videobin = gst_bin_get_by_name(GST_BIN_CAST(gst_elem_pipeline), "video bin");
- if( videobin ) {
- //stop playback of video bin to be able to make changes
- gst_element_set_locked_state(videobin, true);
- gst_element_set_state(videobin, GST_STATE_READY);
-
- //remove the currently active sink from video bin
- GstElement* active = activeSink();
- gst_object_ref(GST_OBJECT(active));
- gst_bin_remove(GST_BIN_CAST(videobin), active);
-
- //get colorspace element
- GstElement* colorspace = gst_bin_get_by_name(GST_BIN_CAST(videobin), "ffmpegcolorspace");
- if( colorspace ) {
-
- //change the sink to the wanted target, if there is no support
- //for xv rendering force texture rendering
- if( !gst_elem_xvimagesink )
- m_renderTarget = MSink;
- else
- m_renderTarget = targetSink;
-
-
- active = activeSink();
-
- if( active == gst_elem_xvimagesink ) {
- g_object_set(gst_elem_xvimagesink,
- "autopaint-colorkey", FALSE,
- "colorkey", m_colorKey.rgba() & 0x00FFFFFF,
- "force-aspect-ratio", m_forceAspectRatio,
- "draw-borders", TRUE,
- (void*) 0);
- gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(gst_elem_xvimagesink), m_winId);
- expose();
- }
-
- //link the new active sink with the colorspace element
- gst_bin_add(GST_BIN_CAST(videobin), active);
- gst_element_link_pads(colorspace, "src", active, "sink");
-
- //sync the state of videobin again with it's parent, sync the clock and
- //position manually as well because for some reason they do not
- //get automatically synced during runtime target switch
- gst_element_set_locked_state(videobin, false);
- gst_element_set_clock(videobin, gst_element_get_clock(gst_elem_pipeline));
- gst_element_sync_state_with_parent(videobin);
- gst_element_seek_simple(videobin, GST_FORMAT_TIME,
- (GstSeekFlags)(GST_SEEK_FLAG_FLUSH),
- position() * GST_MSECOND);
- }
- }
- } else
- m_renderTarget = targetSink;
-}
-
-MGstVideo::RenderTarget MGstVideo::renderTarget()
-{
- return m_renderTarget;
-}
-
-void MGstVideo::expose()
-{
- if( gst_elem_xvimagesink && m_renderTarget == XvSink ) {
- gst_x_overlay_expose(GST_X_OVERLAY(gst_elem_xvimagesink));
- }
-}
-
-void MGstVideo::setWinId(unsigned long id)
-{
- m_winId = id;
- if( gst_elem_xvimagesink )
- gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(gst_elem_xvimagesink), m_winId);
-}
-
-unsigned long MGstVideo::winId()
-{
- return m_winId;
-}
-
-void MGstVideo::setColorKey(const QColor& key)
-{
- m_colorKey = key;
-
- if( gst_elem_xvimagesink ) {
- g_object_set(gst_elem_xvimagesink,
- "autopaint-colorkey", FALSE,
- "colorkey", m_colorKey.rgba() & 0x00FFFFFF,
- (void*) 0);
- }
-}
-
-QColor MGstVideo::colorKey()
-{
- return m_colorKey;
-}
-
-void MGstVideo::forceAspectRatio(bool forceAspectRatio)
-{
- m_forceAspectRatio = forceAspectRatio;
- if( gst_elem_xvimagesink ) {
- g_object_set(gst_elem_xvimagesink,
- "force-aspect-ratio", m_forceAspectRatio,
- (void*) 0);
- }
-}
-
-
-/*
- * Gstreamer message callback for catching general
- * messages and errors in stream.
- */
-gboolean MGstVideo::bus_cb(GstBus *bus, GstMessage *message, void *data)
-{
- Q_UNUSED(bus);
-
- MGstVideo* gstVideo = (MGstVideo*) data;
-
- // video stream has reached end
- if( GST_MESSAGE_TYPE(message) == GST_MESSAGE_EOS ) {
- if( gstVideo->m_looping ) {
- if( gstVideo->m_seekable ) {
- gstVideo->seek(0);
- } else {
- //TODO: Reset the video by some other means than seeking to 0
- }
- }
- else
- {
- gstVideo->setVideoState(MVideo::Stopped);
- }
- }
- // some error has happened
- else if( GST_MESSAGE_TYPE(message) == GST_MESSAGE_ERROR ) {
- GError *error = NULL;
- gst_message_parse_error(message, &error, NULL);
- mWarning("MGstVideo::bus_cb()") << "ERROR: " << error->message;
- g_error_free(error);
-
- // stop pipeline, we are in trouble
- return false;
- }
- else if ( GST_MESSAGE_TYPE(message)== GST_MESSAGE_STATE_CHANGED ) {
- if( GST_IS_PIPELINE(message->src) ) {
-
- GstState oldState, newState, pendingState;
- gst_message_parse_state_changed(message, &oldState, &newState, &pendingState);
- if( oldState == GST_STATE_READY && newState == GST_STATE_PAUSED ) {
- video_ready_cb(data);
- }
- }
- }
- return true;
-}
-
-/*
- * Called from msink when the natural size of video is known.
- */
-void MGstVideo::video_ready_cb(void* user_data)
-{
- if( user_data ) {
- MGstVideo* gstVideo = (MGstVideo*) user_data;
-
- //check if the video is seekable
- gstVideo->checkSeekable();
-
- if( gstVideo->m_storedState != MVideo::NotReady ) {
- //restore the stored state information
- gstVideo->seek(gstVideo->m_storedPosition);
- gstVideo->setVideoState(gstVideo->m_storedState);
- gstVideo->m_storedState = MVideo::NotReady;
- gstVideo->m_storedPosition = 0;
- }
- else {
- //automatically stop after buffering the first frame
- gstVideo->setVideoState(MVideo::Stopped);
- }
-
- emit gstVideo->videoReady();
- }
-}
-
-/*
- * Called from decodebin2 when unknown video format is encountered
- */
-void MGstVideo::unknownpad_cb(GstElement*/*bin*/,
- GstPad */*pad*/,
- GstCaps *caps,
- MGstVideo */*w*/)
-{
- GstStructure* type;
- type = gst_caps_get_structure(caps, 0);
- QString typeString = gst_structure_get_name(type);
- mWarning("MGstVideo::unknownpad_cb()") << typeString;
-}
-
-/*
- * Called from decodebin2 when known video format is encountered and it
- can be decoded to raw data automatically
- */
-void MGstVideo::newpad_cb(GstElement *decodebin,
- GstPad *pad,
- gboolean last,
- MGstVideo *w)
-{
- GstPad *sinkpad;
- GstCaps *caps;
- GstElement *sink;
- GstStructure *type;
- GstElement *bin;
-
- Q_UNUSED(decodebin);
- Q_UNUSED(last);
-
- caps = gst_pad_get_caps(pad);
- type = gst_caps_get_structure(caps, 0);
-
- QString typeString = gst_structure_get_name(type);
-
- //FIXME
- //Find compatible pads more accurately, add more error checking.
- if (g_strrstr(gst_structure_get_name(type), "video")) {
- bool yuv = false;
- if (g_strrstr(gst_structure_get_name(type), "yuv"))
- yuv = true;
-
- sink = w->makeSinks(yuv);
- w->m_format = yuv ? YUV : RGB;
-
- //FIXME:
- //Add ffmpegcolorspace plugin only when necessary
- if ( /*!yuv*//*!pad2*/true) {
- bin = gst_bin_new("video bin");
- GstElement *colorspace = gst_element_factory_make("ffmpegcolorspace", "ffmpegcolorspace");
-
- gst_bin_add(GST_BIN(bin), colorspace);
- gst_bin_add(GST_BIN(bin), sink);
- gst_element_link_pads(colorspace, "src", sink, "sink");
-
- GstPad *pad = gst_element_get_pad(colorspace, "sink");
-
- gst_element_add_pad(bin, gst_ghost_pad_new("sink", pad));
- gst_object_unref(pad);
-
- sink = bin;
- }
- } else if (g_strrstr(gst_structure_get_name(type), "audio")) {
- GstElement *vol;
-
- bin = gst_bin_new("audio bin");
- vol = w->makeVolume();
-
- sink = gst_element_factory_make("autoaudiosink", "sink");
-
- gst_bin_add(GST_BIN(bin), vol);
- gst_bin_add(GST_BIN(bin), sink);
- gst_element_link_pads(vol, "src", sink, "sink");
-
- GstPad *sinkpad = gst_element_get_compatible_pad(vol, pad, NULL);//gst_element_get_pad(vol, "sink");
-
- gst_element_add_pad(bin, gst_ghost_pad_new("sink", sinkpad));
- gst_object_unref(pad);
-
- sink = bin;
-
- } else {
- mWarning("MGstVideo::newpad_cb()") << "error creating sink for " << gst_structure_get_name(type);
- sink = NULL;
- }
-
- if (w->gst_elem_pipeline && sink) {
- gst_caps_unref(caps);
- gst_bin_add(GST_BIN_CAST(w->gst_elem_pipeline), sink);
- gst_element_set_state(sink, GST_STATE_PAUSED);
-
- sinkpad = gst_element_get_compatible_pad(sink, pad, NULL);//gst_element_get_pad(sink, "sink");
- if (sinkpad) {
- gst_pad_link(pad, sinkpad);
- gst_object_unref(sinkpad);
- }
- }
-}
-
-
-/*
- * Called from msink to render the current frame in video stream.
- */
-void MGstVideo::render_frame_cb(void* pointer, void* user_data)
-{
- if( user_data ) {
- //try to lock the mutex, if the we cannot lock it
- //a new frame is currently being rendered so no need
- //to create new one
- MGstVideo* gstVideo = (MGstVideo*) user_data;
- if( !gstVideo->lockFrameData() ) {
- mWarning("MGstVideo::render_frame_cb()") << "MUTEX LOCK CONFLICT!";
- gst_buffer_unref(GST_BUFFER(pointer));
- return;
- }
-
- //release old buffer and set new one
- if( gstVideo->gst_buffer ) {
- gst_buffer_unref(gstVideo->gst_buffer);
- gstVideo->gst_buffer = NULL;
- }
- gstVideo->gst_buffer = GST_BUFFER(pointer);
-
- gstVideo->unlockFrameData();
-
- emit gstVideo->frameReady();
- }
-}
-
-GstElement* MGstVideo::makeSinks(bool yuv)
-{
- if( gst_elem_videosink || gst_elem_xvimagesink ) {
- mWarning("MGstVideo::makeSink()") << "Sink already initialized. Call destroyPipeline() before initializing new sink.";
- return NULL;
- }
-
- //try to create xvimagesink, if it fails fallback to msink rendering
- gst_elem_xvimagesink = gst_element_factory_make("xvimagesink", "xvsink");
- if( gst_elem_xvimagesink && GST_IS_ELEMENT(gst_elem_xvimagesink) && m_renderTarget == XvSink ) {
- g_object_set(gst_elem_xvimagesink,
- "autopaint-colorkey", FALSE,
- "colorkey", m_colorKey.rgba() & 0x00FFFFFF,
- "force-aspect-ratio", m_forceAspectRatio,
- "draw-borders", TRUE,
- (void*) 0);
- gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(gst_elem_xvimagesink), m_winId);
- }else {
- mWarning("MGstVideo::makeSink()") << "xvimagesink doest not exist, falling back to texture rendering with msink.";
- }
-
- //setup textured video rendering using msink
- gst_elem_videosink = yuv ? m_gst_video_sink_yuv_new() : m_gst_video_sink_new();
- MGstVideoSink *msink = M_GST_VIDEO_SINK(gst_elem_videosink);
- msink->user_data = this;
- msink->frame_cb = render_frame_cb;
- msink->ready_cb = video_ready_cb;
-
- return activeSink();
-}
-
-GstElement* MGstVideo::activeSink()
-{
- if( m_renderTarget == XvSink && gst_elem_xvimagesink ) {
- m_renderTarget = XvSink;
- return gst_elem_xvimagesink;
- }
- else {
- m_renderTarget = MSink;
- return gst_elem_videosink;
- }
-}
-
-GstElement* MGstVideo::makeVolume()
-{
- gst_elem_volume = gst_element_factory_make("volume", "volume");
- setVolume(m_volume);
- setMuted(m_muted);
- return gst_elem_volume;
-}
-
-bool MGstVideo::constructPipeline()
-{
- destroyPipeline();
-
- bool ok = true;
-
- //create file source element
- gst_elem_source = gst_element_factory_make("filesrc", "file-source");
- if( gst_elem_source && GST_IS_ELEMENT(gst_elem_source) ) {
- g_object_set(G_OBJECT(gst_elem_source), "location", m_filename.toStdString().c_str(), NULL);
- }
- else {
- mWarning("MGstVideo::constructPipeline()") << "filesrc gstreamer plugin not found.";
- ok = false;
- }
-
- //create decoder element
- gst_elem_decoder = gst_element_factory_make("decodebin2", "decoder");
- if( gst_elem_decoder && GST_IS_ELEMENT(gst_elem_decoder) ) {
- g_signal_connect(gst_elem_decoder, "new-decoded-pad", G_CALLBACK(newpad_cb), this);
- g_signal_connect(gst_elem_decoder, "unknown-type", G_CALLBACK(unknownpad_cb), this);
- }
- else {
- mWarning("MGstVideo::constructPipeline()") << "decodebin2 gstreamer plugin not found.";
- ok = false;
- }
-
- //check if everything is still ok, if not do some cleanup and stop pipeline creation
- if( !ok ) {
- mWarning("MGstVideo::constructPipeline()") << "Core gstreamer plugin(s) are missing, cannot construct pipeline.";
- gst_object_unref(gst_elem_source);
- gst_object_unref(gst_elem_decoder);
- return false;
- }
-
- //create pipeline from source and decoder elements
- gst_elem_pipeline = gst_pipeline_new("m-gst-video");
- gst_bin_add_many(GST_BIN(gst_elem_pipeline), gst_elem_source, gst_elem_decoder, NULL);
- if( !gst_element_link_many(gst_elem_source, gst_elem_decoder, NULL) ) {
- mWarning("MGstVideo::constructPipeline()") << "Failed to link elements.";
- destroyPipeline();
- return false;
- }
-
- //setup callback for pipeline bus messages
- gst_messagebus = gst_pipeline_get_bus(GST_PIPELINE(gst_elem_pipeline));
- gst_bus_add_watch(gst_messagebus, bus_cb, this);
- gst_object_unref(gst_messagebus);
-
- //start buiffering, this is done to get the first frame of the video and
- //thus be able to parse video format information
- if( GST_STATE_CHANGE_FAILURE == gst_element_set_state(gst_elem_pipeline, GST_STATE_PAUSED) ) {
- mWarning("MGstVideo::constructPipeline()") << "Failed to start buffering.";
- destroyPipeline();
- return false;
- }
-
- return true;
-}
-
-void MGstVideo::destroyPipeline()
-{
- m_mutex.lock();
- //if( gst_elem_videosink ) {
- // MGstVideoSink* msink = M_GST_VIDEO_SINK(gst_elem_videosink);
- // msink->user_data = NULL;
- //}
-
- if( gst_elem_pipeline ) {
- gst_element_set_state(gst_elem_pipeline, GST_STATE_NULL);
- gst_object_unref(GST_OBJECT(gst_elem_pipeline));
-
- if( activeSink() == gst_elem_xvimagesink ) {
- if( gst_elem_videosink )
- gst_object_unref(GST_OBJECT(gst_elem_videosink));
- }
- else if( gst_elem_xvimagesink )
- gst_object_unref(GST_OBJECT(gst_elem_xvimagesink));
- }
-
- //TODO should some of these be destroyed as well?
- gst_elem_pipeline = NULL;
- gst_elem_decoder = NULL;
- gst_elem_source = NULL;
- gst_elem_volume = NULL;
- gst_elem_videosink = NULL;
- gst_elem_audiosink = NULL;
- gst_elem_xvimagesink = NULL;
-
- setVideoState(MVideo::NotReady);
-
- m_mutex.unlock();
-}
-
-void MGstVideo::checkSeekable()
-{
- if( gst_elem_pipeline ) {
- GstQuery *query;
- gboolean result;
- query = gst_query_new_seeking(GST_FORMAT_TIME);
- result = gst_element_query(gst_elem_pipeline, query);
- if( result ) {
- gboolean seekable;
- gst_query_parse_seeking(query, NULL, &seekable, NULL, NULL);
- m_seekable = seekable;
- }
- gst_query_unref(query);
- }
-}
-
diff --git a/src/views/video/mgstvideo.h b/src/views/video/mgstvideo.h
deleted file mode 100644
index 0b4c6207..00000000
--- a/src/views/video/mgstvideo.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * This file is part of libmeegotouch *
- *
- * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- *
- * Contact: Tomas Junnonen <tomas.junnonen@nokia.com>
- *
- * This software, including documentation, is protected by copyright
- * controlled by Nokia Corporation. All rights are reserved. Copying,
- * including reproducing, storing, adapting or translating, any or all of
- * this material requires the prior written consent of Nokia Corporation.
- * This material also contains confidential information which may not be
- * disclosed to others without the prior written consent of Nokia.
- */
-#ifndef MGSTVIDEO_P_H
-#define MGSTVIDEO_P_H
-
-#include <QObject>
-#include <QMutex>
-#include <QColor>
-
-#include <gst/gst.h>
-#include <gst/gstvalue.h>
-#include <gst/video/video.h>
-
-#include "mvideo.h"
-
-//! \internal
-
-class MGstVideo : public MVideo
-{
- Q_OBJECT
-
-public:
-
- enum RenderTarget
- {
- MSink,
- XvSink
- };
-
- MGstVideo();
- virtual ~MGstVideo();
-
- bool open(const QString& filename);
-
- bool isReady() const;
-
- void setVideoState(MVideo::State state);
- MVideo::State videoState() const;
-
- void seek(quint64 time);
- quint64 position() const;
- quint64 length() const;
-
- void setMuted(bool muted);
- bool isMuted() const;
- void setVolume(qreal volume);
- qreal volume() const;
-
- void setLooping(bool enabled) {m_looping = enabled;}
- bool isLooping() const {return m_looping;}
-
- QSize resolution() const;
-
- uchar* frameData() const;
- MVideo::DataFormat frameDataFormat() const;
-
- bool lockFrameData();
- void unlockFrameData();
-
- //gst and xv specific methods
- void setRenderTarget(MGstVideo::RenderTarget targetSink);
- MGstVideo::RenderTarget renderTarget();
-
- void expose();
- void setWinId(unsigned long id);
- unsigned long winId();
-
- void setColorKey(const QColor& key);
- QColor colorKey();
-
- void forceAspectRatio(bool forceAspectRatio);
-
-private:
-
- static gboolean bus_cb(GstBus *bus, GstMessage *message, void *data);
- static void video_ready_cb(void *user_data);
- static void unknownpad_cb( GstElement* bin,
- GstPad* pad,
- GstCaps* caps,
- MGstVideo* w);
- static void newpad_cb( GstElement* decodebin,
- GstPad* pad,
- gboolean last,
- MGstVideo* w);
- static void render_frame_cb(void* pointer, void* user_data);
-
- GstElement* makeSinks(bool yuv);
- GstElement* activeSink();
-
- GstElement* makeVolume();
-
- bool constructPipeline();
- void destroyPipeline();
-
- void checkSeekable();
-
- GstElement* gst_elem_pipeline;
- GstElement* gst_elem_source;
- GstElement* gst_elem_decoder;
- GstElement* gst_elem_volume;
-
- GstElement* gst_elem_audiosink;
-
- GstElement* gst_elem_videosink;
- GstElement* gst_elem_xvimagesink;
-
- GstBus* gst_messagebus;
- GstBuffer* gst_buffer;
-
- QString m_filename;
- bool m_looping;
- bool m_seekable;
- bool m_ready;
- bool m_muted;
- qreal m_volume;
- MVideo::State m_state;
- MVideo::DataFormat m_format;
-
- QMutex m_mutex;
-
- MGstVideo::RenderTarget m_renderTarget;
- MVideo::State m_storedState;
- quint64 m_storedPosition;
-
- unsigned long m_winId;
- QColor m_colorKey;
-
- bool m_forceAspectRatio;
-};
-
-//! \internal_end
-
-#endif
diff --git a/src/views/video/msink.c b/src/views/video/msink.c
deleted file mode 100644
index 8e85c6ab..00000000
--- a/src/views/video/msink.c
+++ /dev/null
@@ -1,141 +0,0 @@
-
-#include <gst/gst.h>
-#include <gst/video/video.h>
-
-#include "msink.h"
-
-static GstStaticPadTemplate sinktemplate
-= GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ IYUV, I420, YV12 }") ";" \
- GST_VIDEO_CAPS_RGBx ";" \
- GST_VIDEO_CAPS_BGRx ";" \
- GST_VIDEO_CAPS_RGB ";" \
- GST_VIDEO_CAPS_BGR));
-static GstStaticPadTemplate sinktemplate_rgb
-= GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB));
- /*GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx ";" \
- GST_VIDEO_CAPS_BGRx ";" \
- GST_VIDEO_CAPS_RGB ";" \
- GST_VIDEO_CAPS_BGR));*/
-static GstStaticPadTemplate sinktemplate_yuv
-= GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ IYUV, I420, YV12 }")));
-
-G_DEFINE_TYPE (MGstVideoSink, m_gst_video_sink, GST_TYPE_BASE_SINK)
-
-static void
-m_gst_video_sink_init (MGstVideoSink *sink)
-{
- sink->w = sink->h = 0;
- sink->frameskip = 1;
-}
-
-static GstFlowReturn
-m_gst_video_sink_render (GstBaseSink *bsink, GstBuffer *buffer)
-{
- MGstVideoSink *sink;
- static int n = 1;
-
- sink = M_GST_VIDEO_SINK (bsink);
-
- if (buffer == NULL || G_UNLIKELY (!GST_IS_BUFFER (buffer))) {
- return FALSE;
- }
-
- // take ownership
- gst_buffer_ref (buffer);
-
- if (--n==0) {
- sink->frame_cb (buffer, sink->user_data);
- n = sink->frameskip;
- }
- else {
- gst_buffer_unref (buffer);
- }
-
- return GST_FLOW_OK;
-}
-
-static gboolean
-m_gst_video_sink_set_caps (GstBaseSink *bsink,
- GstCaps *caps)
-{
-
- MGstVideoSink *sink;
- GstStructure *structure;
-
- sink = M_GST_VIDEO_SINK (bsink);
-
- if (sink->yuv_mode) {
- gst_caps_intersect
- (gst_static_pad_template_get_caps (&sinktemplate_yuv),
- caps);
- } else {
- gst_caps_intersect
- (gst_static_pad_template_get_caps (&sinktemplate_rgb),
- caps);
- }
-
- structure = gst_caps_get_structure (caps, 0);
-
- gst_structure_get_int (structure, "width", &sink->w);
- gst_structure_get_int (structure, "height", &sink->h);
-
- //sink->ready_cb(sink->user_data);
- return TRUE;
-}
-
-static GstCaps*
-m_gst_video_sink_get_caps (GstBaseSink *bsink)
-{
- MGstVideoSink *sink;
-
- sink = M_GST_VIDEO_SINK (bsink);
-
- if (sink->yuv_mode)
- return gst_static_pad_template_get_caps (&sinktemplate_yuv);
- else
- return gst_static_pad_template_get_caps (&sinktemplate_rgb);
-}
-
-
-static void
-m_gst_video_sink_class_init (MGstVideoSinkClass *klass)
-{
- GstBaseSinkClass *gstbase_sink_class = GST_BASE_SINK_CLASS (klass);
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gstbase_sink_class->render = m_gst_video_sink_render;
- gstbase_sink_class->preroll = m_gst_video_sink_render;
- gstbase_sink_class->set_caps = m_gst_video_sink_set_caps;
- gstbase_sink_class->get_caps = m_gst_video_sink_get_caps;
-
- gst_element_class_add_pad_template
- (element_class,
- gst_static_pad_template_get (&sinktemplate));
-}
-
-GstElement *
-m_gst_video_sink_new ()
-{
- GstElement *sink = g_object_new (M_GST_TYPE_VIDEO_SINK, NULL);
- M_GST_VIDEO_SINK (sink)->yuv_mode = 0;
-
- return sink;
-}
-
-GstElement *
-m_gst_video_sink_yuv_new ()
-{
- GstElement *sink = g_object_new (M_GST_TYPE_VIDEO_SINK, NULL);
- M_GST_VIDEO_SINK (sink)->yuv_mode = 1;
-
- return sink;
-}
diff --git a/src/views/video/msink.h b/src/views/video/msink.h
deleted file mode 100644
index b23a31be..00000000
--- a/src/views/video/msink.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (directui@nokia.com)
-**
-** This file is part of libmeegotouch.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at directui@nokia.com.
-**
-** This library is free software; you can redistribute it and/or
-** modify it 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.
-**
-****************************************************************************/
-
-#ifndef _HAVE_M_GST_VIDEO_SINK_H
-#define _HAVE_M_GST_VIDEO_SINK_H
-
-#include <glib-object.h>
-#include <gst/base/gstbasesink.h>
-#include <gst/gstplugin.h>
-
-//! \cond
-G_BEGIN_DECLS
-
-#define M_GST_TYPE_VIDEO_SINK m_gst_video_sink_get_type()
-
-#define M_GST_VIDEO_SINK(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- M_GST_TYPE_VIDEO_SINK, MGstVideoSink))
-
-#define M_GST_VIDEO_SINK_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- M_GST_TYPE_VIDEO_SINK, MGstVideoSinkClass))
-
-#define M_GST_IS_VIDEO_SINK(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- M_GST_TYPE_VIDEO_SINK))
-
-#define M_GST_IS_VIDEO_SINK_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- M_GST_TYPE_VIDEO_SINK))
-
-#define M_GST_VIDEO_SINK_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- M_GST_TYPE_VIDEO_SINK, MGstVideoSinkClass))
-
-typedef struct _MGstVideoSink MGstVideoSink;
-typedef struct _MGstVideoSinkClass MGstVideoSinkClass;
-
-/*!
- * \class MGstVideoSink
- * \brief MGstVideoSink is a simple video sink with a render callback function.
- *
- * MGstVideoSink provides callbacks for custom video rendering offering gstbuffer
- * to the frame_cb function.
- */
-struct _MGstVideoSink {
- GstBaseSink parent;
-
- /*! render frame callback function
- * \param void pointer to GstBuffer
- * \param void pointer to user specified data
- */
- void (*frame_cb)(void *, void *);
-
- /*! render frame callback function
- * \param void pointer to user specified data
- */
- void (*ready_cb)(void *);
-
- void *user_data;
-
- int frameskip;
- guint yuv_mode;
-
- int w;
- int h;
-};
-
-struct _MGstVideoSinkClass {
- GstBaseSinkClass parent_class;
-};
-
-GType m_gst_video_sink_get_type(void) G_GNUC_CONST;
-
-/*!
- * \brief Constructor - creates RGB|BGR sink
- */
-GstElement *m_gst_video_sink_new();
-
-/*!
- * \brief Constructor - creates YUV sink
- */
-GstElement *m_gst_video_sink_yuv_new();
-
-
-G_END_DECLS
-//! \endcond
-
-#endif
diff --git a/src/views/video/mvideowidgetview.cpp b/src/views/video/mvideowidgetview.cpp
deleted file mode 100644
index c683b930..00000000
--- a/src/views/video/mvideowidgetview.cpp
+++ /dev/null
@@ -1,660 +0,0 @@
-/* * This file is part of libmeegotouch *
- *
- * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- *
- * Contact: Tomas Junnonen <tomas.junnonen@nokia.com>
- *
- * This software, including documentation, is protected by copyright
- * controlled by Nokia Corporation. All rights are reserved. Copying,
- * including reproducing, storing, adapting or translating, any or all of
- * this material requires the prior written consent of Nokia Corporation.
- * This material also contains confidential information which may not be
- * disclosed to others without the prior written consent of Nokia.
- */
-
-#include "mvideowidgetview.h"
-#include "mvideowidgetview_p.h"
-#include "mvideowidget.h"
-
-#include "mapplication.h"
-#include "mapplicationwindow.h"
-
-#include <gst/gst.h>
-#include <gst/gstvalue.h>
-#include <gst/video/video.h>
-
-#include "mgles2renderer.h"
-#include "mgstvideo.h"
-
-#include "msink.h"
-#include "mdebug.h"
-
-#include <mscene.h>
-
-MVideoWidgetViewPrivate::MVideoWidgetViewPrivate()
- : m_useSingleYuvTexture(false),
- image(NULL),
- bits(NULL),
- scaleOffsets(NULL),
- m_needFillBg(false),
- m_fullscreen(false),
- m_gstVideo(new MGstVideo()),
- m_updateEnabled(false)
-{
- m_textures[0] = 0;
- m_textures[1] = 0;
- m_textures[2] = 0;
-
- qRegisterMetaType< QList<const char*> >("QList<const char*>");
-#ifdef M_USE_OPENGL
- glGenTextures(3, &m_textures[0]);
-#endif
-}
-
-MVideoWidgetViewPrivate::~MVideoWidgetViewPrivate()
-{
- delete image;
- delete[] bits;
- delete[] scaleOffsets;
-
- delete m_gstVideo;
-
-#ifdef M_USE_OPENGL
- glDeleteTextures(3, &m_textures[0]);
-#endif
-}
-
-const MVideoWidgetModel* MVideoWidgetViewPrivate::model() const
-{
- Q_Q(const MVideoWidgetView);
- return q->model();
-}
-
-MVideoWidgetModel* MVideoWidgetViewPrivate::model()
-{
- Q_Q(MVideoWidgetView);
- return q->model();
-}
-
-void MVideoWidgetViewPrivate::update()
-{
- Q_Q(MVideoWidgetView);
- if( m_updateEnabled )
- q->update();
-}
-
-void MVideoWidgetViewPrivate::updateGeometry()
-{
- Q_Q(MVideoWidgetView);
- q->updateGeometry();
-}
-
-void MVideoWidgetViewPrivate::videoReady()
-{
- model()->setLength(m_gstVideo->length());
-
- updateVideoGeometry();
- updateGeometry();
- update();
-}
-
-void MVideoWidgetViewPrivate::frameReady()
-{
- model()->setPositionNoEmit(m_gstVideo->position());
-
- if( m_updateEnabled ) {
- if( MApplication::softwareRendering()) {
- blitSwFrame();
- } else {
- #ifdef M_USE_OPENGL
- blitGLFrame();
- #else
- blitSwFrame();
- #endif
- }
- update();
- }
-}
-
-void MVideoWidgetViewPrivate::stateChanged()
-{
- model()->setState(m_gstVideo->videoState());
-}
-
-
-void MVideoWidgetViewPrivate::updateVideoGeometry()
-{
- Q_Q(MVideoWidgetView);
-
- QSize videoSize = m_gstVideo->resolution();
- QSize widgetSize = q->size().toSize();
-
- if( model()->scaleMode() == MVideoWidgetModel::ScaleToFit ) {
- if( model()->aspectRatioMode() == MVideoWidgetModel::AspectRatioOriginal ) {
- //scale but preserve the original aspect ratio
- videoSize.scale(widgetSize, Qt::KeepAspectRatio);
- qreal dx = (widgetSize.width() - videoSize.width()) / 2.0;
- qreal dy = (widgetSize.height() - videoSize.height()) / 2.0;
- m_scaledVideoRect.setRect(dx, dy, videoSize.width(), videoSize.height());
- m_needFillBg = widgetSize != videoSize;
- }
- else {
- //scale the video to match exactly the widget's size
- m_scaledVideoRect.setRect(0, 0, widgetSize.width(), widgetSize.height());
- m_needFillBg = false;
- }
- }
- else {
- //do not scale just center the video inside the widget
- qreal dx = (widgetSize.width() - videoSize.width()) / 2.0;
- qreal dy = (widgetSize.height() - videoSize.height()) / 2.0;
- m_scaledVideoRect.setRect(dx, dy, videoSize.width(), videoSize.height());
- m_needFillBg = widgetSize != videoSize;
- }
-}
-
-void MVideoWidgetViewPrivate::blitGLFrame()
-{
- if( !m_gstVideo->frameData() )
- return;
-
- //try to lock the frame data if the we cannot lock it
- //a new frame is currently being received and there will update
- //call when the new frame has been completely received so we
- //can safely skip the new frame texture creation for now
- if( !m_gstVideo->lockFrameData() ) {
- mWarning("MVideoWidgetViewPrivate::blitGLFrame()") << "MUTEX LOCK CONFLICT!";
- return;
- }
-
- //create texture from the data
- if( m_gstVideo->frameDataFormat() == MGstVideo::RGB ) {
- blitRgbTexture(m_gstVideo->frameData(), m_gstVideo->resolution().width(), m_gstVideo->resolution().height());
- } else {
- m_useSingleYuvTexture ? blitSingleYuvTexture(m_gstVideo->frameData(), m_gstVideo->resolution().width(), m_gstVideo->resolution().height()) :
- blitMultiYuvTexture(m_gstVideo->frameData(), m_gstVideo->resolution().width(), m_gstVideo->resolution().height());
- }
-
- m_gstVideo->unlockFrameData();
-}
-
-void MVideoWidgetViewPrivate::blitRgbTexture(const uchar* data, int width, int height)
-{
-#ifdef M_USE_OPENGL
- GLuint target = GL_TEXTURE_2D;
- GLuint format = GL_RGB;
- glBindTexture(target, m_textures[0]);
- glTexImage2D(target, 0, format, width, height, 0, format,
- GL_UNSIGNED_BYTE, data);
-#else
- Q_UNUSED(data)
- Q_UNUSED(width)
- Q_UNUSED(height)
-#endif
-}
-
-void MVideoWidgetViewPrivate::blitMultiYuvTexture(const uchar* data, int width, int height)
-{
-#ifdef M_USE_OPENGL
- GLuint target = GL_TEXTURE_2D;
- GLuint format = GL_LUMINANCE;
-
- int w[3] = {width, width / 2, width / 2};
- int h[3] = {height, height / 2, height / 2};
- int offs[3] = {0, width*height, width*height*5 / 4 };
- for (int i = 0; i < 3; ++i) {
- glBindTexture(target, m_textures[i]);
- glTexImage2D(target, 0, format, w[i], h[i], 0,
- GL_LUMINANCE, GL_UNSIGNED_BYTE, data + offs[i]);
- }
-#else
- Q_UNUSED(data)
- Q_UNUSED(width)
- Q_UNUSED(height)
-#endif
-}
-
-void MVideoWidgetViewPrivate::blitSingleYuvTexture(const uchar* data, int width, int height)
-{
-#ifdef M_USE_OPENGL
- const uchar *sp = data;
- uchar *texdata = new uchar[width * height * 3];
- uchar *dp = texdata;
-
- //do some precalculations for indexing the yuv data buffer
- int w_x_h = width * height;
- int w_x_h_div_4 = w_x_h / 4;
- int w_div_2 = width / 2;
-
- for (int y = 0; y < height; ++y) {
- int idx = y / 2 * w_div_2;
-
- for (int x = 0; x < width; ++x, dp += 3) {
- int x_div_2 = x / 2;
-
- // find yuv components from yuv420
- uchar y_val = sp[y * width + x];
- uchar u_val = sp[idx + x_div_2 + w_x_h];
- uchar v_val = sp[idx + x_div_2 + w_x_h + w_x_h_div_4];
-
- //fill texture data buffer
- dp[0] = y_val;
- dp[1] = u_val;
- dp[2] = v_val;
- }
- }
-
- //create the actual gl texture from the data
- GLuint target = GL_TEXTURE_2D;
- GLuint format = GL_RGB;
- glBindTexture(target, m_textures[0]);
- glTexImage2D(target, 0, format, width, height, 0,
- format, GL_UNSIGNED_BYTE, texdata);
- delete[] texdata;
-#else
- Q_UNUSED(data)
- Q_UNUSED(width)
- Q_UNUSED(height)
-#endif
-}
-
-/*
- * Precalculates a linear scale table for software blit.
- */
-static const int*
-calc_linear_scale(int src_w, int src_h, int dst_w, int dst_h)
-{
- int *table = new int[dst_w * dst_h];
- for (int y = 0, i = 0; y < dst_h; ++y) {
- int s_scan = ((y * src_h) / dst_h) * (src_w * 3);
- for (int x = 0; x < dst_w; ++x, ++i) {
- table[i] = s_scan + ((x * src_w) / dst_w) * 3;
- }
- }
- return table;
-}
-
-void MVideoWidgetViewPrivate::blitSwFrame()
-{
- if( !m_gstVideo->frameData() )
- return;
-
- //try to lock the frame data if the we cannot lock it
- //a new frame is currently being received and there will update
- //call when the new frame has been completely received so we
- //can safely skip the new frame texture creation for now
- if( !m_gstVideo->lockFrameData() ) {
- mWarning("MVideoWidgetViewPrivate::blitSwFrame()") << "MUTEX LOCK CONFLICT!";
- return;
- }
-
- blit(m_gstVideo->frameData(), m_gstVideo->resolution().width(), m_gstVideo->resolution().height());
-
- m_gstVideo->unlockFrameData();
-}
-
-/*
- * Prepare software blit, set correct image size, create
- * buffers & scaling offset table.
- */
-void MVideoWidgetViewPrivate::prepareBlit(int w, int h)
-{
- if (image && (image->width() != w || image->height() != h)) {
- delete image;
- delete[] bits;
- image = NULL;
- bits = NULL;
- }
-
- if (!image) {
- if (scaleOffsets)
- delete[] scaleOffsets;
-
- scaleOffsets = calc_linear_scale(m_gstVideo->resolution().width(), m_gstVideo->resolution().height(), w, h);
-
- bits = new uchar[w * h * 4];
- image = new QImage(bits, w, h, QImage::Format_RGB32);
- image->fill(0);
- }
-}
-
-/*
- * Blits the video frame using software rendering. Uses the
- * scale offset table precalculated in prepareBlit()
- */
-void MVideoWidgetViewPrivate::blit(const uchar* data, int w, int h)
-{
- QSize videoSize = m_gstVideo->resolution();
-
- //FIXME: non scaling method crashes currently.
- /*if( videoSize.width() == w && videoSize.height() == h ) {
- //blit without scaling
- blit(data);
- return;
- }else*/
- if (w > videoSize.width() || h > videoSize.height()) {
- // only downscaling supported
- mWarning("MVideoWidgetPrivate::blit()") << "error - upscaling not supported with sw rendering";
- return;
- }
-
- prepareBlit(w, h);
-
- // for each pixel in video frame
- uchar *sp, *dp;
- dp = bits;
- for (int i = 0, x = 0, y = 0; i < w*h; ++i, ++x, dp += 4) {
- sp = (uchar*)data + scaleOffsets[i];
- if (m_gstVideo->frameDataFormat() == MGstVideo::RGB) {
- // BGR -> RGB
- dp[0] = sp[2];
- dp[1] = sp[1];
- dp[2] = sp[0];
- } else {
-
- if (x == w) {
- x = 0;
- ++y;
- }
-
- int xx = (x * videoSize.width()) / w;
- int yy = (y * videoSize.height()) / h;
-
- // YUV420->RGB implementation (http://en.wikipedia.org/wiki/YUV#Y.27UV444)
- const uchar *srcp = data;
- // find yuv components from yuv420
- int y_val = srcp[yy * videoSize.width() + xx];
- int u_val = srcp[(yy/2) * (videoSize.width()/2) + xx/2 + videoSize.width()*videoSize.height()];
- int v_val = srcp[(yy/2) * (videoSize.width()/2) + xx/2 + videoSize.width()*videoSize.height() + ((videoSize.width()*videoSize.height())/4)];
-
- // fixed point yuv -> rgb conversion
- int r = (298 * (y_val - 16) + 409 * (v_val - 128) + 128) >> 8;
- int g = (298 * (y_val - 16) - 100 * (u_val - 128) - 208 * (v_val - 128) + 128) >> 8;
- int b = (298 * (y_val - 16) + 516 * (u_val - 128) + 128) >> 8;
-
- dp[0] = CLAMP(b, 0, 255);
- dp[1] = CLAMP(g, 0, 255);
- dp[2] = CLAMP(r, 0, 255);
- }
- }
-
- //force change of QImage::cacheKey(), to make sure the gl texture caching works.
- image->setPixel(0,0, image->pixel(0,0));
-}
-
-/*
- * Blits the video frame using software rendering
- * without any scaling.
- */
-void MVideoWidgetViewPrivate::blit(const uchar* data)
-{
- QSize videoSize = m_gstVideo->resolution();
- prepareBlit(videoSize.width(), videoSize.height());
-
- const uchar *sp = data;
- uchar *dp = bits;
- for (int x = 0, y = 0; y < videoSize.height(); ++x, sp += 3, dp += 4) {
-
- if (m_gstVideo->frameDataFormat() == MGstVideo::RGB) {
- // BGR -> RGB
- dp[0] = sp[2];
- dp[1] = sp[1];
- dp[2] = sp[0];
- } else {
- // YUV420->RGB implementation (http://en.wikipedia.org/wiki/YUV#Y.27UV444)
-
- // find yuv components from yuv420
- int y_val = sp[y * videoSize.width() + x];
- int u_val = sp[(y/2) * (videoSize.width()/2) + x/2 + videoSize.width()*videoSize.height()];
- int v_val = sp[(y/2) * (videoSize.width()/2) + x/2 + videoSize.width()*videoSize.height() + ((videoSize.width()*videoSize.height())/4)];
-
- // fixed point yuv -> rgb conversion
- int r = (298 * (y_val - 16) + 409 * (v_val - 128) + 128) >> 8;
- int g = (298 * (y_val - 16) - 100 * (u_val - 128) - 208 * (v_val - 128) + 128) >> 8;
- int b = (298 * (y_val - 16) + 516 * (u_val - 128) + 128) >> 8;
-
- dp[0] = CLAMP(b, 0, 255);
- dp[1] = CLAMP(g, 0, 255);
- dp[2] = CLAMP(r, 0, 255);
- }
-
- if (x == videoSize.width()) {
- x = 0;
- ++y;
- }
- }
-}
-
-unsigned long MVideoWidgetViewPrivate::currentWinId() const
-{
- return MApplication::activeApplicationWindow()->viewport()->effectiveWinId();
-}
-
-void MVideoWidgetViewPrivate::_q_enableVisualUpdates()
-{
- m_updateEnabled = true;
-}
-
-void MVideoWidgetViewPrivate::_q_disableVisualUpdates()
-{
- m_updateEnabled = false;
-}
-
-MVideoWidgetView::MVideoWidgetView(MVideoWidget* controller) :
- MWidgetView(* new MVideoWidgetViewPrivate, controller)
-{
- Q_D(MVideoWidgetView);
- connect(d->m_gstVideo, SIGNAL(videoReady()),
- SLOT(videoReady()));
- connect(d->m_gstVideo, SIGNAL(frameReady()),
- SLOT(frameReady()));
- connect(d->m_gstVideo, SIGNAL(stateChanged()),
- SLOT(stateChanged()));
-
- connect(controller, SIGNAL(displayEntered()),SLOT(_q_enableVisualUpdates()));
- connect(controller, SIGNAL(displayExited()), SLOT(_q_disableVisualUpdates()));
-}
-
-MVideoWidgetView::MVideoWidgetView(MVideoWidgetViewPrivate &dd, MVideoWidget *controller) :
- MWidgetView(dd, controller)
-{
- Q_D(MVideoWidgetView);
- connect(d->m_gstVideo, SIGNAL(videoReady()),
- SLOT(videoReady()));
- connect(d->m_gstVideo, SIGNAL(frameReady()),
- SLOT(frameReady()));
- connect(d->m_gstVideo, SIGNAL(stateChanged()),
- SLOT(stateChanged()));
-
- connect(controller, SIGNAL(displayEntered()),SLOT(_q_enableVisualUpdates()));
- connect(controller, SIGNAL(displayExited()), SLOT(_q_disableVisualUpdates()));
-}
-
-MVideoWidgetView::~MVideoWidgetView()
-{
-}
-
-void MVideoWidgetView::drawContents(QPainter* painter, const QStyleOptionGraphicsItem* option) const
-{
- Q_UNUSED(option);
-
- Q_D(const MVideoWidgetView);
-
- if( d->m_gstVideo->renderTarget() == MGstVideo::MSink ) {
- if (d->m_needFillBg && style()->backgroundColor().isValid()) {
- painter->fillRect(boundingRect(), style()->backgroundColor());
- }
-
- if( !d->m_gstVideo->isReady() )
- return;
-
- MGLES2Renderer* r = MGLES2Renderer::instance();
- if( r ) {
- bool yuv = d->m_gstVideo->frameDataFormat() == MGstVideo::YUV;
- if( yuv ) {
- if( d->m_useSingleYuvTexture ) {
- r->begin(painter, r->getShaderProgram(M_SHADER_SOURCE_DIR "/yuv1.frag" ));
- r->bindTexture(d->m_textures[0], QSize(-1,-1), 0, "textureYUV");
- } else {
- r->begin(painter, r->getShaderProgram(M_SHADER_SOURCE_DIR "/yuv3.frag"));
- r->bindTexture(d->m_textures[0], QSize(-1,-1), 0, "textureY");
- r->bindTexture(d->m_textures[1], QSize(-1,-1), 1, "textureU");
- r->bindTexture(d->m_textures[2], QSize(-1,-1), 2, "textureV");
- }
- } else {
- r->begin(painter);
- r->bindTexture(d->m_textures[0]);
- }
- r->setInvertTexture(true);
- r->draw(d->m_scaledVideoRect.toRect());
- r->end();
- }
- else if( d->image ) {
- // SW rendering
- painter->drawImage(d->m_scaledVideoRect.toRect(), *d->image);
- }
- } else {
- painter->fillRect(boundingRect(), style()->colorKey());
- unsigned long id = d->currentWinId();
- if( d->m_gstVideo->winId() != id && id != 0 )
- d->m_gstVideo->setWinId(id);
- d->m_gstVideo->expose();
- }
-}
-
-QSizeF MVideoWidgetView::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const
-{
- Q_D(const MVideoWidgetView);
- Q_UNUSED(constraint);
-
- if( d->m_gstVideo->isReady() ) {
- if (which == Qt::PreferredSize) {
- MWindow* w = MApplication::activeWindow();
- return model()->fullscreen() ? w->visibleSceneSize() : d->m_gstVideo->resolution();
- }
- }
- return QSizeF(-1, -1);
-}
-
-void MVideoWidgetView::resizeEvent(QGraphicsSceneResizeEvent* event)
-{
- Q_UNUSED(event);
- Q_D(MVideoWidgetView);
- d->updateVideoGeometry();
-}
-
-void MVideoWidgetView::applyStyle()
-{
- Q_D(MVideoWidgetView);
-
- if( model()->fullscreen() ) {
- style().setModeFullscreen();
- d->m_gstVideo->setColorKey(style()->colorKey());
- }
- else {
- style().setModeDefault();
- }
-
- MWidgetView::applyStyle();
-
- d->update();
-}
-
-void MVideoWidgetView::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_UNUSED(event);
-}
-
-void MVideoWidgetView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_UNUSED(event);
-}
-
-void MVideoWidgetView::cancelEvent(MCancelEvent *event)
-{
- Q_UNUSED(event);
-}
-
-void MVideoWidgetView::updateData(const QList<const char*>& modifications)
-{
- Q_D(MVideoWidgetView);
-
- MWidgetView::updateData(modifications);
-
- const char* member;
- foreach(member, modifications) {
- if(member == MVideoWidgetModel::Filename ) {
- model()->setLength(0);
- if( !d->m_gstVideo->open(model()->filename()) ) {
- }
- }
- else if( member == MVideoWidgetModel::State ) {
- d->m_gstVideo->setVideoState(model()->state());
- }
- else if( member == MVideoWidgetModel::Position ) {
- d->m_gstVideo->seek(model()->position());
- d->update();
- }
- else if( member == MVideoWidgetModel::Looping ) {
- d->m_gstVideo->setLooping(model()->looping());
- }
- else if( member == MVideoWidgetModel::Muted ) {
- d->m_gstVideo->setMuted(model()->muted());
- }
- else if( member == MVideoWidgetModel::Volume ) {
- d->m_gstVideo->setVolume(model()->volume());
- }
- else if( member == MVideoWidgetModel::Fullscreen ) {
- applyStyle();
-
- if( model()->fullscreen() ) {
- d->m_gstVideo->setWinId(d->currentWinId());
- d->m_gstVideo->setRenderTarget(MGstVideo::XvSink);
- }
- else {
- d->m_gstVideo->setRenderTarget(MGstVideo::MSink);
- }
-
- updateGeometry();
- d->update();
- }
- else if( member == MVideoWidgetModel::ScaleMode ) {
- d->updateVideoGeometry();
- d->update();
- }
- else if( member == MVideoWidgetModel::AspectRatioMode ) {
- d->m_gstVideo->forceAspectRatio(model()->aspectRatioMode() == MVideoWidgetModel::AspectRatioOriginal);
- d->updateVideoGeometry();
- d->update();
- }
- }
-}
-
-void MVideoWidgetView::setupModel()
-{
- MWidgetView::setupModel();
-
- Q_D(MVideoWidgetView);
-
- applyStyle();
-
- if( model()->fullscreen() ) {
- d->m_gstVideo->setWinId(d->currentWinId());
- d->m_gstVideo->setRenderTarget(MGstVideo::XvSink);
- }
- else {
- d->m_gstVideo->setRenderTarget(MGstVideo::MSink);
- }
-
- d->m_gstVideo->forceAspectRatio(model()->aspectRatioMode() == MVideoWidgetModel::AspectRatioOriginal);
-
- d->m_gstVideo->setLooping(model()->looping());
- d->m_gstVideo->open(model()->filename());
-
- updateGeometry();
- d->update();
-}
-
-M_REGISTER_VIEW_NEW(MVideoWidgetView, MVideoWidget)
-#include "moc_mvideowidgetview.cpp"
diff --git a/src/views/video/mvideowidgetview.h b/src/views/video/mvideowidgetview.h
deleted file mode 100644
index 2bc064e3..00000000
--- a/src/views/video/mvideowidgetview.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* * This file is part of libmeegotouch *
- *
- * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- *
- * Contact: Tomas Junnonen <tomas.junnonen@nokia.com>
- *
- * This software, including documentation, is protected by copyright
- * controlled by Nokia Corporation. All rights are reserved. Copying,
- * including reproducing, storing, adapting or translating, any or all of
- * this material requires the prior written consent of Nokia Corporation.
- * This material also contains confidential information which may not be
- * disclosed to others without the prior written consent of Nokia.
- */
-#ifndef MVIDEOWIDGETVIEW_H
-#define MVIDEOWIDGETVIEW_H
-
-#include <mwidgetview.h>
-#include <mvideowidgetmodel.h>
-#include <mvideowidgetstyle.h>
-
-class MVideoWidgetViewPrivate;
-class MVideoWidget;
-
-class QGraphicsSceneResizeEvent;
-
-/*!
- \class MVideoWidgetView
- \brief View class for a video frame.
-
- \ingroup views
-
- \section MVideoWidgetViewOverview Overview
- Standard view for displaying video frames without any other graphical
- components.
-
- \section MVideoWidgetViewInteractions Interactions
-
- \section MVideoWidgetViewOpenIssues Open issues
-
- \sa MVideoWidget MVideoWidgetStyle
-*/
-class M_VIEWS_EXPORT MVideoWidgetView : public MWidgetView
-{
- Q_OBJECT
- M_VIEW(MVideoWidgetModel, MVideoWidgetStyle)
-
-public:
-
- /*!
- \brief Constructs the view.
- \param Pointer to the controller.
- */
- MVideoWidgetView(MVideoWidget* controller);
-
- /*!
- \brief Destructs the view.
- */
- virtual ~MVideoWidgetView();
-
- //! \reimp
- virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
- //! \reimp_end
-
-protected:
-
- //! \reimp
- virtual void drawContents(QPainter* painter, const QStyleOptionGraphicsItem* option) const;
- virtual void applyStyle();
- virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
- virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
- virtual void setupModel();
- virtual void cancelEvent(MCancelEvent* event);
- virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint = QSizeF()) const;
- //! \reimp_end
-
- //! \cond
- MVideoWidgetView(MVideoWidgetViewPrivate& dd, MVideoWidget* controller);
- //! \endcond
-
-protected Q_SLOTS:
- //! \reimp
- virtual void updateData(const QList<const char*>& modifications);
- //! \reimp_end
-
-private:
- Q_DISABLE_COPY(MVideoWidgetView)
- Q_DECLARE_PRIVATE(MVideoWidgetView)
-
- Q_PRIVATE_SLOT(d_func(), void videoReady())
- Q_PRIVATE_SLOT(d_func(), void frameReady())
- Q_PRIVATE_SLOT(d_func(), void stateChanged())
-
- Q_PRIVATE_SLOT(d_func(), void _q_enableVisualUpdates())
- Q_PRIVATE_SLOT(d_func(), void _q_disableVisualUpdates())
-};
-
-#endif
diff --git a/src/views/video/mvideowidgetview_p.h b/src/views/video/mvideowidgetview_p.h
deleted file mode 100644
index 89940caf..00000000
--- a/src/views/video/mvideowidgetview_p.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* This file is part of libmeegotouch
- *
- * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- *
- * Contact: Tomas Junnonen <tomas.junnonen@nokia.com>
- *
- * This software, including documentation, is protected by copyright
- * controlled by Nokia Corporation. All rights are reserved. Copying,
- * including reproducing, storing, adapting or translating, any or all of
- * this material requires the prior written consent of Nokia Corporation.
- * This material also contains confidential information which may not be
- * disclosed to others without the prior written consent of Nokia.
- */
-#ifndef MVIDEOWIDGETVIEW_P_H
-#define MVIDEOWIDGETVIEW_P_H
-
-#include "private/mwidgetview_p.h"
-
-class MVideoWidgetView;
-class MVideoWidgetModel;
-class MGstVideo;
-class QGLShaderProgram;
-
-class MVideoWidgetViewPrivate : public MWidgetViewPrivate
-{
-public:
-
- Q_DECLARE_PUBLIC(MVideoWidgetView)
-
- MVideoWidgetViewPrivate();
- virtual ~MVideoWidgetViewPrivate();
-
- const MVideoWidgetModel* model() const;
- MVideoWidgetModel* model();
-
- void update();
- void updateGeometry();
-
- void videoReady();
- void frameReady();
- void stateChanged();
-
- void updateVideoGeometry();
-
- void blitGLFrame();
- void blitRgbTexture(const uchar* data, int width, int height);
- void blitMultiYuvTexture(const uchar* data, int width, int height);
- void blitSingleYuvTexture(const uchar* data, int width, int height);
-
- void blitSwFrame();
- void prepareBlit(int w, int h);
- void blit(const uchar* data);
- void blit(const uchar* data, int w, int h);
-
- unsigned long currentWinId() const;
-
- void _q_enableVisualUpdates();
- void _q_disableVisualUpdates();
-
- bool m_useSingleYuvTexture;
- unsigned int m_textures[3];
-
- QImage *image;
- uchar *bits;
- const int *scaleOffsets;
-
- bool m_needFillBg;
-
- QString m_videoFilename;
-
- QRectF m_scaledVideoRect;
-
- bool m_fullscreen;
-
- MGstVideo* m_gstVideo;
-
- bool m_updateEnabled;
-};
-
-#endif
diff --git a/src/views/video/video.pri b/src/views/video/video.pri
deleted file mode 100644
index 921a8791..00000000
--- a/src/views/video/video.pri
+++ /dev/null
@@ -1,17 +0,0 @@
-VIDEO_SRC_DIR = ./video
-INCLUDEPATH +=./video
-
-contains( DEFINES, HAVE_GSTREAMER) {
- PUBLIC_HEADERS += \
- $$VIDEO_SRC_DIR/mvideowidgetview.h \
-
- PRIVATE_HEADERS += \
- $$VIDEO_SRC_DIR/mvideowidgetview_p.h \
- $$VIDEO_SRC_DIR/msink.h \
- $$VIDEO_SRC_DIR/mgstvideo.h \
-
- SOURCES += \
- $$VIDEO_SRC_DIR/mvideowidgetview.cpp \
- $$VIDEO_SRC_DIR/msink.c \
- $$VIDEO_SRC_DIR/mgstvideo.cpp \
-}
diff --git a/src/views/views.pro b/src/views/views.pro
index 316f0241..01807a69 100644
--- a/src/views/views.pro
+++ b/src/views/views.pro
@@ -12,7 +12,6 @@ INCLUDEPATH += \
../corelib/widgets/views \
../corelib/widgets \
../corelib/core \
- ../corelib/video \
../corelib/.gen \
include(effects/effects.pri)
@@ -20,7 +19,6 @@ include(views.pri)
include(widgets/widgets.pri)
include(animations/animations.pri)
include(style/style.pri)
-include(video/video.pri)
LIBS += $$mAddLibrary(meegotouchcore)
SOURCES += mviewslibrary.cpp
diff --git a/tests/tests.pro b/tests/tests.pro
index 65b5071b..e5acc754 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -175,7 +175,6 @@ SUBDIRS = \
ut_mextensionhandle \
ut_mextensionhandleview \
ut_mtapandholdrecognizer \
- ut_mvideowidget \
ut_mservicefwgen \
ut_mpanrecognizer \
ut_mstatusbarview \
diff --git a/tests/ut_mvideowidget/.gitignore b/tests/ut_mvideowidget/.gitignore
deleted file mode 100644
index 3fbefa5a..00000000
--- a/tests/ut_mvideowidget/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-ut_mvideowidget
diff --git a/tests/ut_mvideowidget/test.mov b/tests/ut_mvideowidget/test.mov
deleted file mode 100644
index b1910f94..00000000
--- a/tests/ut_mvideowidget/test.mov
+++ /dev/null
Binary files differ
diff --git a/tests/ut_mvideowidget/ut_mvideowidget.cpp b/tests/ut_mvideowidget/ut_mvideowidget.cpp
deleted file mode 100644
index bddadf29..00000000
--- a/tests/ut_mvideowidget/ut_mvideowidget.cpp
+++ /dev/null
@@ -1,272 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (directui@nokia.com)
-**
-** This file is part of libmeegotouch.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at directui@nokia.com.
-**
-** This library is free software; you can redistribute it and/or
-** modify it 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.
-**
-****************************************************************************/
-
-#include "ut_mvideowidget.h"
-#include "mvideowidget.h"
-#include "mvideowidgetview.h"
-
-#include <mapplication.h>
-
-ut_mvideowidget::ut_mvideowidget()
- : m_subject(NULL),
- app(NULL),
- ready(false)
-{
-}
-
-ut_mvideowidget::~ut_mvideowidget()
-{
-}
-
-bool ut_mvideowidget::waitVideoReady(int msec)
-{
- ready = false;
- QTime t;
- t.start();
- while( !ready && t.elapsed() < msec ) {
- usleep(100000);
- QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents, 500);
- }
- return ready;
-}
-
-bool ut_mvideowidget::waitPositionChange(int msec)
-{
- QTime t;
- t.start();
- quint64 pos = m_subject->position();
- while( m_subject->position() == pos && t.elapsed() < msec ) {
- qDebug() << pos << m_subject->position();
- usleep(100000);
- QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents, 500);
- }
- qDebug() << pos << m_subject->position();
- return m_subject->position() != pos;
-}
-
-bool ut_mvideowidget::waitPositionFreeze(int msec)
-{
- QTime t;
- t.start();
- quint64 pos = m_subject->position();
- int count = 0;
- do {
- pos = m_subject->position();
- usleep(100000);
- QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents, 500);
- if( m_subject->position() == pos )
- count++;
- else
- count = 0;
- qDebug() << pos << m_subject->position();
- } while( count < 2 && t.elapsed() < msec );
-
- return m_subject->position() == pos;
-}
-
-void ut_mvideowidget::videoReady()
-{
- ready = true;
-}
-
-void ut_mvideowidget::init()
-{
- m_subject = new MVideoWidget();
- m_subject->setView(new MVideoWidgetView(m_subject));
- connect(m_subject, SIGNAL(videoReady()),
- this, SLOT(videoReady()));
-}
-
-void ut_mvideowidget::cleanup()
-{
- delete m_subject;
-}
-
-void ut_mvideowidget::initTestCase()
-{
-#define MAX_PARAMS 8
- static char *argv[MAX_PARAMS];
- static int argc = 2;
-
- argv[0] = strdup("./ut_mbutton");
- argv[1] = strdup("-software");
-
- app = new MApplication(argc, argv);
-
- free(argv[0]);
- free(argv[1]);
-}
-
-void ut_mvideowidget::cleanupTestCase()
-{
- delete app;
-}
-
-void ut_mvideowidget::testInitialState()
-{
- QCOMPARE(m_subject->state(), MVideo::NotReady);
-}
-
-void ut_mvideowidget::testBogusOpen()
-{
- QSignalSpy videoReadySpy(m_subject, SIGNAL(videoReady()));
- m_subject->open(QString("bogusdata"));
- waitVideoReady();
-
- QCOMPARE(videoReadySpy.count(), 0);
- QCOMPARE(m_subject->state(), MVideo::NotReady);
-}
-
-void ut_mvideowidget::testOpen()
-{
- QSignalSpy videoReadySpy(m_subject, SIGNAL(videoReady()));
- m_subject->open(QString(qApp->applicationDirPath() + "/test.mov"));
- waitVideoReady();
-
- QCOMPARE(videoReadySpy.count(), 1);
- QCOMPARE(m_subject->state(), MVideo::Stopped);
- QCOMPARE(m_subject->position(), (quint64)0);
- QVERIFY(m_subject->length() > 0);
-}
-
-void ut_mvideowidget::testPlayback()
-{
- m_subject->open(QString(qApp->applicationDirPath() + "/test.mov"));
- //m_subject->setMuted(true);
- waitVideoReady();
-
- //test initial -> play
- bool ok;
- m_subject->play();
- ok = waitPositionChange();
- QCOMPARE(m_subject->state(), MVideo::Playing);
- QVERIFY(m_subject->position() > 0);
- QVERIFY(ok);
-
- //test play -> pause
- m_subject->pause();
- ok = waitPositionFreeze();
- QCOMPARE(m_subject->state(), MVideo::Paused);
- QVERIFY(ok);
-
- //test pause -> play
- m_subject->play();
- ok = waitPositionChange();
- QCOMPARE(m_subject->state(), MVideo::Playing);
- QVERIFY(ok);
-
- //test play -> stop
- m_subject->stop();
- ok = waitPositionFreeze();
- QVERIFY(ok);
- QCOMPARE(m_subject->state(), MVideo::Stopped);
- QCOMPARE(m_subject->position(), (quint64)0);
-
- //test pause -> stop
- m_subject->play();
- ok = waitPositionChange();
- QVERIFY(ok);
- m_subject->pause();
- ok = waitPositionFreeze();
- QVERIFY(ok);
- m_subject->stop();
- ok = waitPositionFreeze();
- QVERIFY(ok);
- QCOMPARE(m_subject->state(), MVideo::Stopped);
- QCOMPARE(m_subject->position(), (quint64)0);
-
- //stop -> pause
- m_subject->pause();
- ok = waitPositionFreeze();
- QVERIFY(ok);
- QCOMPARE(m_subject->state(), MVideo::Paused);
- QCOMPARE(m_subject->position(), (quint64)0);
-}
-
-void ut_mvideowidget::testVolumeControl()
-{
- m_subject->open(QString(qApp->applicationDirPath() + "/test.mov"));
- waitVideoReady();
-
- //mute
- m_subject->setMuted(true);
- QVERIFY(m_subject->isMuted());
- m_subject->setMuted(false);
- QVERIFY(!m_subject->isMuted());
-
- //volume
- m_subject->setVolume(-0.1);
- QCOMPARE(m_subject->volume(), 0.0);
- m_subject->setVolume(1000);
- QCOMPARE(m_subject->volume(), 10.0);
-}
-
-void ut_mvideowidget::testPositionControl()
-{
- m_subject->open(QString(qApp->applicationDirPath() + "/test.mov"));
- waitVideoReady();
-
- //seeking when playing
- m_subject->play();
- m_subject->seek(500);
- waitPositionChange();
- QVERIFY(m_subject->position() >= 500);
-
- //seeking when paused
- m_subject->pause();
- waitPositionFreeze();
- m_subject->seek(0);
- m_subject->play();
- waitPositionChange();
- QVERIFY(m_subject->position() < 500);
-
- //seeking when stopped
- m_subject->stop();
- waitPositionFreeze();
- QVERIFY(m_subject->position() == 0);
- m_subject->seek(500);
- m_subject->play();
- waitPositionChange();
- QVERIFY(m_subject->position() >= 500);
-
- //seek past EOS
- m_subject->seek(m_subject->length() + 1000);
- waitPositionChange();
- QVERIFY(m_subject->position() < m_subject->length());
-
- //non-looping EOS
- m_subject->setLooping(false);
- m_subject->seek(m_subject->length() - 500);
- bool ok = waitPositionFreeze();
- QVERIFY(ok);
- QCOMPARE(m_subject->state(), MVideo::Stopped);
- QCOMPARE(m_subject->position(), (quint64)0);
-
- //looping EOS
- m_subject->setLooping(true);
- m_subject->seek(m_subject->length() - 500);
- m_subject->play();
- waitPositionChange();
- waitPositionFreeze();
- //QVERIFY(!ok);
- QCOMPARE(m_subject->state(), MVideo::Playing);
- QVERIFY(m_subject->position() > 0);
-}
-
-QTEST_APPLESS_MAIN(ut_mvideowidget)
diff --git a/tests/ut_mvideowidget/ut_mvideowidget.h b/tests/ut_mvideowidget/ut_mvideowidget.h
deleted file mode 100644
index a8be9180..00000000
--- a/tests/ut_mvideowidget/ut_mvideowidget.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (directui@nokia.com)
-**
-** This file is part of libmeegotouch.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at directui@nokia.com.
-**
-** This library is free software; you can redistribute it and/or
-** modify it 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.
-**
-****************************************************************************/
-
-#ifndef _ut_mvideowidget_
-#define _ut_mvideowidget_
-
-#include <QtTest/QtTest>
-#include <QObject>
-
-#include <mapplication.h>
-#include <mvideowidget.h>
-
-Q_DECLARE_METATYPE(MVideoWidget *);
-
-class ut_mvideowidget: public QObject
-{
- Q_OBJECT;
-
-public:
- ut_mvideowidget();
- virtual ~ut_mvideowidget();
-
-private:
-
- MVideoWidget *m_subject;
- MApplication *app;
-
-
- bool waitVideoReady(int msec=1000);
- bool waitPositionChange(int msec=1000);
- bool waitPositionFreeze(int msec=1000);
- bool ready;
-public slots:
-
- void videoReady();
-
-private slots:
-
- void init();
- void cleanup();
- void initTestCase();
- void cleanupTestCase();
-
- void testInitialState();
- void testBogusOpen();
- void testOpen();
- void testPlayback();
- void testVolumeControl();
- void testPositionControl();
-};
-#endif
diff --git a/tests/ut_mvideowidget/ut_mvideowidget.pro b/tests/ut_mvideowidget/ut_mvideowidget.pro
deleted file mode 100644
index 8648ffd4..00000000
--- a/tests/ut_mvideowidget/ut_mvideowidget.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-include(../common_top.pri)
-TARGET = ut_mvideowidget
-
-SOURCES += ut_mvideowidget.cpp
-HEADERS += ut_mvideowidget.h
-
-support_files.files += *.mov
-
-include(../common_bot.pri)
-