diff options
517 files changed, 15913 insertions, 57901 deletions
@@ -7,6 +7,8 @@ examples/*/*/* examples/*/*/*[.]app !examples/declarative/* demos/*/* +!demos/spectrum/* +demos/spectrum/bin !demos/*/*[.]* demos/*/*[.]app !demos/declarative/* @@ -50,8 +50,7 @@ my %modules = ( # path to module name map "QtDBus" => "$basedir/src/dbus", "QtWebKit" => "$basedir/src/3rdparty/webkit/WebCore", "phonon" => "$basedir/src/phonon", - "QtMultimedia" => "$basedir/src/multimedia/multimedia", - "QtMediaServices" => "$basedir/src/multimedia/mediaservices", + "QtMultimedia" => "$basedir/src/multimedia", ); my %moduleheaders = ( # restrict the module headers to those found in relative path "QtWebKit" => "../WebKit/qt/Api", @@ -682,8 +682,6 @@ CFG_RELEASE_QMAKE=no CFG_PHONON=auto CFG_PHONON_BACKEND=yes CFG_MULTIMEDIA=auto -CFG_MEDIASERVICES=auto -CFG_MEDIA_BACKEND=auto CFG_AUDIO_BACKEND=auto CFG_SVG=auto CFG_DECLARATIVE=auto @@ -938,7 +936,7 @@ while [ "$#" -gt 0 ]; do VAL=no ;; #Qt style yes options - -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-egl|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-carbon|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-mediaservices|-media-backend|-audio-backend|-svg|-declarative|-webkit|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config|-s60|-usedeffiles) + -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-egl|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-carbon|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-audio-backend|-svg|-declarative|-webkit|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config|-s60|-usedeffiles) VAR=`echo $1 | sed "s,^-\(.*\),\1,"` VAL=yes ;; @@ -2165,20 +2163,6 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; - mediaservices) - if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then - CFG_MEDIASERVICES="$VAL" - else - UNKNOWN_OPT=yes - fi - ;; - media-backend) - if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then - CFG_MEDIA_BACKEND="$VAL" - else - UNKNOWN_OPT=yes - fi - ;; audio-backend) if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then CFG_AUDIO_BACKEND="$VAL" @@ -3409,8 +3393,7 @@ Usage: $relconf [-h] [-prefix <dir>] [-prefix-install] [-bindir <dir>] [-libdir [-no-separate-debug-info] [-no-mmx] [-no-3dnow] [-no-sse] [-no-sse2] [-qtnamespace <namespace>] [-qtlibinfix <infix>] [-separate-debug-info] [-armfpa] [-no-optimized-qmake] [-optimized-qmake] [-no-xmlpatterns] [-xmlpatterns] - [-no-multimedia] [-multimedia] [-no-mediaservices] [-mediaservices] - [-no-phonon] [-phonon] [-no-phonon-backend] [-phonon-backend] + [-no-multimedia] [-multimedia] [-no-phonon] [-phonon] [-no-phonon-backend] [-phonon-backend] [-no-media-backend] [-media-backend] [-no-audio-backend] [-audio-backend] [-no-openssl] [-openssl] [-openssl-linked] [-no-gtkstyle] [-gtkstyle] [-no-svg] [-svg] [-no-webkit] [-webkit] [-no-javascript-jit] [-javascript-jit] @@ -3555,12 +3538,6 @@ fi -no-audio-backend .. Do not build the platform audio backend into QtMultimedia. + -audio-backend ..... Build the platform audio backend into QtMultimedia if available. - -no-mediaservices... Do not build the QtMediaServices module. - + -mediaservices...... Build the QtMediaServices module. - - -no-media-backend... Do not build platform mediaservices plugin. - + -media-backend..... Build the platform mediaservices plugin. - -no-phonon ......... Do not build the Phonon module. + -phonon ............ Build the Phonon module. Phonon is built if a decent C++ compiler is used. @@ -5225,21 +5202,8 @@ if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" ]; then fi fi - if [ "$CFG_GUI" = "no" ]; then - if [ "$CFG_MEDIA_BACKEND" = "auto" ]; then - CFG_MEDIA_BACKEND=no - fi - if [ "$CFG_MEDIA_BACKEND" != "no" ]; then - echo "Medias backend enabled, but GUI disabled." - echo " You might need to either enable the GUI or disable the media backend" - exit 1 - fi - elif [ "$CFG_MEDIA_BACKEND" = "auto" ]; then - CFG_MEDIA_BACKEND=yes - fi - # Auto-detect GStreamer support (needed for both Phonon & QtMultimedia) - if [ "$CFG_PHONON" != "no" -o "$CFG_MEDIASERVICES" != "no" ]; then + if [ "$CFG_PHONON" != "no" ]; then if [ "$CFG_GLIB" = "yes" -a "$CFG_GSTREAMER" != "no" ]; then if [ -n "$PKG_CONFIG" ]; then QT_CFLAGS_GSTREAMER=`$PKG_CONFIG --cflags gstreamer-0.10 gstreamer-plugins-base-0.10 2>/dev/null` @@ -6933,15 +6897,6 @@ else QT_CONFIG="$QT_CONFIG multimedia" fi -if [ "$CFG_MEDIASERVICES" = "no" ]; then - QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_MEDIASERVICES" -else - QT_CONFIG="$QT_CONFIG mediaservices" - if [ "$CFG_MEDIA_BACKEND" != "no" ]; then - QT_CONFIG="$QT_CONFIG media-backend" - fi -fi - if [ "$CFG_AUDIO_BACKEND" = "yes" ]; then QT_CONFIG="$QT_CONFIG audio-backend" fi @@ -7899,7 +7854,6 @@ echo "QtScriptTools module ... $CFG_SCRIPTTOOLS" echo "QtXmlPatterns module ... $CFG_XMLPATTERNS" echo "Phonon module .......... $CFG_PHONON" echo "Multimedia module ...... $CFG_MULTIMEDIA" -echo "Mediaservices module ... $CFG_MEDIASERVICES" echo "SVG module ............. $CFG_SVG" echo "WebKit module .......... $CFG_WEBKIT" if [ "$CFG_WEBKIT" = "yes" ]; then diff --git a/configure.exe b/configure.exe Binary files differindex 69e98dd..a19f515 100755 --- a/configure.exe +++ b/configure.exe diff --git a/demos/demos.pro b/demos/demos.pro index 5e8a4ea..f359bd7 100644 --- a/demos/demos.pro +++ b/demos/demos.pro @@ -57,8 +57,8 @@ wince*:SUBDIRS += demos_sqlbrowser } contains(QT_CONFIG, phonon):!static:SUBDIRS += demos_mediaplayer contains(QT_CONFIG, webkit):contains(QT_CONFIG, svg):!symbian:SUBDIRS += demos_browser -contains(QT_CONFIG, multimedia):SUBDIRS += demos_multimedia contains(QT_CONFIG, declarative):SUBDIRS += demos_declarative +contains(QT_CONFIG, multimedia):SUBDIRS += demos_spectrum # install sources.files = README *.pro @@ -89,13 +89,13 @@ demos_sqlbrowser.subdir = sqlbrowser demos_undo.subdir = undo demos_qtdemo.subdir = qtdemo demos_mediaplayer.subdir = qmediaplayer -demos_multimedia.subdir = multimedia demos_declarative.subdir = declarative demos_browser.subdir = browser demos_boxes.subdir = boxes demos_sub-attaq.subdir = sub-attaq +demos_spectrum.subdir = spectrum #CONFIG += ordered !ordered { diff --git a/demos/embedded/anomaly/src/ControlStrip.cpp b/demos/embedded/anomaly/src/ControlStrip.cpp index dc6d5c2..c9c81c0 100644 --- a/demos/embedded/anomaly/src/ControlStrip.cpp +++ b/demos/embedded/anomaly/src/ControlStrip.cpp @@ -66,6 +66,7 @@ QSize ControlStrip::minimumSizeHint() const void ControlStrip::mousePressEvent(QMouseEvent *event) { int h = height(); + int spacing = qMin(h, (width() - h * 4) / 3); int x = event->pos().x(); if (x < h) { @@ -80,13 +81,13 @@ void ControlStrip::mousePressEvent(QMouseEvent *event) return; } - if ((x < width() - 2 * h) && (x > width() - 3 * h)) { + if ((x < width() - (h + spacing)) && (x > width() - (h * 2 + spacing))) { emit forwardClicked(); event->accept(); return; } - if ((x < width() - 3 * h) && (x > width() - 5 * h)) { + if ((x < width() - (h * 2 + spacing * 2)) && (x > width() - (h * 3 + spacing * 2))) { emit backClicked(); event->accept(); return; @@ -96,15 +97,16 @@ void ControlStrip::mousePressEvent(QMouseEvent *event) void ControlStrip::paintEvent(QPaintEvent *event) { int h = height(); - int s = (h - menuPixmap.height()) / 2; + int spacing = qMin(h, (width() - h * 4) / 3); + int s = (height() - menuPixmap.height()) / 2; QPainter p(this); p.fillRect(event->rect(), QColor(32, 32, 32, 192)); p.setCompositionMode(QPainter::CompositionMode_SourceOver); p.drawPixmap(s, s, menuPixmap); p.drawPixmap(width() - h + s, s, closePixmap); - p.drawPixmap(width() - 3 * h + s, s, forwardPixmap); - p.drawPixmap(width() - 5 * h + s, s, backPixmap); + p.drawPixmap(width() - (h * 2 + spacing) + s, s, forwardPixmap); + p.drawPixmap(width() - (h * 3 + spacing * 2) + s, s, backPixmap); p.end(); } diff --git a/demos/embedded/fluidlauncher/config_s60/config.xml b/demos/embedded/fluidlauncher/config_s60/config.xml index 176f52e..d926a4b 100644 --- a/demos/embedded/fluidlauncher/config_s60/config.xml +++ b/demos/embedded/fluidlauncher/config_s60/config.xml @@ -20,6 +20,7 @@ <example filename="flickable" name="Kinetic Scrolling" image="screenshots/flickable.png"/> <example filename="digiflip" name="Flipping Clock" image="screenshots/digiflip.png"/> <example filename="qmediaplayer" name="Media Player" image="screenshots/mediaplayer.png" args="-small-screen"/> + <example filename="spectrum" name="Spectrum Analyzer" image="screenshots/spectrum.png" args="-small-screen"/> </demos> <slideshow timeout="60000" interval="10000"> <imagedir dir="slides"/> diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro index c6a105e..bb512d9 100644 --- a/demos/embedded/fluidlauncher/fluidlauncher.pro +++ b/demos/embedded/fluidlauncher/fluidlauncher.pro @@ -116,6 +116,10 @@ symbian { reg_resource.sources += $$regResourceDir(demos/qmediaplayer/qmediaplayer_reg.rsc) } + contains(QT_CONFIG, multimedia) { + reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/spectrum_reg.rsc + } + reg_resource.path = $$REG_RESOURCE_IMPORT_DIR @@ -196,6 +200,13 @@ symbian { $$appResourceDir(demos/qmediaplayer/qmediaplayer.mif) } + contains(QT_CONFIG, multimedia) { + executables.sources += spectrum.exe fftreal.dll + resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/spectrum.rsc + mifs.sources += \ + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/spectrum.mif + } + contains(QT_CONFIG, script) { executables.sources += $$QT_BUILD_TREE/examples/script/context2d/context2d.exe reg_resource.sources += $$regResourceDir(examples/script/context2d/context2d_reg.rsc) diff --git a/demos/embedded/fluidlauncher/screenshots/spectrum.png b/demos/embedded/fluidlauncher/screenshots/spectrum.png Binary files differnew file mode 100644 index 0000000..7f4938f --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/spectrum.png diff --git a/demos/multimedia/multimedia.pro b/demos/multimedia/multimedia.pro deleted file mode 100644 index fa29a12..0000000 --- a/demos/multimedia/multimedia.pro +++ /dev/null @@ -1,3 +0,0 @@ -TEMPLATE = subdirs -contains(QT_CONFIG, mediaservices): SUBDIRS = player - diff --git a/demos/multimedia/player/main.cpp b/demos/multimedia/player/main.cpp deleted file mode 100644 index 87c5b87..0000000 --- a/demos/multimedia/player/main.cpp +++ /dev/null @@ -1,54 +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 demonstration applications 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 "player.h" - -#include <QtGui> - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - Player player; - player.show(); - - return app.exec(); -}; diff --git a/demos/multimedia/player/player.cpp b/demos/multimedia/player/player.cpp deleted file mode 100644 index bf314ee..0000000 --- a/demos/multimedia/player/player.cpp +++ /dev/null @@ -1,372 +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 demonstration applications 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 "player.h" - -#include "playercontrols.h" -#include "playlistmodel.h" -#include "videowidget.h" - -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmediaplaylist.h> - -#include <QtGui> - -Player::Player(QWidget *parent) - : QWidget(parent) - , videoWidget(0) - , coverLabel(0) - , slider(0) - , colorDialog(0) -{ - player = new QMediaPlayer(this); - playlist = new QMediaPlaylist(this); - playlist->setMediaObject(player); - - connect(player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64))); - connect(player, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64))); - connect(player, SIGNAL(metaDataChanged()), SLOT(metaDataChanged())); - connect(playlist, SIGNAL(currentIndexChanged(int)), SLOT(playlistPositionChanged(int))); - connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), - this, SLOT(statusChanged(QMediaPlayer::MediaStatus))); - connect(player, SIGNAL(bufferStatusChanged(int)), this, SLOT(bufferingProgress(int))); - - videoWidget = new VideoWidget; - videoWidget->setMediaObject(player); - - playlistModel = new PlaylistModel(this); - playlistModel->setPlaylist(playlist); - - playlistView = new QListView; - playlistView->setModel(playlistModel); - playlistView->setCurrentIndex(playlistModel->index(playlist->currentIndex(), 0)); - - connect(playlistView, SIGNAL(activated(QModelIndex)), this, SLOT(jump(QModelIndex))); - - playbackModeBox = new QComboBox; - playbackModeBox->addItem(tr("Linear"), - QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::Linear)); - playbackModeBox->addItem(tr("Loop"), - QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::Loop)); - playbackModeBox->addItem(tr("Random"), - QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::Random)); - playbackModeBox->addItem(tr("Current Item Once"), - QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::CurrentItemOnce)); - playbackModeBox->addItem(tr("Current Item In Loop"), - QVariant::fromValue<QMediaPlaylist::PlaybackMode>(QMediaPlaylist::CurrentItemInLoop)); - playbackModeBox->setCurrentIndex(0); - - connect(playbackModeBox, SIGNAL(activated(int)), SLOT(updatePlaybackMode())); - updatePlaybackMode(); - - slider = new QSlider(Qt::Horizontal); - slider->setRange(0, player->duration() / 1000); - - connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(seek(int))); - - QPushButton *openButton = new QPushButton(tr("Open")); - - connect(openButton, SIGNAL(clicked()), this, SLOT(open())); - - PlayerControls *controls = new PlayerControls; - controls->setState(player->state()); - controls->setVolume(player->volume()); - controls->setMuted(controls->isMuted()); - - connect(controls, SIGNAL(play()), player, SLOT(play())); - connect(controls, SIGNAL(pause()), player, SLOT(pause())); - connect(controls, SIGNAL(stop()), player, SLOT(stop())); - connect(controls, SIGNAL(next()), playlist, SLOT(next())); - connect(controls, SIGNAL(previous()), this, SLOT(previousClicked())); - connect(controls, SIGNAL(changeVolume(int)), player, SLOT(setVolume(int))); - connect(controls, SIGNAL(changeMuting(bool)), player, SLOT(setMuted(bool))); - connect(controls, SIGNAL(changeRate(qreal)), player, SLOT(setPlaybackRate(qreal))); - - connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), - controls, SLOT(setState(QMediaPlayer::State))); - connect(player, SIGNAL(volumeChanged(int)), controls, SLOT(setVolume(int))); - connect(player, SIGNAL(mutedChanged(bool)), controls, SLOT(setMuted(bool))); - - QPushButton *fullScreenButton = new QPushButton(tr("FullScreen")); - fullScreenButton->setCheckable(true); - - if (videoWidget != 0) { - connect(fullScreenButton, SIGNAL(clicked(bool)), videoWidget, SLOT(setFullScreen(bool))); - connect(videoWidget, SIGNAL(fullScreenChanged(bool)), - fullScreenButton, SLOT(setChecked(bool))); - } else { - fullScreenButton->setEnabled(false); - } - - QPushButton *colorButton = new QPushButton(tr("Color Options...")); - if (videoWidget) - connect(colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog())); - else - colorButton->setEnabled(false); - - QBoxLayout *playlistLayout = new QVBoxLayout; - playlistLayout->addWidget(playlistView); - playlistLayout->addWidget(playbackModeBox); - - QBoxLayout *displayLayout = new QHBoxLayout; - if (videoWidget) - displayLayout->addWidget(videoWidget, 2); - else - displayLayout->addWidget(coverLabel, 2); - displayLayout->addLayout(playlistLayout); - - QBoxLayout *controlLayout = new QHBoxLayout; - controlLayout->setMargin(0); - controlLayout->addWidget(openButton); - controlLayout->addStretch(1); - controlLayout->addWidget(controls); - controlLayout->addStretch(1); - controlLayout->addWidget(fullScreenButton); - controlLayout->addWidget(colorButton); - - QBoxLayout *layout = new QVBoxLayout; - layout->addLayout(displayLayout); - layout->addWidget(slider); - layout->addLayout(controlLayout); - - setLayout(layout); - - metaDataChanged(); - - QStringList arguments = qApp->arguments(); - arguments.removeAt(0); - foreach (QString const &argument, arguments) { - QFileInfo fileInfo(argument); - if (fileInfo.exists()) { - QUrl url = QUrl::fromLocalFile(fileInfo.absoluteFilePath()); - if (fileInfo.suffix().toLower() == QLatin1String("m3u")) { - playlist->load(url); - } else - playlist->addMedia(url); - } else { - QUrl url(argument); - if (url.isValid()) { - playlist->addMedia(url); - } - } - } -} - -Player::~Player() -{ - delete playlist; - delete player; -} - -void Player::open() -{ - QStringList fileNames = QFileDialog::getOpenFileNames(); - foreach (QString const &fileName, fileNames) - playlist->addMedia(QUrl::fromLocalFile(fileName)); -} - -void Player::durationChanged(qint64 duration) -{ - slider->setMaximum(duration / 1000); -} - -void Player::positionChanged(qint64 progress) -{ - slider->setValue(progress / 1000); -} - -void Player::metaDataChanged() -{ - //qDebug() << "update metadata" << player->metaData(QtMediaServices::Title).toString(); - if (player->isMetaDataAvailable()) { - setTrackInfo(QString("%1 - %2") - .arg(player->metaData(QtMediaServices::AlbumArtist).toString()) - .arg(player->metaData(QtMediaServices::Title).toString())); - - if (coverLabel) { - QUrl url = player->metaData(QtMediaServices::CoverArtUrlLarge).value<QUrl>(); - - coverLabel->setPixmap(!url.isEmpty() - ? QPixmap(url.toString()) - : QPixmap()); - } - } -} - -void Player::previousClicked() -{ - // Go to previous track if we are within the first 5 seconds of playback - // Otherwise, seek to the beginning. - if(player->position() <= 5000) - playlist->previous(); - else - player->setPosition(0); -} - -void Player::jump(const QModelIndex &index) -{ - if (index.isValid()) { - playlist->setCurrentIndex(index.row()); - player->play(); - } -} - -void Player::playlistPositionChanged(int currentItem) -{ - playlistView->setCurrentIndex(playlistModel->index(currentItem, 0)); -} - -void Player::seek(int seconds) -{ - player->setPosition(seconds * 1000); -} - -void Player::statusChanged(QMediaPlayer::MediaStatus status) -{ - switch (status) { - case QMediaPlayer::UnknownMediaStatus: - case QMediaPlayer::NoMedia: - case QMediaPlayer::LoadedMedia: - case QMediaPlayer::BufferingMedia: - case QMediaPlayer::BufferedMedia: -#ifndef QT_NO_CURSOR - unsetCursor(); -#endif - setStatusInfo(QString()); - break; - case QMediaPlayer::LoadingMedia: -#ifndef QT_NO_CURSOR - setCursor(QCursor(Qt::BusyCursor)); -#endif - setStatusInfo(tr("Loading...")); - break; - case QMediaPlayer::StalledMedia: -#ifndef QT_NO_CURSOR - setCursor(QCursor(Qt::BusyCursor)); -#endif - break; - case QMediaPlayer::EndOfMedia: -#ifndef QT_NO_CURSOR - unsetCursor(); -#endif - setStatusInfo(QString()); - QApplication::alert(this); - break; - case QMediaPlayer::InvalidMedia: -#ifndef QT_NO_CURSOR - unsetCursor(); -#endif - setStatusInfo(player->errorString()); - break; - } -} - -void Player::bufferingProgress(int progress) -{ - setStatusInfo(tr("Buffering %4%%").arg(progress)); -} - -void Player::setTrackInfo(const QString &info) -{ - trackInfo = info; - - if (!statusInfo.isEmpty()) - setWindowTitle(QString("%1 | %2").arg(trackInfo).arg(statusInfo)); - else - setWindowTitle(trackInfo); - -} - -void Player::setStatusInfo(const QString &info) -{ - statusInfo = info; - - if (!statusInfo.isEmpty()) - setWindowTitle(QString("%1 | %2").arg(trackInfo).arg(statusInfo)); - else - setWindowTitle(trackInfo); -} - -void Player::showColorDialog() -{ - if (!colorDialog) { - QSlider *brightnessSlider = new QSlider(Qt::Horizontal); - brightnessSlider->setRange(-100, 100); - brightnessSlider->setValue(videoWidget->brightness()); - connect(brightnessSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setBrightness(int))); - connect(videoWidget, SIGNAL(brightnessChanged(int)), brightnessSlider, SLOT(setValue(int))); - - QSlider *contrastSlider = new QSlider(Qt::Horizontal); - contrastSlider->setRange(-100, 100); - contrastSlider->setValue(videoWidget->contrast()); - connect(contrastSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setContrast(int))); - connect(videoWidget, SIGNAL(contrastChanged(int)), contrastSlider, SLOT(setValue(int))); - - QSlider *hueSlider = new QSlider(Qt::Horizontal); - hueSlider->setRange(-100, 100); - hueSlider->setValue(videoWidget->hue()); - connect(hueSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setHue(int))); - connect(videoWidget, SIGNAL(hueChanged(int)), hueSlider, SLOT(setValue(int))); - - QSlider *saturationSlider = new QSlider(Qt::Horizontal); - saturationSlider->setRange(-100, 100); - saturationSlider->setValue(videoWidget->saturation()); - connect(saturationSlider, SIGNAL(sliderMoved(int)), videoWidget, SLOT(setSaturation(int))); - connect(videoWidget, SIGNAL(saturationChanged(int)), saturationSlider, SLOT(setValue(int))); - - QFormLayout *layout = new QFormLayout; - layout->addRow(tr("Brightness"), brightnessSlider); - layout->addRow(tr("Contrast"), contrastSlider); - layout->addRow(tr("Hue"), hueSlider); - layout->addRow(tr("Saturation"), saturationSlider); - - colorDialog = new QDialog(this); - colorDialog->setWindowTitle(tr("Color Options")); - colorDialog->setLayout(layout); - } - colorDialog->show(); -} - -void Player::updatePlaybackMode() -{ - playlist->setPlaybackMode( - playbackModeBox->itemData(playbackModeBox->currentIndex()).value<QMediaPlaylist::PlaybackMode>()); -} diff --git a/demos/multimedia/player/player.h b/demos/multimedia/player/player.h deleted file mode 100644 index cda3eb9..0000000 --- a/demos/multimedia/player/player.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 demonstration applications 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 PLAYER_H -#define PLAYER_H - -#include <QtGui/QWidget> - -#include <qmediaplayer.h> -#include <qmediaplaylist.h> -#include <qvideowidget.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QAbstractItemView; -class QLabel; -class QModelIndex; -class QSlider; -class QComboBox; -class QMediaPlayer; -class QVideoWidget; -class PlaylistModel; - -class Player : public QWidget -{ - Q_OBJECT -public: - Player(QWidget *parent = 0); - ~Player(); - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - -private slots: - void open(); - void durationChanged(qint64 duration); - void positionChanged(qint64 progress); - void metaDataChanged(); - - void previousClicked(); - - void seek(int seconds); - void jump(const QModelIndex &index); - void playlistPositionChanged(int); - - void statusChanged(QMediaPlayer::MediaStatus status); - void bufferingProgress(int progress); - - void showColorDialog(); - void updatePlaybackMode(); - -private: - void setTrackInfo(const QString &info); - void setStatusInfo(const QString &info); - - QMediaPlayer *player; - QMediaPlaylist *playlist; - QVideoWidget *videoWidget; - QLabel *coverLabel; - QSlider *slider; - QComboBox *playbackModeBox; - PlaylistModel *playlistModel; - QAbstractItemView *playlistView; - QDialog *colorDialog; - QString trackInfo; - QString statusInfo; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/demos/multimedia/player/player.pro b/demos/multimedia/player/player.pro deleted file mode 100644 index 12bdf64..0000000 --- a/demos/multimedia/player/player.pro +++ /dev/null @@ -1,29 +0,0 @@ -TEMPLATE = app -TARGET = player - -QT += gui mediaservices - -HEADERS = \ - player.h \ - playercontrols.h \ - playlistmodel.h \ - videowidget.h - -SOURCES = \ - main.cpp \ - player.cpp \ - playercontrols.cpp \ - playlistmodel.cpp \ - videowidget.cpp - -target.path = $$[QT_INSTALL_DEMOS]/multimedia/player -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_DEMOS]/multimedia/player - -INSTALLS += target sources - -symbian { - TARGET.UID3 = 0xA000E3FA - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) -} - diff --git a/demos/multimedia/player/playercontrols.cpp b/demos/multimedia/player/playercontrols.cpp deleted file mode 100644 index 3798a71..0000000 --- a/demos/multimedia/player/playercontrols.cpp +++ /dev/null @@ -1,205 +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 demonstration applications 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 "playercontrols.h" - -#include <QtGui/qboxlayout.h> -#include <QtGui/qslider.h> -#include <QtGui/qstyle.h> -#include <QtGui/qtoolbutton.h> -#include <QtGui/qcombobox.h> - -PlayerControls::PlayerControls(QWidget *parent) - : QWidget(parent) - , playerState(QMediaPlayer::StoppedState) - , playerMuted(false) - , playButton(0) - , stopButton(0) - , nextButton(0) - , previousButton(0) - , muteButton(0) - , volumeSlider(0) - , rateBox(0) -{ - playButton = new QToolButton; - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - - connect(playButton, SIGNAL(clicked()), this, SLOT(playClicked())); - - stopButton = new QToolButton; - stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop)); - stopButton->setEnabled(false); - - connect(stopButton, SIGNAL(clicked()), this, SIGNAL(stop())); - - nextButton = new QToolButton; - nextButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward)); - - connect(nextButton, SIGNAL(clicked()), this, SIGNAL(next())); - - previousButton = new QToolButton; - previousButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward)); - - connect(previousButton, SIGNAL(clicked()), this, SIGNAL(previous())); - - muteButton = new QToolButton; - muteButton->setIcon(style()->standardIcon(QStyle::SP_MediaVolume)); - - connect(muteButton, SIGNAL(clicked()), this, SLOT(muteClicked())); - - volumeSlider = new QSlider(Qt::Horizontal); - volumeSlider->setRange(0, 100); - - connect(volumeSlider, SIGNAL(sliderMoved(int)), this, SIGNAL(changeVolume(int))); - - rateBox = new QComboBox; - rateBox->addItem("0.5x", QVariant(0.5)); - rateBox->addItem("1.0x", QVariant(1.0)); - rateBox->addItem("2.0x", QVariant(2.0)); - rateBox->setCurrentIndex(1); - - connect(rateBox, SIGNAL(activated(int)), SLOT(updateRate())); - - QBoxLayout *layout = new QHBoxLayout; - layout->setMargin(0); - layout->addWidget(stopButton); - layout->addWidget(previousButton); - layout->addWidget(playButton); - layout->addWidget(nextButton); - layout->addWidget(muteButton); - layout->addWidget(volumeSlider); - layout->addWidget(rateBox); - setLayout(layout); -} - -QMediaPlayer::State PlayerControls::state() const -{ - return playerState; -} - -void PlayerControls::setState(QMediaPlayer::State state) -{ - if (state != playerState) { - playerState = state; - - switch (state) { - case QMediaPlayer::StoppedState: - stopButton->setEnabled(false); - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - break; - case QMediaPlayer::PlayingState: - stopButton->setEnabled(true); - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); - break; - case QMediaPlayer::PausedState: - stopButton->setEnabled(true); - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - break; - } - } -} - -int PlayerControls::volume() const -{ - return volumeSlider->value(); -} - -void PlayerControls::setVolume(int volume) -{ - volumeSlider->setValue(volume); -} - -bool PlayerControls::isMuted() const -{ - return playerMuted; -} - -void PlayerControls::setMuted(bool muted) -{ - if (muted != playerMuted) { - playerMuted = muted; - - muteButton->setIcon(style()->standardIcon(muted - ? QStyle::SP_MediaVolumeMuted - : QStyle::SP_MediaVolume)); - } -} - -void PlayerControls::playClicked() -{ - switch (playerState) { - case QMediaPlayer::StoppedState: - case QMediaPlayer::PausedState: - emit play(); - break; - case QMediaPlayer::PlayingState: - emit pause(); - break; - } -} - -void PlayerControls::muteClicked() -{ - emit changeMuting(!playerMuted); -} - -qreal PlayerControls::playbackRate() const -{ - return rateBox->itemData(rateBox->currentIndex()).toDouble(); -} - -void PlayerControls::setPlaybackRate(float rate) -{ - for (int i=0; i<rateBox->count(); i++) { - if (qFuzzyCompare(rate, float(rateBox->itemData(i).toDouble()))) { - rateBox->setCurrentIndex(i); - return; - } - } - - rateBox->addItem( QString("%1x").arg(rate), QVariant(rate)); - rateBox->setCurrentIndex(rateBox->count()-1); -} - -void PlayerControls::updateRate() -{ - emit changeRate(playbackRate()); -} diff --git a/demos/multimedia/player/playercontrols.h b/demos/multimedia/player/playercontrols.h deleted file mode 100644 index d2229bd..0000000 --- a/demos/multimedia/player/playercontrols.h +++ /dev/null @@ -1,107 +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 demonstration applications 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 PLAYERCONTROLS_H -#define PLAYERCONTROLS_H - -#include <QtMediaServices/qmediaplayer.h> - -#include <QtGui/qwidget.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QAbstractButton; -class QAbstractSlider; -class QComboBox; - -class PlayerControls : public QWidget -{ - Q_OBJECT -public: - PlayerControls(QWidget *parent = 0); - - QMediaPlayer::State state() const; - - int volume() const; - bool isMuted() const; - qreal playbackRate() const; - -public slots: - void setState(QMediaPlayer::State state); - void setVolume(int volume); - void setMuted(bool muted); - void setPlaybackRate(float rate); - -signals: - void play(); - void pause(); - void stop(); - void next(); - void previous(); - void changeVolume(int volume); - void changeMuting(bool muting); - void changeRate(qreal rate); - -private slots: - void playClicked(); - void muteClicked(); - void updateRate(); - -private: - QMediaPlayer::State playerState; - bool playerMuted; - QAbstractButton *playButton; - QAbstractButton *stopButton; - QAbstractButton *nextButton; - QAbstractButton *previousButton; - QAbstractButton *muteButton; - QAbstractSlider *volumeSlider; - QComboBox *rateBox; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/demos/multimedia/player/playlistmodel.cpp b/demos/multimedia/player/playlistmodel.cpp deleted file mode 100644 index b60f914..0000000 --- a/demos/multimedia/player/playlistmodel.cpp +++ /dev/null @@ -1,160 +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 demonstration applications 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 "playlistmodel.h" - -#include <QtCore/qfileinfo.h> -#include <QtCore/qurl.h> - -#include <qmediaplaylist.h> - -PlaylistModel::PlaylistModel(QObject *parent) - : QAbstractItemModel(parent) - , m_playlist(0) -{ -} - -int PlaylistModel::rowCount(const QModelIndex &parent) const -{ - return m_playlist && !parent.isValid() ? m_playlist->mediaCount() : 0; -} - -int PlaylistModel::columnCount(const QModelIndex &parent) const -{ - return !parent.isValid() ? ColumnCount : 0; -} - -QModelIndex PlaylistModel::index(int row, int column, const QModelIndex &parent) const -{ - return m_playlist && !parent.isValid() - && row >= 0 && row < m_playlist->mediaCount() - && column >= 0 && column < ColumnCount - ? createIndex(row, column) - : QModelIndex(); -} - -QModelIndex PlaylistModel::parent(const QModelIndex &child) const -{ - Q_UNUSED(child); - - return QModelIndex(); -} - -QVariant PlaylistModel::data(const QModelIndex &index, int role) const -{ - if (index.isValid() && role == Qt::DisplayRole) { - QVariant value = m_data[index]; - if (!value.isValid() && index.column() == Title) { - QUrl location = m_playlist->media(index.row()).canonicalUrl(); - return QFileInfo(location.path()).fileName(); - } - - return value; - } - return QVariant(); -} - -QMediaPlaylist *PlaylistModel::playlist() const -{ - return m_playlist; -} - -void PlaylistModel::setPlaylist(QMediaPlaylist *playlist) -{ - if (m_playlist) { - disconnect(m_playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SLOT(beginInsertItems(int,int))); - disconnect(m_playlist, SIGNAL(mediaInserted(int,int)), this, SLOT(endInsertItems())); - disconnect(m_playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SLOT(beginRemoveItems(int,int))); - disconnect(m_playlist, SIGNAL(mediaRemoved(int,int)), this, SLOT(endRemoveItems())); - disconnect(m_playlist, SIGNAL(mediaChanged(int,int)), this, SLOT(changeItems(int,int))); - } - - m_playlist = playlist; - - if (m_playlist) { - connect(m_playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SLOT(beginInsertItems(int,int))); - connect(m_playlist, SIGNAL(mediaInserted(int,int)), this, SLOT(endInsertItems())); - connect(m_playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SLOT(beginRemoveItems(int,int))); - connect(m_playlist, SIGNAL(mediaRemoved(int,int)), this, SLOT(endRemoveItems())); - connect(m_playlist, SIGNAL(mediaChanged(int,int)), this, SLOT(changeItems(int,int))); - } - - - reset(); -} - -bool PlaylistModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - Q_UNUSED(role); - m_data[index] = value; - emit dataChanged(index, index); - return true; -} - -void PlaylistModel::beginInsertItems(int start, int end) -{ - m_data.clear(); - beginInsertRows(QModelIndex(), start, end); -} - -void PlaylistModel::endInsertItems() -{ - endInsertRows(); -} - -void PlaylistModel::beginRemoveItems(int start, int end) -{ - m_data.clear(); - beginRemoveRows(QModelIndex(), start, end); -} - -void PlaylistModel::endRemoveItems() -{ - endInsertRows(); -} - -void PlaylistModel::changeItems(int start, int end) -{ - m_data.clear(); - emit dataChanged(index(start,0), index(end,ColumnCount)); -} - - diff --git a/demos/multimedia/player/playlistmodel.h b/demos/multimedia/player/playlistmodel.h deleted file mode 100644 index 0180282..0000000 --- a/demos/multimedia/player/playlistmodel.h +++ /dev/null @@ -1,95 +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 demonstration applications 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 PLAYLISTMODEL_H -#define PLAYLISTMODEL_H - -#include <QtCore/qabstractitemmodel.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaPlaylist; - -class PlaylistModel : public QAbstractItemModel -{ - Q_OBJECT -public: - enum Column - { - Title = 0, - ColumnCount - }; - - PlaylistModel(QObject *parent = 0); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - - QMediaPlaylist *playlist() const; - void setPlaylist(QMediaPlaylist *playlist); - - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole); - -private slots: - void beginInsertItems(int start, int end); - void endInsertItems(); - void beginRemoveItems(int start, int end); - void endRemoveItems(); - void changeItems(int start, int end); - -private: - QMediaPlaylist *m_playlist; - QMap<QModelIndex, QVariant> m_data; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/demos/multimedia/player/videowidget.cpp b/demos/multimedia/player/videowidget.cpp deleted file mode 100644 index be864ec..0000000 --- a/demos/multimedia/player/videowidget.cpp +++ /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 demonstration applications 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 "videowidget.h" - -#include <QtGui> - -VideoWidget::VideoWidget(QWidget *parent) - : QVideoWidget(parent) -{ - setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); - - QPalette p = palette(); - p.setColor(QPalette::Window, Qt::black); - setPalette(p); - - setAttribute(Qt::WA_OpaquePaintEvent); -} - -void VideoWidget::keyPressEvent(QKeyEvent *event) -{ - if (event->key() == Qt::Key_Escape && isFullScreen()) { - showNormal(); - - event->accept(); - } else if (event->key() == Qt::Key_Enter && event->modifiers() & Qt::Key_Alt) { - setFullScreen(!isFullScreen()); - - event->accept(); - } else { - QVideoWidget::keyPressEvent(event); - } -} - -void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event) -{ - setFullScreen(!isFullScreen()); - - event->accept(); -} diff --git a/demos/multimedia/player/videowidget.h b/demos/multimedia/player/videowidget.h deleted file mode 100644 index b5bf581..0000000 --- a/demos/multimedia/player/videowidget.h +++ /dev/null @@ -1,66 +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 demonstration applications 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 VIDEOWIDGET_H -#define VIDEOWIDGET_H - -#include <QtMediaServices/qvideowidget.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class VideoWidget : public QVideoWidget -{ - Q_OBJECT -public: - VideoWidget(QWidget *parent = 0); - -protected: - void keyPressEvent(QKeyEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/demos/qtdemo/xml/examples.xml b/demos/qtdemo/xml/examples.xml index e3240ab..9121861 100644 --- a/demos/qtdemo/xml/examples.xml +++ b/demos/qtdemo/xml/examples.xml @@ -19,6 +19,7 @@ <example filename="qmediaplayer" name="Media Player" /> <example filename="boxes" name="Boxes" /> <example filename="sub-attaq" name="Sub-attaq" /> + <example filename="spectrum" name="Spectrum Analyzer" /> </demos> <category dirname="animation" name="Animation Framework"> <example filename="animatedtiles" name="Animated Tiles" /> diff --git a/demos/spectrum/3rdparty/fftreal/Array.h b/demos/spectrum/3rdparty/fftreal/Array.h new file mode 100644 index 0000000..a08e3cf --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/Array.h @@ -0,0 +1,97 @@ +/***************************************************************************** + + Array.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (Array_HEADER_INCLUDED) +#define Array_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class T, long LEN> +class Array +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef T DataType; + + Array (); + + inline const DataType & + operator [] (long pos) const; + inline DataType & + operator [] (long pos); + + static inline long + size (); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + DataType _data_arr [LEN]; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + Array (const Array &other); + Array & operator = (const Array &other); + bool operator == (const Array &other); + bool operator != (const Array &other); + +}; // class Array + + + +#include "Array.hpp" + + + +#endif // Array_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/Array.hpp b/demos/spectrum/3rdparty/fftreal/Array.hpp new file mode 100644 index 0000000..8300077 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/Array.hpp @@ -0,0 +1,98 @@ +/***************************************************************************** + + Array.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (Array_CURRENT_CODEHEADER) + #error Recursive inclusion of Array code header. +#endif +#define Array_CURRENT_CODEHEADER + +#if ! defined (Array_CODEHEADER_INCLUDED) +#define Array_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include <cassert> + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class T, long LEN> +Array <T, LEN>::Array () +{ + // Nothing +} + + + +template <class T, long LEN> +const typename Array <T, LEN>::DataType & Array <T, LEN>::operator [] (long pos) const +{ + assert (pos >= 0); + assert (pos < LEN); + + return (_data_arr [pos]); +} + + + +template <class T, long LEN> +typename Array <T, LEN>::DataType & Array <T, LEN>::operator [] (long pos) +{ + assert (pos >= 0); + assert (pos < LEN); + + return (_data_arr [pos]); +} + + + +template <class T, long LEN> +long Array <T, LEN>::size () +{ + return (LEN); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // Array_CODEHEADER_INCLUDED + +#undef Array_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/DynArray.h b/demos/spectrum/3rdparty/fftreal/DynArray.h new file mode 100644 index 0000000..8041a0c --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/DynArray.h @@ -0,0 +1,100 @@ +/***************************************************************************** + + DynArray.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (DynArray_HEADER_INCLUDED) +#define DynArray_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class T> +class DynArray +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef T DataType; + + DynArray (); + explicit DynArray (long size); + ~DynArray (); + + inline long size () const; + inline void resize (long size); + + inline const DataType & + operator [] (long pos) const; + inline DataType & + operator [] (long pos); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + DataType * _data_ptr; + long _len; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + DynArray (const DynArray &other); + DynArray & operator = (const DynArray &other); + bool operator == (const DynArray &other); + bool operator != (const DynArray &other); + +}; // class DynArray + + + +#include "DynArray.hpp" + + + +#endif // DynArray_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/DynArray.hpp b/demos/spectrum/3rdparty/fftreal/DynArray.hpp new file mode 100644 index 0000000..e62b10f --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/DynArray.hpp @@ -0,0 +1,143 @@ +/***************************************************************************** + + DynArray.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (DynArray_CURRENT_CODEHEADER) + #error Recursive inclusion of DynArray code header. +#endif +#define DynArray_CURRENT_CODEHEADER + +#if ! defined (DynArray_CODEHEADER_INCLUDED) +#define DynArray_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include <cassert> + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class T> +DynArray <T>::DynArray () +: _data_ptr (0) +, _len (0) +{ + // Nothing +} + + + +template <class T> +DynArray <T>::DynArray (long size) +: _data_ptr (0) +, _len (0) +{ + assert (size >= 0); + if (size > 0) + { + _data_ptr = new DataType [size]; + _len = size; + } +} + + + +template <class T> +DynArray <T>::~DynArray () +{ + delete [] _data_ptr; + _data_ptr = 0; + _len = 0; +} + + + +template <class T> +long DynArray <T>::size () const +{ + return (_len); +} + + + +template <class T> +void DynArray <T>::resize (long size) +{ + assert (size >= 0); + if (size > 0) + { + DataType * old_data_ptr = _data_ptr; + DataType * tmp_data_ptr = new DataType [size]; + + _data_ptr = tmp_data_ptr; + _len = size; + + delete [] old_data_ptr; + } +} + + + +template <class T> +const typename DynArray <T>::DataType & DynArray <T>::operator [] (long pos) const +{ + assert (pos >= 0); + assert (pos < _len); + + return (_data_ptr [pos]); +} + + + +template <class T> +typename DynArray <T>::DataType & DynArray <T>::operator [] (long pos) +{ + assert (pos >= 0); + assert (pos < _len); + + return (_data_ptr [pos]); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // DynArray_CODEHEADER_INCLUDED + +#undef DynArray_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTReal.dsp b/demos/spectrum/3rdparty/fftreal/FFTReal.dsp new file mode 100644 index 0000000..fe970db --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTReal.dsp @@ -0,0 +1,273 @@ +# Microsoft Developer Studio Project File - Name="FFTReal" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=FFTReal - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "FFTReal.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "FFTReal.mak" CFG="FFTReal - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "FFTReal - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "FFTReal - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "FFTReal - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GR /GX /O2 /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x40c /d "NDEBUG" +# ADD RSC /l 0x40c /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "FFTReal - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Gm /GR /GX /Zi /Od /Gf /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c +# ADD BASE RSC /l 0x40c /d "_DEBUG" +# ADD RSC /l 0x40c /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "FFTReal - Win32 Release" +# Name "FFTReal - Win32 Debug" +# Begin Group "Library" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\Array.h +# End Source File +# Begin Source File + +SOURCE=.\Array.hpp +# End Source File +# Begin Source File + +SOURCE=.\def.h +# End Source File +# Begin Source File + +SOURCE=.\DynArray.h +# End Source File +# Begin Source File + +SOURCE=.\DynArray.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTReal.h +# End Source File +# Begin Source File + +SOURCE=.\FFTReal.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealFixLen.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealFixLen.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealFixLenParam.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealPassDirect.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealPassDirect.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealPassInverse.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealPassInverse.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealSelect.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealSelect.hpp +# End Source File +# Begin Source File + +SOURCE=.\FFTRealUseTrigo.h +# End Source File +# Begin Source File + +SOURCE=.\FFTRealUseTrigo.hpp +# End Source File +# Begin Source File + +SOURCE=.\OscSinCos.h +# End Source File +# Begin Source File + +SOURCE=.\OscSinCos.hpp +# End Source File +# End Group +# Begin Group "Test" + +# PROP Default_Filter "" +# Begin Group "stopwatch" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\stopwatch\ClockCycleCounter.cpp +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\ClockCycleCounter.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\ClockCycleCounter.hpp +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\def.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\fnc.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\fnc.hpp +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\Int64.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\StopWatch.cpp +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\StopWatch.h +# End Source File +# Begin Source File + +SOURCE=.\stopwatch\StopWatch.hpp +# End Source File +# End Group +# Begin Source File + +SOURCE=.\test.cpp +# End Source File +# Begin Source File + +SOURCE=.\test_fnc.h +# End Source File +# Begin Source File + +SOURCE=.\test_fnc.hpp +# End Source File +# Begin Source File + +SOURCE=.\test_settings.h +# End Source File +# Begin Source File + +SOURCE=.\TestAccuracy.h +# End Source File +# Begin Source File + +SOURCE=.\TestAccuracy.hpp +# End Source File +# Begin Source File + +SOURCE=.\TestHelperFixLen.h +# End Source File +# Begin Source File + +SOURCE=.\TestHelperFixLen.hpp +# End Source File +# Begin Source File + +SOURCE=.\TestHelperNormal.h +# End Source File +# Begin Source File + +SOURCE=.\TestHelperNormal.hpp +# End Source File +# Begin Source File + +SOURCE=.\TestSpeed.h +# End Source File +# Begin Source File + +SOURCE=.\TestSpeed.hpp +# End Source File +# Begin Source File + +SOURCE=.\TestWhiteNoiseGen.h +# End Source File +# Begin Source File + +SOURCE=.\TestWhiteNoiseGen.hpp +# End Source File +# End Group +# End Target +# End Project diff --git a/demos/spectrum/3rdparty/fftreal/FFTReal.dsw b/demos/spectrum/3rdparty/fftreal/FFTReal.dsw new file mode 100644 index 0000000..076b0ae --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTReal.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "FFTReal"=.\FFTReal.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/demos/spectrum/3rdparty/fftreal/FFTReal.h b/demos/spectrum/3rdparty/fftreal/FFTReal.h new file mode 100644 index 0000000..9fb2725 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTReal.h @@ -0,0 +1,142 @@ +/***************************************************************************** + + FFTReal.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTReal_HEADER_INCLUDED) +#define FFTReal_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "DynArray.h" +#include "OscSinCos.h" + + + +template <class DT> +class FFTReal +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + enum { MAX_BIT_DEPTH = 30 }; // So length can be represented as long int + + typedef DT DataType; + + explicit FFTReal (long length); + virtual ~FFTReal () {} + + long get_length () const; + void do_fft (DataType f [], const DataType x []) const; + void do_ifft (const DataType f [], DataType x []) const; + void rescale (DataType x []) const; + DataType * use_buffer () const; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + // Over this bit depth, we use direct calculation for sin/cos + enum { TRIGO_BD_LIMIT = 12 }; + + typedef OscSinCos <DataType> OscType; + + void init_br_lut (); + void init_trigo_lut (); + void init_trigo_osc (); + + FORCEINLINE const long * + get_br_ptr () const; + FORCEINLINE const DataType * + get_trigo_ptr (int level) const; + FORCEINLINE long + get_trigo_level_index (int level) const; + + inline void compute_fft_general (DataType f [], const DataType x []) const; + inline void compute_direct_pass_1_2 (DataType df [], const DataType x []) const; + inline void compute_direct_pass_3 (DataType df [], const DataType sf []) const; + inline void compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const; + inline void compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const; + inline void compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const; + + inline void compute_ifft_general (const DataType f [], DataType x []) const; + inline void compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const; + inline void compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const; + inline void compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const; + inline void compute_inverse_pass_3 (DataType df [], const DataType sf []) const; + inline void compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const; + + const long _length; + const int _nbr_bits; + DynArray <long> + _br_lut; + DynArray <DataType> + _trigo_lut; + mutable DynArray <DataType> + _buffer; + mutable DynArray <OscType> + _trigo_osc; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTReal (); + FFTReal (const FFTReal &other); + FFTReal & operator = (const FFTReal &other); + bool operator == (const FFTReal &other); + bool operator != (const FFTReal &other); + +}; // class FFTReal + + + +#include "FFTReal.hpp" + + + +#endif // FFTReal_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTReal.hpp b/demos/spectrum/3rdparty/fftreal/FFTReal.hpp new file mode 100644 index 0000000..335d771 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTReal.hpp @@ -0,0 +1,916 @@ +/***************************************************************************** + + FFTReal.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTReal_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTReal code header. +#endif +#define FFTReal_CURRENT_CODEHEADER + +#if ! defined (FFTReal_CODEHEADER_INCLUDED) +#define FFTReal_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include <cassert> +#include <cmath> + + + +static inline bool FFTReal_is_pow2 (long x) +{ + assert (x > 0); + + return ((x & -x) == x); +} + + + +static inline int FFTReal_get_next_pow2 (long x) +{ + --x; + + int p = 0; + while ((x & ~0xFFFFL) != 0) + { + p += 16; + x >>= 16; + } + while ((x & ~0xFL) != 0) + { + p += 4; + x >>= 4; + } + while (x > 0) + { + ++p; + x >>= 1; + } + + return (p); +} + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/* +============================================================================== +Name: ctor +Input parameters: + - length: length of the array on which we want to do a FFT. Range: power of + 2 only, > 0. +Throws: std::bad_alloc +============================================================================== +*/ + +template <class DT> +FFTReal <DT>::FFTReal (long length) +: _length (length) +, _nbr_bits (FFTReal_get_next_pow2 (length)) +, _br_lut () +, _trigo_lut () +, _buffer (length) +, _trigo_osc () +{ + assert (FFTReal_is_pow2 (length)); + assert (_nbr_bits <= MAX_BIT_DEPTH); + + init_br_lut (); + init_trigo_lut (); + init_trigo_osc (); +} + + + +/* +============================================================================== +Name: get_length +Description: + Returns the number of points processed by this FFT object. +Returns: The number of points, power of 2, > 0. +Throws: Nothing +============================================================================== +*/ + +template <class DT> +long FFTReal <DT>::get_length () const +{ + return (_length); +} + + + +/* +============================================================================== +Name: do_fft +Description: + Compute the FFT of the array. +Input parameters: + - x: pointer on the source array (time). +Output parameters: + - f: pointer on the destination array (frequencies). + f [0...length(x)/2] = real values, + f [length(x)/2+1...length(x)-1] = negative imaginary values of + coefficents 1...length(x)/2-1. +Throws: Nothing +============================================================================== +*/ + +template <class DT> +void FFTReal <DT>::do_fft (DataType f [], const DataType x []) const +{ + assert (f != 0); + assert (f != use_buffer ()); + assert (x != 0); + assert (x != use_buffer ()); + assert (x != f); + + // General case + if (_nbr_bits > 2) + { + compute_fft_general (f, x); + } + + // 4-point FFT + else if (_nbr_bits == 2) + { + f [1] = x [0] - x [2]; + f [3] = x [1] - x [3]; + + const DataType b_0 = x [0] + x [2]; + const DataType b_2 = x [1] + x [3]; + + f [0] = b_0 + b_2; + f [2] = b_0 - b_2; + } + + // 2-point FFT + else if (_nbr_bits == 1) + { + f [0] = x [0] + x [1]; + f [1] = x [0] - x [1]; + } + + // 1-point FFT + else + { + f [0] = x [0]; + } +} + + + +/* +============================================================================== +Name: do_ifft +Description: + Compute the inverse FFT of the array. Note that data must be post-scaled: + IFFT (FFT (x)) = x * length (x). +Input parameters: + - f: pointer on the source array (frequencies). + f [0...length(x)/2] = real values + f [length(x)/2+1...length(x)-1] = negative imaginary values of + coefficents 1...length(x)/2-1. +Output parameters: + - x: pointer on the destination array (time). +Throws: Nothing +============================================================================== +*/ + +template <class DT> +void FFTReal <DT>::do_ifft (const DataType f [], DataType x []) const +{ + assert (f != 0); + assert (f != use_buffer ()); + assert (x != 0); + assert (x != use_buffer ()); + assert (x != f); + + // General case + if (_nbr_bits > 2) + { + compute_ifft_general (f, x); + } + + // 4-point IFFT + else if (_nbr_bits == 2) + { + const DataType b_0 = f [0] + f [2]; + const DataType b_2 = f [0] - f [2]; + + x [0] = b_0 + f [1] * 2; + x [2] = b_0 - f [1] * 2; + x [1] = b_2 + f [3] * 2; + x [3] = b_2 - f [3] * 2; + } + + // 2-point IFFT + else if (_nbr_bits == 1) + { + x [0] = f [0] + f [1]; + x [1] = f [0] - f [1]; + } + + // 1-point IFFT + else + { + x [0] = f [0]; + } +} + + + +/* +============================================================================== +Name: rescale +Description: + Scale an array by divide each element by its length. This function should + be called after FFT + IFFT. +Input parameters: + - x: pointer on array to rescale (time or frequency). +Throws: Nothing +============================================================================== +*/ + +template <class DT> +void FFTReal <DT>::rescale (DataType x []) const +{ + const DataType mul = DataType (1.0 / _length); + + if (_length < 4) + { + long i = _length - 1; + do + { + x [i] *= mul; + --i; + } + while (i >= 0); + } + + else + { + assert ((_length & 3) == 0); + + // Could be optimized with SIMD instruction sets (needs alignment check) + long i = _length - 4; + do + { + x [i + 0] *= mul; + x [i + 1] *= mul; + x [i + 2] *= mul; + x [i + 3] *= mul; + i -= 4; + } + while (i >= 0); + } +} + + + +/* +============================================================================== +Name: use_buffer +Description: + Access the internal buffer, whose length is the FFT one. + Buffer content will be erased at each do_fft() / do_ifft() call! + This buffer cannot be used as: + - source for FFT or IFFT done with this object + - destination for FFT or IFFT done with this object +Returns: + Buffer start address +Throws: Nothing +============================================================================== +*/ + +template <class DT> +typename FFTReal <DT>::DataType * FFTReal <DT>::use_buffer () const +{ + return (&_buffer [0]); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class DT> +void FFTReal <DT>::init_br_lut () +{ + const long length = 1L << _nbr_bits; + _br_lut.resize (length); + + _br_lut [0] = 0; + long br_index = 0; + for (long cnt = 1; cnt < length; ++cnt) + { + // ++br_index (bit reversed) + long bit = length >> 1; + while (((br_index ^= bit) & bit) == 0) + { + bit >>= 1; + } + + _br_lut [cnt] = br_index; + } +} + + + +template <class DT> +void FFTReal <DT>::init_trigo_lut () +{ + using namespace std; + + if (_nbr_bits > 3) + { + const long total_len = (1L << (_nbr_bits - 1)) - 4; + _trigo_lut.resize (total_len); + + for (int level = 3; level < _nbr_bits; ++level) + { + const long level_len = 1L << (level - 1); + DataType * const level_ptr = + &_trigo_lut [get_trigo_level_index (level)]; + const double mul = PI / (level_len << 1); + + for (long i = 0; i < level_len; ++ i) + { + level_ptr [i] = static_cast <DataType> (cos (i * mul)); + } + } + } +} + + + +template <class DT> +void FFTReal <DT>::init_trigo_osc () +{ + const int nbr_osc = _nbr_bits - TRIGO_BD_LIMIT; + if (nbr_osc > 0) + { + _trigo_osc.resize (nbr_osc); + + for (int osc_cnt = 0; osc_cnt < nbr_osc; ++osc_cnt) + { + OscType & osc = _trigo_osc [osc_cnt]; + + const long len = 1L << (TRIGO_BD_LIMIT + osc_cnt); + const double mul = (0.5 * PI) / len; + osc.set_step (mul); + } + } +} + + + +template <class DT> +const long * FFTReal <DT>::get_br_ptr () const +{ + return (&_br_lut [0]); +} + + + +template <class DT> +const typename FFTReal <DT>::DataType * FFTReal <DT>::get_trigo_ptr (int level) const +{ + assert (level >= 3); + + return (&_trigo_lut [get_trigo_level_index (level)]); +} + + + +template <class DT> +long FFTReal <DT>::get_trigo_level_index (int level) const +{ + assert (level >= 3); + + return ((1L << (level - 1)) - 4); +} + + + +// Transform in several passes +template <class DT> +void FFTReal <DT>::compute_fft_general (DataType f [], const DataType x []) const +{ + assert (f != 0); + assert (f != use_buffer ()); + assert (x != 0); + assert (x != use_buffer ()); + assert (x != f); + + DataType * sf; + DataType * df; + + if ((_nbr_bits & 1) != 0) + { + df = use_buffer (); + sf = f; + } + else + { + df = f; + sf = use_buffer (); + } + + compute_direct_pass_1_2 (df, x); + compute_direct_pass_3 (sf, df); + + for (int pass = 3; pass < _nbr_bits; ++ pass) + { + compute_direct_pass_n (df, sf, pass); + + DataType * const temp_ptr = df; + df = sf; + sf = temp_ptr; + } +} + + + +template <class DT> +void FFTReal <DT>::compute_direct_pass_1_2 (DataType df [], const DataType x []) const +{ + assert (df != 0); + assert (x != 0); + assert (df != x); + + const long * const bit_rev_lut_ptr = get_br_ptr (); + long coef_index = 0; + do + { + const long rev_index_0 = bit_rev_lut_ptr [coef_index]; + const long rev_index_1 = bit_rev_lut_ptr [coef_index + 1]; + const long rev_index_2 = bit_rev_lut_ptr [coef_index + 2]; + const long rev_index_3 = bit_rev_lut_ptr [coef_index + 3]; + + DataType * const df2 = df + coef_index; + df2 [1] = x [rev_index_0] - x [rev_index_1]; + df2 [3] = x [rev_index_2] - x [rev_index_3]; + + const DataType sf_0 = x [rev_index_0] + x [rev_index_1]; + const DataType sf_2 = x [rev_index_2] + x [rev_index_3]; + + df2 [0] = sf_0 + sf_2; + df2 [2] = sf_0 - sf_2; + + coef_index += 4; + } + while (coef_index < _length); +} + + + +template <class DT> +void FFTReal <DT>::compute_direct_pass_3 (DataType df [], const DataType sf []) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + + const DataType sqrt2_2 = DataType (SQRT2 * 0.5); + long coef_index = 0; + do + { + DataType v; + + df [coef_index] = sf [coef_index] + sf [coef_index + 4]; + df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4]; + df [coef_index + 2] = sf [coef_index + 2]; + df [coef_index + 6] = sf [coef_index + 6]; + + v = (sf [coef_index + 5] - sf [coef_index + 7]) * sqrt2_2; + df [coef_index + 1] = sf [coef_index + 1] + v; + df [coef_index + 3] = sf [coef_index + 1] - v; + + v = (sf [coef_index + 5] + sf [coef_index + 7]) * sqrt2_2; + df [coef_index + 5] = v + sf [coef_index + 3]; + df [coef_index + 7] = v - sf [coef_index + 3]; + + coef_index += 8; + } + while (coef_index < _length); +} + + + +template <class DT> +void FFTReal <DT>::compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass >= 3); + assert (pass < _nbr_bits); + + if (pass <= TRIGO_BD_LIMIT) + { + compute_direct_pass_n_lut (df, sf, pass); + } + else + { + compute_direct_pass_n_osc (df, sf, pass); + } +} + + + +template <class DT> +void FFTReal <DT>::compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass >= 3); + assert (pass < _nbr_bits); + + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + const DataType * const cos_ptr = get_trigo_ptr (pass); + do + { + const DataType * const sf1r = sf + coef_index; + const DataType * const sf2r = sf1r + nbr_coef; + DataType * const dfr = df + coef_index; + DataType * const dfi = dfr + nbr_coef; + + // Extreme coefficients are always real + dfr [0] = sf1r [0] + sf2r [0]; + dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] = + dfr [h_nbr_coef] = sf1r [h_nbr_coef]; + dfi [h_nbr_coef] = sf2r [h_nbr_coef]; + + // Others are conjugate complex numbers + const DataType * const sf1i = sf1r + h_nbr_coef; + const DataType * const sf2i = sf1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++ i) + { + const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef); + const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef); + DataType v; + + v = sf2r [i] * c - sf2i [i] * s; + dfr [i] = sf1r [i] + v; + dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] = + + v = sf2r [i] * s + sf2i [i] * c; + dfi [i] = v + sf1i [i]; + dfi [nbr_coef - i] = v - sf1i [i]; + } + + coef_index += d_nbr_coef; + } + while (coef_index < _length); +} + + + +template <class DT> +void FFTReal <DT>::compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass > TRIGO_BD_LIMIT); + assert (pass < _nbr_bits); + + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)]; + do + { + const DataType * const sf1r = sf + coef_index; + const DataType * const sf2r = sf1r + nbr_coef; + DataType * const dfr = df + coef_index; + DataType * const dfi = dfr + nbr_coef; + + osc.clear_buffers (); + + // Extreme coefficients are always real + dfr [0] = sf1r [0] + sf2r [0]; + dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] = + dfr [h_nbr_coef] = sf1r [h_nbr_coef]; + dfi [h_nbr_coef] = sf2r [h_nbr_coef]; + + // Others are conjugate complex numbers + const DataType * const sf1i = sf1r + h_nbr_coef; + const DataType * const sf2i = sf1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++ i) + { + osc.step (); + const DataType c = osc.get_cos (); + const DataType s = osc.get_sin (); + DataType v; + + v = sf2r [i] * c - sf2i [i] * s; + dfr [i] = sf1r [i] + v; + dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] = + + v = sf2r [i] * s + sf2i [i] * c; + dfi [i] = v + sf1i [i]; + dfi [nbr_coef - i] = v - sf1i [i]; + } + + coef_index += d_nbr_coef; + } + while (coef_index < _length); +} + + + +// Transform in several pass +template <class DT> +void FFTReal <DT>::compute_ifft_general (const DataType f [], DataType x []) const +{ + assert (f != 0); + assert (f != use_buffer ()); + assert (x != 0); + assert (x != use_buffer ()); + assert (x != f); + + DataType * sf = const_cast <DataType *> (f); + DataType * df; + DataType * df_temp; + + if (_nbr_bits & 1) + { + df = use_buffer (); + df_temp = x; + } + else + { + df = x; + df_temp = use_buffer (); + } + + for (int pass = _nbr_bits - 1; pass >= 3; -- pass) + { + compute_inverse_pass_n (df, sf, pass); + + if (pass < _nbr_bits - 1) + { + DataType * const temp_ptr = df; + df = sf; + sf = temp_ptr; + } + else + { + sf = df; + df = df_temp; + } + } + + compute_inverse_pass_3 (df, sf); + compute_inverse_pass_1_2 (x, df); +} + + + +template <class DT> +void FFTReal <DT>::compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass >= 3); + assert (pass < _nbr_bits); + + if (pass <= TRIGO_BD_LIMIT) + { + compute_inverse_pass_n_lut (df, sf, pass); + } + else + { + compute_inverse_pass_n_osc (df, sf, pass); + } +} + + + +template <class DT> +void FFTReal <DT>::compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass >= 3); + assert (pass < _nbr_bits); + + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + const DataType * const cos_ptr = get_trigo_ptr (pass); + do + { + const DataType * const sfr = sf + coef_index; + const DataType * const sfi = sfr + nbr_coef; + DataType * const df1r = df + coef_index; + DataType * const df2r = df1r + nbr_coef; + + // Extreme coefficients are always real + df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef] + df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef] + df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2; + df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2; + + // Others are conjugate complex numbers + DataType * const df1i = df1r + h_nbr_coef; + DataType * const df2i = df1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++ i) + { + df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i] + df1i [i] = sfi [i] - sfi [nbr_coef - i]; + + const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef); + const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef); + const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i] + const DataType vi = sfi [i] + sfi [nbr_coef - i]; + + df2r [i] = vr * c + vi * s; + df2i [i] = vi * c - vr * s; + } + + coef_index += d_nbr_coef; + } + while (coef_index < _length); +} + + + +template <class DT> +void FFTReal <DT>::compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + assert (pass > TRIGO_BD_LIMIT); + assert (pass < _nbr_bits); + + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)]; + do + { + const DataType * const sfr = sf + coef_index; + const DataType * const sfi = sfr + nbr_coef; + DataType * const df1r = df + coef_index; + DataType * const df2r = df1r + nbr_coef; + + osc.clear_buffers (); + + // Extreme coefficients are always real + df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef] + df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef] + df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2; + df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2; + + // Others are conjugate complex numbers + DataType * const df1i = df1r + h_nbr_coef; + DataType * const df2i = df1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++ i) + { + df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i] + df1i [i] = sfi [i] - sfi [nbr_coef - i]; + + osc.step (); + const DataType c = osc.get_cos (); + const DataType s = osc.get_sin (); + const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i] + const DataType vi = sfi [i] + sfi [nbr_coef - i]; + + df2r [i] = vr * c + vi * s; + df2i [i] = vi * c - vr * s; + } + + coef_index += d_nbr_coef; + } + while (coef_index < _length); +} + + + +template <class DT> +void FFTReal <DT>::compute_inverse_pass_3 (DataType df [], const DataType sf []) const +{ + assert (df != 0); + assert (sf != 0); + assert (df != sf); + + const DataType sqrt2_2 = DataType (SQRT2 * 0.5); + long coef_index = 0; + do + { + df [coef_index] = sf [coef_index] + sf [coef_index + 4]; + df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4]; + df [coef_index + 2] = sf [coef_index + 2] * 2; + df [coef_index + 6] = sf [coef_index + 6] * 2; + + df [coef_index + 1] = sf [coef_index + 1] + sf [coef_index + 3]; + df [coef_index + 3] = sf [coef_index + 5] - sf [coef_index + 7]; + + const DataType vr = sf [coef_index + 1] - sf [coef_index + 3]; + const DataType vi = sf [coef_index + 5] + sf [coef_index + 7]; + + df [coef_index + 5] = (vr + vi) * sqrt2_2; + df [coef_index + 7] = (vi - vr) * sqrt2_2; + + coef_index += 8; + } + while (coef_index < _length); +} + + + +template <class DT> +void FFTReal <DT>::compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const +{ + assert (x != 0); + assert (sf != 0); + assert (x != sf); + + const long * bit_rev_lut_ptr = get_br_ptr (); + const DataType * sf2 = sf; + long coef_index = 0; + do + { + { + const DataType b_0 = sf2 [0] + sf2 [2]; + const DataType b_2 = sf2 [0] - sf2 [2]; + const DataType b_1 = sf2 [1] * 2; + const DataType b_3 = sf2 [3] * 2; + + x [bit_rev_lut_ptr [0]] = b_0 + b_1; + x [bit_rev_lut_ptr [1]] = b_0 - b_1; + x [bit_rev_lut_ptr [2]] = b_2 + b_3; + x [bit_rev_lut_ptr [3]] = b_2 - b_3; + } + { + const DataType b_0 = sf2 [4] + sf2 [6]; + const DataType b_2 = sf2 [4] - sf2 [6]; + const DataType b_1 = sf2 [5] * 2; + const DataType b_3 = sf2 [7] * 2; + + x [bit_rev_lut_ptr [4]] = b_0 + b_1; + x [bit_rev_lut_ptr [5]] = b_0 - b_1; + x [bit_rev_lut_ptr [6]] = b_2 + b_3; + x [bit_rev_lut_ptr [7]] = b_2 - b_3; + } + + sf2 += 8; + coef_index += 8; + bit_rev_lut_ptr += 8; + } + while (coef_index < _length); +} + + + +#endif // FFTReal_CODEHEADER_INCLUDED + +#undef FFTReal_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealFixLen.h b/demos/spectrum/3rdparty/fftreal/FFTRealFixLen.h new file mode 100644 index 0000000..0b80266 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealFixLen.h @@ -0,0 +1,130 @@ +/***************************************************************************** + + FFTRealFixLen.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealFixLen_HEADER_INCLUDED) +#define FFTRealFixLen_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "Array.h" +#include "DynArray.h" +#include "FFTRealFixLenParam.h" +#include "OscSinCos.h" + + + +template <int LL2> +class FFTRealFixLen +{ + typedef int CompileTimeCheck1 [(LL2 >= 0) ? 1 : -1]; + typedef int CompileTimeCheck2 [(LL2 <= 30) ? 1 : -1]; + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos <DataType> OscType; + + enum { FFT_LEN_L2 = LL2 }; + enum { FFT_LEN = 1 << FFT_LEN_L2 }; + + FFTRealFixLen (); + + inline long get_length () const; + void do_fft (DataType f [], const DataType x []); + void do_ifft (const DataType f [], DataType x []); + void rescale (DataType x []) const; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + enum { TRIGO_BD_LIMIT = FFTRealFixLenParam::TRIGO_BD_LIMIT }; + + enum { BR_ARR_SIZE_L2 = ((FFT_LEN_L2 - 3) < 0) ? 0 : (FFT_LEN_L2 - 2) }; + enum { BR_ARR_SIZE = 1 << BR_ARR_SIZE_L2 }; + + enum { TRIGO_BD = ((FFT_LEN_L2 - TRIGO_BD_LIMIT) < 0) + ? (int)FFT_LEN_L2 + : (int)TRIGO_BD_LIMIT }; + enum { TRIGO_TABLE_ARR_SIZE_L2 = (LL2 < 4) ? 0 : (TRIGO_BD - 2) }; + enum { TRIGO_TABLE_ARR_SIZE = 1 << TRIGO_TABLE_ARR_SIZE_L2 }; + + enum { NBR_TRIGO_OSC = FFT_LEN_L2 - TRIGO_BD }; + enum { TRIGO_OSC_ARR_SIZE = (NBR_TRIGO_OSC > 0) ? NBR_TRIGO_OSC : 1 }; + + void build_br_lut (); + void build_trigo_lut (); + void build_trigo_osc (); + + DynArray <DataType> + _buffer; + DynArray <long> + _br_data; + DynArray <DataType> + _trigo_data; + Array <OscType, TRIGO_OSC_ARR_SIZE> + _trigo_osc; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealFixLen (const FFTRealFixLen &other); + FFTRealFixLen& operator = (const FFTRealFixLen &other); + bool operator == (const FFTRealFixLen &other); + bool operator != (const FFTRealFixLen &other); + +}; // class FFTRealFixLen + + + +#include "FFTRealFixLen.hpp" + + + +#endif // FFTRealFixLen_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealFixLen.hpp b/demos/spectrum/3rdparty/fftreal/FFTRealFixLen.hpp new file mode 100644 index 0000000..6defb00 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealFixLen.hpp @@ -0,0 +1,322 @@ +/***************************************************************************** + + FFTRealFixLen.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealFixLen_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealFixLen code header. +#endif +#define FFTRealFixLen_CURRENT_CODEHEADER + +#if ! defined (FFTRealFixLen_CODEHEADER_INCLUDED) +#define FFTRealFixLen_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "FFTRealPassDirect.h" +#include "FFTRealPassInverse.h" +#include "FFTRealSelect.h" + +#include <cassert> +#include <cmath> + +namespace std { } + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <int LL2> +FFTRealFixLen <LL2>::FFTRealFixLen () +: _buffer (FFT_LEN) +, _br_data (BR_ARR_SIZE) +, _trigo_data (TRIGO_TABLE_ARR_SIZE) +, _trigo_osc () +{ + build_br_lut (); + build_trigo_lut (); + build_trigo_osc (); +} + + + +template <int LL2> +long FFTRealFixLen <LL2>::get_length () const +{ + return (FFT_LEN); +} + + + +// General case +template <int LL2> +void FFTRealFixLen <LL2>::do_fft (DataType f [], const DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + assert (FFT_LEN_L2 >= 3); + + // Do the transform in several passes + const DataType * cos_ptr = &_trigo_data [0]; + const long * br_ptr = &_br_data [0]; + + FFTRealPassDirect <FFT_LEN_L2 - 1>::process ( + FFT_LEN, + f, + &_buffer [0], + x, + cos_ptr, + TRIGO_TABLE_ARR_SIZE, + br_ptr, + &_trigo_osc [0] + ); +} + +// 4-point FFT +template <> +void FFTRealFixLen <2>::do_fft (DataType f [], const DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + f [1] = x [0] - x [2]; + f [3] = x [1] - x [3]; + + const DataType b_0 = x [0] + x [2]; + const DataType b_2 = x [1] + x [3]; + + f [0] = b_0 + b_2; + f [2] = b_0 - b_2; +} + +// 2-point FFT +template <> +void FFTRealFixLen <1>::do_fft (DataType f [], const DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + f [0] = x [0] + x [1]; + f [1] = x [0] - x [1]; +} + +// 1-point FFT +template <> +void FFTRealFixLen <0>::do_fft (DataType f [], const DataType x []) +{ + assert (f != 0); + assert (x != 0); + + f [0] = x [0]; +} + + + +// General case +template <int LL2> +void FFTRealFixLen <LL2>::do_ifft (const DataType f [], DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + assert (FFT_LEN_L2 >= 3); + + // Do the transform in several passes + DataType * s_ptr = + FFTRealSelect <FFT_LEN_L2 & 1>::sel_bin (&_buffer [0], x); + DataType * d_ptr = + FFTRealSelect <FFT_LEN_L2 & 1>::sel_bin (x, &_buffer [0]); + const DataType * cos_ptr = &_trigo_data [0]; + const long * br_ptr = &_br_data [0]; + + FFTRealPassInverse <FFT_LEN_L2 - 1>::process ( + FFT_LEN, + d_ptr, + s_ptr, + f, + cos_ptr, + TRIGO_TABLE_ARR_SIZE, + br_ptr, + &_trigo_osc [0] + ); +} + +// 4-point IFFT +template <> +void FFTRealFixLen <2>::do_ifft (const DataType f [], DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + const DataType b_0 = f [0] + f [2]; + const DataType b_2 = f [0] - f [2]; + + x [0] = b_0 + f [1] * 2; + x [2] = b_0 - f [1] * 2; + x [1] = b_2 + f [3] * 2; + x [3] = b_2 - f [3] * 2; +} + +// 2-point IFFT +template <> +void FFTRealFixLen <1>::do_ifft (const DataType f [], DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + x [0] = f [0] + f [1]; + x [1] = f [0] - f [1]; +} + +// 1-point IFFT +template <> +void FFTRealFixLen <0>::do_ifft (const DataType f [], DataType x []) +{ + assert (f != 0); + assert (x != 0); + assert (x != f); + + x [0] = f [0]; +} + + + + +template <int LL2> +void FFTRealFixLen <LL2>::rescale (DataType x []) const +{ + assert (x != 0); + + const DataType mul = DataType (1.0 / FFT_LEN); + + if (FFT_LEN < 4) + { + long i = FFT_LEN - 1; + do + { + x [i] *= mul; + --i; + } + while (i >= 0); + } + + else + { + assert ((FFT_LEN & 3) == 0); + + // Could be optimized with SIMD instruction sets (needs alignment check) + long i = FFT_LEN - 4; + do + { + x [i + 0] *= mul; + x [i + 1] *= mul; + x [i + 2] *= mul; + x [i + 3] *= mul; + i -= 4; + } + while (i >= 0); + } +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <int LL2> +void FFTRealFixLen <LL2>::build_br_lut () +{ + _br_data [0] = 0; + for (long cnt = 1; cnt < BR_ARR_SIZE; ++cnt) + { + long index = cnt << 2; + long br_index = 0; + + int bit_cnt = FFT_LEN_L2; + do + { + br_index <<= 1; + br_index += (index & 1); + index >>= 1; + + -- bit_cnt; + } + while (bit_cnt > 0); + + _br_data [cnt] = br_index; + } +} + + + +template <int LL2> +void FFTRealFixLen <LL2>::build_trigo_lut () +{ + const double mul = (0.5 * PI) / TRIGO_TABLE_ARR_SIZE; + for (long i = 0; i < TRIGO_TABLE_ARR_SIZE; ++ i) + { + using namespace std; + + _trigo_data [i] = DataType (cos (i * mul)); + } +} + + + +template <int LL2> +void FFTRealFixLen <LL2>::build_trigo_osc () +{ + for (int i = 0; i < NBR_TRIGO_OSC; ++i) + { + OscType & osc = _trigo_osc [i]; + + const long len = static_cast <long> (TRIGO_TABLE_ARR_SIZE) << (i + 1); + const double mul = (0.5 * PI) / len; + osc.set_step (mul); + } +} + + + +#endif // FFTRealFixLen_CODEHEADER_INCLUDED + +#undef FFTRealFixLen_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealFixLenParam.h b/demos/spectrum/3rdparty/fftreal/FFTRealFixLenParam.h new file mode 100644 index 0000000..163c083 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealFixLenParam.h @@ -0,0 +1,93 @@ +/***************************************************************************** + + FFTRealFixLenParam.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealFixLenParam_HEADER_INCLUDED) +#define FFTRealFixLenParam_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +class FFTRealFixLenParam +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + // Over this bit depth, we use direct calculation for sin/cos + enum { TRIGO_BD_LIMIT = 12 }; + + typedef float DataType; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + +#if 0 // To avoid GCC warning: + // All member functions in class 'FFTRealFixLenParam' are private + FFTRealFixLenParam (); + ~FFTRealFixLenParam (); + FFTRealFixLenParam (const FFTRealFixLenParam &other); + FFTRealFixLenParam & + operator = (const FFTRealFixLenParam &other); + bool operator == (const FFTRealFixLenParam &other); + bool operator != (const FFTRealFixLenParam &other); +#endif + +}; // class FFTRealFixLenParam + + + +//#include "FFTRealFixLenParam.hpp" + + + +#endif // FFTRealFixLenParam_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealPassDirect.h b/demos/spectrum/3rdparty/fftreal/FFTRealPassDirect.h new file mode 100644 index 0000000..7d19c02 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealPassDirect.h @@ -0,0 +1,96 @@ +/***************************************************************************** + + FFTRealPassDirect.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealPassDirect_HEADER_INCLUDED) +#define FFTRealPassDirect_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "FFTRealFixLenParam.h" +#include "OscSinCos.h" + + + +template <int PASS> +class FFTRealPassDirect +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos <DataType> OscType; + + FORCEINLINE static void + process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealPassDirect (); + ~FFTRealPassDirect (); + FFTRealPassDirect (const FFTRealPassDirect &other); + FFTRealPassDirect & + operator = (const FFTRealPassDirect &other); + bool operator == (const FFTRealPassDirect &other); + bool operator != (const FFTRealPassDirect &other); + +}; // class FFTRealPassDirect + + + +#include "FFTRealPassDirect.hpp" + + + +#endif // FFTRealPassDirect_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealPassDirect.hpp b/demos/spectrum/3rdparty/fftreal/FFTRealPassDirect.hpp new file mode 100644 index 0000000..db9d568 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealPassDirect.hpp @@ -0,0 +1,204 @@ +/***************************************************************************** + + FFTRealPassDirect.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealPassDirect_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealPassDirect code header. +#endif +#define FFTRealPassDirect_CURRENT_CODEHEADER + +#if ! defined (FFTRealPassDirect_CODEHEADER_INCLUDED) +#define FFTRealPassDirect_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "FFTRealUseTrigo.h" + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <> +void FFTRealPassDirect <1>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // First and second pass at once + const long qlen = len >> 2; + + long coef_index = 0; + do + { + // To do: unroll the loop (2x). + const long ri_0 = br_ptr [coef_index >> 2]; + const long ri_1 = ri_0 + 2 * qlen; // bit_rev_lut_ptr [coef_index + 1]; + const long ri_2 = ri_0 + 1 * qlen; // bit_rev_lut_ptr [coef_index + 2]; + const long ri_3 = ri_0 + 3 * qlen; // bit_rev_lut_ptr [coef_index + 3]; + + DataType * const df2 = dest_ptr + coef_index; + df2 [1] = x_ptr [ri_0] - x_ptr [ri_1]; + df2 [3] = x_ptr [ri_2] - x_ptr [ri_3]; + + const DataType sf_0 = x_ptr [ri_0] + x_ptr [ri_1]; + const DataType sf_2 = x_ptr [ri_2] + x_ptr [ri_3]; + + df2 [0] = sf_0 + sf_2; + df2 [2] = sf_0 - sf_2; + + coef_index += 4; + } + while (coef_index < len); +} + +template <> +void FFTRealPassDirect <2>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Executes "previous" passes first. Inverts source and destination buffers + FFTRealPassDirect <1>::process ( + len, + src_ptr, + dest_ptr, + x_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); + + // Third pass + const DataType sqrt2_2 = DataType (SQRT2 * 0.5); + + long coef_index = 0; + do + { + dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4]; + dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4]; + dest_ptr [coef_index + 2] = src_ptr [coef_index + 2]; + dest_ptr [coef_index + 6] = src_ptr [coef_index + 6]; + + DataType v; + + v = (src_ptr [coef_index + 5] - src_ptr [coef_index + 7]) * sqrt2_2; + dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + v; + dest_ptr [coef_index + 3] = src_ptr [coef_index + 1] - v; + + v = (src_ptr [coef_index + 5] + src_ptr [coef_index + 7]) * sqrt2_2; + dest_ptr [coef_index + 5] = v + src_ptr [coef_index + 3]; + dest_ptr [coef_index + 7] = v - src_ptr [coef_index + 3]; + + coef_index += 8; + } + while (coef_index < len); +} + +template <int PASS> +void FFTRealPassDirect <PASS>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Executes "previous" passes first. Inverts source and destination buffers + FFTRealPassDirect <PASS - 1>::process ( + len, + src_ptr, + dest_ptr, + x_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); + + const long dist = 1L << (PASS - 1); + const long c1_r = 0; + const long c1_i = dist; + const long c2_r = dist * 2; + const long c2_i = dist * 3; + const long cend = dist * 4; + const long table_step = cos_len >> (PASS - 1); + + enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT }; + enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 }; + + long coef_index = 0; + do + { + const DataType * const sf = src_ptr + coef_index; + DataType * const df = dest_ptr + coef_index; + + // Extreme coefficients are always real + df [c1_r] = sf [c1_r] + sf [c2_r]; + df [c2_r] = sf [c1_r] - sf [c2_r]; + df [c1_i] = sf [c1_i]; + df [c2_i] = sf [c2_i]; + + FFTRealUseTrigo <TRIGO_DIRECT>::prepare (osc_list [TRIGO_OSC]); + + // Others are conjugate complex numbers + for (long i = 1; i < dist; ++ i) + { + DataType c; + DataType s; + FFTRealUseTrigo <TRIGO_DIRECT>::iterate ( + osc_list [TRIGO_OSC], + c, + s, + cos_ptr, + i * table_step, + (dist - i) * table_step + ); + + const DataType sf_r_i = sf [c1_r + i]; + const DataType sf_i_i = sf [c1_i + i]; + + const DataType v1 = sf [c2_r + i] * c - sf [c2_i + i] * s; + df [c1_r + i] = sf_r_i + v1; + df [c2_r - i] = sf_r_i - v1; + + const DataType v2 = sf [c2_r + i] * s + sf [c2_i + i] * c; + df [c2_r + i] = v2 + sf_i_i; + df [cend - i] = v2 - sf_i_i; + } + + coef_index += cend; + } + while (coef_index < len); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // FFTRealPassDirect_CODEHEADER_INCLUDED + +#undef FFTRealPassDirect_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealPassInverse.h b/demos/spectrum/3rdparty/fftreal/FFTRealPassInverse.h new file mode 100644 index 0000000..2de8952 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealPassInverse.h @@ -0,0 +1,101 @@ +/***************************************************************************** + + FFTRealPassInverse.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealPassInverse_HEADER_INCLUDED) +#define FFTRealPassInverse_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "FFTRealFixLenParam.h" +#include "OscSinCos.h" + + + + +template <int PASS> +class FFTRealPassInverse +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos <DataType> OscType; + + FORCEINLINE static void + process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); + FORCEINLINE static void + process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); + FORCEINLINE static void + process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealPassInverse (); + ~FFTRealPassInverse (); + FFTRealPassInverse (const FFTRealPassInverse &other); + FFTRealPassInverse & + operator = (const FFTRealPassInverse &other); + bool operator == (const FFTRealPassInverse &other); + bool operator != (const FFTRealPassInverse &other); + +}; // class FFTRealPassInverse + + + +#include "FFTRealPassInverse.hpp" + + + +#endif // FFTRealPassInverse_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealPassInverse.hpp b/demos/spectrum/3rdparty/fftreal/FFTRealPassInverse.hpp new file mode 100644 index 0000000..5737546 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealPassInverse.hpp @@ -0,0 +1,229 @@ +/***************************************************************************** + + FFTRealPassInverse.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealPassInverse_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealPassInverse code header. +#endif +#define FFTRealPassInverse_CURRENT_CODEHEADER + +#if ! defined (FFTRealPassInverse_CODEHEADER_INCLUDED) +#define FFTRealPassInverse_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "FFTRealUseTrigo.h" + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <int PASS> +void FFTRealPassInverse <PASS>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + process_internal ( + len, + dest_ptr, + f_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); + FFTRealPassInverse <PASS - 1>::process_rec ( + len, + src_ptr, + dest_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); +} + + + +template <int PASS> +void FFTRealPassInverse <PASS>::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + process_internal ( + len, + dest_ptr, + src_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); + FFTRealPassInverse <PASS - 1>::process_rec ( + len, + src_ptr, + dest_ptr, + cos_ptr, + cos_len, + br_ptr, + osc_list + ); +} + +template <> +void FFTRealPassInverse <0>::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Stops recursion +} + + + +template <int PASS> +void FFTRealPassInverse <PASS>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + const long dist = 1L << (PASS - 1); + const long c1_r = 0; + const long c1_i = dist; + const long c2_r = dist * 2; + const long c2_i = dist * 3; + const long cend = dist * 4; + const long table_step = cos_len >> (PASS - 1); + + enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT }; + enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 }; + + long coef_index = 0; + do + { + const DataType * const sf = src_ptr + coef_index; + DataType * const df = dest_ptr + coef_index; + + // Extreme coefficients are always real + df [c1_r] = sf [c1_r] + sf [c2_r]; + df [c2_r] = sf [c1_r] - sf [c2_r]; + df [c1_i] = sf [c1_i] * 2; + df [c2_i] = sf [c2_i] * 2; + + FFTRealUseTrigo <TRIGO_DIRECT>::prepare (osc_list [TRIGO_OSC]); + + // Others are conjugate complex numbers + for (long i = 1; i < dist; ++ i) + { + df [c1_r + i] = sf [c1_r + i] + sf [c2_r - i]; + df [c1_i + i] = sf [c2_r + i] - sf [cend - i]; + + DataType c; + DataType s; + FFTRealUseTrigo <TRIGO_DIRECT>::iterate ( + osc_list [TRIGO_OSC], + c, + s, + cos_ptr, + i * table_step, + (dist - i) * table_step + ); + + const DataType vr = sf [c1_r + i] - sf [c2_r - i]; + const DataType vi = sf [c2_r + i] + sf [cend - i]; + + df [c2_r + i] = vr * c + vi * s; + df [c2_i + i] = vi * c - vr * s; + } + + coef_index += cend; + } + while (coef_index < len); +} + +template <> +void FFTRealPassInverse <2>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Antepenultimate pass + const DataType sqrt2_2 = DataType (SQRT2 * 0.5); + + long coef_index = 0; + do + { + dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4]; + dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4]; + dest_ptr [coef_index + 2] = src_ptr [coef_index + 2] * 2; + dest_ptr [coef_index + 6] = src_ptr [coef_index + 6] * 2; + + dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + src_ptr [coef_index + 3]; + dest_ptr [coef_index + 3] = src_ptr [coef_index + 5] - src_ptr [coef_index + 7]; + + const DataType vr = src_ptr [coef_index + 1] - src_ptr [coef_index + 3]; + const DataType vi = src_ptr [coef_index + 5] + src_ptr [coef_index + 7]; + + dest_ptr [coef_index + 5] = (vr + vi) * sqrt2_2; + dest_ptr [coef_index + 7] = (vi - vr) * sqrt2_2; + + coef_index += 8; + } + while (coef_index < len); +} + +template <> +void FFTRealPassInverse <1>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +{ + // Penultimate and last pass at once + const long qlen = len >> 2; + + long coef_index = 0; + do + { + const long ri_0 = br_ptr [coef_index >> 2]; + + const DataType b_0 = src_ptr [coef_index ] + src_ptr [coef_index + 2]; + const DataType b_2 = src_ptr [coef_index ] - src_ptr [coef_index + 2]; + const DataType b_1 = src_ptr [coef_index + 1] * 2; + const DataType b_3 = src_ptr [coef_index + 3] * 2; + + dest_ptr [ri_0 ] = b_0 + b_1; + dest_ptr [ri_0 + 2 * qlen] = b_0 - b_1; + dest_ptr [ri_0 + 1 * qlen] = b_2 + b_3; + dest_ptr [ri_0 + 3 * qlen] = b_2 - b_3; + + coef_index += 4; + } + while (coef_index < len); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // FFTRealPassInverse_CODEHEADER_INCLUDED + +#undef FFTRealPassInverse_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealSelect.h b/demos/spectrum/3rdparty/fftreal/FFTRealSelect.h new file mode 100644 index 0000000..bd722d4 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealSelect.h @@ -0,0 +1,77 @@ +/***************************************************************************** + + FFTRealSelect.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealSelect_HEADER_INCLUDED) +#define FFTRealSelect_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" + + + +template <int P> +class FFTRealSelect +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + FORCEINLINE static float * + sel_bin (float *e_ptr, float *o_ptr); + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealSelect (); + ~FFTRealSelect (); + FFTRealSelect (const FFTRealSelect &other); + FFTRealSelect& operator = (const FFTRealSelect &other); + bool operator == (const FFTRealSelect &other); + bool operator != (const FFTRealSelect &other); + +}; // class FFTRealSelect + + + +#include "FFTRealSelect.hpp" + + + +#endif // FFTRealSelect_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealSelect.hpp b/demos/spectrum/3rdparty/fftreal/FFTRealSelect.hpp new file mode 100644 index 0000000..9ddf586 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealSelect.hpp @@ -0,0 +1,62 @@ +/***************************************************************************** + + FFTRealSelect.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealSelect_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealSelect code header. +#endif +#define FFTRealSelect_CURRENT_CODEHEADER + +#if ! defined (FFTRealSelect_CODEHEADER_INCLUDED) +#define FFTRealSelect_CODEHEADER_INCLUDED + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <int P> +float * FFTRealSelect <P>::sel_bin (float *e_ptr, float *o_ptr) +{ + return (o_ptr); +} + + + +template <> +float * FFTRealSelect <0>::sel_bin (float *e_ptr, float *o_ptr) +{ + return (e_ptr); +} + + + +#endif // FFTRealSelect_CODEHEADER_INCLUDED + +#undef FFTRealSelect_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.h b/demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.h new file mode 100644 index 0000000..c4368ee --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.h @@ -0,0 +1,101 @@ +/***************************************************************************** + + FFTRealUseTrigo.h + Copyright (c) 2005 Laurent de Soras + +Template parameters: + - ALGO: algorithm choice. 0 = table, other = oscillator + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (FFTRealUseTrigo_HEADER_INCLUDED) +#define FFTRealUseTrigo_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "FFTRealFixLenParam.h" +#include "OscSinCos.h" + + + +template <int ALGO> +class FFTRealUseTrigo +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos <DataType> OscType; + + FORCEINLINE static void + prepare (OscType &osc); + FORCEINLINE static void + iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + FFTRealUseTrigo (); + ~FFTRealUseTrigo (); + FFTRealUseTrigo (const FFTRealUseTrigo &other); + FFTRealUseTrigo & + operator = (const FFTRealUseTrigo &other); + bool operator == (const FFTRealUseTrigo &other); + bool operator != (const FFTRealUseTrigo &other); + +}; // class FFTRealUseTrigo + + + +#include "FFTRealUseTrigo.hpp" + + + +#endif // FFTRealUseTrigo_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.hpp b/demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.hpp new file mode 100644 index 0000000..aa968b8 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/FFTRealUseTrigo.hpp @@ -0,0 +1,91 @@ +/***************************************************************************** + + FFTRealUseTrigo.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (FFTRealUseTrigo_CURRENT_CODEHEADER) + #error Recursive inclusion of FFTRealUseTrigo code header. +#endif +#define FFTRealUseTrigo_CURRENT_CODEHEADER + +#if ! defined (FFTRealUseTrigo_CODEHEADER_INCLUDED) +#define FFTRealUseTrigo_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "OscSinCos.h" + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <int ALGO> +void FFTRealUseTrigo <ALGO>::prepare (OscType &osc) +{ + osc.clear_buffers (); +} + +template <> +void FFTRealUseTrigo <0>::prepare (OscType &osc) +{ + // Nothing +} + + + +template <int ALGO> +void FFTRealUseTrigo <ALGO>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) +{ + osc.step (); + c = osc.get_cos (); + s = osc.get_sin (); +} + +template <> +void FFTRealUseTrigo <0>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) +{ + c = cos_ptr [index_c]; + s = cos_ptr [index_s]; +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // FFTRealUseTrigo_CODEHEADER_INCLUDED + +#undef FFTRealUseTrigo_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/OscSinCos.h b/demos/spectrum/3rdparty/fftreal/OscSinCos.h new file mode 100644 index 0000000..775fc14 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/OscSinCos.h @@ -0,0 +1,106 @@ +/***************************************************************************** + + OscSinCos.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (OscSinCos_HEADER_INCLUDED) +#define OscSinCos_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" + + + +template <class T> +class OscSinCos +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef T DataType; + + OscSinCos (); + + FORCEINLINE void + set_step (double angle_rad); + + FORCEINLINE DataType + get_cos () const; + FORCEINLINE DataType + get_sin () const; + FORCEINLINE void + step (); + FORCEINLINE void + clear_buffers (); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + DataType _pos_cos; // Current phase expressed with sin and cos. [-1 ; 1] + DataType _pos_sin; // - + DataType _step_cos; // Phase increment per step, [-1 ; 1] + DataType _step_sin; // - + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + OscSinCos (const OscSinCos &other); + OscSinCos & operator = (const OscSinCos &other); + bool operator == (const OscSinCos &other); + bool operator != (const OscSinCos &other); + +}; // class OscSinCos + + + +#include "OscSinCos.hpp" + + + +#endif // OscSinCos_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/OscSinCos.hpp b/demos/spectrum/3rdparty/fftreal/OscSinCos.hpp new file mode 100644 index 0000000..749aef0 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/OscSinCos.hpp @@ -0,0 +1,122 @@ +/***************************************************************************** + + OscSinCos.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (OscSinCos_CURRENT_CODEHEADER) + #error Recursive inclusion of OscSinCos code header. +#endif +#define OscSinCos_CURRENT_CODEHEADER + +#if ! defined (OscSinCos_CODEHEADER_INCLUDED) +#define OscSinCos_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include <cmath> + +namespace std { } + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class T> +OscSinCos <T>::OscSinCos () +: _pos_cos (1) +, _pos_sin (0) +, _step_cos (1) +, _step_sin (0) +{ + // Nothing +} + + + +template <class T> +void OscSinCos <T>::set_step (double angle_rad) +{ + using namespace std; + + _step_cos = static_cast <DataType> (cos (angle_rad)); + _step_sin = static_cast <DataType> (sin (angle_rad)); +} + + + +template <class T> +typename OscSinCos <T>::DataType OscSinCos <T>::get_cos () const +{ + return (_pos_cos); +} + + + +template <class T> +typename OscSinCos <T>::DataType OscSinCos <T>::get_sin () const +{ + return (_pos_sin); +} + + + +template <class T> +void OscSinCos <T>::step () +{ + const DataType old_cos = _pos_cos; + const DataType old_sin = _pos_sin; + + _pos_cos = old_cos * _step_cos - old_sin * _step_sin; + _pos_sin = old_cos * _step_sin + old_sin * _step_cos; +} + + + +template <class T> +void OscSinCos <T>::clear_buffers () +{ + _pos_cos = static_cast <DataType> (1); + _pos_sin = static_cast <DataType> (0); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // OscSinCos_CODEHEADER_INCLUDED + +#undef OscSinCos_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestAccuracy.h b/demos/spectrum/3rdparty/fftreal/TestAccuracy.h new file mode 100644 index 0000000..4b07a6b --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestAccuracy.h @@ -0,0 +1,105 @@ +/***************************************************************************** + + TestAccuracy.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestAccuracy_HEADER_INCLUDED) +#define TestAccuracy_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class FO> +class TestAccuracy +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef typename FO::DataType DataType; + typedef long double BigFloat; // To get maximum accuracy during intermediate calculations + + static int perform_test_single_object (FO &fft); + static int perform_test_d (FO &fft, const char *class_name_0); + static int perform_test_i (FO &fft, const char *class_name_0); + static int perform_test_di (FO &fft, const char *class_name_0); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + enum { NBR_ACC_TESTS = 10 * 1000 * 1000 }; + enum { MAX_NBR_TESTS = 10000 }; + + static void compute_tf (DataType s [], const DataType x [], long length); + static void compute_itf (DataType x [], const DataType s [], long length); + static int compare_vect_display (const DataType x_ptr [], const DataType y_ptr [], long len, BigFloat &max_err_rel); + static BigFloat + compute_power (const DataType x_ptr [], long len); + static BigFloat + compute_power (const DataType x_ptr [], const DataType y_ptr [], long len); + static void compare_vect (const DataType x_ptr [], const DataType y_ptr [], BigFloat &power, long &max_err_pos, long len); + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestAccuracy (); + ~TestAccuracy (); + TestAccuracy (const TestAccuracy &other); + TestAccuracy & operator = (const TestAccuracy &other); + bool operator == (const TestAccuracy &other); + bool operator != (const TestAccuracy &other); + +}; // class TestAccuracy + + + +#include "TestAccuracy.hpp" + + + +#endif // TestAccuracy_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestAccuracy.hpp b/demos/spectrum/3rdparty/fftreal/TestAccuracy.hpp new file mode 100644 index 0000000..5c794f7 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestAccuracy.hpp @@ -0,0 +1,472 @@ +/***************************************************************************** + + TestAccuracy.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestAccuracy_CURRENT_CODEHEADER) + #error Recursive inclusion of TestAccuracy code header. +#endif +#define TestAccuracy_CURRENT_CODEHEADER + +#if ! defined (TestAccuracy_CODEHEADER_INCLUDED) +#define TestAccuracy_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "test_fnc.h" +#include "TestWhiteNoiseGen.h" + +#include <typeinfo> +#include <vector> + +#include <cmath> +#include <cstdio> + + + +static const double TestAccuracy_LN10 = 2.3025850929940456840179914546844; + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class FO> +int TestAccuracy <FO>::perform_test_single_object (FO &fft) +{ + assert (&fft != 0); + + using namespace std; + + int ret_val = 0; + + const std::type_info & ti = typeid (fft); + const char * class_name_0 = ti.name (); + + if (ret_val == 0) + { + ret_val = perform_test_d (fft, class_name_0); + } + if (ret_val == 0) + { + ret_val = perform_test_i (fft, class_name_0); + } + if (ret_val == 0) + { + ret_val = perform_test_di (fft, class_name_0); + } + + if (ret_val == 0) + { + printf ("\n"); + } + + return (ret_val); +} + + + +template <class FO> +int TestAccuracy <FO>::perform_test_d (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + using namespace std; + + int ret_val = 0; + const long len = fft.get_length (); + const long nbr_tests = limit ( + NBR_ACC_TESTS / len / len, + 1L, + static_cast <long> (MAX_NBR_TESTS) + ); + + printf ("Testing %s::do_fft () [%ld samples]... ", class_name_0, len); + fflush (stdout); + TestWhiteNoiseGen <DataType> noise; + std::vector <DataType> x (len); + std::vector <DataType> s1 (len); + std::vector <DataType> s2 (len); + BigFloat err_avg = 0; + + for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) + { + noise.generate (&x [0], len); + fft.do_fft (&s1 [0], &x [0]); + compute_tf (&s2 [0], &x [0], len); + + BigFloat max_err; + compare_vect_display (&s1 [0], &s2 [0], len, max_err); + err_avg += max_err; + } + err_avg /= NBR_ACC_TESTS; + + printf ("done.\n"); + printf ( + "Average maximum error: %.6f %% (%f dB)\n", + static_cast <double> (err_avg * 100), + static_cast <double> ((20 / TestAccuracy_LN10) * log (err_avg)) + ); + + return (ret_val); +} + + + +template <class FO> +int TestAccuracy <FO>::perform_test_i (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + using namespace std; + + int ret_val = 0; + const long len = fft.get_length (); + const long nbr_tests = limit ( + NBR_ACC_TESTS / len / len, + 10L, + static_cast <long> (MAX_NBR_TESTS) + ); + + printf ("Testing %s::do_ifft () [%ld samples]... ", class_name_0, len); + fflush (stdout); + TestWhiteNoiseGen <DataType> noise; + std::vector <DataType> s (len); + std::vector <DataType> x1 (len); + std::vector <DataType> x2 (len); + BigFloat err_avg = 0; + + for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) + { + noise.generate (&s [0], len); + fft.do_ifft (&s [0], &x1 [0]); + compute_itf (&x2 [0], &s [0], len); + + BigFloat max_err; + compare_vect_display (&x1 [0], &x2 [0], len, max_err); + err_avg += max_err; + } + err_avg /= NBR_ACC_TESTS; + + printf ("done.\n"); + printf ( + "Average maximum error: %.6f %% (%f dB)\n", + static_cast <double> (err_avg * 100), + static_cast <double> ((20 / TestAccuracy_LN10) * log (err_avg)) + ); + + return (ret_val); +} + + + +template <class FO> +int TestAccuracy <FO>::perform_test_di (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + using namespace std; + + int ret_val = 0; + const long len = fft.get_length (); + const long nbr_tests = limit ( + NBR_ACC_TESTS / len / len, + 1L, + static_cast <long> (MAX_NBR_TESTS) + ); + + printf ( + "Testing %s::do_fft () / do_ifft () / rescale () [%ld samples]... ", + class_name_0, + len + ); + fflush (stdout); + TestWhiteNoiseGen <DataType> noise; + std::vector <DataType> x (len); + std::vector <DataType> s (len); + std::vector <DataType> y (len); + BigFloat err_avg = 0; + + for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) + { + noise.generate (&x [0], len); + fft.do_fft (&s [0], &x [0]); + fft.do_ifft (&s [0], &y [0]); + fft.rescale (&y [0]); + + BigFloat max_err; + compare_vect_display (&x [0], &y [0], len, max_err); + err_avg += max_err; + } + err_avg /= NBR_ACC_TESTS; + + printf ("done.\n"); + printf ( + "Average maximum error: %.6f %% (%f dB)\n", + static_cast <double> (err_avg * 100), + static_cast <double> ((20 / TestAccuracy_LN10) * log (err_avg)) + ); + + return (ret_val); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +// Positive transform +template <class FO> +void TestAccuracy <FO>::compute_tf (DataType s [], const DataType x [], long length) +{ + assert (s != 0); + assert (x != 0); + assert (length >= 2); + assert ((length & 1) == 0); + + const long nbr_bins = length >> 1; + + // DC and Nyquist + BigFloat dc = 0; + BigFloat ny = 0; + for (long pos = 0; pos < length; pos += 2) + { + const BigFloat even = x [pos ]; + const BigFloat odd = x [pos + 1]; + dc += even + odd; + ny += even - odd; + } + s [0 ] = static_cast <DataType> (dc); + s [nbr_bins] = static_cast <DataType> (ny); + + // Regular bins + for (long bin = 1; bin < nbr_bins; ++ bin) + { + BigFloat sum_r = 0; + BigFloat sum_i = 0; + + const BigFloat m = bin * static_cast <BigFloat> (2 * PI) / length; + + for (long pos = 0; pos < length; ++pos) + { + using namespace std; + + const BigFloat phase = pos * m; + const BigFloat e_r = cos (phase); + const BigFloat e_i = sin (phase); + + sum_r += x [pos] * e_r; + sum_i += x [pos] * e_i; + } + + s [ bin] = static_cast <DataType> (sum_r); + s [nbr_bins + bin] = static_cast <DataType> (sum_i); + } +} + + + +// Negative transform +template <class FO> +void TestAccuracy <FO>::compute_itf (DataType x [], const DataType s [], long length) +{ + assert (s != 0); + assert (x != 0); + assert (length >= 2); + assert ((length & 1) == 0); + + const long nbr_bins = length >> 1; + + // DC and Nyquist + BigFloat dc = s [0 ]; + BigFloat ny = s [nbr_bins]; + + // Regular bins + for (long pos = 0; pos < length; ++pos) + { + BigFloat sum = dc + ny * (1 - 2 * (pos & 1)); + + const BigFloat m = pos * static_cast <BigFloat> (-2 * PI) / length; + + for (long bin = 1; bin < nbr_bins; ++ bin) + { + using namespace std; + + const BigFloat phase = bin * m; + const BigFloat e_r = cos (phase); + const BigFloat e_i = sin (phase); + + sum += 2 * ( e_r * s [bin ] + - e_i * s [bin + nbr_bins]); + } + + x [pos] = static_cast <DataType> (sum); + } +} + + + +template <class FO> +int TestAccuracy <FO>::compare_vect_display (const DataType x_ptr [], const DataType y_ptr [], long len, BigFloat &max_err_rel) +{ + assert (x_ptr != 0); + assert (y_ptr != 0); + assert (len > 0); + assert (&max_err_rel != 0); + + using namespace std; + + int ret_val = 0; + + BigFloat power = compute_power (&x_ptr [0], &y_ptr [0], len); + BigFloat power_dif; + long max_err_pos; + compare_vect (&x_ptr [0], &y_ptr [0], power_dif, max_err_pos, len); + + if (power == 0) + { + power = power_dif; + } + const BigFloat power_err_rel = power_dif / power; + + BigFloat max_err = 0; + max_err_rel = 0; + if (max_err_pos >= 0) + { + max_err = y_ptr [max_err_pos] - x_ptr [max_err_pos]; + max_err_rel = 2 * fabs (max_err) / ( fabs (y_ptr [max_err_pos]) + + fabs (x_ptr [max_err_pos])); + } + + if (power_err_rel > 0.001) + { + printf ("Power error : %f (%.6f %%)\n", + static_cast <double> (power_err_rel), + static_cast <double> (power_err_rel * 100) + ); + if (max_err_pos >= 0) + { + printf ( + "Maximum error: %f - %f = %f (%f)\n", + static_cast <double> (y_ptr [max_err_pos]), + static_cast <double> (x_ptr [max_err_pos]), + static_cast <double> (max_err), + static_cast <double> (max_err_pos) + ); + } + } + + return (ret_val); +} + + + +template <class FO> +typename TestAccuracy <FO>::BigFloat TestAccuracy <FO>::compute_power (const DataType x_ptr [], long len) +{ + assert (x_ptr != 0); + assert (len > 0); + + BigFloat power = 0; + for (long pos = 0; pos < len; ++pos) + { + const BigFloat val = x_ptr [pos]; + + power += val * val; + } + + using namespace std; + + power = sqrt (power) / len; + + return (power); +} + + + +template <class FO> +typename TestAccuracy <FO>::BigFloat TestAccuracy <FO>::compute_power (const DataType x_ptr [], const DataType y_ptr [], long len) +{ + assert (x_ptr != 0); + assert (y_ptr != 0); + assert (len > 0); + + return ((compute_power (x_ptr, len) + compute_power (y_ptr, len)) * 0.5); +} + + + +template <class FO> +void TestAccuracy <FO>::compare_vect (const DataType x_ptr [], const DataType y_ptr [], BigFloat &power, long &max_err_pos, long len) +{ + assert (x_ptr != 0); + assert (y_ptr != 0); + assert (len > 0); + assert (&power != 0); + assert (&max_err_pos != 0); + + power = 0; + BigFloat max_dif2 = 0; + max_err_pos = -1; + + for (long pos = 0; pos < len; ++pos) + { + const BigFloat x = x_ptr [pos]; + const BigFloat y = y_ptr [pos]; + const BigFloat dif = y - x; + const BigFloat dif2 = dif * dif; + + power += dif2; + if (dif2 > max_dif2) + { + max_err_pos = pos; + max_dif2 = dif2; + } + } + + using namespace std; + + power = sqrt (power) / len; +} + + + +#endif // TestAccuracy_CODEHEADER_INCLUDED + +#undef TestAccuracy_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestHelperFixLen.h b/demos/spectrum/3rdparty/fftreal/TestHelperFixLen.h new file mode 100644 index 0000000..ecff96d --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestHelperFixLen.h @@ -0,0 +1,93 @@ +/***************************************************************************** + + TestHelperFixLen.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestHelperFixLen_HEADER_INCLUDED) +#define TestHelperFixLen_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "FFTRealFixLen.h" + + + +template <int L> +class TestHelperFixLen +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef FFTRealFixLen <L> FftType; + + static void perform_test_accuracy (int &ret_val); + static void perform_test_speed (int &ret_val); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestHelperFixLen (); + ~TestHelperFixLen (); + TestHelperFixLen (const TestHelperFixLen &other); + TestHelperFixLen & + operator = (const TestHelperFixLen &other); + bool operator == (const TestHelperFixLen &other); + bool operator != (const TestHelperFixLen &other); + +}; // class TestHelperFixLen + + + +#include "TestHelperFixLen.hpp" + + + +#endif // TestHelperFixLen_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestHelperFixLen.hpp b/demos/spectrum/3rdparty/fftreal/TestHelperFixLen.hpp new file mode 100644 index 0000000..25048b9 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestHelperFixLen.hpp @@ -0,0 +1,93 @@ +/***************************************************************************** + + TestHelperFixLen.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestHelperFixLen_CURRENT_CODEHEADER) + #error Recursive inclusion of TestHelperFixLen code header. +#endif +#define TestHelperFixLen_CURRENT_CODEHEADER + +#if ! defined (TestHelperFixLen_CODEHEADER_INCLUDED) +#define TestHelperFixLen_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "test_settings.h" + +#include "TestAccuracy.h" +#if defined (test_settings_SPEED_TEST_ENABLED) + #include "TestSpeed.h" +#endif + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <int L> +void TestHelperFixLen <L>::perform_test_accuracy (int &ret_val) +{ + if (ret_val == 0) + { + FftType fft; + ret_val = TestAccuracy <FftType>::perform_test_single_object (fft); + } +} + + + +template <int L> +void TestHelperFixLen <L>::perform_test_speed (int &ret_val) +{ +#if defined (test_settings_SPEED_TEST_ENABLED) + + if (ret_val == 0) + { + FftType fft; + ret_val = TestSpeed <FftType>::perform_test_single_object (fft); + } + +#endif +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // TestHelperFixLen_CODEHEADER_INCLUDED + +#undef TestHelperFixLen_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestHelperNormal.h b/demos/spectrum/3rdparty/fftreal/TestHelperNormal.h new file mode 100644 index 0000000..a7bff5c --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestHelperNormal.h @@ -0,0 +1,94 @@ +/***************************************************************************** + + TestHelperNormal.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestHelperNormal_HEADER_INCLUDED) +#define TestHelperNormal_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "FFTReal.h" + + + +template <class DT> +class TestHelperNormal +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef DT DataType; + typedef FFTReal <DataType> FftType; + + static void perform_test_accuracy (int &ret_val); + static void perform_test_speed (int &ret_val); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestHelperNormal (); + ~TestHelperNormal (); + TestHelperNormal (const TestHelperNormal &other); + TestHelperNormal & + operator = (const TestHelperNormal &other); + bool operator == (const TestHelperNormal &other); + bool operator != (const TestHelperNormal &other); + +}; // class TestHelperNormal + + + +#include "TestHelperNormal.hpp" + + + +#endif // TestHelperNormal_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestHelperNormal.hpp b/demos/spectrum/3rdparty/fftreal/TestHelperNormal.hpp new file mode 100644 index 0000000..e037696 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestHelperNormal.hpp @@ -0,0 +1,99 @@ +/***************************************************************************** + + TestHelperNormal.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestHelperNormal_CURRENT_CODEHEADER) + #error Recursive inclusion of TestHelperNormal code header. +#endif +#define TestHelperNormal_CURRENT_CODEHEADER + +#if ! defined (TestHelperNormal_CODEHEADER_INCLUDED) +#define TestHelperNormal_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "test_settings.h" + +#include "TestAccuracy.h" +#if defined (test_settings_SPEED_TEST_ENABLED) + #include "TestSpeed.h" +#endif + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class DT> +void TestHelperNormal <DT>::perform_test_accuracy (int &ret_val) +{ + const int len_arr [] = { 1, 2, 3, 4, 7, 8, 10, 12 }; + const int nbr_len = sizeof (len_arr) / sizeof (len_arr [0]); + for (int k = 0; k < nbr_len && ret_val == 0; ++k) + { + const long len = 1L << (len_arr [k]); + FftType fft (len); + ret_val = TestAccuracy <FftType>::perform_test_single_object (fft); + } +} + + + +template <class DT> +void TestHelperNormal <DT>::perform_test_speed (int &ret_val) +{ +#if defined (test_settings_SPEED_TEST_ENABLED) + + const int len_arr [] = { 1, 2, 3, 4, 7, 8, 10, 12, 14, 16, 18, 20, 22 }; + const int nbr_len = sizeof (len_arr) / sizeof (len_arr [0]); + for (int k = 0; k < nbr_len && ret_val == 0; ++k) + { + const long len = 1L << (len_arr [k]); + FftType fft (len); + ret_val = TestSpeed <FftType>::perform_test_single_object (fft); + } + +#endif +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // TestHelperNormal_CODEHEADER_INCLUDED + +#undef TestHelperNormal_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestSpeed.h b/demos/spectrum/3rdparty/fftreal/TestSpeed.h new file mode 100644 index 0000000..2295781 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestSpeed.h @@ -0,0 +1,95 @@ +/***************************************************************************** + + TestSpeed.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestSpeed_HEADER_INCLUDED) +#define TestSpeed_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class FO> +class TestSpeed +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef typename FO::DataType DataType; + + static int perform_test_single_object (FO &fft); + static int perform_test_d (FO &fft, const char *class_name_0); + static int perform_test_i (FO &fft, const char *class_name_0); + static int perform_test_di (FO &fft, const char *class_name_0); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + enum { NBR_SPD_TESTS = 10 * 1000 * 1000 }; + enum { MAX_NBR_TESTS = 10000 }; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestSpeed (); + ~TestSpeed (); + TestSpeed (const TestSpeed &other); + TestSpeed & operator = (const TestSpeed &other); + bool operator == (const TestSpeed &other); + bool operator != (const TestSpeed &other); + +}; // class TestSpeed + + + +#include "TestSpeed.hpp" + + + +#endif // TestSpeed_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestSpeed.hpp b/demos/spectrum/3rdparty/fftreal/TestSpeed.hpp new file mode 100644 index 0000000..e716b2a --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestSpeed.hpp @@ -0,0 +1,223 @@ +/***************************************************************************** + + TestSpeed.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestSpeed_CURRENT_CODEHEADER) + #error Recursive inclusion of TestSpeed code header. +#endif +#define TestSpeed_CURRENT_CODEHEADER + +#if ! defined (TestSpeed_CODEHEADER_INCLUDED) +#define TestSpeed_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "test_fnc.h" +#include "stopwatch/StopWatch.h" +#include "TestWhiteNoiseGen.h" + +#include <typeinfo> + +#include <cstdio> + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class FO> +int TestSpeed <FO>::perform_test_single_object (FO &fft) +{ + assert (&fft != 0); + + int ret_val = 0; + + const std::type_info & ti = typeid (fft); + const char * class_name_0 = ti.name (); + + if (ret_val == 0) + { + perform_test_d (fft, class_name_0); + } + if (ret_val == 0) + { + perform_test_i (fft, class_name_0); + } + if (ret_val == 0) + { + perform_test_di (fft, class_name_0); + } + + if (ret_val == 0) + { + printf ("\n"); + } + + return (ret_val); +} + + + +template <class FO> +int TestSpeed <FO>::perform_test_d (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + const long len = fft.get_length (); + const long nbr_tests = limit ( + static_cast <long> (NBR_SPD_TESTS / len / len), + 1L, + static_cast <long> (MAX_NBR_TESTS) + ); + + TestWhiteNoiseGen <DataType> noise; + std::vector <DataType> x (len, 0); + std::vector <DataType> s (len); + noise.generate (&x [0], len); + + printf ( + "%s::do_fft () speed test [%ld samples]... ", + class_name_0, + len + ); + fflush (stdout); + + stopwatch::StopWatch chrono; + chrono.start (); + for (long test = 0; test < nbr_tests; ++ test) + { + fft.do_fft (&s [0], &x [0]); + chrono.stop_lap (); + } + + printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); + + return (0); +} + + + +template <class FO> +int TestSpeed <FO>::perform_test_i (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + const long len = fft.get_length (); + const long nbr_tests = limit ( + static_cast <long> (NBR_SPD_TESTS / len / len), + 1L, + static_cast <long> (MAX_NBR_TESTS) + ); + + TestWhiteNoiseGen <DataType> noise; + std::vector <DataType> x (len); + std::vector <DataType> s (len, 0); + noise.generate (&s [0], len); + + printf ( + "%s::do_ifft () speed test [%ld samples]... ", + class_name_0, + len + ); + fflush (stdout); + + stopwatch::StopWatch chrono; + chrono.start (); + for (long test = 0; test < nbr_tests; ++ test) + { + fft.do_ifft (&s [0], &x [0]); + chrono.stop_lap (); + } + + printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); + + return (0); +} + + + +template <class FO> +int TestSpeed <FO>::perform_test_di (FO &fft, const char *class_name_0) +{ + assert (&fft != 0); + assert (class_name_0 != 0); + + const long len = fft.get_length (); + const long nbr_tests = limit ( + static_cast <long> (NBR_SPD_TESTS / len / len), + 1L, + static_cast <long> (MAX_NBR_TESTS) + ); + + TestWhiteNoiseGen <DataType> noise; + std::vector <DataType> x (len, 0); + std::vector <DataType> s (len); + std::vector <DataType> y (len); + noise.generate (&x [0], len); + + printf ( + "%s::do_fft () / do_ifft () / rescale () speed test [%ld samples]... ", + class_name_0, + len + ); + fflush (stdout); + + stopwatch::StopWatch chrono; + + chrono.start (); + for (long test = 0; test < nbr_tests; ++ test) + { + fft.do_fft (&s [0], &x [0]); + fft.do_ifft (&s [0], &y [0]); + fft.rescale (&y [0]); + chrono.stop_lap (); + } + + printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); + + return (0); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // TestSpeed_CODEHEADER_INCLUDED + +#undef TestSpeed_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.h b/demos/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.h new file mode 100644 index 0000000..d815f8e --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.h @@ -0,0 +1,95 @@ +/***************************************************************************** + + TestWhiteNoiseGen.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (TestWhiteNoiseGen_HEADER_INCLUDED) +#define TestWhiteNoiseGen_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class DT> +class TestWhiteNoiseGen +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + typedef DT DataType; + + TestWhiteNoiseGen (); + virtual ~TestWhiteNoiseGen () {} + + void generate (DataType data_ptr [], long len); + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + typedef unsigned long StateType; + + StateType _rand_state; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + TestWhiteNoiseGen (const TestWhiteNoiseGen &other); + TestWhiteNoiseGen & + operator = (const TestWhiteNoiseGen &other); + bool operator == (const TestWhiteNoiseGen &other); + bool operator != (const TestWhiteNoiseGen &other); + +}; // class TestWhiteNoiseGen + + + +#include "TestWhiteNoiseGen.hpp" + + + +#endif // TestWhiteNoiseGen_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.hpp b/demos/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.hpp new file mode 100644 index 0000000..13b7eb3 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.hpp @@ -0,0 +1,91 @@ +/***************************************************************************** + + TestWhiteNoiseGen.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (TestWhiteNoiseGen_CURRENT_CODEHEADER) + #error Recursive inclusion of TestWhiteNoiseGen code header. +#endif +#define TestWhiteNoiseGen_CURRENT_CODEHEADER + +#if ! defined (TestWhiteNoiseGen_CODEHEADER_INCLUDED) +#define TestWhiteNoiseGen_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class DT> +TestWhiteNoiseGen <DT>::TestWhiteNoiseGen () +: _rand_state (0) +{ + _rand_state = reinterpret_cast <StateType> (this); +} + + + +template <class DT> +void TestWhiteNoiseGen <DT>::generate (DataType data_ptr [], long len) +{ + assert (data_ptr != 0); + assert (len > 0); + + const DataType one = static_cast <DataType> (1); + const DataType mul = one / static_cast <DataType> (0x80000000UL); + + long pos = 0; + do + { + const DataType x = static_cast <DataType> (_rand_state & 0xFFFFFFFFUL); + data_ptr [pos] = x * mul - one; + + _rand_state = _rand_state * 1234567UL + 890123UL; + + ++ pos; + } + while (pos < len); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#endif // TestWhiteNoiseGen_CODEHEADER_INCLUDED + +#undef TestWhiteNoiseGen_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/bwins/fftrealu.def b/demos/spectrum/3rdparty/fftreal/bwins/fftrealu.def new file mode 100644 index 0000000..7a79397 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/bwins/fftrealu.def @@ -0,0 +1,5 @@ +EXPORTS + ??0FFTRealWrapper@@QAE@XZ @ 1 NONAME ; FFTRealWrapper::FFTRealWrapper(void) + ??1FFTRealWrapper@@QAE@XZ @ 2 NONAME ; FFTRealWrapper::~FFTRealWrapper(void) + ?calculateFFT@FFTRealWrapper@@QAEXQAMQBM@Z @ 3 NONAME ; void FFTRealWrapper::calculateFFT(float * const, float const * const) + diff --git a/demos/spectrum/3rdparty/fftreal/def.h b/demos/spectrum/3rdparty/fftreal/def.h new file mode 100644 index 0000000..99c545f --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/def.h @@ -0,0 +1,60 @@ +/***************************************************************************** + + def.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (def_HEADER_INCLUDED) +#define def_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + + +const double PI = 3.1415926535897932384626433832795; +const double SQRT2 = 1.41421356237309514547462185873883; + +#if defined (_MSC_VER) + + #define FORCEINLINE __forceinline + +#else + + #define FORCEINLINE inline + +#endif + + + +#endif // def_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/eabi/fftrealu.def b/demos/spectrum/3rdparty/fftreal/eabi/fftrealu.def new file mode 100644 index 0000000..f95a441 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/eabi/fftrealu.def @@ -0,0 +1,7 @@ +EXPORTS + _ZN14FFTRealWrapper12calculateFFTEPfPKf @ 1 NONAME + _ZN14FFTRealWrapperC1Ev @ 2 NONAME + _ZN14FFTRealWrapperC2Ev @ 3 NONAME + _ZN14FFTRealWrapperD1Ev @ 4 NONAME + _ZN14FFTRealWrapperD2Ev @ 5 NONAME + diff --git a/demos/spectrum/3rdparty/fftreal/fftreal.pas b/demos/spectrum/3rdparty/fftreal/fftreal.pas new file mode 100644 index 0000000..ea63754 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/fftreal.pas @@ -0,0 +1,661 @@ +(***************************************************************************** + + DIGITAL SIGNAL PROCESSING TOOLS + Version 1.03, 2001/06/15 + (c) 1999 - Laurent de Soras + + FFTReal.h + Fourier transformation of real number arrays. + Portable ISO C++ + +------------------------------------------------------------------------------ + + LEGAL + + Source code may be freely used for any purpose, including commercial + applications. Programs must display in their "About" dialog-box (or + documentation) a text telling they use these routines by Laurent de Soras. + Modified source code can be distributed, but modifications must be clearly + indicated. + + CONTACT + + Laurent de Soras + 92 avenue Albert 1er + 92500 Rueil-Malmaison + France + + ldesoras@club-internet.fr + +------------------------------------------------------------------------------ + + Translation to ObjectPascal by : + Frederic Vanmol + frederic@axiworld.be + +*****************************************************************************) + + +unit + FFTReal; + +interface + +uses + Windows; + +(* Change this typedef to use a different floating point type in your FFTs + (i.e. float, double or long double). *) +type + pflt_t = ^flt_t; + flt_t = single; + + pflt_array = ^flt_array; + flt_array = array[0..0] of flt_t; + + plongarray = ^longarray; + longarray = array[0..0] of longint; + +const + sizeof_flt : longint = SizeOf(flt_t); + + + +type + // Bit reversed look-up table nested class + TBitReversedLUT = class + private + _ptr : plongint; + public + constructor Create(const nbr_bits: integer); + destructor Destroy; override; + function get_ptr: plongint; + end; + + // Trigonometric look-up table nested class + TTrigoLUT = class + private + _ptr : pflt_t; + public + constructor Create(const nbr_bits: integer); + destructor Destroy; override; + function get_ptr(const level: integer): pflt_t; + end; + + TFFTReal = class + private + _bit_rev_lut : TBitReversedLUT; + _trigo_lut : TTrigoLUT; + _sqrt2_2 : flt_t; + _length : longint; + _nbr_bits : integer; + _buffer_ptr : pflt_t; + public + constructor Create(const length: longint); + destructor Destroy; override; + + procedure do_fft(f: pflt_array; const x: pflt_array); + procedure do_ifft(const f: pflt_array; x: pflt_array); + procedure rescale(x: pflt_array); + end; + + + + + + + +implementation + +uses + Math; + +{ TBitReversedLUT } + +constructor TBitReversedLUT.Create(const nbr_bits: integer); +var + length : longint; + cnt : longint; + br_index : longint; + bit : longint; +begin + inherited Create; + + length := 1 shl nbr_bits; + GetMem(_ptr, length*SizeOf(longint)); + + br_index := 0; + plongarray(_ptr)^[0] := 0; + for cnt := 1 to length-1 do + begin + // ++br_index (bit reversed) + bit := length shr 1; + br_index := br_index xor bit; + while br_index and bit = 0 do + begin + bit := bit shr 1; + br_index := br_index xor bit; + end; + + plongarray(_ptr)^[cnt] := br_index; + end; +end; + +destructor TBitReversedLUT.Destroy; +begin + FreeMem(_ptr); + _ptr := nil; + inherited; +end; + +function TBitReversedLUT.get_ptr: plongint; +begin + Result := _ptr; +end; + +{ TTrigLUT } + +constructor TTrigoLUT.Create(const nbr_bits: integer); +var + total_len : longint; + PI : double; + level : integer; + level_len : longint; + level_ptr : pflt_array; + mul : double; + i : longint; +begin + inherited Create; + + _ptr := nil; + + if (nbr_bits > 3) then + begin + total_len := (1 shl (nbr_bits - 1)) - 4; + GetMem(_ptr, total_len * sizeof_flt); + + PI := ArcTan(1) * 4; + for level := 3 to nbr_bits-1 do + begin + level_len := 1 shl (level - 1); + level_ptr := pointer(get_ptr(level)); + mul := PI / (level_len shl 1); + + for i := 0 to level_len-1 do + level_ptr^[i] := cos(i * mul); + end; + end; +end; + +destructor TTrigoLUT.Destroy; +begin + FreeMem(_ptr); + _ptr := nil; + inherited; +end; + +function TTrigoLUT.get_ptr(const level: integer): pflt_t; +var + tempp : pflt_t; +begin + tempp := _ptr; + inc(tempp, (1 shl (level-1)) - 4); + Result := tempp; +end; + +{ TFFTReal } + +constructor TFFTReal.Create(const length: longint); +begin + inherited Create; + + _length := length; + _nbr_bits := Floor(Ln(length) / Ln(2) + 0.5); + _bit_rev_lut := TBitReversedLUT.Create(Floor(Ln(length) / Ln(2) + 0.5)); + _trigo_lut := TTrigoLUT.Create(Floor(Ln(length) / Ln(2) + 0.05)); + _sqrt2_2 := Sqrt(2) * 0.5; + + _buffer_ptr := nil; + if _nbr_bits > 2 then + GetMem(_buffer_ptr, _length * sizeof_flt); +end; + +destructor TFFTReal.Destroy; +begin + if _buffer_ptr <> nil then + begin + FreeMem(_buffer_ptr); + _buffer_ptr := nil; + end; + + _bit_rev_lut.Free; + _bit_rev_lut := nil; + _trigo_lut.Free; + _trigo_lut := nil; + + inherited; +end; + +(*==========================================================================*/ +/* Name: do_fft */ +/* Description: Compute the FFT of the array. */ +/* Input parameters: */ +/* - x: pointer on the source array (time). */ +/* Output parameters: */ +/* - f: pointer on the destination array (frequencies). */ +/* f [0...length(x)/2] = real values, */ +/* f [length(x)/2+1...length(x)-1] = imaginary values of */ +/* coefficents 1...length(x)/2-1. */ +/*==========================================================================*) +procedure TFFTReal.do_fft(f: pflt_array; const x: pflt_array); +var + sf, df : pflt_array; + pass : integer; + nbr_coef : longint; + h_nbr_coef : longint; + d_nbr_coef : longint; + coef_index : longint; + bit_rev_lut_ptr : plongarray; + rev_index_0 : longint; + rev_index_1 : longint; + rev_index_2 : longint; + rev_index_3 : longint; + df2 : pflt_array; + n1, n2, n3 : integer; + sf_0, sf_2 : flt_t; + sqrt2_2 : flt_t; + v : flt_t; + cos_ptr : pflt_array; + i : longint; + sf1r, sf2r : pflt_array; + dfr, dfi : pflt_array; + sf1i, sf2i : pflt_array; + c, s : flt_t; + temp_ptr : pflt_array; + b_0, b_2 : flt_t; +begin + n1 := 1; + n2 := 2; + n3 := 3; + + (*______________________________________________ + * + * General case + *______________________________________________ + *) + + if _nbr_bits > 2 then + begin + if _nbr_bits and 1 <> 0 then + begin + df := pointer(_buffer_ptr); + sf := f; + end + else + begin + df := f; + sf := pointer(_buffer_ptr); + end; + + // + // Do the transformation in several passes + // + + // First and second pass at once + bit_rev_lut_ptr := pointer(_bit_rev_lut.get_ptr); + coef_index := 0; + + repeat + rev_index_0 := bit_rev_lut_ptr^[coef_index]; + rev_index_1 := bit_rev_lut_ptr^[coef_index + 1]; + rev_index_2 := bit_rev_lut_ptr^[coef_index + 2]; + rev_index_3 := bit_rev_lut_ptr^[coef_index + 3]; + + df2 := pointer(longint(df) + (coef_index*sizeof_flt)); + df2^[n1] := x^[rev_index_0] - x^[rev_index_1]; + df2^[n3] := x^[rev_index_2] - x^[rev_index_3]; + + sf_0 := x^[rev_index_0] + x^[rev_index_1]; + sf_2 := x^[rev_index_2] + x^[rev_index_3]; + + df2^[0] := sf_0 + sf_2; + df2^[n2] := sf_0 - sf_2; + + inc(coef_index, 4); + until (coef_index >= _length); + + + // Third pass + coef_index := 0; + sqrt2_2 := _sqrt2_2; + + repeat + sf^[coef_index] := df^[coef_index] + df^[coef_index + 4]; + sf^[coef_index + 4] := df^[coef_index] - df^[coef_index + 4]; + sf^[coef_index + 2] := df^[coef_index + 2]; + sf^[coef_index + 6] := df^[coef_index + 6]; + + v := (df [coef_index + 5] - df^[coef_index + 7]) * sqrt2_2; + sf^[coef_index + 1] := df^[coef_index + 1] + v; + sf^[coef_index + 3] := df^[coef_index + 1] - v; + + v := (df^[coef_index + 5] + df^[coef_index + 7]) * sqrt2_2; + sf [coef_index + 5] := v + df^[coef_index + 3]; + sf [coef_index + 7] := v - df^[coef_index + 3]; + + inc(coef_index, 8); + until (coef_index >= _length); + + + // Next pass + for pass := 3 to _nbr_bits-1 do + begin + coef_index := 0; + nbr_coef := 1 shl pass; + h_nbr_coef := nbr_coef shr 1; + d_nbr_coef := nbr_coef shl 1; + + cos_ptr := pointer(_trigo_lut.get_ptr(pass)); + repeat + sf1r := pointer(longint(sf) + (coef_index * sizeof_flt)); + sf2r := pointer(longint(sf1r) + (nbr_coef * sizeof_flt)); + dfr := pointer(longint(df) + (coef_index * sizeof_flt)); + dfi := pointer(longint(dfr) + (nbr_coef * sizeof_flt)); + + // Extreme coefficients are always real + dfr^[0] := sf1r^[0] + sf2r^[0]; + dfi^[0] := sf1r^[0] - sf2r^[0]; // dfr [nbr_coef] = + dfr^[h_nbr_coef] := sf1r^[h_nbr_coef]; + dfi^[h_nbr_coef] := sf2r^[h_nbr_coef]; + + // Others are conjugate complex numbers + sf1i := pointer(longint(sf1r) + (h_nbr_coef * sizeof_flt)); + sf2i := pointer(longint(sf1i) + (nbr_coef * sizeof_flt)); + + for i := 1 to h_nbr_coef-1 do + begin + c := cos_ptr^[i]; // cos (i*PI/nbr_coef); + s := cos_ptr^[h_nbr_coef - i]; // sin (i*PI/nbr_coef); + + v := sf2r^[i] * c - sf2i^[i] * s; + dfr^[i] := sf1r^[i] + v; + dfi^[-i] := sf1r^[i] - v; // dfr [nbr_coef - i] = + + v := sf2r^[i] * s + sf2i^[i] * c; + dfi^[i] := v + sf1i^[i]; + dfi^[nbr_coef - i] := v - sf1i^[i]; + end; + + inc(coef_index, d_nbr_coef); + until (coef_index >= _length); + + // Prepare to the next pass + temp_ptr := df; + df := sf; + sf := temp_ptr; + end; + end + + (*______________________________________________ + * + * Special cases + *______________________________________________ + *) + + // 4-point FFT + else if _nbr_bits = 2 then + begin + f^[n1] := x^[0] - x^[n2]; + f^[n3] := x^[n1] - x^[n3]; + + b_0 := x^[0] + x^[n2]; + b_2 := x^[n1] + x^[n3]; + + f^[0] := b_0 + b_2; + f^[n2] := b_0 - b_2; + end + + // 2-point FFT + else if _nbr_bits = 1 then + begin + f^[0] := x^[0] + x^[n1]; + f^[n1] := x^[0] - x^[n1]; + end + + // 1-point FFT + else + f^[0] := x^[0]; +end; + + +(*==========================================================================*/ +/* Name: do_ifft */ +/* Description: Compute the inverse FFT of the array. Notice that */ +/* IFFT (FFT (x)) = x * length (x). Data must be */ +/* post-scaled. */ +/* Input parameters: */ +/* - f: pointer on the source array (frequencies). */ +/* f [0...length(x)/2] = real values, */ +/* f [length(x)/2+1...length(x)-1] = imaginary values of */ +/* coefficents 1...length(x)/2-1. */ +/* Output parameters: */ +/* - x: pointer on the destination array (time). */ +/*==========================================================================*) +procedure TFFTReal.do_ifft(const f: pflt_array; x: pflt_array); +var + n1, n2, n3 : integer; + n4, n5, n6, n7 : integer; + sf, df, df_temp : pflt_array; + pass : integer; + nbr_coef : longint; + h_nbr_coef : longint; + d_nbr_coef : longint; + coef_index : longint; + cos_ptr : pflt_array; + i : longint; + sfr, sfi : pflt_array; + df1r, df2r : pflt_array; + df1i, df2i : pflt_array; + c, s, vr, vi : flt_t; + temp_ptr : pflt_array; + sqrt2_2 : flt_t; + bit_rev_lut_ptr : plongarray; + sf2 : pflt_array; + b_0, b_1, b_2, b_3 : flt_t; +begin + n1 := 1; + n2 := 2; + n3 := 3; + n4 := 4; + n5 := 5; + n6 := 6; + n7 := 7; + + (*______________________________________________ + * + * General case + *______________________________________________ + *) + + if _nbr_bits > 2 then + begin + sf := f; + + if _nbr_bits and 1 <> 0 then + begin + df := pointer(_buffer_ptr); + df_temp := x; + end + else + begin + df := x; + df_temp := pointer(_buffer_ptr); + end; + + // Do the transformation in several pass + + // First pass + for pass := _nbr_bits-1 downto 3 do + begin + coef_index := 0; + nbr_coef := 1 shl pass; + h_nbr_coef := nbr_coef shr 1; + d_nbr_coef := nbr_coef shl 1; + + cos_ptr := pointer(_trigo_lut.get_ptr(pass)); + + repeat + sfr := pointer(longint(sf) + (coef_index*sizeof_flt)); + sfi := pointer(longint(sfr) + (nbr_coef*sizeof_flt)); + df1r := pointer(longint(df) + (coef_index*sizeof_flt)); + df2r := pointer(longint(df1r) + (nbr_coef*sizeof_flt)); + + // Extreme coefficients are always real + df1r^[0] := sfr^[0] + sfi^[0]; // + sfr [nbr_coef] + df2r^[0] := sfr^[0] - sfi^[0]; // - sfr [nbr_coef] + df1r^[h_nbr_coef] := sfr^[h_nbr_coef] * 2; + df2r^[h_nbr_coef] := sfi^[h_nbr_coef] * 2; + + // Others are conjugate complex numbers + df1i := pointer(longint(df1r) + (h_nbr_coef*sizeof_flt)); + df2i := pointer(longint(df1i) + (nbr_coef*sizeof_flt)); + + for i := 1 to h_nbr_coef-1 do + begin + df1r^[i] := sfr^[i] + sfi^[-i]; // + sfr [nbr_coef - i] + df1i^[i] := sfi^[i] - sfi^[nbr_coef - i]; + + c := cos_ptr^[i]; // cos (i*PI/nbr_coef); + s := cos_ptr^[h_nbr_coef - i]; // sin (i*PI/nbr_coef); + vr := sfr^[i] - sfi^[-i]; // - sfr [nbr_coef - i] + vi := sfi^[i] + sfi^[nbr_coef - i]; + + df2r^[i] := vr * c + vi * s; + df2i^[i] := vi * c - vr * s; + end; + + inc(coef_index, d_nbr_coef); + until (coef_index >= _length); + + + // Prepare to the next pass + if (pass < _nbr_bits - 1) then + begin + temp_ptr := df; + df := sf; + sf := temp_ptr; + end + else + begin + sf := df; + df := df_temp; + end + end; + + // Antepenultimate pass + sqrt2_2 := _sqrt2_2; + coef_index := 0; + + repeat + df^[coef_index] := sf^[coef_index] + sf^[coef_index + 4]; + df^[coef_index + 4] := sf^[coef_index] - sf^[coef_index + 4]; + df^[coef_index + 2] := sf^[coef_index + 2] * 2; + df^[coef_index + 6] := sf^[coef_index + 6] * 2; + + df^[coef_index + 1] := sf^[coef_index + 1] + sf^[coef_index + 3]; + df^[coef_index + 3] := sf^[coef_index + 5] - sf^[coef_index + 7]; + + vr := sf^[coef_index + 1] - sf^[coef_index + 3]; + vi := sf^[coef_index + 5] + sf^[coef_index + 7]; + + df^[coef_index + 5] := (vr + vi) * sqrt2_2; + df^[coef_index + 7] := (vi - vr) * sqrt2_2; + + inc(coef_index, 8); + until (coef_index >= _length); + + + // Penultimate and last pass at once + coef_index := 0; + bit_rev_lut_ptr := pointer(_bit_rev_lut.get_ptr); + sf2 := df; + + repeat + b_0 := sf2^[0] + sf2^[n2]; + b_2 := sf2^[0] - sf2^[n2]; + b_1 := sf2^[n1] * 2; + b_3 := sf2^[n3] * 2; + + x^[bit_rev_lut_ptr^[0]] := b_0 + b_1; + x^[bit_rev_lut_ptr^[n1]] := b_0 - b_1; + x^[bit_rev_lut_ptr^[n2]] := b_2 + b_3; + x^[bit_rev_lut_ptr^[n3]] := b_2 - b_3; + + b_0 := sf2^[n4] + sf2^[n6]; + b_2 := sf2^[n4] - sf2^[n6]; + b_1 := sf2^[n5] * 2; + b_3 := sf2^[n7] * 2; + + x^[bit_rev_lut_ptr^[n4]] := b_0 + b_1; + x^[bit_rev_lut_ptr^[n5]] := b_0 - b_1; + x^[bit_rev_lut_ptr^[n6]] := b_2 + b_3; + x^[bit_rev_lut_ptr^[n7]] := b_2 - b_3; + + inc(sf2, 8); + inc(coef_index, 8); + inc(bit_rev_lut_ptr, 8); + until (coef_index >= _length); + end + + (*______________________________________________ + * + * Special cases + *______________________________________________ + *) + + // 4-point IFFT + else if _nbr_bits = 2 then + begin + b_0 := f^[0] + f [n2]; + b_2 := f^[0] - f [n2]; + + x^[0] := b_0 + f [n1] * 2; + x^[n2] := b_0 - f [n1] * 2; + x^[n1] := b_2 + f [n3] * 2; + x^[n3] := b_2 - f [n3] * 2; + end + + // 2-point IFFT + else if _nbr_bits = 1 then + begin + x^[0] := f^[0] + f^[n1]; + x^[n1] := f^[0] - f^[n1]; + end + + // 1-point IFFT + else + x^[0] := f^[0]; +end; + +(*==========================================================================*/ +/* Name: rescale */ +/* Description: Scale an array by divide each element by its length. */ +/* This function should be called after FFT + IFFT. */ +/* Input/Output parameters: */ +/* - x: pointer on array to rescale (time or frequency). */ +/*==========================================================================*) +procedure TFFTReal.rescale(x: pflt_array); +var + mul : flt_t; + i : longint; +begin + mul := 1.0 / _length; + i := _length - 1; + + repeat + x^[i] := x^[i] * mul; + dec(i); + until (i < 0); +end; + +end. diff --git a/demos/spectrum/3rdparty/fftreal/fftreal.pro b/demos/spectrum/3rdparty/fftreal/fftreal.pro new file mode 100644 index 0000000..4ab9652 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/fftreal.pro @@ -0,0 +1,41 @@ +TEMPLATE = lib +TARGET = fftreal + +# FFTReal +HEADERS += Array.h \ + Array.hpp \ + DynArray.h \ + DynArray.hpp \ + FFTRealFixLen.h \ + FFTRealFixLen.hpp \ + FFTRealFixLenParam.h \ + FFTRealPassDirect.h \ + FFTRealPassDirect.hpp \ + FFTRealPassInverse.h \ + FFTRealPassInverse.hpp \ + FFTRealSelect.h \ + FFTRealSelect.hpp \ + FFTRealUseTrigo.h \ + FFTRealUseTrigo.hpp \ + OscSinCos.h \ + OscSinCos.hpp \ + def.h + +# Wrapper used to export the required instantiation of the FFTRealFixLen template +HEADERS += fftreal_wrapper.h +SOURCES += fftreal_wrapper.cpp + +DEFINES += FFTREAL_LIBRARY + +symbian { + # Provide unique ID for the generated binary, required by Symbian OS + TARGET.UID3 = 0xA000E3FB +} else { + macx { + CONFIG += lib_bundle + } else { + DESTDIR = ../../bin + } +} + + diff --git a/demos/spectrum/3rdparty/fftreal/fftreal_wrapper.cpp b/demos/spectrum/3rdparty/fftreal/fftreal_wrapper.cpp new file mode 100644 index 0000000..50ab36d --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/fftreal_wrapper.cpp @@ -0,0 +1,54 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as +** published by the Free Software Foundation, either version 2.1. This +** program is distributed in the hope that it will be useful, but WITHOUT +** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. You should have received a copy of the GNU General +** Public License along with this program. If not, see +** <http://www.gnu.org/licenses/>. +** +***************************************************************************/ + +#include "fftreal_wrapper.h" + +// FFTReal code generates quite a lot of 'unused parameter' compiler warnings, +// which we suppress here in order to get a clean build output. +#if defined Q_CC_MSVC +# pragma warning(disable:4100) +#elif defined Q_CC_GNU +# pragma GCC diagnostic ignored "-Wunused-parameter" +#elif defined Q_CC_MWERKS +# pragma warning off (10182) +#endif + +#include "FFTRealFixLen.h" + +class FFTRealWrapperPrivate { +public: + FFTRealFixLen<FFTLengthPowerOfTwo> m_fft; +}; + + +FFTRealWrapper::FFTRealWrapper() + : m_private(new FFTRealWrapperPrivate) +{ + +} + +FFTRealWrapper::~FFTRealWrapper() +{ + delete m_private; +} + +void FFTRealWrapper::calculateFFT(DataType in[], const DataType out[]) +{ + m_private->m_fft.do_fft(in, out); +} diff --git a/demos/spectrum/3rdparty/fftreal/fftreal_wrapper.h b/demos/spectrum/3rdparty/fftreal/fftreal_wrapper.h new file mode 100644 index 0000000..48d614e --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/fftreal_wrapper.h @@ -0,0 +1,63 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as +** published by the Free Software Foundation, either version 2.1. This +** program is distributed in the hope that it will be useful, but WITHOUT +** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. You should have received a copy of the GNU General +** Public License along with this program. If not, see +** <http://www.gnu.org/licenses/>. +** +***************************************************************************/ + +#ifndef FFTREAL_WRAPPER_H +#define FFTREAL_WRAPPER_H + +#include <QtCore/QtGlobal> + +#if defined(FFTREAL_LIBRARY) +# define FFTREAL_EXPORT Q_DECL_EXPORT +#else +# define FFTREAL_EXPORT Q_DECL_IMPORT +#endif + +class FFTRealWrapperPrivate; + +// Each pass of the FFT processes 2^X samples, where X is the +// number below. +static const int FFTLengthPowerOfTwo = 12; + +/** + * Wrapper around the FFTRealFixLen template provided by the FFTReal + * library + * + * This class instantiates a single instance of FFTRealFixLen, using + * FFTLengthPowerOfTwo as the template parameter. It then exposes + * FFTRealFixLen<FFTLengthPowerOfTwo>::do_fft via the calculateFFT + * function, thereby allowing an application to dynamically link + * against the FFTReal implementation. + * + * See http://ldesoras.free.fr/prod.html + */ +class FFTREAL_EXPORT FFTRealWrapper +{ +public: + FFTRealWrapper(); + ~FFTRealWrapper(); + + typedef float DataType; + void calculateFFT(DataType in[], const DataType out[]); + +private: + FFTRealWrapperPrivate* m_private; +}; + +#endif // FFTREAL_WRAPPER_H + diff --git a/demos/spectrum/3rdparty/fftreal/license.txt b/demos/spectrum/3rdparty/fftreal/license.txt new file mode 100644 index 0000000..918fe68 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/license.txt @@ -0,0 +1,459 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + diff --git a/demos/spectrum/3rdparty/fftreal/readme.txt b/demos/spectrum/3rdparty/fftreal/readme.txt new file mode 100644 index 0000000..0c5ce16 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/readme.txt @@ -0,0 +1,242 @@ +============================================================================== + + FFTReal + Version 2.00, 2005/10/18 + + Fourier transformation (FFT, IFFT) library specialised for real data + Portable ISO C++ + + (c) Laurent de Soras <laurent.de.soras@club-internet.fr> + Object Pascal port (c) Frederic Vanmol <frederic@fruityloops.com> + +============================================================================== + + + +1. Legal +-------- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Check the file license.txt to get full information about the license. + + + +2. Content +---------- + +FFTReal is a library to compute Discrete Fourier Transforms (DFT) with the +FFT algorithm (Fast Fourier Transform) on arrays of real numbers. It can +also compute the inverse transform. + +You should find in this package a lot of files ; some of them are of interest: +- readme.txt: you are reading it +- FFTReal.h: FFT, length fixed at run-time +- FFTRealFixLen.h: FFT, length fixed at compile-time +- FFTReal.pas: Pascal implementation (working but not up-to-date) +- stopwatch directory + + + +3. Using FFTReal +---------------- + +Important - if you were using older versions of FFTReal (up to 1.03), some +things have changed. FFTReal is now a template. Therefore use FFTReal<float> +or FFTReal<double> in your code depending on the application datatype. The +flt_t typedef has been removed. + +You have two ways to use FFTReal. In the first way, the FFT has its length +fixed at run-time, when the object is instanciated. It means that you have +not to know the length when you write the code. This is the usual way of +proceeding. + + +3.1 FFTReal - Length fixed at run-time +-------------------------------------- + +Just instanciate one time a FFTReal object. Specify the data type you want +as template parameter (only floating point: float, double, long double or +custom type). The constructor precompute a lot of things, so it may be a bit +long. The parameter is the number of points used for the next FFTs. It must +be a power of 2: + + #include "FFTReal.h" + ... + long len = 1024; + ... + FFTReal <float> fft_object (len); // 1024-point FFT object constructed. + +Then you can use this object to compute as many FFTs and IFFTs as you want. +They will be computed very quickly because a lot of work has been done in the +object construction. + + float x [1024]; + float f [1024]; + + ... + fft_object.do_fft (f, x); // x (real) --FFT---> f (complex) + ... + fft_object.do_ifft (f, x); // f (complex) --IFFT--> x (real) + fft_object.rescale (x); // Post-scaling should be done after FFT+IFFT + ... + +x [] and f [] are floating point number arrays. x [] is the real number +sequence which we want to compute the FFT. f [] is the result, in the +"frequency" domain. f has the same number of elements as x [], but f [] +elements are complex numbers. The routine uses some FFT properties to +optimize memory and to reduce calculations: the transformaton of a real +number sequence is a conjugate complex number sequence: F [k] = F [-k]*. + + +3.2 FFTRealFixLen - Length fixed at compile-time +------------------------------------------------ + +This class is significantly faster than the previous one, giving a speed +gain between 50 and 100 %. The template parameter is the base-2 logarithm of +the FFT length. The datatype is float; it can be changed by modifying the +DataType typedef in FFTRealFixLenParam.h. As FFTReal class, it supports +only floating-point types or equivalent. + +To instanciate the object, just proceed as below: + + #include "FFTRealFixLen.h" + ... + FFTRealFixLen <10> fft_object; // 1024-point (2^10) FFT object constructed. + +Use is similar as the one of FFTReal. + + +3.3 Data organisation +--------------------- + +Mathematically speaking, the formulas below show what does FFTReal: + +do_fft() : f(k) = sum (p = 0, N-1, x(p) * exp (+j*2*pi*k*p/N)) +do_ifft(): x(k) = sum (p = 0, N-1, f(p) * exp (-j*2*pi*k*p/N)) + +Where j is the square root of -1. The formulas differ only by the sign of +the exponential. When the sign is positive, the transform is called positive. +Common formulas for Fourier transform are negative for the direct tranform and +positive for the inverse one. + +However in these formulas, f is an array of complex numbers and doesn't +correspound exactly to the f[] array taken as function parameter. The +following table shows how the f[] sequence is mapped onto the usable FFT +coefficients (called bins): + + FFTReal output | Positive FFT equiv. | Negative FFT equiv. + ---------------+-----------------------+----------------------- + f [0] | Real (bin 0) | Real (bin 0) + f [...] | Real (bin ...) | Real (bin ...) + f [length/2] | Real (bin length/2) | Real (bin length/2) + f [length/2+1] | Imag (bin 1) | -Imag (bin 1) + f [...] | Imag (bin ...) | -Imag (bin ...) + f [length-1] | Imag (bin length/2-1) | -Imag (bin length/2-1) + +And FFT bins are distributed in f [] as above: + + | | Positive FFT | Negative FFT + Bin | Real part | imaginary part | imaginary part + ------------+----------------+-----------------+--------------- + 0 | f [0] | 0 | 0 + 1 | f [1] | f [length/2+1] | -f [length/2+1] + ... | f [...], | f [...] | -f [...] + length/2-1 | f [length/2-1] | f [length-1] | -f [length-1] + length/2 | f [length/2] | 0 | 0 + length/2+1 | f [length/2-1] | -f [length-1] | f [length-1] + ... | f [...] | -f [...] | f [...] + length-1 | f [1] | -f [length/2+1] | f [length/2+1] + +f [] coefficients have the same layout for FFT and IFFT functions. You may +notice that scaling must be done if you want to retrieve x after FFT and IFFT. +Actually, IFFT (FFT (x)) = x * length(x). This is a not a problem because +most of the applications don't care about absolute values. Thus, the operation +requires less calculation. If you want to use the FFT and IFFT to transform a +signal, you have to apply post- (or pre-) processing yourself. Multiplying +or dividing floating point numbers by a power of 2 doesn't generate extra +computation noise. + + + +4. Compilation and testing +-------------------------- + +Drop the following files into your project or makefile: + +Array.* +def.h +DynArray.* +FFTReal*.cpp +FFTReal*.h* +OscSinCos.* + +Other files are for testing purpose only, do not include them if you just need +to use the library ; they are not needed to use FFTReal in your own programs. + +FFTReal may be compiled in two versions: release and debug. Debug version +has checks that could slow down the code. Define NDEBUG to set the Release +mode. For example, the command line to compile the test bench on GCC would +look like: + +Debug mode: +g++ -Wall -o fftreal_debug.exe *.cpp stopwatch/*.cpp + +Release mode: +g++ -Wall -o fftreal_release.exe -DNDEBUG -O3 *.cpp stopwatch/*.cpp + +It may be tricky to compile the test bench because the speed tests use the +stopwatch sub-library, which is not that cross-platform. If you encounter +any problem that you cannot easily fix while compiling it, edit the file +test_settings.h and un-define the speed test macro. Remove the stopwatch +directory from your source file list, too. + +If it's not done by default, you should activate the exception handling +of your compiler to get the class memory-leak-safe. Thus, when a memory +allocation fails (in the constructor), an exception is thrown and the entire +object is safely destructed. It reduces the permanent error checking overhead +in the client code. Also, the test bench requires Run-Time Type Information +(RTTI) to be enabled in order to display the names of the tested classes - +sometimes mangled, depending on the compiler. + +The test bench may take a long time to compile, especially in Release mode, +because a lot of recursive templates are instanciated. + + + +5. History +---------- + +v2.00 (2005.10.18) +- Turned FFTReal class into template (data type as parameter) +- Added FFTRealFixLen +- Trigonometric tables are size-limited in order to preserve cache memory; +over a given size, sin/cos functions are computed on the fly. +- Better test bench for accuracy and speed + +v1.03 (2001.06.15) +- Thanks to Frederic Vanmol for the Pascal port (works with Delphi). +- Documentation improvement + +v1.02 (2001.03.25) +- sqrt() is now precomputed when the object FFTReal is constructed, resulting +in speed impovement for small size FFT. + +v1.01 (2000) +- Small modifications, I don't remember what. + +v1.00 (1999.08.14) +- First version released + diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.cpp b/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.cpp new file mode 100644 index 0000000..fe1d424 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.cpp @@ -0,0 +1,285 @@ +/***************************************************************************** + + ClockCycleCounter.cpp + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (_MSC_VER) + #pragma warning (1 : 4130) // "'operator' : logical operation on address of string constant" + #pragma warning (1 : 4223) // "nonstandard extension used : non-lvalue array converted to pointer" + #pragma warning (1 : 4705) // "statement has no effect" + #pragma warning (1 : 4706) // "assignment within conditional expression" + #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" + #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" + #pragma warning (4 : 4355) // "'this' : used in base member initializer list" +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "ClockCycleCounter.h" + +#include <cassert> + + + +namespace stopwatch +{ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/* +============================================================================== +Name: ctor +Description: + The first object constructed initialise global data. This first + construction may be a bit slow. +Throws: Nothing +============================================================================== +*/ + +ClockCycleCounter::ClockCycleCounter () +: _start_time (0) +, _state (0) +, _best_score (-1) +{ + if (! _init_flag) + { + // Should be executed in this order + compute_clk_mul (); + compute_measure_time_total (); + compute_measure_time_lap (); + + // Restores object state + _start_time = 0; + _state = 0; + _best_score = -1; + + _init_flag = true; + } +} + + + +/* +============================================================================== +Name: get_time_total +Description: + Gives the time elapsed between the latest stop_lap() and start() calls. +Returns: + The duration, in clock cycles. +Throws: Nothing +============================================================================== +*/ + +Int64 ClockCycleCounter::get_time_total () const +{ + const Int64 duration = _state - _start_time; + assert (duration >= 0); + + const Int64 t = max ( + duration - _measure_time_total, + static_cast <Int64> (0) + ); + + return (t * _clk_mul); +} + + + +/* +============================================================================== +Name: get_time_best_lap +Description: + Gives the smallest time between two consecutive stop_lap() or between + the stop_lap() and start(). The value is reset by a call to start(). + Call this function only after a stop_lap(). + The time is amputed from the duration of the stop_lap() call itself. +Returns: + The smallest duration, in clock cycles. +Throws: Nothing +============================================================================== +*/ + +Int64 ClockCycleCounter::get_time_best_lap () const +{ + assert (_best_score >= 0); + + const Int64 t1 = max ( + _best_score - _measure_time_lap, + static_cast <Int64> (0) + ); + const Int64 t = min (t1, get_time_total ()); + + return (t * _clk_mul); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +#if defined (__MACOS__) + +static inline double stopwatch_ClockCycleCounter_get_time_s () +{ + const Nanoseconds ns = AbsoluteToNanoseconds (UpTime ()); + + return (ns.hi * 4294967296e-9 + ns.lo * 1e-9); +} + +#endif // __MACOS__ + + + +/* +============================================================================== +Name: compute_clk_mul +Description: + This function, only for PowerPC/MacOS computers, computes the multiplier + required to deduce clock cycles from the internal counter. +Throws: Nothing +============================================================================== +*/ + +void ClockCycleCounter::compute_clk_mul () +{ + assert (! _init_flag); + +#if defined (__MACOS__) + + long clk_speed_mhz = CurrentProcessorSpeed (); + const Int64 clk_speed = + static_cast <Int64> (clk_speed_mhz) * (1000L*1000L); + + const double start_time_s = stopwatch_ClockCycleCounter_get_time_s (); + start (); + + const double duration = 0.01; // Seconds + while (stopwatch_ClockCycleCounter_get_time_s () - start_time_s < duration) + { + continue; + } + + const double stop_time_s = stopwatch_ClockCycleCounter_get_time_s (); + stop (); + + const double diff_time_s = stop_time_s - start_time_s; + const double nbr_cycles = diff_time_s * static_cast <double> (clk_speed); + + const Int64 diff_time_c = _state - _start_time; + const double clk_mul = nbr_cycles / static_cast <double> (diff_time_c); + + _clk_mul = round_int (clk_mul); + +#endif // __MACOS__ +} + + + +void ClockCycleCounter::compute_measure_time_total () +{ + start (); + spend_time (); + + Int64 best_result = 0x7FFFFFFFL; // Should be enough + long nbr_tests = 100; + for (long cnt = 0; cnt < nbr_tests; ++cnt) + { + start (); + stop_lap (); + const Int64 duration = _state - _start_time; + best_result = min (best_result, duration); + } + + _measure_time_total = best_result; +} + + + +/* +============================================================================== +Name: compute_measure_time_lap +Description: + Computes the duration of one stop_lap() call and store it. It will be used + later to get the real duration of the measured operation (by substracting + the measurement duration). +Throws: Nothing +============================================================================== +*/ + +void ClockCycleCounter::compute_measure_time_lap () +{ + start (); + spend_time (); + + long nbr_tests = 10; + for (long cnt = 0; cnt < nbr_tests; ++cnt) + { + stop_lap (); + stop_lap (); + stop_lap (); + stop_lap (); + } + + _measure_time_lap = _best_score; +} + + + +void ClockCycleCounter::spend_time () +{ + const Int64 nbr_clocks = 500; // Number of clock cycles to spend + + const Int64 start = read_clock_counter (); + Int64 current; + + do + { + current = read_clock_counter (); + } + while ((current - start) * _clk_mul < nbr_clocks); +} + + + +Int64 ClockCycleCounter::_measure_time_total = 0; +Int64 ClockCycleCounter::_measure_time_lap = 0; +int ClockCycleCounter::_clk_mul = 1; +bool ClockCycleCounter::_init_flag = false; + + +} // namespace stopwatch + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.h b/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.h new file mode 100644 index 0000000..ba7a99a --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.h @@ -0,0 +1,124 @@ +/***************************************************************************** + + ClockCycleCounter.h + Copyright (c) 2003 Laurent de Soras + +Instrumentation class, for accurate time interval measurement. You may have +to modify the implementation to adapt it to your system and/or compiler. + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_ClockCycleCounter_HEADER_INCLUDED) +#define stopwatch_ClockCycleCounter_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "def.h" +#include "Int64.h" + + + +namespace stopwatch +{ + + + +class ClockCycleCounter +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + ClockCycleCounter (); + + stopwatch_FORCEINLINE void + start (); + stopwatch_FORCEINLINE void + stop_lap (); + Int64 get_time_total () const; + Int64 get_time_best_lap () const; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + void compute_clk_mul (); + void compute_measure_time_total (); + void compute_measure_time_lap (); + + static void spend_time (); + static stopwatch_FORCEINLINE Int64 + read_clock_counter (); + + Int64 _start_time; + Int64 _state; + Int64 _best_score; + + static Int64 _measure_time_total; + static Int64 _measure_time_lap; + static int _clk_mul; + static bool _init_flag; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + ClockCycleCounter (const ClockCycleCounter &other); + ClockCycleCounter & + operator = (const ClockCycleCounter &other); + bool operator == (const ClockCycleCounter &other); + bool operator != (const ClockCycleCounter &other); + +}; // class ClockCycleCounter + + + +} // namespace stopwatch + + + +#include "ClockCycleCounter.hpp" + + + +#endif // stopwatch_ClockCycleCounter_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.hpp b/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.hpp new file mode 100644 index 0000000..fbd511e --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.hpp @@ -0,0 +1,150 @@ +/***************************************************************************** + + ClockCycleCounter.hpp + Copyright (c) 2003 Laurent de Soras + +Please complete the definitions according to your compiler/architecture. +It's not a big deal if it's not possible to get the clock count... + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (stopwatch_ClockCycleCounter_CURRENT_CODEHEADER) + #error Recursive inclusion of ClockCycleCounter code header. +#endif +#define stopwatch_ClockCycleCounter_CURRENT_CODEHEADER + +#if ! defined (stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED) +#define stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "fnc.h" + +#include <climits> + + + +namespace stopwatch +{ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/* +============================================================================== +Name: start +Description: + Starts the counter. +Throws: Nothing +============================================================================== +*/ + +void ClockCycleCounter::start () +{ + _best_score = (static_cast <Int64> (1) << (sizeof (Int64) * CHAR_BIT - 2)); + const Int64 start_clock = read_clock_counter (); + _start_time = start_clock; + _state = start_clock - _best_score; +} + + + +/* +============================================================================== +Name: stop_lap +Description: + Captures the current time and updates the smallest duration between two + consecutive calls to stop_lap() or the latest start(). + start() must have been called at least once before calling this function. +Throws: Nothing +============================================================================== +*/ + +void ClockCycleCounter::stop_lap () +{ + const Int64 end_clock = read_clock_counter (); + _best_score = min (end_clock - _state, _best_score); + _state = end_clock; +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +Int64 ClockCycleCounter::read_clock_counter () +{ + register Int64 clock_cnt; + +#if defined (_MSC_VER) + + __asm + { + lea edi, clock_cnt + rdtsc + mov [edi ], eax + mov [edi + 4], edx + } + +#elif defined (__GNUC__) && defined (__i386__) + + __asm__ __volatile__ ("rdtsc" : "=A" (clock_cnt)); + +#elif (__MWERKS__) && defined (__POWERPC__) + + asm + { + loop: + mftbu clock_cnt@hiword + mftb clock_cnt@loword + mftbu r5 + cmpw clock_cnt@hiword,r5 + bne loop + } + +#endif + + return (clock_cnt); +} + + + +} // namespace stopwatch + + + +#endif // stopwatch_ClockCycleCounter_CODEHEADER_INCLUDED + +#undef stopwatch_ClockCycleCounter_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/Int64.h b/demos/spectrum/3rdparty/fftreal/stopwatch/Int64.h new file mode 100644 index 0000000..1e786e2 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/Int64.h @@ -0,0 +1,71 @@ +/***************************************************************************** + + Int64.h + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_Int64_HEADER_INCLUDED) +#define stopwatch_Int64_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +namespace stopwatch +{ + + +#if defined (_MSC_VER) + + typedef __int64 Int64; + +#elif defined (__MWERKS__) || defined (__GNUC__) + + typedef long long Int64; + +#elif defined (__BEOS__) + + typedef int64 Int64; + +#else + + #error No 64-bit integer type defined for this compiler ! + +#endif + + +} // namespace stopwatch + + + +#endif // stopwatch_Int64_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.cpp b/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.cpp new file mode 100644 index 0000000..7795d86 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.cpp @@ -0,0 +1,101 @@ +/***************************************************************************** + + StopWatch.cpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (_MSC_VER) + #pragma warning (1 : 4130) // "'operator' : logical operation on address of string constant" + #pragma warning (1 : 4223) // "nonstandard extension used : non-lvalue array converted to pointer" + #pragma warning (1 : 4705) // "statement has no effect" + #pragma warning (1 : 4706) // "assignment within conditional expression" + #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" + #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" + #pragma warning (4 : 4355) // "'this' : used in base member initializer list" +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "StopWatch.h" + +#include <cassert> + + + +namespace stopwatch +{ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +StopWatch::StopWatch () +: _ccc () +, _nbr_laps (0) +{ + // Nothing +} + + + +double StopWatch::get_time_total (Int64 nbr_op) const +{ + assert (_nbr_laps > 0); + assert (nbr_op > 0); + + return ( + static_cast <double> (_ccc.get_time_total ()) + / (static_cast <double> (nbr_op) * static_cast <double> (_nbr_laps)) + ); +} + + + +double StopWatch::get_time_best_lap (Int64 nbr_op) const +{ + assert (nbr_op > 0); + + return ( + static_cast <double> (_ccc.get_time_best_lap ()) + / static_cast <double> (nbr_op) + ); +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +} // namespace stopwatch + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.h b/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.h new file mode 100644 index 0000000..9cc47e5 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.h @@ -0,0 +1,110 @@ +/***************************************************************************** + + StopWatch.h + Copyright (c) 2005 Laurent de Soras + +Utility class based on ClockCycleCounter to measure the unit time of a +repeated operation. + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_StopWatch_HEADER_INCLUDED) +#define stopwatch_StopWatch_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "ClockCycleCounter.h" + + + +namespace stopwatch +{ + + + +class StopWatch +{ + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +public: + + StopWatch (); + + stopwatch_FORCEINLINE void + start (); + stopwatch_FORCEINLINE void + stop_lap (); + + double get_time_total (Int64 nbr_op) const; + double get_time_best_lap (Int64 nbr_op) const; + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +protected: + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + ClockCycleCounter + _ccc; + Int64 _nbr_laps; + + + +/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +private: + + StopWatch (const StopWatch &other); + StopWatch & operator = (const StopWatch &other); + bool operator == (const StopWatch &other); + bool operator != (const StopWatch &other); + +}; // class StopWatch + + + +} // namespace stopwatch + + + +#include "StopWatch.hpp" + + + +#endif // stopwatch_StopWatch_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.hpp b/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.hpp new file mode 100644 index 0000000..74482a7 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/StopWatch.hpp @@ -0,0 +1,83 @@ +/***************************************************************************** + + StopWatch.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (stopwatch_StopWatch_CURRENT_CODEHEADER) + #error Recursive inclusion of StopWatch code header. +#endif +#define stopwatch_StopWatch_CURRENT_CODEHEADER + +#if ! defined (stopwatch_StopWatch_CODEHEADER_INCLUDED) +#define stopwatch_StopWatch_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +namespace stopwatch +{ + + + +/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +void StopWatch::start () +{ + _nbr_laps = 0; + _ccc.start (); +} + + + +void StopWatch::stop_lap () +{ + _ccc.stop_lap (); + ++ _nbr_laps; +} + + + +/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +} // namespace stopwatch + + + +#endif // stopwatch_StopWatch_CODEHEADER_INCLUDED + +#undef stopwatch_StopWatch_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/def.h b/demos/spectrum/3rdparty/fftreal/stopwatch/def.h new file mode 100644 index 0000000..81ee6aa --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/def.h @@ -0,0 +1,65 @@ +/***************************************************************************** + + def.h + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_def_HEADER_INCLUDED) +#define stopwatch_def_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +namespace stopwatch +{ + + + +#if defined (_MSC_VER) + + #define stopwatch_FORCEINLINE __forceinline + +#else + + #define stopwatch_FORCEINLINE inline + +#endif + + + +} // namespace stopwatch + + + +#endif // stopwatch_def_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/fnc.h b/demos/spectrum/3rdparty/fftreal/stopwatch/fnc.h new file mode 100644 index 0000000..0554535 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/fnc.h @@ -0,0 +1,67 @@ +/***************************************************************************** + + fnc.h + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (stopwatch_fnc_HEADER_INCLUDED) +#define stopwatch_fnc_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +namespace stopwatch +{ + + + +template <typename T> +inline T min (T a, T b); + +template <typename T> +inline T max (T a, T b); + +inline int round_int (double x); + + + +} // namespace rsp + + + +#include "fnc.hpp" + + + +#endif // stopwatch_fnc_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/stopwatch/fnc.hpp b/demos/spectrum/3rdparty/fftreal/stopwatch/fnc.hpp new file mode 100644 index 0000000..0ab5949 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/stopwatch/fnc.hpp @@ -0,0 +1,85 @@ +/***************************************************************************** + + fnc.hpp + Copyright (c) 2003 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (stopwatch_fnc_CURRENT_CODEHEADER) + #error Recursive inclusion of fnc code header. +#endif +#define stopwatch_fnc_CURRENT_CODEHEADER + +#if ! defined (stopwatch_fnc_CODEHEADER_INCLUDED) +#define stopwatch_fnc_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include <cassert> +#include <cmath> + +namespace std {} + + + +namespace stopwatch +{ + + + +template <typename T> +inline T min (T a, T b) +{ + return ((a < b) ? a : b); +} + + + +template <typename T> +inline T max (T a, T b) +{ + return ((b < a) ? a : b); +} + + + +int round_int (double x) +{ + using namespace std; + + return (static_cast <int> (floor (x + 0.5))); +} + + + +} // namespace stopwatch + + + +#endif // stopwatch_fnc_CODEHEADER_INCLUDED + +#undef stopwatch_fnc_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/test.cpp b/demos/spectrum/3rdparty/fftreal/test.cpp new file mode 100644 index 0000000..7b6ed2c --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/test.cpp @@ -0,0 +1,267 @@ +/***************************************************************************** + + test.cpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (_MSC_VER) + #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" + #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + +#include "test_settings.h" +#include "TestHelperFixLen.h" +#include "TestHelperNormal.h" + +#if defined (_MSC_VER) +#include <crtdbg.h> +#include <new.h> +#endif // _MSC_VER + +#include <new> + +#include <cassert> +#include <cstdio> + + + +#define TEST_ + + +/*\\\ FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +static int TEST_perform_test_accuracy_all (); +static int TEST_perform_test_speed_all (); + +static void TEST_prog_init (); +static void TEST_prog_end (); + + + +int main (int argc, char *argv []) +{ + using namespace std; + + int ret_val = 0; + + TEST_prog_init (); + + try + { + if (ret_val == 0) + { + ret_val = TEST_perform_test_accuracy_all (); + } + + if (ret_val == 0) + { + ret_val = TEST_perform_test_speed_all (); + } + } + + catch (std::exception &e) + { + printf ("\n*** main(): Exception (std::exception) : %s\n", e.what ()); + ret_val = -1; + } + + catch (...) + { + printf ("\n*** main(): Undefined exception\n"); + ret_val = -1; + } + + TEST_prog_end (); + + return (ret_val); +} + + + +int TEST_perform_test_accuracy_all () +{ + int ret_val = 0; + + TestHelperNormal <float >::perform_test_accuracy (ret_val); + TestHelperNormal <double>::perform_test_accuracy (ret_val); + + TestHelperFixLen < 1>::perform_test_accuracy (ret_val); + TestHelperFixLen < 2>::perform_test_accuracy (ret_val); + TestHelperFixLen < 3>::perform_test_accuracy (ret_val); + TestHelperFixLen < 4>::perform_test_accuracy (ret_val); + TestHelperFixLen < 7>::perform_test_accuracy (ret_val); + TestHelperFixLen < 8>::perform_test_accuracy (ret_val); + TestHelperFixLen <10>::perform_test_accuracy (ret_val); + TestHelperFixLen <12>::perform_test_accuracy (ret_val); + TestHelperFixLen <13>::perform_test_accuracy (ret_val); + + return (ret_val); +} + + + +int TEST_perform_test_speed_all () +{ + int ret_val = 0; + +#if defined (test_settings_SPEED_TEST_ENABLED) + + TestHelperNormal <float >::perform_test_speed (ret_val); + TestHelperNormal <double>::perform_test_speed (ret_val); + + TestHelperFixLen < 1>::perform_test_speed (ret_val); + TestHelperFixLen < 2>::perform_test_speed (ret_val); + TestHelperFixLen < 3>::perform_test_speed (ret_val); + TestHelperFixLen < 4>::perform_test_speed (ret_val); + TestHelperFixLen < 7>::perform_test_speed (ret_val); + TestHelperFixLen < 8>::perform_test_speed (ret_val); + TestHelperFixLen <10>::perform_test_speed (ret_val); + TestHelperFixLen <12>::perform_test_speed (ret_val); + TestHelperFixLen <14>::perform_test_speed (ret_val); + TestHelperFixLen <16>::perform_test_speed (ret_val); + TestHelperFixLen <20>::perform_test_speed (ret_val); + +#endif + + return (ret_val); +} + + + +#if defined (_MSC_VER) +static int __cdecl TEST_new_handler_cb (size_t dummy) +{ + throw std::bad_alloc (); + return (0); +} +#endif // _MSC_VER + + + +#if defined (_MSC_VER) && ! defined (NDEBUG) +static int __cdecl TEST_debug_alloc_hook_cb (int alloc_type, void *user_data_ptr, size_t size, int block_type, long request_nbr, const unsigned char *filename_0, int line_nbr) +{ + if (block_type != _CRT_BLOCK) // Ignore CRT blocks to prevent infinite recursion + { + switch (alloc_type) + { + case _HOOK_ALLOC: + case _HOOK_REALLOC: + case _HOOK_FREE: + + // Put some debug code here + + break; + + default: + assert (false); // Undefined allocation type + break; + } + } + + return (1); +} +#endif + + + +#if defined (_MSC_VER) && ! defined (NDEBUG) +static int __cdecl TEST_debug_report_hook_cb (int report_type, char *user_msg_0, int *ret_val_ptr) +{ + *ret_val_ptr = 0; // 1 to override the CRT default reporting mode + + switch (report_type) + { + case _CRT_WARN: + case _CRT_ERROR: + case _CRT_ASSERT: + +// Put some debug code here + + break; + } + + return (*ret_val_ptr); +} +#endif + + + +static void TEST_prog_init () +{ +#if defined (_MSC_VER) + ::_set_new_handler (::TEST_new_handler_cb); +#endif // _MSC_VER + +#if defined (_MSC_VER) && ! defined (NDEBUG) + { + const int mode = (1 * _CRTDBG_MODE_DEBUG) + | (1 * _CRTDBG_MODE_WNDW); + ::_CrtSetReportMode (_CRT_WARN, mode); + ::_CrtSetReportMode (_CRT_ERROR, mode); + ::_CrtSetReportMode (_CRT_ASSERT, mode); + + const int old_flags = ::_CrtSetDbgFlag (_CRTDBG_REPORT_FLAG); + ::_CrtSetDbgFlag ( old_flags + | (1 * _CRTDBG_LEAK_CHECK_DF) + | (1 * _CRTDBG_CHECK_ALWAYS_DF)); + ::_CrtSetBreakAlloc (-1); // Specify here a memory bloc number + ::_CrtSetAllocHook (TEST_debug_alloc_hook_cb); + ::_CrtSetReportHook (TEST_debug_report_hook_cb); + + // Speed up I/O but breaks C stdio compatibility +// std::cout.sync_with_stdio (false); +// std::cin.sync_with_stdio (false); +// std::cerr.sync_with_stdio (false); +// std::clog.sync_with_stdio (false); + } +#endif // _MSC_VER, NDEBUG +} + + + +static void TEST_prog_end () +{ +#if defined (_MSC_VER) && ! defined (NDEBUG) + { + const int mode = (1 * _CRTDBG_MODE_DEBUG) + | (0 * _CRTDBG_MODE_WNDW); + ::_CrtSetReportMode (_CRT_WARN, mode); + ::_CrtSetReportMode (_CRT_ERROR, mode); + ::_CrtSetReportMode (_CRT_ASSERT, mode); + + ::_CrtMemState mem_state; + ::_CrtMemCheckpoint (&mem_state); + ::_CrtMemDumpStatistics (&mem_state); + } +#endif // _MSC_VER, NDEBUG +} + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/test_fnc.h b/demos/spectrum/3rdparty/fftreal/test_fnc.h new file mode 100644 index 0000000..2622156 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/test_fnc.h @@ -0,0 +1,53 @@ +/***************************************************************************** + + test_fnc.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (test_fnc_HEADER_INCLUDED) +#define test_fnc_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class T> +inline T limit (const T &x, const T &inf, const T &sup); + + + +#include "test_fnc.hpp" + + + +#endif // test_fnc_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/test_fnc.hpp b/demos/spectrum/3rdparty/fftreal/test_fnc.hpp new file mode 100644 index 0000000..4b5f9f5 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/test_fnc.hpp @@ -0,0 +1,56 @@ +/***************************************************************************** + + test_fnc.hpp + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if defined (test_fnc_CURRENT_CODEHEADER) + #error Recursive inclusion of test_fnc code header. +#endif +#define test_fnc_CURRENT_CODEHEADER + +#if ! defined (test_fnc_CODEHEADER_INCLUDED) +#define test_fnc_CODEHEADER_INCLUDED + + + +/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + + + +template <class T> +T limit (const T &x, const T &inf, const T &sup) +{ + assert (! (sup < inf)); + + return ((x < inf) ? inf : ((sup < x) ? sup : x)); +} + + + +#endif // test_fnc_CODEHEADER_INCLUDED + +#undef test_fnc_CURRENT_CODEHEADER + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/test_settings.h b/demos/spectrum/3rdparty/fftreal/test_settings.h new file mode 100644 index 0000000..b893afc --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/test_settings.h @@ -0,0 +1,45 @@ +/***************************************************************************** + + test_settings.h + Copyright (c) 2005 Laurent de Soras + +--- Legal stuff --- + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*Tab=3***********************************************************************/ + + + +#if ! defined (test_settings_HEADER_INCLUDED) +#define test_settings_HEADER_INCLUDED + +#if defined (_MSC_VER) + #pragma once + #pragma warning (4 : 4250) // "Inherits via dominance." +#endif + + + +// #undef this label to avoid speed test compilation. +#define test_settings_SPEED_TEST_ENABLED + + + +#endif // test_settings_HEADER_INCLUDED + + + +/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/demos/spectrum/3rdparty/fftreal/testapp.dpr b/demos/spectrum/3rdparty/fftreal/testapp.dpr new file mode 100644 index 0000000..54f2eb9 --- /dev/null +++ b/demos/spectrum/3rdparty/fftreal/testapp.dpr @@ -0,0 +1,150 @@ +program testapp; +{$APPTYPE CONSOLE} +uses + SysUtils, + fftreal in 'fftreal.pas', + Math, + Windows; + +var + nbr_points : longint; + x, f : pflt_array; + fft : TFFTReal; + i : longint; + PI : double; + areal, img : double; + f_abs : double; + buffer_size : longint; + nbr_tests : longint; + time0, time1, time2 : int64; + timereso : int64; + offset : longint; + t0, t1 : double; + nbr_s_chn : longint; + tempp1, tempp2 : pflt_array; + +begin + (*______________________________________________ + * + * Exactness test + *______________________________________________ + *) + + WriteLn('Accuracy test:'); + WriteLn; + + nbr_points := 16; // Power of 2 + GetMem(x, nbr_points * sizeof_flt); + GetMem(f, nbr_points * sizeof_flt); + fft := TFFTReal.Create(nbr_points); // FFT object initialized here + + // Test signal + PI := ArcTan(1) * 4; + for i := 0 to nbr_points-1 do + begin + x^[i] := -1 + sin (3*2*PI*i/nbr_points) + + cos (5*2*PI*i/nbr_points) * 2 + - sin (7*2*PI*i/nbr_points) * 3 + + cos (8*2*PI*i/nbr_points) * 5; + end; + + // Compute FFT and IFFT + fft.do_fft(f, x); + fft.do_ifft(f, x); + fft.rescale(x); + + // Display the result + WriteLn('FFT:'); + for i := 0 to nbr_points div 2 do + begin + areal := f^[i]; + if (i > 0) and (i < nbr_points div 2) then + img := f^[i + nbr_points div 2] + else + img := 0; + + f_abs := Sqrt(areal * areal + img * img); + WriteLn(Format('%5d: %12.6f %12.6f (%12.6f)', [i, areal, img, f_abs])); + end; + + WriteLn; + WriteLn('IFFT:'); + for i := 0 to nbr_points-1 do + WriteLn(Format('%5d: %f', [i, x^[i]])); + + WriteLn; + + FreeMem(x); + FreeMem(f); + fft.Free; + + + (*______________________________________________ + * + * Speed test + *______________________________________________ + *) + + WriteLn('Speed test:'); + WriteLn('Please wait...'); + WriteLn; + + nbr_points := 1024; // Power of 2 + buffer_size := 256*nbr_points; // Number of flt_t (float or double) + nbr_tests := 10000; + + assert(nbr_points <= buffer_size); + GetMem(x, buffer_size * sizeof_flt); + GetMem(f, buffer_size * sizeof_flt); + fft := TFFTReal.Create(nbr_points); // FFT object initialized here + + // Test signal: noise + for i := 0 to nbr_points-1 do + x^[i] := Random($7fff) - ($7fff shr 1); + + // timing + QueryPerformanceFrequency(timereso); + QueryPerformanceCounter(time0); + + for i := 0 to nbr_tests-1 do + begin + offset := (i * nbr_points) and (buffer_size - 1); + tempp1 := f; + inc(tempp1, offset); + tempp2 := x; + inc(tempp2, offset); + fft.do_fft(tempp1, tempp2); + end; + + QueryPerformanceCounter(time1); + + for i := 0 to nbr_tests-1 do + begin + offset := (i * nbr_points) and (buffer_size - 1); + tempp1 := f; + inc(tempp1, offset); + tempp2 := x; + inc(tempp2, offset); + fft.do_ifft(tempp1, tempp2); + fft.rescale(x); + end; + + QueryPerformanceCounter(time2); + + t0 := ((time1-time0) / timereso) / nbr_tests; + t1 := ((time2-time1) / timereso) / nbr_tests; + + WriteLn(Format('%d-points FFT : %.0f us.', [nbr_points, t0 * 1000000])); + WriteLn(Format('%d-points IFFT + scaling: %.0f us.', [nbr_points, t1 * 1000000])); + + nbr_s_chn := Floor(nbr_points / ((t0 + t1) * 44100 * 2)); + WriteLn(Format('Peak performance: FFT+IFFT on %d mono channels at 44.1 KHz (with overlapping)', [nbr_s_chn])); + WriteLn; + + FreeMem(x); + FreeMem(f); + fft.Free; + + WriteLn('Press [Return] key to terminate...'); + ReadLn; +end. diff --git a/demos/spectrum/README.txt b/demos/spectrum/README.txt new file mode 100644 index 0000000..c39d4a7 --- /dev/null +++ b/demos/spectrum/README.txt @@ -0,0 +1,103 @@ +Spectrum analyser demo app +========================== + +Introduction +------------ + +This application is a demo which uses the QtMultimedia APIs to capture and play back PCM audio. While either recording or playback is ongoing, the application performs real-time level and frequency spectrum analysis, displaying the results in its main window. + + +Acknowledgments +--------------- + +The application uses the FFTReal v2.00 library by Laurent de Soras to perform frequency analysis of the audio signal. For further information, see the project home page: + http://ldesoras.free.fr/prod.html + + +Quick start +----------- + +Play generated tone +1. Select 'Play generated tone' from the mode menu +2. Ensure that the 'Frequency sweep' box is checked +3. Press 'OK' +4. Press the play button +You should hear a rising tone, and see progressively higher frequencies indicated by the spectrograph. + +Record and playback +1. Select 'Record and play back audio' from the mode menu +2. Press the record button, and speak into the microphone +3. Wait until the buffer is full (shown as a full blue bar in the top widget) +4. Press play, and wait until playback of the buffer is complete + +Play file +1. Select 'Play file' from the mode menu +2. Select a WAV file +3. Press the play button +You should hear the first few seconds of the file being played. The waveform, spectrograph and level meter should be updated as the file is played. + + +Things to play with +------------------- + +Try repeating the 'Play generated tone' sequence using different window functions. These can be selected from the settings dialog - launch it by pressing the spanner icon. The window function is applied to the audio signal before performing the frequency analysis; different windows should have a visible effect on the resulting frequency spectrum. + +Try clicking on one of the spectrograph bars while the tone is being played. The frequency range for that bar will be displayed at the top of the application window. + + +Troubleshooting +--------------- + +If either recording or playback do not work, you may need to select a different input / output audio device. This can be done in the settings dialog - launch it by pressing the spanner icon. + +If that doesn't work, there may be a problem either in the application or in Qt. Report a bug in the usual way. + + +Application interface +--------------------- + +The main window of the application contains the following widgets, starting at the top: + +Message box +This shows various messages during execution, such as the current audio format. + +Progress bar / waveform display +- While recording or playback is ongoing, the audio waveform is displayed, sliding from right to left. +- Superimposed on the waveform, the amount of data currently in the buffer is showed as a blue bar. When recording, this blue bar fills up from left to right; when playing, the bar gets consumed from left to right. +- A green window shows which part of the buffer has most recently been analysed. This window should be close to the 'leading edge' of recording or playback, i.e. the most recently recorded / played data, although it will lag slightly depending on the performance of the machine on which the application is running. + +Frequency spectrograph (on the left) +The spectrograph shows 10 bars, each representing a frequency range. The frequency range of each bar is displayed in the message box when the bar is clicked. The height of the bar shows the maximum amplitude of freqencies within its range. + +Level meter (on the right) +The current peak audio level is shown as a pink bar; the current RMS level is shown as a red bar. The 'high water mark' during a recent period is shown as a thin red line. + +Button panel +- The mode menu allows switching between the three operation modes - 'Play generated tone', 'Record and play back' and 'Play file'. +- The record button starts or resumes audio capture from the current input device. +- The pause button suspends either capture or recording. +- The play button starts or resumes audio playback to the current output device. +- The settings button launches the settings dialog. + + +Hacking +------- + +If you want to hack the application, here are some pointers to get started. + +The spectrum.pri file contains several macros which you can enable by uncommenting: +- LOG_FOO Enable logging from class Foo via qDebug() +- DUMP_FOO Dump data from class Foo to the file system + e.g. DUMP_SPECTRUMANALYSER writes files containing the raw FFT input and output. + Be aware that this can generate a *lot* of data and may slow the app down considerably. +- DISABLE_FOO Disable specified functionality + +If you don't like the combination of the waveform and progress bar in a single widget, separate them by commenting out SUPERIMPOSE_PROGRESS_ON_WAVEFORM. + +The spectrum.h file defines a number of parameters which can be played with. These control things such as the number of audio samples analysed per FFT calculation, the range and number of bands displayed by the spectrograph, and so on. + +The part of the application which interacts with QtMultimedia is in the Engine class. + +Some ideas for enhancements to the app are listed in TODO.txt. Feel free to start work on any of them :) + + diff --git a/demos/spectrum/TODO.txt b/demos/spectrum/TODO.txt new file mode 100644 index 0000000..dc3d8f3 --- /dev/null +++ b/demos/spectrum/TODO.txt @@ -0,0 +1,34 @@ +TODO list for spectrum analyser +=============================== + +Bug fixes +--------- + + +New features +------------ + +* Wrap user-visible strings in tr() + +* Allow user to set frequency range +There should be some constraints on this, e.g. + - Maximum frequency must not be greater than Nyquist frequency + - Range is divisible by number of bars? + +* Add more visualizers other than bar spectrogram +e.g. Funky OpenGL visualizers, particle effects etc + + +Non-functional stuff +-------------------- + +* Improve robustness of QComboBox -> enum mapping +At the moment, SettingsDialog relies on casting the combobox item index directly to the enumerated type. This is clearly a bit fragile... + +* For functions which take or return qint64 values, make a clear distinction between duration (microseconds) and length (bytes). +A sensible convention would be that the default is bytes - i.e. microseconds must be indicated by adding a Us suffix, where not already obvious from the function name. + + + + + diff --git a/demos/spectrum/app/app.pro b/demos/spectrum/app/app.pro new file mode 100644 index 0000000..2adb605 --- /dev/null +++ b/demos/spectrum/app/app.pro @@ -0,0 +1,121 @@ +include(../spectrum.pri) + +TEMPLATE = app + +TARGET = spectrum +unix: !macx: !symbian: TARGET = spectrum.bin + +QT += multimedia + +SOURCES += main.cpp \ + engine.cpp \ + frequencyspectrum.cpp \ + levelmeter.cpp \ + mainwidget.cpp \ + progressbar.cpp \ + settingsdialog.cpp \ + spectrograph.cpp \ + spectrumanalyser.cpp \ + tonegenerator.cpp \ + tonegeneratordialog.cpp \ + utils.cpp \ + waveform.cpp \ + wavfile.cpp + +HEADERS += engine.h \ + frequencyspectrum.h \ + levelmeter.h \ + mainwidget.h \ + progressbar.h \ + settingsdialog.h \ + spectrograph.h \ + spectrum.h \ + spectrumanalyser.h \ + tonegenerator.h \ + tonegeneratordialog.h \ + utils.h \ + waveform.h \ + wavfile.h + +fftreal_dir = ../3rdparty/fftreal + +INCLUDEPATH += $${fftreal_dir} + +RESOURCES = spectrum.qrc + +symbian { + # Platform security capability required to record audio on Symbian + TARGET.CAPABILITY += UserEnvironment + + # Provide unique ID for the generated binary, required by Symbian OS + TARGET.UID3 = 0xA000E3FA +} + + +# Dynamic linkage against FFTReal DLL +!contains(DEFINES, DISABLE_FFT) { + symbian { + # Must explicitly add the .dll suffix to ensure dynamic linkage + LIBS += -lfftreal.dll + } else { + macx { + # Link to fftreal framework + LIBS += -F$${fftreal_dir} + LIBS += -framework fftreal + } else { + # Link to dynamic library which is written to ../bin + LIBS += -L../bin + LIBS += -lfftreal + } + } +} + + +# Deployment + +symbian { + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + + !contains(DEFINES, DISABLE_FFT) { + # Include FFTReal DLL in the SIS file + fftreal.sources = $${EPOCROOT}epoc32/release/$(PLATFORM)/$(TARGET)/fftreal.dll + fftreal.path = !:/sys/bin + DEPLOYMENT += fftreal + } +} else { + macx { + # Specify directory in which to create spectrum.app bundle + DESTDIR = .. + + !contains(DEFINES, DISABLE_FFT) { + # Relocate fftreal.framework into spectrum.app bundle + framework_dir = ../spectrum.app/Contents/Frameworks + framework_name = fftreal.framework/Versions/1/fftreal + QMAKE_POST_LINK = \ + mkdir -p $${framework_dir} &&\ + rm -rf $${framework_dir}/fftreal.framework &&\ + cp -R $${fftreal_dir}/fftreal.framework $${framework_dir} &&\ + install_name_tool -id @executable_path/../Frameworks/$${framework_name} \ + $${framework_dir}/$${framework_name} &&\ + install_name_tool -change $${framework_name} \ + @executable_path/../Frameworks/$${framework_name} \ + ../spectrum.app/Contents/MacOS/spectrum + } + } else { + # Specify directory in which to create spectrum application + DESTDIR = ../bin + + unix: !symbian { + # On unices other than Mac OSX, we copy a shell script into the bin directory. + # This script takes care of correctly setting the LD_LIBRARY_PATH so that + # the dynamic library can be located. + copy_launch_script.target = copy_launch_script + copy_launch_script.commands = \ + install -m 0555 spectrum.sh ../bin/spectrum + QMAKE_EXTRA_TARGETS += copy_launch_script + POST_TARGETDEPS += copy_launch_script + } + } +} + + diff --git a/demos/spectrum/app/engine.cpp b/demos/spectrum/app/engine.cpp new file mode 100644 index 0000000..5cdfb6d --- /dev/null +++ b/demos/spectrum/app/engine.cpp @@ -0,0 +1,752 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 "engine.h" +#include "tonegenerator.h" +#include "utils.h" + +#include <math.h> + +#include <QCoreApplication> +#include <QMetaObject> +#include <QSet> +#include <QtMultimedia/QAudioInput> +#include <QtMultimedia/QAudioOutput> +#include <QDebug> +#include <QThread> +#include <QFile> + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +const qint64 BufferDurationUs = 10 * 1000000; +const int NotifyIntervalMs = 100; + +// Size of the level calculation window in microseconds +const int LevelWindowUs = 0.1 * 1000000; + + +//----------------------------------------------------------------------------- +// Helper functions +//----------------------------------------------------------------------------- + +QDebug& operator<<(QDebug &debug, const QAudioFormat &format) +{ + debug << format.frequency() << "Hz" + << format.channels() << "channels"; + return debug; +} + +//----------------------------------------------------------------------------- +// Constructor and destructor +//----------------------------------------------------------------------------- + +Engine::Engine(QObject *parent) + : QObject(parent) + , m_mode(QAudio::AudioInput) + , m_state(QAudio::StoppedState) + , m_generateTone(false) + , m_file(0) + , m_availableAudioInputDevices + (QAudioDeviceInfo::availableDevices(QAudio::AudioInput)) + , m_audioInputDevice(QAudioDeviceInfo::defaultInputDevice()) + , m_audioInput(0) + , m_audioInputIODevice(0) + , m_recordPosition(0) + , m_availableAudioOutputDevices + (QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) + , m_audioOutputDevice(QAudioDeviceInfo::defaultOutputDevice()) + , m_audioOutput(0) + , m_playPosition(0) + , m_dataLength(0) + , m_rmsLevel(0.0) + , m_peakLevel(0.0) + , m_spectrumLengthBytes(0) + , m_spectrumAnalyser() + , m_spectrumPosition(0) + , m_count(0) +{ + qRegisterMetaType<FrequencySpectrum>("FrequencySpectrum"); + CHECKED_CONNECT(&m_spectrumAnalyser, + SIGNAL(spectrumChanged(FrequencySpectrum)), + this, + SLOT(spectrumChanged(FrequencySpectrum))); + + initialize(); + +#ifdef DUMP_DATA + createOutputDir(); +#endif + +#ifdef DUMP_SPECTRUM + m_spectrumAnalyser.setOutputPath(outputPath()); +#endif +} + +Engine::~Engine() +{ + +} + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +bool Engine::loadFile(const QString &fileName) +{ + bool result = false; + m_generateTone = false; + + Q_ASSERT(!fileName.isEmpty()); + Q_ASSERT(!m_file); + m_file = new QFile(fileName, this); + m_file->setFileName(fileName); + Q_ASSERT(m_file->exists()); + if (m_file->open(QFile::ReadOnly)) { + m_wavFile.readHeader(*m_file); + if (isPCMS16LE(m_wavFile.format())) { + result = initialize(); + } else { + emit errorMessage(tr("Audio format not supported"), + formatToString(m_wavFile.format())); + } + } else { + emit errorMessage(tr("Could not open file"), fileName); + } + + delete m_file; + m_file = 0; + + return result; +} + +bool Engine::generateTone(const Tone &tone) +{ + Q_ASSERT(!m_file); + m_generateTone = true; + m_tone = tone; + ENGINE_DEBUG << "Engine::generateTone" + << "startFreq" << m_tone.startFreq + << "endFreq" << m_tone.endFreq + << "amp" << m_tone.amplitude; + return initialize(); +} + +bool Engine::generateSweptTone(qreal amplitude) +{ + Q_ASSERT(!m_file); + m_generateTone = true; + m_tone.startFreq = 1; + m_tone.endFreq = 0; + m_tone.amplitude = amplitude; + ENGINE_DEBUG << "Engine::generateSweptTone" + << "startFreq" << m_tone.startFreq + << "amp" << m_tone.amplitude; + return initialize(); +} + +bool Engine::initializeRecord() +{ + ENGINE_DEBUG << "Engine::initializeRecord"; + Q_ASSERT(!m_file); + m_generateTone = false; + m_tone = SweptTone(); + return initialize(); +} + +qint64 Engine::bufferDuration() const +{ + return BufferDurationUs; +} + +qint64 Engine::dataDuration() const +{ + qint64 result = 0; + if (QAudioFormat() != m_format) + result = audioDuration(m_format, m_dataLength); + return result; +} + +qint64 Engine::audioBufferLength() const +{ + qint64 length = 0; + if (QAudio::ActiveState == m_state || QAudio::IdleState == m_state) { + Q_ASSERT(QAudioFormat() != m_format); + switch (m_mode) { + case QAudio::AudioInput: + length = m_audioInput->bufferSize(); + break; + case QAudio::AudioOutput: + length = m_audioOutput->bufferSize(); + break; + } + } + return length; +} + +void Engine::setWindowFunction(WindowFunction type) +{ + m_spectrumAnalyser.setWindowFunction(type); +} + + +//----------------------------------------------------------------------------- +// Public slots +//----------------------------------------------------------------------------- + +void Engine::startRecording() +{ + if (m_audioInput) { + if (QAudio::AudioInput == m_mode && + QAudio::SuspendedState == m_state) { + m_audioInput->resume(); + } else { + m_spectrumAnalyser.cancelCalculation(); + spectrumChanged(0, 0, FrequencySpectrum()); + + m_buffer.fill(0); + setRecordPosition(0, true); + stopPlayback(); + m_mode = QAudio::AudioInput; + CHECKED_CONNECT(m_audioInput, SIGNAL(stateChanged(QAudio::State)), + this, SLOT(audioStateChanged(QAudio::State))); + CHECKED_CONNECT(m_audioInput, SIGNAL(notify()), + this, SLOT(audioNotify())); + m_count = 0; + m_dataLength = 0; + emit dataDurationChanged(0); + m_audioInputIODevice = m_audioInput->start(); + CHECKED_CONNECT(m_audioInputIODevice, SIGNAL(readyRead()), + this, SLOT(audioDataReady())); + } + } +} + +void Engine::startPlayback() +{ + if (m_audioOutput) { + if (QAudio::AudioOutput == m_mode && + QAudio::SuspendedState == m_state) { +#ifdef Q_OS_WIN + // The Windows backend seems to internally go back into ActiveState + // while still returning SuspendedState, so to ensure that it doesn't + // ignore the resume() call, we first re-suspend + m_audioOutput->suspend(); +#endif + m_audioOutput->resume(); + } else { + m_spectrumAnalyser.cancelCalculation(); + spectrumChanged(0, 0, FrequencySpectrum()); + + setPlayPosition(0, true); + stopRecording(); + m_mode = QAudio::AudioOutput; + CHECKED_CONNECT(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), + this, SLOT(audioStateChanged(QAudio::State))); + CHECKED_CONNECT(m_audioOutput, SIGNAL(notify()), + this, SLOT(audioNotify())); + m_count = 0; + m_audioOutputIODevice.close(); + m_audioOutputIODevice.setBuffer(&m_buffer); + m_audioOutputIODevice.open(QIODevice::ReadOnly); + m_audioOutput->start(&m_audioOutputIODevice); + } + } +} + +void Engine::suspend() +{ + if (QAudio::ActiveState == m_state || + QAudio::IdleState == m_state) { + switch (m_mode) { + case QAudio::AudioInput: + m_audioInput->suspend(); + break; + case QAudio::AudioOutput: + m_audioOutput->suspend(); + break; + } + } +} + +void Engine::setAudioInputDevice(const QAudioDeviceInfo &device) +{ + if (device.deviceName() != m_audioInputDevice.deviceName()) { + m_audioInputDevice = device; + initialize(); + } +} + +void Engine::setAudioOutputDevice(const QAudioDeviceInfo &device) +{ + if (device.deviceName() != m_audioOutputDevice.deviceName()) { + m_audioOutputDevice = device; + initialize(); + } +} + + +//----------------------------------------------------------------------------- +// Private slots +//----------------------------------------------------------------------------- + +void Engine::audioNotify() +{ + switch (m_mode) { + case QAudio::AudioInput: { + const qint64 recordPosition = + qMin(BufferDurationUs, m_audioInput->processedUSecs()); + setRecordPosition(recordPosition); + + // Calculate level of most recently captured data + qint64 levelLength = audioLength(m_format, LevelWindowUs); + levelLength = qMin(m_dataLength, levelLength); + const qint64 levelPosition = m_dataLength - levelLength; + calculateLevel(levelPosition, levelLength); + + // Calculate spectrum of most recently captured data + if (m_dataLength >= m_spectrumLengthBytes) { + const qint64 spectrumPosition = m_dataLength - m_spectrumLengthBytes; + calculateSpectrum(spectrumPosition); + } + } + break; + case QAudio::AudioOutput: { + const qint64 playPosition = + qMin(dataDuration(), m_audioOutput->processedUSecs()); + setPlayPosition(playPosition); + + qint64 analysisPosition = audioLength(m_format, playPosition); + + // Calculate level of data starting at current playback position + const qint64 levelLength = audioLength(m_format, LevelWindowUs); + if (analysisPosition + levelLength < m_dataLength) + calculateLevel(analysisPosition, levelLength); + + if (analysisPosition + m_spectrumLengthBytes < m_dataLength) + calculateSpectrum(analysisPosition); + + if (dataDuration() == playPosition) + stopPlayback(); + } + break; + } +} + +void Engine::audioStateChanged(QAudio::State state) +{ + ENGINE_DEBUG << "Engine::audioStateChanged from" << m_state + << "to" << state; + + if (QAudio::StoppedState == state) { + // Check error + QAudio::Error error = QAudio::NoError; + switch (m_mode) { + case QAudio::AudioInput: + error = m_audioInput->error(); + break; + case QAudio::AudioOutput: + error = m_audioOutput->error(); + break; + } + if (QAudio::NoError != error) { + reset(); + return; + } + } + setState(state); +} + +void Engine::audioDataReady() +{ + const qint64 bytesReady = m_audioInput->bytesReady(); + const qint64 bytesSpace = m_buffer.size() - m_dataLength; + const qint64 bytesToRead = qMin(bytesReady, bytesSpace); + + const qint64 bytesRead = m_audioInputIODevice->read( + m_buffer.data() + m_dataLength, + bytesToRead); + + if (bytesRead) { + m_dataLength += bytesRead; + + const qint64 duration = audioDuration(m_format, m_dataLength); + emit dataDurationChanged(duration); + } + + if (m_buffer.size() == m_dataLength) + stopRecording(); +} + +void Engine::spectrumChanged(const FrequencySpectrum &spectrum) +{ + ENGINE_DEBUG << "Engine::spectrumChanged" << "pos" << m_spectrumPosition; + const qint64 positionUs = audioDuration(m_format, m_spectrumPosition); + const qint64 lengthUs = audioDuration(m_format, m_spectrumLengthBytes); + emit spectrumChanged(positionUs, lengthUs, spectrum); +} + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void Engine::reset() +{ + stopRecording(); + stopPlayback(); + setState(QAudio::AudioInput, QAudio::StoppedState); + setFormat(QAudioFormat()); + delete m_audioInput; + m_audioInput = 0; + m_audioInputIODevice = 0; + setRecordPosition(0); + delete m_audioOutput; + m_audioOutput = 0; + setPlayPosition(0); + m_buffer.clear(); + m_dataLength = 0; + m_spectrumPosition = 0; + emit dataDurationChanged(0); + setLevel(0.0, 0.0, 0); +} + +bool Engine::initialize() +{ + bool result = false; + + reset(); + + if (selectFormat()) { + const qint64 bufferLength = audioLength(m_format, BufferDurationUs); + m_buffer.resize(bufferLength); + m_buffer.fill(0); + emit bufferDurationChanged(BufferDurationUs); + + if (m_generateTone) { + if (0 == m_tone.endFreq) { + const qreal nyquist = nyquistFrequency(m_format); + m_tone.endFreq = qMin(qreal(SpectrumHighFreq), nyquist); + } + + // Call function defined in utils.h, at global scope + ::generateTone(m_tone, m_format, m_buffer); + m_dataLength = m_buffer.size(); + emit dataDurationChanged(bufferDuration()); + setRecordPosition(bufferDuration()); + result = true; + } else if (m_file) { + const qint64 length = m_wavFile.readData(*m_file, m_buffer, m_format); + if (length) { + m_dataLength = length; + emit dataDurationChanged(dataDuration()); + setRecordPosition(dataDuration()); + result = true; + } + } else { + m_audioInput = new QAudioInput(m_audioInputDevice, m_format, this); + m_audioInput->setNotifyInterval(NotifyIntervalMs); + result = true; + } + + m_audioOutput = new QAudioOutput(m_audioOutputDevice, m_format, this); + m_audioOutput->setNotifyInterval(NotifyIntervalMs); + m_spectrumLengthBytes = SpectrumLengthSamples * + (m_format.sampleSize() / 8) * m_format.channels(); + } else { + if (m_file) + emit errorMessage(tr("Audio format not supported"), + formatToString(m_format)); + else if (m_generateTone) + emit errorMessage(tr("No suitable format found"), ""); + else + emit errorMessage(tr("No common input / output format found"), ""); + } + + ENGINE_DEBUG << "Engine::initialize" << "format" << m_format; + + return result; +} + +bool Engine::selectFormat() +{ + bool foundSupportedFormat = false; + + if (m_file) { + // Header is read from the WAV file; just need to check whether + // it is supported by the audio output device + QAudioFormat format = m_wavFile.format(); + if (m_audioOutputDevice.isFormatSupported(m_wavFile.format())) { + setFormat(m_wavFile.format()); + foundSupportedFormat = true; + } else { + // Try flipping mono <-> stereo + const int channels = (format.channels() == 1) ? 2 : 1; + format.setChannels(channels); + if (m_audioOutputDevice.isFormatSupported(format)) { + setFormat(format); + foundSupportedFormat = true; + } + } + } else { + + QList<int> frequenciesList; + #ifdef Q_OS_WIN + // The Windows audio backend does not correctly report format support + // (see QTBUG-9100). Furthermore, although the audio subsystem captures + // at 11025Hz, the resulting audio is corrupted. + frequenciesList += 8000; + #endif + + if (!m_generateTone) + frequenciesList += m_audioInputDevice.supportedFrequencies(); + + frequenciesList += m_audioOutputDevice.supportedFrequencies(); + frequenciesList = frequenciesList.toSet().toList(); // remove duplicates + qSort(frequenciesList); + ENGINE_DEBUG << "Engine::initialize frequenciesList" << frequenciesList; + + QList<int> channelsList; + channelsList += m_audioInputDevice.supportedChannels(); + channelsList += m_audioOutputDevice.supportedChannels(); + channelsList = channelsList.toSet().toList(); + qSort(channelsList); + ENGINE_DEBUG << "Engine::initialize channelsList" << channelsList; + + QAudioFormat format; + format.setByteOrder(QAudioFormat::LittleEndian); + format.setCodec("audio/pcm"); + format.setSampleSize(16); + format.setSampleType(QAudioFormat::SignedInt); + int frequency, channels; + foreach (frequency, frequenciesList) { + if (foundSupportedFormat) + break; + format.setFrequency(frequency); + foreach (channels, channelsList) { + format.setChannels(channels); + const bool inputSupport = m_generateTone || + m_audioInputDevice.isFormatSupported(format); + const bool outputSupport = m_audioOutputDevice.isFormatSupported(format); + ENGINE_DEBUG << "Engine::initialize checking " << format + << "input" << inputSupport + << "output" << outputSupport; + if (inputSupport && outputSupport) { + foundSupportedFormat = true; + break; + } + } + } + + if (!foundSupportedFormat) + format = QAudioFormat(); + + setFormat(format); + } + + return foundSupportedFormat; +} + +void Engine::stopRecording() +{ + if (m_audioInput) { + m_audioInput->stop(); + QCoreApplication::instance()->processEvents(); + m_audioInput->disconnect(); + } + m_audioInputIODevice = 0; + +#ifdef DUMP_AUDIO + dumpData(); +#endif +} + +void Engine::stopPlayback() +{ + if (m_audioOutput) { + m_audioOutput->stop(); + QCoreApplication::instance()->processEvents(); + m_audioOutput->disconnect(); + setPlayPosition(0); + } +} + +void Engine::setState(QAudio::State state) +{ + const bool changed = (m_state != state); + m_state = state; + if (changed) + emit stateChanged(m_mode, m_state); +} + +void Engine::setState(QAudio::Mode mode, QAudio::State state) +{ + const bool changed = (m_mode != mode || m_state != state); + m_mode = mode; + m_state = state; + if (changed) + emit stateChanged(m_mode, m_state); +} + +void Engine::setRecordPosition(qint64 position, bool forceEmit) +{ + const bool changed = (m_recordPosition != position); + m_recordPosition = position; + if (changed || forceEmit) + emit recordPositionChanged(m_recordPosition); +} + +void Engine::setPlayPosition(qint64 position, bool forceEmit) +{ + const bool changed = (m_playPosition != position); + m_playPosition = position; + if (changed || forceEmit) + emit playPositionChanged(m_playPosition); +} + +void Engine::calculateLevel(qint64 position, qint64 length) +{ +#ifdef DISABLE_LEVEL + Q_UNUSED(position) + Q_UNUSED(length) +#else + Q_ASSERT(position + length <= m_dataLength); + + qreal peakLevel = 0.0; + + qreal sum = 0.0; + const char *ptr = m_buffer.constData() + position; + const char *const end = ptr + length; + while (ptr < end) { + const qint16 value = *reinterpret_cast<const qint16*>(ptr); + const qreal fracValue = pcmToReal(value); + peakLevel = qMax(peakLevel, fracValue); + sum += fracValue * fracValue; + ptr += 2; + } + const int numSamples = length / 2; + qreal rmsLevel = sqrt(sum / numSamples); + + rmsLevel = qMax(qreal(0.0), rmsLevel); + rmsLevel = qMin(qreal(1.0), rmsLevel); + setLevel(rmsLevel, peakLevel, numSamples); + + ENGINE_DEBUG << "Engine::calculateLevel" << "pos" << position << "len" << length + << "rms" << rmsLevel << "peak" << peakLevel; +#endif +} + +void Engine::calculateSpectrum(qint64 position) +{ +#ifdef DISABLE_SPECTRUM + Q_UNUSED(position) +#else + Q_ASSERT(position + m_spectrumLengthBytes <= m_dataLength); + Q_ASSERT(0 == m_spectrumLengthBytes % 2); // constraint of FFT algorithm + + // QThread::currentThread is marked 'for internal use only', but + // we're only using it for debug output here, so it's probably OK :) + ENGINE_DEBUG << "Engine::calculateSpectrum" << QThread::currentThread() + << "count" << m_count << "pos" << position << "len" << m_spectrumLengthBytes + << "spectrumAnalyser.isReady" << m_spectrumAnalyser.isReady(); + + if(m_spectrumAnalyser.isReady()) { + m_spectrumBuffer = QByteArray::fromRawData(m_buffer.constData() + position, + m_spectrumLengthBytes); + m_spectrumPosition = position; + m_spectrumAnalyser.calculate(m_spectrumBuffer, m_format); + } +#endif +} + +void Engine::setFormat(const QAudioFormat &format) +{ + const bool changed = (format != m_format); + m_format = format; + if (changed) + emit formatChanged(m_format); +} + +void Engine::setLevel(qreal rmsLevel, qreal peakLevel, int numSamples) +{ + m_rmsLevel = rmsLevel; + m_peakLevel = peakLevel; + emit levelChanged(m_rmsLevel, m_peakLevel, numSamples); +} + +#ifdef DUMP_DATA +void Engine::createOutputDir() +{ + m_outputDir.setPath("output"); + + // Ensure output directory exists and is empty + if (m_outputDir.exists()) { + const QStringList files = m_outputDir.entryList(QDir::Files); + QString file; + foreach (file, files) + m_outputDir.remove(file); + } else { + QDir::current().mkdir("output"); + } +} +#endif // DUMP_DATA + +#ifdef DUMP_AUDIO +void Engine::dumpData() +{ + const QString txtFileName = m_outputDir.filePath("data.txt"); + QFile txtFile(txtFileName); + txtFile.open(QFile::WriteOnly | QFile::Text); + QTextStream stream(&txtFile); + const qint16 *ptr = reinterpret_cast<const qint16*>(m_buffer.constData()); + const int numSamples = m_dataLength / (2 * m_format.channels()); + for (int i=0; i<numSamples; ++i) { + stream << i << "\t" << *ptr << "\n"; + ptr += m_format.channels(); + } + + const QString pcmFileName = m_outputDir.filePath("data.pcm"); + QFile pcmFile(pcmFileName); + pcmFile.open(QFile::WriteOnly); + pcmFile.write(m_buffer.constData(), m_dataLength); +} +#endif // DUMP_AUDIO diff --git a/demos/spectrum/app/engine.h b/demos/spectrum/app/engine.h new file mode 100644 index 0000000..16088b2 --- /dev/null +++ b/demos/spectrum/app/engine.h @@ -0,0 +1,311 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ +** +*****************************************************************************/ + +#ifndef ENGINE_H +#define ENGINE_H + +#include "spectrum.h" +#include "spectrumanalyser.h" +#include "wavfile.h" + +#include <QObject> +#include <QByteArray> +#include <QBuffer> +#include <QVector> +#include <QtMultimedia/QAudioDeviceInfo> +#include <QtMultimedia/QAudioFormat> + +#ifdef DUMP_CAPTURED_AUDIO +#define DUMP_DATA +#endif + +#ifdef DUMP_SPECTRUM +#define DUMP_DATA +#endif + +#ifdef DUMP_DATA +#include <QDir> +#endif + +class QAudioInput; +class QAudioOutput; +class FrequencySpectrum; +class QFile; + +/** + * This class interfaces with the QtMultimedia audio classes, and also with + * the SpectrumAnalyser class. Its role is to manage the capture and playback + * of audio data, meanwhile performing real-time analysis of the audio level + * and frequency spectrum. + */ +class Engine : public QObject { + Q_OBJECT +public: + Engine(QObject *parent = 0); + ~Engine(); + + const QList<QAudioDeviceInfo>& availableAudioInputDevices() const + { return m_availableAudioInputDevices; } + + const QList<QAudioDeviceInfo>& availableAudioOutputDevices() const + { return m_availableAudioOutputDevices; } + + QAudio::Mode mode() const { return m_mode; } + QAudio::State state() const { return m_state; } + + /** + * \return Reference to internal audio buffer + * \note This reference is valid for the lifetime of the Engine + */ + const QByteArray& buffer() const { return m_buffer; } + + /** + * \return Current audio format + * \note May be QAudioFormat() if engine is not initialized + */ + const QAudioFormat& format() const { return m_format; } + + /** + * Stop any ongoing recording or playback, and reset to ground state. + */ + void reset(); + + /** + * Load data from WAV file + */ + bool loadFile(const QString &fileName); + + /** + * Generate tone + */ + bool generateTone(const Tone &tone); + + /** + * Generate tone + */ + bool generateSweptTone(qreal amplitude); + + /** + * Initialize for recording + */ + bool initializeRecord(); + + /** + * Position of the audio input device. + * \return Position in microseconds. + */ + qint64 recordPosition() const { return m_recordPosition; } + + /** + * RMS level of the most recently processed set of audio samples. + * \return Level in range (0.0, 1.0) + */ + qreal rmsLevel() const { return m_rmsLevel; } + + /** + * Peak level of the most recently processed set of audio samples. + * \return Level in range (0.0, 1.0) + */ + qreal peakLevel() const { return m_peakLevel; } + + /** + * Position of the audio output device. + * \return Position in microseconds. + */ + qint64 playPosition() const { return m_playPosition; } + + /** + * Length of the internal engine buffer. + * \return Buffer length in microseconds. + */ + qint64 bufferDuration() const; + + /** + * Amount of data held in the buffer. + * \return Data duration in microseconds. + */ + qint64 dataDuration() const; + + /** + * Returns the size of the underlying audio buffer in bytes. + * This should be an approximation of the capture latency. + */ + qint64 audioBufferLength() const; + + /** + * Set window function applied to audio data before spectral analysis. + */ + void setWindowFunction(WindowFunction type); + +public slots: + void startRecording(); + void startPlayback(); + void suspend(); + void setAudioInputDevice(const QAudioDeviceInfo &device); + void setAudioOutputDevice(const QAudioDeviceInfo &device); + +signals: + void stateChanged(QAudio::Mode mode, QAudio::State state); + + /** + * Informational message for non-modal display + */ + void infoMessage(const QString &message, int durationMs); + + /** + * Error message for modal display + */ + void errorMessage(const QString &heading, const QString &detail); + + /** + * Format of audio data has changed + */ + void formatChanged(const QAudioFormat &format); + + /** + * Length of buffer has changed. + * \param duration Duration in microseconds + */ + void bufferDurationChanged(qint64 duration); + + /** + * Amount of data in buffer has changed. + * \param duration Duration of data in microseconds + */ + void dataDurationChanged(qint64 duration); + + /** + * Position of the audio input device has changed. + * \param position Position in microseconds + */ + void recordPositionChanged(qint64 position); + + /** + * Position of the audio output device has changed. + * \param position Position in microseconds + */ + void playPositionChanged(qint64 position); + + /** + * Level changed + * \param rmsLevel RMS level in range 0.0 - 1.0 + * \param peakLevel Peak level in range 0.0 - 1.0 + * \param numSamples Number of audio samples analysed + */ + void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples); + + /** + * Spectrum has changed. + * \param position Position of start of window in microseconds + * \param length Length of window in microseconds + * \param spectrum Resulting frequency spectrum + */ + void spectrumChanged(qint64 position, qint64 length, const FrequencySpectrum &spectrum); + +private slots: + void audioNotify(); + void audioStateChanged(QAudio::State state); + void audioDataReady(); + void spectrumChanged(const FrequencySpectrum &spectrum); + +private: + bool initialize(); + bool selectFormat(); + void stopRecording(); + void stopPlayback(); + void setState(QAudio::State state); + void setState(QAudio::Mode mode, QAudio::State state); + void setFormat(const QAudioFormat &format); + void setRecordPosition(qint64 position, bool forceEmit = false); + void setPlayPosition(qint64 position, bool forceEmit = false); + void calculateLevel(qint64 position, qint64 length); + void calculateSpectrum(qint64 position); + void setLevel(qreal rmsLevel, qreal peakLevel, int numSamples); + +#ifdef DUMP_DATA + void createOutputDir(); + QString outputPath() const { return m_outputDir.path(); } +#endif + +#ifdef DUMP_CAPTURED_AUDIO + void dumpData(); +#endif + +private: + QAudio::Mode m_mode; + QAudio::State m_state; + + bool m_generateTone; + SweptTone m_tone; + + QFile* m_file; + WavFile m_wavFile; + + QAudioFormat m_format; + + const QList<QAudioDeviceInfo> m_availableAudioInputDevices; + QAudioDeviceInfo m_audioInputDevice; + QAudioInput* m_audioInput; + QIODevice* m_audioInputIODevice; + qint64 m_recordPosition; + + const QList<QAudioDeviceInfo> m_availableAudioOutputDevices; + QAudioDeviceInfo m_audioOutputDevice; + QAudioOutput* m_audioOutput; + qint64 m_playPosition; + QBuffer m_audioOutputIODevice; + + QByteArray m_buffer; + qint64 m_dataLength; + + qreal m_rmsLevel; + qreal m_peakLevel; + + int m_spectrumLengthBytes; + QByteArray m_spectrumBuffer; + SpectrumAnalyser m_spectrumAnalyser; + qint64 m_spectrumPosition; + + int m_count; + +#ifdef DUMP_DATA + QDir m_outputDir; +#endif + +}; + +#endif // ENGINE_H diff --git a/demos/spectrum/app/frequencyspectrum.cpp b/demos/spectrum/app/frequencyspectrum.cpp new file mode 100644 index 0000000..6ab80c2 --- /dev/null +++ b/demos/spectrum/app/frequencyspectrum.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 "frequencyspectrum.h" + +FrequencySpectrum::FrequencySpectrum(int numPoints) + : m_elements(numPoints) +{ + +} + +void FrequencySpectrum::reset() +{ + iterator i = begin(); + for ( ; i != end(); ++i) + *i = Element(); +} + +int FrequencySpectrum::count() const +{ + return m_elements.count(); +} + +FrequencySpectrum::Element& FrequencySpectrum::operator[](int index) +{ + return m_elements[index]; +} + +const FrequencySpectrum::Element& FrequencySpectrum::operator[](int index) const +{ + return m_elements[index]; +} + +FrequencySpectrum::iterator FrequencySpectrum::begin() +{ + return m_elements.begin(); +} + +FrequencySpectrum::iterator FrequencySpectrum::end() +{ + return m_elements.end(); +} + +FrequencySpectrum::const_iterator FrequencySpectrum::begin() const +{ + return m_elements.begin(); +} + +FrequencySpectrum::const_iterator FrequencySpectrum::end() const +{ + return m_elements.end(); +} diff --git a/demos/spectrum/app/frequencyspectrum.h b/demos/spectrum/app/frequencyspectrum.h new file mode 100644 index 0000000..0dd814e --- /dev/null +++ b/demos/spectrum/app/frequencyspectrum.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ +** +*****************************************************************************/ + +#ifndef FREQUENCYSPECTRUM_H +#define FREQUENCYSPECTRUM_H + +#include <QtCore/QVector> + +/** + * Represents a frequency spectrum as a series of elements, each of which + * consists of a frequency, an amplitude and a phase. + */ +class FrequencySpectrum { +public: + FrequencySpectrum(int numPoints = 0); + + struct Element { + Element() + : frequency(0.0), amplitude(0.0), phase(0.0), clipped(false) + { } + + /** + * Frequency in Hertz + */ + qreal frequency; + + /** + * Amplitude in range [0.0, 1.0] + */ + qreal amplitude; + + /** + * Phase in range [0.0, 2*PI] + */ + qreal phase; + + /** + * Indicates whether value has been clipped during spectrum analysis + */ + bool clipped; + }; + + typedef QVector<Element>::iterator iterator; + typedef QVector<Element>::const_iterator const_iterator; + + void reset(); + + int count() const; + Element& operator[](int index); + const Element& operator[](int index) const; + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + +private: + QVector<Element> m_elements; + +}; + +#endif // FREQUENCYSPECTRUM_H diff --git a/demos/spectrum/app/images/record.png b/demos/spectrum/app/images/record.png Binary files differnew file mode 100644 index 0000000..e7493aa --- /dev/null +++ b/demos/spectrum/app/images/record.png diff --git a/demos/spectrum/app/images/settings.png b/demos/spectrum/app/images/settings.png Binary files differnew file mode 100644 index 0000000..12179dc --- /dev/null +++ b/demos/spectrum/app/images/settings.png diff --git a/demos/spectrum/app/levelmeter.cpp b/demos/spectrum/app/levelmeter.cpp new file mode 100644 index 0000000..39e43c9 --- /dev/null +++ b/demos/spectrum/app/levelmeter.cpp @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 "levelmeter.h" + +#include <math.h> + +#include <QPainter> +#include <QTimer> +#include <QDebug> + + +// Constants +const int RedrawInterval = 100; // ms +const qreal PeakDecayRate = 0.001; +const int PeakHoldLevelDuration = 2000; // ms + + +LevelMeter::LevelMeter(QWidget *parent) + : QWidget(parent) + , m_rmsLevel(0.0) + , m_peakLevel(0.0) + , m_decayedPeakLevel(0.0) + , m_peakDecayRate(PeakDecayRate) + , m_peakHoldLevel(0.0) + , m_redrawTimer(new QTimer(this)) + , m_rmsColor(Qt::red) + , m_peakColor(255, 200, 200, 255) +{ + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + setMinimumWidth(30); + + connect(m_redrawTimer, SIGNAL(timeout()), this, SLOT(redrawTimerExpired())); + m_redrawTimer->start(RedrawInterval); +} + +LevelMeter::~LevelMeter() +{ + +} + +void LevelMeter::reset() +{ + m_rmsLevel = 0.0; + m_peakLevel = 0.0; + update(); +} + +void LevelMeter::levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples) +{ + // Smooth the RMS signal + const qreal smooth = pow(qreal(0.9), static_cast<qreal>(numSamples) / 256); // TODO: remove this magic number + m_rmsLevel = (m_rmsLevel * smooth) + (rmsLevel * (1.0 - smooth)); + + if (peakLevel > m_decayedPeakLevel) { + m_peakLevel = peakLevel; + m_decayedPeakLevel = peakLevel; + m_peakLevelChanged.start(); + } + + if (peakLevel > m_peakHoldLevel) { + m_peakHoldLevel = peakLevel; + m_peakHoldLevelChanged.start(); + } + + update(); +} + +void LevelMeter::redrawTimerExpired() +{ + // Decay the peak signal + const int elapsedMs = m_peakLevelChanged.elapsed(); + const qreal decayAmount = m_peakDecayRate * elapsedMs; + if (decayAmount < m_peakLevel) + m_decayedPeakLevel = m_peakLevel - decayAmount; + else + m_decayedPeakLevel = 0.0; + + // Check whether to clear the peak hold level + if (m_peakHoldLevelChanged.elapsed() > PeakHoldLevelDuration) + m_peakHoldLevel = 0.0; + + update(); +} + +void LevelMeter::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event) + + QPainter painter(this); + painter.fillRect(rect(), Qt::black); + + QRect bar = rect(); + + bar.setTop(rect().top() + (1.0 - m_peakHoldLevel) * rect().height()); + bar.setBottom(bar.top() + 5); + painter.fillRect(bar, m_rmsColor); + bar.setBottom(rect().bottom()); + + bar.setTop(rect().top() + (1.0 - m_decayedPeakLevel) * rect().height()); + painter.fillRect(bar, m_peakColor); + + bar.setTop(rect().top() + (1.0 - m_rmsLevel) * rect().height()); + painter.fillRect(bar, m_rmsColor); +} diff --git a/demos/spectrum/app/levelmeter.h b/demos/spectrum/app/levelmeter.h new file mode 100644 index 0000000..ab8340b --- /dev/null +++ b/demos/spectrum/app/levelmeter.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ +** +*****************************************************************************/ + +#ifndef LEVELMETER_H +#define LEVELMETER_H + +#include <QTime> +#include <QWidget> + +/** + * Widget which displays a vertical audio level meter, indicating the + * RMS and peak levels of the window of audio samples most recently analysed + * by the Engine. + */ +class LevelMeter : public QWidget { + Q_OBJECT +public: + LevelMeter(QWidget *parent = 0); + ~LevelMeter(); + + void paintEvent(QPaintEvent *event); + +public slots: + void reset(); + void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples); + +private slots: + void redrawTimerExpired(); + +private: + /** + * Height of RMS level bar. + * Range 0.0 - 1.0. + */ + qreal m_rmsLevel; + + /** + * Most recent peak level. + * Range 0.0 - 1.0. + */ + qreal m_peakLevel; + + /** + * Height of peak level bar. + * This is calculated by decaying m_peakLevel depending on the + * elapsed time since m_peakLevelChanged, and the value of m_decayRate. + */ + qreal m_decayedPeakLevel; + + /** + * Time at which m_peakLevel was last changed. + */ + QTime m_peakLevelChanged; + + /** + * Rate at which peak level bar decays. + * Expressed in level units / millisecond. + */ + qreal m_peakDecayRate; + + /** + * High watermark of peak level. + * Range 0.0 - 1.0. + */ + qreal m_peakHoldLevel; + + /** + * Time at which m_peakHoldLevel was last changed. + */ + QTime m_peakHoldLevelChanged; + + QTimer *m_redrawTimer; + + QColor m_rmsColor; + QColor m_peakColor; + +}; + +#endif // LEVELMETER_H diff --git a/tests/auto/qdbusserver/server.cpp b/demos/spectrum/app/main.cpp index d4422f0..6e2b6fc 100644 --- a/tests/auto/qdbusserver/server.cpp +++ b/demos/spectrum/app/main.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the test suite of the Qt Toolkit. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,12 +38,21 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include <QtCore/QtCore> -#include <QtDBus/QtDBus> -int main(int argc, char *argv[]) +#include <QtGui/QApplication> +#include "mainwidget.h" + +int main(int argc, char **argv) { - QCoreApplication app(argc, argv); - QDBusServer server("unix:path=/tmp/qdbus-test"); + QApplication app(argc, argv); + app.setApplicationName("QtMultimedia spectrum analyser"); + MainWidget w; + +#ifdef Q_OS_SYMBIAN + w.showMaximized(); +#else + w.show(); +#endif + return app.exec(); } diff --git a/demos/spectrum/app/mainwidget.cpp b/demos/spectrum/app/mainwidget.cpp new file mode 100644 index 0000000..3b7c306 --- /dev/null +++ b/demos/spectrum/app/mainwidget.cpp @@ -0,0 +1,455 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 "engine.h" +#include "levelmeter.h" +#include "mainwidget.h" +#include "waveform.h" +#include "progressbar.h" +#include "settingsdialog.h" +#include "spectrograph.h" +#include "tonegeneratordialog.h" +#include "utils.h" + +#include <QLabel> +#include <QPushButton> +#include <QHBoxLayout> +#include <QVBoxLayout> +#include <QStyle> +#include <QMenu> +#include <QFileDialog> +#include <QTimerEvent> +#include <QMessageBox> + +const int NullTimerId = -1; + +MainWidget::MainWidget(QWidget *parent) + : QWidget(parent) + , m_mode(NoMode) + , m_engine(new Engine(this)) +#ifndef DISABLE_WAVEFORM + , m_waveform(new Waveform(m_engine->buffer(), this)) +#endif + , m_progressBar(new ProgressBar(this)) + , m_spectrograph(new Spectrograph(this)) + , m_levelMeter(new LevelMeter(this)) + , m_modeButton(new QPushButton(this)) + , m_recordButton(new QPushButton(this)) + , m_pauseButton(new QPushButton(this)) + , m_playButton(new QPushButton(this)) + , m_settingsButton(new QPushButton(this)) + , m_infoMessage(new QLabel(tr("Select a mode to begin"), this)) + , m_infoMessageTimerId(NullTimerId) + , m_settingsDialog(new SettingsDialog( + m_engine->availableAudioInputDevices(), + m_engine->availableAudioOutputDevices(), + this)) + , m_toneGeneratorDialog(new ToneGeneratorDialog(this)) + , m_modeMenu(new QMenu(this)) + , m_loadFileAction(0) + , m_generateToneAction(0) + , m_recordAction(0) +{ + m_spectrograph->setParams(SpectrumNumBands, SpectrumLowFreq, SpectrumHighFreq); + + createUi(); + connectUi(); +} + +MainWidget::~MainWidget() +{ + +} + + +//----------------------------------------------------------------------------- +// Public slots +//----------------------------------------------------------------------------- + +void MainWidget::stateChanged(QAudio::Mode mode, QAudio::State state) +{ + Q_UNUSED(mode); + + updateButtonStates(); + + if (QAudio::ActiveState != state && QAudio::SuspendedState != state) { + m_levelMeter->reset(); + m_spectrograph->reset(); + } +} + +void MainWidget::formatChanged(const QAudioFormat &format) +{ + infoMessage(formatToString(format), NullMessageTimeout); + +#ifndef DISABLE_WAVEFORM + if (QAudioFormat() != format) { + m_waveform->initialize(format, WaveformTileLength, + WaveformWindowDuration); + } +#endif +} + +void MainWidget::spectrumChanged(qint64 position, qint64 length, + const FrequencySpectrum &spectrum) +{ + m_progressBar->windowChanged(position, length); + m_spectrograph->spectrumChanged(spectrum); +} + +void MainWidget::infoMessage(const QString &message, int timeoutMs) +{ + m_infoMessage->setText(message); + + if (NullTimerId != m_infoMessageTimerId) { + killTimer(m_infoMessageTimerId); + m_infoMessageTimerId = NullTimerId; + } + + if (NullMessageTimeout != timeoutMs) + m_infoMessageTimerId = startTimer(timeoutMs); +} + +void MainWidget::errorMessage(const QString &heading, const QString &detail) +{ +#ifdef Q_OS_SYMBIAN + const QString message = heading + "\n" + detail; + QMessageBox::warning(this, "", message, QMessageBox::Close); +#else + QMessageBox::warning(this, heading, detail, QMessageBox::Close); +#endif +} + +void MainWidget::timerEvent(QTimerEvent *event) +{ + Q_ASSERT(event->timerId() == m_infoMessageTimerId); + Q_UNUSED(event) // suppress warnings in release builds + killTimer(m_infoMessageTimerId); + m_infoMessageTimerId = NullTimerId; + m_infoMessage->setText(""); +} + +void MainWidget::positionChanged(qint64 positionUs) +{ +#ifndef DISABLE_WAVEFORM + qint64 positionBytes = audioLength(m_engine->format(), positionUs); + m_waveform->positionChanged(positionBytes); +#else + Q_UNUSED(positionUs) +#endif +} + +void MainWidget::bufferDurationChanged(qint64 durationUs) +{ + m_progressBar->bufferDurationChanged(durationUs); +} + + +//----------------------------------------------------------------------------- +// Private slots +//----------------------------------------------------------------------------- + +void MainWidget::dataDurationChanged(qint64 duration) +{ +#ifndef DISABLE_WAVEFORM + const qint64 dataLength = audioLength(m_engine->format(), duration); + m_waveform->dataLengthChanged(dataLength); +#else + Q_UNUSED(duration) +#endif + + updateButtonStates(); +} + +void MainWidget::showFileDialog() +{ + reset(); + const QString dir; + const QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open WAV file"), dir, "*.wav"); + if (fileNames.count()) { + setMode(LoadFileMode); + m_engine->loadFile(fileNames.front()); + updateButtonStates(); + } +} + +void MainWidget::showSettingsDialog() +{ + reset(); + m_settingsDialog->exec(); + if (m_settingsDialog->result() == QDialog::Accepted) { + m_engine->setAudioInputDevice(m_settingsDialog->inputDevice()); + m_engine->setAudioOutputDevice(m_settingsDialog->outputDevice()); + m_engine->setWindowFunction(m_settingsDialog->windowFunction()); + } +} + +void MainWidget::showToneGeneratorDialog() +{ + reset(); + m_toneGeneratorDialog->exec(); + if (m_toneGeneratorDialog->result() == QDialog::Accepted) { + setMode(GenerateToneMode); + const qreal amplitude = m_toneGeneratorDialog->amplitude(); + if (m_toneGeneratorDialog->isFrequencySweepEnabled()) { + m_engine->generateSweptTone(amplitude); + } else { + const qreal frequency = m_toneGeneratorDialog->frequency(); + const Tone tone(frequency, amplitude); + m_engine->generateTone(tone); + updateButtonStates(); + } + } +} + +void MainWidget::initializeRecord() +{ + reset(); + setMode(RecordMode); + if (m_engine->initializeRecord()) + updateButtonStates(); +} + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void MainWidget::createUi() +{ + createMenus(); + + setWindowTitle(tr("Spectrum Analyser")); + + QVBoxLayout *windowLayout = new QVBoxLayout(this); + + m_infoMessage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + m_infoMessage->setAlignment(Qt::AlignHCenter); + windowLayout->addWidget(m_infoMessage); + +#ifdef SUPERIMPOSE_PROGRESS_ON_WAVEFORM + QScopedPointer<QHBoxLayout> waveformLayout(new QHBoxLayout); + waveformLayout->addWidget(m_progressBar); + m_progressBar->setMinimumHeight(m_waveform->minimumHeight()); + waveformLayout->setMargin(0); + m_waveform->setLayout(waveformLayout.data()); + waveformLayout.take(); + windowLayout->addWidget(m_waveform); +#else +#ifndef DISABLE_WAVEFORM + windowLayout->addWidget(m_waveform); +#endif // DISABLE_WAVEFORM + windowLayout->addWidget(m_progressBar); +#endif // SUPERIMPOSE_PROGRESS_ON_WAVEFORM + + // Spectrograph and level meter + + QScopedPointer<QHBoxLayout> analysisLayout(new QHBoxLayout); + analysisLayout->addWidget(m_spectrograph); + analysisLayout->addWidget(m_levelMeter); + windowLayout->addLayout(analysisLayout.data()); + analysisLayout.take(); + + // Button panel + + const QSize buttonSize(30, 30); + + m_modeButton->setText(tr("Mode")); + + m_recordIcon = QIcon(":/images/record.png"); + m_recordButton->setIcon(m_recordIcon); + m_recordButton->setEnabled(false); + m_recordButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_recordButton->setMinimumSize(buttonSize); + + m_pauseIcon = style()->standardIcon(QStyle::SP_MediaPause); + m_pauseButton->setIcon(m_pauseIcon); + m_pauseButton->setEnabled(false); + m_pauseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_pauseButton->setMinimumSize(buttonSize); + + m_playIcon = style()->standardIcon(QStyle::SP_MediaPlay); + m_playButton->setIcon(m_playIcon); + m_playButton->setEnabled(false); + m_playButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_playButton->setMinimumSize(buttonSize); + + m_settingsIcon = QIcon(":/images/settings.png"); + m_settingsButton->setIcon(m_settingsIcon); + m_settingsButton->setEnabled(true); + m_settingsButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_settingsButton->setMinimumSize(buttonSize); + + QScopedPointer<QHBoxLayout> buttonPanelLayout(new QHBoxLayout); + buttonPanelLayout->addStretch(); + buttonPanelLayout->addWidget(m_modeButton); + buttonPanelLayout->addWidget(m_recordButton); + buttonPanelLayout->addWidget(m_pauseButton); + buttonPanelLayout->addWidget(m_playButton); + buttonPanelLayout->addWidget(m_settingsButton); + + QWidget *buttonPanel = new QWidget(this); + buttonPanel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + buttonPanel->setLayout(buttonPanelLayout.data()); + buttonPanelLayout.take(); // ownership transferred to buttonPanel + + QScopedPointer<QHBoxLayout> bottomPaneLayout(new QHBoxLayout); + bottomPaneLayout->addWidget(buttonPanel); + windowLayout->addLayout(bottomPaneLayout.data()); + bottomPaneLayout.take(); // ownership transferred to windowLayout + + // Apply layout + + setLayout(windowLayout); +} + +void MainWidget::connectUi() +{ + CHECKED_CONNECT(m_recordButton, SIGNAL(clicked()), + m_engine, SLOT(startRecording())); + + CHECKED_CONNECT(m_pauseButton, SIGNAL(clicked()), + m_engine, SLOT(suspend())); + + CHECKED_CONNECT(m_playButton, SIGNAL(clicked()), + m_engine, SLOT(startPlayback())); + + CHECKED_CONNECT(m_settingsButton, SIGNAL(clicked()), + this, SLOT(showSettingsDialog())); + + CHECKED_CONNECT(m_engine, SIGNAL(stateChanged(QAudio::Mode,QAudio::State)), + this, SLOT(stateChanged(QAudio::Mode,QAudio::State))); + + CHECKED_CONNECT(m_engine, SIGNAL(formatChanged(const QAudioFormat &)), + this, SLOT(formatChanged(const QAudioFormat &))); + + m_progressBar->bufferDurationChanged(m_engine->bufferDuration()); + + CHECKED_CONNECT(m_engine, SIGNAL(bufferDurationChanged(qint64)), + this, SLOT(bufferDurationChanged(qint64))); + + CHECKED_CONNECT(m_engine, SIGNAL(dataDurationChanged(qint64)), + this, SLOT(dataDurationChanged(qint64))); + + CHECKED_CONNECT(m_engine, SIGNAL(recordPositionChanged(qint64)), + m_progressBar, SLOT(recordPositionChanged(qint64))); + + CHECKED_CONNECT(m_engine, SIGNAL(playPositionChanged(qint64)), + m_progressBar, SLOT(playPositionChanged(qint64))); + + CHECKED_CONNECT(m_engine, SIGNAL(recordPositionChanged(qint64)), + this, SLOT(positionChanged(qint64))); + + CHECKED_CONNECT(m_engine, SIGNAL(playPositionChanged(qint64)), + this, SLOT(positionChanged(qint64))); + + CHECKED_CONNECT(m_engine, SIGNAL(levelChanged(qreal, qreal, int)), + m_levelMeter, SLOT(levelChanged(qreal, qreal, int))); + + CHECKED_CONNECT(m_engine, SIGNAL(spectrumChanged(qint64, qint64, const FrequencySpectrum &)), + this, SLOT(spectrumChanged(qint64, qint64, const FrequencySpectrum &))); + + CHECKED_CONNECT(m_engine, SIGNAL(infoMessage(QString, int)), + this, SLOT(infoMessage(QString, int))); + + CHECKED_CONNECT(m_engine, SIGNAL(errorMessage(QString, QString)), + this, SLOT(errorMessage(QString, QString))); + + CHECKED_CONNECT(m_spectrograph, SIGNAL(infoMessage(QString, int)), + this, SLOT(infoMessage(QString, int))); +} + +void MainWidget::createMenus() +{ + m_modeButton->setMenu(m_modeMenu); + + m_generateToneAction = m_modeMenu->addAction(tr("Play generated tone")); + m_recordAction = m_modeMenu->addAction(tr("Record and play back")); + m_loadFileAction = m_modeMenu->addAction(tr("Play file")); + + m_loadFileAction->setCheckable(true); + m_generateToneAction->setCheckable(true); + m_recordAction->setCheckable(true); + + connect(m_loadFileAction, SIGNAL(triggered(bool)), this, SLOT(showFileDialog())); + connect(m_generateToneAction, SIGNAL(triggered(bool)), this, SLOT(showToneGeneratorDialog())); + connect(m_recordAction, SIGNAL(triggered(bool)), this, SLOT(initializeRecord())); +} + +void MainWidget::updateButtonStates() +{ + const bool recordEnabled = ((QAudio::AudioOutput == m_engine->mode() || + (QAudio::ActiveState != m_engine->state() && + QAudio::IdleState != m_engine->state())) && + RecordMode == m_mode); + m_recordButton->setEnabled(recordEnabled); + + const bool pauseEnabled = (QAudio::ActiveState == m_engine->state() || + QAudio::IdleState == m_engine->state()); + m_pauseButton->setEnabled(pauseEnabled); + + const bool playEnabled = (m_engine->dataDuration() && + (QAudio::AudioOutput != m_engine->mode() || + (QAudio::ActiveState != m_engine->state() && + QAudio::IdleState != m_engine->state()))); + m_playButton->setEnabled(playEnabled); +} + +void MainWidget::reset() +{ +#ifndef DISABLE_WAVEFORM + m_waveform->reset(); +#endif + m_engine->reset(); + m_levelMeter->reset(); + m_spectrograph->reset(); + m_progressBar->reset(); +} + +void MainWidget::setMode(Mode mode) +{ + + m_mode = mode; + m_loadFileAction->setChecked(LoadFileMode == mode); + m_generateToneAction->setChecked(GenerateToneMode == mode); + m_recordAction->setChecked(RecordMode == mode); +} + diff --git a/demos/spectrum/app/mainwidget.h b/demos/spectrum/app/mainwidget.h new file mode 100644 index 0000000..846b97a --- /dev/null +++ b/demos/spectrum/app/mainwidget.h @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ +** +*****************************************************************************/ + +#ifndef MAINWIDGET_H +#define MAINWIDGET_H + +#include <QWidget> +#include <QIcon> +#include <QtMultimedia/qaudio.h> + +class Engine; +class FrequencySpectrum; +class ProgressBar; +class Spectrograph; +class Waveform; +class LevelMeter; +class SettingsDialog; +class ToneGeneratorDialog; +class QAudioFormat; +class QLabel; +class QPushButton; +class QMenu; +class QAction; + +/** + * Main application widget, responsible for connecting the various UI + * elements to the Engine. + */ +class MainWidget : public QWidget { + Q_OBJECT +public: + MainWidget(QWidget *parent = 0); + ~MainWidget(); + + // QObject + void timerEvent(QTimerEvent *event); + +public slots: + void stateChanged(QAudio::Mode mode, QAudio::State state); + void formatChanged(const QAudioFormat &format); + void spectrumChanged(qint64 position, qint64 length, + const FrequencySpectrum &spectrum); + void infoMessage(const QString &message, int timeoutMs); + void errorMessage(const QString &heading, const QString &detail); + void positionChanged(qint64 position); + void bufferDurationChanged(qint64 duration); + +private slots: + void showFileDialog(); + void showSettingsDialog(); + void showToneGeneratorDialog(); + void initializeRecord(); + void dataDurationChanged(qint64 duration); + +private: + void createUi(); + void createMenus(); + void connectUi(); + void updateButtonStates(); + void reset(); + + enum Mode { + NoMode, + RecordMode, + GenerateToneMode, + LoadFileMode + }; + + void setMode(Mode mode); + +private: + Mode m_mode; + + Engine* m_engine; + + Waveform* m_waveform; + ProgressBar* m_progressBar; + Spectrograph* m_spectrograph; + LevelMeter* m_levelMeter; + + QPushButton* m_modeButton; + QPushButton* m_recordButton; + QIcon m_recordIcon; + QPushButton* m_pauseButton; + QIcon m_pauseIcon; + QPushButton* m_playButton; + QIcon m_playIcon; + QPushButton* m_settingsButton; + QIcon m_settingsIcon; + + QLabel* m_infoMessage; + int m_infoMessageTimerId; + + SettingsDialog* m_settingsDialog; + ToneGeneratorDialog* m_toneGeneratorDialog; + + QMenu* m_modeMenu; + QAction* m_loadFileAction; + QAction* m_generateToneAction; + QAction* m_recordAction; + +}; + +#endif // MAINWIDGET_H diff --git a/demos/spectrum/app/progressbar.cpp b/demos/spectrum/app/progressbar.cpp new file mode 100644 index 0000000..256acf0 --- /dev/null +++ b/demos/spectrum/app/progressbar.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 "progressbar.h" +#include "spectrum.h" +#include <QPainter> + +ProgressBar::ProgressBar(QWidget *parent) + : QWidget(parent) + , m_bufferDuration(0) + , m_recordPosition(0) + , m_playPosition(0) + , m_windowPosition(0) + , m_windowLength(0) +{ + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + setMinimumHeight(30); +#ifdef SUPERIMPOSE_PROGRESS_ON_WAVEFORM + setAutoFillBackground(false); +#endif +} + +ProgressBar::~ProgressBar() +{ + +} + +void ProgressBar::reset() +{ + m_bufferDuration = 0; + m_recordPosition = 0; + m_playPosition = 0; + m_windowPosition = 0; + m_windowLength = 0; + update(); +} + +void ProgressBar::paintEvent(QPaintEvent * /*event*/) +{ + QPainter painter(this); + + QColor bufferColor(0, 0, 255); + QColor windowColor(0, 255, 0); + +#ifdef SUPERIMPOSE_PROGRESS_ON_WAVEFORM + bufferColor.setAlphaF(0.5); + windowColor.setAlphaF(0.5); +#else + painter.fillRect(rect(), Qt::black); +#endif + + if (m_bufferDuration) { + QRect bar = rect(); + const qreal play = qreal(m_playPosition) / m_bufferDuration; + bar.setLeft(rect().left() + play * rect().width()); + const qreal record = qreal(m_recordPosition) / m_bufferDuration; + bar.setRight(rect().left() + record * rect().width()); + painter.fillRect(bar, bufferColor); + + QRect window = rect(); + const qreal windowLeft = qreal(m_windowPosition) / m_bufferDuration; + window.setLeft(rect().left() + windowLeft * rect().width()); + const qreal windowWidth = qreal(m_windowLength) / m_bufferDuration; + window.setWidth(windowWidth * rect().width()); + painter.fillRect(window, windowColor); + } +} + +void ProgressBar::bufferDurationChanged(qint64 bufferSize) +{ + m_bufferDuration = bufferSize; + m_recordPosition = 0; + m_playPosition = 0; + m_windowPosition = 0; + m_windowLength = 0; + repaint(); +} + +void ProgressBar::recordPositionChanged(qint64 recordPosition) +{ + Q_ASSERT(recordPosition >= 0); + Q_ASSERT(recordPosition <= m_bufferDuration); + m_recordPosition = recordPosition; + repaint(); +} + +void ProgressBar::playPositionChanged(qint64 playPosition) +{ + Q_ASSERT(playPosition >= 0); + Q_ASSERT(playPosition <= m_bufferDuration); + m_playPosition = playPosition; + repaint(); +} + +void ProgressBar::windowChanged(qint64 position, qint64 length) +{ + Q_ASSERT(position >= 0); + Q_ASSERT(position <= m_bufferDuration); + Q_ASSERT(position + length <= m_bufferDuration); + m_windowPosition = position; + m_windowLength = length; + repaint(); +} diff --git a/demos/spectrum/app/progressbar.h b/demos/spectrum/app/progressbar.h new file mode 100644 index 0000000..de9e5a9 --- /dev/null +++ b/demos/spectrum/app/progressbar.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ +** +*****************************************************************************/ + +#ifndef PROGRESSBAR_H +#define PROGRESSBAR_H + +#include <QWidget> + +/** + * Widget which displays a the current fill state of the Engine's internal + * buffer, and the current play/record position within that buffer. + */ +class ProgressBar : public QWidget { + Q_OBJECT +public: + ProgressBar(QWidget *parent = 0); + ~ProgressBar(); + + void reset(); + void paintEvent(QPaintEvent *event); + +public slots: + void bufferDurationChanged(qint64 bufferSize); + void recordPositionChanged(qint64 recordPosition); + void playPositionChanged(qint64 playPosition); + void windowChanged(qint64 position, qint64 length); + +private: + qint64 m_bufferDuration; + qint64 m_recordPosition; + qint64 m_playPosition; + qint64 m_windowPosition; + qint64 m_windowLength; + +}; + +#endif // PROGRESSBAR_H diff --git a/demos/spectrum/app/settingsdialog.cpp b/demos/spectrum/app/settingsdialog.cpp new file mode 100644 index 0000000..204b43f --- /dev/null +++ b/demos/spectrum/app/settingsdialog.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 "settingsdialog.h" +#include <QComboBox> +#include <QDialogButtonBox> +#include <QLabel> +#include <QPushButton> +#include <QVBoxLayout> +#include <QCheckBox> +#include <QSlider> +#include <QSpinBox> + +SettingsDialog::SettingsDialog( + const QList<QAudioDeviceInfo> &availableInputDevices, + const QList<QAudioDeviceInfo> &availableOutputDevices, + QWidget *parent) + : QDialog(parent) + , m_windowFunction(DefaultWindowFunction) + , m_inputDeviceComboBox(new QComboBox(this)) + , m_outputDeviceComboBox(new QComboBox(this)) + , m_windowFunctionComboBox(new QComboBox(this)) +{ + QVBoxLayout *dialogLayout = new QVBoxLayout(this); + + // Populate combo boxes + + QAudioDeviceInfo device; + foreach (device, availableInputDevices) + m_inputDeviceComboBox->addItem(device.deviceName(), + qVariantFromValue(device)); + foreach (device, availableOutputDevices) + m_outputDeviceComboBox->addItem(device.deviceName(), + qVariantFromValue(device)); + + m_windowFunctionComboBox->addItem(tr("None"), qVariantFromValue(int(NoWindow))); + m_windowFunctionComboBox->addItem("Hann", qVariantFromValue(int(HannWindow))); + m_windowFunctionComboBox->setCurrentIndex(m_windowFunction); + + // Initialize default devices + if (!availableInputDevices.empty()) + m_inputDevice = availableInputDevices.front(); + if (!availableOutputDevices.empty()) + m_outputDevice = availableOutputDevices.front(); + + // Add widgets to layout + + QScopedPointer<QHBoxLayout> inputDeviceLayout(new QHBoxLayout); + QLabel *inputDeviceLabel = new QLabel(tr("Input device"), this); + inputDeviceLayout->addWidget(inputDeviceLabel); + inputDeviceLayout->addWidget(m_inputDeviceComboBox); + dialogLayout->addLayout(inputDeviceLayout.data()); + inputDeviceLayout.take(); // ownership transferred to dialogLayout + + QScopedPointer<QHBoxLayout> outputDeviceLayout(new QHBoxLayout); + QLabel *outputDeviceLabel = new QLabel(tr("Output device"), this); + outputDeviceLayout->addWidget(outputDeviceLabel); + outputDeviceLayout->addWidget(m_outputDeviceComboBox); + dialogLayout->addLayout(outputDeviceLayout.data()); + outputDeviceLayout.take(); // ownership transferred to dialogLayout + + QScopedPointer<QHBoxLayout> windowFunctionLayout(new QHBoxLayout); + QLabel *windowFunctionLabel = new QLabel(tr("Window function"), this); + windowFunctionLayout->addWidget(windowFunctionLabel); + windowFunctionLayout->addWidget(m_windowFunctionComboBox); + dialogLayout->addLayout(windowFunctionLayout.data()); + windowFunctionLayout.take(); // ownership transferred to dialogLayout + + // Connect + CHECKED_CONNECT(m_inputDeviceComboBox, SIGNAL(activated(int)), + this, SLOT(inputDeviceChanged(int))); + CHECKED_CONNECT(m_outputDeviceComboBox, SIGNAL(activated(int)), + this, SLOT(outputDeviceChanged(int))); + CHECKED_CONNECT(m_windowFunctionComboBox, SIGNAL(activated(int)), + this, SLOT(windowFunctionChanged(int))); + + // Add standard buttons to layout + QDialogButtonBox *buttonBox = new QDialogButtonBox(this); + buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + dialogLayout->addWidget(buttonBox); + + // Connect standard buttons + CHECKED_CONNECT(buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), + this, SLOT(accept())); + CHECKED_CONNECT(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), + this, SLOT(reject())); + + setLayout(dialogLayout); +} + +SettingsDialog::~SettingsDialog() +{ + +} + +void SettingsDialog::windowFunctionChanged(int index) +{ + m_windowFunction = static_cast<WindowFunction>( + m_windowFunctionComboBox->itemData(index).value<int>()); +} + +void SettingsDialog::inputDeviceChanged(int index) +{ + m_inputDevice = m_inputDeviceComboBox->itemData(index).value<QAudioDeviceInfo>(); +} + +void SettingsDialog::outputDeviceChanged(int index) +{ + m_outputDevice = m_outputDeviceComboBox->itemData(index).value<QAudioDeviceInfo>(); +} + diff --git a/demos/spectrum/app/settingsdialog.h b/demos/spectrum/app/settingsdialog.h new file mode 100644 index 0000000..7215a50 --- /dev/null +++ b/demos/spectrum/app/settingsdialog.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ +** +*****************************************************************************/ + +#ifndef SETTINGSDIALOG_H +#define SETTINGSDIALOG_H + +#include "spectrum.h" +#include <QDialog> +#include <QtMultimedia/QAudioDeviceInfo> + +class QComboBox; +class QCheckBox; +class QSlider; +class QSpinBox; +class QGridLayout; + +/** + * Dialog used to control settings such as the audio input / output device + * and the windowing function. + */ +class SettingsDialog : public QDialog { + Q_OBJECT +public: + SettingsDialog(const QList<QAudioDeviceInfo> &availableInputDevices, + const QList<QAudioDeviceInfo> &availableOutputDevices, + QWidget *parent = 0); + ~SettingsDialog(); + + WindowFunction windowFunction() const { return m_windowFunction; } + const QAudioDeviceInfo& inputDevice() const { return m_inputDevice; } + const QAudioDeviceInfo& outputDevice() const { return m_outputDevice; } + +private slots: + void windowFunctionChanged(int index); + void inputDeviceChanged(int index); + void outputDeviceChanged(int index); + +private: + WindowFunction m_windowFunction; + QAudioDeviceInfo m_inputDevice; + QAudioDeviceInfo m_outputDevice; + + QComboBox* m_inputDeviceComboBox; + QComboBox* m_outputDeviceComboBox; + + QComboBox* m_windowFunctionComboBox; + +}; + +#endif // SETTINGSDIALOG_H diff --git a/demos/spectrum/app/spectrograph.cpp b/demos/spectrum/app/spectrograph.cpp new file mode 100644 index 0000000..1fcf434 --- /dev/null +++ b/demos/spectrum/app/spectrograph.cpp @@ -0,0 +1,242 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 "spectrograph.h" +#include <QPainter> +#include <QMouseEvent> +#include <QDebug> +#include <QTimerEvent> + +const int NullTimerId = -1; +const int NullIndex = -1; +const int BarSelectionInterval = 2000; + +Spectrograph::Spectrograph(QWidget *parent) + : QWidget(parent) + , m_barSelected(NullIndex) + , m_timerId(NullTimerId) + , m_lowFreq(0.0) + , m_highFreq(0.0) +{ + setMinimumHeight(100); +} + +Spectrograph::~Spectrograph() +{ + +} + +void Spectrograph::setParams(int numBars, qreal lowFreq, qreal highFreq) +{ + Q_ASSERT(numBars > 0); + Q_ASSERT(highFreq > lowFreq); + m_bars.resize(numBars); + m_lowFreq = lowFreq; + m_highFreq = highFreq; + updateBars(); +} + +void Spectrograph::timerEvent(QTimerEvent *event) +{ + Q_ASSERT(event->timerId() == m_timerId); + Q_UNUSED(event) // suppress warnings in release builds + killTimer(m_timerId); + m_timerId = NullTimerId; + m_barSelected = NullIndex; + update(); +} + +void Spectrograph::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event) + + QPainter painter(this); + painter.fillRect(rect(), Qt::black); + + const int numBars = m_bars.count(); + + // Highlight region of selected bar + if (m_barSelected != NullIndex && numBars) { + QRect regionRect = rect(); + regionRect.setLeft(m_barSelected * rect().width() / numBars); + regionRect.setWidth(rect().width() / numBars); + QColor regionColor(202, 202, 64); + painter.setBrush(Qt::DiagCrossPattern); + painter.fillRect(regionRect, regionColor); + painter.setBrush(Qt::NoBrush); + } + + QColor barColor(51, 204, 102); + QColor clipColor(255, 255, 0); + + // Draw the outline + const QColor gridColor = barColor.darker(); + QPen gridPen(gridColor); + painter.setPen(gridPen); + painter.drawLine(rect().topLeft(), rect().topRight()); + painter.drawLine(rect().topRight(), rect().bottomRight()); + painter.drawLine(rect().bottomRight(), rect().bottomLeft()); + painter.drawLine(rect().bottomLeft(), rect().topLeft()); + + QVector<qreal> dashes; + dashes << 2 << 2; + gridPen.setDashPattern(dashes); + painter.setPen(gridPen); + + // Draw vertical lines between bars + if (numBars) { + const int numHorizontalSections = numBars; + QLine line(rect().topLeft(), rect().bottomLeft()); + for (int i=1; i<numHorizontalSections; ++i) { + line.translate(rect().width()/numHorizontalSections, 0); + painter.drawLine(line); + } + } + + // Draw horizontal lines + const int numVerticalSections = 10; + QLine line(rect().topLeft(), rect().topRight()); + for (int i=1; i<numVerticalSections; ++i) { + line.translate(0, rect().height()/numVerticalSections); + painter.drawLine(line); + } + + barColor = barColor.lighter(); + barColor.setAlphaF(0.75); + clipColor.setAlphaF(0.75); + + // Draw the bars + if (numBars) { + // Calculate width of bars and gaps + const int widgetWidth = rect().width(); + const int barPlusGapWidth = widgetWidth / numBars; + const int barWidth = 0.8 * barPlusGapWidth; + const int gapWidth = barPlusGapWidth - barWidth; + const int paddingWidth = widgetWidth - numBars * (barWidth + gapWidth); + const int leftPaddingWidth = (paddingWidth + gapWidth) / 2; + const int barHeight = rect().height() - 2 * gapWidth; + + for (int i=0; i<numBars; ++i) { + const qreal value = m_bars[i].value; + Q_ASSERT(value >= 0.0 && value <= 1.0); + QRect bar = rect(); + bar.setLeft(rect().left() + leftPaddingWidth + (i * (gapWidth + barWidth))); + bar.setWidth(barWidth); + bar.setTop(rect().top() + gapWidth + (1.0 - value) * barHeight); + bar.setBottom(rect().bottom() - gapWidth); + + QColor color = barColor; + if (m_bars[i].clipped) + color = clipColor; + + painter.fillRect(bar, color); + } + } +} + +void Spectrograph::mousePressEvent(QMouseEvent *event) +{ + const QPoint pos = event->pos(); + const int index = m_bars.count() * (pos.x() - rect().left()) / rect().width(); + selectBar(index); +} + +void Spectrograph::reset() +{ + m_spectrum.reset(); + spectrumChanged(m_spectrum); +} + +void Spectrograph::spectrumChanged(const FrequencySpectrum &spectrum) +{ + m_spectrum = spectrum; + updateBars(); +} + +int Spectrograph::barIndex(qreal frequency) const +{ + Q_ASSERT(frequency >= m_lowFreq && frequency < m_highFreq); + const qreal bandWidth = (m_highFreq - m_lowFreq) / m_bars.count(); + const int index = (frequency - m_lowFreq) / bandWidth; + if(index <0 || index >= m_bars.count()) + Q_ASSERT(false); + return index; +} + +QPair<qreal, qreal> Spectrograph::barRange(int index) const +{ + Q_ASSERT(index >= 0 && index < m_bars.count()); + const qreal bandWidth = (m_highFreq - m_lowFreq) / m_bars.count(); + return QPair<qreal, qreal>(index * bandWidth, (index+1) * bandWidth); +} + +void Spectrograph::updateBars() +{ + m_bars.fill(Bar()); + FrequencySpectrum::const_iterator i = m_spectrum.begin(); + const FrequencySpectrum::const_iterator end = m_spectrum.end(); + for ( ; i != end; ++i) { + const FrequencySpectrum::Element e = *i; + if (e.frequency >= m_lowFreq && e.frequency < m_highFreq) { + Bar &bar = m_bars[barIndex(e.frequency)]; + bar.value = qMax(bar.value, e.amplitude); + bar.clipped |= e.clipped; + } + } + update(); +} + +void Spectrograph::selectBar(int index) { + const QPair<qreal, qreal> frequencyRange = barRange(index); + const QString message = QString("%1 - %2 Hz") + .arg(frequencyRange.first) + .arg(frequencyRange.second); + emit infoMessage(message, BarSelectionInterval); + + if (NullTimerId != m_timerId) + killTimer(m_timerId); + m_timerId = startTimer(BarSelectionInterval); + + m_barSelected = index; + update(); +} + + diff --git a/demos/spectrum/app/spectrograph.h b/demos/spectrum/app/spectrograph.h new file mode 100644 index 0000000..6bfef33 --- /dev/null +++ b/demos/spectrum/app/spectrograph.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ +** +*****************************************************************************/ + +#ifndef SPECTROGRAPH_H +#define SPECTROGRAPH_H + +#include <QWidget> +#include "frequencyspectrum.h" + +class QMouseEvent; + +/** + * Widget which displays a spectrograph showing the frequency spectrum + * of the window of audio samples most recently analysed by the Engine. + */ +class Spectrograph : public QWidget { + Q_OBJECT +public: + Spectrograph(QWidget *parent = 0); + ~Spectrograph(); + + void setParams(int numBars, qreal lowFreq, qreal highFreq); + + // QObject + void timerEvent(QTimerEvent *event); + + // QWidget + void paintEvent(QPaintEvent *event); + void mousePressEvent(QMouseEvent *event); + +signals: + void infoMessage(const QString &message, int intervalMs); + +public slots: + void reset(); + void spectrumChanged(const FrequencySpectrum &spectrum); + +private: + int barIndex(qreal frequency) const; + QPair<qreal, qreal> barRange(int barIndex) const; + void updateBars(); + + void selectBar(int index); + +private: + struct Bar { + Bar() : value(0.0), clipped(false) { } + qreal value; + bool clipped; + }; + + QVector<Bar> m_bars; + int m_barSelected; + int m_timerId; + qreal m_lowFreq; + qreal m_highFreq; + FrequencySpectrum m_spectrum; + + +}; + +#endif // SPECTROGRAPH_H diff --git a/demos/spectrum/app/spectrum.h b/demos/spectrum/app/spectrum.h new file mode 100644 index 0000000..6cfe29f --- /dev/null +++ b/demos/spectrum/app/spectrum.h @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ +** +*****************************************************************************/ + +#ifndef SPECTRUM_H +#define SPECTRUM_H + +#include <QtCore/qglobal.h> +#include "utils.h" +#include "fftreal_wrapper.h" // For FFTLengthPowerOfTwo + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +// Number of audio samples used to calculate the frequency spectrum +const int SpectrumLengthSamples = PowerOfTwo<FFTLengthPowerOfTwo>::Result; + +// Number of bands in the frequency spectrum +const int SpectrumNumBands = 10; + +// Lower bound of first band in the spectrum +const qreal SpectrumLowFreq = 0.0; // Hz + +// Upper band of last band in the spectrum +const qreal SpectrumHighFreq = 1000.0; // Hz + +// Waveform window size in microseconds +const qint64 WaveformWindowDuration = 500 * 1000; + +// Length of waveform tiles in bytes +// Ideally, these would match the QAudio*::bufferSize(), but that isn't +// available until some time after QAudio*::start() has been called, and we +// need this value in order to initialize the waveform display. +// We therefore just choose a sensible value. +const int WaveformTileLength = 4096; + +// Fudge factor used to calculate the spectrum bar heights +const qreal SpectrumAnalyserMultiplier = 0.15; + +// Disable message timeout +const int NullMessageTimeout = -1; + + +//----------------------------------------------------------------------------- +// Types and data structures +//----------------------------------------------------------------------------- + +enum WindowFunction { + NoWindow, + HannWindow +}; + +const WindowFunction DefaultWindowFunction = HannWindow; + +struct Tone { + Tone(qreal freq = 0.0, qreal amp = 0.0) + : frequency(freq), amplitude(amp) + { } + + // Start and end frequencies for swept tone generation + qreal frequency; + + // Amplitude in range [0.0, 1.0] + qreal amplitude; +}; + +struct SweptTone { + SweptTone(qreal start = 0.0, qreal end = 0.0, qreal amp = 0.0) + : startFreq(start), endFreq(end), amplitude(amp) + { Q_ASSERT(end >= start); } + + SweptTone(const Tone &tone) + : startFreq(tone.frequency), endFreq(tone.frequency), amplitude(tone.amplitude) + { } + + // Start and end frequencies for swept tone generation + qreal startFreq; + qreal endFreq; + + // Amplitude in range [0.0, 1.0] + qreal amplitude; +}; + + +//----------------------------------------------------------------------------- +// Macros +//----------------------------------------------------------------------------- + +// Macro which connects a signal to a slot, and which causes application to +// abort if the connection fails. This is intended to catch programming errors +// such as mis-typing a signal or slot name. It is necessary to write our own +// macro to do this - the following idiom +// Q_ASSERT(connect(source, signal, receiver, slot)); +// will not work because Q_ASSERT compiles to a no-op in release builds. + +#define CHECKED_CONNECT(source, signal, receiver, slot) \ + if(!connect(source, signal, receiver, slot)) \ + qt_assert_x(Q_FUNC_INFO, "CHECKED_CONNECT failed", __FILE__, __LINE__); + +// Handle some dependencies between macros defined in the .pro file + +#ifdef DISABLE_WAVEFORM +#undef SUPERIMPOSE_PROGRESS_ON_WAVEFORM +#endif + +#endif // SPECTRUM_H + diff --git a/demos/spectrum/app/spectrum.qrc b/demos/spectrum/app/spectrum.qrc new file mode 100644 index 0000000..6100479 --- /dev/null +++ b/demos/spectrum/app/spectrum.qrc @@ -0,0 +1,7 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>images/record.png</file> + <file>images/settings.png</file> +</qresource> +</RCC> + diff --git a/demos/spectrum/app/spectrum.sh b/demos/spectrum/app/spectrum.sh new file mode 100644 index 0000000..75ad6c2 --- /dev/null +++ b/demos/spectrum/app/spectrum.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Shell script for launching spectrum application on Unix systems other than Mac OSX + +bindir=`dirname "$0"` +LD_LIBRARY_PATH="${bindir}:${LD_LIBRARY_PATH}" +export LD_LIBRARY_PATH +exec "${bindir}/spectrum.bin" ${1+"$@"} + diff --git a/demos/spectrum/app/spectrumanalyser.cpp b/demos/spectrum/app/spectrumanalyser.cpp new file mode 100644 index 0000000..54d3f5e --- /dev/null +++ b/demos/spectrum/app/spectrumanalyser.cpp @@ -0,0 +1,280 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 "spectrumanalyser.h" +#include "utils.h" + +#include <QtCore/qmath.h> +#include <QtCore/qmetatype.h> +#include <QtMultimedia/QAudioFormat> +#include <QThread> + +#include "fftreal_wrapper.h" + +SpectrumAnalyserThread::SpectrumAnalyserThread(QObject *parent) + : QObject(parent) +#ifndef DISABLE_FFT + , m_fft(new FFTRealWrapper) +#endif + , m_numSamples(SpectrumLengthSamples) + , m_windowFunction(DefaultWindowFunction) + , m_window(SpectrumLengthSamples, 0.0) + , m_input(SpectrumLengthSamples, 0.0) + , m_output(SpectrumLengthSamples, 0.0) + , m_spectrum(SpectrumLengthSamples) +#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD + , m_thread(new QThread(this)) +#endif +{ +#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD + moveToThread(m_thread); + m_thread->start(); +#endif + calculateWindow(); +} + +SpectrumAnalyserThread::~SpectrumAnalyserThread() +{ +#ifndef DISABLE_FFT + delete m_fft; +#endif +} + +void SpectrumAnalyserThread::setWindowFunction(WindowFunction type) +{ + m_windowFunction = type; + calculateWindow(); +} + +void SpectrumAnalyserThread::calculateWindow() +{ + for (int i=0; i<m_numSamples; ++i) { + DataType x = 0.0; + + switch (m_windowFunction) { + case NoWindow: + x = 1.0; + break; + case HannWindow: + x = 0.5 * (1 - qCos((2 * M_PI * i) / (m_numSamples - 1))); + break; + default: + Q_ASSERT(false); + } + + m_window[i] = x; + } +} + +void SpectrumAnalyserThread::calculateSpectrum(const QByteArray &buffer, + int inputFrequency, + int bytesPerSample) +{ +#ifndef DISABLE_FFT + Q_ASSERT(buffer.size() == m_numSamples * bytesPerSample); + + // Initialize data array + const char *ptr = buffer.constData(); + for (int i=0; i<m_numSamples; ++i) { + const qint16 pcmSample = *reinterpret_cast<const qint16*>(ptr); + // Scale down to range [-1.0, 1.0] + const DataType realSample = pcmToReal(pcmSample); + const DataType windowedSample = realSample * m_window[i]; + m_input[i] = windowedSample; + ptr += bytesPerSample; + } + + // Calculate the FFT + m_fft->calculateFFT(m_output.data(), m_input.data()); + + // Analyse output to obtain amplitude and phase for each frequency + for (int i=2; i<=m_numSamples/2; ++i) { + // Calculate frequency of this complex sample + m_spectrum[i].frequency = qreal(i * inputFrequency) / (m_numSamples); + + const qreal real = m_output[i]; + qreal imag = 0.0; + if (i>0 && i<m_numSamples/2) + imag = m_output[m_numSamples/2 + i]; + + const qreal magnitude = sqrt(real*real + imag*imag); + qreal amplitude = SpectrumAnalyserMultiplier * log(magnitude); + + // Bound amplitude to [0.0, 1.0] + m_spectrum[i].clipped = (amplitude > 1.0); + amplitude = qMax(qreal(0.0), amplitude); + amplitude = qMin(qreal(1.0), amplitude); + m_spectrum[i].amplitude = amplitude; + } +#endif + + emit calculationComplete(m_spectrum); +} + + +//============================================================================= +// SpectrumAnalyser +//============================================================================= + +SpectrumAnalyser::SpectrumAnalyser(QObject *parent) + : QObject(parent) + , m_thread(new SpectrumAnalyserThread(this)) + , m_state(Idle) +#ifdef DUMP_SPECTRUMANALYSER + , m_count(0) +#endif +{ + CHECKED_CONNECT(m_thread, SIGNAL(calculationComplete(FrequencySpectrum)), + this, SLOT(calculationComplete(FrequencySpectrum))); +} + +SpectrumAnalyser::~SpectrumAnalyser() +{ + +} + +#ifdef DUMP_SPECTRUMANALYSER +void SpectrumAnalyser::setOutputPath(const QString &outputDir) +{ + m_outputDir.setPath(outputDir); + m_textFile.setFileName(m_outputDir.filePath("spectrum.txt")); + m_textFile.open(QIODevice::WriteOnly | QIODevice::Text); + m_textStream.setDevice(&m_textFile); +} +#endif + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +void SpectrumAnalyser::setWindowFunction(WindowFunction type) +{ + const bool b = QMetaObject::invokeMethod(m_thread, "setWindowFunction", + Qt::AutoConnection, + Q_ARG(WindowFunction, type)); + Q_ASSERT(b); + Q_UNUSED(b) // suppress warnings in release builds +} + +void SpectrumAnalyser::calculate(const QByteArray &buffer, + const QAudioFormat &format) +{ + // QThread::currentThread is marked 'for internal use only', but + // we're only using it for debug output here, so it's probably OK :) + SPECTRUMANALYSER_DEBUG << "SpectrumAnalyser::calculate" + << QThread::currentThread() + << "state" << m_state; + + if (isReady()) { + Q_ASSERT(isPCMS16LE(format)); + + const int bytesPerSample = format.sampleSize() * format.channels() / 8; + +#ifdef DUMP_SPECTRUMANALYSER + m_count++; + const QString pcmFileName = m_outputDir.filePath(QString("spectrum_%1.pcm").arg(m_count, 4, 10, QChar('0'))); + QFile pcmFile(pcmFileName); + pcmFile.open(QIODevice::WriteOnly); + const int bufferLength = m_numSamples * bytesPerSample; + pcmFile.write(buffer, bufferLength); + + m_textStream << "TimeDomain " << m_count << "\n"; + const qint16* input = reinterpret_cast<const qint16*>(buffer); + for (int i=0; i<m_numSamples; ++i) { + m_textStream << i << "\t" << *input << "\n"; + input += format.channels(); + } +#endif + + m_state = Busy; + + // Invoke SpectrumAnalyserThread::calculateSpectrum using QMetaObject. If + // m_thread is in a different thread from the current thread, the + // calculation will be done in the child thread. + // Once the calculation is finished, a calculationChanged signal will be + // emitted by m_thread. + const bool b = QMetaObject::invokeMethod(m_thread, "calculateSpectrum", + Qt::AutoConnection, + Q_ARG(QByteArray, buffer), + Q_ARG(int, format.frequency()), + Q_ARG(int, bytesPerSample)); + Q_ASSERT(b); + Q_UNUSED(b) // suppress warnings in release builds + +#ifdef DUMP_SPECTRUMANALYSER + m_textStream << "FrequencySpectrum " << m_count << "\n"; + FrequencySpectrum::const_iterator x = m_spectrum.begin(); + for (int i=0; i<m_numSamples; ++i, ++x) + m_textStream << i << "\t" + << x->frequency << "\t" + << x->amplitude<< "\t" + << x->phase << "\n"; +#endif + } +} + +bool SpectrumAnalyser::isReady() const +{ + return (Idle == m_state); +} + +void SpectrumAnalyser::cancelCalculation() +{ + if (Busy == m_state) + m_state = Cancelled; +} + + +//----------------------------------------------------------------------------- +// Private slots +//----------------------------------------------------------------------------- + +void SpectrumAnalyser::calculationComplete(const FrequencySpectrum &spectrum) +{ + Q_ASSERT(Idle != m_state); + if (Busy == m_state) + emit spectrumChanged(spectrum); + m_state = Idle; +} + + + + diff --git a/demos/spectrum/app/spectrumanalyser.h b/demos/spectrum/app/spectrumanalyser.h new file mode 100644 index 0000000..caeb1c1 --- /dev/null +++ b/demos/spectrum/app/spectrumanalyser.h @@ -0,0 +1,190 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ +** +*****************************************************************************/ + +#ifndef SPECTRUMANALYSER_H +#define SPECTRUMANALYSER_H + +#include <QByteArray> +#include <QObject> +#include <QVector> + +#ifdef DUMP_SPECTRUMANALYSER +#include <QDir> +#include <QFile> +#include <QTextStream> +#endif + +#include "frequencyspectrum.h" +#include "spectrum.h" + +#ifndef DISABLE_FFT +#include "FFTRealFixLenParam.h" +#endif + +class QAudioFormat; +class QThread; +class FFTRealWrapper; + +class SpectrumAnalyserThreadPrivate; + +/** + * Implementation of the spectrum analysis which can be run in a + * separate thread. + */ +class SpectrumAnalyserThread : public QObject +{ + Q_OBJECT +public: + SpectrumAnalyserThread(QObject *parent); + ~SpectrumAnalyserThread(); + +public slots: + void setWindowFunction(WindowFunction type); + void calculateSpectrum(const QByteArray &buffer, + int inputFrequency, + int bytesPerSample); + +signals: + void calculationComplete(const FrequencySpectrum &spectrum); + +private: + void calculateWindow(); + +private: +#ifndef DISABLE_FFT + FFTRealWrapper* m_fft; +#endif + + const int m_numSamples; + + WindowFunction m_windowFunction; + +#ifdef DISABLE_FFT + typedef qreal DataType; +#else + typedef FFTRealFixLenParam::DataType DataType; +#endif + QVector<DataType> m_window; + + QVector<DataType> m_input; + QVector<DataType> m_output; + + FrequencySpectrum m_spectrum; + +#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD + QThread* m_thread; +#endif +}; + +/** + * Class which performs frequency spectrum analysis on a window of + * audio samples, provided to it by the Engine. + */ +class SpectrumAnalyser : public QObject +{ + Q_OBJECT +public: + SpectrumAnalyser(QObject *parent = 0); + ~SpectrumAnalyser(); + +#ifdef DUMP_SPECTRUMANALYSER + void setOutputPath(const QString &outputPath); +#endif + +public: + /* + * Set the windowing function which is applied before calculating the FFT + */ + void setWindowFunction(WindowFunction type); + + /* + * Calculate a frequency spectrum + * + * \param buffer Audio data + * \param format Format of audio data + * + * Frequency spectrum is calculated asynchronously. The result is returned + * via the spectrumChanged signal. + * + * An ongoing calculation can be cancelled by calling cancelCalculation(). + * + */ + void calculate(const QByteArray &buffer, const QAudioFormat &format); + + /* + * Check whether the object is ready to perform another calculation + */ + bool isReady() const; + + /* + * Cancel an ongoing calculation + * + * Note that cancelling is asynchronous. + */ + void cancelCalculation(); + +signals: + void spectrumChanged(const FrequencySpectrum &spectrum); + +private slots: + void calculationComplete(const FrequencySpectrum &spectrum); + +private: + void calculateWindow(); + +private: + + SpectrumAnalyserThread* m_thread; + + enum State { + Idle, + Busy, + Cancelled + }; + + State m_state; + +#ifdef DUMP_SPECTRUMANALYSER + QDir m_outputDir; + int m_count; + QFile m_textFile; + QTextStream m_textStream; +#endif +}; + +#endif // SPECTRUMANALYSER_H + diff --git a/demos/spectrum/app/tonegenerator.cpp b/demos/spectrum/app/tonegenerator.cpp new file mode 100644 index 0000000..6458a7d --- /dev/null +++ b/demos/spectrum/app/tonegenerator.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 "spectrum.h" +#include "utils.h" +#include <QByteArray> +#include <QtMultimedia/QAudioFormat> +#include <QtCore/qmath.h> +#include <QtCore/qendian.h> + +void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray &buffer) +{ + Q_ASSERT(isPCMS16LE(format)); + + const int channelBytes = format.sampleSize() / 8; + const int sampleBytes = format.channels() * channelBytes; + int length = buffer.size(); + const int numSamples = buffer.size() / sampleBytes; + + Q_ASSERT(length % sampleBytes == 0); + Q_UNUSED(sampleBytes) // suppress warning in release builds + + unsigned char *ptr = reinterpret_cast<unsigned char *>(buffer.data()); + + qreal phase = 0.0; + + const qreal d = 2 * M_PI / format.frequency(); + + // We can't generate a zero-frequency sine wave + const qreal startFreq = tone.startFreq ? tone.startFreq : 1.0; + + // Amount by which phase increases on each sample + qreal phaseStep = d * startFreq; + + // Amount by which phaseStep increases on each sample + // If this is non-zero, the output is a frequency-swept tone + const qreal phaseStepStep = d * (tone.endFreq - startFreq) / numSamples; + + while (length) { + const qreal x = tone.amplitude * qSin(phase); + const qint16 value = realToPcm(x); + for (int i=0; i<format.channels(); ++i) { + qToLittleEndian<qint16>(value, ptr); + ptr += channelBytes; + length -= channelBytes; + } + + phase += phaseStep; + while (phase > 2 * M_PI) + phase -= 2 * M_PI; + phaseStep += phaseStepStep; + } +} + diff --git a/demos/spectrum/app/tonegenerator.h b/demos/spectrum/app/tonegenerator.h new file mode 100644 index 0000000..419f7e4 --- /dev/null +++ b/demos/spectrum/app/tonegenerator.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ +** +*****************************************************************************/ + +#ifndef TONEGENERATOR_H +#define TONEGENERATOR_H + +#include <QtCore/qglobal.h> +#include "spectrum.h" + +class QAudioFormat; +class QByteArray; + +/** + * Generate a sine wave + */ +void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray &buffer); + +#endif // TONEGENERATOR_H + diff --git a/demos/spectrum/app/tonegeneratordialog.cpp b/demos/spectrum/app/tonegeneratordialog.cpp new file mode 100644 index 0000000..06e453c --- /dev/null +++ b/demos/spectrum/app/tonegeneratordialog.cpp @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 "tonegeneratordialog.h" +#include <QComboBox> +#include <QDialogButtonBox> +#include <QLabel> +#include <QPushButton> +#include <QVBoxLayout> +#include <QCheckBox> +#include <QSlider> +#include <QSpinBox> + +const int ToneGeneratorFreqMin = 1; +const int ToneGeneratorFreqMax = 1000; +const int ToneGeneratorFreqDefault = 440; +const int ToneGeneratorAmplitudeDefault = 75; + +ToneGeneratorDialog::ToneGeneratorDialog(QWidget *parent) + : QDialog(parent) + , m_toneGeneratorSweepCheckBox(new QCheckBox(tr("Frequency sweep"), this)) + , m_frequencySweepEnabled(true) + , m_toneGeneratorControl(new QWidget(this)) + , m_toneGeneratorFrequencyControl(new QWidget(this)) + , m_frequencySlider(new QSlider(Qt::Horizontal, this)) + , m_frequencySpinBox(new QSpinBox(this)) + , m_frequency(ToneGeneratorFreqDefault) + , m_amplitudeSlider(new QSlider(Qt::Horizontal, this)) +{ + QVBoxLayout *dialogLayout = new QVBoxLayout(this); + + m_toneGeneratorSweepCheckBox->setChecked(true); + + // Configure tone generator controls + m_frequencySlider->setRange(ToneGeneratorFreqMin, ToneGeneratorFreqMax); + m_frequencySlider->setValue(ToneGeneratorFreqDefault); + m_frequencySpinBox->setRange(ToneGeneratorFreqMin, ToneGeneratorFreqMax); + m_frequencySpinBox->setValue(ToneGeneratorFreqDefault); + m_amplitudeSlider->setRange(0, 100); + m_amplitudeSlider->setValue(ToneGeneratorAmplitudeDefault); + + // Add widgets to layout + + QScopedPointer<QGridLayout> frequencyControlLayout(new QGridLayout); + QLabel *frequencyLabel = new QLabel(tr("Frequency (Hz)"), this); + frequencyControlLayout->addWidget(frequencyLabel, 0, 0, 2, 1); + frequencyControlLayout->addWidget(m_frequencySlider, 0, 1); + frequencyControlLayout->addWidget(m_frequencySpinBox, 1, 1); + m_toneGeneratorFrequencyControl->setLayout(frequencyControlLayout.data()); + frequencyControlLayout.take(); // ownership transferred to m_toneGeneratorFrequencyControl + m_toneGeneratorFrequencyControl->setEnabled(false); + + QScopedPointer<QGridLayout> toneGeneratorLayout(new QGridLayout); + QLabel *amplitudeLabel = new QLabel(tr("Amplitude"), this); + toneGeneratorLayout->addWidget(m_toneGeneratorSweepCheckBox, 0, 1); + toneGeneratorLayout->addWidget(m_toneGeneratorFrequencyControl, 1, 0, 1, 2); + toneGeneratorLayout->addWidget(amplitudeLabel, 2, 0); + toneGeneratorLayout->addWidget(m_amplitudeSlider, 2, 1); + m_toneGeneratorControl->setLayout(toneGeneratorLayout.data()); + m_toneGeneratorControl->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + dialogLayout->addWidget(m_toneGeneratorControl); + toneGeneratorLayout.take(); // ownership transferred + + // Connect + CHECKED_CONNECT(m_toneGeneratorSweepCheckBox, SIGNAL(toggled(bool)), + this, SLOT(frequencySweepEnabled(bool))); + CHECKED_CONNECT(m_frequencySlider, SIGNAL(valueChanged(int)), + m_frequencySpinBox, SLOT(setValue(int))); + CHECKED_CONNECT(m_frequencySpinBox, SIGNAL(valueChanged(int)), + m_frequencySlider, SLOT(setValue(int))); + + // Add standard buttons to layout + QDialogButtonBox *buttonBox = new QDialogButtonBox(this); + buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + dialogLayout->addWidget(buttonBox); + + // Connect standard buttons + CHECKED_CONNECT(buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), + this, SLOT(accept())); + CHECKED_CONNECT(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), + this, SLOT(reject())); + + setLayout(dialogLayout); +} + +ToneGeneratorDialog::~ToneGeneratorDialog() +{ + +} + +bool ToneGeneratorDialog::isFrequencySweepEnabled() const +{ + return m_toneGeneratorSweepCheckBox->isChecked(); +} + +qreal ToneGeneratorDialog::frequency() const +{ + return qreal(m_frequencySlider->value()); +} + +qreal ToneGeneratorDialog::amplitude() const +{ + return qreal(m_amplitudeSlider->value()) / 100.0; +} + +void ToneGeneratorDialog::frequencySweepEnabled(bool enabled) +{ + m_frequencySweepEnabled = enabled; + m_toneGeneratorFrequencyControl->setEnabled(!enabled); +} diff --git a/demos/spectrum/app/tonegeneratordialog.h b/demos/spectrum/app/tonegeneratordialog.h new file mode 100644 index 0000000..35d69c2 --- /dev/null +++ b/demos/spectrum/app/tonegeneratordialog.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ +** +*****************************************************************************/ + +#ifndef TONEGENERATORDIALOG_H +#define TONEGENERATORDIALOG_H + +#include "spectrum.h" +#include <QDialog> +#include <QtMultimedia/QAudioDeviceInfo> + +class QCheckBox; +class QSlider; +class QSpinBox; +class QGridLayout; + +/** + * Dialog which controls the parameters of the tone generator. + */ +class ToneGeneratorDialog : public QDialog { + Q_OBJECT +public: + ToneGeneratorDialog(QWidget *parent = 0); + ~ToneGeneratorDialog(); + + bool isFrequencySweepEnabled() const; + qreal frequency() const; + qreal amplitude() const; + +private slots: + void frequencySweepEnabled(bool enabled); + +private: + QCheckBox* m_toneGeneratorSweepCheckBox; + bool m_frequencySweepEnabled; + QWidget* m_toneGeneratorControl; + QWidget* m_toneGeneratorFrequencyControl; + QSlider* m_frequencySlider; + QSpinBox* m_frequencySpinBox; + qreal m_frequency; + QSlider* m_amplitudeSlider; + +}; + +#endif // TONEGENERATORDIALOG_H diff --git a/demos/spectrum/app/utils.cpp b/demos/spectrum/app/utils.cpp new file mode 100644 index 0000000..97dc6e3 --- /dev/null +++ b/demos/spectrum/app/utils.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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/QAudioFormat> +#include "utils.h" + +qint64 audioDuration(const QAudioFormat &format, qint64 bytes) +{ + return (bytes * 1000000) / + (format.frequency() * format.channels() * (format.sampleSize() / 8)); +} + +qint64 audioLength(const QAudioFormat &format, qint64 microSeconds) +{ + return (format.frequency() * format.channels() * (format.sampleSize() / 8)) + * microSeconds / 1000000; +} + +qreal nyquistFrequency(const QAudioFormat &format) +{ + return format.frequency() / 2; +} + +QString formatToString(const QAudioFormat &format) +{ + QString result; + + if (QAudioFormat() != format) { + if (format.codec() == "audio/pcm") { + Q_ASSERT(format.sampleType() == QAudioFormat::SignedInt); + + const QString formatEndian = (format.byteOrder() == QAudioFormat::LittleEndian) + ? QString("LE") : QString("BE"); + + QString formatType; + switch(format.sampleType()) { + case QAudioFormat::SignedInt: + formatType = "signed"; + break; + case QAudioFormat::UnSignedInt: + formatType = "unsigned"; + break; + case QAudioFormat::Float: + formatType = "float"; + break; + case QAudioFormat::Unknown: + formatType = "unknown"; + break; + } + + QString formatChannels = QString("%1 channels").arg(format.channels()); + switch (format.channels()) { + case 1: + formatChannels = "mono"; + break; + case 2: + formatChannels = "stereo"; + break; + } + + result = QString("%1 Hz %2 bit %3 %4 %5") + .arg(format.frequency()) + .arg(format.sampleSize()) + .arg(formatType) + .arg(formatEndian) + .arg(formatChannels); + } else { + result = format.codec(); + } + } + + return result; +} + +bool isPCM(const QAudioFormat &format) +{ + return (format.codec() == "audio/pcm"); +} + + +bool isPCMS16LE(const QAudioFormat &format) +{ + return (isPCM(format) && + format.sampleType() == QAudioFormat::SignedInt && + format.sampleSize() == 16 && + format.byteOrder() == QAudioFormat::LittleEndian); +} + +const qint16 PCMS16MaxValue = 32767; +const quint16 PCMS16MaxAmplitude = 32768; // because minimum is -32768 + +qreal pcmToReal(qint16 pcm) +{ + return qreal(pcm) / PCMS16MaxAmplitude; +} + +qint16 realToPcm(qreal real) +{ + return real * PCMS16MaxValue; +} diff --git a/demos/spectrum/app/utils.h b/demos/spectrum/app/utils.h new file mode 100644 index 0000000..83467cd --- /dev/null +++ b/demos/spectrum/app/utils.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ +** +*****************************************************************************/ + +#ifndef UTILS_H +#define UTILS_H + +#include <QtCore/qglobal.h> +#include <QDebug> + +class QAudioFormat; + +//----------------------------------------------------------------------------- +// Miscellaneous utility functions +//----------------------------------------------------------------------------- + +qint64 audioDuration(const QAudioFormat &format, qint64 bytes); +qint64 audioLength(const QAudioFormat &format, qint64 microSeconds); + +QString formatToString(const QAudioFormat &format); + +qreal nyquistFrequency(const QAudioFormat &format); + +// Scale PCM value to [-1.0, 1.0] +qreal pcmToReal(qint16 pcm); + +// Scale real value in [-1.0, 1.0] to PCM +qint16 realToPcm(qreal real); + +// Check whether the audio format is PCM +bool isPCM(const QAudioFormat &format); + +// Check whether the audio format is signed, little-endian, 16-bit PCM +bool isPCMS16LE(const QAudioFormat &format); + +// Compile-time calculation of powers of two + +template<int N> class PowerOfTwo +{ public: static const int Result = PowerOfTwo<N-1>::Result * 2; }; + +template<> class PowerOfTwo<0> +{ public: static const int Result = 1; }; + + +//----------------------------------------------------------------------------- +// Debug output +//----------------------------------------------------------------------------- + +class NullDebug +{ +public: + template <typename T> + NullDebug& operator<<(const T&) { return *this; } +}; + +inline NullDebug nullDebug() { return NullDebug(); } + +#ifdef LOG_ENGINE +# define ENGINE_DEBUG qDebug() +#else +# define ENGINE_DEBUG nullDebug() +#endif + +#ifdef LOG_SPECTRUMANALYSER +# define SPECTRUMANALYSER_DEBUG qDebug() +#else +# define SPECTRUMANALYSER_DEBUG nullDebug() +#endif + +#ifdef LOG_WAVEFORM +# define WAVEFORM_DEBUG qDebug() +#else +# define WAVEFORM_DEBUG nullDebug() +#endif + +#endif // UTILS_H diff --git a/demos/spectrum/app/waveform.cpp b/demos/spectrum/app/waveform.cpp new file mode 100644 index 0000000..3fc4f76 --- /dev/null +++ b/demos/spectrum/app/waveform.cpp @@ -0,0 +1,419 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 "waveform.h" +#include "utils.h" +#include <QPainter> +#include <QResizeEvent> +#include <QDebug> + + +Waveform::Waveform(const QByteArray &buffer, QWidget *parent) + : QWidget(parent) + , m_buffer(buffer) + , m_dataLength(0) + , m_position(0) + , m_active(false) + , m_tileLength(0) + , m_tileArrayStart(0) + , m_windowPosition(0) + , m_windowLength(0) +{ + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + setMinimumHeight(50); +} + +Waveform::~Waveform() +{ + deletePixmaps(); +} + +void Waveform::paintEvent(QPaintEvent * /*event*/) +{ + QPainter painter(this); + + painter.fillRect(rect(), Qt::black); + + if (m_active) { + WAVEFORM_DEBUG << "Waveform::paintEvent" + << "windowPosition" << m_windowPosition + << "windowLength" << m_windowLength; + qint64 pos = m_windowPosition; + const qint64 windowEnd = m_windowPosition + m_windowLength; + int destLeft = 0; + int destRight = 0; + while (pos < windowEnd) { + const TilePoint point = tilePoint(pos); + WAVEFORM_DEBUG << "Waveform::paintEvent" << "pos" << pos + << "tileIndex" << point.index + << "positionOffset" << point.positionOffset + << "pixelOffset" << point.pixelOffset; + + if (point.index != NullIndex) { + const Tile &tile = m_tiles[point.index]; + if (tile.painted) { + const qint64 sectionLength = qMin((m_tileLength - point.positionOffset), + (windowEnd - pos)); + Q_ASSERT(sectionLength > 0); + + const int sourceRight = tilePixelOffset(point.positionOffset + sectionLength); + destRight = windowPixelOffset(pos - m_windowPosition + sectionLength); + + QRect destRect = rect(); + destRect.setLeft(destLeft); + destRect.setRight(destRight); + + QRect sourceRect(QPoint(), m_pixmapSize); + sourceRect.setLeft(point.pixelOffset); + sourceRect.setRight(sourceRight); + + WAVEFORM_DEBUG << "Waveform::paintEvent" << "tileIndex" << point.index + << "source" << point.pixelOffset << sourceRight + << "dest" << destLeft << destRight; + + painter.drawPixmap(destRect, *tile.pixmap, sourceRect); + + destLeft = destRight; + + if (point.index < m_tiles.count()) { + pos = tilePosition(point.index + 1); + WAVEFORM_DEBUG << "Waveform::paintEvent" << "pos ->" << pos; + } else { + // Reached end of tile array + WAVEFORM_DEBUG << "Waveform::paintEvent" << "reached end of tile array"; + break; + } + } else { + // Passed last tile which is painted + WAVEFORM_DEBUG << "Waveform::paintEvent" << "tile" << point.index << "not painted"; + break; + } + } else { + // pos is past end of tile array + WAVEFORM_DEBUG << "Waveform::paintEvent" << "pos" << pos << "past end of tile array"; + break; + } + } + + WAVEFORM_DEBUG << "Waveform::paintEvent" << "final pos" << pos << "final x" << destRight; + } +} + +void Waveform::resizeEvent(QResizeEvent *event) +{ + if (event->size() != event->oldSize()) + createPixmaps(event->size()); +} + +void Waveform::initialize(const QAudioFormat &format, qint64 audioBufferSize, qint64 windowDurationUs) +{ + WAVEFORM_DEBUG << "Waveform::initialize" + << "audioBufferSize" << audioBufferSize + << "m_buffer.size()" << m_buffer.size() + << "windowDurationUs" << windowDurationUs; + + reset(); + + m_format = format; + + // Calculate tile size + m_tileLength = audioBufferSize; + + // Calculate window size + m_windowLength = audioLength(m_format, windowDurationUs); + + // Calculate number of tiles required + int nTiles; + if (m_tileLength > m_windowLength) { + nTiles = 2; + } else { + nTiles = m_windowLength / m_tileLength + 1; + if (m_windowLength % m_tileLength) + ++nTiles; + } + + WAVEFORM_DEBUG << "Waveform::initialize" + << "tileLength" << m_tileLength + << "windowLength" << m_windowLength + << "nTiles" << nTiles; + + m_pixmaps.fill(0, nTiles); + m_tiles.resize(nTiles); + + createPixmaps(rect().size()); + + m_active = true; +} + +void Waveform::reset() +{ + WAVEFORM_DEBUG << "Waveform::reset"; + + m_dataLength = 0; + m_position = 0; + m_format = QAudioFormat(); + m_active = false; + deletePixmaps(); + m_tiles.clear(); + m_tileLength = 0; + m_tileArrayStart = 0; + m_windowPosition = 0; + m_windowLength = 0; +} + +void Waveform::dataLengthChanged(qint64 length) +{ + WAVEFORM_DEBUG << "Waveform::dataLengthChanged" << length; + const qint64 oldLength = m_dataLength; + m_dataLength = length; + + if (m_active) { + if (m_dataLength < oldLength) + positionChanged(m_dataLength); + else + paintTiles(); + } +} + +void Waveform::positionChanged(qint64 position) +{ + WAVEFORM_DEBUG << "Waveform::positionChanged" << position; + + if (position + m_windowLength > m_dataLength) + position = m_dataLength - m_windowLength; + + m_position = position; + + setWindowPosition(position); +} + +void Waveform::deletePixmaps() +{ + QPixmap *pixmap; + foreach (pixmap, m_pixmaps) + delete pixmap; + m_pixmaps.clear(); +} + +void Waveform::createPixmaps(const QSize &widgetSize) +{ + m_pixmapSize = widgetSize; + m_pixmapSize.setWidth(qreal(widgetSize.width()) * m_tileLength / m_windowLength); + + WAVEFORM_DEBUG << "Waveform::createPixmaps" + << "widgetSize" << widgetSize + << "pixmapSize" << m_pixmapSize; + + Q_ASSERT(m_tiles.count() == m_pixmaps.count()); + + // (Re)create pixmaps + for (int i=0; i<m_pixmaps.size(); ++i) { + delete m_pixmaps[i]; + m_pixmaps[i] = 0; + m_pixmaps[i] = new QPixmap(m_pixmapSize); + } + + // Update tile pixmap pointers, and mark for repainting + for (int i=0; i<m_tiles.count(); ++i) { + m_tiles[i].pixmap = m_pixmaps[i]; + m_tiles[i].painted = false; + } + + paintTiles(); +} + +void Waveform::setWindowPosition(qint64 position) +{ + WAVEFORM_DEBUG << "Waveform::setWindowPosition" + << "old" << m_windowPosition << "new" << position + << "tileArrayStart" << m_tileArrayStart; + + const qint64 oldPosition = m_windowPosition; + m_windowPosition = position; + + if((m_windowPosition >= oldPosition) && + (m_windowPosition - m_tileArrayStart < (m_tiles.count() * m_tileLength))) { + // Work out how many tiles need to be shuffled + const qint64 offset = m_windowPosition - m_tileArrayStart; + const int nTiles = offset / m_tileLength; + shuffleTiles(nTiles); + } else { + resetTiles(m_windowPosition); + } + + if(!paintTiles() && m_windowPosition != oldPosition) + update(); +} + +qint64 Waveform::tilePosition(int index) const +{ + return m_tileArrayStart + index * m_tileLength; +} + +Waveform::TilePoint Waveform::tilePoint(qint64 position) const +{ + TilePoint result; + if (position >= m_tileArrayStart) { + const qint64 tileArrayEnd = m_tileArrayStart + m_tiles.count() * m_tileLength; + if (position < tileArrayEnd) { + const qint64 offsetIntoTileArray = position - m_tileArrayStart; + result.index = offsetIntoTileArray / m_tileLength; + Q_ASSERT(result.index >= 0 && result.index <= m_tiles.count()); + result.positionOffset = offsetIntoTileArray % m_tileLength; + result.pixelOffset = tilePixelOffset(result.positionOffset); + Q_ASSERT(result.pixelOffset >= 0 && result.pixelOffset <= m_pixmapSize.width()); + } + } + + return result; +} + +int Waveform::tilePixelOffset(qint64 positionOffset) const +{ + Q_ASSERT(positionOffset >= 0 && positionOffset <= m_tileLength); + const int result = (qreal(positionOffset) / m_tileLength) * m_pixmapSize.width(); + return result; +} + +int Waveform::windowPixelOffset(qint64 positionOffset) const +{ + Q_ASSERT(positionOffset >= 0 && positionOffset <= m_windowLength); + const int result = (qreal(positionOffset) / m_windowLength) * rect().width(); + return result; +} + +bool Waveform::paintTiles() +{ + WAVEFORM_DEBUG << "Waveform::paintTiles"; + bool updateRequired = false; + + for (int i=0; i<m_tiles.count(); ++i) { + const Tile &tile = m_tiles[i]; + if (!tile.painted) { + const qint64 tileEnd = m_tileArrayStart + (i + 1) * m_tileLength; + if (m_dataLength >= tileEnd) { + paintTile(i); + updateRequired = true; + } + } + } + + if (updateRequired) + update(); + + return updateRequired; +} + +void Waveform::paintTile(int index) +{ + WAVEFORM_DEBUG << "Waveform::paintTile" << "index" << index; + + const qint64 tileStart = m_tileArrayStart + index * m_tileLength; + Q_ASSERT(m_dataLength >= tileStart + m_tileLength); + + Tile &tile = m_tiles[index]; + Q_ASSERT(!tile.painted); + + const qint16* base = reinterpret_cast<const qint16*>(m_buffer.constData()); + const qint16* buffer = base + (tileStart / 2); + const int numSamples = m_tileLength / (2 * m_format.channels()); + + QPainter painter(tile.pixmap); + + painter.fillRect(tile.pixmap->rect(), Qt::black); + + QPen pen(Qt::white); + painter.setPen(pen); + + // Calculate initial PCM value + qint16 previousPcmValue = 0; + if (buffer > base) + previousPcmValue = *(buffer - m_format.channels()); + + // Calculate initial point + const qreal previousRealValue = pcmToReal(previousPcmValue); + const int originY = ((previousRealValue + 1.0) / 2) * m_pixmapSize.height(); + const QPoint origin(0, originY); + + QLine line(origin, origin); + + for (int i=0; i<numSamples; ++i) { + const qint16* ptr = buffer + i * m_format.channels(); + const qint16 pcmValue = *ptr; + const qreal realValue = pcmToReal(pcmValue); + + const int x = tilePixelOffset(i * 2 * m_format.channels()); + const int y = ((realValue + 1.0) / 2) * m_pixmapSize.height(); + + line.setP2(QPoint(x, y)); + painter.drawLine(line); + line.setP1(line.p2()); + } + + tile.painted = true; +} + +void Waveform::shuffleTiles(int n) +{ + WAVEFORM_DEBUG << "Waveform::shuffleTiles" << "n" << n; + + while (n--) { + Tile tile = m_tiles.first(); + tile.painted = false; + m_tiles.erase(m_tiles.begin()); + m_tiles += tile; + m_tileArrayStart += m_tileLength; + } + + WAVEFORM_DEBUG << "Waveform::shuffleTiles" << "tileArrayStart" << m_tileArrayStart; +} + +void Waveform::resetTiles(qint64 newStartPos) +{ + WAVEFORM_DEBUG << "Waveform::resetTiles" << "newStartPos" << newStartPos; + + QVector<Tile>::iterator i = m_tiles.begin(); + for ( ; i != m_tiles.end(); ++i) + i->painted = false; + + m_tileArrayStart = newStartPos; +} + diff --git a/demos/spectrum/app/waveform.h b/demos/spectrum/app/waveform.h new file mode 100644 index 0000000..4de527f --- /dev/null +++ b/demos/spectrum/app/waveform.h @@ -0,0 +1,198 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ +** +*****************************************************************************/ + +#ifndef WAVEFORM_H +#define WAVEFORM_H + +#include <QWidget> +#include <QtMultimedia/QAudioFormat> +#include <QPixmap> +#include <QScopedPointer> + +class QByteArray; + +/** + * Widget which displays a section of the audio waveform. + * + * The waveform is rendered on a set of QPixmaps which form a group of tiles + * whose extent covers the widget. As the audio position is updated, these + * tiles are scrolled from left to right; when the left-most tile scrolls + * outside the widget, it is moved to the right end of the tile array and + * painted with the next section of the waveform. + */ +class Waveform : public QWidget { + Q_OBJECT +public: + Waveform(const QByteArray &buffer, QWidget *parent = 0); + ~Waveform(); + + // QWidget + void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent *event); + + void initialize(const QAudioFormat &format, qint64 audioBufferSize, qint64 windowDurationUs); + void reset(); + + void setAutoUpdatePosition(bool enabled); + +public slots: + void dataLengthChanged(qint64 length); + void positionChanged(qint64 position); + +private: + static const int NullIndex = -1; + + void deletePixmaps(); + + /* + * (Re)create all pixmaps, repaint and update the display. + * Triggers an update(); + */ + void createPixmaps(const QSize &newSize); + + /* + * Update window position. + * Triggers an update(). + */ + void setWindowPosition(qint64 position); + + /* + * Base position of tile + */ + qint64 tilePosition(int index) const; + + /* + * Structure which identifies a point within a given + * tile. + */ + struct TilePoint + { + TilePoint(int idx = 0, qint64 pos = 0, qint64 pix = 0) + : index(idx), positionOffset(pos), pixelOffset(pix) + { } + + // Index of tile + int index; + + // Number of bytes from start of tile + qint64 positionOffset; + + // Number of pixels from left of corresponding pixmap + int pixelOffset; + }; + + /* + * Convert position in m_buffer into a tile index and an offset in pixels + * into the corresponding pixmap. + * + * \param position Offset into m_buffer, in bytes + + * If position is outside the tile array, index is NullIndex and + * offset is zero. + */ + TilePoint tilePoint(qint64 position) const; + + /* + * Convert offset in bytes into a tile into an offset in pixels + * within that tile. + */ + int tilePixelOffset(qint64 positionOffset) const; + + /* + * Convert offset in bytes into the window into an offset in pixels + * within the widget rect(). + */ + int windowPixelOffset(qint64 positionOffset) const; + + /* + * Paint all tiles which can be painted. + * \return true iff update() was called + */ + bool paintTiles(); + + /* + * Paint the specified tile + * + * \pre Sufficient data is available to completely paint the tile, i.e. + * m_dataLength is greater than the upper bound of the tile. + */ + void paintTile(int index); + + /* + * Move the first n tiles to the end of the array, and mark them as not + * painted. + */ + void shuffleTiles(int n); + + /* + * Reset tile array + */ + void resetTiles(qint64 newStartPos); + +private: + const QByteArray& m_buffer; + qint64 m_dataLength; + qint64 m_position; + QAudioFormat m_format; + + bool m_active; + + QSize m_pixmapSize; + QVector<QPixmap*> m_pixmaps; + + struct Tile { + // Pointer into parent m_pixmaps array + QPixmap* pixmap; + + // Flag indicating whether this tile has been painted + bool painted; + }; + + QVector<Tile> m_tiles; + + // Length of audio data in bytes depicted by each tile + qint64 m_tileLength; + + // Position in bytes of the first tile, relative to m_buffer + qint64 m_tileArrayStart; + + qint64 m_windowPosition; + qint64 m_windowLength; + +}; + +#endif // WAVEFORM_H diff --git a/demos/spectrum/app/wavfile.cpp b/demos/spectrum/app/wavfile.cpp new file mode 100644 index 0000000..ec911ad --- /dev/null +++ b/demos/spectrum/app/wavfile.cpp @@ -0,0 +1,247 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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/qendian.h> +#include <QVector> +#include <QDebug> +#include "utils.h" +#include "wavfile.h" + +struct chunk +{ + char id[4]; + quint32 size; +}; + +struct RIFFHeader +{ + chunk descriptor; // "RIFF" + char type[4]; // "WAVE" +}; + +struct WAVEHeader +{ + chunk descriptor; + quint16 audioFormat; + quint16 numChannels; + quint32 sampleRate; + quint32 byteRate; + quint16 blockAlign; + quint16 bitsPerSample; +}; + +struct DATAHeader +{ + chunk descriptor; +}; + +struct CombinedHeader +{ + RIFFHeader riff; + WAVEHeader wave; + DATAHeader data; +}; + +static const int HeaderLength = sizeof(CombinedHeader); + + +WavFile::WavFile(const QAudioFormat &format, qint64 dataLength) + : m_format(format) + , m_dataLength(dataLength) +{ + +} + +bool WavFile::readHeader(QIODevice &device) +{ + bool result = true; + + if (!device.isSequential()) + result = device.seek(0); + // else, assume that current position is the start of the header + + if (result) { + CombinedHeader header; + result = (device.read(reinterpret_cast<char *>(&header), HeaderLength) == HeaderLength); + if (result) { + if ((memcmp(&header.riff.descriptor.id, "RIFF", 4) == 0 + || memcmp(&header.riff.descriptor.id, "RIFX", 4) == 0) + && memcmp(&header.riff.type, "WAVE", 4) == 0 + && memcmp(&header.wave.descriptor.id, "fmt ", 4) == 0 + && header.wave.audioFormat == 1 // PCM + ) { + if (memcmp(&header.riff.descriptor.id, "RIFF", 4) == 0) + m_format.setByteOrder(QAudioFormat::LittleEndian); + else + m_format.setByteOrder(QAudioFormat::BigEndian); + + m_format.setChannels(qFromLittleEndian<quint16>(header.wave.numChannels)); + m_format.setCodec("audio/pcm"); + m_format.setFrequency(qFromLittleEndian<quint32>(header.wave.sampleRate)); + m_format.setSampleSize(qFromLittleEndian<quint16>(header.wave.bitsPerSample)); + + switch(header.wave.bitsPerSample) { + case 8: + m_format.setSampleType(QAudioFormat::UnSignedInt); + break; + case 16: + m_format.setSampleType(QAudioFormat::SignedInt); + break; + default: + result = false; + } + + m_dataLength = device.size() - HeaderLength; + } else { + result = false; + } + } + } + + return result; +} + +bool WavFile::writeHeader(QIODevice &device) +{ + CombinedHeader header; + + memset(&header, 0, HeaderLength); + + // RIFF header + if (m_format.byteOrder() == QAudioFormat::LittleEndian) + strncpy(&header.riff.descriptor.id[0], "RIFF", 4); + else + strncpy(&header.riff.descriptor.id[0], "RIFX", 4); + qToLittleEndian<quint32>(quint32(m_dataLength + HeaderLength - 8), + reinterpret_cast<unsigned char*>(&header.riff.descriptor.size)); + strncpy(&header.riff.type[0], "WAVE", 4); + + // WAVE header + strncpy(&header.wave.descriptor.id[0], "fmt ", 4); + qToLittleEndian<quint32>(quint32(16), + reinterpret_cast<unsigned char*>(&header.wave.descriptor.size)); + qToLittleEndian<quint16>(quint16(1), + reinterpret_cast<unsigned char*>(&header.wave.audioFormat)); + qToLittleEndian<quint16>(quint16(m_format.channels()), + reinterpret_cast<unsigned char*>(&header.wave.numChannels)); + qToLittleEndian<quint32>(quint32(m_format.frequency()), + reinterpret_cast<unsigned char*>(&header.wave.sampleRate)); + qToLittleEndian<quint32>(quint32(m_format.frequency() * m_format.channels() * m_format.sampleSize() / 8), + reinterpret_cast<unsigned char*>(&header.wave.byteRate)); + qToLittleEndian<quint16>(quint16(m_format.channels() * m_format.sampleSize() / 8), + reinterpret_cast<unsigned char*>(&header.wave.blockAlign)); + qToLittleEndian<quint16>(quint16(m_format.sampleSize()), + reinterpret_cast<unsigned char*>(&header.wave.bitsPerSample)); + + // DATA header + strncpy(&header.data.descriptor.id[0], "data", 4); + qToLittleEndian<quint32>(quint32(m_dataLength), + reinterpret_cast<unsigned char*>(&header.data.descriptor.size)); + + return (device.write(reinterpret_cast<const char *>(&header), HeaderLength) == HeaderLength); +} + +const QAudioFormat& WavFile::format() const +{ + return m_format; +} + +qint64 WavFile::dataLength() const +{ + return m_dataLength; +} + +qint64 WavFile::headerLength() +{ + return HeaderLength; +} + +bool WavFile::writeDataLength(QIODevice &device, qint64 dataLength) +{ + bool result = false; + if (!device.isSequential()) { + device.seek(40); + unsigned char dataLengthLE[4]; + qToLittleEndian<quint32>(quint32(dataLength), dataLengthLE); + result = (device.write(reinterpret_cast<const char *>(dataLengthLE), 4) == 4); + } + return result; +} + +#include <QFile> +#include <QTextStream> + +qint64 WavFile::readData(QIODevice &device, QByteArray &buffer, + QAudioFormat outputFormat) +{ + if (QAudioFormat() == outputFormat) + outputFormat = m_format; + + qint64 result = 0; + + QFile file("wav.txt"); + file.open(QIODevice::WriteOnly | QIODevice::Text); + QTextStream stream; + stream.setDevice(&file); + + if (isPCMS16LE(outputFormat) && isPCMS16LE(m_format)) { + QVector<char> inputSample(2 * m_format.channels()); + + qint16 *output = reinterpret_cast<qint16*>(buffer.data()); + + while (result < buffer.size()) { + if (device.read(inputSample.data(), inputSample.count())) { + int inputIdx = 0; + for (int outputIdx = 0; outputIdx < outputFormat.channels(); ++outputIdx) { + const qint16* input = reinterpret_cast<const qint16*>(inputSample.data() + 2 * inputIdx); + *output++ = qFromLittleEndian<qint16>(*input); + result += 2; + if (inputIdx < m_format.channels()) + ++inputIdx; + } + } else { + break; + } + } + } + return result; +} + diff --git a/demos/spectrum/app/wavfile.h b/demos/spectrum/app/wavfile.h new file mode 100644 index 0000000..05866f7 --- /dev/null +++ b/demos/spectrum/app/wavfile.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** - Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** - Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** - Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +** POSSIBILITY OF SUCH DAMAGE. +** $QT_END_LICENSE$ +** +*****************************************************************************/ + + +#ifndef WAVFILE_H +#define WAVFILE_H + +#include <QtCore/qobject.h> +#include <QtCore/qfile.h> +#include <QtMultimedia/qaudioformat.h> + +/** + * Helper class for reading WAV files + * + * See https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ + */ +class WavFile +{ +public: + WavFile(const QAudioFormat &format = QAudioFormat(), + qint64 dataLength = 0); + + // Reads WAV header and seeks to start of data + bool readHeader(QIODevice &device); + + // Writes WAV header + bool writeHeader(QIODevice &device); + + // Read PCM data + qint64 readData(QIODevice &device, QByteArray &buffer, + QAudioFormat outputFormat = QAudioFormat()); + + const QAudioFormat& format() const; + qint64 dataLength() const; + + static qint64 headerLength(); + + static bool writeDataLength(QIODevice &device, qint64 dataLength); + +private: + QAudioFormat m_format; + qint64 m_dataLength; +}; + +#endif + diff --git a/demos/spectrum/spectrum.pri b/demos/spectrum/spectrum.pri new file mode 100644 index 0000000..c09aa0d --- /dev/null +++ b/demos/spectrum/spectrum.pri @@ -0,0 +1,37 @@ +# The following macros allow certain features and debugging output +# to be disabled / enabled at compile time. + +# Debug output from spectrum calculation +DEFINES += LOG_SPECTRUMANALYSER + +# Debug output from waveform generation +#DEFINES += LOG_WAVEFORM + +# Debug output from engine +DEFINES += LOG_ENGINE + +# Dump input data to spectrum analyer, plus artefact data files +#DEFINES += DUMP_SPECTRUMANALYSER + +# Dump captured audio data +#DEFINES += DUMP_CAPTURED_AUDIO + +# Disable calculation of level +#DEFINES += DISABLE_LEVEL + +# Disable calculation of frequency spectrum +# If this macro is defined, the FFTReal DLL will not be built +#DEFINES += DISABLE_FFT + +# Disables rendering of the waveform +#DEFINES += DISABLE_WAVEFORM + +# If defined, superimpose the progress bar on the waveform +DEFINES += SUPERIMPOSE_PROGRESS_ON_WAVEFORM + +# Perform spectrum analysis calculation in a separate thread +DEFINES += SPECTRUM_ANALYSER_SEPARATE_THREAD + +# Suppress warnings about strncpy potentially being unsafe, emitted by MSVC +win32: DEFINES += _CRT_SECURE_NO_WARNINGS + diff --git a/demos/spectrum/spectrum.pro b/demos/spectrum/spectrum.pro new file mode 100644 index 0000000..04bbdee --- /dev/null +++ b/demos/spectrum/spectrum.pro @@ -0,0 +1,37 @@ +load(data_caging_paths) +include(spectrum.pri) + +TEMPLATE = subdirs + +# Ensure that library is built before application +CONFIG += ordered + +!contains(DEFINES, DISABLE_FFT) { + SUBDIRS += 3rdparty/fftreal +} + +SUBDIRS += app + +TARGET = spectrum + +symbian { + # Create a 'make sis' rule which can be run from the top-level + + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + + # UID for the SIS file + TARGET.UID3 = 0xA000E3FA + + bin.sources = spectrum.exe + !contains(DEFINES, DISABLE_FFT) { + bin.sources += fftreal.dll + } + bin.path = /sys/bin + rsc.sources = $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/spectrum.rsc + rsc.path = $$APP_RESOURCE_DIR + mif.sources = $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/spectrum.mif + mif.path = $$APP_RESOURCE_DIR + reg_rsc.sources = $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/spectrum_reg.rsc + reg_rsc.path = $$REG_RESOURCE_IMPORT_DIR + DEPLOYMENT += bin rsc mif reg_rsc +} diff --git a/doc/doc.pri b/doc/doc.pri index 3d04049..3180a61 100644 --- a/doc/doc.pri +++ b/doc/doc.pri @@ -55,11 +55,11 @@ docs_zh_CN.commands = $$QT_ZH_CN_DOCUMENTATION # Install rules htmldocs.files = $$QT_BUILD_TREE/doc/html htmldocs.path = $$[QT_INSTALL_DOCS] -htmldocs.CONFIG += no_check_exist +htmldocs.CONFIG += no_check_exist directory qchdocs.files= $$QT_BUILD_TREE/doc/qch qchdocs.path = $$[QT_INSTALL_DOCS] -qchdocs.CONFIG += no_check_exist +qchdocs.CONFIG += no_check_exist directory docimages.files = $$QT_BUILD_TREE/doc/src/images docimages.path = $$[QT_INSTALL_DOCS]/src diff --git a/doc/src/howtos/openvg.qdoc b/doc/src/howtos/openvg.qdoc index f70ed54..e448d9c 100644 --- a/doc/src/howtos/openvg.qdoc +++ b/doc/src/howtos/openvg.qdoc @@ -172,8 +172,25 @@ \endlist The other members of QPainter::CompositionMode are not supported - because OpenVG 1.1 does not have an equivalent in its \c VGBlendMode - enumeration. Any attempt to set an unsupported mode will result in + unless the \c{VG_KHR_advanced_blending} extension is present, + in which case the following additional modes are supported: + + \list + \o QPainter::CompositionMode_Overlay + \o QPainter::CompositionMode_ColorDodge + \o QPainter::CompositionMode_ColorBurn + \o QPainter::CompositionMode_HardLight + \o QPainter::CompositionMode_SoftLight + \o QPainter::CompositionMode_Difference + \o QPainter::CompositionMode_Exclusion + \o QPainter::CompositionMode_SourceOut + \o QPainter::CompositionMode_DestinationOut + \o QPainter::CompositionMode_SourceAtop + \o QPainter::CompositionMode_DestinationAtop + \o QPainter::CompositionMode_Xor + \endlist + + Any attempt to set an unsupported mode will result in the actual mode being set to QPainter::CompositionMode_SourceOver. Client applications should avoid using unsupported modes. diff --git a/doc/src/platforms/emb-openvg.qdocinc b/doc/src/platforms/emb-openvg.qdocinc index 2f9cc21..579af67 100644 --- a/doc/src/platforms/emb-openvg.qdocinc +++ b/doc/src/platforms/emb-openvg.qdocinc @@ -135,8 +135,25 @@ transformations for non-image elements in performance critical code. \endlist The other members of QPainter::CompositionMode are not supported -because OpenVG 1.1 does not have an equivalent in its \c VGBlendMode -enumeration. Any attempt to set an unsupported mode will result in +unless the \c{VG_KHR_advanced_blending} extension is present, +in which case the following additional modes are supported: + +\list +\o QPainter::CompositionMode_Overlay +\o QPainter::CompositionMode_ColorDodge +\o QPainter::CompositionMode_ColorBurn +\o QPainter::CompositionMode_HardLight +\o QPainter::CompositionMode_SoftLight +\o QPainter::CompositionMode_Difference +\o QPainter::CompositionMode_Exclusion +\o QPainter::CompositionMode_SourceOut +\o QPainter::CompositionMode_DestinationOut +\o QPainter::CompositionMode_SourceAtop +\o QPainter::CompositionMode_DestinationAtop +\o QPainter::CompositionMode_Xor +\endlist + +Any attempt to set an unsupported mode will result in the actual mode being set to QPainter::CompositionMode_SourceOver. Client applications should avoid using unsupported modes. diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp index 7d09c38..1a7a7ee 100644 --- a/examples/multimedia/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audiodevices/audiodevices.cpp @@ -44,6 +44,40 @@ #include "audiodevices.h" +// Utility functions for converting QAudioFormat fields into text + +QString toString(QAudioFormat::SampleType sampleType) +{ + QString result("Unknown"); + switch (sampleType) { + case QAudioFormat::SignedInt: + result = "SignedInt"; + break; + case QAudioFormat::UnSignedInt: + result = "UnSignedInt"; + break; + case QAudioFormat::Float: + result = "Float"; + break; + } + return result; +} + +QString toString(QAudioFormat::Endian endian) +{ + QString result("Unknown"); + switch (endian) { + case QAudioFormat::LittleEndian: + result = "LittleEndian"; + break; + case QAudioFormat::BigEndian: + result = "BigEndian"; + break; + } + return result; +} + + AudioDevicesBase::AudioDevicesBase(QWidget *parent, Qt::WFlags f) : QMainWindow(parent, f) { @@ -67,6 +101,7 @@ AudioTest::AudioTest(QWidget *parent, Qt::WFlags f) connect(sampleSizesBox, SIGNAL(activated(int)), SLOT(sampleSizeChanged(int))); connect(sampleTypesBox, SIGNAL(activated(int)), SLOT(sampleTypeChanged(int))); connect(endianBox, SIGNAL(activated(int)), SLOT(endianChanged(int))); + connect(populateTableButton, SIGNAL(clicked()), SLOT(populateTable())); modeBox->setCurrentIndex(0); modeChanged(0); @@ -81,12 +116,11 @@ AudioTest::~AudioTest() void AudioTest::test() { // tries to set all the settings picked. - logOutput->clear(); - logOutput->append("NOTE: an invalid codec audio/test exists for testing, to get a fail condition."); + testResult->clear(); if (!deviceInfo.isNull()) { if (deviceInfo.isFormatSupported(settings)) { - logOutput->append(tr("Success")); + testResult->setText(tr("Success")); nearestFreq->setText(""); nearestChannel->setText(""); nearestCodec->setText(""); @@ -95,40 +129,23 @@ void AudioTest::test() nearestEndian->setText(""); } else { QAudioFormat nearest = deviceInfo.nearestFormat(settings); - logOutput->append(tr("Failed")); + testResult->setText(tr("Failed")); nearestFreq->setText(QString("%1").arg(nearest.frequency())); nearestChannel->setText(QString("%1").arg(nearest.channels())); nearestCodec->setText(nearest.codec()); nearestSampleSize->setText(QString("%1").arg(nearest.sampleSize())); - - switch(nearest.sampleType()) { - case QAudioFormat::SignedInt: - nearestSampleType->setText("SignedInt"); - break; - case QAudioFormat::UnSignedInt: - nearestSampleType->setText("UnSignedInt"); - break; - case QAudioFormat::Float: - nearestSampleType->setText("Float"); - break; - case QAudioFormat::Unknown: - nearestSampleType->setText("Unknown"); - } - switch(nearest.byteOrder()) { - case QAudioFormat::LittleEndian: - nearestEndian->setText("LittleEndian"); - break; - case QAudioFormat::BigEndian: - nearestEndian->setText("BigEndian"); - } + nearestSampleType->setText(toString(nearest.sampleType())); + nearestEndian->setText(toString(nearest.byteOrder())); } } else - logOutput->append(tr("No Device")); + testResult->setText(tr("No Device")); } void AudioTest::modeChanged(int idx) { + testResult->clear(); + // mode has changed if (idx == 0) mode = QAudio::AudioInput; @@ -138,10 +155,15 @@ void AudioTest::modeChanged(int idx) deviceBox->clear(); foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(mode)) deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); + + deviceBox->setCurrentIndex(0); + deviceChanged(0); } void AudioTest::deviceChanged(int idx) { + testResult->clear(); + if (deviceBox->count() == 0) return; @@ -180,38 +202,68 @@ void AudioTest::deviceChanged(int idx) sampleTypesBox->clear(); QList<QAudioFormat::SampleType> sampleTypez = deviceInfo.supportedSampleTypes(); - for (int i = 0; i < sampleTypez.size(); ++i) { - switch(sampleTypez.at(i)) { - case QAudioFormat::SignedInt: - sampleTypesBox->addItem("SignedInt"); - break; - case QAudioFormat::UnSignedInt: - sampleTypesBox->addItem("UnSignedInt"); - break; - case QAudioFormat::Float: - sampleTypesBox->addItem("Float"); - break; - case QAudioFormat::Unknown: - sampleTypesBox->addItem("Unknown"); - } - if (sampleTypez.size()) - settings.setSampleType(sampleTypez.at(0)); - } + + for (int i = 0; i < sampleTypez.size(); ++i) + sampleTypesBox->addItem(toString(sampleTypez.at(i))); + if (sampleTypez.size()) + settings.setSampleType(sampleTypez.at(0)); endianBox->clear(); QList<QAudioFormat::Endian> endianz = deviceInfo.supportedByteOrders(); - for (int i = 0; i < endianz.size(); ++i) { - switch (endianz.at(i)) { - case QAudioFormat::LittleEndian: - endianBox->addItem("Little Endian"); - break; - case QAudioFormat::BigEndian: - endianBox->addItem("Big Endian"); - break; - } - } + for (int i = 0; i < endianz.size(); ++i) + endianBox->addItem(toString(endianz.at(i))); if (endianz.size()) settings.setByteOrder(endianz.at(0)); + + allFormatsTable->clearContents(); +} + +void AudioTest::populateTable() +{ + int row = 0; + + QAudioFormat format; + foreach (QString codec, deviceInfo.supportedCodecs()) { + format.setCodec(codec); + foreach (int frequency, deviceInfo.supportedFrequencies()) { + format.setFrequency(frequency); + foreach (int channels, deviceInfo.supportedChannels()) { + format.setChannels(channels); + foreach (QAudioFormat::SampleType sampleType, deviceInfo.supportedSampleTypes()) { + format.setSampleType(sampleType); + foreach (int sampleSize, deviceInfo.supportedSampleSizes()) { + format.setSampleSize(sampleSize); + foreach (QAudioFormat::Endian endian, deviceInfo.supportedByteOrders()) { + format.setByteOrder(endian); + if (deviceInfo.isFormatSupported(format)) { + allFormatsTable->setRowCount(row + 1); + + QTableWidgetItem *codecItem = new QTableWidgetItem(format.codec()); + allFormatsTable->setItem(row, 0, codecItem); + + QTableWidgetItem *frequencyItem = new QTableWidgetItem(QString("%1").arg(format.frequency())); + allFormatsTable->setItem(row, 1, frequencyItem); + + QTableWidgetItem *channelsItem = new QTableWidgetItem(QString("%1").arg(format.channels())); + allFormatsTable->setItem(row, 2, channelsItem); + + QTableWidgetItem *sampleTypeItem = new QTableWidgetItem(toString(format.sampleType())); + allFormatsTable->setItem(row, 3, sampleTypeItem); + + QTableWidgetItem *sampleSizeItem = new QTableWidgetItem(QString("%1").arg(format.sampleSize())); + allFormatsTable->setItem(row, 4, sampleSizeItem); + + QTableWidgetItem *byteOrderItem = new QTableWidgetItem(toString(format.byteOrder())); + allFormatsTable->setItem(row, 5, byteOrderItem); + + ++row; + } + } + } + } + } + } + } } void AudioTest::freqChanged(int idx) diff --git a/examples/multimedia/audiodevices/audiodevices.h b/examples/multimedia/audiodevices/audiodevices.h index 15ace92..b5b5204 100644 --- a/examples/multimedia/audiodevices/audiodevices.h +++ b/examples/multimedia/audiodevices/audiodevices.h @@ -74,5 +74,7 @@ private slots: void sampleTypeChanged(int idx); void endianChanged(int idx); void test(); + void populateTable(); + }; diff --git a/examples/multimedia/audiodevices/audiodevicesbase.ui b/examples/multimedia/audiodevices/audiodevicesbase.ui index 667a6e5..23b45d7 100644 --- a/examples/multimedia/audiodevices/audiodevicesbase.ui +++ b/examples/multimedia/audiodevices/audiodevicesbase.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>320</width> - <height>300</height> + <width>679</width> + <height>598</height> </rect> </property> <property name="windowTitle"> @@ -30,58 +30,30 @@ <property name="geometry"> <rect> <x>0</x> - <y>-192</y> - <width>282</width> - <height>471</height> + <y>0</y> + <width>659</width> + <height>558</height> </rect> </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <layout class="QGridLayout" name="gridLayout"> + <layout class="QGridLayout" name="gridLayout_4"> + <item row="0" column="0"> + <layout class="QGridLayout" name="gridLayout_2"> <item row="0" column="0"> - <widget class="QLabel" name="deviceLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>1</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> + <widget class="QLabel" name="modeLabel"> <property name="text"> - <string>Device</string> + <string>Mode</string> </property> </widget> </item> <item row="0" column="1"> - <widget class="QLabel" name="modeLabel"> + <widget class="QLabel" name="deviceLabel"> <property name="text"> - <string>Mode</string> + <string>Device</string> </property> </widget> </item> <item row="1" column="0"> - <widget class="QComboBox" name="deviceBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>150</width> - <height>0</height> - </size> - </property> - </widget> - </item> - <item row="1" column="1"> <widget class="QComboBox" name="modeBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> <item> <property name="text"> <string>Input</string> @@ -94,203 +66,322 @@ </item> </widget> </item> - <item row="2" column="0"> - <widget class="QLabel" name="actualLabel"> - <property name="frameShape"> - <enum>QFrame::Panel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <property name="text"> - <string>Actual Settings</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLabel" name="nearestLabel"> - <property name="frameShape"> - <enum>QFrame::Panel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <property name="text"> - <string>Nearest Settings</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="actualFreqLabel"> - <property name="text"> - <string>Frequency</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLabel" name="nearestFreqLabel"> - <property name="text"> - <string>Frequency</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QComboBox" name="frequencyBox"/> - </item> - <item row="4" column="1"> - <widget class="QLineEdit" name="nearestFreq"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="actualChannelsLabel"> - <property name="text"> - <string>Channels</string> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QLabel" name="nearestChannelLabel"> - <property name="text"> - <string>Channel</string> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QComboBox" name="channelsBox"/> - </item> - <item row="6" column="1"> - <widget class="QLineEdit" name="nearestChannel"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="7" column="0"> - <widget class="QLabel" name="actualCodecLabel"> - <property name="text"> - <string>Codecs</string> - </property> - </widget> - </item> - <item row="7" column="1"> - <widget class="QLabel" name="nearestCodecLabel"> - <property name="text"> - <string>Codec</string> - </property> - </widget> - </item> - <item row="8" column="0"> - <widget class="QComboBox" name="codecsBox"/> - </item> - <item row="8" column="1"> - <widget class="QLineEdit" name="nearestCodec"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="9" column="0"> - <widget class="QLabel" name="actualSampleSizeLabel"> - <property name="text"> - <string>SampleSize</string> - </property> - </widget> - </item> - <item row="9" column="1"> - <widget class="QLabel" name="nearestSampleSizeLabel"> - <property name="text"> - <string>SampleSize</string> - </property> - </widget> - </item> - <item row="10" column="0"> - <widget class="QComboBox" name="sampleSizesBox"/> - </item> - <item row="10" column="1"> - <widget class="QLineEdit" name="nearestSampleSize"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="11" column="0"> - <widget class="QLabel" name="actualSampleTypeLabel"> - <property name="text"> - <string>SampleType</string> - </property> - </widget> - </item> - <item row="11" column="1"> - <widget class="QLabel" name="nearestSampleTypeLabel"> - <property name="text"> - <string>SampleType</string> - </property> - </widget> - </item> - <item row="12" column="0"> - <widget class="QComboBox" name="sampleTypesBox"/> - </item> - <item row="12" column="1"> - <widget class="QLineEdit" name="nearestSampleType"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="13" column="0"> - <widget class="QLabel" name="actualEndianLabel"> - <property name="text"> - <string>Endianess</string> - </property> - </widget> - </item> - <item row="13" column="1"> - <widget class="QLabel" name="nearestEndianLabel"> - <property name="text"> - <string>Endianess</string> - </property> - </widget> - </item> - <item row="14" column="0"> - <widget class="QComboBox" name="endianBox"/> - </item> - <item row="14" column="1"> - <widget class="QLineEdit" name="nearestEndian"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="15" column="0" colspan="2"> - <widget class="QTextEdit" name="logOutput"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="horizontalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOff</enum> - </property> - </widget> - </item> - <item row="16" column="0" colspan="2"> - <widget class="QPushButton" name="testButton"> - <property name="text"> - <string>Test</string> - </property> + <item row="1" column="1"> + <widget class="QComboBox" name="deviceBox"/> + </item> + <item row="2" column="0" colspan="2"> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="testFormatTab"> + <attribute name="title"> + <string>Test format</string> + </attribute> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="1"> + <widget class="QLabel" name="actualLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Plain</enum> + </property> + <property name="text"> + <string><i>Actual Settings</i></string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="nearestLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Plain</enum> + </property> + <property name="text"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Nearest Settings</span></p></body></html></string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QComboBox" name="frequencyBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QLineEdit" name="nearestFreq"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QComboBox" name="channelsBox"/> + </item> + <item row="5" column="2"> + <widget class="QLineEdit" name="nearestChannel"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="9" column="1"> + <widget class="QComboBox" name="sampleSizesBox"/> + </item> + <item row="9" column="2"> + <widget class="QLineEdit" name="nearestSampleSize"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="14" column="1"> + <widget class="QComboBox" name="endianBox"/> + </item> + <item row="14" column="2"> + <widget class="QLineEdit" name="nearestEndian"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="15" column="1"> + <widget class="QPushButton" name="testButton"> + <property name="text"> + <string>Test</string> + </property> + </widget> + </item> + <item row="15" column="2"> + <widget class="QLabel" name="testResult"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="actualFreqLabel"> + <property name="text"> + <string>Frequency (Hz)</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="actualChannelLabel"> + <property name="text"> + <string>Channels</string> + </property> + </widget> + </item> + <item row="9" column="0"> + <widget class="QLabel" name="actualSampleSizeLabel"> + <property name="text"> + <string>Sample size (bits)</string> + </property> + </widget> + </item> + <item row="14" column="0"> + <widget class="QLabel" name="actualEndianLabel"> + <property name="text"> + <string>Endianess</string> + </property> + </widget> + </item> + <item row="16" column="0" colspan="3"> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Note: an invalid codec 'audio/test' exists in order to allow an invalid format to be constructed, and therefore to trigger a 'nearest format' calculation.</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="actualCodecLabel"> + <property name="text"> + <string>Codec</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QLineEdit" name="nearestCodec"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="codecsBox"/> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="actualSampleTypeLabel"> + <property name="text"> + <string>SampleType</string> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QComboBox" name="sampleTypesBox"/> + </item> + <item row="6" column="2"> + <widget class="QLineEdit" name="nearestSampleType"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>All formats</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QPushButton" name="populateTableButton"> + <property name="text"> + <string>Populate table</string> + </property> + </widget> + </item> + <item> + <widget class="QTableWidget" name="allFormatsTable"> + <property name="editTriggers"> + <set>QAbstractItemView::NoEditTriggers</set> + </property> + <property name="dragDropOverwriteMode"> + <bool>false</bool> + </property> + <property name="selectionMode"> + <enum>QAbstractItemView::NoSelection</enum> + </property> + <property name="selectionBehavior"> + <enum>QAbstractItemView::SelectItems</enum> + </property> + <property name="textElideMode"> + <enum>Qt::ElideNone</enum> + </property> + <property name="sortingEnabled"> + <bool>false</bool> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="cornerButtonEnabled"> + <bool>false</bool> + </property> + <attribute name="horizontalHeaderHighlightSections"> + <bool>false</bool> + </attribute> + <attribute name="verticalHeaderVisible"> + <bool>false</bool> + </attribute> + <attribute name="verticalHeaderHighlightSections"> + <bool>false</bool> + </attribute> + <attribute name="verticalHeaderVisible"> + <bool>false</bool> + </attribute> + <attribute name="horizontalHeaderHighlightSections"> + <bool>false</bool> + </attribute> + <attribute name="verticalHeaderHighlightSections"> + <bool>false</bool> + </attribute> + <column> + <property name="text"> + <string>Codec</string> + </property> + <property name="textAlignment"> + <set>AlignHCenter|AlignVCenter|AlignCenter</set> + </property> + </column> + <column> + <property name="text"> + <string>Frequency (Hz)</string> + </property> + <property name="textAlignment"> + <set>AlignHCenter|AlignVCenter|AlignCenter</set> + </property> + </column> + <column> + <property name="text"> + <string>Channels</string> + </property> + <property name="textAlignment"> + <set>AlignHCenter|AlignVCenter|AlignCenter</set> + </property> + </column> + <column> + <property name="text"> + <string>Sample type</string> + </property> + <property name="textAlignment"> + <set>AlignHCenter|AlignVCenter|AlignCenter</set> + </property> + </column> + <column> + <property name="text"> + <string>Sample size (bits)</string> + </property> + <property name="textAlignment"> + <set>AlignHCenter|AlignVCenter|AlignCenter</set> + </property> + </column> + <column> + <property name="text"> + <string>Endianness</string> + </property> + <property name="textAlignment"> + <set>AlignHCenter|AlignVCenter|AlignCenter</set> + </property> + </column> + </widget> + </item> + </layout> + </widget> </widget> </item> </layout> diff --git a/examples/multimedia/audiodevices/main.cpp b/examples/multimedia/audiodevices/main.cpp index 0ea18a1..8ca4932 100644 --- a/examples/multimedia/audiodevices/main.cpp +++ b/examples/multimedia/audiodevices/main.cpp @@ -49,7 +49,11 @@ int main(int argv, char **args) app.setApplicationName("Audio Device Test"); AudioTest audio; +#ifdef Q_OS_SYMBIAN + audio.showMaximized(); +#else audio.show(); +#endif return app.exec(); } diff --git a/mkspecs/features/dbusadaptors.prf b/mkspecs/features/dbusadaptors.prf index 241ace6..17dffa5 100644 --- a/mkspecs/features/dbusadaptors.prf +++ b/mkspecs/features/dbusadaptors.prf @@ -1,7 +1,4 @@ -isEmpty(QMAKE_QDBUSXML2CPP) { - win32:QMAKE_QDBUSXML2CPP = $$[QT_INSTALL_BINS]\qdbusxml2cpp.exe - else:QMAKE_QDBUSXML2CPP = $$[QT_INSTALL_BINS]/qdbusxml2cpp -} +qtPrepareTool(QMAKE_QDBUSXML2CPP, qdbusxml2cpp) for(DBUS_ADAPTOR, $$list($$unique(DBUS_ADAPTORS))) { diff --git a/mkspecs/features/dbusinterfaces.prf b/mkspecs/features/dbusinterfaces.prf index c32597a..412e80f 100644 --- a/mkspecs/features/dbusinterfaces.prf +++ b/mkspecs/features/dbusinterfaces.prf @@ -1,9 +1,6 @@ load(moc) -isEmpty(QMAKE_QDBUSXML2CPP) { - win32:QMAKE_QDBUSXML2CPP = $$[QT_INSTALL_BINS]\qdbusxml2cpp.exe - else:QMAKE_QDBUSXML2CPP = $$[QT_INSTALL_BINS]/qdbusxml2cpp -} +qtPrepareTool(QMAKE_QDBUSXML2CPP, qdbusxml2cpp) for(DBUS_INTERFACE, $$list($$unique(DBUS_INTERFACES))) { diff --git a/mkspecs/features/moc.prf b/mkspecs/features/moc.prf index d12f5ad..e1032fd 100644 --- a/mkspecs/features/moc.prf +++ b/mkspecs/features/moc.prf @@ -1,9 +1,6 @@ #global defaults -isEmpty(QMAKE_MOC) { - contains(QMAKE_HOST.os,Windows):QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe - else:QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -} +qtPrepareTool(QMAKE_MOC, moc) isEmpty(MOC_DIR):MOC_DIR = . isEmpty(QMAKE_H_MOD_MOC):QMAKE_H_MOD_MOC = moc_ isEmpty(QMAKE_EXT_CPP_MOC):QMAKE_EXT_CPP_MOC = .moc diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 7b0b4af..62cce62 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -36,7 +36,7 @@ INCLUDEPATH = $$QMAKE_INCDIR_QT $$INCLUDEPATH #prepending prevents us from picki win32:INCLUDEPATH += $$QMAKE_INCDIR_QT/ActiveQt # As order does matter for static libs, we reorder the QT variable here -TMPLIBS = declarative webkit phonon mediaservices multimedia dbus testlib script scripttools svg qt3support sql xmlpatterns xml egl opengl openvg gui network core +TMPLIBS = declarative webkit phonon multimedia dbus testlib script scripttools svg qt3support sql xmlpatterns xml egl opengl openvg gui network core for(QTLIB, $$list($$TMPLIBS)) { contains(QT, $$QTLIB): QT_ORDERED += $$QTLIB } @@ -175,7 +175,6 @@ for(QTLIB, $$list($$lower($$unique(QT)))) { } } else:isEqual(QTLIB, declarative):qlib = QtDeclarative else:isEqual(QTLIB, multimedia):qlib = QtMultimedia - else:isEqual(QTLIB, mediaservices):qlib = QtMediaServices else:message("Unknown QT: $$QTLIB"):qlib = !isEmpty(qlib) { target_qt:isEqual(TARGET, qlib) { diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 1be6d9b..a49c1a6 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -78,3 +78,14 @@ defineTest(qtAddLibrary) { export(QMAKE_LFLAGS) return(true) } + +# variable, default +defineTest(qtPrepareTool) { + isEmpty($$1) { + !isEmpty(QT_BUILD_TREE):$$1 = $$QT_BUILD_TREE/bin/$$2 + else:$$1 = $$[QT_INSTALL_BINS]/$$2 + } + $$1 ~= s,[/\\\\],$$QMAKE_DIR_SEP, + contains(QMAKE_HOST.os, Windows):!contains($$1, .*\\.exe$):$$1 = $$eval($$1).exe + export($$1) +} diff --git a/mkspecs/features/resources.prf b/mkspecs/features/resources.prf index eb33aab..5d00a4d 100644 --- a/mkspecs/features/resources.prf +++ b/mkspecs/features/resources.prf @@ -1,7 +1,4 @@ -isEmpty(QMAKE_RCC) { - win32:QMAKE_RCC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}rcc.exe - else:QMAKE_RCC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}rcc -} +qtPrepareTool(QMAKE_RCC, rcc) isEmpty(RCC_DIR):RCC_DIR = . isEmpty(QMAKE_RESOURCE_PREFIX):QMAKE_RESOURCE_PREFIX = /tmp/ diff --git a/mkspecs/features/uic.prf b/mkspecs/features/uic.prf index 8ebe0ea..d108f24 100644 --- a/mkspecs/features/uic.prf +++ b/mkspecs/features/uic.prf @@ -1,13 +1,5 @@ - -isEmpty(QMAKE_UIC3) { - contains(QMAKE_HOST.os,Windows):QMAKE_UIC3 = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic3.exe - else:QMAKE_UIC3 = $$[QT_INSTALL_BINS]/uic3 -} - -isEmpty(QMAKE_UIC) { - contains(QMAKE_HOST.os,Windows):QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe - else:QMAKE_UIC = $$[QT_INSTALL_BINS]/uic -} +qtPrepareTool(QMAKE_UIC3, uic3) +qtPrepareTool(QMAKE_UIC, uic) isEmpty(UI_DIR):UI_DIR = . isEmpty(UI_SOURCES_DIR):UI_SOURCES_DIR = $$UI_DIR diff --git a/mkspecs/features/win32/qaxcontainer.prf b/mkspecs/features/win32/qaxcontainer.prf index 49edb2a..34c6dfe 100644 --- a/mkspecs/features/win32/qaxcontainer.prf +++ b/mkspecs/features/win32/qaxcontainer.prf @@ -8,9 +8,7 @@ LIBS += -lQAxContainer } -isEmpty(QMAKE_DUMPCPP) { - win32:QMAKE_DUMPCPP = $$[QT_INSTALL_BINS]\dumpcpp.exe -} +qtPrepareTool(QMAKE_DUMPCPP, dumpcpp) dumpcpp_decl.commands = $$QMAKE_DUMPCPP ${QMAKE_FILE_IN} -o ${QMAKE_FILE_BASE} qaxcontainer_compat: dumpcpp_decl.commands += -compat diff --git a/mkspecs/features/win32/qaxserver.prf b/mkspecs/features/win32/qaxserver.prf index a18c421..1ff6825 100644 --- a/mkspecs/features/win32/qaxserver.prf +++ b/mkspecs/features/win32/qaxserver.prf @@ -14,7 +14,8 @@ equals(TEMPLATE, "vcapp"):ACTIVEQT_IDE = VisualStudio equals(TEMPLATE, "vclib"):ACTIVEQT_IDE = VisualStudio equals(ACTIVEQT_IDE, "VisualStudio") { - ACTIVEQT_IDC = $${QMAKE_IDC} + ACTIVEQT_IDC = $${QMAKE_IDC} ### Qt5: remove me + qtPrepareTool(ACTIVEQT_IDC, idc) ACTIVEQT_IDL = $${QMAKE_IDL} ACTIVEQT_TARGET = "$(TargetPath)" win32-msvc { diff --git a/mkspecs/win32-g++/qmake.conf b/mkspecs/win32-g++/qmake.conf index b282f69..8881d02 100644 --- a/mkspecs/win32-g++/qmake.conf +++ b/mkspecs/win32-g++/qmake.conf @@ -75,6 +75,7 @@ QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqtmain !isEmpty(QMAKE_SH) { MINGW_IN_SHELL = 1 QMAKE_DIR_SEP = / + QMAKE_QMAKE ~= s,\\\\,/, QMAKE_COPY = cp QMAKE_COPY_DIR = xcopy /s /q /y /i QMAKE_MOVE = mv diff --git a/projects.pro b/projects.pro index fc7db1d..45fb8da 100644 --- a/projects.pro +++ b/projects.pro @@ -165,6 +165,10 @@ unix { DEFAULT_QMAKESPEC ~= s,^.*mkspecs/,,g mkspecs.commands += $(DEL_FILE) $(INSTALL_ROOT)$$mkspecs.path/default; $(SYMLINK) $$DEFAULT_QMAKESPEC $(INSTALL_ROOT)$$mkspecs.path/default } +win32:!equals(QT_BUILD_TREE, $$QT_SOURCE_TREE) { + # When shadow building on Windows, the default mkspec only exists in the build tree. + mkspecs.files += $$QT_BUILD_TREE/mkspecs/default +} INSTALLS += mkspecs false:macx { #mac install location diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 29a2422..4c4f5bc 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1236,7 +1236,7 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs, bool n target += "\n"; do_default = false; for(QStringList::Iterator wild_it = tmp.begin(); wild_it != tmp.end(); ++wild_it) { - QString wild = Option::fixPathToLocalOS((*wild_it), false, false); + QString wild = Option::fixPathToTargetOS((*wild_it), false, false); QString dirstr = qmake_getpwd(), filestr = wild; int slsh = filestr.lastIndexOf(Option::dir_sep); if(slsh != -1) { @@ -1277,13 +1277,26 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs, bool n } QString local_dirstr = Option::fixPathToLocalOS(dirstr, true); QStringList files = QDir(local_dirstr).entryList(QStringList(filestr)); - if(project->values((*it) + ".CONFIG").indexOf("no_check_exist") != -1 && files.isEmpty()) { + const QStringList &installConfigValues = project->values((*it) + ".CONFIG"); + if (installConfigValues.contains("no_check_exist") && files.isEmpty()) { if(!target.isEmpty()) target += "\t"; QString dst_file = filePrefixRoot(root, dst); QFileInfo fi(fileInfo(wild)); - QString cmd = QString(fi.isExecutable() ? "-$(INSTALL_PROGRAM)" : "-$(INSTALL_FILE)") + " " + - wild + " " + dst_file + "\n"; + QString cmd; + if (installConfigValues.contains("directory")) { + cmd = QLatin1String("-$(INSTALL_DIR)"); + if (!dst_file.endsWith(Option::dir_sep)) + dst_file += Option::dir_sep; + dst_file += fi.fileName(); + } else if (installConfigValues.contains("executable")) { + cmd = QLatin1String("-$(INSTALL_PROGRAM)"); + } else if (installConfigValues.contains("data")) { + cmd = QLatin1String("-$(INSTALL_FILE)"); + } else { + cmd = QString(fi.isExecutable() ? "-$(INSTALL_PROGRAM)" : "-$(INSTALL_FILE)"); + } + cmd += " " + wild + " " + dst_file + "\n"; target += cmd; if(!uninst.isEmpty()) uninst.append("\n\t"); diff --git a/src/3rdparty/phonon/qt7/audiodevice.mm b/src/3rdparty/phonon/qt7/audiodevice.mm index 6bec62d..3aae0ee4 100644 --- a/src/3rdparty/phonon/qt7/audiodevice.mm +++ b/src/3rdparty/phonon/qt7/audiodevice.mm @@ -149,7 +149,6 @@ QString AudioDevice::deviceSourceName(AudioDeviceID deviceID) size = sizeof(translation); err = AudioDeviceGetProperty(deviceID, 0, 0, kAudioDevicePropertyDataSourceNameForIDCFString, &size, &translation); if (err != noErr){ - CFRelease(cfName); return QString(); } QString name = PhononCFString::toQString(cfName); diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 8359637..3118f8f 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1243,11 +1243,6 @@ class QDataStream; # else # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT # endif -# if defined(QT_BUILD_MEDIASERVICES_LIB) -# define Q_MEDIASERVICES_EXPORT Q_DECL_EXPORT -# else -# define Q_MEDIASERVICES_EXPORT Q_DECL_IMPORT -# endif # if defined(QT_BUILD_OPENVG_LIB) # define Q_OPENVG_EXPORT Q_DECL_EXPORT # else @@ -1294,7 +1289,6 @@ class QDataStream; # define Q_CANVAS_EXPORT Q_DECL_IMPORT # define Q_OPENGL_EXPORT Q_DECL_IMPORT # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT -# define Q_MEDIASERVICES_EXPORT Q_DECL_IMPORT # define Q_OPENVG_EXPORT Q_DECL_IMPORT # define Q_XML_EXPORT Q_DECL_IMPORT # define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT @@ -1323,7 +1317,6 @@ class QDataStream; # define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT # define Q_OPENGL_EXPORT Q_DECL_EXPORT # define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT -# define Q_MEDIASERVICES_EXPORT Q_DECL_EXPORT # define Q_OPENVG_EXPORT Q_DECL_EXPORT # define Q_XML_EXPORT Q_DECL_EXPORT # define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT @@ -1339,7 +1332,6 @@ class QDataStream; # define Q_DECLARATIVE_EXPORT # define Q_OPENGL_EXPORT # define Q_MULTIMEDIA_EXPORT -# define Q_MEDIASERVICES_EXPORT # define Q_XML_EXPORT # define Q_XMLPATTERNS_EXPORT # define Q_SCRIPT_EXPORT diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index d4b8b5f..79a8ce4 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -345,6 +345,7 @@ public: bool hasQuery; bool hasFragment; bool isValid; + bool isHostValid; char valueDelimiter; char pairDelimiter; @@ -3138,10 +3139,11 @@ static void toPunycodeHelper(const QChar *s, int ucLength, QString *output) static const char * const idn_whitelist[] = { - "ac", "at", - "br", + "ac", "ar", "at", + "biz", "br", "cat", "ch", "cl", "cn", "de", "dk", + "es", "fi", "gr", "hu", @@ -3155,6 +3157,9 @@ static const char * const idn_whitelist[] = { "se", "sh", "th", "tm", "tw", "vn", + "xn--mgbaam7a8h", // UAE + "xn--mgberp4a5d4ar", // Saudi Arabia + "xn--wgbh1c" // Egypt }; static QStringList *user_idn_whitelist = 0; @@ -3313,6 +3318,7 @@ static QString qt_ACE_do(const QString &domain, AceOperation op) qt_nameprep(&result, prevLen); labelLength = result.length() - prevLen; register int toReserve = labelLength + 4 + 6; // "xn--" plus some extra bytes + aceForm.resize(0); if (toReserve > aceForm.capacity()) aceForm.reserve(toReserve); toPunycodeHelper(result.constData() + prevLen, result.size() - prevLen, &aceForm); @@ -3349,6 +3355,7 @@ QUrlPrivate::QUrlPrivate() ref = 1; port = -1; isValid = false; + isHostValid = true; parsingMode = QUrl::TolerantMode; valueDelimiter = '='; pairDelimiter = '&'; @@ -3375,6 +3382,7 @@ QUrlPrivate::QUrlPrivate(const QUrlPrivate ©) hasQuery(copy.hasQuery), hasFragment(copy.hasFragment), isValid(copy.isValid), + isHostValid(copy.isHostValid), valueDelimiter(copy.valueDelimiter), pairDelimiter(copy.pairDelimiter), stateFlags(copy.stateFlags), @@ -3405,6 +3413,8 @@ QString QUrlPrivate::canonicalHost() const that->host = host.toLower(); } else { that->host = qt_ACE_do(host, NormalizeAce); + if (that->host.isNull()) + that->isHostValid = false; } return that->host; } @@ -3481,6 +3491,7 @@ QString QUrlPrivate::authority(QUrl::FormattingOptions options) const void QUrlPrivate::setAuthority(const QString &auth) { + isHostValid = true; if (auth.isEmpty()) { setUserInfo(QString()); host.clear(); @@ -4175,7 +4186,7 @@ bool QUrl::isValid() const if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Validated)) d->validate(); - return d->isValid; + return d->isValid && d->isHostValid; } /*! @@ -4427,7 +4438,6 @@ void QUrl::setAuthority(const QString &authority) if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); detach(); QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized); - d->setAuthority(authority); } @@ -4648,6 +4658,7 @@ void QUrl::setHost(const QString &host) if (!d) d = new QUrlPrivate; if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); detach(); + d->isHostValid = true; QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized | QUrlPrivate::HostCanonicalized); d->host = host; diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 687a6d9..33775d2 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -47,6 +47,8 @@ #include <unistd.h> #include <errno.h> +#include <net/if.h> + QT_BEGIN_NAMESPACE #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS @@ -569,13 +571,17 @@ void QSelectThread::updateActivatedNotifiers(QSocketNotifier::Type type, fd_set * check if socket is in exception set * then signal RequestComplete for it */ - qWarning("exception on %d [will close the socket handle - hack]", i.key()->socket()); + qWarning("exception on %d [will do setdefaultif(0) - hack]", i.key()->socket()); // quick fix; there is a bug // when doing read on socket // errors not preoperly mapped // after offline-ing the device // on some devices we do get exception - ::close(i.key()->socket()); + // close all exiting sockets + // and reset default IAP + if(::setdefaultif(0) != KErrNone) // well we can't do much about it + qWarning("setdefaultif(0) failed"); + toRemove.append(i.key()); TRequestStatus *status = i.value(); QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone); diff --git a/src/corelib/kernel/qfunctions_wince.cpp b/src/corelib/kernel/qfunctions_wince.cpp index 8ad6126..e58feb3 100644 --- a/src/corelib/kernel/qfunctions_wince.cpp +++ b/src/corelib/kernel/qfunctions_wince.cpp @@ -352,16 +352,18 @@ void *qt_wince_bsearch(const void *key, size_t low = 0; size_t high = num - 1; while (low <= high) { - unsigned int mid = ((unsigned) (low + high)) >> 1; + size_t mid = (low + high) >> 1; int c = compare(key, (char*)base + mid * size); - if (c < 0) + if (c < 0) { + if (!mid) + break; high = mid - 1; - else if (c > 0) + } else if (c > 0) low = mid + 1; else return (char*) base + mid * size; } - return (NULL); + return 0; } void *lfind(const void* key, const void* base, size_t* elements, size_t size, diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index 6e36dcd..1777ba9 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -140,7 +140,7 @@ static const symbianToISO symbian_to_iso_list[] = { { ELangBrazilianPortuguese, "pt_BR" }, { ELangRomanian, "ro_RO" }, { ELangSerbian, "sr_RS" }, - { ELangLatinAmericanSpanish, "es" }, + { ELangLatinAmericanSpanish,"es_MX" }, // TODO: should be es_419 { ELangUkrainian, "uk_UA" }, { ELangUrdu, "ur_PK" }, // India/Pakistan { ELangVietnamese, "vi_VN" }, diff --git a/src/dbus/qdbusmacros.h b/src/dbus/qdbusmacros.h index 77122fc..693a350 100644 --- a/src/dbus/qdbusmacros.h +++ b/src/dbus/qdbusmacros.h @@ -48,8 +48,10 @@ #if defined(QDBUS_MAKEDLL) # define QDBUS_EXPORT Q_DECL_EXPORT -#else +#elif defined(QT_SHARED) # define QDBUS_EXPORT Q_DECL_IMPORT +#else +# define QDBUS_EXPORT #endif #ifndef Q_MOC_RUN diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp index e3c62be..5d0bcac 100644 --- a/src/gui/dialogs/qprintdialog_unix.cpp +++ b/src/gui/dialogs/qprintdialog_unix.cpp @@ -973,7 +973,7 @@ void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) void QUnixPrintWidgetPrivate::setCupsProperties() { - if (cups && QCUPSSupport::isAvailable()) { + if (cups && QCUPSSupport::isAvailable() && cups->pageSizes()) { QPrintEngine *engine = printer->printEngine(); const ppd_option_t* pageSizes = cups->pageSizes(); QByteArray cupsPageSize; diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 5e0d46f..fd128b8 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3656,6 +3656,8 @@ void QGraphicsItem::setPos(const QPointF &pos) // Update and repositition. if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) { d_ptr->setPosHelper(pos); + if (d_ptr->isWidget) + static_cast<QGraphicsWidget *>(this)->d_func()->setGeometryFromSetPos(); return; } diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 478c0c3..c486c45 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -1096,13 +1096,7 @@ QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant & } break; case ItemPositionHasChanged: - if (!d->inSetGeometry) { - d->inSetPos = 1; - // Ensure setGeometry is called (avoid recursion when setPos is - // called from within setGeometry). - setGeometry(QRectF(pos(), size())); - d->inSetPos = 0 ; - } + d->setGeometryFromSetPos(); break; case ItemParentChange: { // Deliver ParentAboutToChange. diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp index 50b315a..076e8626 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.cpp +++ b/src/gui/graphicsview/qgraphicswidget_p.cpp @@ -879,6 +879,18 @@ void QGraphicsWidgetPrivate::resetHeight() q->setGeometry(QRectF(q->x(), q->y(), width(), 0)); } +void QGraphicsWidgetPrivate::setGeometryFromSetPos() +{ + if (inSetGeometry) + return; + Q_Q(QGraphicsWidget); + inSetPos = 1; + // Ensure setGeometry is called (avoid recursion when setPos is + // called from within setGeometry). + q->setGeometry(QRectF(pos, q->size())); + inSetPos = 0 ; +} + QT_END_NAMESPACE #endif //QT_NO_GRAPHICSVIEW diff --git a/src/gui/graphicsview/qgraphicswidget_p.h b/src/gui/graphicsview/qgraphicswidget_p.h index 7116a23..e9e6fc2 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.h +++ b/src/gui/graphicsview/qgraphicswidget_p.h @@ -139,6 +139,7 @@ public: qreal height() const; void setHeight(qreal); void resetHeight(); + void setGeometryFromSetPos(); // State inline int attributeToBitIndex(Qt::WidgetAttribute att) const diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 610ac3c..d081cfd 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -484,9 +484,10 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) void QCoeFepInputContext::applyFormat(QList<QInputMethodEvent::Attribute> *attributes) { TCharFormat cFormat; - QColor styleTextColor = QApplication::palette("QLineEdit").text().color(); - TLogicalRgb tontColor(TRgb(styleTextColor.red(), styleTextColor.green(), styleTextColor.blue(), styleTextColor.alpha())); - cFormat.iFontPresentation.iTextColor = tontColor; + const QColor styleTextColor = focusWidget() ? focusWidget()->palette().text().color() : + QApplication::palette("QLineEdit").text().color(); + const TLogicalRgb fontColor(TRgb(styleTextColor.red(), styleTextColor.green(), styleTextColor.blue(), styleTextColor.alpha())); + cFormat.iFontPresentation.iTextColor = fontColor; TInt numChars = 0; TInt charPos = 0; diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 97fd6e1..6d4562a 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -1785,7 +1785,10 @@ void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event) emit clicked(index); if (edited) return; - if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this)) + QStyleOptionViewItemV4 option = d->viewOptionsV4(); + if (d->pressedAlreadySelected) + option.state |= QStyle::State_Selected; + if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, &option, this)) emit activated(index); } } diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 50b9759..60fc5e1 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -2477,7 +2477,7 @@ extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wPa QApplication::postEvent(widget, new QEvent(QEvent::Close)); else #ifndef QT_NO_MENUBAR - QMenuBar::wceCommands(LOWORD(wParam), (HWND) lParam); + QMenuBar::wceCommands(LOWORD(wParam)); #endif result = true; } diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index a0429d3..02e7cb8 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -387,7 +387,6 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de | EPointerFilterMove | EPointerFilterDrag, 0); drawableWindow->EnableVisibilityChangeEvents(); - s60UpdateIsOpaque(); } q->setAttribute(Qt::WA_WState_Created); @@ -400,6 +399,9 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de // this generates a WinIdChanged event. setWinId(control.take()); + if (!desktop) + s60UpdateIsOpaque(); // must be called after setWinId() + } else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create native child widget QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) ); diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 898a996..596649e 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5977,12 +5977,17 @@ void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justif gf.glyphs = engine.shapedGlyphs(&si); gf.chars = engine.layoutData->string.unicode() + si.position; gf.num_chars = engine.length(item); - gf.width = si.width; + if (engine.forceJustification) { + for (int j=0; j<gf.glyphs.numGlyphs; ++j) + gf.width += gf.glyphs.effectiveAdvance(j); + } else { + gf.width = si.width; + } gf.logClusters = engine.logClusters(&si); drawTextItem(QPointF(x.toReal(), p.y()), gf); - x += si.width; + x += gf.width; } } diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 44049c0..6e02435 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -971,12 +971,17 @@ void QPdfBaseEngine::drawPoints (const QPointF *points, int pointCount) if (!points) return; + Q_D(QPdfBaseEngine); QPainterPath p; for (int i=0; i!=pointCount;++i) { p.moveTo(points[i]); p.lineTo(points[i] + QPointF(0, 0.001)); } + + bool hadBrush = d->hasBrush; + d->hasBrush = false; drawPath(p); + d->hasBrush = hadBrush; } void QPdfBaseEngine::drawLines (const QLineF *lines, int lineCount) @@ -984,12 +989,16 @@ void QPdfBaseEngine::drawLines (const QLineF *lines, int lineCount) if (!lines) return; + Q_D(QPdfBaseEngine); QPainterPath p; for (int i=0; i!=lineCount;++i) { p.moveTo(lines[i].p1()); p.lineTo(lines[i].p2()); } + bool hadBrush = d->hasBrush; + d->hasBrush = false; drawPath(p); + d->hasBrush = hadBrush; } void QPdfBaseEngine::drawRects (const QRectF *rects, int rectCount) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 20297ae..d28e1d9 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -92,10 +92,10 @@ static const qreal goldenRatio = 1.618; const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { // *** generated layout data *** -{240,320,1,18,"QVGA Landscape"}, -{320,240,1,18,"QVGA Portrait"}, -{360,640,1,18,"NHD Landscape"}, -{640,360,1,18,"NHD Portrait"}, +{240,320,1,19,"QVGA Landscape"}, +{320,240,1,19,"QVGA Portrait"}, +{360,640,1,19,"NHD Landscape"}, +{640,360,1,19,"NHD Portrait"}, {352,800,1,12,"E90 Landscape"} // *** End of generated data *** }; @@ -104,11 +104,11 @@ const int QS60StylePrivate::m_numberOfLayouts = const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { // *** generated pixel metrics *** -{5,0,-909,0,0,2,0,0,-1,7,12,19,13,13,6,200,-909,-909,-909,20,13,2,0,0,21,7,18,30,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1, 106}, -{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,28,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1, 106}, -{7,0,-909,0,0,2,0,0,-1,25,69,28,19,19,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,44,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,13,13,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1, 135}, -{7,0,-909,0,0,2,0,0,-1,25,68,28,19,19,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,52,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,12,12,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1, 135}, -{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,30,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1, 106} +{5,0,-909,0,0,2,0,0,-1,7,12,22,15,15,7,198,-909,-909,-909,20,13,2,0,0,21,7,18,30,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1,106}, +{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,28,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1,106}, +{7,0,-909,0,0,2,0,0,-1,25,69,46,37,37,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,44,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,13,13,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135}, +{7,0,-909,0,0,2,0,0,-1,25,68,46,37,37,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,52,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,12,12,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135}, +{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,30,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1,106} // *** End of generated data *** }; @@ -653,6 +653,8 @@ void QS60StylePrivate::setFont(QWidget *widget) const fontCategory = QS60StyleEnums::FC_Primary; } else if (qobject_cast<QMenu *>(widget)){ fontCategory = QS60StyleEnums::FC_Primary; + } else if (qobject_cast<QCalendarWidget *>(widget)){ + fontCategory = QS60StyleEnums::FC_Secondary; } if (fontCategory != QS60StyleEnums::FC_Undefined) { const bool resolveFontSize = widget->testAttribute(Qt::WA_SetFont) @@ -813,12 +815,6 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const widgetPalette.setColor(QPalette::HighlightedText, s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); QApplication::setPalette(widgetPalette, "QLineEdit"); - widgetPalette = *palette; - - widgetPalette.setColor(QPalette::Text, - s60Color(QS60StyleEnums::CL_QsnTextColors, 27, 0)); - widgetPalette.setColor(QPalette::HighlightedText, - s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); QApplication::setPalette(widgetPalette, "QTextEdit"); widgetPalette = *palette; @@ -880,7 +876,6 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag case QS60StyleEnums::SP_QgnGrafNsliderEndLeft: case QS60StyleEnums::SP_QgnGrafNsliderEndRight: case QS60StyleEnums::SP_QgnGrafNsliderMiddle: - result.setWidth(result.height() >> 1); break; case QS60StyleEnums::SP_QgnGrafNsliderMarker: @@ -1120,11 +1115,9 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom tool.rect = button.unite(menuRect); tool.state = bflags; const QToolButton *toolButtonWidget = qobject_cast<const QToolButton *>(widget); - QS60StylePrivate::SkinElements element; - if (toolButtonWidget) - element = (toolButtonWidget->isDown()) ? QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; - else - element = (option->state & State_Sunken) ? QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; + const QS60StylePrivate::SkinElements element = + ((toolButtonWidget && toolButtonWidget->isDown()) || (option->state & State_Sunken)) ? + QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; QS60StylePrivate::drawSkinElement(element, painter, tool.rect, flags); drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); } @@ -1534,13 +1527,13 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QS60StylePrivate::SE_TabBarTabNorthInactive; break; } - if (skinElement==QS60StylePrivate::SE_TabBarTabEastInactive|| - skinElement==QS60StylePrivate::SE_TabBarTabNorthInactive|| - skinElement==QS60StylePrivate::SE_TabBarTabSouthInactive|| - skinElement==QS60StylePrivate::SE_TabBarTabWestInactive|| - skinElement==QS60StylePrivate::SE_TabBarTabEastActive|| - skinElement==QS60StylePrivate::SE_TabBarTabNorthActive|| - skinElement==QS60StylePrivate::SE_TabBarTabSouthActive|| + if (skinElement == QS60StylePrivate::SE_TabBarTabEastInactive || + skinElement == QS60StylePrivate::SE_TabBarTabNorthInactive || + skinElement == QS60StylePrivate::SE_TabBarTabSouthInactive || + skinElement == QS60StylePrivate::SE_TabBarTabWestInactive || + skinElement == QS60StylePrivate::SE_TabBarTabEastActive || + skinElement == QS60StylePrivate::SE_TabBarTabNorthActive || + skinElement == QS60StylePrivate::SE_TabBarTabSouthActive || skinElement==QS60StylePrivate::SE_TabBarTabWestActive) { const int borderThickness = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); @@ -2052,16 +2045,17 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti case PE_FrameFocusRect: { //Draw themed highlight to radiobuttons and checkboxes. //For other widgets skip, unless palette has been modified. In that case, draw with commonstyle. - if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) + if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) { if ((qstyleoption_cast<const QStyleOptionFocusRect *>(option) && (qobject_cast<const QRadioButton *>(widget) || qobject_cast<const QCheckBox *>(widget)))) QS60StylePrivate::drawSkinElement( QS60StylePrivate::isWidgetPressed(widget) ? QS60StylePrivate::SE_ListItemPressed : QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); - else + } else { commonStyleDraws = true; } + } break; #ifndef QT_NO_LINEEDIT case PE_PanelLineEdit: @@ -2361,41 +2355,43 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti #endif QCommonStyle::drawPrimitive(element, option, painter, widget); } else { - const bool rightLine = option->state & State_Item; - const bool downLine = option->state & State_Sibling; - const bool upLine = option->state & (State_Open | State_Children | State_Item | State_Sibling); - - QS60StyleEnums::SkinParts skinPart; - bool drawSkinPart = false; - if (rightLine && downLine && upLine) { - skinPart = QS60StyleEnums::SP_QgnIndiHlLineBranch; - drawSkinPart = true; - } else if (rightLine && upLine) { - skinPart = QS60StyleEnums::SP_QgnIndiHlLineEnd; - drawSkinPart = true; - } else if (upLine && downLine) { - skinPart = QS60StyleEnums::SP_QgnIndiHlLineStraight; - drawSkinPart = true; - } - - if (drawSkinPart) - QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); + if (const QStyleOptionViewItemV2 *vopt = qstyleoption_cast<const QStyleOptionViewItemV2 *>(option)) { + const bool rightLine = option->state & State_Item; + const bool downLine = option->state & State_Sibling; + const bool upLine = option->state & (State_Open | State_Children | State_Item | State_Sibling); + QS60StylePrivate::SkinElementFlags adjustedFlags = flags; + + QS60StyleEnums::SkinParts skinPart; + bool drawSkinPart = false; + if (rightLine && downLine && upLine) { + skinPart = QS60StyleEnums::SP_QgnIndiHlLineBranch; + drawSkinPart = true; + } else if (rightLine && upLine) { + skinPart = QS60StyleEnums::SP_QgnIndiHlLineEnd; + drawSkinPart = true; + } else if (upLine && downLine) { + skinPart = QS60StyleEnums::SP_QgnIndiHlLineStraight; + drawSkinPart = true; + } - if (option->state & State_Children) { - QS60StyleEnums::SkinParts skinPart = - (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; - int minDimension = qMin(option->rect.width(), option->rect.height()); - QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension)); - const int magicTweak = 3; - int resizeValue = minDimension >> 1; - if (!QS60StylePrivate::isTouchSupported()) { - minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. - iconRect.setSize(QSize(minDimension, minDimension)); - const int verticalMagic = (option->rect.width() <= option->rect.height()) ? magicTweak : 0; - resizeValue = verticalMagic - resizeValue; + if (option->direction == Qt::RightToLeft) + adjustedFlags |= QS60StylePrivate::SF_Mirrored_X_Axis; + + if (drawSkinPart) + QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, adjustedFlags); + + if (option->state & State_Children) { + QS60StyleEnums::SkinParts skinPart = + (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; + const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, vopt, widget); + const int minDimension = qMin(option->rect.width(), option->rect.height()); + const int magicTweak = (option->direction == Qt::RightToLeft) ? -3 : 3; //@todo: magic + //The branch indicator icon in S60 is supposed to be superimposed on top of branch lines. + QRect iconRect(QPoint(option->rect.left() + magicTweak, selectionRect.top() + 1), QSize(minDimension, minDimension)); + if (!QS60StylePrivate::isTouchSupported()) + iconRect.translate(0, -4); //@todo: magic + QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, adjustedFlags); } - iconRect.translate(magicTweak, resizeValue); - QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); } } break; @@ -2478,6 +2474,12 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const //double the top layout margin for dialogs, it is very close to real value //without having to define custom pixel metric metricValue *= 2; + + if (widget && (metric == PM_FocusFrameHMargin)) + if (qobject_cast<const QTableView *>(widget)) + //Halve the focus frame margin for table items + metricValue /= 2; + return metricValue; } @@ -2503,7 +2505,7 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0); const int iconHeight = (!buttonWidget->icon().isNull()) ? buttonWidget->iconSize().height() : 0; const int textHeight = (buttonWidget->text().length() > 0) ? - buttonWidget->fontMetrics().size(Qt::TextSingleLine, buttonWidget->text()).height() : 0; + buttonWidget->fontMetrics().size(Qt::TextSingleLine, buttonWidget->text()).height() : opt->fontMetrics.height(); const int decoratorHeight = (buttonWidget->isCheckable()) ? pixelMetric(PM_IndicatorHeight) : 0; const int contentHeight = @@ -2573,7 +2575,7 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *hret) const { - int retValue = -1; + int retValue = 0; switch (sh) { case SH_RequestSoftwareInputPanel: if (QS60StylePrivate::isSingleClickUi()) @@ -2608,9 +2610,13 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_Dial_BackgroundRole: retValue = QPalette::Base; break; - case SH_ItemView_ActivateItemOnSingleClick: - retValue = QS60StylePrivate::isSingleClickUi(); + case SH_ItemView_ActivateItemOnSingleClick: { + if (QS60StylePrivate::isSingleClickUi()) + retValue = true; + else if (opt && opt->state & QStyle::State_Selected) + retValue = true; break; + } case SH_ProgressDialog_TextLabelAlignment: retValue = (QApplication::layoutDirection() == Qt::LeftToRight) ? Qt::AlignLeft : @@ -3002,7 +3008,7 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con } break; case SE_ItemViewItemCheckIndicator: - if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { + if (const QStyleOptionViewItemV2 *vopt = qstyleoption_cast<const QStyleOptionViewItemV2 *>(opt)) { const QListWidget *listItem = qobject_cast<const QListWidget *>(widget); const bool singleSelection = listItem && diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 9dd3810..d8c31f8 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -476,6 +476,8 @@ public: SF_StateDisabled = 0x0020, SF_ColorSkinned = 0x0040, // pixmap is colored with foreground pen color SF_Animation = 0x0080, + SF_Mirrored_X_Axis = 0x0100, + SF_Mirrored_Y_Axis = 0x0200 }; enum CacheClearReason { diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 46de9ef..c1223af 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -654,6 +654,14 @@ QPixmap QS60StyleModeSpecifics::fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask pixmap = QPixmap::fromImage(iconImage); } + if ((flags & QS60StylePrivate::SF_Mirrored_X_Axis) || + (flags & QS60StylePrivate::SF_Mirrored_Y_Axis)) { + QImage iconImage = pixmap.toImage().mirrored( + flags & QS60StylePrivate::SF_Mirrored_X_Axis, + flags & QS60StylePrivate::SF_Mirrored_Y_Axis); + pixmap = QPixmap::fromImage(iconImage); + } + return pixmap; } @@ -969,7 +977,7 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme switch(frameElement) { case QS60StylePrivate::SF_ToolTip: - if (QSysInfo::s60Version()!=QSysInfo::SV_S60_3_1) { + if (QSysInfo::s60Version() != QSysInfo::SV_S60_3_1) { centerId.Set(EAknsMajorGeneric, 0x19c2); frameId.Set(EAknsMajorSkin, 0x5300); } else { @@ -978,7 +986,8 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme } break; case QS60StylePrivate::SF_ToolBar: - if (QSysInfo::s60Version()==QSysInfo::SV_S60_3_1 || QSysInfo::s60Version()==QSysInfo::SV_S60_3_2) { + if (QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || + QSysInfo::s60Version() == QSysInfo::SV_S60_3_2) { centerId.Set(KAknsIIDQsnFrPopupCenterSubmenu); frameId.Set(KAknsIIDQsnFrPopupSub); } diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp index 5f939d0..67eb1ef 100644 --- a/src/gui/styles/qwindowsmobilestyle.cpp +++ b/src/gui/styles/qwindowsmobilestyle.cpp @@ -5356,6 +5356,50 @@ void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOp painter->setPen(option->palette.text().color()); painter->drawLines(a); break; } + case PE_IndicatorBranch: { + // Copied from the Windows style. + static const int decoration_size = d->doubleControls ? 18 : 9; + static const int ofsA = d->doubleControls ? 4 : 2; + static const int ofsB = d->doubleControls ? 8 : 4; + static const int ofsC = d->doubleControls ? 12 : 6; + static const int ofsD = d->doubleControls ? 1 : 0; + int mid_h = option->rect.x() + option->rect.width() / 2; + int mid_v = option->rect.y() + option->rect.height() / 2; + int bef_h = mid_h; + int bef_v = mid_v; + int aft_h = mid_h; + int aft_v = mid_v; + if (option->state & State_Children) { + int delta = decoration_size / 2; + bef_h -= delta; + bef_v -= delta; + aft_h += delta; + aft_v += delta; + QPen oldPen = painter->pen(); + QPen crossPen = oldPen; + crossPen.setWidth(2); + painter->setPen(crossPen); + painter->drawLine(bef_h + ofsA + ofsD, bef_v + ofsB + ofsD, bef_h + ofsC + ofsD, bef_v + ofsB + ofsD); + if (!(option->state & State_Open)) + painter->drawLine(bef_h + ofsB + ofsD, bef_v + ofsA + ofsD, bef_h + ofsB + ofsD, bef_v + ofsC + ofsD); + painter->setPen(option->palette.dark().color()); + painter->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1); + if (d->doubleControls) + painter->drawRect(bef_h + 1, bef_v + 1, decoration_size - 3, decoration_size - 3); + painter->setPen(oldPen); + } + QBrush brush(option->palette.dark().color(), Qt::Dense4Pattern); + if (option->state & State_Item) { + if (option->direction == Qt::RightToLeft) + painter->fillRect(option->rect.left(), mid_v, bef_h - option->rect.left(), 1, brush); + else + painter->fillRect(aft_h, mid_v, option->rect.right() - aft_h + 1, 1, brush); + } + if (option->state & State_Sibling) + painter->fillRect(mid_h, aft_v, 1, option->rect.bottom() - aft_v + 1, brush); + if (option->state & (State_Open | State_Children | State_Item | State_Sibling)) + painter->fillRect(mid_h, option->rect.y(), 1, bef_v - option->rect.y(), brush); + break; } case PE_Frame: qDrawPlainRect(painter, option->rect, option->palette.shadow().color(), d->doubleControls ? 2 : 1, &option->palette.background()); diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 21a31a3..c229242 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -805,6 +805,9 @@ QFont::QFont(const QString &family, int pointSize, int weight, bool italic) resolve_mask |= QFont::WeightResolved | QFont::StyleResolved; } + if (italic) + resolve_mask |= QFont::StyleResolved; + d->request.family = family; d->request.pointSize = qreal(pointSize); d->request.pixelSize = -1; diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 95774f9..489b70b 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -113,6 +113,7 @@ QSymbianFontDatabaseExtrasImplementation::QSymbianFontDatabaseExtrasImplementati QStringList filters; filters.append(QLatin1String("*.ttf")); filters.append(QLatin1String("*.ccc")); + filters.append(QLatin1String("*.ltt")); const QFileInfoList fontFiles = alternativeFilePaths(QLatin1String("resource\\Fonts"), filters); const TInt heapMinLength = 0x1000; diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp index 05fe744..1abc2d9 100644 --- a/src/gui/util/qcompleter.cpp +++ b/src/gui/util/qcompleter.cpp @@ -532,17 +532,22 @@ void QCompletionEngine::saveInCache(QString part, const QModelIndex& parent, con QMatchData old = cache[parent].take(part); cost = cost + m.indices.cost() - old.indices.cost(); if (cost * sizeof(int) > 1024 * 1024) { - QMap<QModelIndex, CacheItem>::iterator it1 ; - for (it1 = cache.begin(); it1 != cache.end(); ++it1) { + QMap<QModelIndex, CacheItem>::iterator it1 = cache.begin(); + while (it1 != cache.end()) { CacheItem& ci = it1.value(); int sz = ci.count()/2; QMap<QString, QMatchData>::iterator it2 = ci.begin(); - for (int i = 0; it2 != ci.end() && i < sz; i++, ++it2) { + int i = 0; + while (it2 != ci.end() && i < sz) { cost -= it2.value().indices.cost(); - ci.erase(it2); + it2 = ci.erase(it2); + i++; + } + if (ci.count() == 0) { + it1 = cache.erase(it1); + } else { + ++it1; } - if (ci.count() == 0) - cache.erase(it1); } } @@ -1808,7 +1813,7 @@ QStringList QCompleter::splitPath(const QString& path) const This signal is sent when an item in the popup() is highlighted by the user. It is also sent if complete() is called with the completionMode() - set to QCOmpleter::InlineCompletion. The item's \a text is given. + set to QCompleter::InlineCompletion. The item's \a text is given. */ QT_END_NAMESPACE diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp index 8e482e0..c89fbae 100644 --- a/src/gui/util/qsystemtrayicon_win.cpp +++ b/src/gui/util/qsystemtrayicon_win.cpp @@ -60,17 +60,9 @@ #include <QDesktopWidget> #include <QSettings> -#if defined(Q_WS_WINCE) && !defined(STANDARDSHELL_UI_MODEL) -# include <streams.h> -#endif - QT_BEGIN_NAMESPACE -#if defined(Q_WS_WINCE) -static const UINT q_uNOTIFYICONID = 13; // IDs from 0 to 12 are reserved on WinCE. -#else static const UINT q_uNOTIFYICONID = 0; -#endif static uint MYWM_TASKBARCREATED = 0; #define MYWM_NOTIFYICON (WM_APP+101) @@ -124,23 +116,15 @@ bool QSystemTrayIconSys::allowsMessages() bool QSystemTrayIconSys::supportsMessages() { -#ifndef Q_OS_WINCE return allowsMessages(); -#endif - return false; } QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object) : hIcon(0), q(object), ignoreNextMouseRelease(false) { -#ifndef Q_OS_WINCE notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, guidItem); // NOTIFYICONDATAW_V2_SIZE; maxTipLength = 128; -#else - notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, szTip[64]); // NOTIFYICONDATAW_V1_SIZE; - maxTipLength = 64; -#endif // For restoring the tray icon after explorer crashes if (!MYWM_TASKBARCREATED) { @@ -316,24 +300,13 @@ bool QSystemTrayIconSys::winEvent( MSG *m, long *result ) case WM_RBUTTONUP: if (q->contextMenu()) { q->contextMenu()->popup(gpos); -#if defined(Q_WS_WINCE) - // We must ensure that the popup menu doesn't show up behind the task bar. - QRect desktopRect = qApp->desktop()->availableGeometry(); - int maxY = desktopRect.y() + desktopRect.height() - q->contextMenu()->height(); - if (gpos.y() > maxY) { - gpos.ry() = maxY; - q->contextMenu()->move(gpos); - } -#endif } emit q->activated(QSystemTrayIcon::Context); break; -#if !defined(Q_WS_WINCE) case NIN_BALLOONUSERCLICK: emit q->messageClicked(); break; -#endif case WM_MBUTTONUP: emit q->activated(QSystemTrayIcon::MiddleClick); @@ -400,23 +373,11 @@ QRect QSystemTrayIconSys::findIconGeometry(const int iconId) //find the toolbar used in the notification area if (trayHandle) { -#if defined(Q_OS_WINCE) - trayHandle = FindWindow(L"TrayNotifyWnd", NULL); -#else trayHandle = FindWindowEx(trayHandle, NULL, L"TrayNotifyWnd", NULL); -#endif if (trayHandle) { -#if defined(Q_OS_WINCE) - HWND hwnd = FindWindow(L"SysPager", NULL); -#else HWND hwnd = FindWindowEx(trayHandle, NULL, L"SysPager", NULL); -#endif if (hwnd) { -#if defined(Q_OS_WINCE) - hwnd = FindWindow(L"ToolbarWindow32", NULL); -#else hwnd = FindWindowEx(hwnd, NULL, L"ToolbarWindow32", NULL); -#endif if (hwnd) trayHandle = hwnd; } @@ -435,11 +396,7 @@ QRect QSystemTrayIconSys::findIconGeometry(const int iconId) return ret; int buttonCount = SendMessage(trayHandle, TB_BUTTONCOUNT, 0, 0); -#if defined(Q_OS_WINCE) - LPVOID data = VirtualAlloc(NULL, sizeof(TBBUTTON), MEM_COMMIT, PAGE_READWRITE); -#else LPVOID data = VirtualAllocEx(trayProcess, NULL, sizeof(TBBUTTON), MEM_COMMIT, PAGE_READWRITE); -#endif if ( buttonCount < 1 || !data ) { CloseHandle(trayProcess); @@ -477,11 +434,7 @@ QRect QSystemTrayIconSys::findIconGeometry(const int iconId) } } } -#if defined(Q_OS_WINCE) - VirtualFree(data, 0, MEM_RELEASE); -#else VirtualFreeEx(trayProcess, data, 0, MEM_RELEASE); -#endif CloseHandle(trayProcess); return ret; } @@ -555,16 +508,10 @@ void QSystemTrayIconPrivate::updateMenu_sys() void QSystemTrayIconPrivate::updateToolTip_sys() { -#ifdef Q_WS_WINCE - // Calling sys->trayMessage(NIM_MODIFY) on an existing icon is broken on Windows CE. - // So we need to call updateIcon_sys() which creates a new icon handle. - updateIcon_sys(); -#else if (!sys) return; sys->trayMessage(NIM_MODIFY); -#endif } bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys() diff --git a/src/gui/util/qsystemtrayicon_wince.cpp b/src/gui/util/qsystemtrayicon_wince.cpp new file mode 100644 index 0000000..0a0d340 --- /dev/null +++ b/src/gui/util/qsystemtrayicon_wince.cpp @@ -0,0 +1,296 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module 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 "qsystemtrayicon_p.h" +#ifndef QT_NO_SYSTEMTRAYICON +#define _WIN32_IE 0x0600 //required for NOTIFYICONDATA_V2_SIZE + +#include <qt_windows.h> +#include <shlwapi.h> +#include <QApplication> + +QT_BEGIN_NAMESPACE + +static const UINT q_uNOTIFYICONID = 13; // IDs from 0 to 12 are reserved on WinCE. +#define MYWM_NOTIFYICON (WM_APP+101) + +struct Q_NOTIFYICONIDENTIFIER { + DWORD cbSize; + HWND hWnd; + UINT uID; + GUID guidItem; +}; + +class QSystemTrayIconSys : QWidget +{ +public: + QSystemTrayIconSys(QSystemTrayIcon *object); + ~QSystemTrayIconSys(); + bool winEvent( MSG *m, long *result ); + bool trayMessage(DWORD msg); + void setIconContents(NOTIFYICONDATA &data); + void createIcon(); + QRect findTrayGeometry(); + HICON hIcon; + QPoint globalPos; + QSystemTrayIcon *q; +private: + uint notifyIconSize; + int maxTipLength; + bool ignoreNextMouseRelease; +}; + +QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object) + : hIcon(0), q(object), ignoreNextMouseRelease(false) + +{ + notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, szTip[64]); // NOTIFYICONDATAW_V1_SIZE; + maxTipLength = 64; +} + +QSystemTrayIconSys::~QSystemTrayIconSys() +{ + if (hIcon) + DestroyIcon(hIcon); +} + +QRect QSystemTrayIconSys::findTrayGeometry() +{ + // Use lower right corner as fallback + QPoint brCorner = qApp->desktop()->screenGeometry().bottomRight(); + QRect ret(brCorner.x() - 10, brCorner.y() - 10, 10, 10); + return ret; +} + +void QSystemTrayIconSys::setIconContents(NOTIFYICONDATA &tnd) +{ + tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; + tnd.uCallbackMessage = MYWM_NOTIFYICON; + tnd.hIcon = hIcon; + QString tip = q->toolTip(); + + if (!tip.isNull()) { + tip = tip.left(maxTipLength - 1) + QChar(); + memcpy(tnd.szTip, tip.utf16(), qMin(tip.length() + 1, maxTipLength) * sizeof(wchar_t)); + } +} + +bool QSystemTrayIconSys::trayMessage(DWORD msg) +{ + NOTIFYICONDATA tnd; + memset(&tnd, 0, notifyIconSize); + tnd.uID = q_uNOTIFYICONID; + tnd.cbSize = notifyIconSize; + tnd.hWnd = winId(); + + Q_ASSERT(testAttribute(Qt::WA_WState_Created)); + + if (msg != NIM_DELETE) { + setIconContents(tnd); + } + + return Shell_NotifyIcon(msg, &tnd); +} + +void QSystemTrayIconSys::createIcon() +{ + hIcon = 0; + QIcon icon = q->icon(); + if (icon.isNull()) + return; + + //const QSize preferredSize(GetSystemMetrics(SM_CXSMICON) * 2, GetSystemMetrics(SM_CYSMICON) * 2); + const QSize preferredSize(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)); + QPixmap pm = icon.pixmap(preferredSize); + if (pm.isNull()) + return; + + hIcon = pm.toWinHICON(); +} + +bool QSystemTrayIconSys::winEvent( MSG *m, long *result ) +{ + switch(m->message) { + case WM_CREATE: + SetWindowLong(winId(), GWL_USERDATA, (LONG)((CREATESTRUCTW*)m->lParam)->lpCreateParams); + break; + + case MYWM_NOTIFYICON: + { + RECT r; + GetWindowRect(winId(), &r); + QEvent *e = 0; + Qt::KeyboardModifiers keys = QApplication::keyboardModifiers(); + QPoint gpos = QCursor::pos(); + + switch (m->lParam) { + case WM_LBUTTONUP: + if (ignoreNextMouseRelease) + ignoreNextMouseRelease = false; + else + emit q->activated(QSystemTrayIcon::Trigger); + break; + + case WM_LBUTTONDBLCLK: + ignoreNextMouseRelease = true; // Since DBLCLICK Generates a second mouse + // release we must ignore it + emit q->activated(QSystemTrayIcon::DoubleClick); + break; + + case WM_RBUTTONUP: + if (q->contextMenu()) { + q->contextMenu()->popup(gpos); + + // We must ensure that the popup menu doesn't show up behind the task bar. + QRect desktopRect = qApp->desktop()->availableGeometry(); + int maxY = desktopRect.y() + desktopRect.height() - q->contextMenu()->height(); + if (gpos.y() > maxY) { + gpos.ry() = maxY; + q->contextMenu()->move(gpos); + } + } + emit q->activated(QSystemTrayIcon::Context); + break; + + case WM_MBUTTONUP: + emit q->activated(QSystemTrayIcon::MiddleClick); + break; + default: + break; + } + if (e) { + bool res = QApplication::sendEvent(q, e); + delete e; + return res; + } + break; + } + default: + return QWidget::winEvent(m, result); + } + return 0; +} + +void QSystemTrayIconPrivate::install_sys() +{ + Q_Q(QSystemTrayIcon); + if (!sys) { + sys = new QSystemTrayIconSys(q); + sys->createIcon(); + sys->trayMessage(NIM_ADD); + } +} + +void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, int timeOut) +{ + if (!sys) + return; + + uint uSecs = 0; + if ( timeOut < 0) + uSecs = 10000; //10 sec default + else uSecs = (int)timeOut; + + //message is limited to 255 chars + NULL + QString messageString; + if (message.isEmpty() && !title.isEmpty()) + messageString = QLatin1Char(' '); //ensures that the message shows when only title is set + else + messageString = message.left(255) + QChar(); + + //title is limited to 63 chars + NULL + QString titleString = title.left(63) + QChar(); + + //show QBalloonTip + QRect trayRect = sys->findTrayGeometry(); + QBalloonTip::showBalloon(type, title, message, sys->q, QPoint(trayRect.left(), + trayRect.center().y()), uSecs, false); +} + +QRect QSystemTrayIconPrivate::geometry_sys() const +{ + return QRect(); +} + +void QSystemTrayIconPrivate::remove_sys() +{ + if (!sys) + return; + + sys->trayMessage(NIM_DELETE); + delete sys; + sys = 0; +} + +void QSystemTrayIconPrivate::updateIcon_sys() +{ + if (!sys) + return; + + HICON hIconToDestroy = sys->hIcon; + + sys->createIcon(); + sys->trayMessage(NIM_MODIFY); + + if (hIconToDestroy) + DestroyIcon(hIconToDestroy); +} + +void QSystemTrayIconPrivate::updateMenu_sys() +{ + +} + +void QSystemTrayIconPrivate::updateToolTip_sys() +{ + // Calling sys->trayMessage(NIM_MODIFY) on an existing icon is broken on Windows CE. + // So we need to call updateIcon_sys() which creates a new icon handle. + updateIcon_sys(); +} + +bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys() +{ + return true; +} + +QT_END_NAMESPACE + +#endif diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri index bd2af85..be8db93 100644 --- a/src/gui/util/util.pri +++ b/src/gui/util/util.pri @@ -20,7 +20,10 @@ SOURCES += \ util/qundoview.cpp -win32 { +wince* { + SOURCES += \ + util/qsystemtrayicon_wince.cpp +} else:win32 { SOURCES += \ util/qsystemtrayicon_win.cpp } diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index e0b09aa..1504066 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -152,7 +152,10 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt menuOption.icon = qvariant_cast<QPixmap>(variant); break; } - + if (qVariantCanConvert<QBrush>(index.data(Qt::BackgroundRole))) { + menuOption.palette.setBrush(QPalette::All, QPalette::Background, + qvariant_cast<QBrush>(index.data(Qt::BackgroundRole))); + } menuOption.text = index.model()->data(index, Qt::DisplayRole).toString() .replace(QLatin1Char('&'), QLatin1String("&&")); menuOption.tabWidth = 0; diff --git a/src/gui/widgets/qmenu.h b/src/gui/widgets/qmenu.h index a040afa..7708e05 100644 --- a/src/gui/widgets/qmenu.h +++ b/src/gui/widgets/qmenu.h @@ -142,7 +142,7 @@ public: #endif #ifdef Q_WS_WINCE - HMENU wceMenu(bool create = false); + HMENU wceMenu(); #endif bool separatorsCollapsible() const; diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h index 39cbbd8..33283fd 100644 --- a/src/gui/widgets/qmenu_p.h +++ b/src/gui/widgets/qmenu_p.h @@ -358,7 +358,7 @@ public: return 0; } } *wce_menu; - HMENU wceMenu(bool create = false); + HMENU wceMenu(); QAction* wceCommands(uint command); #endif #if defined(Q_WS_S60) diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp index 1577f0a..e088db6 100644 --- a/src/gui/widgets/qmenu_wince.cpp +++ b/src/gui/widgets/qmenu_wince.cpp @@ -126,6 +126,7 @@ static void qt_wce_enable_soft_key(HWND handle, uint command) if (ptrEnableSoftKey) ptrEnableSoftKey(handle, command, false, true); } + static void qt_wce_disable_soft_key(HWND handle, uint command) { resolveAygLibs(); @@ -133,7 +134,8 @@ static void qt_wce_disable_soft_key(HWND handle, uint command) ptrEnableSoftKey(handle, command, false, false); } -static void qt_wce_delete_action_list(QList<QWceMenuAction*> *list) { +static void qt_wce_delete_action_list(QList<QWceMenuAction*> *list) +{ for(QList<QWceMenuAction*>::Iterator it = list->begin(); it != list->end(); ++it) { QWceMenuAction *action = (*it); delete action; @@ -143,7 +145,8 @@ static void qt_wce_delete_action_list(QList<QWceMenuAction*> *list) { } //search for first QuitRole in QMenuBar -static QAction* qt_wce_get_quit_action(QList<QAction *> actionItems) { +static QAction* qt_wce_get_quit_action(QList<QAction *> actionItems) +{ QAction *returnAction = 0; for (int i = 0; i < actionItems.size(); ++i) { QAction *action = actionItems.at(i); @@ -158,7 +161,8 @@ static QAction* qt_wce_get_quit_action(QList<QAction *> actionItems) { return 0; //nothing found; } -static QAction* qt_wce_get_quit_action(QList<QWceMenuAction*> actionItems) { +static QAction* qt_wce_get_quit_action(QList<QWceMenuAction*> actionItems) +{ for (int i = 0; i < actionItems.size(); ++i) { if (actionItems.at(i)->action->menuRole() == QAction::QuitRole) return actionItems.at(i)->action; @@ -171,7 +175,8 @@ static QAction* qt_wce_get_quit_action(QList<QWceMenuAction*> actionItems) { return 0; } -static HMODULE qt_wce_get_module_handle() { +static HMODULE qt_wce_get_module_handle() +{ HMODULE module = 0; //handle to resources if (!(module = GetModuleHandle(L"QtGui4"))) //release dynamic if (!(module = GetModuleHandle(L"QtGuid4"))) //debug dynamic @@ -180,7 +185,8 @@ static HMODULE qt_wce_get_module_handle() { return module; } -static void qt_wce_change_command(HWND menuHandle, int item, int command) { +static void qt_wce_change_command(HWND menuHandle, int item, int command) +{ TBBUTTONINFOA tbbi; memset(&tbbi,0,sizeof(tbbi)); tbbi.cbSize = sizeof(tbbi); @@ -189,7 +195,8 @@ TBBUTTONINFOA tbbi; SendMessage(menuHandle, TB_SETBUTTONINFO, item, (LPARAM)&tbbi); } -static void qt_wce_rename_menu_item(HWND menuHandle, int item, const QString &newText) { +static void qt_wce_rename_menu_item(HWND menuHandle, int item, const QString &newText) +{ TBBUTTONINFOA tbbi; memset(&tbbi,0,sizeof(tbbi)); tbbi.cbSize = sizeof(tbbi); @@ -200,7 +207,8 @@ static void qt_wce_rename_menu_item(HWND menuHandle, int item, const QString &ne SendMessage(menuHandle, TB_SETBUTTONINFO, item, (LPARAM)&tbbi); } -static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, int toolbarID, int flags = 0) { +static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, int toolbarID, int flags = 0) +{ resolveAygLibs(); if (ptrCreateMenuBar) { @@ -225,8 +233,8 @@ static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, i return 0; } -static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action, bool created) { - +static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action) +{ Q_ASSERT_X(menu, "AppendMenu", "menu is 0"); if (action->action->isVisible()) { int flags; @@ -240,7 +248,7 @@ static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action, bool create else if (action->action->menu()) { text.remove(QChar::fromLatin1('&')); AppendMenu (menu, MF_STRING | flags | MF_POPUP, - (UINT) action->action->menu()->wceMenu(created), reinterpret_cast<const wchar_t *> (text.utf16())); + (UINT) action->action->menu()->wceMenu(), reinterpret_cast<const wchar_t *> (text.utf16())); } else { AppendMenu (menu, MF_STRING | flags, action->command, reinterpret_cast<const wchar_t *> (text.utf16())); @@ -265,12 +273,14 @@ static void qt_wce_clear_menu(HMENU hMenu) This function refreshes the native Windows CE menu. */ -void QMenuBar::wceRefresh() { +void QMenuBar::wceRefresh() +{ for (int i = 0; i < nativeMenuBars.size(); ++i) nativeMenuBars.at(i)->d_func()->wceRefresh(); } -void QMenuBarPrivate::wceRefresh() { +void QMenuBarPrivate::wceRefresh() +{ DrawMenuBar(wce_menubar->menubarHandle); } @@ -280,7 +290,8 @@ void QMenuBarPrivate::wceRefresh() { This function sends native Windows CE commands to Qt menus. */ -QAction* QMenu::wceCommands(uint command) { +QAction* QMenu::wceCommands(uint command) +{ Q_D(QMenu); return d->wceCommands(command); } @@ -292,22 +303,27 @@ QAction* QMenu::wceCommands(uint command) { and all their child menus. */ -void QMenuBar::wceCommands(uint command, HWND) { - for (int i = 0; i < nativeMenuBars.size(); ++i) - nativeMenuBars.at(i)->d_func()->wceCommands(command); +void QMenuBar::wceCommands(uint command) +{ + const HWND hwndActiveWindow = GetActiveWindow(); + for (int i = 0; i < nativeMenuBars.size(); ++i) { + QMenuBarPrivate* nativeMenuBar = nativeMenuBars.at(i)->d_func(); + if (hwndActiveWindow == nativeMenuBar->wce_menubar->parentWindowHandle) + nativeMenuBar->wceCommands(command); + } } -bool QMenuBarPrivate::wceEmitSignals(QList<QWceMenuAction*> actions, uint command) { +bool QMenuBarPrivate::wceEmitSignals(QList<QWceMenuAction*> actions, uint command) +{ QAction *foundAction = 0; for (int i = 0; i < actions.size(); ++i) { - if (foundAction) - break; QWceMenuAction *action = actions.at(i); if (action->action->menu()) { foundAction = action->action->menu()->wceCommands(command); + if (foundAction) + break; } else if (action->command == command) { - emit q_func()->triggered(action->action); action->action->activate(QAction::Trigger); return true; } @@ -319,13 +335,14 @@ bool QMenuBarPrivate::wceEmitSignals(QList<QWceMenuAction*> actions, uint comman return false; } -void QMenuBarPrivate::wceCommands(uint command) { +void QMenuBarPrivate::wceCommands(uint command) +{ if (wceClassicMenu) { for (int i = 0; i < wce_menubar->actionItemsClassic.size(); ++i) wceEmitSignals(wce_menubar->actionItemsClassic.at(i), command); } else { if (wceEmitSignals(wce_menubar->actionItems, command)) { - return ; + return; } else if (wce_menubar->leftButtonIsMenu) {//check if command is on the left quick button wceEmitSignals(wce_menubar->actionItemsLeftButton, command); @@ -337,7 +354,8 @@ void QMenuBarPrivate::wceCommands(uint command) { } } -QAction *QMenuPrivate::wceCommands(uint command) { +QAction *QMenuPrivate::wceCommands(uint command) +{ QAction *foundAction = 0; for (int i = 0; i < wce_menu->actionItems.size(); ++i) { if (foundAction) @@ -347,7 +365,7 @@ QAction *QMenuPrivate::wceCommands(uint command) { foundAction = action->action->menu()->d_func()->wceCommands(command); } else if (action->command == command) { - action->action->activate(QAction::Trigger); + activateAction(action->action, QAction::Trigger); return action->action; } } @@ -356,8 +374,8 @@ QAction *QMenuPrivate::wceCommands(uint command) { return foundAction; } -void QMenuBarPrivate::wceCreateMenuBar(QWidget *parent) { - +void QMenuBarPrivate::wceCreateMenuBar(QWidget *parent) +{ Q_Q(QMenuBar); wce_menubar = new QWceMenuBarPrivate(this); @@ -371,21 +389,25 @@ void QMenuBarPrivate::wceCreateMenuBar(QWidget *parent) { wceClassicMenu = (!qt_wince_is_smartphone() && !qt_wince_is_pocket_pc()); } -void QMenuBarPrivate::wceDestroyMenuBar() { +void QMenuBarPrivate::wceDestroyMenuBar() +{ Q_Q(QMenuBar); int index = nativeMenuBars.indexOf(q); nativeMenuBars.removeAt(index); - if (wce_menubar) - delete wce_menubar; - wce_menubar = 0; + if (wce_menubar) { + delete wce_menubar; + wce_menubar = 0; + } } -QMenuBarPrivate::QWceMenuBarPrivate::QWceMenuBarPrivate(QMenuBarPrivate *menubar) : - menubarHandle(0), menuHandle(0),leftButtonMenuHandle(0) , - leftButtonAction(0), leftButtonIsMenu(false), d(menubar) { +QMenuBarPrivate::QWceMenuBarPrivate::QWceMenuBarPrivate(QMenuBarPrivate *menubar) +: menubarHandle(0), menuHandle(0), leftButtonMenuHandle(0), + leftButtonAction(0), leftButtonIsMenu(false), d(menubar) +{ } -QMenuBarPrivate::QWceMenuBarPrivate::~QWceMenuBarPrivate() { +QMenuBarPrivate::QWceMenuBarPrivate::~QWceMenuBarPrivate() +{ if (menubarHandle) DestroyWindow(menubarHandle); qt_wce_delete_action_list(&actionItems); @@ -403,24 +425,28 @@ QMenuBarPrivate::QWceMenuBarPrivate::~QWceMenuBarPrivate() { QMenuBar::wceRefresh(); } -QMenuPrivate::QWceMenuPrivate::QWceMenuPrivate() { - menuHandle = 0; +QMenuPrivate::QWceMenuPrivate::QWceMenuPrivate() +: menuHandle(0) +{ } -QMenuPrivate::QWceMenuPrivate::~QWceMenuPrivate() { +QMenuPrivate::QWceMenuPrivate::~QWceMenuPrivate() +{ qt_wce_delete_action_list(&actionItems); if (menuHandle) DestroyMenu(menuHandle); } -void QMenuPrivate::QWceMenuPrivate::addAction(QAction *a, QWceMenuAction *before) { +void QMenuPrivate::QWceMenuPrivate::addAction(QAction *a, QWceMenuAction *before) +{ QWceMenuAction *action = new QWceMenuAction; action->action = a; action->command = qt_wce_menu_static_cmd_id++; addAction(action, before); } -void QMenuPrivate::QWceMenuPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) { +void QMenuPrivate::QWceMenuPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) +{ if (!action) return; int before_index = actionItems.indexOf(before); @@ -439,12 +465,16 @@ void QMenuPrivate::QWceMenuPrivate::addAction(QWceMenuAction *action, QWceMenuAc Windows CE menu bar bindings. */ -HMENU QMenu::wceMenu(bool create) { return d_func()->wceMenu(create); } +HMENU QMenu::wceMenu() +{ + return d_func()->wceMenu(); +} -HMENU QMenuPrivate::wceMenu(bool create) { +HMENU QMenuPrivate::wceMenu() +{ if (!wce_menu) wce_menu = new QWceMenuPrivate; - if (!wce_menu->menuHandle || create) + if (!wce_menu->menuHandle) wce_menu->rebuild(); return wce_menu->menuHandle; } @@ -459,30 +489,33 @@ void QMenuPrivate::QWceMenuPrivate::rebuild() for (int i = 0; i < actionItems.size(); ++i) { QWceMenuAction *action = actionItems.at(i); action->menuHandle = menuHandle; - qt_wce_insert_action(menuHandle, action, true); + qt_wce_insert_action(menuHandle, action); } QMenuBar::wceRefresh(); } -void QMenuPrivate::QWceMenuPrivate::syncAction(QWceMenuAction *) { +void QMenuPrivate::QWceMenuPrivate::syncAction(QWceMenuAction *) +{ rebuild(); } -void QMenuPrivate::QWceMenuPrivate::removeAction(QWceMenuAction *action) { - actionItems.removeAll(action); - delete action; - action = 0; - rebuild(); +void QMenuPrivate::QWceMenuPrivate::removeAction(QWceMenuAction *action) +{ + actionItems.removeAll(action); + delete action; + rebuild(); } -void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QAction *a, QWceMenuAction *before) { +void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QAction *a, QWceMenuAction *before) +{ QWceMenuAction *action = new QWceMenuAction; action->action = a; action->command = qt_wce_menu_static_cmd_id++; addAction(action, before); } -void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) { +void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) +{ if (!action) return; int before_index = actionItems.indexOf(before); @@ -494,25 +527,27 @@ void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QWceMenuAction *action, QWce rebuild(); } -void QMenuBarPrivate::QWceMenuBarPrivate::syncAction(QWceMenuAction*) { +void QMenuBarPrivate::QWceMenuBarPrivate::syncAction(QWceMenuAction*) +{ QMenuBar::wceRefresh(); rebuild(); } -void QMenuBarPrivate::QWceMenuBarPrivate::removeAction(QWceMenuAction *action) { +void QMenuBarPrivate::QWceMenuBarPrivate::removeAction(QWceMenuAction *action) +{ actionItems.removeAll(action); delete action; - action = 0; rebuild(); } -void QMenuBarPrivate::_q_updateDefaultAction() { +void QMenuBarPrivate::_q_updateDefaultAction() +{ if (wce_menubar) wce_menubar->rebuild(); } -void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() { - +void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() +{ d->q_func()->resize(0,0); parentWindowHandle = d->q_func()->parentWidget() ? d->q_func()->parentWidget()->winId() : d->q_func()->winId(); if (d->wceClassicMenu) { @@ -559,7 +594,7 @@ void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() { action->command = qt_wce_menu_static_cmd_id++; action->menuHandle = subMenuHandle; actionItemsClassic.last().append(action); - qt_wce_insert_action(subMenuHandle, action, true); + qt_wce_insert_action(subMenuHandle, action); } } for (int i = actions.size();i<maxEntries;++i) { @@ -602,7 +637,7 @@ void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() { for (int i = 0; i < actionItems.size(); ++i) { QWceMenuAction *action = actionItems.at(i); action->menuHandle = menuHandle; - qt_wce_insert_action(menuHandle, action, true); + qt_wce_insert_action(menuHandle, action); } if (!leftButtonIsMenu) { if (leftButtonAction) { @@ -622,7 +657,7 @@ void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() { action->command = qt_wce_menu_static_cmd_id++; action->menuHandle = leftButtonMenuHandle; actionItemsLeftButton.append(action); - qt_wce_insert_action(leftButtonMenuHandle, action, true); + qt_wce_insert_action(leftButtonMenuHandle, action); } } } diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index ef37fd1..aa4ffce 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -1956,7 +1956,7 @@ bool QMenuBar::isNativeMenuBar() const to the right soft key. Currently there is only support for the default action on Windows - Mobile. All other platforms ignore the default action. + Mobile. On all other platforms this method is not available. \sa defaultAction() */ diff --git a/src/gui/widgets/qmenubar.h b/src/gui/widgets/qmenubar.h index 85c0988..c63a4f5 100644 --- a/src/gui/widgets/qmenubar.h +++ b/src/gui/widgets/qmenubar.h @@ -115,7 +115,7 @@ public: void setDefaultAction(QAction *); QAction *defaultAction() const; - static void wceCommands(uint command, HWND controlHandle); + static void wceCommands(uint command); static void wceRefresh(); #endif diff --git a/src/imports/imports.pro b/src/imports/imports.pro index a9d600e..a45af95 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -3,5 +3,4 @@ TEMPLATE = subdirs SUBDIRS += particles gestures contains(QT_CONFIG, webkit): SUBDIRS += webkit -contains(QT_CONFIG, mediaservices): SUBDIRS += multimedia diff --git a/src/imports/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp deleted file mode 100644 index e2a2821..0000000 --- a/src/imports/multimedia/multimedia.cpp +++ /dev/null @@ -1,73 +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 <QtDeclarative/qdeclarativeextensionplugin.h> -#include <QtDeclarative/qdeclarative.h> -#include <QtMediaServices/private/qsoundeffect_p.h> - -#include "qdeclarativevideo_p.h" -#include "qdeclarativeaudio_p.h" - - -QML_DECLARE_TYPE(QSoundEffect) - -QT_BEGIN_NAMESPACE - -class QMultimediaDeclarativeModule : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.multimedia")); - - qmlRegisterType<QSoundEffect>(uri, 4, 7, "SoundEffect"); - qmlRegisterType<QDeclarativeAudio>(uri, 4, 7, "Audio"); - qmlRegisterType<QDeclarativeVideo>(uri, 4, 7, "Video"); - } -}; - -QT_END_NAMESPACE - -#include "multimedia.moc" - -Q_EXPORT_PLUGIN2(qmultimediadeclarativemodule, QT_PREPEND_NAMESPACE(QMultimediaDeclarativeModule)); - diff --git a/src/imports/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro deleted file mode 100644 index 212f7b9..0000000 --- a/src/imports/multimedia/multimedia.pro +++ /dev/null @@ -1,36 +0,0 @@ -TARGET = multimedia -TARGETPATH = Qt/multimedia -include(../qimportbase.pri) - -QT += mediaservices declarative - -HEADERS += \ - qdeclarativeaudio_p.h \ - qdeclarativemediabase_p.h \ - qdeclarativevideo_p.h \ - qmetadatacontrolmetaobject_p.h \ - -SOURCES += \ - multimedia.cpp \ - qdeclarativeaudio.cpp \ - qdeclarativemediabase.cpp \ - qdeclarativevideo.cpp \ - qmetadatacontrolmetaobject.cpp - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -qmldir.files += $$PWD/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -symbian:{ - load(data_caging_paths) - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - - importFiles.sources = multimedia.dll qmldir - importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH - - DEPLOYMENT = importFiles -} - -INSTALLS += target qmldir diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp deleted file mode 100644 index 234b6df..0000000 --- a/src/imports/multimedia/qdeclarativeaudio.cpp +++ /dev/null @@ -1,362 +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 "qdeclarativeaudio_p.h" - -#include <QtMediaServices/qmediaplayercontrol.h> - -QT_BEGIN_NAMESPACE - - -/*! - \qmlclass Audio QDeclarativeAudio - \since 4.7 - \brief The Audio element allows you to add audio playback to a scene. - - This element is part of the \bold{Qt.multimedia 4.7} module. - - \qml - import Qt 4.7 - import Qt.multimedia 4.7 - - Text { - text: "Click Me!"; - font.pointSize: 24; - width: 150; height: 50; - - Audio { - id: playMusic - source: "music.wav" - } - MouseArea { - id: playArea - anchors.fill: parent - onPressed: { playMusic.play() } - } - } - \endqml - - \sa Video -*/ - -/*! - \internal - \class QDeclarativeAudio - \brief The QDeclarativeAudio class provides an audio item that you can add to a QDeclarativeView. -*/ - -void QDeclarativeAudio::_q_error(int errorCode, const QString &errorString) -{ - m_error = QMediaPlayer::Error(errorCode); - m_errorString = errorString; - - emit error(Error(errorCode), errorString); - emit errorChanged(); -} - - -QDeclarativeAudio::QDeclarativeAudio(QObject *parent) - : QObject(parent) -{ -} - -QDeclarativeAudio::~QDeclarativeAudio() -{ - shutdown(); -} - -/*! - \qmlmethod Audio::play() - - Starts playback of the media. - - Sets the \l playing property to true, and the \l paused property to false. -*/ - -void QDeclarativeAudio::play() -{ - if (m_playerControl == 0) - return; - - setPaused(false); - setPlaying(true); -} - -/*! - \qmlmethod Audio::pause() - - Pauses playback of the media. - - Sets the \l playing and \l paused properties to true. -*/ - -void QDeclarativeAudio::pause() -{ - if (m_playerControl == 0) - return; - - setPaused(true); - setPlaying(true); -} - -/*! - \qmlmethod Audio::stop() - - Stops playback of the media. - - Sets the \l playing and \l paused properties to false. -*/ - -void QDeclarativeAudio::stop() -{ - if (m_playerControl == 0) - return; - - setPlaying(false); - setPaused(false); -} - -/*! - \qmlproperty url Audio::source - - This property holds the source URL of the media. -*/ - -/*! - \qmlproperty url Audio::autoLoad - - This property indicates if loading of media should begin immediately. - - Defaults to true, if false media will not be loaded until playback is started. -*/ - -/*! - \qmlproperty bool Audio::playing - - This property holds whether the media is playing. - - Defaults to false, and can be set to true to start playback. -*/ - -/*! - \qmlproperty bool Audio::paused - - This property holds whether the media is paused. - - Defaults to false, and can be set to true to pause playback. -*/ - -/*! - \qmlsignal Audio::onStarted() - - This handler is called when playback is started. -*/ - -/*! - \qmlsignal Audio::onResumed() - - This handler is called when playback is resumed from the paused state. -*/ - -/*! - \qmlsignal Audio::onPaused() - - This handler is called when playback is paused. -*/ - -/*! - \qmlsignal Audio::onStopped() - - This handler is called when playback is stopped. -*/ - -/*! - \qmlproperty enumeration Audio::status - - This property holds the status of media loading. It can be one of: - - \list - \o NoMedia - no media has been set. - \o Loading - the media is currently being loaded. - \o Loaded - the media has been loaded. - \o Buffering - the media is buffering data. - \o Stalled - playback has been interrupted while the media is buffering data. - \o Buffered - the media has buffered data. - \o EndOfMedia - the media has played to the end. - \o InvalidMedia - the media cannot be played. - \o UnknownStatus - the status of the media is unknown. - \endlist -*/ - -QDeclarativeAudio::Status QDeclarativeAudio::status() const -{ - return Status(m_status); -} - -/*! - \qmlsignal Audio::onLoaded() - - This handler is called when the media source has been loaded. -*/ - -/*! - \qmlsignal Audio::onBuffering() - - This handler is called when the media starts buffering. -*/ - -/*! - \qmlsignal Audio::onStalled() - - This handler is called when playback has stalled while the media buffers. -*/ - -/*! - \qmlsignal Audio::onBuffered() - - This handler is called when the media has finished buffering. -*/ - -/*! - \qmlsignal Audio::onEndOfMedia() - - This handler is called when playback stops because end of the media has been reached. -*/ -/*! - \qmlproperty int Audio::duration - - This property holds the duration of the media in milliseconds. - - If the media doesn't have a fixed duration (a live stream for example) this will be 0. -*/ - -/*! - \qmlproperty int Audio::position - - This property holds the current playback position in milliseconds. - - If the \l seekable property is true, this property can be set to seek to a new position. -*/ - -/*! - \qmlproperty real Audio::volume - - This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume). -*/ - -/*! - \qmlproperty bool Audio::muted - - This property holds whether the audio output is muted. -*/ - -/*! - \qmlproperty real Audio::bufferProgress - - This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0 - (full). -*/ - -/*! - \qmlproperty bool Audio::seekable - - This property holds whether position of the audio can be changed. - - If true; setting a \l position value will cause playback to seek to the new position. -*/ - -/*! - \qmlproperty real Audio::playbackRate - - This property holds the rate at which audio is played at as a multiple of the normal rate. -*/ - -/*! - \qmlproperty enumeration Audio::error - - This property holds the error state of the audio. It can be one of: - - \list - \o NoError - there is no current error. - \o ResourceError - the audio cannot be played due to a problem allocating resources. - \o FormatError - the audio format is not supported. - \o NetworkError - the audio cannot be played due to network issues. - \o AccessDenied - the audio cannot be played due to insufficient permissions. - \o ServiceMissing - the audio cannot be played because the media service could not be - instantiated. - \endlist -*/ - -QDeclarativeAudio::Error QDeclarativeAudio::error() const -{ - return Error(m_error); -} - -void QDeclarativeAudio::classBegin() -{ -} - -void QDeclarativeAudio::componentComplete() -{ - if (m_playerControl == 0) - setObject(this); -} - - -/*! - \qmlproperty string Audio::errorString - - This property holds a string describing the current error condition in more detail. -*/ - -/*! - \qmlsignal Audio::onError(error, errorString) - - This handler is called when an \l {QMediaPlayer::Error}{error} has - occurred. The errorString parameter may contain more detailed - information about the error. -*/ - -QT_END_NAMESPACE - -#include "moc_qdeclarativeaudio_p.cpp" - - diff --git a/src/imports/multimedia/qdeclarativeaudio_p.h b/src/imports/multimedia/qdeclarativeaudio_p.h deleted file mode 100644 index e960b9d..0000000 --- a/src/imports/multimedia/qdeclarativeaudio_p.h +++ /dev/null @@ -1,177 +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 QDECLARATIVEAUDIO_P_H -#define QDECLARATIVEAUDIO_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativemediabase_p.h" - -#include <QtCore/qbasictimer.h> -#include <QtDeclarative/qdeclarativeitem.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QTimerEvent; - -class QDeclarativeAudio : public QObject, public QDeclarativeMediaBase, public QDeclarativeParserStatus -{ - Q_OBJECT - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(bool autoLoad READ isAutoLoad WRITE setAutoLoad NOTIFY autoLoadChanged) - Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged) - Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - Q_PROPERTY(int duration READ duration NOTIFY durationChanged) - Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged) - Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged) - Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged) - Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged) - Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged) - Q_PROPERTY(Error error READ error NOTIFY errorChanged) - Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged) - Q_ENUMS(Status) - Q_ENUMS(Error) - Q_INTERFACES(QDeclarativeParserStatus) -public: - enum Status - { - UnknownStatus = QMediaPlayer::UnknownMediaStatus, - NoMedia = QMediaPlayer::NoMedia, - Loading = QMediaPlayer::LoadingMedia, - Loaded = QMediaPlayer::LoadedMedia, - Stalled = QMediaPlayer::StalledMedia, - Buffering = QMediaPlayer::BufferingMedia, - Buffered = QMediaPlayer::BufferedMedia, - EndOfMedia = QMediaPlayer::EndOfMedia, - InvalidMedia = QMediaPlayer::InvalidMedia - }; - - enum Error - { - NoError = QMediaPlayer::NoError, - ResourceError = QMediaPlayer::ResourceError, - FormatError = QMediaPlayer::FormatError, - NetworkError = QMediaPlayer::NetworkError, - AccessDenied = QMediaPlayer::AccessDeniedError, - ServiceMissing = QMediaPlayer::ServiceMissingError - }; - - QDeclarativeAudio(QObject *parent = 0); - ~QDeclarativeAudio(); - - Status status() const; - Error error() const; - - void classBegin(); - void componentComplete(); - -public Q_SLOTS: - void play(); - void pause(); - void stop(); - -Q_SIGNALS: - void sourceChanged(); - void autoLoadChanged(); - void playingChanged(); - void pausedChanged(); - - void started(); - void resumed(); - void paused(); - void stopped(); - - void statusChanged(); - - void loaded(); - void buffering(); - void stalled(); - void buffered(); - void endOfMedia(); - - void durationChanged(); - void positionChanged(); - - void volumeChanged(); - void mutedChanged(); - - void bufferProgressChanged(); - - void seekableChanged(); - void playbackRateChanged(); - - void errorChanged(); - void error(QDeclarativeAudio::Error error, const QString &errorString); - -private Q_SLOTS: - void _q_error(int, const QString &); - -private: - Q_DISABLE_COPY(QDeclarativeAudio) - Q_PRIVATE_SLOT(mediaBase(), void _q_stateChanged(QMediaPlayer::State)) - Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus)) - Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged()) - - inline QDeclarativeMediaBase *mediaBase() { return this; } -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeAudio)) - -QT_END_HEADER - -#endif diff --git a/src/imports/multimedia/qdeclarativemediabase.cpp b/src/imports/multimedia/qdeclarativemediabase.cpp deleted file mode 100644 index ee0737b..0000000 --- a/src/imports/multimedia/qdeclarativemediabase.cpp +++ /dev/null @@ -1,528 +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 "qdeclarativemediabase_p.h" - -#include <QtCore/qcoreevent.h> -#include <QtCore/qurl.h> - -#include <QtMediaServices/qmediaplayercontrol.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmediaserviceprovider.h> -#include <QtMediaServices/qmetadatacontrol.h> -#include "qmetadatacontrolmetaobject_p.h" - - - -QT_BEGIN_NAMESPACE - - -class QDeclarativeMediaBaseObject : public QMediaObject -{ -public: - QDeclarativeMediaBaseObject(QMediaService *service) - : QMediaObject(0, service) - { - } -}; - -class QDeclarativeMediaBasePlayerControl : public QMediaPlayerControl -{ -public: - QDeclarativeMediaBasePlayerControl(QObject *parent) - : QMediaPlayerControl(parent) - { - } - - QMediaPlayer::State state() const { return QMediaPlayer::StoppedState; } - QMediaPlayer::MediaStatus mediaStatus() const { return QMediaPlayer::NoMedia; } - - qint64 duration() const { return 0; } - qint64 position() const { return 0; } - void setPosition(qint64) {} - int volume() const { return 0; } - void setVolume(int) {} - bool isMuted() const { return false; } - void setMuted(bool) {} - int bufferStatus() const { return 0; } - bool isAudioAvailable() const { return false; } - bool isVideoAvailable() const { return false; } - bool isSeekable() const { return false; } - QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); } - qreal playbackRate() const { return 1; } - void setPlaybackRate(qreal) {} - QMediaContent media() const { return QMediaContent(); } - const QIODevice *mediaStream() const { return 0; } - void setMedia(const QMediaContent &, QIODevice *) {} - - void play() {} - void pause() {} - void stop() {} -}; - -class QDeclarativeMediaBaseAnimation : public QObject -{ -public: - QDeclarativeMediaBaseAnimation(QDeclarativeMediaBase *media) - : m_media(media) - { - } - - void start() { if (!m_timer.isActive()) m_timer.start(500, this); } - void stop() { m_timer.stop(); } - -protected: - void timerEvent(QTimerEvent *event) - { - if (event->timerId() == m_timer.timerId()) { - event->accept(); - - if (m_media->m_state == QMediaPlayer::PlayingState) - emit m_media->positionChanged(); - if (m_media->m_status == QMediaPlayer::BufferingMedia || QMediaPlayer::StalledMedia) - emit m_media->bufferProgressChanged(); - } else { - QObject::timerEvent(event); - } - } - -private: - QDeclarativeMediaBase *m_media; - QBasicTimer m_timer; -}; - -void QDeclarativeMediaBase::_q_stateChanged(QMediaPlayer::State state) -{ - if (m_state == state) - return; - - switch (state) { - case QMediaPlayer::StoppedState: { - emit stopped(); - - if (m_playing) { - m_playing = false; - emit playingChanged(); - } - } - break; - case QMediaPlayer::PausedState: { - emit paused(); - - if (!m_paused) { - m_paused = true; - emit pausedChanged(); - } - - if (m_state == QMediaPlayer::StoppedState) - emit started(); - } - break; - case QMediaPlayer::PlayingState: { - if (m_state == QMediaPlayer::PausedState) - emit resumed(); - else - emit started(); - - if (m_paused) { - m_paused = false; - emit pausedChanged(); - } - } - break; - } - - // Check - if (state == QMediaPlayer::PlayingState - || m_status == QMediaPlayer::BufferingMedia - || m_status == QMediaPlayer::StalledMedia) { - m_animation->start(); - } - else { - m_animation->stop(); - } - - m_state = state; -} - -void QDeclarativeMediaBase::_q_mediaStatusChanged(QMediaPlayer::MediaStatus status) -{ - if (status != m_status) { - m_status = status; - - switch (status) { - case QMediaPlayer::LoadedMedia: - emit loaded(); - break; - case QMediaPlayer::BufferingMedia: - emit buffering(); - break; - case QMediaPlayer::BufferedMedia: - emit buffered(); - break; - case QMediaPlayer::StalledMedia: - emit stalled(); - break; - case QMediaPlayer::EndOfMedia: - emit endOfMedia(); - break; - default: - break; - } - - emit statusChanged(); - - if (m_state == QMediaPlayer::PlayingState - || m_status == QMediaPlayer::BufferingMedia - || m_status == QMediaPlayer::StalledMedia) { - m_animation->start(); - } else { - m_animation->stop(); - } - } -} - -void QDeclarativeMediaBase::_q_metaDataChanged() -{ - m_metaObject->metaDataChanged(); -} - -QDeclarativeMediaBase::QDeclarativeMediaBase() - : m_paused(false) - , m_playing(false) - , m_autoLoad(true) - , m_loaded(false) - , m_muted(false) - , m_position(0) - , m_vol(1.0) - , m_playbackRate(1.0) - , m_mediaService(0) - , m_playerControl(0) - , m_mediaObject(0) - , m_mediaProvider(0) - , m_metaDataControl(0) - , m_metaObject(0) - , m_animation(0) - , m_state(QMediaPlayer::StoppedState) - , m_status(QMediaPlayer::NoMedia) - , m_error(QMediaPlayer::ServiceMissingError) -{ -} - -QDeclarativeMediaBase::~QDeclarativeMediaBase() -{ -} - -void QDeclarativeMediaBase::shutdown() -{ - delete m_metaObject; - delete m_mediaObject; - - if (m_mediaProvider) - m_mediaProvider->releaseService(m_mediaService); - - delete m_animation; - -} - -void QDeclarativeMediaBase::setObject(QObject *object) -{ - if ((m_mediaProvider = QMediaServiceProvider::defaultServiceProvider())) { - if ((m_mediaService = m_mediaProvider->requestService(Q_MEDIASERVICE_MEDIAPLAYER))) { - m_playerControl = qobject_cast<QMediaPlayerControl *>( - m_mediaService->control(QMediaPlayerControl_iid)); - m_metaDataControl = qobject_cast<QMetaDataControl *>( - m_mediaService->control(QMetaDataControl_iid)); - m_mediaObject = new QDeclarativeMediaBaseObject(m_mediaService); - } - } - - if (m_playerControl) { - QObject::connect(m_playerControl, SIGNAL(stateChanged(QMediaPlayer::State)), - object, SLOT(_q_stateChanged(QMediaPlayer::State))); - QObject::connect(m_playerControl, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), - object, SLOT(_q_mediaStatusChanged(QMediaPlayer::MediaStatus))); - QObject::connect(m_playerControl, SIGNAL(mediaChanged(QMediaContent)), - object, SIGNAL(sourceChanged())); - QObject::connect(m_playerControl, SIGNAL(durationChanged(qint64)), - object, SIGNAL(durationChanged())); - QObject::connect(m_playerControl, SIGNAL(positionChanged(qint64)), - object, SIGNAL(positionChanged())); - QObject::connect(m_playerControl, SIGNAL(volumeChanged(int)), - object, SIGNAL(volumeChanged())); - QObject::connect(m_playerControl, SIGNAL(mutedChanged(bool)), - object, SIGNAL(mutedChanged())); - QObject::connect(m_playerControl, SIGNAL(bufferStatusChanged(int)), - object, SIGNAL(bufferProgressChanged())); - QObject::connect(m_playerControl, SIGNAL(seekableChanged(bool)), - object, SIGNAL(seekableChanged())); - QObject::connect(m_playerControl, SIGNAL(playbackRateChanged(qreal)), - object, SIGNAL(playbackRateChanged())); - QObject::connect(m_playerControl, SIGNAL(error(int,QString)), - object, SLOT(_q_error(int,QString))); - - m_animation = new QDeclarativeMediaBaseAnimation(this); - m_error = QMediaPlayer::NoError; - } else { - m_playerControl = new QDeclarativeMediaBasePlayerControl(object); - } - - if (m_metaDataControl) { - m_metaObject = new QMetaDataControlMetaObject(m_metaDataControl, object); - - QObject::connect(m_metaDataControl, SIGNAL(metaDataChanged()), - object, SLOT(_q_metaDataChanged())); - } - - // Init - m_playerControl->setVolume(m_vol * 100); - m_playerControl->setMuted(m_muted); - m_playerControl->setPlaybackRate(m_playbackRate); - - if (!m_source.isEmpty() && (m_autoLoad || m_playing)) // Override autoLoad if playing set - m_playerControl->setMedia(m_source, 0); - - if (m_paused) - m_playerControl->pause(); - else if (m_playing) - m_playerControl->play(); - - if ((m_playing || m_paused) && m_position > 0) - m_playerControl->setPosition(m_position); -} - - -// Properties - -QUrl QDeclarativeMediaBase::source() const -{ - return m_source; -} - -void QDeclarativeMediaBase::setSource(const QUrl &url) -{ - if (url == m_source) - return; - - m_source = url; - m_loaded = false; - if (m_playerControl != 0 && m_autoLoad) { - if (m_error != QMediaPlayer::ServiceMissingError && m_error != QMediaPlayer::NoError) { - m_error = QMediaPlayer::NoError; - m_errorString = QString(); - - emit errorChanged(); - } - - m_playerControl->setMedia(m_source, 0); - m_loaded = true; - } - else - emit sourceChanged(); -} - -bool QDeclarativeMediaBase::isAutoLoad() const -{ - return m_autoLoad; -} - -void QDeclarativeMediaBase::setAutoLoad(bool autoLoad) -{ - if (m_autoLoad == autoLoad) - return; - - m_autoLoad = autoLoad; - emit autoLoadChanged(); -} - -bool QDeclarativeMediaBase::isPlaying() const -{ - return m_playing; -} - -void QDeclarativeMediaBase::setPlaying(bool playing) -{ - if (playing == m_playing) - return; - - m_playing = playing; - if (m_playerControl != 0) { - if (m_playing) { - if (!m_autoLoad && !m_loaded) { - m_playerControl->setMedia(m_source, 0); - m_playerControl->setPosition(m_position); - m_loaded = true; - } - - if (!m_paused) - m_playerControl->play(); - else - m_playerControl->pause(); - } - else if (m_state != QMediaPlayer::StoppedState) - m_playerControl->stop(); - } - - emit playingChanged(); -} - -bool QDeclarativeMediaBase::isPaused() const -{ - return m_paused; -} - -void QDeclarativeMediaBase::setPaused(bool paused) -{ - if (m_paused == paused) - return; - - m_paused = paused; - if (m_playerControl != 0) { - if (!m_autoLoad && !m_loaded) { - m_playerControl->setMedia(m_source, 0); - m_playerControl->setPosition(m_position); - m_loaded = true; - } - - if (m_paused && m_state == QMediaPlayer::PlayingState) { - m_playerControl->pause(); - } - else if (!m_paused && m_playing) { - m_playerControl->play(); - } - } - - emit pausedChanged(); -} - -int QDeclarativeMediaBase::duration() const -{ - return m_playerControl == 0 ? 0 : m_playerControl->duration(); -} - -int QDeclarativeMediaBase::position() const -{ - return m_playerControl == 0 ? m_position : m_playerControl->position(); -} - -void QDeclarativeMediaBase::setPosition(int position) -{ - if (m_position == position) - return; - - m_position = position; - if (m_playerControl != 0) - m_playerControl->setPosition(m_position); - else - emit positionChanged(); -} - -qreal QDeclarativeMediaBase::volume() const -{ - return m_playerControl == 0 ? m_vol : qreal(m_playerControl->volume()) / 100; -} - -void QDeclarativeMediaBase::setVolume(qreal volume) -{ - if (m_vol == volume) - return; - - m_vol = volume; - - if (m_playerControl != 0) - m_playerControl->setVolume(qRound(volume * 100)); - else - emit volumeChanged(); -} - -bool QDeclarativeMediaBase::isMuted() const -{ - return m_playerControl == 0 ? m_muted : m_playerControl->isMuted(); -} - -void QDeclarativeMediaBase::setMuted(bool muted) -{ - if (m_muted == muted) - return; - - m_muted = muted; - - if (m_playerControl != 0) - m_playerControl->setMuted(muted); - else - emit mutedChanged(); -} - -qreal QDeclarativeMediaBase::bufferProgress() const -{ - return m_playerControl == 0 ? 0 : qreal(m_playerControl->bufferStatus()) / 100; -} - -bool QDeclarativeMediaBase::isSeekable() const -{ - return m_playerControl == 0 ? false : m_playerControl->isSeekable(); -} - -qreal QDeclarativeMediaBase::playbackRate() const -{ - return m_playbackRate; -} - -void QDeclarativeMediaBase::setPlaybackRate(qreal rate) -{ - if (m_playbackRate == rate) - return; - - m_playbackRate = rate; - - if (m_playerControl != 0) - m_playerControl->setPlaybackRate(m_playbackRate); - else - emit playbackRateChanged(); -} - -QString QDeclarativeMediaBase::errorString() const -{ - return m_errorString; -} - -QT_END_NAMESPACE - diff --git a/src/imports/multimedia/qdeclarativemediabase_p.h b/src/imports/multimedia/qdeclarativemediabase_p.h deleted file mode 100644 index 34875f9..0000000 --- a/src/imports/multimedia/qdeclarativemediabase_p.h +++ /dev/null @@ -1,181 +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 QDECLARATIVEMEDIABASE_P_H -#define QDECLARATIVEMEDIABASE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qbasictimer.h> -#include <QtMediaServices/qmediaplayer.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaPlayerControl; -class QMediaService; -class QMediaServiceProvider; -class QMetaDataControl; -class QMetaDataControlMetaObject; -class QDeclarativeMediaBaseAnimation; - -class QDeclarativeMediaBase -{ -public: - QDeclarativeMediaBase(); - virtual ~QDeclarativeMediaBase(); - - QUrl source() const; - void setSource(const QUrl &url); - - bool isAutoLoad() const; - void setAutoLoad(bool autoLoad); - - bool isPlaying() const; - void setPlaying(bool playing); - - bool isPaused() const; - void setPaused(bool paused); - - int duration() const; - - int position() const; - void setPosition(int position); - - qreal volume() const; - void setVolume(qreal volume); - - bool isMuted() const; - void setMuted(bool muted); - - qreal bufferProgress() const; - - bool isSeekable() const; - - qreal playbackRate() const; - void setPlaybackRate(qreal rate); - - QString errorString() const; - - void _q_stateChanged(QMediaPlayer::State state); - void _q_mediaStatusChanged(QMediaPlayer::MediaStatus status); - - void _q_metaDataChanged(); - - void componentComplete(); - -protected: - void shutdown(); - - void setObject(QObject *object); - - virtual void sourceChanged() = 0; - virtual void autoLoadChanged() = 0; - virtual void playingChanged() = 0; - virtual void pausedChanged() = 0; - - virtual void started() = 0; - virtual void resumed() = 0; - virtual void paused() = 0; - virtual void stopped() = 0; - - virtual void statusChanged() = 0; - - virtual void loaded() = 0; - virtual void buffering() = 0; - virtual void stalled() = 0; - virtual void buffered() = 0; - virtual void endOfMedia() = 0; - - virtual void durationChanged() = 0; - virtual void positionChanged() = 0; - - virtual void volumeChanged() = 0; - virtual void mutedChanged() = 0; - - virtual void bufferProgressChanged() = 0; - - virtual void seekableChanged() = 0; - virtual void playbackRateChanged() = 0; - - virtual void errorChanged() = 0; - - bool m_paused; - bool m_playing; - bool m_autoLoad; - bool m_loaded; - bool m_muted; - int m_position; - qreal m_vol; - qreal m_playbackRate; - QMediaService *m_mediaService; - QMediaPlayerControl *m_playerControl; - - QMediaObject *m_mediaObject; - QMediaServiceProvider *m_mediaProvider; - QMetaDataControl *m_metaDataControl; - QMetaDataControlMetaObject *m_metaObject; - QDeclarativeMediaBaseAnimation *m_animation; - - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_status; - QMediaPlayer::Error m_error; - QString m_errorString; - QUrl m_source; - - friend class QDeclarativeMediaBaseAnimation; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/imports/multimedia/qdeclarativevideo.cpp b/src/imports/multimedia/qdeclarativevideo.cpp deleted file mode 100644 index 1b51e2c..0000000 --- a/src/imports/multimedia/qdeclarativevideo.cpp +++ /dev/null @@ -1,976 +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 "qdeclarativevideo_p.h" - -#include <QtMediaServices/qmediaplayercontrol.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/private/qpaintervideosurface_p.h> -#include <QtMediaServices/qvideooutputcontrol.h> -#include <QtMediaServices/qvideorenderercontrol.h> - - -QT_BEGIN_NAMESPACE - - -void QDeclarativeVideo::_q_nativeSizeChanged(const QSizeF &size) -{ - setImplicitWidth(size.width()); - setImplicitHeight(size.height()); -} - -void QDeclarativeVideo::_q_error(int errorCode, const QString &errorString) -{ - m_error = QMediaPlayer::Error(errorCode); - m_errorString = errorString; - - emit error(Error(errorCode), errorString); - emit errorChanged(); -} - - -/*! - \qmlclass Video QDeclarativeVideo - \since 4.7 - \brief The Video element allows you to add videos to a scene. - \inherits Item - - This element is part of the \bold{Qt.multimedia 4.7} module. - - \qml - import Qt 4.7 - import Qt.multimedia 4.7 - - Video { - id: video - width : 800 - height : 600 - source: "video.avi" - - MouseArea { - anchors.fill: parent - onClicked: { - video.play() - } - } - - focus: true - Keys.onSpacePressed: video.paused = !video.paused - Keys.onLeftPressed: video.position -= 5000 - Keys.onRightPressed: video.position += 5000 - } - \endqml - - The Video item supports untransformed, stretched, and uniformly scaled video presentation. - For a description of stretched uniformly scaled presentation, see the \l fillMode property - description. - - The Video item is only visible when the \l hasVideo property is true and the video is playing. - - \sa Audio -*/ - -/*! - \internal - \class QDeclarativeVideo - \brief The QDeclarativeVideo class provides a video item that you can add to a QDeclarativeView. -*/ - -QDeclarativeVideo::QDeclarativeVideo(QDeclarativeItem *parent) - : QDeclarativeItem(parent) - , m_graphicsItem(0) - -{ - m_graphicsItem = new QGraphicsVideoItem(this); - connect(m_graphicsItem, SIGNAL(nativeSizeChanged(QSizeF)), - this, SLOT(_q_nativeSizeChanged(QSizeF))); -} - -QDeclarativeVideo::~QDeclarativeVideo() -{ - shutdown(); - - delete m_graphicsItem; -} - -/*! - \qmlproperty url Video::source - - This property holds the source URL of the media. -*/ - -/*! - \qmlproperty url Video::autoLoad - - This property indicates if loading of media should begin immediately. - - Defaults to true, if false media will not be loaded until playback is started. -*/ - -/*! - \qmlproperty bool Video::playing - - This property holds whether the media is playing. - - Defaults to false, and can be set to true to start playback. -*/ - -/*! - \qmlproperty bool Video::paused - - This property holds whether the media is paused. - - Defaults to false, and can be set to true to pause playback. -*/ - -/*! - \qmlsignal Video::onStarted() - - This handler is called when playback is started. -*/ - -/*! - \qmlsignal Video::onResumed() - - This handler is called when playback is resumed from the paused state. -*/ - -/*! - \qmlsignal Video::onPaused() - - This handler is called when playback is paused. -*/ - -/*! - \qmlsignal Video::onStopped() - - This handler is called when playback is stopped. -*/ - -/*! - \qmlproperty enumeration Video::status - - This property holds the status of media loading. It can be one of: - - \list - \o NoMedia - no media has been set. - \o Loading - the media is currently being loaded. - \o Loaded - the media has been loaded. - \o Buffering - the media is buffering data. - \o Stalled - playback has been interrupted while the media is buffering data. - \o Buffered - the media has buffered data. - \o EndOfMedia - the media has played to the end. - \o InvalidMedia - the media cannot be played. - \o UnknownStatus - the status of the media is cannot be determined. - \endlist -*/ - -QDeclarativeVideo::Status QDeclarativeVideo::status() const -{ - return Status(m_status); -} - -/*! - \qmlsignal Video::onLoaded() - - This handler is called when the media source has been loaded. -*/ - -/*! - \qmlsignal Video::onBuffering() - - This handler is called when the media starts buffering. -*/ - -/*! - \qmlsignal Video::onStalled() - - This handler is called when playback has stalled while the media buffers. -*/ - -/*! - \qmlsignal Video::onBuffered() - - This handler is called when the media has finished buffering. -*/ - -/*! - \qmlsignal Video::onEndOfMedia() - - This handler is called when playback stops because end of the media has been reached. -*/ - -/*! - \qmlproperty int Video::duration - - This property holds the duration of the media in milliseconds. - - If the media doesn't have a fixed duration (a live stream for example) this will be 0. -*/ - -/*! - \qmlproperty int Video::position - - This property holds the current playback position in milliseconds. -*/ - -/*! - \qmlproperty real Video::volume - - This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume). -*/ - -/*! - \qmlproperty bool Video::muted - - This property holds whether the audio output is muted. -*/ - -/*! - \qmlproperty bool Video::hasAudio - - This property holds whether the media contains audio. -*/ - -bool QDeclarativeVideo::hasAudio() const -{ - return m_playerControl == 0 ? false : m_playerControl->isAudioAvailable(); -} - -/*! - \qmlproperty bool Video::hasVideo - - This property holds whether the media contains video. -*/ - -bool QDeclarativeVideo::hasVideo() const -{ - return m_playerControl == 0 ? false : m_playerControl->isVideoAvailable(); -} - -/*! - \qmlproperty real Video::bufferProgress - - This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0 - (full). -*/ - -/*! - \qmlproperty bool Video::seekable - - This property holds whether position of the video can be changed. -*/ - -/*! - \qmlproperty real Video::playbackRate - - This property holds the rate at which video is played at as a multiple of the normal rate. -*/ - -/*! - \qmlproperty enumeration Video::error - - This property holds the error state of the video. It can be one of: - - \list - \o NoError - there is no current error. - \o ResourceError - the video cannot be played due to a problem allocating resources. - \o FormatError - the video format is not supported. - \o NetworkError - the video cannot be played due to network issues. - \o AccessDenied - the video cannot be played due to insufficient permissions. - \o ServiceMissing - the video cannot be played because the media service could not be - instantiated. - \endlist -*/ - - -QDeclarativeVideo::Error QDeclarativeVideo::error() const -{ - return Error(m_error); -} - -/*! - \qmlproperty string Video::errorString - - This property holds a string describing the current error condition in more detail. -*/ - -/*! - \qmlsignal Video::onError(error, errorString) - - This handler is called when an \l {QMediaPlayer::Error}{error} has - occurred. The errorString parameter may contain more detailed - information about the error. -*/ - -/*! - \qmlproperty enumeration Video::fillMode - - Set this property to define how the video is scaled to fit the target area. - - \list - \o Stretch - the video is scaled to fit. - \o PreserveAspectFit - the video is scaled uniformly to fit without cropping - \o PreserveAspectCrop - the video is scaled uniformly to fill, cropping if necessary - \endlist - - The default fill mode is PreserveAspectFit. -*/ - -QDeclarativeVideo::FillMode QDeclarativeVideo::fillMode() const -{ - return FillMode(m_graphicsItem->aspectRatioMode()); -} - -void QDeclarativeVideo::setFillMode(FillMode mode) -{ - m_graphicsItem->setAspectRatioMode(Qt::AspectRatioMode(mode)); -} - -/*! - \qmlmethod Video::play() - - Starts playback of the media. - - Sets the \l playing property to true, and the \l paused property to false. -*/ - -void QDeclarativeVideo::play() -{ - if (m_playerControl == 0) - return; - - setPaused(false); - setPlaying(true); -} - -/*! - \qmlmethod Video::pause() - - Pauses playback of the media. - - Sets the \l playing and \l paused properties to true. -*/ - -void QDeclarativeVideo::pause() -{ - if (m_playerControl == 0) - return; - - setPaused(true); - setPlaying(true); -} - -/*! - \qmlmethod Video::stop() - - Stops playback of the media. - - Sets the \l playing and \l paused properties to false. -*/ - -void QDeclarativeVideo::stop() -{ - if (m_playerControl == 0) - return; - - setPlaying(false); - setPaused(false); -} - -void QDeclarativeVideo::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) -{ -} - -void QDeclarativeVideo::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - m_graphicsItem->setSize(newGeometry.size()); - - QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); -} - -void QDeclarativeVideo::componentComplete() -{ - setObject(this); - - if (m_mediaService) { - connect(m_playerControl, SIGNAL(audioAvailableChanged(bool)), - this, SIGNAL(hasAudioChanged())); - connect(m_playerControl, SIGNAL(videoAvailableChanged(bool)), - this, SIGNAL(hasVideoChanged())); - - m_graphicsItem->setMediaObject(m_mediaObject); - } -} - -QT_END_NAMESPACE - -// *************************************** -// Documentation for meta-data properties. -// *************************************** - -/*! - \qmlproperty variant Video::title - - This property holds the tile of the media. - - \sa {QtMediaServices::Title} -*/ - -/*! - \qmlproperty variant Video::subTitle - - This property holds the sub-title of the media. - - \sa {QtMediaServices::SubTitle} -*/ - -/*! - \qmlproperty variant Video::author - - This property holds the author of the media. - - \sa {QtMediaServices::Author} -*/ - -/*! - \qmlproperty variant Video::comment - - This property holds a user comment about the media. - - \sa {QtMediaServices::Comment} -*/ - -/*! - \qmlproperty variant Video::description - - This property holds a description of the media. - - \sa {QtMediaServices::Description} -*/ - -/*! - \qmlproperty variant Video::category - - This property holds the category of the media - - \sa {QtMediaServices::Category} -*/ - -/*! - \qmlproperty variant Video::genre - - This property holds the genre of the media. - - \sa {QtMediaServices::Genre} -*/ - -/*! - \qmlproperty variant Video::year - - This property holds the year of release of the media. - - \sa {QtMediaServices::Year} -*/ - -/*! - \qmlproperty variant Video::date - - This property holds the date of the media. - - \sa {QtMediaServices::Date} -*/ - -/*! - \qmlproperty variant Video::userRating - - This property holds a user rating of the media in the range of 0 to 100. - - \sa {QtMediaServices::UserRating} -*/ - -/*! - \qmlproperty variant Video::keywords - - This property holds a list of keywords describing the media. - - \sa {QtMediaServices::Keywords} -*/ - -/*! - \qmlproperty variant Video::language - - This property holds the language of the media, as an ISO 639-2 code. - - \sa {QtMediaServices::Language} -*/ - -/*! - \qmlproperty variant Video::publisher - - This property holds the publisher of the media. - - \sa {QtMediaServices::Publisher} -*/ - -/*! - \qmlproperty variant Video::copyright - - This property holds the media's copyright notice. - - \sa {QtMediaServices::Copyright} -*/ - -/*! - \qmlproperty variant Video::parentalRating - - This property holds the parental rating of the media. - - \sa {QtMediaServices::ParentalRating} -*/ - -/*! - \qmlproperty variant Video::ratingOrganisation - - This property holds the name of the rating organisation responsible for the - parental rating of the media. - - \sa {QtMediaServices::RatingOrganisation} -*/ - -/*! - \qmlproperty variant Video::size - - This property property holds the size of the media in bytes. - - \sa {QtMediaServices::Size} -*/ - -/*! - \qmlproperty variant Video::mediaType - - This property holds the type of the media. - - \sa {QtMediaServices::MediaType} -*/ - -/*! - \qmlproperty variant Video::audioBitRate - - This property holds the bit rate of the media's audio stream ni bits per - second. - - \sa {QtMediaServices::AudioBitRate} -*/ - -/*! - \qmlproperty variant Video::audioCodec - - This property holds the encoding of the media audio stream. - - \sa {QtMediaServices::AudioCodec} -*/ - -/*! - \qmlproperty variant Video::averageLevel - - This property holds the average volume level of the media. - - \sa {QtMediaServices::AverageLevel} -*/ - -/*! - \qmlproperty variant Video::channelCount - - This property holds the number of channels in the media's audio stream. - - \sa {QtMediaServices::ChannelCount} -*/ - -/*! - \qmlproperty variant Video::peakValue - - This property holds the peak volume of media's audio stream. - - \sa {QtMediaServices::PeakValue} -*/ - -/*! - \qmlproperty variant Video::sampleRate - - This property holds the sample rate of the media's audio stream in hertz. - - \sa {QtMediaServices::SampleRate} -*/ - -/*! - \qmlproperty variant Video::albumTitle - - This property holds the title of the album the media belongs to. - - \sa {QtMediaServices::AlbumTitle} -*/ - -/*! - \qmlproperty variant Video::albumArtist - - This property holds the name of the principal artist of the album the media - belongs to. - - \sa {QtMediaServices::AlbumArtist} -*/ - -/*! - \qmlproperty variant Video::contributingArtist - - This property holds the names of artists contributing to the media. - - \sa {QtMediaServices::ContributingArtist} -*/ - -/*! - \qmlproperty variant Video::composer - - This property holds the composer of the media. - - \sa {QtMediaServices::Composer} -*/ - -/*! - \qmlproperty variant Video::conductor - - This property holds the conductor of the media. - - \sa {QtMediaServices::Conductor} -*/ - -/*! - \qmlproperty variant Video::lyrics - - This property holds the lyrics to the media. - - \sa {QtMediaServices::Lyrics} -*/ - -/*! - \qmlproperty variant Video::mood - - This property holds the mood of the media. - - \sa {QtMediaServices::Mood} -*/ - -/*! - \qmlproperty variant Video::trackNumber - - This property holds the track number of the media. - - \sa {QtMediaServices::TrackNumber} -*/ - -/*! - \qmlproperty variant Video::trackCount - - This property holds the number of track on the album containing the media. - - \sa {QtMediaServices::TrackNumber} -*/ - -/*! - \qmlproperty variant Video::coverArtUrlSmall - - This property holds the URL of a small cover art image. - - \sa {QtMediaServices::CoverArtUrlSmall} -*/ - -/*! - \qmlproperty variant Video::coverArtUrlLarge - - This property holds the URL of a large cover art image. - - \sa {QtMediaServices::CoverArtUrlLarge} -*/ - -/*! - \qmlproperty variant Video::resolution - - This property holds the dimension of an image or video. - - \sa {QtMediaServices::Resolution} -*/ - -/*! - \qmlproperty variant Video::pixelAspectRatio - - This property holds the pixel aspect ratio of an image or video. - - \sa {QtMediaServices::PixelAspectRatio} -*/ - -/*! - \qmlproperty variant Video::videoFrameRate - - This property holds the frame rate of the media's video stream. - - \sa {QtMediaServices::VideoFrameRate} -*/ - -/*! - \qmlproperty variant Video::videoBitRate - - This property holds the bit rate of the media's video stream in bits per - second. - - \sa {QtMediaServices::VideoBitRate} -*/ - -/*! - \qmlproperty variant Video::videoCodec - - This property holds the encoding of the media's video stream. - - \sa {QtMediaServices::VideoCodec} -*/ - -/*! - \qmlproperty variant Video::posterUrl - - This property holds the URL of a poster image. - - \sa {QtMediaServices::PosterUrl} -*/ - -/*! - \qmlproperty variant Video::chapterNumber - - This property holds the chapter number of the media. - - \sa {QtMediaServices::ChapterNumber} -*/ - -/*! - \qmlproperty variant Video::director - - This property holds the director of the media. - - \sa {QtMediaServices::Director} -*/ - -/*! - \qmlproperty variant Video::leadPerformer - - This property holds the lead performer in the media. - - \sa {QtMediaServices::LeadPerformer} -*/ - -/*! - \qmlproperty variant Video::writer - - This property holds the writer of the media. - - \sa {QtMediaServices::Writer} -*/ - -// The remaining properties are related to photos, and are technically -// available but will certainly never have values. -#ifndef Q_QDOC - -/*! - \qmlproperty variant Video::cameraManufacturer - - \sa {QtMediaServices::CameraManufacturer} -*/ - -/*! - \qmlproperty variant Video::cameraModel - - \sa {QtMediaServices::CameraModel} -*/ - -/*! - \qmlproperty variant Video::event - - \sa {QtMediaServices::Event} -*/ - -/*! - \qmlproperty variant Video::subject - - \sa {QtMediaServices::Subject} -*/ - -/*! - \qmlproperty variant Video::orientation - - \sa {QtMediaServices::Orientation} -*/ - -/*! - \qmlproperty variant Video::exposureTime - - \sa {QtMediaServices::ExposureTime} -*/ - -/*! - \qmlproperty variant Video::fNumber - - \sa {QtMediaServices::FNumber} -*/ - -/*! - \qmlproperty variant Video::exposureProgram - - \sa {QtMediaServices::ExposureProgram} -*/ - -/*! - \qmlproperty variant Video::isoSpeedRatings - - \sa {QtMediaServices::ISOSpeedRatings} -*/ - -/*! - \qmlproperty variant Video::exposureBiasValue - - \sa {QtMediaServices::ExposureBiasValue} -*/ - -/*! - \qmlproperty variant Video::dateTimeDigitized - - \sa {QtMediaServices::DateTimeDigitized} -*/ - -/*! - \qmlproperty variant Video::subjectDistance - - \sa {QtMediaServices::SubjectDistance} -*/ - -/*! - \qmlproperty variant Video::meteringMode - - \sa {QtMediaServices::MeteringMode} -*/ - -/*! - \qmlproperty variant Video::lightSource - - \sa {QtMediaServices::LightSource} -*/ - -/*! - \qmlproperty variant Video::flash - - \sa {QtMediaServices::Flash} -*/ - -/*! - \qmlproperty variant Video::focalLength - - \sa {QtMediaServices::FocalLength} -*/ - -/*! - \qmlproperty variant Video::exposureMode - - \sa {QtMediaServices::ExposureMode} -*/ - -/*! - \qmlproperty variant Video::whiteBalance - - \sa {QtMediaServices::WhiteBalance} -*/ - -/*! - \qmlproperty variant Video::DigitalZoomRatio - - \sa {QtMediaServices::DigitalZoomRatio} -*/ - -/*! - \qmlproperty variant Video::focalLengthIn35mmFilm - - \sa {QtMediaServices::FocalLengthIn35mmFile} -*/ - -/*! - \qmlproperty variant Video::sceneCaptureType - - \sa {QtMediaServices::SceneCaptureType} -*/ - -/*! - \qmlproperty variant Video::gainControl - - \sa {QtMediaServices::GainControl} -*/ - -/*! - \qmlproperty variant Video::contrast - - \sa {QtMediaServices::contrast} -*/ - -/*! - \qmlproperty variant Video::saturation - - \sa {QtMediaServices::Saturation} -*/ - -/*! - \qmlproperty variant Video::sharpness - - \sa {QtMediaServices::Sharpness} -*/ - -/*! - \qmlproperty variant Video::deviceSettingDescription - - \sa {QtMediaServices::DeviceSettingDescription} -*/ - -#endif - -#include "moc_qdeclarativevideo_p.cpp" diff --git a/src/imports/multimedia/qdeclarativevideo_p.h b/src/imports/multimedia/qdeclarativevideo_p.h deleted file mode 100644 index c048b7d..0000000 --- a/src/imports/multimedia/qdeclarativevideo_p.h +++ /dev/null @@ -1,207 +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 QDECLARATIVEVIDEO_H -#define QDECLARATIVEVIDEO_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativemediabase_p.h" - -#include <QtMediaServices/qgraphicsvideoitem.h> - -#include <QtCore/qbasictimer.h> -#include <QtDeclarative/qdeclarativeitem.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QTimerEvent; -class QVideoSurfaceFormat; - - -class QDeclarativeVideo : public QDeclarativeItem, public QDeclarativeMediaBase -{ - Q_OBJECT - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(bool autoLoad READ isAutoLoad WRITE setAutoLoad NOTIFY autoLoadChanged) - Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged) - Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - Q_PROPERTY(int duration READ duration NOTIFY durationChanged) - Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged) - Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged) - Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - Q_PROPERTY(bool hasAudio READ hasAudio NOTIFY hasAudioChanged) - Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged) - Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged) - Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged) - Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged) - Q_PROPERTY(Error error READ error NOTIFY errorChanged) - Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged) - Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode) - Q_ENUMS(FillMode) - Q_ENUMS(Status) - Q_ENUMS(Error) -public: - enum FillMode - { - Stretch = Qt::IgnoreAspectRatio, - PreserveAspectFit = Qt::KeepAspectRatio, - PreserveAspectCrop = Qt::KeepAspectRatioByExpanding - }; - - enum Status - { - UnknownStatus = QMediaPlayer::UnknownMediaStatus, - NoMedia = QMediaPlayer::NoMedia, - Loading = QMediaPlayer::LoadingMedia, - Loaded = QMediaPlayer::LoadedMedia, - Stalled = QMediaPlayer::StalledMedia, - Buffering = QMediaPlayer::BufferingMedia, - Buffered = QMediaPlayer::BufferedMedia, - EndOfMedia = QMediaPlayer::EndOfMedia, - InvalidMedia = QMediaPlayer::InvalidMedia - }; - - enum Error - { - NoError = QMediaPlayer::NoError, - ResourceError = QMediaPlayer::ResourceError, - FormatError = QMediaPlayer::FormatError, - NetworkError = QMediaPlayer::NetworkError, - AccessDenied = QMediaPlayer::AccessDeniedError, - ServiceMissing = QMediaPlayer::ServiceMissingError - }; - - QDeclarativeVideo(QDeclarativeItem *parent = 0); - ~QDeclarativeVideo(); - - bool hasAudio() const; - bool hasVideo() const; - - FillMode fillMode() const; - void setFillMode(FillMode mode); - - Status status() const; - Error error() const; - - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - - void componentComplete(); - -public Q_SLOTS: - void play(); - void pause(); - void stop(); - -Q_SIGNALS: - void sourceChanged(); - void autoLoadChanged(); - void playingChanged(); - void pausedChanged(); - - void started(); - void resumed(); - void paused(); - void stopped(); - - void statusChanged(); - - void loaded(); - void buffering(); - void stalled(); - void buffered(); - void endOfMedia(); - - void durationChanged(); - void positionChanged(); - - void volumeChanged(); - void mutedChanged(); - void hasAudioChanged(); - void hasVideoChanged(); - - void bufferProgressChanged(); - - void seekableChanged(); - void playbackRateChanged(); - - void errorChanged(); - void error(QDeclarativeVideo::Error error, const QString &errorString); - -protected: - void geometryChanged(const QRectF &geometry, const QRectF &); - -private Q_SLOTS: - void _q_nativeSizeChanged(const QSizeF &size); - void _q_error(int, const QString &); - -private: - Q_DISABLE_COPY(QDeclarativeVideo) - - QGraphicsVideoItem *m_graphicsItem; - - Q_PRIVATE_SLOT(mediaBase(), void _q_stateChanged(QMediaPlayer::State)) - Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus)) - Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged()) - - inline QDeclarativeMediaBase *mediaBase() { return this; } -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeVideo)) - -QT_END_HEADER - -#endif diff --git a/src/imports/multimedia/qmetadatacontrolmetaobject.cpp b/src/imports/multimedia/qmetadatacontrolmetaobject.cpp deleted file mode 100644 index 5235a87..0000000 --- a/src/imports/multimedia/qmetadatacontrolmetaobject.cpp +++ /dev/null @@ -1,362 +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 "qmetadatacontrolmetaobject_p.h" -#include <QtMediaServices/qmetadatacontrol.h> - - -QT_BEGIN_NAMESPACE - -// copied from qmetaobject.cpp -// do not touch without touching the moc as well -enum PropertyFlags { - Invalid = 0x00000000, - Readable = 0x00000001, - Writable = 0x00000002, - Resettable = 0x00000004, - EnumOrFlag = 0x00000008, - StdCppSet = 0x00000100, -// Override = 0x00000200, - Designable = 0x00001000, - ResolveDesignable = 0x00002000, - Scriptable = 0x00004000, - ResolveScriptable = 0x00008000, - Stored = 0x00010000, - ResolveStored = 0x00020000, - Editable = 0x00040000, - ResolveEditable = 0x00080000, - User = 0x00100000, - ResolveUser = 0x00200000, - Notify = 0x00400000, - Dynamic = 0x00800000 -}; - -enum MethodFlags { - AccessPrivate = 0x00, - AccessProtected = 0x01, - AccessPublic = 0x02, - AccessMask = 0x03, //mask - - MethodMethod = 0x00, - MethodSignal = 0x04, - MethodSlot = 0x08, - MethodConstructor = 0x0c, - MethodTypeMask = 0x0c, - - MethodCompatibility = 0x10, - MethodCloned = 0x20, - MethodScriptable = 0x40 -}; - -struct QMetaObjectPrivate -{ - int revision; - int className; - int classInfoCount, classInfoData; - int methodCount, methodData; - int propertyCount, propertyData; - int enumeratorCount, enumeratorData; - int constructorCount, constructorData; - int flags; -}; - -static inline const QMetaObjectPrivate *priv(const uint* m_data) -{ return reinterpret_cast<const QMetaObjectPrivate*>(m_data); } -// end of copied lines from qmetaobject.cpp - -namespace -{ - struct MetaDataKey - { - QtMediaServices::MetaData key; - const char *name; - }; - - const MetaDataKey qt_metaDataKeys[] = - { - { QtMediaServices::Title, "title" }, - { QtMediaServices::SubTitle, "subTitle" }, - { QtMediaServices::Author, "author" }, - { QtMediaServices::Comment, "comment" }, - { QtMediaServices::Description, "description" }, - { QtMediaServices::Category, "category" }, - { QtMediaServices::Genre, "genre" }, - { QtMediaServices::Year, "year" }, - { QtMediaServices::Date, "date" }, - { QtMediaServices::UserRating, "userRating" }, - { QtMediaServices::Keywords, "keywords" }, - { QtMediaServices::Language, "language" }, - { QtMediaServices::Publisher, "publisher" }, - { QtMediaServices::Copyright, "copyright" }, - { QtMediaServices::ParentalRating, "parentalRating" }, - { QtMediaServices::RatingOrganisation, "ratingOrganisation" }, - - // Media - { QtMediaServices::Size, "size" }, - { QtMediaServices::MediaType, "mediaType" }, -// { QtMediaServices::Duration, "duration" }, - - // Audio - { QtMediaServices::AudioBitRate, "audioBitRate" }, - { QtMediaServices::AudioCodec, "audioCodec" }, - { QtMediaServices::AverageLevel, "averageLevel" }, - { QtMediaServices::ChannelCount, "channelCount" }, - { QtMediaServices::PeakValue, "peakValue" }, - { QtMediaServices::SampleRate, "sampleRate" }, - - // Music - { QtMediaServices::AlbumTitle, "albumTitle" }, - { QtMediaServices::AlbumArtist, "albumArtist" }, - { QtMediaServices::ContributingArtist, "contributingArtist" }, - { QtMediaServices::Composer, "composer" }, - { QtMediaServices::Conductor, "conductor" }, - { QtMediaServices::Lyrics, "lyrics" }, - { QtMediaServices::Mood, "mood" }, - { QtMediaServices::TrackNumber, "trackNumber" }, - { QtMediaServices::TrackCount, "trackCount" }, - - { QtMediaServices::CoverArtUrlSmall, "coverArtUrlSmall" }, - { QtMediaServices::CoverArtUrlLarge, "coverArtUrlLarge" }, - - // Image/Video - { QtMediaServices::Resolution, "resolution" }, - { QtMediaServices::PixelAspectRatio, "pixelAspectRatio" }, - - // Video - { QtMediaServices::VideoFrameRate, "videoFrameRate" }, - { QtMediaServices::VideoBitRate, "videoBitRate" }, - { QtMediaServices::VideoCodec, "videoCodec" }, - - { QtMediaServices::PosterUrl, "posterUrl" }, - - // Movie - { QtMediaServices::ChapterNumber, "chapterNumber" }, - { QtMediaServices::Director, "director" }, - { QtMediaServices::LeadPerformer, "leadPerformer" }, - { QtMediaServices::Writer, "writer" }, - - // Photos - { QtMediaServices::CameraManufacturer, "cameraManufacturer" }, - { QtMediaServices::CameraModel, "cameraModel" }, - { QtMediaServices::Event, "event" }, - { QtMediaServices::Subject, "subject" }, - { QtMediaServices::Orientation, "orientation" }, - { QtMediaServices::ExposureTime, "exposureTime" }, - { QtMediaServices::FNumber, "fNumber" }, - { QtMediaServices::ExposureProgram, "exposureProgram" }, - { QtMediaServices::ISOSpeedRatings, "isoSpeedRatings" }, - { QtMediaServices::ExposureBiasValue, "exposureBiasValue" }, - { QtMediaServices::DateTimeOriginal, "dateTimeOriginal" }, - { QtMediaServices::DateTimeDigitized, "dateTimeDigitized" }, - { QtMediaServices::SubjectDistance, "subjectDistance" }, - { QtMediaServices::MeteringMode, "meteringMode" }, - { QtMediaServices::LightSource, "lightSource" }, - { QtMediaServices::Flash, "flash" }, - { QtMediaServices::FocalLength, "focalLength" }, - { QtMediaServices::ExposureMode, "exposureMode" }, - { QtMediaServices::WhiteBalance, "whiteBalance" }, - { QtMediaServices::DigitalZoomRatio, "digitalZoomRatio" }, - { QtMediaServices::FocalLengthIn35mmFilm, "focalLengthIn35mmFilm" }, - { QtMediaServices::SceneCaptureType, "sceneCaptureType" }, - { QtMediaServices::GainControl, "gainControl" }, - { QtMediaServices::Contrast, "contrast" }, - { QtMediaServices::Saturation, "saturation" }, - { QtMediaServices::Sharpness, "sharpness" }, - { QtMediaServices::DeviceSettingDescription, "deviceSettingDescription" } - }; - - class QMetaDataControlObject : public QObject - { - public: - inline QObjectData *data() { return d_ptr.data(); } - }; -} - -QMetaDataControlMetaObject::QMetaDataControlMetaObject(QMetaDataControl *control, QObject *object) - : m_control(control) - , m_object(object) - , m_string(0) - , m_data(0) - , m_propertyOffset(0) - , m_signalOffset(0) -{ - const QMetaObject *superClass = m_object->metaObject(); - - const int propertyCount = sizeof(qt_metaDataKeys) / sizeof(MetaDataKey); - const int dataSize = sizeof(uint) - * (13 // QMetaObjectPrivate members. - + 5 // 5 members per signal. - + 4 * propertyCount // 3 members per property + 1 notify signal per property. - + 1); // Terminating value. - - m_data = reinterpret_cast<uint *>(qMalloc(dataSize)); - - QMetaObjectPrivate *pMeta = reinterpret_cast<QMetaObjectPrivate *>(m_data); - - pMeta->revision = 3; - pMeta->className = 0; - pMeta->classInfoCount = 0; - pMeta->classInfoData = 0; - pMeta->methodCount = 1; - pMeta->methodData = 13; - pMeta->propertyCount = propertyCount; - pMeta->propertyData = 18; - pMeta->enumeratorCount = 0; - pMeta->enumeratorData = 0; - pMeta->constructorCount = 0; - pMeta->constructorData = 0; - pMeta->flags = 0x01; // Dynamic meta object flag. - - const int classNameSize = qstrlen(superClass->className()) + 1; - - int stringIndex = classNameSize + 1; - - // __metaDataChanged() signal. - static const char *changeSignal = "__metaDataChanged()"; - const int changeSignalSize = qstrlen(changeSignal) + 1; - - m_data[13] = stringIndex; // Signature. - m_data[14] = classNameSize; // Parameters. - m_data[15] = classNameSize; // Type. - m_data[16] = classNameSize; // Tag. - m_data[17] = MethodSignal | AccessProtected; // Flags. - - stringIndex += changeSignalSize; - - const char *qvariantName = "QVariant"; - const int qvariantSize = qstrlen(qvariantName) + 1; - const int qvariantIndex = stringIndex; - - stringIndex += qvariantSize; - - // Properties. - for (int i = 0; i < propertyCount; ++i) { - m_data[18 + 3 * i] = stringIndex; // Name. - m_data[19 + 3 * i] = qvariantIndex; // Type. - m_data[20 + 3 * i] - = Readable | Writable | Notify | Dynamic | (0xffffffff << 24); // Flags. - m_data[18 + propertyCount * 3 + i] = 0; // Notify signal. - - stringIndex += qstrlen(qt_metaDataKeys[i].name) + 1; - } - - // Terminating value. - m_data[18 + propertyCount * 4] = 0; - - // Build string. - m_string = reinterpret_cast<char *>(qMalloc(stringIndex + 1)); - - // Class name. - qMemCopy(m_string, superClass->className(), classNameSize); - - stringIndex = classNameSize; - - // Null m_string. - m_string[stringIndex] = '\0'; - stringIndex += 1; - - // __metaDataChanged() signal. - qMemCopy(m_string + stringIndex, changeSignal, changeSignalSize); - stringIndex += changeSignalSize; - - qMemCopy(m_string + stringIndex, qvariantName, qvariantSize); - stringIndex += qvariantSize; - - // Properties. - for (int i = 0; i < propertyCount; ++i) { - const int propertyNameSize = qstrlen(qt_metaDataKeys[i].name) + 1; - - qMemCopy(m_string + stringIndex, qt_metaDataKeys[i].name, propertyNameSize); - stringIndex += propertyNameSize; - } - - // Terminating character. - m_string[stringIndex] = '\0'; - - d.superdata = superClass; - d.stringdata = m_string; - d.data = m_data; - d.extradata = 0; - - static_cast<QMetaDataControlObject *>(m_object)->data()->metaObject = this; - - m_propertyOffset = propertyOffset(); - m_signalOffset = methodOffset(); -} - -QMetaDataControlMetaObject::~QMetaDataControlMetaObject() -{ - static_cast<QMetaDataControlObject *>(m_object)->data()->metaObject = 0; - - qFree(m_data); - qFree(m_string); -} - -int QMetaDataControlMetaObject::metaCall(QMetaObject::Call c, int id, void **a) -{ - if (c == QMetaObject::ReadProperty && id >= m_propertyOffset) { - int propId = id - m_propertyOffset; - - *reinterpret_cast<QVariant *>(a[0]) = m_control->metaData(qt_metaDataKeys[propId].key); - - return -1; - } else if (c == QMetaObject::WriteProperty && id >= m_propertyOffset) { - int propId = id - m_propertyOffset; - - m_control->setMetaData(qt_metaDataKeys[propId].key, *reinterpret_cast<QVariant *>(a[0])); - - return -1; - } else { - return m_object->qt_metacall(c, id, a); - } -} - -int QMetaDataControlMetaObject::createProperty(const char *, const char *) -{ - return -1; -} - -void QMetaDataControlMetaObject::metaDataChanged() -{ - activate(m_object, m_signalOffset, 0); -} - -QT_END_NAMESPACE diff --git a/src/imports/multimedia/qmetadatacontrolmetaobject_p.h b/src/imports/multimedia/qmetadatacontrolmetaobject_p.h deleted file mode 100644 index bbbc6fe..0000000 --- a/src/imports/multimedia/qmetadatacontrolmetaobject_p.h +++ /dev/null @@ -1,92 +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 QMETADATACONTROLMETAOBJECT_P_H -#define QMETADATACONTROLMETAOJBECT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qmetaobject.h> -#include <QtMediaServices/qtmedianamespace.h> - -#include <QtCore/private/qobject_p.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMetaDataControl; - -class QMetaDataControlMetaObject : public QAbstractDynamicMetaObject -{ -public: - QMetaDataControlMetaObject(QMetaDataControl *control, QObject *object); - ~QMetaDataControlMetaObject(); - - int metaCall(QMetaObject::Call call, int _id, void **arguments); - int createProperty(const char *, const char *); - - void metaDataChanged(); - -private: - QMetaDataControl *m_control; - QObject *m_object; - char *m_string; - uint *m_data; - - int m_propertyOffset; - int m_signalOffset; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/imports/multimedia/qmldir b/src/imports/multimedia/qmldir deleted file mode 100644 index 0e6f656..0000000 --- a/src/imports/multimedia/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin multimedia diff --git a/src/multimedia/multimedia/audio/audio.pri b/src/multimedia/audio/audio.pri index ae28a26..ae28a26 100644 --- a/src/multimedia/multimedia/audio/audio.pri +++ b/src/multimedia/audio/audio.pri diff --git a/src/multimedia/multimedia/audio/qaudio.cpp b/src/multimedia/audio/qaudio.cpp index e0f24ce..e0f24ce 100644 --- a/src/multimedia/multimedia/audio/qaudio.cpp +++ b/src/multimedia/audio/qaudio.cpp diff --git a/src/multimedia/multimedia/audio/qaudio.h b/src/multimedia/audio/qaudio.h index 9ca1dff..9ca1dff 100644 --- a/src/multimedia/multimedia/audio/qaudio.h +++ b/src/multimedia/audio/qaudio.h diff --git a/src/multimedia/multimedia/audio/qaudio_mac.cpp b/src/multimedia/audio/qaudio_mac.cpp index 14fee8b..14fee8b 100644 --- a/src/multimedia/multimedia/audio/qaudio_mac.cpp +++ b/src/multimedia/audio/qaudio_mac.cpp diff --git a/src/multimedia/multimedia/audio/qaudio_mac_p.h b/src/multimedia/audio/qaudio_mac_p.h index 4e7d688..4e7d688 100644 --- a/src/multimedia/multimedia/audio/qaudio_mac_p.h +++ b/src/multimedia/audio/qaudio_mac_p.h diff --git a/src/multimedia/multimedia/audio/qaudio_symbian_p.cpp b/src/multimedia/audio/qaudio_symbian_p.cpp index afe98f5..4522c5c 100644 --- a/src/multimedia/multimedia/audio/qaudio_symbian_p.cpp +++ b/src/multimedia/audio/qaudio_symbian_p.cpp @@ -45,41 +45,6 @@ QT_BEGIN_NAMESPACE namespace SymbianAudio { - -DevSoundCapabilities::DevSoundCapabilities(CMMFDevSound &devsound, - QAudio::Mode mode) -{ - QT_TRAP_THROWING(constructL(devsound, mode)); -} - -DevSoundCapabilities::~DevSoundCapabilities() -{ - m_fourCC.Close(); -} - -void DevSoundCapabilities::constructL(CMMFDevSound &devsound, - QAudio::Mode mode) -{ - m_caps = devsound.Capabilities(); - - TMMFPrioritySettings settings; - - switch (mode) { - case QAudio::AudioOutput: - settings.iState = EMMFStatePlaying; - devsound.GetSupportedInputDataTypesL(m_fourCC, settings); - break; - - case QAudio::AudioInput: - settings.iState = EMMFStateRecording; - devsound.GetSupportedInputDataTypesL(m_fourCC, settings); - break; - - default: - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode"); - } -} - namespace Utils { //----------------------------------------------------------------------------- @@ -274,11 +239,8 @@ bool sampleInfoQtToNative(int inputSampleSize, return found; } -//----------------------------------------------------------------------------- -// Public functions -//----------------------------------------------------------------------------- - -void capabilitiesNativeToQt(const DevSoundCapabilities &caps, +void capabilitiesNativeToQt(const TMMFCapabilities &caps, + const TFourCC &fourcc, QList<int> &frequencies, QList<int> &channels, QList<int> &sampleSizes, @@ -292,37 +254,20 @@ void capabilitiesNativeToQt(const DevSoundCapabilities &caps, channels.clear(); for (int i=0; i<SampleRateCount; ++i) - if (caps.caps().iRate & SampleRateListNative[i]) + if (caps.iRate & SampleRateListNative[i]) frequencies += SampleRateListQt[i]; for (int i=0; i<ChannelsCount; ++i) - if (caps.caps().iChannels & ChannelsListNative[i]) + if (caps.iChannels & ChannelsListNative[i]) channels += ChannelsListQt[i]; for (int i=0; i<EncodingCount; ++i) { - if (caps.fourCC().Find(EncodingFourCC[i]) != KErrNotFound) { + if (fourcc == EncodingFourCC[i]) { sampleSizes += EncodingSampleSize[i]; byteOrders += EncodingByteOrder[i]; sampleTypes += EncodingSampleType[i]; } } - -} - -bool isFormatSupported(const QAudioFormat &formatQt, - const DevSoundCapabilities &caps) { - TMMFCapabilities formatNative; - TUint32 fourCC; - - bool result = false; - if (formatQt.codec() == QString::fromAscii("audio/pcm") && - formatQtToNative(formatQt, fourCC, formatNative)) { - result = - (formatNative.iRate & caps.caps().iRate) - && (formatNative.iChannels & caps.caps().iChannels) - && (caps.fourCC().Find(fourCC) != KErrNotFound); - } - return result; } bool formatQtToNative(const QAudioFormat &inputFormat, @@ -337,7 +282,7 @@ bool formatQtToNative(const QAudioFormat &inputFormat, TMMFMonoStereo outputChannels; TMMFSoundEncoding outputEncoding; - if (inputFormat.codec() == QString::fromAscii("audio/pcm")) { + if (inputFormat.codec() == QLatin1String("audio/pcm")) { result = sampleRateQtToNative(inputFormat.frequency(), outputSampleRate) && channelsQtToNative(inputFormat.channels(), outputChannels) @@ -357,14 +302,13 @@ bool formatQtToNative(const QAudioFormat &inputFormat, return result; } -QAudio::State stateNativeToQt(State nativeState, - QAudio::State initializingState) +QAudio::State stateNativeToQt(State nativeState) { switch (nativeState) { case ClosedState: return QAudio::StoppedState; case InitializingState: - return initializingState; + return QAudio::StoppedState; case ActiveState: return QAudio::ActiveState; case IdleState: @@ -388,6 +332,291 @@ qint64 samplesToBytes(const QAudioFormat &format, qint64 samples) } } // namespace Utils + + +//----------------------------------------------------------------------------- +// DevSoundWrapper +//----------------------------------------------------------------------------- + +DevSoundWrapper::DevSoundWrapper(QAudio::Mode mode, QObject *parent) + : QObject(parent) + , m_mode(mode) + , m_state(StateIdle) + , m_devsound(0) + , m_fourcc(0) +{ + QT_TRAP_THROWING(m_devsound = CMMFDevSound::NewL()); + + switch (mode) { + case QAudio::AudioOutput: + m_nativeMode = EMMFStatePlaying; + break; + + case QAudio::AudioInput: + m_nativeMode = EMMFStateRecording; + break; + + default: + Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode"); + } + + getSupportedCodecs(); +} + +DevSoundWrapper::~DevSoundWrapper() +{ + delete m_devsound; +} + +const QList<QString>& DevSoundWrapper::supportedCodecs() const +{ + return m_supportedCodecs; +} + +void DevSoundWrapper::initialize(const QString& codec) +{ + Q_ASSERT(StateInitializing != m_state); + m_state = StateInitializing; + if (QLatin1String("audio/pcm") == codec) { + m_fourcc = KMMFFourCCCodePCM16; + TRAPD(err, m_devsound->InitializeL(*this, m_fourcc, m_nativeMode)); + if (KErrNone != err) { + m_state = StateIdle; + emit initializeComplete(err); + } + } else { + emit initializeComplete(KErrNotSupported); + } +} + +const QList<int>& DevSoundWrapper::supportedFrequencies() const +{ + Q_ASSERT(StateInitialized == m_state); + return m_supportedFrequencies; +} + +const QList<int>& DevSoundWrapper::supportedChannels() const +{ + Q_ASSERT(StateInitialized == m_state); + return m_supportedChannels; +} + +const QList<int>& DevSoundWrapper::supportedSampleSizes() const +{ + Q_ASSERT(StateInitialized == m_state); + return m_supportedSampleSizes; +} + +const QList<QAudioFormat::Endian>& DevSoundWrapper::supportedByteOrders() const +{ + Q_ASSERT(StateInitialized == m_state); + return m_supportedByteOrders; +} + +const QList<QAudioFormat::SampleType>& DevSoundWrapper::supportedSampleTypes() const +{ + Q_ASSERT(StateInitialized == m_state); + return m_supportedSampleTypes; +} + +bool DevSoundWrapper::isFormatSupported(const QAudioFormat &format) const +{ + Q_ASSERT(StateInitialized == m_state); + return m_supportedCodecs.contains(format.codec()) + && m_supportedFrequencies.contains(format.frequency()) + && m_supportedChannels.contains(format.channels()) + && m_supportedSampleSizes.contains(format.sampleSize()) + && m_supportedSampleTypes.contains(format.sampleType()) + && m_supportedByteOrders.contains(format.byteOrder()); +} + +int DevSoundWrapper::samplesProcessed() const +{ + Q_ASSERT(StateInitialized == m_state); + int result = 0; + switch (m_mode) { + case QAudio::AudioInput: + result = m_devsound->SamplesRecorded(); + break; + case QAudio::AudioOutput: + result = m_devsound->SamplesPlayed(); + break; + } + return result; +} + +bool DevSoundWrapper::setFormat(const QAudioFormat &format) +{ + Q_ASSERT(StateInitialized == m_state); + bool result = false; + TUint32 fourcc; + TMMFCapabilities nativeFormat; + if (Utils::formatQtToNative(format, fourcc, nativeFormat)) { + TMMFCapabilities currentNativeFormat = m_devsound->Config(); + nativeFormat.iBufferSize = currentNativeFormat.iBufferSize; + TRAPD(err, m_devsound->SetConfigL(nativeFormat)); + result = (KErrNone == err); + } + return result; +} + +bool DevSoundWrapper::start() +{ + Q_ASSERT(StateInitialized == m_state); + int err = KErrArgument; + switch (m_mode) { + case QAudio::AudioInput: + TRAP(err, m_devsound->RecordInitL()); + break; + case QAudio::AudioOutput: + TRAP(err, m_devsound->PlayInitL()); + break; + } + return (KErrNone == err); +} + +void DevSoundWrapper::pause() +{ + Q_ASSERT(StateInitialized == m_state); + m_devsound->Pause(); +} + +void DevSoundWrapper::stop() +{ + m_devsound->Stop(); +} + +void DevSoundWrapper::bufferProcessed() +{ + Q_ASSERT(StateInitialized == m_state); + switch (m_mode) { + case QAudio::AudioInput: + m_devsound->RecordData(); + break; + case QAudio::AudioOutput: + m_devsound->PlayData(); + break; + } +} + +void DevSoundWrapper::getSupportedCodecs() +{ +/* + * TODO: once we support formats other than PCM, this function should + * convert the array of FourCC codes into MIME types for each codec. + * + RArray<TFourCC> fourcc; + QT_TRAP_THROWING(CleanupClosePushL(&fourcc)); + + TMMFPrioritySettings settings; + switch (mode) { + case QAudio::AudioOutput: + settings.iState = EMMFStatePlaying; + m_devsound->GetSupportedInputDataTypesL(fourcc, settings); + break; + + case QAudio::AudioInput: + settings.iState = EMMFStateRecording; + m_devsound->GetSupportedInputDataTypesL(fourcc, settings); + break; + + default: + Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode"); + } + + CleanupStack::PopAndDestroy(); // fourcc +*/ + + m_supportedCodecs.append(QLatin1String("audio/pcm")); +} + +void DevSoundWrapper::populateCapabilities() +{ + m_supportedFrequencies.clear(); + m_supportedChannels.clear(); + m_supportedSampleSizes.clear(); + m_supportedByteOrders.clear(); + m_supportedSampleTypes.clear(); + + const TMMFCapabilities caps = m_devsound->Capabilities(); + + for (int i=0; i<Utils::SampleRateCount; ++i) + if (caps.iRate & Utils::SampleRateListNative[i]) + m_supportedFrequencies += Utils::SampleRateListQt[i]; + + for (int i=0; i<Utils::ChannelsCount; ++i) + if (caps.iChannels & Utils::ChannelsListNative[i]) + m_supportedChannels += Utils::ChannelsListQt[i]; + + for (int i=0; i<Utils::EncodingCount; ++i) { + if (m_fourcc == Utils::EncodingFourCC[i]) { + m_supportedSampleSizes += Utils::EncodingSampleSize[i]; + m_supportedByteOrders += Utils::EncodingByteOrder[i]; + m_supportedSampleTypes += Utils::EncodingSampleType[i]; + } + } +} + +void DevSoundWrapper::InitializeComplete(TInt aError) +{ + Q_ASSERT(StateInitializing == m_state); + if (KErrNone == aError) { + m_state = StateInitialized; + populateCapabilities(); + } else { + m_state = StateIdle; + } + emit initializeComplete(aError); +} + +void DevSoundWrapper::ToneFinished(TInt aError) +{ + Q_UNUSED(aError) + // This class doesn't use DevSound's tone playback functions, so should + // never receive this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void DevSoundWrapper::BufferToBeFilled(CMMFBuffer *aBuffer) +{ + Q_ASSERT(QAudio::AudioOutput == m_mode); + emit bufferToBeProcessed(aBuffer); +} + +void DevSoundWrapper::PlayError(TInt aError) +{ + Q_ASSERT(QAudio::AudioOutput == m_mode); + emit processingError(aError); +} + +void DevSoundWrapper::BufferToBeEmptied(CMMFBuffer *aBuffer) +{ + Q_ASSERT(QAudio::AudioInput == m_mode); + emit bufferToBeProcessed(aBuffer); +} + +void DevSoundWrapper::RecordError(TInt aError) +{ + Q_ASSERT(QAudio::AudioInput == m_mode); + emit processingError(aError); +} + +void DevSoundWrapper::ConvertError(TInt aError) +{ + Q_UNUSED(aError) + // This class doesn't use DevSound's format conversion functions, so + // should never receive this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void DevSoundWrapper::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg) +{ + Q_UNUSED(aMessageType) + Q_UNUSED(aMsg) + // Ignore this callback. +} + + } // namespace SymbianAudio QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudio_symbian_p.h b/src/multimedia/audio/qaudio_symbian_p.h index d5238b4..58ef192 100644 --- a/src/multimedia/multimedia/audio/qaudio_symbian_p.h +++ b/src/multimedia/audio/qaudio_symbian_p.h @@ -53,7 +53,8 @@ #ifndef QAUDIO_SYMBIAN_P_H #define QAUDIO_SYMBIAN_P_H -#include <QtCore/qnamespace.h> +#include <QtCore/QList> +#include <QtCore/QString> #include <QtMultimedia/qaudioformat.h> #include <QtMultimedia/qaudio.h> #include <sounddevice.h> @@ -83,60 +84,92 @@ enum State { , SuspendedState }; -/* - * Helper class for querying DevSound codec / format support +/** + * Wrapper around DevSound instance */ -class DevSoundCapabilities { +class DevSoundWrapper + : public QObject + , public MDevSoundObserver +{ + Q_OBJECT + +public: + DevSoundWrapper(QAudio::Mode mode, QObject *parent = 0); + ~DevSoundWrapper(); + public: - DevSoundCapabilities(CMMFDevSound &devsound, QAudio::Mode mode); - ~DevSoundCapabilities(); + // List of supported codecs; can be called once object is constructed + const QList<QString>& supportedCodecs() const; + + // Asynchronous initialization function; emits devsoundInitializeComplete + void initialize(const QString& codec); + + // Capabilities, for selected codec. Can be called once initialize has returned + // successfully. + const QList<int>& supportedFrequencies() const; + const QList<int>& supportedChannels() const; + const QList<int>& supportedSampleSizes() const; + const QList<QAudioFormat::Endian>& supportedByteOrders() const; + const QList<QAudioFormat::SampleType>& supportedSampleTypes() const; - const RArray<TFourCC>& fourCC() const { return m_fourCC; } - const TMMFCapabilities& caps() const { return m_caps; } + bool isFormatSupported(const QAudioFormat &format) const; + + int samplesProcessed() const; + bool setFormat(const QAudioFormat &format); + bool start(); + void pause(); + void stop(); + void bufferProcessed(); + +public: + // MDevSoundObserver + void InitializeComplete(TInt aError); + void ToneFinished(TInt aError); + void BufferToBeFilled(CMMFBuffer *aBuffer); + void PlayError(TInt aError); + void BufferToBeEmptied(CMMFBuffer *aBuffer); + void RecordError(TInt aError); + void ConvertError(TInt aError); + void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg); + +signals: + void initializeComplete(int error); + void bufferToBeProcessed(CMMFBuffer *buffer); + void processingError(int error); private: - void constructL(CMMFDevSound &devsound, QAudio::Mode mode); + void getSupportedCodecs(); + void populateCapabilities(); private: - RArray<TFourCC> m_fourCC; - TMMFCapabilities m_caps; -}; + const QAudio::Mode m_mode; + TMMFState m_nativeMode; -namespace Utils { + enum State { + StateIdle, + StateInitializing, + StateInitialized + } m_state; -/** - * Convert native audio capabilities to QAudio lists. - */ -void capabilitiesNativeToQt(const DevSoundCapabilities &caps, - QList<int> &frequencies, - QList<int> &channels, - QList<int> &sampleSizes, - QList<QAudioFormat::Endian> &byteOrders, - QList<QAudioFormat::SampleType> &sampleTypes); + CMMFDevSound* m_devsound; + TFourCC m_fourcc; -/** - * Check whether format is supported. - */ -bool isFormatSupported(const QAudioFormat &format, - const DevSoundCapabilities &caps); + QList<QString> m_supportedCodecs; + QList<int> m_supportedFrequencies; + QList<int> m_supportedChannels; + QList<int> m_supportedSampleSizes; + QList<QAudioFormat::Endian> m_supportedByteOrders; + QList<QAudioFormat::SampleType> m_supportedSampleTypes; -/** - * Convert QAudioFormat to native format types. - * - * Note that, despite the name, DevSound uses TMMFCapabilities to specify - * single formats as well as capabilities. - * - * Note that this function does not modify outputFormat.iBufferSize. - */ -bool formatQtToNative(const QAudioFormat &inputFormat, - TUint32 &outputFourCC, - TMMFCapabilities &outputFormat); +}; + + +namespace Utils { /** * Convert internal states to QAudio states. */ -QAudio::State stateNativeToQt(State nativeState, - QAudio::State initializingState); +QAudio::State stateNativeToQt(State nativeState); /** * Convert data length to number of samples. diff --git a/src/multimedia/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp index 96545b4..96545b4 100644 --- a/src/multimedia/multimedia/audio/qaudiodevicefactory.cpp +++ b/src/multimedia/audio/qaudiodevicefactory.cpp diff --git a/src/multimedia/multimedia/audio/qaudiodevicefactory_p.h b/src/multimedia/audio/qaudiodevicefactory_p.h index 8ee8b05..8ee8b05 100644 --- a/src/multimedia/multimedia/audio/qaudiodevicefactory_p.h +++ b/src/multimedia/audio/qaudiodevicefactory_p.h diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp index ff04b4e..ff04b4e 100644 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h index 1cc0731..1cc0731 100644 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo.h +++ b/src/multimedia/audio/qaudiodeviceinfo.h diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index 36270a7..36270a7 100644 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_alsa_p.h b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h index 6f9a459..6f9a459 100644 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_alsa_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp index ecd03e5..ecd03e5 100644 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_mac_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_mac_p.h b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h index e234384..e234384 100644 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_mac_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp index 36284d3..4be116f 100644 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include <QtCore/QCoreApplication> #include "qaudiodeviceinfo_symbian_p.h" #include "qaudio_symbian_p.h" @@ -50,7 +51,7 @@ QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray device, , m_mode(mode) , m_updated(false) { - QT_TRAP_THROWING(m_devsound.reset(CMMFDevSound::NewL())); + } QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() @@ -85,16 +86,21 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const } if (!isFormatSupported(format)) { - if (m_frequencies.size()) - format.setFrequency(m_frequencies[0]); - if (m_channels.size()) - format.setChannels(m_channels[0]); - if (m_sampleSizes.size()) - format.setSampleSize(m_sampleSizes[0]); - if (m_byteOrders.size()) - format.setByteOrder(m_byteOrders[0]); - if (m_sampleTypes.size()) - format.setSampleType(m_sampleTypes[0]); + format = QAudioFormat(); + format.setCodec(QLatin1String("audio/pcm")); + if (m_capabilities.contains(format.codec())) { + const Capabilities &codecCaps = m_capabilities[format.codec()]; + if (codecCaps.m_frequencies.size()) + format.setFrequency(codecCaps.m_frequencies[0]); + if (codecCaps.m_channels.size()) + format.setChannels(codecCaps.m_channels[0]); + if (codecCaps.m_sampleSizes.size()) + format.setSampleSize(codecCaps.m_sampleSizes[0]); + if (codecCaps.m_byteOrders.size()) + format.setByteOrder(codecCaps.m_byteOrders[0]); + if (codecCaps.m_sampleTypes.size()) + format.setSampleType(codecCaps.m_sampleTypes[0]); + } } return format; @@ -104,14 +110,15 @@ bool QAudioDeviceInfoInternal::isFormatSupported( const QAudioFormat &format) const { getSupportedFormats(); - const bool supported = - m_codecs.contains(format.codec()) - && m_frequencies.contains(format.frequency()) - && m_channels.contains(format.channels()) - && m_sampleSizes.contains(format.sampleSize()) - && m_byteOrders.contains(format.byteOrder()) - && m_sampleTypes.contains(format.sampleType()); - + bool supported = false; + if (m_capabilities.contains(format.codec())) { + const Capabilities &codecCaps = m_capabilities[format.codec()]; + supported = codecCaps.m_frequencies.contains(format.frequency()) + && codecCaps.m_channels.contains(format.channels()) + && codecCaps.m_sampleSizes.contains(format.sampleSize()) + && codecCaps.m_byteOrders.contains(format.byteOrder()) + && codecCaps.m_sampleTypes.contains(format.sampleType()); + } return supported; } @@ -131,37 +138,37 @@ QString QAudioDeviceInfoInternal::deviceName() const QStringList QAudioDeviceInfoInternal::codecList() { getSupportedFormats(); - return m_codecs; + return m_capabilities.keys(); } QList<int> QAudioDeviceInfoInternal::frequencyList() { getSupportedFormats(); - return m_frequencies; + return m_unionCapabilities.m_frequencies; } QList<int> QAudioDeviceInfoInternal::channelsList() { getSupportedFormats(); - return m_channels; + return m_unionCapabilities.m_channels; } QList<int> QAudioDeviceInfoInternal::sampleSizeList() { getSupportedFormats(); - return m_sampleSizes; + return m_unionCapabilities.m_sampleSizes; } QList<QAudioFormat::Endian> QAudioDeviceInfoInternal::byteOrderList() { getSupportedFormats(); - return m_byteOrders; + return m_unionCapabilities.m_byteOrders; } QList<QAudioFormat::SampleType> QAudioDeviceInfoInternal::sampleTypeList() { getSupportedFormats(); - return m_sampleTypes; + return m_unionCapabilities.m_sampleTypes; } QByteArray QAudioDeviceInfoInternal::defaultInputDevice() @@ -181,17 +188,50 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode) return result; } -void QAudioDeviceInfoInternal::getSupportedFormats() const +void QAudioDeviceInfoInternal::devsoundInitializeComplete(int err) { - if (!m_updated) { - QScopedPointer<SymbianAudio::DevSoundCapabilities> caps( - new SymbianAudio::DevSoundCapabilities(*m_devsound, m_mode)); + m_intializationResult = err; + m_initializing = false; +} - SymbianAudio::Utils::capabilitiesNativeToQt(*caps, - m_frequencies, m_channels, m_sampleSizes, - m_byteOrders, m_sampleTypes); +// Helper function +template<typename T> +void appendUnique(QList<T> &left, const QList<T> &right) +{ + foreach (const T &value, right) + if (!left.contains(value)) + left += value; +} - m_codecs.append(QLatin1String("audio/pcm")); +void QAudioDeviceInfoInternal::getSupportedFormats() const +{ + if (!m_updated) { + QScopedPointer<SymbianAudio::DevSoundWrapper> devsound(new SymbianAudio::DevSoundWrapper(m_mode)); + connect(devsound.data(), SIGNAL(initializeComplete(int)), + this, SLOT(devsoundInitializeComplete(int))); + + foreach (const QString& codec, devsound->supportedCodecs()) { + m_initializing = true; + devsound->initialize(codec); + while (m_initializing) + QCoreApplication::instance()->processEvents(QEventLoop::WaitForMoreEvents); + if (KErrNone == m_intializationResult) { + m_capabilities[codec].m_frequencies = devsound->supportedFrequencies(); + appendUnique(m_unionCapabilities.m_frequencies, devsound->supportedFrequencies()); + + m_capabilities[codec].m_channels = devsound->supportedChannels(); + appendUnique(m_unionCapabilities.m_channels, devsound->supportedChannels()); + + m_capabilities[codec].m_sampleSizes = devsound->supportedSampleSizes(); + appendUnique(m_unionCapabilities.m_sampleSizes, devsound->supportedSampleSizes()); + + m_capabilities[codec].m_byteOrders = devsound->supportedByteOrders(); + appendUnique(m_unionCapabilities.m_byteOrders, devsound->supportedByteOrders()); + + m_capabilities[codec].m_sampleTypes = devsound->supportedSampleTypes(); + appendUnique(m_unionCapabilities.m_sampleTypes, devsound->supportedSampleTypes()); + } + } m_updated = true; } diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_symbian_p.h b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.h index 89e539f..79b23cc 100644 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_symbian_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.h @@ -53,11 +53,16 @@ #ifndef QAUDIODEVICEINFO_SYMBIAN_P_H #define QAUDIODEVICEINFO_SYMBIAN_P_H +#include <QtCore/QMap> #include <QtMultimedia/qaudioengine.h> #include <sounddevice.h> QT_BEGIN_NAMESPACE +namespace SymbianAudio { +class DevSoundWrapper; +} + class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo { @@ -82,24 +87,33 @@ public: static QByteArray defaultOutputDevice(); static QList<QByteArray> availableDevices(QAudio::Mode); +private slots: + void devsoundInitializeComplete(int err); + private: void getSupportedFormats() const; private: - QScopedPointer<CMMFDevSound> m_devsound; + mutable bool m_initializing; + int m_intializationResult; QString m_deviceName; QAudio::Mode m_mode; + struct Capabilities + { + QList<int> m_frequencies; + QList<int> m_channels; + QList<int> m_sampleSizes; + QList<QAudioFormat::Endian> m_byteOrders; + QList<QAudioFormat::SampleType> m_sampleTypes; + }; + // Mutable to allow lazy initialization when called from const-qualified // public functions (isFormatSupported, nearestFormat) mutable bool m_updated; - mutable QStringList m_codecs; - mutable QList<int> m_frequencies; - mutable QList<int> m_channels; - mutable QList<int> m_sampleSizes; - mutable QList<QAudioFormat::Endian> m_byteOrders; - mutable QList<QAudioFormat::SampleType> m_sampleTypes; + mutable QMap<QString, Capabilities> m_capabilities; + mutable Capabilities m_unionCapabilities; }; QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index aee0807..aee0807 100644 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp diff --git a/src/multimedia/multimedia/audio/qaudiodeviceinfo_win32_p.h b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h index cb6dd91..cb6dd91 100644 --- a/src/multimedia/multimedia/audio/qaudiodeviceinfo_win32_p.h +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h diff --git a/src/multimedia/multimedia/audio/qaudioengine.cpp b/src/multimedia/audio/qaudioengine.cpp index 7f1f5d3..7f1f5d3 100644 --- a/src/multimedia/multimedia/audio/qaudioengine.cpp +++ b/src/multimedia/audio/qaudioengine.cpp diff --git a/src/multimedia/multimedia/audio/qaudioengine.h b/src/multimedia/audio/qaudioengine.h index df9d09d..df9d09d 100644 --- a/src/multimedia/multimedia/audio/qaudioengine.h +++ b/src/multimedia/audio/qaudioengine.h diff --git a/src/multimedia/multimedia/audio/qaudioengineplugin.cpp b/src/multimedia/audio/qaudioengineplugin.cpp index 82324b5..82324b5 100644 --- a/src/multimedia/multimedia/audio/qaudioengineplugin.cpp +++ b/src/multimedia/audio/qaudioengineplugin.cpp diff --git a/src/multimedia/multimedia/audio/qaudioengineplugin.h b/src/multimedia/audio/qaudioengineplugin.h index 2322d2a..2322d2a 100644 --- a/src/multimedia/multimedia/audio/qaudioengineplugin.h +++ b/src/multimedia/audio/qaudioengineplugin.h diff --git a/src/multimedia/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp index 86d72f6..86d72f6 100644 --- a/src/multimedia/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp diff --git a/src/multimedia/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h index 6c835b7..6c835b7 100644 --- a/src/multimedia/multimedia/audio/qaudioformat.h +++ b/src/multimedia/audio/qaudioformat.h diff --git a/src/multimedia/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index 3676f64..3676f64 100644 --- a/src/multimedia/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp diff --git a/src/multimedia/multimedia/audio/qaudioinput.h b/src/multimedia/audio/qaudioinput.h index 5be9b5a..5be9b5a 100644 --- a/src/multimedia/multimedia/audio/qaudioinput.h +++ b/src/multimedia/audio/qaudioinput.h diff --git a/src/multimedia/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index c9a8b71..c9a8b71 100644 --- a/src/multimedia/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp diff --git a/src/multimedia/multimedia/audio/qaudioinput_alsa_p.h b/src/multimedia/audio/qaudioinput_alsa_p.h index c907019..c907019 100644 --- a/src/multimedia/multimedia/audio/qaudioinput_alsa_p.h +++ b/src/multimedia/audio/qaudioinput_alsa_p.h diff --git a/src/multimedia/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp index cb65f6e..cb65f6e 100644 --- a/src/multimedia/multimedia/audio/qaudioinput_mac_p.cpp +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp diff --git a/src/multimedia/multimedia/audio/qaudioinput_mac_p.h b/src/multimedia/audio/qaudioinput_mac_p.h index 7aa4168..7aa4168 100644 --- a/src/multimedia/multimedia/audio/qaudioinput_mac_p.h +++ b/src/multimedia/audio/qaudioinput_mac_p.h diff --git a/src/multimedia/multimedia/audio/qaudioinput_symbian_p.cpp b/src/multimedia/audio/qaudioinput_symbian_p.cpp index 52daa88..9d240ca 100644 --- a/src/multimedia/multimedia/audio/qaudioinput_symbian_p.cpp +++ b/src/multimedia/audio/qaudioinput_symbian_p.cpp @@ -116,16 +116,16 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, , m_pullMode(false) , m_sink(0) , m_pullTimer(new QTimer(this)) + , m_devSound(0) , m_devSoundBuffer(0) , m_devSoundBufferSize(0) , m_totalBytesReady(0) , m_devSoundBufferPos(0) , m_totalSamplesRecorded(0) { - connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); + qRegisterMetaType<CMMFBuffer *>("CMMFBuffer *"); - SymbianAudio::Utils::formatQtToNative(m_format, m_nativeFourCC, - m_nativeFormat); + connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); m_pullTimer->setInterval(PushInterval); connect(m_pullTimer.data(), SIGNAL(timeout()), this, SLOT(pullData())); @@ -164,7 +164,7 @@ void QAudioInputPrivate::stop() void QAudioInputPrivate::reset() { m_totalSamplesRecorded += getSamplesRecorded(); - m_devSound->Stop(); + m_devSound->stop(); startRecording(); } @@ -174,7 +174,7 @@ void QAudioInputPrivate::suspend() || SymbianAudio::IdleState == m_internalState) { m_notifyTimer->stop(); m_pullTimer->stop(); - m_devSound->Pause(); + m_devSound->pause(); const qint64 samplesRecorded = getSamplesRecorded(); m_totalSamplesRecorded += samplesRecorded; @@ -189,8 +189,11 @@ void QAudioInputPrivate::suspend() void QAudioInputPrivate::resume() { - if (SymbianAudio::SuspendedState == m_internalState) + if (SymbianAudio::SuspendedState == m_internalState) { + if (!m_pullMode && !bytesReady()) + m_devSound->start(); startDataTransfer(); + } } int QAudioInputPrivate::bytesReady() const @@ -224,11 +227,14 @@ int QAudioInputPrivate::bufferSize() const void QAudioInputPrivate::setNotifyInterval(int ms) { - if (ms > 0) { + if (ms >= 0) { const int oldNotifyInterval = m_notifyInterval; m_notifyInterval = ms; - if (m_notifyTimer->isActive() && ms != oldNotifyInterval) + if (m_notifyInterval && (SymbianAudio::ActiveState == m_internalState || + SymbianAudio::IdleState == m_internalState)) m_notifyTimer->start(m_notifyInterval); + else + m_notifyTimer->stop(); } } @@ -275,88 +281,6 @@ QAudioFormat QAudioInputPrivate::format() const return m_format; } -//----------------------------------------------------------------------------- -// MDevSoundObserver implementation -//----------------------------------------------------------------------------- - -void QAudioInputPrivate::InitializeComplete(TInt aError) -{ - Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, - Q_FUNC_INFO, "Invalid state"); - - if (KErrNone == aError) - startRecording(); -} - -void QAudioInputPrivate::ToneFinished(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound's tone playback functions, so should - // never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioInputPrivate::BufferToBeFilled(CMMFBuffer *aBuffer) -{ - Q_UNUSED(aBuffer) - // This class doesn't use DevSound in play mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioInputPrivate::PlayError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound in play mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioInputPrivate::BufferToBeEmptied(CMMFBuffer *aBuffer) -{ - // Following receipt of this callback, DevSound should not provide another - // buffer until we have returned the current one. - Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held"); - - CMMFDataBuffer *const buffer = static_cast<CMMFDataBuffer*>(aBuffer); - - if (!m_devSoundBufferSize) - m_devSoundBufferSize = buffer->Data().MaxLength(); - - m_totalBytesReady += buffer->Data().Length(); - - if (SymbianAudio::SuspendedState == m_internalState) { - m_devSoundBufferQ.append(buffer); - } else { - // Will be returned to DevSound by bufferEmptied(). - m_devSoundBuffer = buffer; - m_devSoundBufferPos = 0; - - if (bytesReady() && !m_pullMode) - pushData(); - } -} - -void QAudioInputPrivate::RecordError(TInt aError) -{ - Q_UNUSED(aError) - setError(QAudio::IOError); -} - -void QAudioInputPrivate::ConvertError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound's format conversion functions, so - // should never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioInputPrivate::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg) -{ - Q_UNUSED(aMessageType) - Q_UNUSED(aMsg) - // Ignore this callback. -} //----------------------------------------------------------------------------- // Private functions @@ -367,33 +291,30 @@ void QAudioInputPrivate::open() Q_ASSERT_X(SymbianAudio::ClosedState == m_internalState, Q_FUNC_INFO, "DevSound already opened"); - QT_TRAP_THROWING( m_devSound.reset(CMMFDevSound::NewL()) ) - - QScopedPointer<SymbianAudio::DevSoundCapabilities> caps( - new SymbianAudio::DevSoundCapabilities(*m_devSound, QAudio::AudioInput)); + Q_ASSERT(!m_devSound); + m_devSound = new SymbianAudio::DevSoundWrapper(QAudio::AudioInput, this); - int err = SymbianAudio::Utils::isFormatSupported(m_format, *caps) ? - KErrNone : KErrNotSupported; - - if (KErrNone == err) { - setState(SymbianAudio::InitializingState); - TRAP(err, m_devSound->InitializeL(*this, m_nativeFourCC, - EMMFStateRecording)); - } + connect(m_devSound, SIGNAL(initializeComplete(int)), + this, SLOT(devsoundInitializeComplete(int))); + connect(m_devSound, SIGNAL(bufferToBeProcessed(CMMFBuffer *)), + this, SLOT(devsoundBufferToBeEmptied(CMMFBuffer *))); + connect(m_devSound, SIGNAL(processingError(int)), + this, SLOT(devsoundRecordError(int))); - if (KErrNone != err) { - setError(QAudio::OpenError); - m_devSound.reset(); - } + setState(SymbianAudio::InitializingState); + m_devSound->initialize(m_format.codec()); } void QAudioInputPrivate::startRecording() { - const int samplesRecorded = m_devSound->SamplesRecorded(); + const int samplesRecorded = m_devSound->samplesProcessed(); Q_ASSERT(samplesRecorded == 0); - TRAPD(err, startDevSoundL()); - if (KErrNone == err) { + bool ok = m_devSound->setFormat(m_format); + if (ok) + ok = m_devSound->start(); + + if (ok) { startDataTransfer(); } else { setError(QAudio::OpenError); @@ -401,17 +322,10 @@ void QAudioInputPrivate::startRecording() } } -void QAudioInputPrivate::startDevSoundL() -{ - TMMFCapabilities nativeFormat = m_devSound->Config(); - m_nativeFormat.iBufferSize = nativeFormat.iBufferSize; - m_devSound->SetConfigL(m_nativeFormat); - m_devSound->RecordInitL(); -} - void QAudioInputPrivate::startDataTransfer() { - m_notifyTimer->start(m_notifyInterval); + if (m_notifyInterval) + m_notifyTimer->start(m_notifyInterval); if (m_pullMode) m_pullTimer->start(); @@ -503,6 +417,48 @@ void QAudioInputPrivate::pullData() } } +void QAudioInputPrivate::devsoundInitializeComplete(int err) +{ + Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, + Q_FUNC_INFO, "Invalid state"); + + if (!err && m_devSound->isFormatSupported(m_format)) + startRecording(); + else + setError(QAudio::OpenError); +} + +void QAudioInputPrivate::devsoundBufferToBeEmptied(CMMFBuffer *baseBuffer) +{ + // Following receipt of this signal, DevSound should not provide another + // buffer until we have returned the current one. + Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held"); + + CMMFDataBuffer *const buffer = static_cast<CMMFDataBuffer*>(baseBuffer); + + if (!m_devSoundBufferSize) + m_devSoundBufferSize = buffer->Data().MaxLength(); + + m_totalBytesReady += buffer->Data().Length(); + + if (SymbianAudio::SuspendedState == m_internalState) { + m_devSoundBufferQ.append(buffer); + } else { + // Will be returned to DevSoundWrapper by bufferProcessed(). + m_devSoundBuffer = buffer; + m_devSoundBufferPos = 0; + + if (bytesReady() && !m_pullMode) + pushData(); + } +} + +void QAudioInputPrivate::devsoundRecordError(int err) +{ + Q_UNUSED(err) + setError(QAudio::IOError); +} + void QAudioInputPrivate::bufferEmptied() { m_devSoundBufferPos = 0; @@ -510,7 +466,7 @@ void QAudioInputPrivate::bufferEmptied() if (m_devSoundBuffer) { m_totalBytesReady -= m_devSoundBuffer->Data().Length(); m_devSoundBuffer = 0; - m_devSound->RecordData(); + m_devSound->bufferProcessed(); } else { Q_ASSERT(!m_devSoundBufferQ.empty()); m_totalBytesReady -= m_devSoundBufferQ.front()->Data().Length(); @@ -518,7 +474,8 @@ void QAudioInputPrivate::bufferEmptied() // If the queue has been emptied, resume transfer from the hardware if (m_devSoundBufferQ.empty()) - m_devSound->RecordInitL(); + if (!m_devSound->start()) + setError(QAudio::IOError); } Q_ASSERT(m_totalBytesReady >= 0); @@ -532,8 +489,10 @@ void QAudioInputPrivate::close() m_error = QAudio::NoError; if (m_devSound) - m_devSound->Stop(); - m_devSound.reset(); + m_devSound->stop(); + delete m_devSound; + m_devSound = 0; + m_devSoundBuffer = 0; m_devSoundBufferSize = 0; m_totalBytesReady = 0; @@ -554,7 +513,7 @@ qint64 QAudioInputPrivate::getSamplesRecorded() const { qint64 result = 0; if (m_devSound) - result = qint64(m_devSound->SamplesRecorded()); + result = qint64(m_devSound->samplesProcessed()); return result; } @@ -565,30 +524,28 @@ void QAudioInputPrivate::setError(QAudio::Error error) // Although no state transition actually occurs here, a stateChanged event // must be emitted to inform the client that the call to start() was // unsuccessful. - if (QAudio::OpenError == error) + if (QAudio::OpenError == error) { emit stateChanged(QAudio::StoppedState); - - // Close the DevSound instance. This causes a transition to StoppedState. - // This must be done asynchronously in case the current function was called - // from a DevSound event handler, in which case deleting the DevSound - // instance may cause an exception. - QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); + } else { + if (QAudio::UnderrunError == error) + setState(SymbianAudio::IdleState); + else + // Close the DevSound instance. This causes a transition to + // StoppedState. This must be done asynchronously in case the + // current function was called from a DevSound event handler, in which + // case deleting the DevSound instance may cause an exception. + QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); + } } void QAudioInputPrivate::setState(SymbianAudio::State newInternalState) { const QAudio::State oldExternalState = m_externalState; m_internalState = newInternalState; - m_externalState = SymbianAudio::Utils::stateNativeToQt( - m_internalState, initializingState()); + m_externalState = SymbianAudio::Utils::stateNativeToQt(m_internalState); if (m_externalState != oldExternalState) emit stateChanged(m_externalState); } -QAudio::State QAudioInputPrivate::initializingState() const -{ - return QAudio::IdleState; -} - QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudioinput_symbian_p.h b/src/multimedia/audio/qaudioinput_symbian_p.h index ca3ccf7..7417655 100644 --- a/src/multimedia/multimedia/audio/qaudioinput_symbian_p.h +++ b/src/multimedia/audio/qaudioinput_symbian_p.h @@ -56,7 +56,6 @@ #include <QtMultimedia/qaudioengine.h> #include <QTime> #include <QTimer> -#include <sounddevice.h> #include "qaudio_symbian_p.h" QT_BEGIN_NAMESPACE @@ -82,7 +81,6 @@ private: class QAudioInputPrivate : public QAbstractAudioInput - , public MDevSoundObserver { friend class SymbianAudioInputPrivate; Q_OBJECT @@ -109,23 +107,15 @@ public: QAudio::State state() const; QAudioFormat format() const; - // MDevSoundObserver - void InitializeComplete(TInt aError); - void ToneFinished(TInt aError); - void BufferToBeFilled(CMMFBuffer *aBuffer); - void PlayError(TInt aError); - void BufferToBeEmptied(CMMFBuffer *aBuffer); - void RecordError(TInt aError); - void ConvertError(TInt aError); - void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg); - private slots: void pullData(); + void devsoundInitializeComplete(int err); + void devsoundBufferToBeEmptied(CMMFBuffer *); + void devsoundRecordError(int err); private: void open(); void startRecording(); - void startDevSoundL(); void startDataTransfer(); CMMFDataBuffer* currentBuffer() const; void pushData(); @@ -138,8 +128,6 @@ private: void setError(QAudio::Error error); void setState(SymbianAudio::State state); - QAudio::State initializingState() const; - private: const QByteArray m_device; const QAudioFormat m_format; @@ -158,9 +146,7 @@ private: QScopedPointer<QTimer> m_pullTimer; - QScopedPointer<CMMFDevSound> m_devSound; - TUint32 m_nativeFourCC; - TMMFCapabilities m_nativeFormat; + SymbianAudio::DevSoundWrapper* m_devSound; // Latest buffer provided by DevSound, to be empied of data. CMMFDataBuffer *m_devSoundBuffer; diff --git a/src/multimedia/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index 14a1cf3..14a1cf3 100644 --- a/src/multimedia/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp diff --git a/src/multimedia/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/audio/qaudioinput_win32_p.h index 8a9b02b..8a9b02b 100644 --- a/src/multimedia/multimedia/audio/qaudioinput_win32_p.h +++ b/src/multimedia/audio/qaudioinput_win32_p.h diff --git a/src/multimedia/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp index b0b5244..371773c 100644 --- a/src/multimedia/multimedia/audio/qaudiooutput.cpp +++ b/src/multimedia/audio/qaudiooutput.cpp @@ -209,6 +209,10 @@ QAudioFormat QAudioOutput::format() const If a problem occurs during this process the error() is set to QAudio::OpenError, state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + In either case, the stateChanged() signal may be emitted either synchronously + during execution of the start() function or asynchronously after start() has + returned to the caller. + \sa QIODevice */ @@ -228,6 +232,10 @@ void QAudioOutput::start(QIODevice* device) If a problem occurs during this process the error() is set to QAudio::OpenError, state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + In either case, the stateChanged() signal may be emitted either synchronously + during execution of the start() function or asynchronously after start() has + returned to the caller. + \sa QIODevice */ @@ -276,6 +284,8 @@ void QAudioOutput::suspend() Sets state() to QAudio::ActiveState if you previously called start(QIODevice*). Sets state() to QAudio::IdleState if you previously called start(). emits stateChanged() signal. + + Note: signal will always be emitted during execution of the resume() function. */ void QAudioOutput::resume() diff --git a/src/multimedia/multimedia/audio/qaudiooutput.h b/src/multimedia/audio/qaudiooutput.h index 0f45b1b..0f45b1b 100644 --- a/src/multimedia/multimedia/audio/qaudiooutput.h +++ b/src/multimedia/audio/qaudiooutput.h diff --git a/src/multimedia/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp index 49b32c0..49b32c0 100644 --- a/src/multimedia/multimedia/audio/qaudiooutput_alsa_p.cpp +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp diff --git a/src/multimedia/multimedia/audio/qaudiooutput_alsa_p.h b/src/multimedia/audio/qaudiooutput_alsa_p.h index e6ac231..e6ac231 100644 --- a/src/multimedia/multimedia/audio/qaudiooutput_alsa_p.h +++ b/src/multimedia/audio/qaudiooutput_alsa_p.h diff --git a/src/multimedia/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp index 9689101..9689101 100644 --- a/src/multimedia/multimedia/audio/qaudiooutput_mac_p.cpp +++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp diff --git a/src/multimedia/multimedia/audio/qaudiooutput_mac_p.h b/src/multimedia/audio/qaudiooutput_mac_p.h index 752905c..752905c 100644 --- a/src/multimedia/multimedia/audio/qaudiooutput_mac_p.h +++ b/src/multimedia/audio/qaudiooutput_mac_p.h diff --git a/src/multimedia/multimedia/audio/qaudiooutput_symbian_p.cpp b/src/multimedia/audio/qaudiooutput_symbian_p.cpp index 3f8e933..5098469 100644 --- a/src/multimedia/multimedia/audio/qaudiooutput_symbian_p.cpp +++ b/src/multimedia/audio/qaudiooutput_symbian_p.cpp @@ -110,6 +110,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, , m_externalState(QAudio::StoppedState) , m_pullMode(false) , m_source(0) + , m_devSound(0) , m_devSoundBuffer(0) , m_devSoundBufferSize(0) , m_bytesWritten(0) @@ -121,10 +122,9 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, , m_samplesPlayed(0) , m_totalSamplesPlayed(0) { - connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); + qRegisterMetaType<CMMFBuffer *>("CMMFBuffer *"); - SymbianAudio::Utils::formatQtToNative(m_format, m_nativeFourCC, - m_nativeFormat); + connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); m_underflowTimer->setInterval(UnderflowTimerInterval); connect(m_underflowTimer.data(), SIGNAL(timeout()), this, @@ -140,8 +140,6 @@ QIODevice* QAudioOutputPrivate::start(QIODevice *device) { stop(); - // We have to set these before the call to open() because of the - // logic in initializingState() if (device) { m_pullMode = true; m_source = device; @@ -171,7 +169,7 @@ void QAudioOutputPrivate::stop() void QAudioOutputPrivate::reset() { m_totalSamplesPlayed += getSamplesPlayed(); - m_devSound->Stop(); + m_devSound->stop(); m_bytesPadding = 0; startPlayback(); } @@ -196,11 +194,12 @@ void QAudioOutputPrivate::suspend() // Because this causes buffered data to be dropped, we replace the // lost data with silence following a call to resume(), in order to // ensure that processedUSecs() returns the correct value. - m_devSound->Stop(); + m_devSound->stop(); m_totalSamplesPlayed += samplesPlayed; // Calculate the amount of data dropped const qint64 paddingSamples = samplesWritten - samplesPlayed; + Q_ASSERT(paddingSamples >= 0); m_bytesPadding = SymbianAudio::Utils::samplesToBytes(m_format, paddingSamples); @@ -210,8 +209,11 @@ void QAudioOutputPrivate::suspend() void QAudioOutputPrivate::resume() { - if (SymbianAudio::SuspendedState == m_internalState) + if (SymbianAudio::SuspendedState == m_internalState) { + if (!m_pullMode && m_devSoundBuffer && m_devSoundBuffer->Data().Length()) + bufferFilled(); startPlayback(); + } } int QAudioOutputPrivate::bytesFree() const @@ -249,11 +251,14 @@ int QAudioOutputPrivate::bufferSize() const void QAudioOutputPrivate::setNotifyInterval(int ms) { - if (ms > 0) { + if (ms >= 0) { const int oldNotifyInterval = m_notifyInterval; m_notifyInterval = ms; - if (m_notifyTimer->isActive() && ms != oldNotifyInterval) + if (m_notifyInterval && (SymbianAudio::ActiveState == m_internalState || + SymbianAudio::IdleState == m_internalState)) m_notifyTimer->start(m_notifyInterval); + else + m_notifyTimer->stop(); } } @@ -300,35 +305,52 @@ QAudioFormat QAudioOutputPrivate::format() const return m_format; } + //----------------------------------------------------------------------------- -// MDevSoundObserver implementation +// Private functions //----------------------------------------------------------------------------- -void QAudioOutputPrivate::InitializeComplete(TInt aError) +void QAudioOutputPrivate::dataReady() { - Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, - Q_FUNC_INFO, "Invalid state"); + // Client-provided QIODevice has data ready to read. - if (KErrNone == aError) - startPlayback(); + Q_ASSERT_X(m_source->bytesAvailable(), Q_FUNC_INFO, + "readyRead signal received, but no data available"); + + if (!m_bytesPadding) + pullData(); } -void QAudioOutputPrivate::ToneFinished(TInt aError) +void QAudioOutputPrivate::underflowTimerExpired() { - Q_UNUSED(aError) - // This class doesn't use DevSound's tone playback functions, so should - // never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); + const TInt samplesPlayed = getSamplesPlayed(); + if (m_samplesPlayed && (samplesPlayed == m_samplesPlayed)) { + setError(QAudio::UnderrunError); + } else { + m_samplesPlayed = samplesPlayed; + m_underflowTimer->start(); + } +} + +void QAudioOutputPrivate::devsoundInitializeComplete(int err) +{ + Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, + Q_FUNC_INFO, "Invalid state"); + + if (!err && m_devSound->isFormatSupported(m_format)) + startPlayback(); + else + setError(QAudio::OpenError); } -void QAudioOutputPrivate::BufferToBeFilled(CMMFBuffer *aBuffer) +void QAudioOutputPrivate::devsoundBufferToBeFilled(CMMFBuffer *bufferBase) { - // Following receipt of this callback, DevSound should not provide another + // Following receipt of this signal, DevSound should not provide another // buffer until we have returned the current one. Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held"); - // Will be returned to DevSound by bufferFilled(). - m_devSoundBuffer = static_cast<CMMFDataBuffer*>(aBuffer); + // Will be returned to DevSoundWrapper by bufferProcessed(). + m_devSoundBuffer = static_cast<CMMFDataBuffer*>(bufferBase); if (!m_devSoundBufferSize) m_devSoundBufferSize = m_devSoundBuffer->Data().MaxLength(); @@ -339,9 +361,9 @@ void QAudioOutputPrivate::BufferToBeFilled(CMMFBuffer *aBuffer) pullData(); } -void QAudioOutputPrivate::PlayError(TInt aError) +void QAudioOutputPrivate::devsoundPlayError(int err) { - switch (aError) { + switch (err) { case KErrUnderflow: m_underflow = true; if (m_pullMode && !m_lastBuffer) @@ -355,102 +377,42 @@ void QAudioOutputPrivate::PlayError(TInt aError) } } -void QAudioOutputPrivate::BufferToBeEmptied(CMMFBuffer *aBuffer) -{ - Q_UNUSED(aBuffer) - // This class doesn't use DevSound in record mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioOutputPrivate::RecordError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound in record mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioOutputPrivate::ConvertError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound's format conversion functions, so - // should never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void QAudioOutputPrivate::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg) -{ - Q_UNUSED(aMessageType) - Q_UNUSED(aMsg) - // Ignore this callback. -} - -//----------------------------------------------------------------------------- -// Private functions -//----------------------------------------------------------------------------- - -void QAudioOutputPrivate::dataReady() -{ - // Client-provided QIODevice has data ready to read. - - Q_ASSERT_X(m_source->bytesAvailable(), Q_FUNC_INFO, - "readyRead signal received, but no data available"); - - if (!m_bytesPadding) - pullData(); -} - -void QAudioOutputPrivate::underflowTimerExpired() -{ - const TInt samplesPlayed = getSamplesPlayed(); - if (m_samplesPlayed && (samplesPlayed == m_samplesPlayed)) { - setError(QAudio::UnderrunError); - } else { - m_samplesPlayed = samplesPlayed; - m_underflowTimer->start(); - } -} - void QAudioOutputPrivate::open() { Q_ASSERT_X(SymbianAudio::ClosedState == m_internalState, Q_FUNC_INFO, "DevSound already opened"); - QT_TRAP_THROWING( m_devSound.reset(CMMFDevSound::NewL()) ) - - QScopedPointer<SymbianAudio::DevSoundCapabilities> caps( - new SymbianAudio::DevSoundCapabilities(*m_devSound, - QAudio::AudioOutput)); + Q_ASSERT(!m_devSound); + m_devSound = new SymbianAudio::DevSoundWrapper(QAudio::AudioOutput, this); - int err = SymbianAudio::Utils::isFormatSupported(m_format, *caps) ? - KErrNone : KErrNotSupported; + connect(m_devSound, SIGNAL(initializeComplete(int)), + this, SLOT(devsoundInitializeComplete(int))); + connect(m_devSound, SIGNAL(bufferToBeProcessed(CMMFBuffer *)), + this, SLOT(devsoundBufferToBeFilled(CMMFBuffer *))); + connect(m_devSound, SIGNAL(processingError(int)), + this, SLOT(devsoundPlayError(int))); - if (KErrNone == err) { - setState(SymbianAudio::InitializingState); - TRAP(err, m_devSound->InitializeL(*this, m_nativeFourCC, - EMMFStatePlaying)); - } - - if (KErrNone != err) { - setError(QAudio::OpenError); - m_devSound.reset(); - } + setState(SymbianAudio::InitializingState); + m_devSound->initialize(m_format.codec()); } void QAudioOutputPrivate::startPlayback() { - TRAPD(err, startDevSoundL()); - if (KErrNone == err) { + bool ok = m_devSound->setFormat(m_format); + if (ok) + ok = m_devSound->start(); + + if (ok) { if (isDataReady()) setState(SymbianAudio::ActiveState); else setState(SymbianAudio::IdleState); - m_notifyTimer->start(m_notifyInterval); + if (m_notifyInterval) + m_notifyTimer->start(m_notifyInterval); m_underflow = false; - Q_ASSERT(m_devSound->SamplesPlayed() == 0); + Q_ASSERT(m_devSound->samplesProcessed() == 0); writePaddingData(); @@ -462,14 +424,6 @@ void QAudioOutputPrivate::startPlayback() } } -void QAudioOutputPrivate::startDevSoundL() -{ - TMMFCapabilities nativeFormat = m_devSound->Config(); - m_nativeFormat.iBufferSize = nativeFormat.iBufferSize; - m_devSound->SetConfigL(m_nativeFormat); - m_devSound->PlayInitL(); -} - void QAudioOutputPrivate::writePaddingData() { // See comments in suspend() @@ -486,10 +440,11 @@ void QAudioOutputPrivate::writePaddingData() Mem::FillZ(ptr, paddingBytes); outputBuffer.SetLength(outputBuffer.Length() + paddingBytes); m_bytesPadding -= paddingBytes; + Q_ASSERT(m_bytesPadding >= 0); if (m_pullMode && m_source->atEnd()) lastBufferFilled(); - if (paddingBytes == outputBytes) + if ((paddingBytes == outputBytes) || !m_bytesPadding) bufferFilled(); } } @@ -543,9 +498,6 @@ void QAudioOutputPrivate::pullData() Q_ASSERT_X(m_pullMode, Q_FUNC_INFO, "pullData called when in push mode"); - if (m_bytesPadding) - m_bytesPadding = 1; - // writePaddingData() is called by BufferToBeFilled() before pullData(), // so we should never have any padding data left at this point. Q_ASSERT_X(0 == m_bytesPadding, Q_FUNC_INFO, @@ -590,7 +542,7 @@ void QAudioOutputPrivate::bufferFilled() if (QAudio::UnderrunError == m_error) m_error = QAudio::NoError; - m_devSound->PlayData(); + m_devSound->bufferProcessed(); } void QAudioOutputPrivate::lastBufferFilled() @@ -610,8 +562,10 @@ void QAudioOutputPrivate::close() m_error = QAudio::NoError; if (m_devSound) - m_devSound->Stop(); - m_devSound.reset(); + m_devSound->stop(); + delete m_devSound; + m_devSound = 0; + m_devSoundBuffer = 0; m_devSoundBufferSize = 0; @@ -644,7 +598,7 @@ qint64 QAudioOutputPrivate::getSamplesPlayed() const // This is necessary because some DevSound implementations report // that they have played more data than has actually been provided to them // by the client. - const qint64 devSoundSamplesPlayed(m_devSound->SamplesPlayed()); + const qint64 devSoundSamplesPlayed(m_devSound->samplesProcessed()); result = qMin(devSoundSamplesPlayed, samplesWritten); } } @@ -658,25 +612,25 @@ void QAudioOutputPrivate::setError(QAudio::Error error) // Although no state transition actually occurs here, a stateChanged event // must be emitted to inform the client that the call to start() was // unsuccessful. - if (QAudio::OpenError == error) + if (QAudio::OpenError == error) { emit stateChanged(QAudio::StoppedState); - - if (QAudio::UnderrunError == error) - setState(SymbianAudio::IdleState); - else - // Close the DevSound instance. This causes a transition to - // StoppedState. This must be done asynchronously in case the - // current function was called from a DevSound event handler, in which - // case deleting the DevSound instance may cause an exception. - QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); + } else { + if (QAudio::UnderrunError == error) + setState(SymbianAudio::IdleState); + else + // Close the DevSound instance. This causes a transition to + // StoppedState. This must be done asynchronously in case the + // current function was called from a DevSound event handler, in which + // case deleting the DevSound instance may cause an exception. + QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); + } } void QAudioOutputPrivate::setState(SymbianAudio::State newInternalState) { const QAudio::State oldExternalState = m_externalState; m_internalState = newInternalState; - m_externalState = SymbianAudio::Utils::stateNativeToQt( - m_internalState, initializingState()); + m_externalState = SymbianAudio::Utils::stateNativeToQt(m_internalState); if (m_externalState != oldExternalState) emit stateChanged(m_externalState); @@ -689,9 +643,4 @@ bool QAudioOutputPrivate::isDataReady() const || m_pushDataReady; } -QAudio::State QAudioOutputPrivate::initializingState() const -{ - return isDataReady() ? QAudio::ActiveState : QAudio::IdleState; -} - QT_END_NAMESPACE diff --git a/src/multimedia/multimedia/audio/qaudiooutput_symbian_p.h b/src/multimedia/audio/qaudiooutput_symbian_p.h index 00ccb24..c0acb07 100644 --- a/src/multimedia/multimedia/audio/qaudiooutput_symbian_p.h +++ b/src/multimedia/audio/qaudiooutput_symbian_p.h @@ -80,7 +80,6 @@ private: class QAudioOutputPrivate : public QAbstractAudioOutput - , public MDevSoundObserver { friend class SymbianAudioOutputPrivate; Q_OBJECT @@ -107,24 +106,16 @@ public: QAudio::State state() const; QAudioFormat format() const; - // MDevSoundObserver - void InitializeComplete(TInt aError); - void ToneFinished(TInt aError); - void BufferToBeFilled(CMMFBuffer *aBuffer); - void PlayError(TInt aError); - void BufferToBeEmptied(CMMFBuffer *aBuffer); - void RecordError(TInt aError); - void ConvertError(TInt aError); - void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg); - private slots: void dataReady(); void underflowTimerExpired(); + void devsoundInitializeComplete(int err); + void devsoundBufferToBeFilled(CMMFBuffer *); + void devsoundPlayError(int err); private: void open(); void startPlayback(); - void startDevSoundL(); void writePaddingData(); qint64 pushData(const char *data, qint64 len); void pullData(); @@ -138,7 +129,6 @@ private: void setState(SymbianAudio::State state); bool isDataReady() const; - QAudio::State initializingState() const; private: const QByteArray m_device; @@ -156,9 +146,7 @@ private: bool m_pullMode; QIODevice *m_source; - QScopedPointer<CMMFDevSound> m_devSound; - TUint32 m_nativeFourCC; - TMMFCapabilities m_nativeFormat; + SymbianAudio::DevSoundWrapper* m_devSound; // Buffer provided by DevSound, to be filled with data. CMMFDataBuffer *m_devSoundBuffer; diff --git a/src/multimedia/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index a8aeb41..a8aeb41 100644 --- a/src/multimedia/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp diff --git a/src/multimedia/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/audio/qaudiooutput_win32_p.h index 2d19225..2d19225 100644 --- a/src/multimedia/multimedia/audio/qaudiooutput_win32_p.h +++ b/src/multimedia/audio/qaudiooutput_win32_p.h diff --git a/src/multimedia/mediaservices/base/base.pri b/src/multimedia/mediaservices/base/base.pri deleted file mode 100644 index 49eca49..0000000 --- a/src/multimedia/mediaservices/base/base.pri +++ /dev/null @@ -1,69 +0,0 @@ - -QT += network -contains(QT_CONFIG, opengl):QT += opengl - -HEADERS += \ - $$PWD/qmediaresource.h \ - $$PWD/qmediacontent.h \ - $$PWD/qmediaobject.h \ - $$PWD/qmediaobject_p.h \ - $$PWD/qmediapluginloader_p.h \ - $$PWD/qmediaservice.h \ - $$PWD/qmediaservice_p.h \ - $$PWD/qmediaserviceprovider.h \ - $$PWD/qmediaserviceproviderplugin.h \ - $$PWD/qmediacontrol.h \ - $$PWD/qmediacontrol_p.h \ - $$PWD/qmetadatacontrol.h \ - $$PWD/qvideooutputcontrol.h \ - $$PWD/qvideowindowcontrol.h \ - $$PWD/qvideorenderercontrol.h \ - $$PWD/qvideodevicecontrol.h \ - $$PWD/qvideowidgetcontrol.h \ - $$PWD/qvideowidget.h \ - $$PWD/qvideowidget_p.h \ - $$PWD/qgraphicsvideoitem.h \ - $$PWD/qmediaplaylistcontrol.h \ - $$PWD/qmediaplaylist.h \ - $$PWD/qmediaplaylist_p.h \ - $$PWD/qmediaplaylistprovider.h \ - $$PWD/qmediaplaylistprovider_p.h \ - $$PWD/qmediaplaylistioplugin.h \ - $$PWD/qlocalmediaplaylistprovider.h \ - $$PWD/qmediaplaylistnavigator.h \ - $$PWD/qpaintervideosurface_p.h \ - $$PWD/qmediatimerange.h \ - $$PWD/qtmedianamespace.h - -SOURCES += \ - $$PWD/qmediaresource.cpp \ - $$PWD/qmediacontent.cpp \ - $$PWD/qmediaobject.cpp \ - $$PWD/qmediapluginloader.cpp \ - $$PWD/qmediaservice.cpp \ - $$PWD/qmediaserviceprovider.cpp \ - $$PWD/qmediacontrol.cpp \ - $$PWD/qmetadatacontrol.cpp \ - $$PWD/qvideooutputcontrol.cpp \ - $$PWD/qvideowindowcontrol.cpp \ - $$PWD/qvideorenderercontrol.cpp \ - $$PWD/qvideodevicecontrol.cpp \ - $$PWD/qvideowidgetcontrol.cpp \ - $$PWD/qvideowidget.cpp \ - $$PWD/qgraphicsvideoitem.cpp \ - $$PWD/qmediaplaylistcontrol.cpp \ - $$PWD/qmediaplaylist.cpp \ - $$PWD/qmediaplaylistprovider.cpp \ - $$PWD/qmediaplaylistioplugin.cpp \ - $$PWD/qlocalmediaplaylistprovider.cpp \ - $$PWD/qmediaplaylistnavigator.cpp \ - $$PWD/qpaintervideosurface.cpp \ - $$PWD/qmediatimerange.cpp - -mac { - HEADERS += $$PWD/qpaintervideosurface_mac_p.h - OBJECTIVE_SOURCES += $$PWD/qpaintervideosurface_mac.mm - - LIBS += -framework AppKit -framework QuartzCore -framework QTKit - -} diff --git a/src/multimedia/mediaservices/base/qgraphicsvideoitem.cpp b/src/multimedia/mediaservices/base/qgraphicsvideoitem.cpp deleted file mode 100644 index d80dec5..0000000 --- a/src/multimedia/mediaservices/base/qgraphicsvideoitem.cpp +++ /dev/null @@ -1,442 +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 QtMediaservies module 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 <QtMediaServices/qgraphicsvideoitem.h> - -#include <QtMediaServices/qmediaobject.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/private/qpaintervideosurface_p.h> -#include <QtMediaServices/qvideooutputcontrol.h> -#include <QtMediaServices/qvideorenderercontrol.h> -#include <QtMultimedia/qvideosurfaceformat.h> - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) -#include <QtOpenGL/qgl.h> -#endif - -#ifndef QT_NO_GRAPHICSVIEW - -QT_BEGIN_NAMESPACE - - -class QGraphicsVideoItemPrivate -{ -public: - QGraphicsVideoItemPrivate() - : q_ptr(0) - , surface(0) - , mediaObject(0) - , service(0) - , outputControl(0) - , rendererControl(0) - , aspectRatioMode(Qt::KeepAspectRatio) - , updatePaintDevice(true) - , rect(0.0, 0.0, 320, 240) - { - } - - QGraphicsVideoItem *q_ptr; - - QPainterVideoSurface *surface; - QMediaObject *mediaObject; - QMediaService *service; - QVideoOutputControl *outputControl; - QVideoRendererControl *rendererControl; - Qt::AspectRatioMode aspectRatioMode; - bool updatePaintDevice; - QRectF rect; - QRectF boundingRect; - QRectF sourceRect; - QSizeF nativeSize; - - void clearService(); - void updateRects(); - - void _q_present(); - void _q_formatChanged(const QVideoSurfaceFormat &format); - void _q_serviceDestroyed(); - void _q_mediaObjectDestroyed(); -}; - -void QGraphicsVideoItemPrivate::clearService() -{ - if (outputControl) { - outputControl->setOutput(QVideoOutputControl::NoOutput); - outputControl = 0; - } - if (rendererControl) { - surface->stop(); - rendererControl->setSurface(0); - rendererControl = 0; - } - if (service) { - QObject::disconnect(service, SIGNAL(destroyed()), q_ptr, SLOT(_q_serviceDestroyed())); - service = 0; - } -} - -void QGraphicsVideoItemPrivate::updateRects() -{ - q_ptr->prepareGeometryChange(); - - if (nativeSize.isEmpty()) { - boundingRect = QRectF(); - } else if (aspectRatioMode == Qt::IgnoreAspectRatio) { - boundingRect = rect; - sourceRect = QRectF(0, 0, 1, 1); - } else if (aspectRatioMode == Qt::KeepAspectRatio) { - QSizeF size = nativeSize; - size.scale(rect.size(), Qt::KeepAspectRatio); - - boundingRect = QRectF(0, 0, size.width(), size.height()); - boundingRect.moveCenter(rect.center()); - - sourceRect = QRectF(0, 0, 1, 1); - } else if (aspectRatioMode == Qt::KeepAspectRatioByExpanding) { - boundingRect = rect; - - QSizeF size = rect.size(); - size.scale(nativeSize, Qt::KeepAspectRatio); - - sourceRect = QRectF( - 0, 0, size.width() / nativeSize.width(), size.height() / nativeSize.height()); - sourceRect.moveCenter(QPointF(0.5, 0.5)); - } -} - -void QGraphicsVideoItemPrivate::_q_present() -{ - if (q_ptr->isObscured()) { - q_ptr->update(boundingRect); - surface->setReady(true); - } else { - q_ptr->update(boundingRect); - } -} - -void QGraphicsVideoItemPrivate::_q_formatChanged(const QVideoSurfaceFormat &format) -{ - nativeSize = format.sizeHint(); - - updateRects(); - - emit q_ptr->nativeSizeChanged(nativeSize); -} - -void QGraphicsVideoItemPrivate::_q_serviceDestroyed() -{ - rendererControl = 0; - outputControl = 0; - service = 0; - - surface->stop(); -} - -void QGraphicsVideoItemPrivate::_q_mediaObjectDestroyed() -{ - mediaObject = 0; - - clearService(); -} - -/*! - \class QGraphicsVideoItem - \brief The QGraphicsVideoItem class provides a graphics item which display video produced by a QMediaObject. - - \since 4.7 - - \ingroup multimedia - - Attaching a QGraphicsVideoItem to a QMediaObject allows it to display - the video or image output of that media object. A QGraphicsVideoItem - is attached to a media object by passing a pointer to the QMediaObject - to the setMediaObject() function. - - \code - player = new QMediaPlayer(this); - - QGraphicsVideoItem *item = new QGraphicsVideoItem; - item->setMediaObject(player); - graphicsView->scence()->addItem(item); - graphicsView->show(); - - player->setMedia(video); - player->play(); - \endcode - - \bold {Note}: Only a single display output can be attached to a media - object at one time. - - \sa QMediaObject, QMediaPlayer, QVideoWidget -*/ - -/*! - Constructs a graphics item that displays video. - - The \a parent is passed to QGraphicsItem. -*/ -QGraphicsVideoItem::QGraphicsVideoItem(QGraphicsItem *parent) - : QGraphicsObject(parent) - , d_ptr(new QGraphicsVideoItemPrivate) -{ - d_ptr->q_ptr = this; - d_ptr->surface = new QPainterVideoSurface; - - connect(d_ptr->surface, SIGNAL(frameChanged()), this, SLOT(_q_present())); - connect(d_ptr->surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), - this, SLOT(_q_formatChanged(QVideoSurfaceFormat))); -} - -/*! - Destroys a video graphics item. -*/ -QGraphicsVideoItem::~QGraphicsVideoItem() -{ - if (d_ptr->outputControl) - d_ptr->outputControl->setOutput(QVideoOutputControl::NoOutput); - - if (d_ptr->rendererControl) - d_ptr->rendererControl->setSurface(0); - - delete d_ptr->surface; - delete d_ptr; -} - -/*! - \property QGraphicsVideoItem::mediaObject - \brief the media object which provides the video displayed by a graphics - item. -*/ - -QMediaObject *QGraphicsVideoItem::mediaObject() const -{ - return d_func()->mediaObject; -} - -void QGraphicsVideoItem::setMediaObject(QMediaObject *object) -{ - Q_D(QGraphicsVideoItem); - - if (object == d->mediaObject) - return; - - d->clearService(); - - if (d->mediaObject) { - disconnect(d->mediaObject, SIGNAL(destroyed()), this, SLOT(_q_mediaObjectDestroyed())); - d->mediaObject->unbind(this); - } - - d->mediaObject = object; - - if (d->mediaObject) { - d->mediaObject->bind(this); - - connect(d->mediaObject, SIGNAL(destroyed()), this, SLOT(_q_mediaObjectDestroyed())); - - d->service = d->mediaObject->service(); - - if (d->service) { - connect(d->service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); - - d->outputControl = qobject_cast<QVideoOutputControl *>( - d->service->control(QVideoOutputControl_iid)); - d->rendererControl = qobject_cast<QVideoRendererControl *>( - d->service->control(QVideoRendererControl_iid)); - - if (d->outputControl != 0 && d->rendererControl != 0) { - d->rendererControl->setSurface(d->surface); - - if (isVisible()) - d->outputControl->setOutput(QVideoOutputControl::RendererOutput); - } - } - } -} - -/*! - \property QGraphicsVideoItem::aspectRatioMode - \brief how a video is scaled to fit the graphics item's size. -*/ - -Qt::AspectRatioMode QGraphicsVideoItem::aspectRatioMode() const -{ - return d_func()->aspectRatioMode; -} - -void QGraphicsVideoItem::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - Q_D(QGraphicsVideoItem); - - d->aspectRatioMode = mode; - d->updateRects(); -} - -/*! - \property QGraphicsVideoItem::offset - \brief the video item's offset. - - QGraphicsVideoItem will draw video using the offset for its top left - corner. -*/ - -QPointF QGraphicsVideoItem::offset() const -{ - return d_func()->rect.topLeft(); -} - -void QGraphicsVideoItem::setOffset(const QPointF &offset) -{ - Q_D(QGraphicsVideoItem); - - d->rect.moveTo(offset); - d->updateRects(); -} - -/*! - \property QGraphicsVideoItem::size - \brief the video item's size. - - QGraphicsVideoItem will draw video scaled to fit size according to its - fillMode. -*/ - -QSizeF QGraphicsVideoItem::size() const -{ - return d_func()->rect.size(); -} - -void QGraphicsVideoItem::setSize(const QSizeF &size) -{ - Q_D(QGraphicsVideoItem); - - d->rect.setSize(size.isValid() ? size : QSizeF(0, 0)); - d->updateRects(); -} - -/*! - \property QGraphicsVideoItem::nativeSize - \brief the native size of the video. -*/ - -QSizeF QGraphicsVideoItem::nativeSize() const -{ - return d_func()->nativeSize; -} - -/*! - \fn QGraphicsVideoItem::nativeSizeChanged(const QSizeF &size) - - Signals that the native \a size of the video has changed. -*/ - -/*! - \reimp -*/ -QRectF QGraphicsVideoItem::boundingRect() const -{ - return d_func()->boundingRect; -} - -/*! - \reimp -*/ -void QGraphicsVideoItem::paint( - QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_D(QGraphicsVideoItem); - - Q_UNUSED(option); - Q_UNUSED(widget); - - if (d->surface && d->surface->isActive()) { - d->surface->paint(painter, d->boundingRect, d->sourceRect); - d->surface->setReady(true); -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - } else if (d->updatePaintDevice && (painter->paintEngine()->type() == QPaintEngine::OpenGL - || painter->paintEngine()->type() == QPaintEngine::OpenGL2)) { - d->updatePaintDevice = false; - - d->surface->setGLContext(const_cast<QGLContext *>(QGLContext::currentContext())); - if (d->surface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) { - d->surface->setShaderType(QPainterVideoSurface::GlslShader); - } else { - d->surface->setShaderType(QPainterVideoSurface::FragmentProgramShader); - } -#endif - } -} - -/*! - \reimp - - \internal -*/ -QVariant QGraphicsVideoItem::itemChange(GraphicsItemChange change, const QVariant &value) -{ - return QGraphicsObject::itemChange(change, value); -} - -/*! - \reimp - - \internal -*/ -bool QGraphicsVideoItem::event(QEvent *event) -{ - return QGraphicsObject::event(event); -} - -/*! - \reimp - - \internal -*/ -bool QGraphicsVideoItem::sceneEvent(QEvent *event) -{ - return QGraphicsObject::sceneEvent(event); -} - -QT_END_NAMESPACE - -#endif // QT_NO_GRAPHICSVIEW - -#include "moc_qgraphicsvideoitem.cpp" diff --git a/src/multimedia/mediaservices/base/qgraphicsvideoitem.h b/src/multimedia/mediaservices/base/qgraphicsvideoitem.h deleted file mode 100644 index 679b353..0000000 --- a/src/multimedia/mediaservices/base/qgraphicsvideoitem.h +++ /dev/null @@ -1,115 +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 QtMediaServices module 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 QGRAPHICSVIDEOITEM_H -#define QGRAPHICSVIDEOITEM_H - -#include <QtGui/qgraphicsitem.h> - -#include <QtMediaServices/qvideowidget.h> - -#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QVideoSurfaceFormat; - -class QGraphicsVideoItemPrivate; -class Q_MEDIASERVICES_EXPORT QGraphicsVideoItem : public QGraphicsObject -{ - Q_OBJECT - Q_PROPERTY(QMediaObject* mediaObject READ mediaObject WRITE setMediaObject) - Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode) - Q_PROPERTY(QPointF offset READ offset WRITE setOffset) - Q_PROPERTY(QSizeF size READ size WRITE setSize) - Q_PROPERTY(QSizeF nativeSize READ nativeSize NOTIFY nativeSizeChanged) -public: - QGraphicsVideoItem(QGraphicsItem *parent = 0); - ~QGraphicsVideoItem(); - - QMediaObject *mediaObject() const; - void setMediaObject(QMediaObject *object); - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - QPointF offset() const; - void setOffset(const QPointF &offset); - - QSizeF size() const; - void setSize(const QSizeF &size); - - QSizeF nativeSize() const; - - QRectF boundingRect() const; - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - -Q_SIGNALS: - void nativeSizeChanged(const QSizeF &size); - -protected: - bool event(QEvent *event); - bool sceneEvent(QEvent *event); - - QVariant itemChange(GraphicsItemChange change, const QVariant &value); - - QGraphicsVideoItemPrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QGraphicsVideoItem) - Q_PRIVATE_SLOT(d_func(), void _q_present()) - Q_PRIVATE_SLOT(d_func(), void _q_formatChanged(const QVideoSurfaceFormat &)) - Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed()) - Q_PRIVATE_SLOT(d_func(), void _q_mediaObjectDestroyed()) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QT_NO_GRAPHICSVIEW - -#endif diff --git a/src/multimedia/mediaservices/base/qlocalmediaplaylistprovider.cpp b/src/multimedia/mediaservices/base/qlocalmediaplaylistprovider.cpp deleted file mode 100644 index 51e3bfb..0000000 --- a/src/multimedia/mediaservices/base/qlocalmediaplaylistprovider.cpp +++ /dev/null @@ -1,196 +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 QtMediaServices module 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 <QtMediaServices/qlocalmediaplaylistprovider.h> -#include "qmediaplaylistprovider_p.h" -#include <QtMediaServices/qmediacontent.h> - - -QT_BEGIN_NAMESPACE - -class QLocalMediaPlaylistProviderPrivate: public QMediaPlaylistProviderPrivate -{ -public: - QList<QMediaContent> resources; -}; - -QLocalMediaPlaylistProvider::QLocalMediaPlaylistProvider(QObject *parent) - :QMediaPlaylistProvider(*new QLocalMediaPlaylistProviderPrivate, parent) -{ -} - -QLocalMediaPlaylistProvider::~QLocalMediaPlaylistProvider() -{ -} - -bool QLocalMediaPlaylistProvider::isReadOnly() const -{ - return false; -} - -int QLocalMediaPlaylistProvider::mediaCount() const -{ - return d_func()->resources.size(); -} - -QMediaContent QLocalMediaPlaylistProvider::media(int pos) const -{ - return d_func()->resources.value(pos); -} - -bool QLocalMediaPlaylistProvider::addMedia(const QMediaContent &content) -{ - Q_D(QLocalMediaPlaylistProvider); - - int pos = d->resources.count(); - - emit mediaAboutToBeInserted(pos, pos); - d->resources.append(content); - emit mediaInserted(pos, pos); - - return true; -} - -bool QLocalMediaPlaylistProvider::addMedia(const QList<QMediaContent> &items) -{ - Q_D(QLocalMediaPlaylistProvider); - - if (items.isEmpty()) - return true; - - int pos = d->resources.count(); - int end = pos+items.count()-1; - - emit mediaAboutToBeInserted(pos, end); - d->resources.append(items); - emit mediaInserted(pos, end); - - return true; -} - - -bool QLocalMediaPlaylistProvider::insertMedia(int pos, const QMediaContent &content) -{ - Q_D(QLocalMediaPlaylistProvider); - - emit mediaAboutToBeInserted(pos, pos); - d->resources.insert(pos, content); - emit mediaInserted(pos,pos); - - return true; -} - -bool QLocalMediaPlaylistProvider::insertMedia(int pos, const QList<QMediaContent> &items) -{ - Q_D(QLocalMediaPlaylistProvider); - - if (items.isEmpty()) - return true; - - const int last = pos+items.count()-1; - - emit mediaAboutToBeInserted(pos, last); - for (int i=0; i<items.count(); i++) - d->resources.insert(pos+i, items.at(i)); - emit mediaInserted(pos, last); - - return true; -} - -bool QLocalMediaPlaylistProvider::removeMedia(int fromPos, int toPos) -{ - Q_D(QLocalMediaPlaylistProvider); - - Q_ASSERT(fromPos >= 0); - Q_ASSERT(fromPos <= toPos); - Q_ASSERT(toPos < mediaCount()); - - emit mediaAboutToBeRemoved(fromPos, toPos); - d->resources.erase(d->resources.begin()+fromPos, d->resources.begin()+toPos+1); - emit mediaRemoved(fromPos, toPos); - - return true; -} - -bool QLocalMediaPlaylistProvider::removeMedia(int pos) -{ - Q_D(QLocalMediaPlaylistProvider); - - emit mediaAboutToBeRemoved(pos, pos); - d->resources.removeAt(pos); - emit mediaRemoved(pos, pos); - - return true; -} - -bool QLocalMediaPlaylistProvider::clear() -{ - Q_D(QLocalMediaPlaylistProvider); - if (!d->resources.isEmpty()) { - int lastPos = mediaCount()-1; - emit mediaAboutToBeRemoved(0, lastPos); - d->resources.clear(); - emit mediaRemoved(0, lastPos); - } - - return true; -} - -void QLocalMediaPlaylistProvider::shuffle() -{ - Q_D(QLocalMediaPlaylistProvider); - if (!d->resources.isEmpty()) { - QList<QMediaContent> resources; - - while (!d->resources.isEmpty()) { - resources.append(d->resources.takeAt(qrand() % d->resources.size())); - } - - d->resources = resources; - emit mediaChanged(0, mediaCount()-1); - } - -} - -#include "moc_qlocalmediaplaylistprovider.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qlocalmediaplaylistprovider.h b/src/multimedia/mediaservices/base/qlocalmediaplaylistprovider.h deleted file mode 100644 index 4dd53df..0000000 --- a/src/multimedia/mediaservices/base/qlocalmediaplaylistprovider.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 QtMediaServices module 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 QLOCALMEDIAPAYLISTPROVIDER_H -#define QLOCALMEDIAPAYLISTPROVIDER_H - -#include <QtMediaServices/qmediaplaylistprovider.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QLocalMediaPlaylistProviderPrivate; -class Q_MEDIASERVICES_EXPORT QLocalMediaPlaylistProvider : public QMediaPlaylistProvider -{ - Q_OBJECT - -public: - QLocalMediaPlaylistProvider(QObject *parent=0); - virtual ~QLocalMediaPlaylistProvider(); - - virtual int mediaCount() const; - virtual QMediaContent media(int pos) const; - - virtual bool isReadOnly() const; - - virtual bool addMedia(const QMediaContent &content); - virtual bool addMedia(const QList<QMediaContent> &items); - virtual bool insertMedia(int pos, const QMediaContent &content); - virtual bool insertMedia(int pos, const QList<QMediaContent> &items); - virtual bool removeMedia(int pos); - virtual bool removeMedia(int start, int end); - virtual bool clear(); - -public Q_SLOTS: - virtual void shuffle(); - -private: - Q_DECLARE_PRIVATE(QLocalMediaPlaylistProvider) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QLOCALMEDIAPAYLISTSOURCE_H diff --git a/src/multimedia/mediaservices/base/qmediacontent.cpp b/src/multimedia/mediaservices/base/qmediacontent.cpp deleted file mode 100644 index 50d8e46..0000000 --- a/src/multimedia/mediaservices/base/qmediacontent.cpp +++ /dev/null @@ -1,242 +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 QtMediaServices module 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/qurl.h> -#include <QtCore/qvariant.h> - -#include <QtMediaServices/qmediacontent.h> - - -QT_BEGIN_NAMESPACE - - -class QMediaContentPrivate : public QSharedData -{ -public: - QMediaContentPrivate() {} - QMediaContentPrivate(const QMediaResourceList &r): - resources(r) {} - - QMediaContentPrivate(const QMediaContentPrivate &other): - QSharedData(other), - resources(other.resources) - {} - - bool operator==(const QMediaContentPrivate &other) const - { - return resources == other.resources; - } - - QMediaResourceList resources; - -private: - QMediaContentPrivate& operator=(const QMediaContentPrivate &other); -}; - - -/*! - \class QMediaContent - \preliminary - \brief The QMediaContent class provides access to the resources relating to a media content. - \since 4.7 - - \ingroup multimedia - - QMediaContent is used within the multimedia framework as the logical handle - to media content. A QMediaContent object is composed of one or more - \l {QMediaResource}s where each resource provides the URL and format - information of a different encoding of the content. - - A non-null QMediaContent will always have a primary or canonical reference to - the content available through the canonicalUrl() or canonicalResource() - methods, any additional resources are optional. -*/ - - -/*! - Constructs a null QMediaContent. -*/ - -QMediaContent::QMediaContent() -{ -} - -/*! - Constructs a media content with \a url providing a reference to the content. -*/ - -QMediaContent::QMediaContent(const QUrl &url): - d(new QMediaContentPrivate) -{ - d->resources << QMediaResource(url); -} - -/*! - Constructs a media content with \a request providing a reference to the content. - - This constructor can be used to reference media content via network protocols such as HTTP. - This may include additional information required to obtain the resource, such as Cookies or HTTP headers. -*/ - -QMediaContent::QMediaContent(const QNetworkRequest &request): - d(new QMediaContentPrivate) -{ - d->resources << QMediaResource(request); -} - -/*! - Constructs a media content with \a resource providing a reference to the content. -*/ - -QMediaContent::QMediaContent(const QMediaResource &resource): - d(new QMediaContentPrivate) -{ - d->resources << resource; -} - -/*! - Constructs a media content with \a resources providing a reference to the content. -*/ - -QMediaContent::QMediaContent(const QMediaResourceList &resources): - d(new QMediaContentPrivate(resources)) -{ -} - -/*! - Constructs a copy of the media content \a other. -*/ - -QMediaContent::QMediaContent(const QMediaContent &other): - d(other.d) -{ -} - -/*! - Destroys the media content object. -*/ - -QMediaContent::~QMediaContent() -{ -} - -/*! - Assigns the value of \a other to this media content. -*/ - -QMediaContent& QMediaContent::operator=(const QMediaContent &other) -{ - d = other.d; - return *this; -} - -/*! - Returns true if \a other is equivalent to this media content; false otherwise. -*/ - -bool QMediaContent::operator==(const QMediaContent &other) const -{ - return (d.constData() == 0 && other.d.constData() == 0) || - (d.constData() != 0 && other.d.constData() != 0 && - *d.constData() == *other.d.constData()); -} - -/*! - Returns true if \a other is not equivalent to this media content; false otherwise. -*/ - -bool QMediaContent::operator!=(const QMediaContent &other) const -{ - return !(*this == other); -} - -/*! - Returns true if this media content is null (uninitialized); false otherwise. -*/ - -bool QMediaContent::isNull() const -{ - return d.constData() == 0; -} - -/*! - Returns a QUrl that represents that canonical resource for this media content. -*/ - -QUrl QMediaContent::canonicalUrl() const -{ - return canonicalResource().url(); -} - -/*! - Returns a QNetworkRequest that represents that canonical resource for this media content. -*/ - -QNetworkRequest QMediaContent::canonicalRequest() const -{ - return canonicalResource().request(); -} - -/*! - Returns a QMediaResource that represents that canonical resource for this media content. -*/ - -QMediaResource QMediaContent::canonicalResource() const -{ - return d.constData() != 0 - ? d->resources.value(0) - : QMediaResource(); -} - -/*! - Returns a list of alternative resources for this media content. The first item in this list - is always the canonical resource. -*/ - -QMediaResourceList QMediaContent::resources() const -{ - return d.constData() != 0 - ? d->resources - : QMediaResourceList(); -} - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediacontent.h b/src/multimedia/mediaservices/base/qmediacontent.h deleted file mode 100644 index c00e443..0000000 --- a/src/multimedia/mediaservices/base/qmediacontent.h +++ /dev/null @@ -1,93 +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 QtMediaServices module 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 QMEDIACONTENT_H -#define QMEDIACONTENT_H - -#include <QtCore/qmetatype.h> -#include <QtCore/qshareddata.h> - -#include <QtMediaServices/qmediaresource.h> -#include <QtNetwork/qnetworkrequest.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMediaContentPrivate; -class Q_MEDIASERVICES_EXPORT QMediaContent -{ -public: - QMediaContent(); - QMediaContent(const QUrl &contentUrl); - QMediaContent(const QNetworkRequest &contentRequest); - QMediaContent(const QMediaResource &contentResource); - QMediaContent(const QMediaResourceList &resources); - QMediaContent(const QMediaContent &other); - ~QMediaContent(); - - QMediaContent& operator=(const QMediaContent &other); - - bool operator==(const QMediaContent &other) const; - bool operator!=(const QMediaContent &other) const; - - bool isNull() const; - - QUrl canonicalUrl() const; - QNetworkRequest canonicalRequest() const; - QMediaResource canonicalResource() const; - - QMediaResourceList resources() const; - -private: - QSharedDataPointer<QMediaContentPrivate> d; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaContent) - -QT_END_HEADER - -#endif // QMEDIACONTENT_H diff --git a/src/multimedia/mediaservices/base/qmediacontrol.cpp b/src/multimedia/mediaservices/base/qmediacontrol.cpp deleted file mode 100644 index 09996c8..0000000 --- a/src/multimedia/mediaservices/base/qmediacontrol.cpp +++ /dev/null @@ -1,140 +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 QtMediaServices module 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/qmetaobject.h> -#include <QtCore/qtimer.h> - -#include <QtMediaServices//qmediacontrol.h> -#include <QtMediaServices/private/qmediacontrol_p.h> - - - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaControl - \ingroup multimedia-serv - \since 4.7 - - \preliminary - \brief The QMediaControl class provides a base interface for media service controls. - - Media controls provide an interface to individual features provided by a media service. Most - services implement a principal control which exposes the core functionality of the service and - a number optional controls which expose any additional functionality. - - A pointer to a control implemented by a media service can be obtained using the - \l {QMediaService::control()}{control()} member of QMediaService. If the service doesn't - implement a control it will instead return a null pointer. - - \code - QMediaPlayerControl *control = qobject_cast<QMediaPlayerControl *>( - service->control("com.nokia.Qt.QMediaPlayerControl/1.0")); - \endcode - - Alternatively if the IId of the control has been declared using Q_MEDIA_DECLARE_CONTROL - the template version of QMediaService::control() can be used to request the service without - explicitly passing the IId. - - \code - QMediaPlayerControl *control = service->control<QMediaPlayerControl *>(); - \endcode - - Most application code will not interface directly with a media service's controls, instead the - QMediaObject which owns the service acts as an intermeditary between one or more controls and - the application. - - \sa QMediaService, QMediaObject -*/ - -/*! - \macro Q_MEDIA_DECLARE_CONTROL(Class, IId) - \relates QMediaControl - - The Q_MEDIA_DECLARE_CONTROL macro declares an \a IId for a \a Class that inherits from - QMediaControl. - - Declaring an IId for a QMediaControl allows an instance of that control to be requested from - QMediaService::control() without explicitly passing the IId. - - \code - QMediaPlayerControl *control = service->control<QMediaPlayerControl *>(); - \endcode - - \sa QMediaService::control() -*/ - -/*! - Destroys a media control. -*/ - -QMediaControl::~QMediaControl() -{ - delete d_ptr; -} - -/*! - Constructs a media control with the given \a parent. -*/ - -QMediaControl::QMediaControl(QObject *parent) - : QObject(parent) - , d_ptr(new QMediaControlPrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - \internal -*/ - -QMediaControl::QMediaControl(QMediaControlPrivate &dd, QObject *parent) - : QObject(parent) - , d_ptr(&dd) - -{ - d_ptr->q_ptr = this; -} - -#include "moc_qmediacontrol.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediacontrol.h b/src/multimedia/mediaservices/base/qmediacontrol.h deleted file mode 100644 index 941c004..0000000 --- a/src/multimedia/mediaservices/base/qmediacontrol.h +++ /dev/null @@ -1,82 +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 QtMediaServices module 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 QABSTRACTMEDIACONTROL_H -#define QABSTRACTMEDIACONTROL_H - -#include <QtCore/qobject.h> -#include <QtCore/qstring.h> -#include <QtCore/qvariant.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMediaControlPrivate; -class Q_MEDIASERVICES_EXPORT QMediaControl : public QObject -{ - Q_OBJECT - -public: - ~QMediaControl(); - -protected: - QMediaControl(QObject *parent = 0); - QMediaControl(QMediaControlPrivate &dd, QObject *parent = 0); - - QMediaControlPrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QMediaControl) -}; - -template <typename T> const char *qmediacontrol_iid() { return 0; } - -#define Q_MEDIA_DECLARE_CONTROL(Class, IId) \ - template <> inline const char *qmediacontrol_iid<Class *>() { return IId; } - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QABSTRACTMEDIACONTROL_H diff --git a/src/multimedia/mediaservices/base/qmediacontrol_p.h b/src/multimedia/mediaservices/base/qmediacontrol_p.h deleted file mode 100644 index 3f9755b..0000000 --- a/src/multimedia/mediaservices/base/qmediacontrol_p.h +++ /dev/null @@ -1,74 +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 QtMediaServices module 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 QABSTRACTMEDIACONTROL_P_H -#define QABSTRACTMEDIACONTROL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaControl; - -class QMediaControlPrivate -{ -public: - virtual ~QMediaControlPrivate() {} - - QMediaControl *q_ptr; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qmediaobject.cpp b/src/multimedia/mediaservices/base/qmediaobject.cpp deleted file mode 100644 index 68fb29e..0000000 --- a/src/multimedia/mediaservices/base/qmediaobject.cpp +++ /dev/null @@ -1,419 +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 QtMediaservics module 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/qmetaobject.h> - -#include "qmediaobject_p.h" - -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmetadatacontrol.h> - - -QT_BEGIN_NAMESPACE - -void QMediaObjectPrivate::_q_notify() -{ - Q_Q(QMediaObject); - - const QMetaObject* m = q->metaObject(); - - foreach (int pi, notifyProperties) { - QMetaProperty p = m->property(pi); - p.notifySignal().invoke( - q, QGenericArgument(QMetaType::typeName(p.userType()), p.read(q).data())); - } -} - - -/*! - \class QMediaObject - \preliminary - \brief The QMediaObject class provides a common base for multimedia objects. - \since 4.7 - - \ingroup multimedia - - QMediaObject derived classes provide access to the functionality of a - QMediaService. Each media object hosts a QMediaService and uses the - QMediaControl interfaces implemented by the service to implement its - API. Most media objects when constructed will request a new - QMediaService instance from a QMediaServiceProvider, but some like - QMediaRecorder will share a service with another object. - - QMediaObject itself provides an API for accessing a media service's \l {metaData()}{meta-data} and a means of connecting other media objects, - and peripheral classes like QVideoWidget and QMediaPlaylist. - - \sa QMediaService, QMediaControl -*/ - -/*! - Destroys a media object. -*/ - -QMediaObject::~QMediaObject() -{ - delete d_ptr; -} - -/*! - Returns the service availability error state. -*/ - -QtMediaServices::AvailabilityError QMediaObject::availabilityError() const -{ - return QtMediaServices::ServiceMissingError; -} - -/*! - Returns true if the service is available for use. -*/ - -bool QMediaObject::isAvailable() const -{ - return false; -} - -/*! - Returns the media service that provides the functionality of a multimedia object. -*/ - -QMediaService* QMediaObject::service() const -{ - return d_func()->service; -} - -int QMediaObject::notifyInterval() const -{ - return d_func()->notifyTimer->interval(); -} - -void QMediaObject::setNotifyInterval(int milliSeconds) -{ - Q_D(QMediaObject); - - if (d->notifyTimer->interval() != milliSeconds) { - d->notifyTimer->setInterval(milliSeconds); - - emit notifyIntervalChanged(milliSeconds); - } -} - -/*! - \internal -*/ -void QMediaObject::bind(QObject*) -{ -} - -/*! - \internal -*/ -void QMediaObject::unbind(QObject*) -{ -} - - -/*! - Constructs a media object which uses the functionality provided by a media \a service. - - The \a parent is passed to QObject. - - This class is meant as a base class for Multimedia objects so this - constructor is protected. -*/ - -QMediaObject::QMediaObject(QObject *parent, QMediaService *service): - QObject(parent), - d_ptr(new QMediaObjectPrivate) - -{ - Q_D(QMediaObject); - - d->q_ptr = this; - - d->notifyTimer = new QTimer(this); - d->notifyTimer->setInterval(1000); - connect(d->notifyTimer, SIGNAL(timeout()), SLOT(_q_notify())); - - d->service = service; - - setupMetaData(); -} - -/*! - \internal -*/ - -QMediaObject::QMediaObject(QMediaObjectPrivate &dd, QObject *parent, - QMediaService *service): - QObject(parent), - d_ptr(&dd) -{ - Q_D(QMediaObject); - d->q_ptr = this; - - d->notifyTimer = new QTimer(this); - d->notifyTimer->setInterval(1000); - connect(d->notifyTimer, SIGNAL(timeout()), SLOT(_q_notify())); - - d->service = service; - - setupMetaData(); -} - -/*! - Watch the property \a name. The property's notify signal will be emitted - once every notifyInterval milliseconds. - - \sa notifyInterval -*/ - -void QMediaObject::addPropertyWatch(QByteArray const &name) -{ - Q_D(QMediaObject); - - const QMetaObject* m = metaObject(); - - int index = m->indexOfProperty(name.constData()); - - if (index != -1 && m->property(index).hasNotifySignal()) { - d->notifyProperties.insert(index); - - if (!d->notifyTimer->isActive()) - d->notifyTimer->start(); - } -} - -/*! - Remove property \a name from the list of properties whose changes are - regularly signaled. - - \sa notifyInterval -*/ - -void QMediaObject::removePropertyWatch(QByteArray const &name) -{ - Q_D(QMediaObject); - - int index = metaObject()->indexOfProperty(name.constData()); - - if (index != -1) { - d->notifyProperties.remove(index); - - if (d->notifyProperties.isEmpty()) - d->notifyTimer->stop(); - } -} - -/*! - \property QMediaObject::notifyInterval - - The interval at which notifiable properties will update. - - The interval is expressed in milliseconds, the default value is 1000. - - \sa addPropertyWatch(), removePropertyWatch() -*/ - -/*! - \fn void QMediaObject::notifyIntervalChanged(int milliseconds) - - Signal a change in the notify interval period to \a milliseconds. -*/ - -/*! - \property QMediaObject::metaDataAvailable - \brief whether access to a media object's meta-data is available. - - If this is true there is meta-data available, otherwise there is no meta-data available. -*/ - -bool QMediaObject::isMetaDataAvailable() const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->isMetaDataAvailable() - : false; -} - -/*! - \fn QMediaObject::metaDataAvailableChanged(bool available) - - Signals that the \a available state of a media object's meta-data has changed. -*/ - -/*! - \property QMediaObject::metaDataWritable - \brief whether a media object's meta-data is writable. - - If this is true the meta-data is writable, otherwise the meta-data is read-only. -*/ - -bool QMediaObject::isMetaDataWritable() const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->isWritable() - : false; -} - -/*! - \fn QMediaObject::metaDataWritableChanged(bool writable) - - Signals that the \a writable state of a media object's meta-data has changed. -*/ - -/*! - Returns the value associated with a meta-data \a key. -*/ -QVariant QMediaObject::metaData(QtMediaServices::MetaData key) const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->metaData(key) - : QVariant(); -} - -/*! - Sets a \a value for a meta-data \a key. -*/ -void QMediaObject::setMetaData(QtMediaServices::MetaData key, const QVariant &value) -{ - Q_D(QMediaObject); - - if (d->metaDataControl) - d->metaDataControl->setMetaData(key, value); -} - -/*! - Returns a list of keys there is meta-data available for. -*/ -QList<QtMediaServices::MetaData> QMediaObject::availableMetaData() const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->availableMetaData() - : QList<QtMediaServices::MetaData>(); -} - -/*! - \fn QMediaObject::metaDataChanged() - - Signals that a media object's meta-data has changed. -*/ - -/*! - Returns the value associated with a meta-data \a key. - - The naming and type of extended meta-data is not standardized, so the values and meaning - of keys may vary between backends. -*/ -QVariant QMediaObject::extendedMetaData(const QString &key) const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->extendedMetaData(key) - : QVariant(); -} - -/*! - Sets a \a value for a meta-data \a key. - - The naming and type of extended meta-data is not standardized, so the values and meaning - of keys may vary between backends. -*/ -void QMediaObject::setExtendedMetaData(const QString &key, const QVariant &value) -{ - Q_D(QMediaObject); - - if (d->metaDataControl) - d->metaDataControl->setExtendedMetaData(key, value); -} - -/*! - Returns a list of keys there is extended meta-data available for. -*/ -QStringList QMediaObject::availableExtendedMetaData() const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->availableExtendedMetaData() - : QStringList(); -} - - -void QMediaObject::setupMetaData() -{ - Q_D(QMediaObject); - - if (d->service != 0) { - d->metaDataControl = - qobject_cast<QMetaDataControl*>(d->service->control(QMetaDataControl_iid)); - - if (d->metaDataControl) { - connect(d->metaDataControl, SIGNAL(metaDataChanged()), SIGNAL(metaDataChanged())); - connect(d->metaDataControl, - SIGNAL(metaDataAvailableChanged(bool)), - SIGNAL(metaDataAvailableChanged(bool))); - connect(d->metaDataControl, - SIGNAL(writableChanged(bool)), - SIGNAL(metaDataWritableChanged(bool))); - } - } -} - -/*! - \fn QMediaObject::availabilityChanged(bool available) - - Signal emitted when the availability state has changed to \a available -*/ - - -#include "moc_qmediaobject.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediaobject.h b/src/multimedia/mediaservices/base/qmediaobject.h deleted file mode 100644 index 067bb56..0000000 --- a/src/multimedia/mediaservices/base/qmediaobject.h +++ /dev/null @@ -1,121 +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 QtMediaServices module 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 QABSTRACTMEDIAOBJECT_H -#define QABSTRACTMEDIAOBJECT_H - -#include <QtCore/qobject.h> -#include <QtCore/qstringlist.h> - -#include <QtMediaServices/qtmedianamespace.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMediaService; - -class QMediaObjectPrivate; -class Q_MEDIASERVICES_EXPORT QMediaObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int notifyInterval READ notifyInterval WRITE setNotifyInterval NOTIFY notifyIntervalChanged) - Q_PROPERTY(bool metaDataAvailable READ isMetaDataAvailable NOTIFY metaDataAvailableChanged) - Q_PROPERTY(bool metaDataWritable READ isMetaDataWritable NOTIFY metaDataWritableChanged) - -public: - ~QMediaObject(); - - virtual bool isAvailable() const; - virtual QtMediaServices::AvailabilityError availabilityError() const; - - virtual QMediaService* service() const; - - int notifyInterval() const; - void setNotifyInterval(int milliSeconds); - - virtual void bind(QObject*); - virtual void unbind(QObject*); - - bool isMetaDataAvailable() const; - bool isMetaDataWritable() 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; - -Q_SIGNALS: - void notifyIntervalChanged(int milliSeconds); - - void metaDataAvailableChanged(bool available); - void metaDataWritableChanged(bool writable); - void metaDataChanged(); - - void availabilityChanged(bool available); - -protected: - QMediaObject(QObject *parent, QMediaService *service); - QMediaObject(QMediaObjectPrivate &dd, QObject *parent, QMediaService *service); - - void addPropertyWatch(QByteArray const &name); - void removePropertyWatch(QByteArray const &name); - - QMediaObjectPrivate *d_ptr; - -private: - void setupMetaData(); - - Q_DECLARE_PRIVATE(QMediaObject) - Q_PRIVATE_SLOT(d_func(), void _q_notify()) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QABSTRACTMEDIAOBJECT_H diff --git a/src/multimedia/mediaservices/base/qmediaobject_p.h b/src/multimedia/mediaservices/base/qmediaobject_p.h deleted file mode 100644 index c31ad46..0000000 --- a/src/multimedia/mediaservices/base/qmediaobject_p.h +++ /dev/null @@ -1,95 +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 QtMediaServices module 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 QABSTRACTMEDIAOBJECT_P_H -#define QABSTRACTMEDIAOBJECT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qbytearray.h> -#include <QtCore/qset.h> -#include <QtCore/qtimer.h> - -#include <QtMediaServices/qmediaobject.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMetaDataControl; - -#define Q_DECLARE_NON_CONST_PUBLIC(Class) \ - inline Class* q_func() { return static_cast<Class *>(q_ptr); } \ - friend class Class; - - -class QMediaObjectPrivate -{ - Q_DECLARE_PUBLIC(QMediaObject) - -public: - QMediaObjectPrivate():metaDataControl(0), notifyTimer(0) {} - virtual ~QMediaObjectPrivate() {} - - void _q_notify(); - - QMediaService *service; - QMetaDataControl *metaDataControl; - QTimer* notifyTimer; - QSet<int> notifyProperties; - - QMediaObject *q_ptr; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qmediaplaylist.cpp b/src/multimedia/mediaservices/base/qmediaplaylist.cpp deleted file mode 100644 index 93278fe..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylist.cpp +++ /dev/null @@ -1,724 +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 QtMediaServices module 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/qlist.h> -#include <QtCore/qfile.h> -#include <QtCore/qurl.h> -#include <QtCore/qcoreevent.h> -#include <QtCore/qcoreapplication.h> - -#include <QtMediaServices/qmediaplaylist.h> -#include "qmediaplaylist_p.h" -#include <QtMediaServices/qmediaplaylistprovider.h> -#include <QtMediaServices/qlocalmediaplaylistprovider.h> -#include <QtMediaServices/qmediaplaylistioplugin.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmediaplaylistcontrol.h> -#include <QtMediaServices/qmediaplayercontrol.h> - -#include "qmediapluginloader_p.h" - - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, playlistIOLoader, - (QMediaPlaylistIOInterface_iid, QLatin1String("/playlistformats"), Qt::CaseInsensitive)) - - -/*! - \class QMediaPlaylist - \ingroup multimedia - \since 4.7 - - \preliminary - \brief The QMediaPlaylist class provides a list of media content to play. - - QMediaPlaylist is intended to be used with other media objects, - like QMediaPlayer or QMediaImageViewer. - QMediaPlaylist allows to access the service intrinsic playlist functionality - if available, otherwise it provides the the local memory playlist implementation. - -\code - player = new QMediaPlayer; - - playlist = new QMediaPlaylist; - playlist->setMediaObject(player); - playlist->append(QUrl("http://example.com/movie1.mp4")); - playlist->append(QUrl("http://example.com/movie2.mp4")); - playlist->append(QUrl("http://example.com/movie3.mp4")); - - playlist->setCurrentIndex(1); - - player->play(); -\endcode - - Depending on playlist source implementation, - most of playlist modifcation operations can be asynchronous. - - \sa QMediaContent -*/ - - -/*! - \enum QMediaPlaylist::PlaybackMode - - The QMediaPlaylist::PlaybackMode describes the order items in playlist are played. - - \value CurrentItemOnce The current item is played only once. - - \value CurrentItemInLoop The current item is played in the loop. - - \value Linear Playback starts from the first to the last items and stops. - next item is a null item when the last one is currently playing. - - \value Loop Playback continues from the first item after the last one finished playing. - - \value Random Play items in random order. -*/ - - - -/*! - Create a new playlist object for with the given \a parent. -*/ - -QMediaPlaylist::QMediaPlaylist(QObject *parent) - : QObject(parent) - , d_ptr(new QMediaPlaylistPrivate) -{ - Q_D(QMediaPlaylist); - - d->q_ptr = this; - d->localPlaylistControl = new QLocalMediaPlaylistControl(this); - - setMediaObject(0); -} - -/*! - Destroys the playlist. - */ - -QMediaPlaylist::~QMediaPlaylist() -{ - Q_D(QMediaPlaylist); - - if (d->mediaObject) - d->mediaObject->unbind(this); - - delete d_ptr; -} - -/*! - Returns the QMediaObject that is being used to play the contents of this playlist. -*/ - -QMediaObject *QMediaPlaylist::mediaObject() const -{ - return d_func()->mediaObject; -} - -/*! - If \a mediaObject is null or doesn't have an intrinsic playlist, - internal local memory playlist source will be created. -*/ -void QMediaPlaylist::setMediaObject(QMediaObject *mediaObject) -{ - Q_D(QMediaPlaylist); - - if (mediaObject && mediaObject == d->mediaObject) - return; - - QMediaService *service = mediaObject - ? mediaObject->service() : 0; - - QMediaPlaylistControl *newControl = 0; - - if (service) - newControl = qobject_cast<QMediaPlaylistControl*>(service->control(QMediaPlaylistControl_iid)); - - if (!newControl) - newControl = d->localPlaylistControl; - - if (d->control != newControl) { - int oldSize = 0; - if (d->control) { - QMediaPlaylistProvider *playlist = d->control->playlistProvider(); - oldSize = playlist->mediaCount(); - disconnect(playlist, SIGNAL(loadFailed(QMediaPlaylist::Error,QString)), - this, SLOT(_q_loadFailed(QMediaPlaylist::Error,QString))); - - disconnect(playlist, SIGNAL(mediaChanged(int,int)), this, SIGNAL(mediaChanged(int,int))); - disconnect(playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SIGNAL(mediaAboutToBeInserted(int,int))); - disconnect(playlist, SIGNAL(mediaInserted(int,int)), this, SIGNAL(mediaInserted(int,int))); - disconnect(playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SIGNAL(mediaAboutToBeRemoved(int,int))); - disconnect(playlist, SIGNAL(mediaRemoved(int,int)), this, SIGNAL(mediaRemoved(int,int))); - - disconnect(playlist, SIGNAL(loaded()), this, SIGNAL(loaded())); - - disconnect(d->control, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)), - this, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode))); - disconnect(d->control, SIGNAL(currentIndexChanged(int)), - this, SIGNAL(currentIndexChanged(int))); - disconnect(d->control, SIGNAL(currentMediaChanged(QMediaContent)), - this, SIGNAL(currentMediaChanged(QMediaContent))); - } - - d->control = newControl; - QMediaPlaylistProvider *playlist = d->control->playlistProvider(); - connect(playlist, SIGNAL(loadFailed(QMediaPlaylist::Error,QString)), - this, SLOT(_q_loadFailed(QMediaPlaylist::Error,QString))); - - connect(playlist, SIGNAL(mediaChanged(int,int)), this, SIGNAL(mediaChanged(int,int))); - connect(playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SIGNAL(mediaAboutToBeInserted(int,int))); - connect(playlist, SIGNAL(mediaInserted(int,int)), this, SIGNAL(mediaInserted(int,int))); - connect(playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SIGNAL(mediaAboutToBeRemoved(int,int))); - connect(playlist, SIGNAL(mediaRemoved(int,int)), this, SIGNAL(mediaRemoved(int,int))); - - connect(playlist, SIGNAL(loaded()), this, SIGNAL(loaded())); - - connect(d->control, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)), - this, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode))); - connect(d->control, SIGNAL(currentIndexChanged(int)), - this, SIGNAL(currentIndexChanged(int))); - connect(d->control, SIGNAL(currentMediaChanged(QMediaContent)), - this, SIGNAL(currentMediaChanged(QMediaContent))); - - if (oldSize) - emit mediaRemoved(0, oldSize-1); - - if (playlist->mediaCount()) { - emit mediaAboutToBeInserted(0,playlist->mediaCount()-1); - emit mediaInserted(0,playlist->mediaCount()-1); - } - } - - if (d->mediaObject) - d->mediaObject->unbind(this); - - d->mediaObject = mediaObject; - if (d->mediaObject) - d->mediaObject->bind(this); -} - -/*! - \property QMediaPlaylist::playbackMode - - This property defines the order, items in playlist are played. - - \sa QMediaPlaylist::PlaybackMode -*/ - -QMediaPlaylist::PlaybackMode QMediaPlaylist::playbackMode() const -{ - return d_func()->control->playbackMode(); -} - -void QMediaPlaylist::setPlaybackMode(QMediaPlaylist::PlaybackMode mode) -{ - Q_D(QMediaPlaylist); - d->control->setPlaybackMode(mode); -} - -/*! - Returns position of the current media source in the playlist. -*/ -int QMediaPlaylist::currentIndex() const -{ - return d_func()->control->currentIndex(); -} - -/*! - Returns the current media content. -*/ - -QMediaContent QMediaPlaylist::currentMedia() const -{ - return d_func()->playlist()->media(currentIndex()); -} - -/*! - Returns the index of item, which were current after calling next() - \a steps times. - - Returned value depends on the size of playlist, current position - and playback mode. - - \sa QMediaPlaylist::playbackMode -*/ -int QMediaPlaylist::nextIndex(int steps) const -{ - return d_func()->control->nextIndex(steps); -} - -/*! - Returns the index of item, which were current after calling previous() - \a steps times. - - \sa QMediaPlaylist::playbackMode -*/ - -int QMediaPlaylist::previousIndex(int steps) const -{ - return d_func()->control->previousIndex(steps); -} - - -/*! - Returns the number of items in the playlist. - - \sa isEmpty() - */ -int QMediaPlaylist::mediaCount() const -{ - return d_func()->playlist()->mediaCount(); -} - -/*! - Returns true if the playlist contains no items; otherwise returns false. - \sa mediaCount() - */ -bool QMediaPlaylist::isEmpty() const -{ - return mediaCount() == 0; -} - -/*! - Returns true if the playlist can be modified; otherwise returns false. - \sa mediaCount() - */ -bool QMediaPlaylist::isReadOnly() const -{ - return d_func()->playlist()->isReadOnly(); -} - -/*! - Returns the media content at \a index in the playlist. -*/ - -QMediaContent QMediaPlaylist::media(int index) const -{ - return d_func()->playlist()->media(index); -} - -/*! - Append the media \a content to the playlist. - - Returns true if the operation is successfull, other wise return false. - */ -bool QMediaPlaylist::addMedia(const QMediaContent &content) -{ - return d_func()->control->playlistProvider()->addMedia(content); -} - -/*! - Append multiple media content \a items to the playlist. - - Returns true if the operation is successfull, other wise return false. - */ -bool QMediaPlaylist::addMedia(const QList<QMediaContent> &items) -{ - return d_func()->control->playlistProvider()->addMedia(items); -} - -/*! - Insert the media \a content to the playlist at position \a pos. - - Returns true if the operation is successful, otherwise false. -*/ - -bool QMediaPlaylist::insertMedia(int pos, const QMediaContent &content) -{ - return d_func()->playlist()->insertMedia(pos, content); -} - -/*! - Insert multiple media content \a items to the playlist at position \a pos. - - Returns true if the operation is successful, otherwise false. -*/ - -bool QMediaPlaylist::insertMedia(int pos, const QList<QMediaContent> &items) -{ - return d_func()->playlist()->insertMedia(pos, items); -} - -/*! - Remove the item from the playlist at position \a pos. - - Returns true if the operation is successfull, other wise return false. - */ -bool QMediaPlaylist::removeMedia(int pos) -{ - Q_D(QMediaPlaylist); - return d->playlist()->removeMedia(pos); -} - -/*! - Remove the items from the playlist from position \a start to \a end inclusive. - - Returns true if the operation is successfull, other wise return false. - */ -bool QMediaPlaylist::removeMedia(int start, int end) -{ - Q_D(QMediaPlaylist); - return d->playlist()->removeMedia(start, end); -} - -/*! - Remove all the items from the playlist. - - Returns true if the operation is successfull, other wise return false. - */ -bool QMediaPlaylist::clear() -{ - Q_D(QMediaPlaylist); - return d->playlist()->clear(); -} - -bool QMediaPlaylistPrivate::readItems(QMediaPlaylistReader *reader) -{ - while (!reader->atEnd()) - playlist()->addMedia(reader->readItem()); - - return true; -} - -bool QMediaPlaylistPrivate::writeItems(QMediaPlaylistWriter *writer) -{ - for (int i=0; i<playlist()->mediaCount(); i++) { - if (!writer->writeItem(playlist()->media(i))) - return false; - } - writer->close(); - return true; -} - -/*! - Load playlist from \a location. If \a format is specified, it is used, - otherwise format is guessed from location name and data. - - New items are appended to playlist. - - QMediaPlaylist::loaded() signal is emited if playlist was loaded succesfully, - otherwise the playlist emits loadFailed(). -*/ -void QMediaPlaylist::load(const QUrl &location, const char *format) -{ - Q_D(QMediaPlaylist); - - d->error = NoError; - d->errorString.clear(); - - if (d->playlist()->load(location,format)) - return; - - if (isReadOnly()) { - d->error = AccessDeniedError; - d->errorString = tr("Could not add items to read only playlist."); - emit loadFailed(); - return; - } - - foreach (QString const& key, playlistIOLoader()->keys()) { - QMediaPlaylistIOInterface* plugin = qobject_cast<QMediaPlaylistIOInterface*>(playlistIOLoader()->instance(key)); - if (plugin && plugin->canRead(location,format)) { - QMediaPlaylistReader *reader = plugin->createReader(location,QByteArray(format)); - if (reader && d->readItems(reader)) { - delete reader; - emit loaded(); - return; - } - delete reader; - } - } - - d->error = FormatNotSupportedError; - d->errorString = tr("Playlist format is not supported"); - emit loadFailed(); - - return; -} - -/*! - Load playlist from QIODevice \a device. If \a format is specified, it is used, - otherwise format is guessed from device data. - - New items are appended to playlist. - - QMediaPlaylist::loaded() signal is emited if playlist was loaded succesfully, - otherwise the playlist emits loadFailed(). -*/ -void QMediaPlaylist::load(QIODevice * device, const char *format) -{ - Q_D(QMediaPlaylist); - - d->error = NoError; - d->errorString.clear(); - - if (d->playlist()->load(device,format)) - return; - - if (isReadOnly()) { - d->error = AccessDeniedError; - d->errorString = tr("Could not add items to read only playlist."); - emit loadFailed(); - return; - } - - foreach (QString const& key, playlistIOLoader()->keys()) { - QMediaPlaylistIOInterface* plugin = qobject_cast<QMediaPlaylistIOInterface*>(playlistIOLoader()->instance(key)); - if (plugin && plugin->canRead(device,format)) { - QMediaPlaylistReader *reader = plugin->createReader(device,QByteArray(format)); - if (reader && d->readItems(reader)) { - delete reader; - emit loaded(); - return; - } - delete reader; - } - } - - d->error = FormatNotSupportedError; - d->errorString = tr("Playlist format is not supported"); - emit loadFailed(); - - return; -} - -/*! - Save playlist to \a location. If \a format is specified, it is used, - otherwise format is guessed from location name. - - Returns true if playlist was saved succesfully, otherwise returns false. - */ -bool QMediaPlaylist::save(const QUrl &location, const char *format) -{ - Q_D(QMediaPlaylist); - - d->error = NoError; - d->errorString.clear(); - - if (d->playlist()->save(location,format)) - return true; - - QFile file(location.toLocalFile()); - - if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { - d->error = AccessDeniedError; - d->errorString = tr("The file could not be accessed."); - return false; - } - - return save(&file, format); -} - -/*! - Save playlist to QIODevice \a device using format \a format. - - Returns true if playlist was saved succesfully, otherwise returns false. -*/ -bool QMediaPlaylist::save(QIODevice * device, const char *format) -{ - Q_D(QMediaPlaylist); - - d->error = NoError; - d->errorString.clear(); - - if (d->playlist()->save(device,format)) - return true; - - foreach (QString const& key, playlistIOLoader()->keys()) { - QMediaPlaylistIOInterface* plugin = qobject_cast<QMediaPlaylistIOInterface*>(playlistIOLoader()->instance(key)); - if (plugin && plugin->canWrite(device,format)) { - QMediaPlaylistWriter *writer = plugin->createWriter(device,QByteArray(format)); - if (writer && d->writeItems(writer)) { - delete writer; - return true; - } - delete writer; - } - } - - d->error = FormatNotSupportedError; - d->errorString = tr("Playlist format is not supported."); - - return false; -} - -/*! - Returns the last error condition. -*/ -QMediaPlaylist::Error QMediaPlaylist::error() const -{ - return d_func()->error; -} - -/*! - Returns the string describing the last error condition. -*/ -QString QMediaPlaylist::errorString() const -{ - return d_func()->errorString; -} - -/*! - Shuffle items in the playlist. -*/ -void QMediaPlaylist::shuffle() -{ - d_func()->playlist()->shuffle(); -} - - -/*! - Advance to the next media content in playlist. -*/ -void QMediaPlaylist::next() -{ - d_func()->control->next(); -} - -/*! - Return to the previous media content in playlist. -*/ -void QMediaPlaylist::previous() -{ - d_func()->control->previous(); -} - -/*! - Activate media content from playlist at position \a playlistPosition. -*/ - -void QMediaPlaylist::setCurrentIndex(int playlistPosition) -{ - d_func()->control->setCurrentIndex(playlistPosition); -} - -/*! - \fn void QMediaPlaylist::mediaInserted(int start, int end) - - This signal is emitted after media has been inserted into the playlist. - The new items are those between \a start and \a end inclusive. - */ - -/*! - \fn void QMediaPlaylist::mediaRemoved(int start, int end) - - This signal is emitted after media has been removed from the playlist. - The removed items are those between \a start and \a end inclusive. - */ - -/*! - \fn void QMediaPlaylist::mediaChanged(int start, int end) - - This signal is emitted after media has been changed in the playlist - between \a start and \a end positions inclusive. - */ - -/*! - \fn void QMediaPlaylist::currentIndexChanged(int position) - - Signal emitted when playlist position changed to \a position. -*/ - -/*! - \fn void QMediaPlaylist::playbackModeChanged(QMediaPlaylist::PlaybackMode mode) - - Signal emitted when playback mode changed to \a mode. -*/ - -/*! - \fn void QMediaPlaylist::mediaAboutToBeInserted(int start, int end) - - Signal emitted when item to be inserted at \a start and ending at \a end. -*/ - -/*! - \fn void QMediaPlaylist::mediaAboutToBeRemoved(int start, int end) - - Signal emitted when item to de deleted ar \a start and ending at \a end. -*/ - -/*! - \fn void QMediaPlaylist::currentMediaChanged(const QMediaContent &content) - - Signal emitted when current media changes to \a content. -*/ - -/*! - \property QMediaPlaylist::currentIndex - \brief Current position. -*/ - -/*! - \property QMediaPlaylist::currentMedia - \brief Current media content. -*/ - -/*! - \fn QMediaPlaylist::loaded() - - Signal emitted when playlist finished loading. -*/ - -/*! - \fn QMediaPlaylist::loadFailed() - - Signal emitted if failed to load playlist. -*/ - -/*! - \enum QMediaPlaylist::Error - - This enum describes the QMediaPlaylist error codes. - - \value NoError No errors. - \value FormatError Format error. - \value FormatNotSupportedError Format not supported. - \value NetworkError Network error. - \value AccessDeniedError Access denied error. -*/ - -QT_END_NAMESPACE - -#include "moc_qmediaplaylist.cpp" -#include "moc_qmediaplaylist_p.cpp" diff --git a/src/multimedia/mediaservices/base/qmediaplaylist.h b/src/multimedia/mediaservices/base/qmediaplaylist.h deleted file mode 100644 index 6cae7c5..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylist.h +++ /dev/null @@ -1,147 +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 QtMediaServices module 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 QMEDIAPLAYLIST_H -#define QMEDIAPLAYLIST_H - -#include <QtCore/qobject.h> - -#include <QtMediaServices/qmediacontent.h> -#include <QtMediaServices/qmediaobject.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMediaPlaylistProvider; - -class QMediaPlaylistPrivate; -class Q_MEDIASERVICES_EXPORT QMediaPlaylist : public QObject -{ - Q_OBJECT - Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode NOTIFY playbackModeChanged) - Q_PROPERTY(QMediaContent currentMedia READ currentMedia NOTIFY currentMediaChanged) - Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) - Q_ENUMS(PlaybackMode Error) - -public: - enum PlaybackMode { CurrentItemOnce, CurrentItemInLoop, Linear, Loop, Random }; - enum Error { NoError, FormatError, FormatNotSupportedError, NetworkError, AccessDeniedError }; - - QMediaPlaylist(QObject *parent = 0); - virtual ~QMediaPlaylist(); - - QMediaObject *mediaObject() const; - void setMediaObject(QMediaObject *object); - - PlaybackMode playbackMode() const; - void setPlaybackMode(PlaybackMode mode); - - int currentIndex() const; - QMediaContent currentMedia() const; - - int nextIndex(int steps = 1) const; - int previousIndex(int steps = 1) const; - - QMediaContent media(int index) const; - - int mediaCount() const; - bool isEmpty() const; - bool isReadOnly() const; - - bool addMedia(const QMediaContent &content); - bool addMedia(const QList<QMediaContent> &items); - bool insertMedia(int index, const QMediaContent &content); - bool insertMedia(int index, const QList<QMediaContent> &items); - bool removeMedia(int pos); - bool removeMedia(int start, int end); - bool clear(); - - void load(const QUrl &location, const char *format = 0); - void load(QIODevice * device, const char *format = 0); - - bool save(const QUrl &location, const char *format = 0); - bool save(QIODevice * device, const char *format); - - Error error() const; - QString errorString() const; - -public Q_SLOTS: - void shuffle(); - - void next(); - void previous(); - - void setCurrentIndex(int index); - -Q_SIGNALS: - void currentIndexChanged(int index); - void playbackModeChanged(QMediaPlaylist::PlaybackMode mode); - void currentMediaChanged(const QMediaContent&); - - void mediaAboutToBeInserted(int start, int end); - void mediaInserted(int start, int end); - void mediaAboutToBeRemoved(int start, int end); - void mediaRemoved(int start, int end); - void mediaChanged(int start, int end); - - void loaded(); - void loadFailed(); - -protected: - QMediaPlaylistPrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QMediaPlaylist) - Q_PRIVATE_SLOT(d_func(), void _q_loadFailed(QMediaPlaylist::Error, const QString &)) -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaPlaylist::PlaybackMode) -Q_DECLARE_METATYPE(QMediaPlaylist::Error) - -QT_END_HEADER - -#endif // QMEDIAPLAYLIST_H diff --git a/src/multimedia/mediaservices/base/qmediaplaylist_p.h b/src/multimedia/mediaservices/base/qmediaplaylist_p.h deleted file mode 100644 index a5f290e..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylist_p.h +++ /dev/null @@ -1,172 +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 QtMediaServices module 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 QMEDIAPLAYLIST_P_H -#define QMEDIAPLAYLIST_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtMediaServices/qmediaplaylist.h> -#include <QtMediaServices/qmediaplaylistcontrol.h> -#include <QtMediaServices/qmediaplayer.h> -#include <QtMediaServices/qmediaplayercontrol.h> -#include <QtMediaServices/qlocalmediaplaylistprovider.h> -#include "qmediaobject_p.h" - -#include <QtCore/qdebug.h> - -#ifdef Q_MOC_RUN -# pragma Q_MOC_EXPAND_MACROS -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaPlaylistControl; -class QMediaPlaylistProvider; -class QMediaPlaylistReader; -class QMediaPlaylistWriter; -class QMediaPlayerControl; - -class QMediaPlaylistPrivate -{ - Q_DECLARE_PUBLIC(QMediaPlaylist) -public: - QMediaPlaylistPrivate() - :mediaObject(0), - control(0), - localPlaylistControl(0), - error(QMediaPlaylist::NoError) - { - } - - virtual ~QMediaPlaylistPrivate() {} - - void _q_loadFailed(QMediaPlaylist::Error error, const QString &errorString) - { - this->error = error; - this->errorString = errorString; - - emit q_ptr->loadFailed(); - } - - void _q_mediaObjectDeleted() - { - Q_Q(QMediaPlaylist); - mediaObject = 0; - if (control != localPlaylistControl) - control = 0; - q->setMediaObject(0); - } - - QMediaObject *mediaObject; - - QMediaPlaylistControl *control; - QMediaPlaylistProvider *playlist() const { return control->playlistProvider(); } - - QMediaPlaylistControl *localPlaylistControl; - - bool readItems(QMediaPlaylistReader *reader); - bool writeItems(QMediaPlaylistWriter *writer); - - QMediaPlaylist::Error error; - QString errorString; - - QMediaPlaylist *q_ptr; -}; - - -class QLocalMediaPlaylistControl : public QMediaPlaylistControl -{ - Q_OBJECT -public: - QLocalMediaPlaylistControl(QObject *parent) - :QMediaPlaylistControl(parent) - { - QMediaPlaylistProvider *playlist = new QLocalMediaPlaylistProvider(this); - m_navigator = new QMediaPlaylistNavigator(playlist,this); - m_navigator->setPlaybackMode(QMediaPlaylist::Linear); - - connect(m_navigator, SIGNAL(currentIndexChanged(int)), SIGNAL(currentIndexChanged(int))); - connect(m_navigator, SIGNAL(activated(QMediaContent)), SIGNAL(currentMediaChanged(QMediaContent))); - } - - virtual ~QLocalMediaPlaylistControl() {}; - - QMediaPlaylistProvider* playlistProvider() const { return m_navigator->playlist(); } - bool setPlaylistProvider(QMediaPlaylistProvider *mediaPlaylist) - { - m_navigator->setPlaylist(mediaPlaylist); - emit playlistProviderChanged(); - return true; - } - - int currentIndex() const { return m_navigator->currentIndex(); } - void setCurrentIndex(int position) { m_navigator->jump(position); } - int nextIndex(int steps) const { return m_navigator->nextIndex(steps); } - int previousIndex(int steps) const { return m_navigator->previousIndex(steps); } - - void next() { m_navigator->next(); } - void previous() { m_navigator->previous(); } - - QMediaPlaylist::PlaybackMode playbackMode() const { return m_navigator->playbackMode(); } - void setPlaybackMode(QMediaPlaylist::PlaybackMode mode) { m_navigator->setPlaybackMode(mode); } - -private: - QMediaPlaylistNavigator *m_navigator; -}; - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLAYLIST_P_H diff --git a/src/multimedia/mediaservices/base/qmediaplaylistcontrol.cpp b/src/multimedia/mediaservices/base/qmediaplaylistcontrol.cpp deleted file mode 100644 index 016c55d..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistcontrol.cpp +++ /dev/null @@ -1,204 +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 QtMediaServices module 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 <QtMediaServices/qmediaplaylistcontrol.h> -#include "qmediacontrol_p.h" - - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaPlaylistControl - \ingroup multimedia-serv - \since 4.7 - - \preliminary - \brief The QMediaPlaylistControl class provides access to the playlist functionality of a - QMediaService. - - If a QMediaService contains an internal playlist it will implement QMediaPlaylistControl. This - control provides access to the contents of the \l {playlistProvider()}{playlist}, as well as the - \l {currentIndex()}{position} of the current media, and a means of navigating to the - \l {next()}{next} and \l {previous()}{previous} media. - - The functionality provided by the control is exposed to application code through the - QMediaPlaylist class. - - The interface name of QMediaPlaylistControl is \c com.nokia.Qt.QMediaPlaylistControl/1.0 as - defined in QMediaPlaylistControl_iid. - - \sa QMediaService::control(), QMediaPlayer -*/ - -/*! - \macro QMediaPlaylistControl_iid - - \c com.nokia.Qt.QMediaPlaylistControl/1.0 - - Defines the interface name of the QMediaPlaylistControl class. - - \relates QMediaPlaylistControl -*/ - -/*! - Create a new playlist control object with the given \a parent. -*/ -QMediaPlaylistControl::QMediaPlaylistControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destroys the playlist control. -*/ -QMediaPlaylistControl::~QMediaPlaylistControl() -{ -} - - -/*! - \fn QMediaPlaylistControl::playlistProvider() const - - Returns the playlist used by this media player. -*/ - -/*! - \fn QMediaPlaylistControl::setPlaylistProvider(QMediaPlaylistProvider *playlist) - - Set the playlist of this media player to \a playlist. - - In many cases it is possible just to use the playlist - constructed by player, but sometimes replacing the whole - playlist allows to avoid copyting of all the items bettween playlists. - - Returns true if player can use this passed playlist; otherwise returns false. - -*/ - -/*! - \fn QMediaPlaylistControl::currentIndex() const - - Returns position of the current media source in the playlist. -*/ - -/*! - \fn QMediaPlaylistControl::setCurrentIndex(int position) - - Jump to the item at the given \a position. -*/ - -/*! - \fn QMediaPlaylistControl::nextIndex(int step) const - - Returns the index of item, which were current after calling next() - \a step times. - - Returned value depends on the size of playlist, current position - and playback mode. - - \sa QMediaPlaylist::playbackMode -*/ - -/*! - \fn QMediaPlaylistControl::previousIndex(int step) const - - Returns the index of item, which were current after calling previous() - \a step times. - - \sa QMediaPlaylist::playbackMode -*/ - -/*! - \fn QMediaPlaylistControl::next() - - Moves to the next item in playlist. -*/ - -/*! - \fn QMediaPlaylistControl::previous() - - Returns to the previous item in playlist. -*/ - -/*! - \fn QMediaPlaylistControl::playbackMode() const - - Returns the playlist navigation mode. - - \sa QMediaPlaylist::PlaybackMode -*/ - -/*! - \fn QMediaPlaylistControl::setPlaybackMode(QMediaPlaylist::PlaybackMode mode) - - Sets the playback \a mode. - - \sa QMediaPlaylist::PlaybackMode -*/ - -/*! - \fn QMediaPlaylistControl::playlistProviderChanged() - - Signal emited when the playlist provider has changed. -*/ - -/*! - \fn QMediaPlaylistControl::currentIndexChanged(int position) - - Signal emited when the playlist \a position is changed. -*/ - -/*! - \fn QMediaPlaylistControl::playbackModeChanged(QMediaPlaylist::PlaybackMode mode) - - Signal emited when the playback \a mode is changed. -*/ - -/*! - \fn QMediaPlaylistControl::currentMediaChanged(const QMediaContent& content) - - Signal emitted when current media changes to \a content. -*/ - -#include "moc_qmediaplaylistcontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediaplaylistcontrol.h b/src/multimedia/mediaservices/base/qmediaplaylistcontrol.h deleted file mode 100644 index 2dc4575..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistcontrol.h +++ /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 QtMediaServices module 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 QMEDIAPLAYLISTCONTROL_H -#define QMEDIAPLAYLISTCONTROL_H - -#include <QtMediaServices/qmediacontrol.h> -#include <QtMediaServices/qmediaplaylistnavigator.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylistProvider; - -class Q_MEDIASERVICES_EXPORT QMediaPlaylistControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QMediaPlaylistControl(); - - virtual QMediaPlaylistProvider* playlistProvider() const = 0; - virtual bool setPlaylistProvider(QMediaPlaylistProvider *playlist) = 0; - - virtual int currentIndex() const = 0; - virtual void setCurrentIndex(int position) = 0; - virtual int nextIndex(int steps) const = 0; - virtual int previousIndex(int steps) const = 0; - - virtual void next() = 0; - virtual void previous() = 0; - - virtual QMediaPlaylist::PlaybackMode playbackMode() const = 0; - virtual void setPlaybackMode(QMediaPlaylist::PlaybackMode mode) = 0; - -Q_SIGNALS: - void playlistProviderChanged(); - void currentIndexChanged(int position); - void currentMediaChanged(const QMediaContent&); - void playbackModeChanged(QMediaPlaylist::PlaybackMode mode); - -protected: - QMediaPlaylistControl(QObject* parent = 0); -}; - -#define QMediaPlaylistControl_iid "com.nokia.Qt.QMediaPlaylistControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMediaPlaylistControl, QMediaPlaylistControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLAYLISTCONTROL_H diff --git a/src/multimedia/mediaservices/base/qmediaplaylistioplugin.cpp b/src/multimedia/mediaservices/base/qmediaplaylistioplugin.cpp deleted file mode 100644 index 60e80e5..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistioplugin.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 QtMediaServices module 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 <QtMediaServices/qmediaplaylistioplugin.h> - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaPlaylistReader - \preliminary - \since 4.7 - \brief The QMediaPlaylistReader class provides an interface for reading a playlist file. - - \sa QMediaPlaylistIOPlugin -*/ - -/*! - Destroys a media playlist reader. -*/ -QMediaPlaylistReader::~QMediaPlaylistReader() -{ -} - -/*! - \fn QMediaPlaylistReader::atEnd() const - - Identifies if a playlist reader has reached the end of its input. - - Returns true if the reader has reached the end; and false otherwise. -*/ - -/*! - \fn QMediaPlaylistReader::readItem() - - Reads an item of media from a playlist file. - - Returns the read media, or a null QMediaContent if no more media is available. -*/ - -/*! - \fn QMediaPlaylistReader::close() - - Closes a playlist reader's input device. -*/ - -/*! - \class QMediaPlaylistWriter - \preliminary - \since 4.7 - \brief The QMediaPlaylistWriter class provides an interface for writing a playlist file. - - \sa QMediaPlaylistIOPlugin -*/ - -/*! - Destroys a media playlist writer. -*/ -QMediaPlaylistWriter::~QMediaPlaylistWriter() -{ -} - -/*! - \fn QMediaPlaylistWriter::writeItem(const QMediaContent &media) - - Writes an item of \a media to a playlist file. - - Returns true if the media was written succesfully; and false otherwise. -*/ - -/*! - \fn QMediaPlaylistWriter::close() - - Finalizes the writing of a playlist and closes the output device. -*/ - -/*! - \class QMediaPlaylistIOPlugin - \since 4.7 - \brief The QMediaPlaylistIOPlugin class provides an interface for media playlist I/O plug-ins. -*/ - -/*! - Constructs a media playlist I/O plug-in with the given \a parent. -*/ -QMediaPlaylistIOPlugin::QMediaPlaylistIOPlugin(QObject *parent) - :QObject(parent) -{ -} - -/*! - Destroys a media playlist I/O plug-in. -*/ -QMediaPlaylistIOPlugin::~QMediaPlaylistIOPlugin() -{ -} - -/*! - \fn QMediaPlaylistIOPlugin::canRead(QIODevice *device, const QByteArray &format) const - - Identifies if plug-in can read \a format data from an I/O \a device. - - Returns true if the data can be read; and false otherwise. -*/ - -/*! - \fn QMediaPlaylistIOPlugin::canRead(const QUrl& location, const QByteArray &format) const - - Identifies if a plug-in can read \a format data from a URL \a location. - - Returns true if the data can be read; and false otherwise. -*/ - -/*! - \fn QMediaPlaylistIOPlugin::canWrite(QIODevice *device, const QByteArray &format) const - - Identifies if a plug-in can write \a format data to an I/O \a device. - - Returns true if the data can be written; and false otherwise. -*/ - -/*! - \fn QMediaPlaylistIOPlugin::keys() const - - Returns a list of format keys supported by a plug-in. -*/ - -/*! - \fn QMediaPlaylistIOPlugin::createReader(QIODevice *device, const QByteArray &format) - - Returns a new QMediaPlaylistReader which reads \a format data from an I/O \a device. - - If the device is invalid or the format is unsupported this will return a null pointer. -*/ - -/*! - \fn QMediaPlaylistIOPlugin::createReader(const QUrl& location, const QByteArray &format) - - Returns a new QMediaPlaylistReader which reads \a format data from a URL \a location. - - If the location or the format is unsupported this will return a null pointer. -*/ - -/*! - \fn QMediaPlaylistIOPlugin::createWriter(QIODevice *device, const QByteArray &format) - - Returns a new QMediaPlaylistWriter which writes \a format data to an I/O \a device. - - If the device is invalid or the format is unsupported this will return a null pointer. -*/ - -QT_END_NAMESPACE - -#include "moc_qmediaplaylistioplugin.cpp" - diff --git a/src/multimedia/mediaservices/base/qmediaplaylistioplugin.h b/src/multimedia/mediaservices/base/qmediaplaylistioplugin.h deleted file mode 100644 index ed8e832..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistioplugin.h +++ /dev/null @@ -1,126 +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 QtMediaServices module 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 QMEDIAPLAYLISTIOPLUGIN_H -#define QMEDIAPLAYLISTIOPLUGIN_H - -#include <QtCore/qobject.h> -#include <QtCore/qplugin.h> -#include <QtCore/qfactoryinterface.h> - -#include <QtMediaServices/qmediacontent.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QString; -class QUrl; -class QByteArray; -class QIODevice; -class QStringList; - -class Q_MEDIASERVICES_EXPORT QMediaPlaylistReader -{ -public: - virtual ~QMediaPlaylistReader(); - - virtual bool atEnd() const = 0; - virtual QMediaContent readItem() = 0; - virtual void close() = 0; -}; - -class Q_MEDIASERVICES_EXPORT QMediaPlaylistWriter -{ -public: - virtual ~QMediaPlaylistWriter(); - - virtual bool writeItem(const QMediaContent &content) = 0; - virtual void close() = 0; -}; - -struct Q_MEDIASERVICES_EXPORT QMediaPlaylistIOInterface : public QFactoryInterface -{ - virtual bool canRead(QIODevice *device, const QByteArray &format = QByteArray() ) const = 0; - virtual bool canRead(const QUrl& location, const QByteArray &format = QByteArray()) const = 0; - - virtual bool canWrite(QIODevice *device, const QByteArray &format) const = 0; - - virtual QMediaPlaylistReader *createReader(QIODevice *device, const QByteArray &format = QByteArray()) = 0; - virtual QMediaPlaylistReader *createReader(const QUrl& location, const QByteArray &format = QByteArray()) = 0; - - virtual QMediaPlaylistWriter *createWriter(QIODevice *device, const QByteArray &format) = 0; -}; - -#define QMediaPlaylistIOInterface_iid "com.nokia.Qt.QMediaPlaylistIOInterface" -Q_DECLARE_INTERFACE(QMediaPlaylistIOInterface, QMediaPlaylistIOInterface_iid); - -class Q_MEDIASERVICES_EXPORT QMediaPlaylistIOPlugin : public QObject, public QMediaPlaylistIOInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaPlaylistIOInterface:QFactoryInterface) - -public: - explicit QMediaPlaylistIOPlugin(QObject *parent = 0); - virtual ~QMediaPlaylistIOPlugin(); - - virtual bool canRead(QIODevice *device, const QByteArray &format = QByteArray() ) const = 0; - virtual bool canRead(const QUrl& location, const QByteArray &format = QByteArray()) const = 0; - - virtual bool canWrite(QIODevice *device, const QByteArray &format) const = 0; - - virtual QStringList keys() const = 0; - - virtual QMediaPlaylistReader *createReader(QIODevice *device, const QByteArray &format = QByteArray()) = 0; - virtual QMediaPlaylistReader *createReader(const QUrl& location, const QByteArray &format = QByteArray()) = 0; - - virtual QMediaPlaylistWriter *createWriter(QIODevice *device, const QByteArray &format) = 0; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLAYLISTIOPLUGIN_H diff --git a/src/multimedia/mediaservices/base/qmediaplaylistnavigator.cpp b/src/multimedia/mediaservices/base/qmediaplaylistnavigator.cpp deleted file mode 100644 index e3eec5e..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistnavigator.cpp +++ /dev/null @@ -1,545 +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 QtMediaServices module 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 <QtMediaServices/qmediaplaylistnavigator.h> -#include <QtMediaServices/qmediaplaylistprovider.h> -#include <QtMediaServices/qmediaplaylist.h> -#include "qmediaobject_p.h" - -#include <QtCore/qdebug.h> - -QT_BEGIN_NAMESPACE - -class QMediaPlaylistNullProvider : public QMediaPlaylistProvider -{ -public: - QMediaPlaylistNullProvider() :QMediaPlaylistProvider() {} - virtual ~QMediaPlaylistNullProvider() {} - virtual int mediaCount() const {return 0;} - virtual QMediaContent media(int) const { return QMediaContent(); } -}; - -Q_GLOBAL_STATIC(QMediaPlaylistNullProvider, _q_nullMediaPlaylist) - -class QMediaPlaylistNavigatorPrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QMediaPlaylistNavigator) -public: - QMediaPlaylistNavigatorPrivate() - :playlist(0), - currentPos(-1), - lastValidPos(-1), - playbackMode(QMediaPlaylist::Linear), - randomPositionsOffset(-1) - { - } - - QMediaPlaylistProvider *playlist; - int currentPos; - int lastValidPos; //to be used with CurrentItemOnce playback mode - QMediaPlaylist::PlaybackMode playbackMode; - QMediaContent currentItem; - - mutable QList<int> randomModePositions; - mutable int randomPositionsOffset; - - int nextItemPos(int steps = 1) const; - int previousItemPos(int steps = 1) const; - - void _q_mediaInserted(int start, int end); - void _q_mediaRemoved(int start, int end); - void _q_mediaChanged(int start, int end); - - QMediaPlaylistNavigator *q_ptr; -}; - - -int QMediaPlaylistNavigatorPrivate::nextItemPos(int steps) const -{ - if (playlist->mediaCount() == 0) - return -1; - - if (steps == 0) - return currentPos; - - switch (playbackMode) { - case QMediaPlaylist::CurrentItemOnce: - return /*currentPos == -1 ? lastValidPos :*/ -1; - case QMediaPlaylist::CurrentItemInLoop: - return currentPos; - case QMediaPlaylist::Linear: - { - int nextPos = currentPos+steps; - return nextPos < playlist->mediaCount() ? nextPos : -1; - } - case QMediaPlaylist::Loop: - return (currentPos+steps) % playlist->mediaCount(); - case QMediaPlaylist::Random: - { - //TODO: limit the history size - - if (randomPositionsOffset == -1) { - randomModePositions.clear(); - randomModePositions.append(currentPos); - randomPositionsOffset = 0; - } - - while (randomModePositions.size() < randomPositionsOffset+steps+1) - randomModePositions.append(-1); - int res = randomModePositions[randomPositionsOffset+steps]; - if (res<0 || res >= playlist->mediaCount()) { - res = qrand() % playlist->mediaCount(); - randomModePositions[randomPositionsOffset+steps] = res; - } - - return res; - } - } - - return -1; -} - -int QMediaPlaylistNavigatorPrivate::previousItemPos(int steps) const -{ - if (playlist->mediaCount() == 0) - return -1; - - if (steps == 0) - return currentPos; - - switch (playbackMode) { - case QMediaPlaylist::CurrentItemOnce: - return /*currentPos == -1 ? lastValidPos :*/ -1; - case QMediaPlaylist::CurrentItemInLoop: - return currentPos; - case QMediaPlaylist::Linear: - { - int prevPos = currentPos == -1 ? playlist->mediaCount() - steps : currentPos - steps; - return prevPos>=0 ? prevPos : -1; - } - case QMediaPlaylist::Loop: - { - int prevPos = currentPos - steps; - while (prevPos<0) - prevPos += playlist->mediaCount(); - return prevPos; - } - case QMediaPlaylist::Random: - { - //TODO: limit the history size - - if (randomPositionsOffset == -1) { - randomModePositions.clear(); - randomModePositions.append(currentPos); - randomPositionsOffset = 0; - } - - while (randomPositionsOffset-steps < 0) { - randomModePositions.prepend(-1); - randomPositionsOffset++; - } - - int res = randomModePositions[randomPositionsOffset-steps]; - if (res<0 || res >= playlist->mediaCount()) { - res = qrand() % playlist->mediaCount(); - randomModePositions[randomPositionsOffset-steps] = res; - } - - return res; - } - } - - return -1; -} - -/*! - \class QMediaPlaylistNavigator - \preliminary - \since 4.7 - \brief The QMediaPlaylistNavigator class provides navigation for a media playlist. - - \sa QMediaPlaylist, QMediaPlaylistProvider -*/ - - -/*! - Constructs a media playlist navigator for a \a playlist. - - The \a parent is passed to QObject. - */ -QMediaPlaylistNavigator::QMediaPlaylistNavigator(QMediaPlaylistProvider *playlist, QObject *parent) - : QObject(parent) - , d_ptr(new QMediaPlaylistNavigatorPrivate) -{ - d_ptr->q_ptr = this; - - setPlaylist(playlist ? playlist : _q_nullMediaPlaylist()); -} - -/*! - Destroys a media playlist navigator. - */ - -QMediaPlaylistNavigator::~QMediaPlaylistNavigator() -{ - delete d_ptr; -} - - -/*! \property QMediaPlaylistNavigator::playbackMode - Contains the playback mode. - */ -QMediaPlaylist::PlaybackMode QMediaPlaylistNavigator::playbackMode() const -{ - return d_func()->playbackMode; -} - -/*! - Sets the playback \a mode. - */ -void QMediaPlaylistNavigator::setPlaybackMode(QMediaPlaylist::PlaybackMode mode) -{ - Q_D(QMediaPlaylistNavigator); - if (d->playbackMode == mode) - return; - - if (mode == QMediaPlaylist::Random) { - d->randomPositionsOffset = 0; - d->randomModePositions.append(d->currentPos); - } else if (d->playbackMode == QMediaPlaylist::Random) { - d->randomPositionsOffset = -1; - d->randomModePositions.clear(); - } - - d->playbackMode = mode; - - emit playbackModeChanged(mode); - emit surroundingItemsChanged(); -} - -/*! - Returns the playlist being navigated. -*/ - -QMediaPlaylistProvider *QMediaPlaylistNavigator::playlist() const -{ - return d_func()->playlist; -} - -/*! - Sets the \a playlist to navigate. -*/ -void QMediaPlaylistNavigator::setPlaylist(QMediaPlaylistProvider *playlist) -{ - Q_D(QMediaPlaylistNavigator); - - if (d->playlist == playlist) - return; - - if (d->playlist) { - d->playlist->disconnect(this); - } - - if (playlist) { - d->playlist = playlist; - } else { - //assign to shared readonly null playlist - d->playlist = _q_nullMediaPlaylist(); - } - - connect(d->playlist, SIGNAL(mediaInserted(int,int)), SLOT(_q_mediaInserted(int,int))); - connect(d->playlist, SIGNAL(mediaRemoved(int,int)), SLOT(_q_mediaRemoved(int,int))); - connect(d->playlist, SIGNAL(mediaChanged(int,int)), SLOT(_q_mediaChanged(int,int))); - - d->randomPositionsOffset = -1; - d->randomModePositions.clear(); - - if (d->currentPos != -1) { - d->currentPos = -1; - emit currentIndexChanged(-1); - } - - if (!d->currentItem.isNull()) { - d->currentItem = QMediaContent(); - emit activated(d->currentItem); //stop playback - } -} - -/*! \property QMediaPlaylistNavigator::currentItem - - Contains the media at the current position in the playlist. - - \sa currentIndex() -*/ - -QMediaContent QMediaPlaylistNavigator::currentItem() const -{ - return itemAt(d_func()->currentPos); -} - -/*! \fn QMediaContent QMediaPlaylistNavigator::nextItem(int steps) const - - Returns the media that is \a steps positions ahead of the current - position in the playlist. - - \sa nextIndex() -*/ -QMediaContent QMediaPlaylistNavigator::nextItem(int steps) const -{ - return itemAt(nextIndex(steps)); -} - -/*! - Returns the media that is \a steps positions behind the current - position in the playlist. - - \sa previousIndex() - */ -QMediaContent QMediaPlaylistNavigator::previousItem(int steps) const -{ - return itemAt(previousIndex(steps)); -} - -/*! - Returns the media at a \a position in the playlist. - */ -QMediaContent QMediaPlaylistNavigator::itemAt(int position) const -{ - return d_func()->playlist->media(position); -} - -/*! \property QMediaPlaylistNavigator::currentIndex - - Contains the position of the current media. - - If no media is current, the property contains -1. - - \sa nextIndex(), previousIndex() -*/ - -int QMediaPlaylistNavigator::currentIndex() const -{ - return d_func()->currentPos; -} - -/*! - Returns a position \a steps ahead of the current position - accounting for the playbackMode(). - - If the position is beyond the end of the playlist, this value - returned is -1. - - \sa currentIndex(), previousIndex(), playbackMode() -*/ - -int QMediaPlaylistNavigator::nextIndex(int steps) const -{ - return d_func()->nextItemPos(steps); -} - -/*! - - Returns a position \a steps behind the current position accounting - for the playbackMode(). - - If the position is prior to the beginning of the playlist this will - return -1. - - \sa currentIndex(), nextIndex(), playbackMode() -*/ -int QMediaPlaylistNavigator::previousIndex(int steps) const -{ - return d_func()->previousItemPos(steps); -} - -/*! - Advances to the next item in the playlist. - - \sa previous(), jump(), playbackMode() - */ -void QMediaPlaylistNavigator::next() -{ - Q_D(QMediaPlaylistNavigator); - - int nextPos = d->nextItemPos(); - - if ( playbackMode() == QMediaPlaylist::Random ) - d->randomPositionsOffset++; - - jump(nextPos); -} - -/*! - Returns to the previous item in the playlist, - - \sa next(), jump(), playbackMode() - */ -void QMediaPlaylistNavigator::previous() -{ - Q_D(QMediaPlaylistNavigator); - - int prevPos = d->previousItemPos(); - if ( playbackMode() == QMediaPlaylist::Random ) - d->randomPositionsOffset--; - - jump(prevPos); -} - -/*! - Jumps to a new \a position in the playlist. - */ -void QMediaPlaylistNavigator::jump(int position) -{ - Q_D(QMediaPlaylistNavigator); - - if (position<-1 || position>=d->playlist->mediaCount()) { - qWarning() << "QMediaPlaylistNavigator: Jump outside playlist range"; - position = -1; - } - - if (position != -1) - d->lastValidPos = position; - - if (playbackMode() == QMediaPlaylist::Random) { - if (d->randomModePositions[d->randomPositionsOffset] != position) { - d->randomModePositions.clear(); - d->randomModePositions.append(position); - d->randomPositionsOffset = 0; - } - } - - if (position != -1) - d->currentItem = d->playlist->media(position); - else - d->currentItem = QMediaContent(); - - if (position != d->currentPos) { - d->currentPos = position; - emit currentIndexChanged(d->currentPos); - emit surroundingItemsChanged(); - } - - emit activated(d->currentItem); -} - -/*! - \internal -*/ -void QMediaPlaylistNavigatorPrivate::_q_mediaInserted(int start, int end) -{ - Q_Q(QMediaPlaylistNavigator); - - if (currentPos >= start) { - currentPos = end-start+1; - q->jump(currentPos); - } - - //TODO: check if they really changed - emit q->surroundingItemsChanged(); -} - -/*! - \internal -*/ -void QMediaPlaylistNavigatorPrivate::_q_mediaRemoved(int start, int end) -{ - Q_Q(QMediaPlaylistNavigator); - - if (currentPos > end) { - currentPos = currentPos - end-start+1; - q->jump(currentPos); - } else if (currentPos >= start) { - //current item was removed - currentPos = qMin(start, playlist->mediaCount()-1); - q->jump(currentPos); - } - - //TODO: check if they really changed - emit q->surroundingItemsChanged(); -} - -/*! - \internal -*/ -void QMediaPlaylistNavigatorPrivate::_q_mediaChanged(int start, int end) -{ - Q_Q(QMediaPlaylistNavigator); - - if (currentPos >= start && currentPos<=end) { - QMediaContent src = playlist->media(currentPos); - if (src != currentItem) { - currentItem = src; - emit q->activated(src); - } - } - - //TODO: check if they really changed - emit q->surroundingItemsChanged(); -} - -/*! - \fn QMediaPlaylistNavigator::activated(const QMediaContent &media) - - Signals that the current \a media has changed. -*/ - -/*! - \fn QMediaPlaylistNavigator::currentIndexChanged(int position) - - Signals the \a position of the current media has changed. -*/ - -/*! - \fn QMediaPlaylistNavigator::playbackModeChanged(QMediaPlaylist::PlaybackMode mode) - - Signals that the playback \a mode has changed. -*/ - -/*! - \fn QMediaPlaylistNavigator::surroundingItemsChanged() - - Signals that media immediately surrounding the current position has changed. -*/ - -#include "moc_qmediaplaylistnavigator.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediaplaylistnavigator.h b/src/multimedia/mediaservices/base/qmediaplaylistnavigator.h deleted file mode 100644 index 42c76f9..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistnavigator.h +++ /dev/null @@ -1,116 +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 QtMediaServices module 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 QMEDIAPLAYLISTNAVIGATOR_H -#define QMEDIAPLAYLISTNAVIGATOR_H - -#include <QtCore/qobject.h> - -#include <QtMediaServices/qmediaplaylistprovider.h> -#include <QtMediaServices/qmediaplaylist.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylistNavigatorPrivate; -class Q_MEDIASERVICES_EXPORT QMediaPlaylistNavigator : public QObject -{ - Q_OBJECT - Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode NOTIFY playbackModeChanged) - Q_PROPERTY(int currentIndex READ currentIndex WRITE jump NOTIFY currentIndexChanged) - Q_PROPERTY(QMediaContent currentItem READ currentItem NOTIFY currentItemChanged) - -public: - QMediaPlaylistNavigator(QMediaPlaylistProvider *playlist, QObject *parent = 0); - virtual ~QMediaPlaylistNavigator(); - - QMediaPlaylistProvider *playlist() const; - void setPlaylist(QMediaPlaylistProvider *playlist); - - QMediaPlaylist::PlaybackMode playbackMode() const; - - QMediaContent currentItem() const; - QMediaContent nextItem(int steps = 1) const; - QMediaContent previousItem(int steps = 1) const; - - QMediaContent itemAt(int position) const; - - int currentIndex() const; - int nextIndex(int steps = 1) const; - int previousIndex(int steps = 1) const; - -public Q_SLOTS: - void next(); - void previous(); - - void jump(int); - - void setPlaybackMode(QMediaPlaylist::PlaybackMode mode); - -Q_SIGNALS: - void activated(const QMediaContent &content); - void currentIndexChanged(int); - void playbackModeChanged(QMediaPlaylist::PlaybackMode mode); - - void surroundingItemsChanged(); - -protected: - QMediaPlaylistNavigatorPrivate *d_ptr; - -private: - Q_DISABLE_COPY(QMediaPlaylistNavigator) - Q_DECLARE_PRIVATE(QMediaPlaylistNavigator) - - Q_PRIVATE_SLOT(d_func(), void _q_mediaInserted(int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_mediaRemoved(int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_mediaChanged(int start, int end)) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLAYLISTNAVIGATOR_H diff --git a/src/multimedia/mediaservices/base/qmediaplaylistprovider.cpp b/src/multimedia/mediaservices/base/qmediaplaylistprovider.cpp deleted file mode 100644 index 3cd766b..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistprovider.cpp +++ /dev/null @@ -1,308 +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 QtMediaServices module 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/qurl.h> - -#include <QtMediaServices/qmediaplaylistprovider.h> -#include "qmediaplaylistprovider_p.h" - - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaPlaylistProvider - \preliminary - \since 4.7 - \brief The QMediaPlaylistProvider class provides an abstract list of media. - - \sa QMediaPlaylist -*/ - -/*! - Constructs a playlist provider with the given \a parent. -*/ -QMediaPlaylistProvider::QMediaPlaylistProvider(QObject *parent) - :QObject(parent), d_ptr(new QMediaPlaylistProviderPrivate) -{ -} - -/*! - \internal -*/ -QMediaPlaylistProvider::QMediaPlaylistProvider(QMediaPlaylistProviderPrivate &dd, QObject *parent) - :QObject(parent), d_ptr(&dd) -{ -} - -/*! - Destroys a playlist provider. -*/ -QMediaPlaylistProvider::~QMediaPlaylistProvider() -{ - delete d_ptr; -} - -/*! - \fn QMediaPlaylistProvider::mediaCount() const; - - Returns the size of playlist. -*/ - -/*! - \fn QMediaPlaylistProvider::media(int index) const; - - Returns the media at \a index in the playlist. - - If the index is invalid this will return a null media content. -*/ - - -/*! - Loads a playlist from from a URL \a location. If no playlist \a format is specified the loader - will inspect the URL or probe the headers to guess the format. - - New items are appended to playlist. - - Returns true if the provider supports the format and loading from the locations URL protocol, - otherwise this will return false. -*/ -bool QMediaPlaylistProvider::load(const QUrl &location, const char *format) -{ - Q_UNUSED(location); - Q_UNUSED(format); - return false; -} - -/*! - Loads a playlist from from an I/O \a device. If no playlist \a format is specified the loader - will probe the headers to guess the format. - - New items are appended to playlist. - - Returns true if the provider supports the format and loading from an I/O device, otherwise this - will return false. -*/ -bool QMediaPlaylistProvider::load(QIODevice * device, const char *format) -{ - Q_UNUSED(device); - Q_UNUSED(format); - return false; -} - -/*! - Saves the contents of a playlist to a URL \a location. If no playlist \a format is specified - the writer will inspect the URL to guess the format. - - Returns true if the playlist was saved succesfully; and false otherwise. - */ -bool QMediaPlaylistProvider::save(const QUrl &location, const char *format) -{ - Q_UNUSED(location); - Q_UNUSED(format); - return false; -} - -/*! - Saves the contents of a playlist to an I/O \a device in the specified \a format. - - Returns true if the playlist was saved succesfully; and false otherwise. -*/ -bool QMediaPlaylistProvider::save(QIODevice * device, const char *format) -{ - Q_UNUSED(device); - Q_UNUSED(format); - return false; -} - -/*! - Returns true if a playlist is read-only; otherwise returns false. -*/ -bool QMediaPlaylistProvider::isReadOnly() const -{ - return true; -} - -/*! - Append \a media to a playlist. - - Returns true if the media was appended; and false otherwise. -*/ -bool QMediaPlaylistProvider::addMedia(const QMediaContent &media) -{ - Q_UNUSED(media); - return false; -} - -/*! - Append multiple media \a items to a playlist. - - Returns true if the media items were appended; and false otherwise. -*/ -bool QMediaPlaylistProvider::addMedia(const QList<QMediaContent> &items) -{ - foreach(const QMediaContent &item, items) { - if (!addMedia(item)) - return false; - } - - return true; -} - -/*! - Inserts \a media into a playlist at \a position. - - Returns true if the media was inserted; and false otherwise. -*/ -bool QMediaPlaylistProvider::insertMedia(int position, const QMediaContent &media) -{ - Q_UNUSED(position); - Q_UNUSED(media); - return false; -} - -/*! - Inserts multiple media \a items into a playlist at \a position. - - Returns true if the media \a items were inserted; and false otherwise. -*/ -bool QMediaPlaylistProvider::insertMedia(int position, const QList<QMediaContent> &items) -{ - for (int i=0; i<items.count(); i++) { - if (!insertMedia(position+i,items.at(i))) - return false; - } - - return true; -} - - -/*! - Removes the media at \a position from a playlist. - - Returns true if the media was removed; and false otherwise. -*/ -bool QMediaPlaylistProvider::removeMedia(int position) -{ - Q_UNUSED(position); - return false; -} - -/*! - Removes the media between the given \a start and \a end positions from a playlist. - - Returns true if the media was removed; and false otherwise. - */ -bool QMediaPlaylistProvider::removeMedia(int start, int end) -{ - for (int pos=start; pos<=end; pos++) { - if (!removeMedia(pos)) - return false; - } - - return true; -} - -/*! - Removes all media from a playlist. - - Returns true if the media was removed; and false otherwise. -*/ -bool QMediaPlaylistProvider::clear() -{ - return removeMedia(0, mediaCount()-1); -} - -/*! - Shuffles the contents of a playlist. -*/ -void QMediaPlaylistProvider::shuffle() -{ -} - -/*! - \fn void QMediaPlaylistProvider::mediaAboutToBeInserted(int start, int end); - - Signals that new media is about to be inserted into a playlist between the \a start and \a end - positions. -*/ - -/*! - \fn void QMediaPlaylistProvider::mediaInserted(int start, int end); - - Signals that new media has been inserted into a playlist between the \a start and \a end - positions. -*/ - -/*! - \fn void QMediaPlaylistProvider::mediaAboutToBeRemoved(int start, int end); - - Signals that media is about to be removed from a playlist between the \a start and \a end - positions. -*/ - -/*! - \fn void QMediaPlaylistProvider::mediaRemoved(int start, int end); - - Signals that media has been removed from a playlist between the \a start and \a end positions. -*/ - -/*! - \fn void QMediaPlaylistProvider::mediaChanged(int start, int end); - - Signals that media in playlist between the \a start and \a end positions inclusive has changed. -*/ - -/*! - \fn void QMediaPlaylistProvider::loaded() - - Signals that a load() finished successfully. -*/ - -/*! - \fn void QMediaPlaylistProvider::loadFailed(QMediaPlaylist::Error error, const QString& errorMessage) - - Signals that a load failed() due to an \a error. The \a errorMessage provides more information. -*/ - -#include "moc_qmediaplaylistprovider.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediaplaylistprovider.h b/src/multimedia/mediaservices/base/qmediaplaylistprovider.h deleted file mode 100644 index c68ed89..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistprovider.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 QtMediaServices module 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 QMEDIAPLAYLISTPROVIDER_H -#define QMEDIAPLAYLISTPROVIDER_H - -#include <QtCore/qobject.h> - -#include <QtMediaServices/qmediacontent.h> -#include <QtMediaServices/qmediaplaylist.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QString; - - -class QMediaPlaylistProviderPrivate; -class Q_MEDIASERVICES_EXPORT QMediaPlaylistProvider : public QObject -{ - Q_OBJECT - -public: - QMediaPlaylistProvider(QObject *parent=0); - virtual ~QMediaPlaylistProvider(); - - virtual bool load(const QUrl &location, const char *format = 0); - virtual bool load(QIODevice * device, const char *format = 0); - virtual bool save(const QUrl &location, const char *format = 0); - virtual bool save(QIODevice * device, const char *format); - - virtual int mediaCount() const = 0; - virtual QMediaContent media(int index) const = 0; - - virtual bool isReadOnly() const; - - virtual bool addMedia(const QMediaContent &content); - virtual bool addMedia(const QList<QMediaContent> &contentList); - virtual bool insertMedia(int index, const QMediaContent &content); - virtual bool insertMedia(int index, const QList<QMediaContent> &content); - virtual bool removeMedia(int pos); - virtual bool removeMedia(int start, int end); - virtual bool clear(); - -public Q_SLOTS: - virtual void shuffle(); - -Q_SIGNALS: - void mediaAboutToBeInserted(int start, int end); - void mediaInserted(int start, int end); - - void mediaAboutToBeRemoved(int start, int end); - void mediaRemoved(int start, int end); - - void mediaChanged(int start, int end); - - void loaded(); - void loadFailed(QMediaPlaylist::Error, const QString& errorMessage); - -protected: - QMediaPlaylistProviderPrivate *d_ptr; - QMediaPlaylistProvider(QMediaPlaylistProviderPrivate &dd, QObject *parent); - -private: - Q_DECLARE_PRIVATE(QMediaPlaylistProvider) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLAYLISTPROVIDER_H diff --git a/src/multimedia/mediaservices/base/qmediaplaylistprovider_p.h b/src/multimedia/mediaservices/base/qmediaplaylistprovider_p.h deleted file mode 100644 index 00d1cca..0000000 --- a/src/multimedia/mediaservices/base/qmediaplaylistprovider_p.h +++ /dev/null @@ -1,75 +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 QtMediaServices module 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 QMEDIAPLAYLISTPROVIDER_P_H -#define QMEDIAPLAYLISTPROVIDER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtMediaServices/qmediaplaylist.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaPlaylistProviderPrivate -{ -public: - QMediaPlaylistProviderPrivate() - {} - virtual ~QMediaPlaylistProviderPrivate() - {} -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLAYLISTSOURCE_P_H diff --git a/src/multimedia/mediaservices/base/qmediapluginloader.cpp b/src/multimedia/mediaservices/base/qmediapluginloader.cpp deleted file mode 100644 index 8b0ddf4..0000000 --- a/src/multimedia/mediaservices/base/qmediapluginloader.cpp +++ /dev/null @@ -1,139 +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 QtMediaServices module 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 "qmediapluginloader_p.h" -#include <QtCore/qcoreapplication.h> -#include <QtCore/qpluginloader.h> -#include <QtCore/qdir.h> -#include <QtCore/qdebug.h> - -#include <QtMediaServices/qmediaserviceproviderplugin.h> - - -QT_BEGIN_NAMESPACE - - -typedef QMap<QString,QObjectList> ObjectListMap; -Q_GLOBAL_STATIC(ObjectListMap, staticMediaPlugins); - -QMediaPluginLoader::QMediaPluginLoader(const char *iid, const QString &location, Qt::CaseSensitivity): - m_iid(iid) -{ - m_location = location + QLatin1String("/"); - load(); -} - -QStringList QMediaPluginLoader::keys() const -{ - return m_instances.keys(); -} - -QObject* QMediaPluginLoader::instance(QString const &key) -{ - return m_instances.value(key); -} - -QList<QObject*> QMediaPluginLoader::instances(QString const &key) -{ - return m_instances.values(key); -} - -//to be used for testing purposes only -void QMediaPluginLoader::setStaticPlugins(const QString &location, const QObjectList& objects) -{ - staticMediaPlugins()->insert(location + QLatin1String("/"), objects); -} - -void QMediaPluginLoader::load() -{ - if (!m_instances.isEmpty()) - return; - - if (staticMediaPlugins() && staticMediaPlugins()->contains(m_location)) { - foreach(QObject *o, staticMediaPlugins()->value(m_location)) { - if (o != 0 && o->qt_metacast(m_iid) != 0) { - QFactoryInterface* p = qobject_cast<QFactoryInterface*>(o); - if (p != 0) { - foreach (QString const &key, p->keys()) - m_instances.insertMulti(key, o); - } - } - } - } else { -#ifndef QT_NO_LIBRARY - QStringList paths = QCoreApplication::libraryPaths(); - - foreach (QString const &path, paths) { - QString pluginPathName(path + m_location); - QDir pluginDir(pluginPathName); - - if (!pluginDir.exists()) - continue; - - foreach (const QString &pluginLib, pluginDir.entryList(QDir::Files)) { -#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) - if (pluginLib.endsWith(QLatin1String(".debug"))) - continue; -#endif - QPluginLoader loader(pluginPathName + pluginLib); - - QObject *o = loader.instance(); - if (o != 0 && o->qt_metacast(m_iid) != 0) { - QFactoryInterface* p = qobject_cast<QFactoryInterface*>(o); - if (p != 0) { - foreach (QString const &key, p->keys()) - m_instances.insertMulti(key, o); - } - - continue; - } else { - qWarning() << "QMediaPluginLoader: Failed to load plugin: " << pluginLib << loader.errorString(); - } - delete o; - loader.unload(); - } - } -#endif - } -} - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediapluginloader_p.h b/src/multimedia/mediaservices/base/qmediapluginloader_p.h deleted file mode 100644 index d911180..0000000 --- a/src/multimedia/mediaservices/base/qmediapluginloader_p.h +++ /dev/null @@ -1,92 +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 QtMediaServices module 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 QMEDIAPLUGINLOADER_H -#define QMEDIAPLUGINLOADER_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qobject.h> -#include <QtCore/qstring.h> -#include <QtCore/qmap.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaServiceProviderPlugin; - -class Q_AUTOTEST_EXPORT QMediaPluginLoader -{ -public: - QMediaPluginLoader(const char *iid, - const QString &suffix = QString(), - Qt::CaseSensitivity = Qt::CaseSensitive); - - QStringList keys() const; - QObject* instance(QString const &key); - QList<QObject*> instances(QString const &key); - - static void setStaticPlugins(const QString &location, const QObjectList& objects); - -private: - void load(); - - QByteArray m_iid; - QString m_location; - QMap<QString, QObject*> m_instances; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLUGINLOADER_H diff --git a/src/multimedia/mediaservices/base/qmediaresource.cpp b/src/multimedia/mediaservices/base/qmediaresource.cpp deleted file mode 100644 index 33bd396..0000000 --- a/src/multimedia/mediaservices/base/qmediaresource.cpp +++ /dev/null @@ -1,399 +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 QtMediaServices module 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/qsize.h> -#include <QtCore/qurl.h> -#include <QtCore/qvariant.h> - -#include <QtMediaServices/qmediaresource.h> - - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaResource - \preliminary - \since 4.7 - \brief The QMediaResource class provides a description of a media resource. - \ingroup multimedia - - A media resource is composed of a \l {url()}{URL} containing the - location of the resource and a set of properties that describe the - format of the resource. The properties provide a means to assess a - resource without first attempting to load it, and in situations where - media be represented by multiple alternative representations provide a - means to select the appropriate resource. - - Media made available by a remote services can often be available in - multiple encodings or quality levels, this allows a client to select - an appropriate resource based on considerations such as codecs supported, - network bandwidth, and display constraints. QMediaResource includes - information such as the \l {mimeType()}{MIME type}, \l {audioCodec()}{audio} - and \l {videoCodec()}{video} codecs, \l {audioBitRate()}{audio} and - \l {videoBitRate()}{video} bit rates, and \l {resolution()}{resolution} - so these constraints and others can be evaluated. - - The only mandatory property of a QMediaResource is the url(). - - \sa QMediaContent -*/ - -/*! - \typedef QMediaResourceList - - Synonym for \c QList<QMediaResource> -*/ - -/*! - Constructs a null media resource. -*/ -QMediaResource::QMediaResource() -{ -} - -/*! - Constructs a media resource with the given \a mimeType from a \a url. -*/ -QMediaResource::QMediaResource(const QUrl &url, const QString &mimeType) -{ - values.insert(Url, url); - values.insert(MimeType, mimeType); -} - -/*! - Constructs a media resource with the given \a mimeType from a network \a request. -*/ -QMediaResource::QMediaResource(const QNetworkRequest &request, const QString &mimeType) -{ - values.insert(Request, QVariant::fromValue(request)); - values.insert(Url, request.url()); - values.insert(MimeType, mimeType); -} - -/*! - Constructs a copy of a media resource \a other. -*/ -QMediaResource::QMediaResource(const QMediaResource &other) - : values(other.values) -{ -} - -/*! - Assigns the value of \a other to a media resource. -*/ -QMediaResource &QMediaResource::operator =(const QMediaResource &other) -{ - values = other.values; - - return *this; -} - -/*! - Destroys a media resource. -*/ -QMediaResource::~QMediaResource() -{ -} - - -/*! - Compares a media resource to \a other. - - Returns true if the resources are identical, and false otherwise. -*/ -bool QMediaResource::operator ==(const QMediaResource &other) const -{ - return values == other.values; -} - -/*! - Compares a media resource to \a other. - - Returns true if they are different, and false otherwise. -*/ -bool QMediaResource::operator !=(const QMediaResource &other) const -{ - return values != other.values; -} - -/*! - Identifies if a media resource is null. - - Returns true if the resource is null, and false otherwise. -*/ -bool QMediaResource::isNull() const -{ - return values.isEmpty(); -} - -/*! - Returns the URL of a media resource. -*/ -QUrl QMediaResource::url() const -{ - return qvariant_cast<QUrl>(values.value(Url)); -} - -/*! - Returns the network request associated with this media resource. -*/ -QNetworkRequest QMediaResource::request() const -{ - if(values.contains(Request)) - return qvariant_cast<QNetworkRequest>(values.value(Request)); - - return QNetworkRequest(url()); -} - -/*! - Returns the MIME type of a media resource. - - This may be null if the MIME type is unknown. -*/ -QString QMediaResource::mimeType() const -{ - return qvariant_cast<QString>(values.value(MimeType)); -} - -/*! - Returns the language of a media resource as an ISO 639-2 code. - - This may be null if the language is unknown. -*/ -QString QMediaResource::language() const -{ - return qvariant_cast<QString>(values.value(Language)); -} - -/*! - Sets the \a language of a media resource. -*/ -void QMediaResource::setLanguage(const QString &language) -{ - if (!language.isNull()) - values.insert(Language, language); - else - values.remove(Language); -} - -/*! - Returns the audio codec of a media resource. - - This may be null if the media resource does not contain an audio stream, or the codec is - unknown. -*/ -QString QMediaResource::audioCodec() const -{ - return qvariant_cast<QString>(values.value(AudioCodec)); -} - -/*! - Sets the audio \a codec of a media resource. -*/ -void QMediaResource::setAudioCodec(const QString &codec) -{ - if (!codec.isNull()) - values.insert(AudioCodec, codec); - else - values.remove(AudioCodec); -} - -/*! - Returns the video codec of a media resource. - - This may be null if the media resource does not contain a video stream, or the codec is - unknonwn. -*/ -QString QMediaResource::videoCodec() const -{ - return qvariant_cast<QString>(values.value(VideoCodec)); -} - -/*! - Sets the video \a codec of media resource. -*/ -void QMediaResource::setVideoCodec(const QString &codec) -{ - if (!codec.isNull()) - values.insert(VideoCodec, codec); - else - values.remove(VideoCodec); -} - -/*! - Returns the size in bytes of a media resource. - - This may be zero if the size is unknown. -*/ -qint64 QMediaResource::dataSize() const -{ - return qvariant_cast<qint64>(values.value(DataSize)); -} - -/*! - Sets the \a size in bytes of a media resource. -*/ -void QMediaResource::setDataSize(const qint64 size) -{ - if (size != 0) - values.insert(DataSize, size); - else - values.remove(DataSize); -} - -/*! - Returns the bit rate in bits per second of a media resource's audio stream. - - This may be zero if the bit rate is unknown, or the resource contains no audio stream. -*/ -int QMediaResource::audioBitRate() const -{ - return values.value(AudioBitRate).toInt(); -} - -/*! - Sets the bit \a rate in bits per second of a media resource's video stream. -*/ -void QMediaResource::setAudioBitRate(int rate) -{ - if (rate != 0) - values.insert(AudioBitRate, rate); - else - values.remove(AudioBitRate); -} - -/*! - Returns the audio sample rate of a media resource. - - This may be zero if the sample size is unknown, or the resource contains no audio stream. -*/ -int QMediaResource::sampleRate() const -{ - return qvariant_cast<int>(values.value(SampleRate)); -} - -/*! - Sets the audio \a sampleRate of a media resource. -*/ -void QMediaResource::setSampleRate(int sampleRate) -{ - if (sampleRate != 0) - values.insert(SampleRate, sampleRate); - else - values.remove(SampleRate); -} - -/*! - Returns the number of audio channels in a media resource. - - This may be zero if the sample size is unknown, or the resource contains no audio stream. -*/ -int QMediaResource::channelCount() const -{ - return qvariant_cast<int>(values.value(ChannelCount)); -} - -/*! - Sets the number of audio \a channels in a media resource. -*/ -void QMediaResource::setChannelCount(int channels) -{ - if (channels != 0) - values.insert(ChannelCount, channels); - else - values.remove(ChannelCount); -} - -/*! - Returns the bit rate in bits per second of a media resource's video stream. - - This may be zero if the bit rate is unknown, or the resource contains no video stream. -*/ -int QMediaResource::videoBitRate() const -{ - return values.value(VideoBitRate).toInt(); -} - -/*! - Sets the bit \a rate in bits per second of a media resource's video stream. -*/ -void QMediaResource::setVideoBitRate(int rate) -{ - if (rate != 0) - values.insert(VideoBitRate, rate); - else - values.remove(VideoBitRate); -} - -/*! - Returns the resolution in pixels of a media resource. - - This may be null is the resolution is unknown, or the resource contains no pixel data (i.e. the - resource is an audio stream. -*/ -QSize QMediaResource::resolution() const -{ - return qvariant_cast<QSize>(values.value(Resolution)); -} - -/*! - Sets the \a resolution in pixels of a media resource. -*/ -void QMediaResource::setResolution(const QSize &resolution) -{ - if (resolution.width() != -1 || resolution.height() != -1) - values.insert(Resolution, resolution); - else - values.remove(Resolution); -} - -/*! - Sets the \a width and \a height in pixels of a media resource. -*/ -void QMediaResource::setResolution(int width, int height) -{ - if (width != -1 || height != -1) - values.insert(Resolution, QSize(width, height)); - else - values.remove(Resolution); -} -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediaresource.h b/src/multimedia/mediaservices/base/qmediaresource.h deleted file mode 100644 index 0ecf008..0000000 --- a/src/multimedia/mediaservices/base/qmediaresource.h +++ /dev/null @@ -1,134 +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 QtMediaServices module 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 QMEDIARESOURCE_H -#define QMEDIARESOURCE_H - -#include <QtCore/qmap.h> -#include <QtCore/qmetatype.h> -#include <QtNetwork/qnetworkrequest.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MEDIASERVICES_EXPORT QMediaResource -{ -public: - QMediaResource(); - QMediaResource(const QUrl &url, const QString &mimeType = QString()); - QMediaResource(const QNetworkRequest &request, const QString &mimeType = QString()); - QMediaResource(const QMediaResource &other); - QMediaResource &operator =(const QMediaResource &other); - ~QMediaResource(); - - bool isNull() const; - - bool operator ==(const QMediaResource &other) const; - bool operator !=(const QMediaResource &other) const; - - QUrl url() const; - QNetworkRequest request() const; - QString mimeType() const; - - QString language() const; - void setLanguage(const QString &language); - - QString audioCodec() const; - void setAudioCodec(const QString &codec); - - QString videoCodec() const; - void setVideoCodec(const QString &codec); - - qint64 dataSize() const; - void setDataSize(const qint64 size); - - int audioBitRate() const; - void setAudioBitRate(int rate); - - int sampleRate() const; - void setSampleRate(int frequency); - - int channelCount() const; - void setChannelCount(int channels); - - int videoBitRate() const; - void setVideoBitRate(int rate); - - QSize resolution() const; - void setResolution(const QSize &resolution); - void setResolution(int width, int height); - - -private: - enum Property - { - Url, - Request, - MimeType, - Language, - AudioCodec, - VideoCodec, - DataSize, - AudioBitRate, - VideoBitRate, - SampleRate, - ChannelCount, - Resolution - }; - QMap<int, QVariant> values; -}; - -typedef QList<QMediaResource> QMediaResourceList; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaResource) -Q_DECLARE_METATYPE(QMediaResourceList) - -QT_END_HEADER - - -#endif diff --git a/src/multimedia/mediaservices/base/qmediaservice.cpp b/src/multimedia/mediaservices/base/qmediaservice.cpp deleted file mode 100644 index b343887..0000000 --- a/src/multimedia/mediaservices/base/qmediaservice.cpp +++ /dev/null @@ -1,140 +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 QtMediaServices module 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/qtimer.h> - -#include <QtMediaServices/qmediaservice.h> -#include "qmediaservice_p.h" - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -/*! - \class QMediaService - \brief The QMediaService class provides a common base class for media - service implementations. - \ingroup multimedia-serv - \preliminary - \since 4.7 - - Media services provide implementations of the functionality promised - by media objects, and allow multiple providers to implement a QMediaObject. - - To provide the functionality of a QMediaObject media services implement - QMediaControl interfaces. Services typically implement one core media - control which provides the core feature of a media object, and some - number of additional controls which provide either optional features of - the media object, or features of a secondary media object or peripheral - object. - - A pointer to media service's QMediaControl implementation can be - obtained by passing the control's interface name to the control() function. - - \code - QMediaPlayerControl *control = qobject_cast<QMediaPlayerControl *>( - service->control("com.nokia.Qt.QMediaPlayerControl/1.0")); - \endcode - - Media objects can use services loaded dynamically from plug-ins or - implemented statically within an applications. Plug-in based services - should also implement the QMediaServiceProviderPlugin interface. Static - services should implement the QMediaServiceProvider interface. - - \sa QMediaObject, QMediaControl, QMediaServiceProvider, QMediaServiceProviderPlugin -*/ - -/*! - Construct a media service with the given \a parent. This class is meant as a - base class for Multimedia services so this constructor is protected. -*/ - -QMediaService::QMediaService(QObject *parent) - : QObject(parent) - , d_ptr(new QMediaServicePrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - \internal -*/ -QMediaService::QMediaService(QMediaServicePrivate &dd, QObject *parent) - : QObject(parent) - , d_ptr(&dd) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys a media service. -*/ - -QMediaService::~QMediaService() -{ - delete d_ptr; -} - -/*! - \fn QMediaService::control(const char *interface) const - - Returns a pointer to the media control implementing \a interface. - - If the service does not implement the control a null pointer is returned instead. -*/ - -/*! - \fn QMediaService::control() const - - Returns a pointer to the media control of type T implemented by a media service. - - If the service does not implment the control a null pointer is returned instead. -*/ - -#include "moc_qmediaservice.cpp" - -QT_END_NAMESPACE - -QT_END_HEADER - diff --git a/src/multimedia/mediaservices/base/qmediaservice.h b/src/multimedia/mediaservices/base/qmediaservice.h deleted file mode 100644 index 5df3fd7..0000000 --- a/src/multimedia/mediaservices/base/qmediaservice.h +++ /dev/null @@ -1,90 +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 QtMediaServices module 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 QABSTRACTMEDIASERVICE_H -#define QABSTRACTMEDIASERVICE_H - -#include <QtCore/qobject.h> -#include <QtCore/qstringlist.h> - -#include <QtMediaServices/qmediacontrol.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMediaServicePrivate; -class Q_MEDIASERVICES_EXPORT QMediaService : public QObject -{ - Q_OBJECT - -public: - ~QMediaService(); - - virtual QMediaControl* control(const char *name) const = 0; - -#ifndef QT_NO_MEMBER_TEMPLATES - template <typename T> inline T control() const { - if (QObject *object = control(qmediacontrol_iid<T>())) { - return qobject_cast<T>(object); - } - return 0; - } -#endif - -protected: - QMediaService(QObject* parent); - QMediaService(QMediaServicePrivate &dd, QObject *parent); - - QMediaServicePrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QMediaService) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QABSTRACTMEDIASERVICE_H - diff --git a/src/multimedia/mediaservices/base/qmediaservice_p.h b/src/multimedia/mediaservices/base/qmediaservice_p.h deleted file mode 100644 index bebae11..0000000 --- a/src/multimedia/mediaservices/base/qmediaservice_p.h +++ /dev/null @@ -1,75 +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 QtMediaServices module 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 QABSTRACTMEDIASERVICE_P_H -#define QABSTRACTMEDIASERVICE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QAudioDeviceControl; - -class QMediaServicePrivate -{ -public: - QMediaServicePrivate(): q_ptr(0) {} - virtual ~QMediaServicePrivate() {} - - QMediaService *q_ptr; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qmediaserviceprovider.cpp b/src/multimedia/mediaservices/base/qmediaserviceprovider.cpp deleted file mode 100644 index f27628b..0000000 --- a/src/multimedia/mediaservices/base/qmediaserviceprovider.cpp +++ /dev/null @@ -1,738 +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 QtMediaServices module 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/qmap.h> - -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmediaserviceprovider.h> -#include <QtMediaServices/qmediaserviceproviderplugin.h> -#include "qmediapluginloader_p.h" -#include <QtMediaServices/qmediaplayer.h> - -QT_BEGIN_NAMESPACE - -class QMediaServiceProviderHintPrivate : public QSharedData -{ -public: - QMediaServiceProviderHintPrivate(QMediaServiceProviderHint::Type type) - :type(type), features(0) - { - } - - QMediaServiceProviderHintPrivate(const QMediaServiceProviderHintPrivate &other) - :QSharedData(other), - type(other.type), - device(other.device), - mimeType(other.mimeType), - codecs(other.codecs), - features(other.features) - { - } - - ~QMediaServiceProviderHintPrivate() - { - } - - QMediaServiceProviderHint::Type type; - QByteArray device; - QString mimeType; - QStringList codecs; - QMediaServiceProviderHint::Features features; -}; - -/*! - \class QMediaServiceProviderHint - \preliminary - \since 4.7 - \brief The QMediaServiceProviderHint class describes what is required of a QMediaService. - - \ingroup multimedia-serv - - The QMediaServiceProvider class uses hints to select an appropriate media service. -*/ - -/*! - \enum QMediaServiceProviderHint::Feature - - Enumerates features a media service may provide. - - \value LowLatencyPlayback - The service is expected to play simple audio formats, - but playback should start without significant delay. - Such playback service can be used for beeps, ringtones, etc. - - \value RecordingSupport - The service provides audio or video recording functions. - - \value StreamPlayback - The service is capable of playing QIODevice based streams. -*/ - -/*! - \enum QMediaServiceProviderHint::Type - - Enumerates the possible types of media service provider hint. - - \value Null En empty hint, use the default service. - \value ContentType Select media service most suitable for certain content type. - \value Device Select media service which supports certain device. - \value SupportedFeatures Select media service supporting the set of optional features. -*/ - - -/*! - Constructs an empty media service provider hint. -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint() - :d(new QMediaServiceProviderHintPrivate(Null)) -{ -} - -/*! - Constructs a ContentType media service provider hint. - - This type of hint describes a service that is able to play content of a specific MIME \a type - encoded with one or more of the listed \a codecs. -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint(const QString &type, const QStringList& codecs) - :d(new QMediaServiceProviderHintPrivate(ContentType)) -{ - d->mimeType = type; - d->codecs = codecs; -} - -/*! - Constructs a Device media service provider hint. - - This type of hint describes a media service that utilizes a specific \a device. -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint(const QByteArray &device) - :d(new QMediaServiceProviderHintPrivate(Device)) -{ - d->device = device; -} - -/*! - Constructs a SupportedFeatures media service provider hint. - - This type of hint describes a service which supports a specific set of \a features. -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint(QMediaServiceProviderHint::Features features) - :d(new QMediaServiceProviderHintPrivate(SupportedFeatures)) -{ - d->features = features; -} - -/*! - Constructs a copy of the media service provider hint \a other. -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint(const QMediaServiceProviderHint &other) - :d(other.d) -{ -} - -/*! - Destroys a media service provider hint. -*/ -QMediaServiceProviderHint::~QMediaServiceProviderHint() -{ -} - -/*! - Assigns the value \a other to a media service provider hint. -*/ -QMediaServiceProviderHint& QMediaServiceProviderHint::operator=(const QMediaServiceProviderHint &other) -{ - d = other.d; - return *this; -} - -/*! - Identifies if \a other is of equal value to a media service provider hint. - - Returns true if the hints are equal, and false if they are not. -*/ -bool QMediaServiceProviderHint::operator == (const QMediaServiceProviderHint &other) const -{ - return (d == other.d) || - (d->type == other.d->type && - d->device == other.d->device && - d->mimeType == other.d->mimeType && - d->codecs == other.d->codecs && - d->features == other.d->features); -} - -/*! - Identifies if \a other is not of equal value to a media service provider hint. - - Returns true if the hints are not equal, and false if they are. -*/ -bool QMediaServiceProviderHint::operator != (const QMediaServiceProviderHint &other) const -{ - return !(*this == other); -} - -/*! - Returns true if a media service provider is null. -*/ -bool QMediaServiceProviderHint::isNull() const -{ - return d->type == Null; -} - -/*! - Returns the type of a media service provider hint. -*/ -QMediaServiceProviderHint::Type QMediaServiceProviderHint::type() const -{ - return d->type; -} - -/*! - Returns the mime type of the media a service is expected to be able play. -*/ -QString QMediaServiceProviderHint::mimeType() const -{ - return d->mimeType; -} - -/*! - Returns a list of codes a media service is expected to be able to decode. -*/ -QStringList QMediaServiceProviderHint::codecs() const -{ - return d->codecs; -} - -/*! - Returns the name of a device a media service is expected to utilize. -*/ -QByteArray QMediaServiceProviderHint::device() const -{ - return d->device; -} - -/*! - Returns a set of features a media service is expected to provide. -*/ -QMediaServiceProviderHint::Features QMediaServiceProviderHint::features() const -{ - return d->features; -} - - -Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, loader, - (QMediaServiceProviderFactoryInterface_iid, QLatin1String("/mediaservices"), Qt::CaseInsensitive)) - - -class QPluginServiceProvider : public QMediaServiceProvider -{ - QMap<QMediaService*, QMediaServiceProviderPlugin*> pluginMap; - -public: - QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &hint) - { - QString key(QString::fromLatin1(type.constData(),type.length())); - - QList<QMediaServiceProviderPlugin *>plugins; - foreach (QObject *obj, loader()->instances(key)) { - QMediaServiceProviderPlugin *plugin = - qobject_cast<QMediaServiceProviderPlugin*>(obj); - if (plugin) - plugins << plugin; - } - - if (!plugins.isEmpty()) { - QMediaServiceProviderPlugin *plugin = 0; - - switch (hint.type()) { - case QMediaServiceProviderHint::Null: - plugin = plugins[0]; - //special case for media player, if low latency was not asked, - //prefer services not offering it, since they are likely to support - //more formats - if (type == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)) { - foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { - QMediaServiceFeaturesInterface *iface = - qobject_cast<QMediaServiceFeaturesInterface*>(currentPlugin); - - if (!iface || !(iface->supportedFeatures(type) & - QMediaServiceProviderHint::LowLatencyPlayback)) { - plugin = currentPlugin; - break; - } - - } - } - break; - case QMediaServiceProviderHint::SupportedFeatures: - plugin = plugins[0]; - foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { - QMediaServiceFeaturesInterface *iface = - qobject_cast<QMediaServiceFeaturesInterface*>(currentPlugin); - - if (iface) { - if ((iface->supportedFeatures(type) & hint.features()) == hint.features()) { - plugin = currentPlugin; - break; - } - } - } - break; - case QMediaServiceProviderHint::Device: { - foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { - QMediaServiceSupportedDevicesInterface *iface = - qobject_cast<QMediaServiceSupportedDevicesInterface*>(currentPlugin); - - if (!iface) { - // the plugin may support the device, - // but this choice still can be overridden - plugin = currentPlugin; - } else { - if (iface->devices(type).contains(hint.device())) { - plugin = currentPlugin; - break; - } - } - } - } - break; - case QMediaServiceProviderHint::ContentType: { - QtMediaServices::SupportEstimate estimate = QtMediaServices::NotSupported; - foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { - QtMediaServices::SupportEstimate currentEstimate = QtMediaServices::MaybeSupported; - QMediaServiceSupportedFormatsInterface *iface = - qobject_cast<QMediaServiceSupportedFormatsInterface*>(currentPlugin); - - if (iface) - currentEstimate = iface->hasSupport(hint.mimeType(), hint.codecs()); - - if (currentEstimate > estimate) { - estimate = currentEstimate; - plugin = currentPlugin; - - if (currentEstimate == QtMediaServices::PreferredService) - break; - } - } - } - break; - } - - if (plugin != 0) { - QMediaService *service = plugin->create(key); - if (service != 0) - pluginMap.insert(service, plugin); - - return service; - } - } - - qWarning() << "defaultServiceProvider::requestService(): no service found for -" << key; - return 0; - } - - void releaseService(QMediaService *service) - { - if (service != 0) { - QMediaServiceProviderPlugin *plugin = pluginMap.take(service); - - if (plugin != 0) - plugin->release(service); - } - } - - QtMediaServices::SupportEstimate hasSupport(const QByteArray &serviceType, - const QString &mimeType, - const QStringList& codecs, - int flags) const - { - QList<QObject*> instances = loader()->instances( - QString::fromLatin1(serviceType.constData(),serviceType.length())); - - if (instances.isEmpty()) - return QtMediaServices::NotSupported; - - bool allServicesProvideInterface = true; - QtMediaServices::SupportEstimate supportEstimate = QtMediaServices::NotSupported; - - foreach(QObject *obj, instances) { - QMediaServiceSupportedFormatsInterface *iface = - qobject_cast<QMediaServiceSupportedFormatsInterface*>(obj); - - - if (flags) { - QMediaServiceFeaturesInterface *iface = - qobject_cast<QMediaServiceFeaturesInterface*>(obj); - - if (iface) { - QMediaServiceProviderHint::Features features = iface->supportedFeatures(serviceType); - - //if low latency playback was asked, skip services known - //not to provide low latency playback - if ((flags & QMediaPlayer::LowLatency) && - !(features & QMediaServiceProviderHint::LowLatencyPlayback)) - continue; - - //the same for QIODevice based streams support - if ((flags & QMediaPlayer::StreamPlayback) && - !(features & QMediaServiceProviderHint::StreamPlayback)) - continue; - } - } - - if (iface) - supportEstimate = qMax(supportEstimate, iface->hasSupport(mimeType, codecs)); - else - allServicesProvideInterface = false; - } - - //don't return PreferredService - supportEstimate = qMin(supportEstimate, QtMediaServices::ProbablySupported); - - //Return NotSupported only if no services are available of serviceType - //or all the services returned NotSupported, otherwise return at least MaybeSupported - if (!allServicesProvideInterface) - supportEstimate = qMax(QtMediaServices::MaybeSupported, supportEstimate); - - return supportEstimate; - } - - QStringList supportedMimeTypes(const QByteArray &serviceType, int flags) const - { - QList<QObject*> instances = loader()->instances( - QString::fromLatin1(serviceType.constData(),serviceType.length())); - - QStringList supportedTypes; - - foreach(QObject *obj, instances) { - QMediaServiceSupportedFormatsInterface *iface = - qobject_cast<QMediaServiceSupportedFormatsInterface*>(obj); - - - if (flags & QMediaPlayer::LowLatency) { - QMediaServiceFeaturesInterface *iface = - qobject_cast<QMediaServiceFeaturesInterface*>(obj); - - if (iface) { - QMediaServiceProviderHint::Features features = iface->supportedFeatures(serviceType); - - // If low latency playback was asked for, skip MIME types from services known - // not to provide low latency playback - if ((flags & QMediaPlayer::LowLatency) && - !(features & QMediaServiceProviderHint::LowLatencyPlayback)) - continue; - - //the same for QIODevice based streams support - if ((flags & QMediaPlayer::StreamPlayback) && - !(features & QMediaServiceProviderHint::StreamPlayback)) - continue; - } - } - - if (iface) { - supportedTypes << iface->supportedMimeTypes(); - } - } - - // Multiple services may support the same MIME type - supportedTypes.removeDuplicates(); - - return supportedTypes; - } - - QList<QByteArray> devices(const QByteArray &serviceType) const - { - QList<QByteArray> res; - - foreach(QObject *obj, loader()->instances( - QString::fromLatin1(serviceType.constData(),serviceType.length()))) { - QMediaServiceSupportedDevicesInterface *iface = - qobject_cast<QMediaServiceSupportedDevicesInterface*>(obj); - - if (iface) { - res.append(iface->devices(serviceType)); - } - } - - return res; - } - - QString deviceDescription(const QByteArray &serviceType, const QByteArray &device) - { - foreach(QObject *obj, loader()->instances( - QString::fromLatin1(serviceType.constData(),serviceType.length()))) { - QMediaServiceSupportedDevicesInterface *iface = - qobject_cast<QMediaServiceSupportedDevicesInterface*>(obj); - - if (iface) { - if (iface->devices(serviceType).contains(device)) - return iface->deviceDescription(serviceType, device); - } - } - - return QString(); - } -}; - -Q_GLOBAL_STATIC(QPluginServiceProvider, pluginProvider); - -/*! - \class QMediaServiceProvider - \preliminary - \since 4.7 - \brief The QMediaServiceProvider class provides an abstract allocator for media services. -*/ - -/*! - \fn QMediaServiceProvider::requestService(const QByteArray &type, const QMediaServiceProviderHint &hint) - - Requests an instance of a \a type service which best matches the given \a hint. - - Returns a pointer to the requested service, or a null pointer if there is no suitable service. - - The returned service must be released with releaseService when it is finished with. -*/ - -/*! - \fn QMediaServiceProvider::releaseService(QMediaService *service) - - Releases a media \a service requested with requestService(). -*/ - -/*! - \fn QtMediaServices::SupportEstimate QMediaServiceProvider::hasSupport(const QByteArray &serviceType, const QString &mimeType, const QStringList& codecs, int flags) const - - Returns how confident a media service provider is that is can provide a \a serviceType - service that is able to play media of a specific \a mimeType that is encoded using the listed - \a codecs while adhearing to constraints identified in \a flags. -*/ -QtMediaServices::SupportEstimate QMediaServiceProvider::hasSupport(const QByteArray &serviceType, - const QString &mimeType, - const QStringList& codecs, - int flags) const -{ - Q_UNUSED(serviceType); - Q_UNUSED(mimeType); - Q_UNUSED(codecs); - Q_UNUSED(flags); - - return QtMediaServices::MaybeSupported; -} - -/*! - \fn QStringList QMediaServiceProvider::supportedMimeTypes(const QByteArray &serviceType, int flags) const - - Returns a list of MIME types supported by the service provider for the specified \a serviceType. - - The resultant list is restricted to MIME types which can be supported given the constraints in \a flags. -*/ -QStringList QMediaServiceProvider::supportedMimeTypes(const QByteArray &serviceType, int flags) const -{ - Q_UNUSED(serviceType); - Q_UNUSED(flags); - - return QStringList(); -} - -/*! - Returns the list of devices related to \a service type. -*/ -QList<QByteArray> QMediaServiceProvider::devices(const QByteArray &service) const -{ - Q_UNUSED(service); - return QList<QByteArray>(); -} - -/*! - Returns the description of \a device related to \a serviceType, - suitable to be displayed to user. -*/ -QString QMediaServiceProvider::deviceDescription(const QByteArray &serviceType, const QByteArray &device) -{ - Q_UNUSED(serviceType); - Q_UNUSED(device); - return QString(); -} - - -#ifdef QT_BUILD_INTERNAL - -static QMediaServiceProvider *qt_defaultMediaServiceProvider = 0; - -/*! - Sets a media service \a provider as the default. - - \internal -*/ -void QMediaServiceProvider::setDefaultServiceProvider(QMediaServiceProvider *provider) -{ - qt_defaultMediaServiceProvider = provider; -} - -#endif - -/*! - Returns a default provider of media services. -*/ -QMediaServiceProvider *QMediaServiceProvider::defaultServiceProvider() -{ -#ifdef QT_BUILD_INTERNAL - return qt_defaultMediaServiceProvider != 0 - ? qt_defaultMediaServiceProvider - : static_cast<QMediaServiceProvider *>(pluginProvider()); -#else - return pluginProvider(); -#endif -} - -/*! - \class QMediaServiceProviderPlugin - \preliminary - \since 4.7 - \brief The QMediaServiceProviderPlugin class interface provides an interface for QMediaService - plug-ins. - - A media service provider plug-in may implement one or more of - QMediaServiceSupportedFormatsInterface, QMediaServiceSupportedDevicesInterface, - and QMediaServiceFeaturesInterface to identify the features it supports. -*/ - -/*! - \fn QMediaServiceProviderPlugin::keys() const - - Returns a list of keys for media services a plug-in can create. -*/ - -/*! - \fn QMediaServiceProviderPlugin::create(const QString &key) - - Constructs a new instance of the QMediaService identified by \a key. - - The QMediaService returned must be destroyed with release(). -*/ - -/*! - \fn QMediaServiceProviderPlugin::release(QMediaService *service) - - Destroys a media \a service constructed with create(). -*/ - - -/*! - \class QMediaServiceSupportedFormatsInterface - \brief The QMediaServiceSupportedFormatsInterface class interface - identifies if a media service plug-in supports a media format. - \since 4.7 - - A QMediaServiceProviderPlugin may implement this interface. -*/ - -/*! - \fn QMediaServiceSupportedFormatsInterface::~QMediaServiceSupportedFormatsInterface() - - Destroys a media service supported formats interface. -*/ - -/*! - \fn QMediaServiceSupportedFormatsInterface::hasSupport(const QString &mimeType, const QStringList& codecs) const - - Returns the level of support a media service plug-in has for a \a mimeType and set of \a codecs. -*/ - -/*! - \fn QMediaServiceSupportedFormatsInterface::supportedMimeTypes() const - - Returns a list of MIME types supported by the media service plug-in. -*/ - -/*! - \class QMediaServiceSupportedDevicesInterface - \brief The QMediaServiceSupportedDevicesInterface class interface - identifies the devices supported by a media service plug-in. - \since 4.7 - - A QMediaServiceProviderPlugin may implement this interface. -*/ - -/*! - \fn QMediaServiceSupportedDevicesInterface::~QMediaServiceSupportedDevicesInterface() - - Destroys a media service supported devices interface. -*/ - -/*! - \fn QMediaServiceSupportedDevicesInterface::devices(const QByteArray &service) const - - Returns a list of devices supported by a plug-in \a service. -*/ - -/*! - \fn QMediaServiceSupportedDevicesInterface::deviceDescription(const QByteArray &service, const QByteArray &device) - - Returns a description of a \a device supported by a plug-in \a service. -*/ - -/*! - \class QMediaServiceFeaturesInterface - \brief The QMediaServiceFeaturesInterface class interface identifies - features supported by a media service plug-in. - \since 4.7 - - A QMediaServiceProviderPlugin may implement this interface. -*/ - -/*! - \fn QMediaServiceFeaturesInterface::~QMediaServiceFeaturesInterface() - - Destroys a media service features interface. -*/ -/*! - \fn QMediaServiceFeaturesInterface::supportedFeatures(const QByteArray &service) const - - Returns a set of features supported by a plug-in \a service. -*/ - -QT_END_NAMESPACE - -#include "moc_qmediaserviceprovider.cpp" -#include "moc_qmediaserviceproviderplugin.cpp" diff --git a/src/multimedia/mediaservices/base/qmediaserviceprovider.h b/src/multimedia/mediaservices/base/qmediaserviceprovider.h deleted file mode 100644 index eeea5d2..0000000 --- a/src/multimedia/mediaservices/base/qmediaserviceprovider.h +++ /dev/null @@ -1,174 +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 QtMediaServices module 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 QMEDIASERVICEPROVIDER_H -#define QMEDIASERVICEPROVIDER_H - -#include <QtCore/qobject.h> -#include <QtCore/qshareddata.h> - -#include <QtMediaServices/qtmedianamespace.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaService; - -class QMediaServiceProviderHintPrivate; -class Q_MEDIASERVICES_EXPORT QMediaServiceProviderHint -{ -public: - enum Type { Null, ContentType, Device, SupportedFeatures }; - - enum Feature { - LowLatencyPlayback = 0x01, - RecordingSupport = 0x02, - StreamPlayback = 0x04 - }; - Q_DECLARE_FLAGS(Features, Feature) - - QMediaServiceProviderHint(); - QMediaServiceProviderHint(const QString &mimeType, const QStringList& codecs); - QMediaServiceProviderHint(const QByteArray &device); - QMediaServiceProviderHint(Features features); - QMediaServiceProviderHint(const QMediaServiceProviderHint &other); - ~QMediaServiceProviderHint(); - - QMediaServiceProviderHint& operator=(const QMediaServiceProviderHint &other); - - bool operator == (const QMediaServiceProviderHint &other) const; - bool operator != (const QMediaServiceProviderHint &other) const; - - bool isNull() const; - - Type type() const; - - QString mimeType() const; - QStringList codecs() const; - - QByteArray device() const; - - Features features() const; - - //to be extended, if necessary - -private: - QSharedDataPointer<QMediaServiceProviderHintPrivate> d; -}; - -class Q_MEDIASERVICES_EXPORT QMediaServiceProvider : public QObject -{ - Q_OBJECT - -public: - virtual QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &hint = QMediaServiceProviderHint()) = 0; - virtual void releaseService(QMediaService *service) = 0; - - virtual QtMediaServices::SupportEstimate hasSupport(const QByteArray &serviceType, - const QString &mimeType, - const QStringList& codecs, - int flags = 0) const; - virtual QStringList supportedMimeTypes(const QByteArray &serviceType, int flags = 0) const; - - virtual QList<QByteArray> devices(const QByteArray &serviceType) const; - virtual QString deviceDescription(const QByteArray &serviceType, const QByteArray &device); - - static QMediaServiceProvider* defaultServiceProvider(); - -#ifdef QT_BUILD_INTERNAL - static void setDefaultServiceProvider(QMediaServiceProvider *provider); -#endif -}; - -/*! - Service with support for media playback - Required Controls: QMediaPlayerControl - Optional Controls: QMediaPlaylistControl, QAudioDeviceControl - Video Output Controls (used by QWideoWidget and QGraphicsVideoItem): - Required: QVideoOutputControl - Optional: QVideoWindowControl, QVideoRendererControl, QVideoWidgetControl -*/ -#define Q_MEDIASERVICE_MEDIAPLAYER "com.nokia.qt.mediaplayer" - -/*! - Service with support for recording from audio sources - Required Controls: QAudioDeviceControl - Recording Controls (QMediaRecorder): - Required: QMediaRecorderControl - Recommended: QAudioEncoderControl - Optional: QMediaContainerControl -*/ -#define Q_MEDIASERVICE_AUDIOSOURCE "com.nokia.qt.audiosource" - -/*! - Service with support for camera use. - Required Controls: QCameraControl - Optional Controls: QCameraExposureControl, QCameraFocusControl, QImageProcessingControl - Still Capture Controls: QImageCaptureControl - Recording Controls (QMediaRecorder): - Required: QMediaRecorderControl - Recommended: QAudioEncoderControl, QVideoEncoderControl, QMediaContainerControl - Viewfinder Video Output Controls (used by QWideoWidget and QGraphicsVideoItem): - Required: QVideoOutputControl - Optional: QVideoWindowControl, QVideoRendererControl, QVideoWidgetControl -*/ -#define Q_MEDIASERVICE_CAMERA "com.nokia.qt.camera" - -/*! - Service with support for radio tuning. - Required Controls: QRadioTunerControl - Recording Controls (Optional, used by QMediaRecorder): - Required: QMediaRecorderControl - Recommended: QAudioEncoderControl - Optional: QMediaContainerControl -*/ -#define Q_MEDIASERVICE_RADIO "com.nokia.qt.radio" - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIASERVICEPROVIDER_H diff --git a/src/multimedia/mediaservices/base/qmediaserviceproviderplugin.h b/src/multimedia/mediaservices/base/qmediaserviceproviderplugin.h deleted file mode 100644 index ca25f91..0000000 --- a/src/multimedia/mediaservices/base/qmediaserviceproviderplugin.h +++ /dev/null @@ -1,125 +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 QtMediaServices module 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 QMEDIASERVICEPROVIDERPLUGIN_H -#define QMEDIASERVICEPROVIDERPLUGIN_H - -#include <QtCore/qstringlist.h> -#include <QtCore/qplugin.h> -#include <QtCore/qfactoryinterface.h> - -#include <QtMediaServices/qmediaserviceprovider.h> - -#ifdef Q_MOC_RUN -# pragma Q_MOC_EXPAND_MACROS -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMediaService; - - -struct Q_MEDIASERVICES_EXPORT QMediaServiceProviderFactoryInterface : public QFactoryInterface -{ - virtual QStringList keys() const = 0; - virtual QMediaService* create(QString const& key) = 0; - virtual void release(QMediaService *service) = 0; -}; - -#define QMediaServiceProviderFactoryInterface_iid \ - "com.nokia.Qt.QMediaServiceProviderFactoryInterface/1.0" -Q_DECLARE_INTERFACE(QMediaServiceProviderFactoryInterface, QMediaServiceProviderFactoryInterface_iid) - - -struct Q_MEDIASERVICES_EXPORT QMediaServiceSupportedFormatsInterface -{ - virtual ~QMediaServiceSupportedFormatsInterface() {} - virtual QtMediaServices::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const = 0; - virtual QStringList supportedMimeTypes() const = 0; -}; - -#define QMediaServiceSupportedFormatsInterface_iid \ - "com.nokia.Qt.QMediaServiceSupportedFormatsInterface/1.0" -Q_DECLARE_INTERFACE(QMediaServiceSupportedFormatsInterface, QMediaServiceSupportedFormatsInterface_iid) - - -struct Q_MEDIASERVICES_EXPORT QMediaServiceSupportedDevicesInterface -{ - virtual ~QMediaServiceSupportedDevicesInterface() {} - virtual QList<QByteArray> devices(const QByteArray &service) const = 0; - virtual QString deviceDescription(const QByteArray &service, const QByteArray &device) = 0; -}; - -#define QMediaServiceSupportedDevicesInterface_iid \ - "com.nokia.Qt.QMediaServiceSupportedDevicesInterface/1.0" -Q_DECLARE_INTERFACE(QMediaServiceSupportedDevicesInterface, QMediaServiceSupportedDevicesInterface_iid) - - -struct Q_MEDIASERVICES_EXPORT QMediaServiceFeaturesInterface -{ - virtual ~QMediaServiceFeaturesInterface() {} - virtual QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const = 0; -}; - -#define QMediaServiceFeaturesInterface_iid \ - "com.nokia.Qt.QMediaServiceFeaturesInterface/1.0" -Q_DECLARE_INTERFACE(QMediaServiceFeaturesInterface, QMediaServiceFeaturesInterface_iid) - -class Q_MEDIASERVICES_EXPORT QMediaServiceProviderPlugin : public QObject, public QMediaServiceProviderFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceProviderFactoryInterface:QFactoryInterface) - -public: - virtual QStringList keys() const = 0; - virtual QMediaService* create(const QString& key) = 0; - virtual void release(QMediaService *service) = 0; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIASERVICEPROVIDERPLUGIN_H diff --git a/src/multimedia/mediaservices/base/qmediatimerange.cpp b/src/multimedia/mediaservices/base/qmediatimerange.cpp deleted file mode 100644 index 2dba20c..0000000 --- a/src/multimedia/mediaservices/base/qmediatimerange.cpp +++ /dev/null @@ -1,708 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices module 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 <QtMediaServices/qmediatimerange.h> - - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaTimeInterval - \brief The QMediaTimeInterval class represents a time interval with integer precision. - \ingroup multimedia - \since 4.7 - - An interval is specified by an inclusive start() and end() time. - These must be set in the constructor, as this is an immutable class. - The specific units of time represented by the class have not been defined - - it is suitable for any times which can be represented by a signed 64 bit integer. - - The isNormal() method determines if a time interval is normal - (a normal time interval has start() <= end()). An abnormal interval can be converted - in to a normal interval by calling the normalized() method. - - The contains() method determines if a specified time lies within - the time interval. - - The translated() method returns a time interval which has been translated - forwards or backwards through time by a specified offset. - - \sa QMediaTimeRange -*/ - -/*! - \fn QMediaTimeInterval::QMediaTimeInterval() - - Constructs an empty interval. -*/ -QMediaTimeInterval::QMediaTimeInterval() - : s(0) - , e(0) -{ - -} - -/*! - \fn QMediaTimeInterval::QMediaTimeInterval(qint64 start, qint64 end) - - Constructs an interval with the specified \a start and \a end times. -*/ -QMediaTimeInterval::QMediaTimeInterval(qint64 start, qint64 end) - : s(start) - , e(end) -{ - -} - -/*! - \fn QMediaTimeInterval::QMediaTimeInterval(const QMediaTimeInterval &other) - - Constructs an interval by taking a copy of \a other. -*/ -QMediaTimeInterval::QMediaTimeInterval(const QMediaTimeInterval &other) - : s(other.s) - , e(other.e) -{ - -} - -/*! - \fn QMediaTimeInterval::start() const - - Returns the start time of the interval. - - \sa end() -*/ -qint64 QMediaTimeInterval::start() const -{ - return s; -} - -/*! - \fn QMediaTimeInterval::end() const - - Returns the end time of the interval. - - \sa start() -*/ -qint64 QMediaTimeInterval::end() const -{ - return e; -} - -/*! - \fn QMediaTimeInterval::contains(qint64 time) const - - Returns true if the time interval contains the specified \a time. - That is, start() <= time <= end(). -*/ -bool QMediaTimeInterval::contains(qint64 time) const -{ - return isNormal() ? (s <= time && time <= e) - : (e <= time && time <= s); -} - -/*! - \fn QMediaTimeInterval::isNormal() const - - Returns true if this time interval is normal. - A normal time interval has start() <= end(). - - \sa normalized() -*/ -bool QMediaTimeInterval::isNormal() const -{ - return s <= e; -} - -/*! - \fn QMediaTimeInterval::normalized() const - - Returns a normalized version of this interval. - - If the start() time of the interval is greater than the end() time, - then the returned interval has the start and end times swapped. -*/ -QMediaTimeInterval QMediaTimeInterval::normalized() const -{ - if(s > e) - return QMediaTimeInterval(e, s); - - return *this; -} - -/*! - \fn QMediaTimeInterval::translated(qint64 offset) const - - Returns a copy of this time interval, translated by a value of \a offset. - An interval can be moved forward through time with a positive offset, or backward - through time with a negative offset. -*/ -QMediaTimeInterval QMediaTimeInterval::translated(qint64 offset) const -{ - return QMediaTimeInterval(s + offset, e + offset); -} - -/*! - \fn operator==(const QMediaTimeInterval &a, const QMediaTimeInterval &b) - \relates QMediaTimeRange - - Returns true if \a a is exactly equal to \a b. -*/ -bool operator==(const QMediaTimeInterval &a, const QMediaTimeInterval &b) -{ - return a.start() == b.start() && a.end() == b.end(); -} - -/*! - \fn operator!=(const QMediaTimeInterval &a, const QMediaTimeInterval &b) - \relates QMediaTimeRange - - Returns true if \a a is not exactly equal to \a b. -*/ -bool operator!=(const QMediaTimeInterval &a, const QMediaTimeInterval &b) -{ - return a.start() != b.start() || a.end() != b.end(); -} - -class QMediaTimeRangePrivate : public QSharedData -{ -public: - - QMediaTimeRangePrivate(); - QMediaTimeRangePrivate(const QMediaTimeRangePrivate &other); - QMediaTimeRangePrivate(const QMediaTimeInterval &interval); - - QList<QMediaTimeInterval> intervals; - - void addInterval(const QMediaTimeInterval &interval); - void removeInterval(const QMediaTimeInterval &interval); -}; - -QMediaTimeRangePrivate::QMediaTimeRangePrivate() - : QSharedData() -{ - -} - -QMediaTimeRangePrivate::QMediaTimeRangePrivate(const QMediaTimeRangePrivate &other) - : QSharedData() - , intervals(other.intervals) -{ - -} - -QMediaTimeRangePrivate::QMediaTimeRangePrivate(const QMediaTimeInterval &interval) - : QSharedData() -{ - if(interval.isNormal()) - intervals << interval; -} - -void QMediaTimeRangePrivate::addInterval(const QMediaTimeInterval &interval) -{ - // Handle normalized intervals only - if(!interval.isNormal()) - return; - - // Find a place to insert the interval - int i; - for (i = 0; i < intervals.count(); i++) { - // Insert before this element - if(interval.s < intervals[i].s) { - intervals.insert(i, interval); - break; - } - } - - // Interval needs to be added to the end of the list - if (i == intervals.count()) - intervals.append(interval); - - // Do we need to correct the element before us? - if(i > 0 && intervals[i - 1].e >= interval.s - 1) - i--; - - // Merge trailing ranges - while (i < intervals.count() - 1 - && intervals[i].e >= intervals[i + 1].s - 1) { - intervals[i].e = qMax(intervals[i].e, intervals[i + 1].e); - intervals.removeAt(i + 1); - } -} - -void QMediaTimeRangePrivate::removeInterval(const QMediaTimeInterval &interval) -{ - // Handle normalized intervals only - if(!interval.isNormal()) - return; - - for (int i = 0; i < intervals.count(); i++) { - QMediaTimeInterval r = intervals[i]; - - if (r.e < interval.s) { - // Before the removal interval - continue; - } else if (interval.e < r.s) { - // After the removal interval - stop here - break; - } else if (r.s < interval.s && interval.e < r.e) { - // Split case - a single range has a chunk removed - intervals[i].e = interval.s -1; - addInterval(QMediaTimeInterval(interval.e + 1, r.e)); - break; - } else if (r.s < interval.s) { - // Trimming Tail Case - intervals[i].e = interval.s - 1; - } else if (interval.e < r.e) { - // Trimming Head Case - we can stop after this - intervals[i].s = interval.e + 1; - break; - } else { - // Complete coverage case - intervals.removeAt(i); - --i; - } - } -} - -/*! - \class QMediaTimeRange - \brief The QMediaTimeRange class represents a set of zero or more disjoint - time intervals. - \ingroup multimedia - \since 4.7 - - \reentrant - - The earliestTime(), latestTime(), intervals() and isEmpty() - methods are used to get information about the current time range. - - The addInterval(), removeInterval() and clear() methods are used to modify - the current time range. - - When adding or removing intervals from the time range, existing intervals - within the range may be expanded, trimmed, deleted, merged or split to ensure - that all intervals within the time range remain distinct and disjoint. As a - consequence, all intervals added or removed from a time range must be - \l{QMediaTimeInterval::isNormal()}{normal}. - - \sa QMediaTimeInterval -*/ - -/*! - \fn QMediaTimeRange::QMediaTimeRange() - - Constructs an empty time range. -*/ -QMediaTimeRange::QMediaTimeRange() - : d(new QMediaTimeRangePrivate) -{ - -} - -/*! - \fn QMediaTimeRange::QMediaTimeRange(qint64 start, qint64 end) - - Constructs a time range that contains an initial interval from - \a start to \a end inclusive. - - If the interval is not \l{QMediaTimeInterval::isNormal()}{normal}, - the resulting time range will be empty. - - \sa addInterval() -*/ -QMediaTimeRange::QMediaTimeRange(qint64 start, qint64 end) - : d(new QMediaTimeRangePrivate(QMediaTimeInterval(start, end))) -{ - -} - -/*! - \fn QMediaTimeRange::QMediaTimeRange(const QMediaTimeInterval &interval) - - Constructs a time range that contains an intitial interval, \a interval. - - If \a interval is not \l{QMediaTimeInterval::isNormal()}{normal}, - the resulting time range will be empty. - - \sa addInterval() -*/ -QMediaTimeRange::QMediaTimeRange(const QMediaTimeInterval &interval) - : d(new QMediaTimeRangePrivate(interval)) -{ - -} - -/*! - \fn QMediaTimeRange::QMediaTimeRange(const QMediaTimeRange &range) - - Constructs a time range by copying another time \a range. -*/ -QMediaTimeRange::QMediaTimeRange(const QMediaTimeRange &range) - : d(range.d) -{ - -} - -/*! - \fn QMediaTimeRange::~QMediaTimeRange() - - Destructor. -*/ -QMediaTimeRange::~QMediaTimeRange() -{ - -} - -/*! - \fn QMediaTimeRange::operator=(const QMediaTimeRange &other) - - Takes a copy of the \a other time range and returns itself. -*/ -QMediaTimeRange &QMediaTimeRange::operator=(const QMediaTimeRange &other) -{ - d = other.d; - return *this; -} - -/*! - \fn QMediaTimeRange::operator=(const QMediaTimeInterval &interval) - - Sets the time range to a single continuous interval, \a interval. -*/ -QMediaTimeRange &QMediaTimeRange::operator=(const QMediaTimeInterval &interval) -{ - d = new QMediaTimeRangePrivate(interval); - return *this; -} - -/*! - \fn QMediaTimeRange::earliestTime() const - - Returns the earliest time within the time range. - - For empty time ranges, this value is equal to zero. - - \sa latestTime() -*/ -qint64 QMediaTimeRange::earliestTime() const -{ - if (!d->intervals.isEmpty()) - return d->intervals[0].s; - - return 0; -} - -/*! - \fn QMediaTimeRange::latestTime() const - - Returns the latest time within the time range. - - For empty time ranges, this value is equal to zero. - - \sa earliestTime() -*/ -qint64 QMediaTimeRange::latestTime() const -{ - if (!d->intervals.isEmpty()) - return d->intervals[d->intervals.count() - 1].e; - - return 0; -} - -/*! - \fn QMediaTimeRange::addInterval(qint64 start, qint64 end) - \overload - - Adds the interval specified by \a start and \a end - to the time range. - - \sa addInterval() -*/ -void QMediaTimeRange::addInterval(qint64 start, qint64 end) -{ - d->addInterval(QMediaTimeInterval(start, end)); -} - -/*! - \fn QMediaTimeRange::addInterval(const QMediaTimeInterval &interval) - - Adds the specified \a interval to the time range. - - Adding intervals which are not \l{QMediaTimeInterval::isNormal()}{normal} - is invalid, and will be ignored. - - If the specified interval is adjacent to, or overlaps existing - intervals within the time range, these intervals will be merged. - - This operation takes \l{linear time} - - \sa removeInterval() -*/ -void QMediaTimeRange::addInterval(const QMediaTimeInterval &interval) -{ - d->addInterval(interval); -} - -/*! - \fn QMediaTimeRange::addTimeRange(const QMediaTimeRange &range) - - Adds each of the intervals in \a range to this time range. - - Equivalent to calling addInterval() for each interval in \a range. -*/ -void QMediaTimeRange::addTimeRange(const QMediaTimeRange &range) -{ - foreach(const QMediaTimeInterval &i, range.intervals()) { - d->addInterval(i); - } -} - -/*! - \fn QMediaTimeRange::removeInterval(qint64 start, qint64 end) - \overload - - Removes the interval specified by \a start and \a end - from the time range. - - \sa removeInterval() -*/ -void QMediaTimeRange::removeInterval(qint64 start, qint64 end) -{ - d->removeInterval(QMediaTimeInterval(start, end)); -} - -/*! - \fn QMediaTimeRange::removeInterval(const QMediaTimeInterval &interval) - - Removes the specified \a interval from the time range. - - Removing intervals which are not \l{QMediaTimeInterval::isNormal()}{normal} - is invalid, and will be ignored. - - Intervals within the time range will be trimmed, split or deleted - such that no intervals within the time range include any part of the - target interval. - - This operation takes \l{linear time} - - \sa addInterval() -*/ -void QMediaTimeRange::removeInterval(const QMediaTimeInterval &interval) -{ - d->removeInterval(interval); -} - -/*! - \fn QMediaTimeRange::removeTimeRange(const QMediaTimeRange &range) - - Removes each of the intervals in \a range from this time range. - - Equivalent to calling removeInterval() for each interval in \a range. -*/ -void QMediaTimeRange::removeTimeRange(const QMediaTimeRange &range) -{ - foreach(const QMediaTimeInterval &i, range.intervals()) { - d->removeInterval(i); - } -} - -/*! - \fn QMediaTimeRange::operator+=(const QMediaTimeRange &other) - - Adds each interval in \a other to the time range and returns the result. -*/ -QMediaTimeRange& QMediaTimeRange::operator+=(const QMediaTimeRange &other) -{ - addTimeRange(other); - return *this; -} - -/*! - \fn QMediaTimeRange::operator+=(const QMediaTimeInterval &interval) - - Adds the specified \a interval to the time range and returns the result. -*/ -QMediaTimeRange& QMediaTimeRange::operator+=(const QMediaTimeInterval &interval) -{ - addInterval(interval); - return *this; -} - -/*! - \fn QMediaTimeRange::operator-=(const QMediaTimeRange &other) - - Removes each interval in \a other from the time range and returns the result. -*/ -QMediaTimeRange& QMediaTimeRange::operator-=(const QMediaTimeRange &other) -{ - removeTimeRange(other); - return *this; -} - -/*! - \fn QMediaTimeRange::operator-=(const QMediaTimeInterval &interval) - - Removes the specified \a interval from the time range and returns the result. -*/ -QMediaTimeRange& QMediaTimeRange::operator-=(const QMediaTimeInterval &interval) -{ - removeInterval(interval); - return *this; -} - -/*! - \fn QMediaTimeRange::clear() - - Removes all intervals from the time range. - - \sa removeInterval() -*/ -void QMediaTimeRange::clear() -{ - d->intervals.clear(); -} - -/*! - \fn QMediaTimeRange::intervals() const - - Returns the list of intervals covered by this time range. -*/ -QList<QMediaTimeInterval> QMediaTimeRange::intervals() const -{ - return d->intervals; -} - -/*! - \fn QMediaTimeRange::isEmpty() const - - Returns true if there are no intervals within the time range. - - \sa intervals() -*/ -bool QMediaTimeRange::isEmpty() const -{ - return d->intervals.isEmpty(); -} - -/*! - \fn QMediaTimeRange::isContinuous() const - - Returns true if the time range consists of a continuous interval. - That is, there is one or fewer disjoint intervals within the time range. -*/ -bool QMediaTimeRange::isContinuous() const -{ - return (d->intervals.count() <= 1); -} - -/*! - \fn QMediaTimeRange::contains(qint64 time) const - - Returns true if the specified \a time lies within the time range. -*/ -bool QMediaTimeRange::contains(qint64 time) const -{ - for (int i = 0; i < d->intervals.count(); i++) { - if (d->intervals[i].contains(time)) - return true; - - if (time < d->intervals[i].s) - break; - } - - return false; -} - -/*! - \fn operator==(const QMediaTimeRange &a, const QMediaTimeRange &b) - \relates QMediaTimeRange - - Returns true if all intervals in \a a are present in \a b. -*/ -bool operator==(const QMediaTimeRange &a, const QMediaTimeRange &b) -{ - if (a.intervals().count() != b.intervals().count()) - return false; - - for (int i = 0; i < a.intervals().count(); i++) - { - if(a.intervals()[i] != b.intervals()[i]) - return false; - } - - return true; -} - -/*! - \fn operator!=(const QMediaTimeRange &a, const QMediaTimeRange &b) - \relates QMediaTimeRange - - Returns true if one or more intervals in \a a are not present in \a b. -*/ -bool operator!=(const QMediaTimeRange &a, const QMediaTimeRange &b) -{ - return !(a == b); -} - -/*! - \fn operator+(const QMediaTimeRange &r1, const QMediaTimeRange &r2) - - Returns a time range containing the union between \a r1 and \a r2. - */ -QMediaTimeRange operator+(const QMediaTimeRange &r1, const QMediaTimeRange &r2) -{ - return (QMediaTimeRange(r1) += r2); -} - -/*! - \fn operator-(const QMediaTimeRange &r1, const QMediaTimeRange &r2) - - Returns a time range containing \a r2 subtracted from \a r1. - */ -QMediaTimeRange operator-(const QMediaTimeRange &r1, const QMediaTimeRange &r2) -{ - return (QMediaTimeRange(r1) -= r2); -} - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmediatimerange.h b/src/multimedia/mediaservices/base/qmediatimerange.h deleted file mode 100644 index 5983db2..0000000 --- a/src/multimedia/mediaservices/base/qmediatimerange.h +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices module 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 QMEDIATIMERANGE_H -#define QMEDIATIMERANGE_H - -#include <QtCore/qshareddata.h> -#include <QtMediaServices/qtmedianamespace.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QMediaTimeRangePrivate; - -class Q_MEDIASERVICES_EXPORT QMediaTimeInterval -{ -public: - QMediaTimeInterval(); - QMediaTimeInterval(qint64 start, qint64 end); - QMediaTimeInterval(const QMediaTimeInterval&); - - qint64 start() const; - qint64 end() const; - - bool contains(qint64 time) const; - - bool isNormal() const; - QMediaTimeInterval normalized() const; - QMediaTimeInterval translated(qint64 offset) const; - -private: - friend class QMediaTimeRangePrivate; - friend class QMediaTimeRange; - - qint64 s; - qint64 e; -}; - -Q_MEDIASERVICES_EXPORT bool operator==(const QMediaTimeInterval&, const QMediaTimeInterval&); -Q_MEDIASERVICES_EXPORT bool operator!=(const QMediaTimeInterval&, const QMediaTimeInterval&); - -class Q_MEDIASERVICES_EXPORT QMediaTimeRange -{ -public: - - QMediaTimeRange(); - QMediaTimeRange(qint64 start, qint64 end); - QMediaTimeRange(const QMediaTimeInterval&); - QMediaTimeRange(const QMediaTimeRange &range); - ~QMediaTimeRange(); - - QMediaTimeRange &operator=(const QMediaTimeRange&); - QMediaTimeRange &operator=(const QMediaTimeInterval&); - - qint64 earliestTime() const; - qint64 latestTime() const; - - QList<QMediaTimeInterval> intervals() const; - bool isEmpty() const; - bool isContinuous() const; - - bool contains(qint64 time) const; - - void addInterval(qint64 start, qint64 end); - void addInterval(const QMediaTimeInterval &interval); - void addTimeRange(const QMediaTimeRange&); - - void removeInterval(qint64 start, qint64 end); - void removeInterval(const QMediaTimeInterval &interval); - void removeTimeRange(const QMediaTimeRange&); - - QMediaTimeRange& operator+=(const QMediaTimeRange&); - QMediaTimeRange& operator+=(const QMediaTimeInterval&); - QMediaTimeRange& operator-=(const QMediaTimeRange&); - QMediaTimeRange& operator-=(const QMediaTimeInterval&); - - void clear(); - -private: - QSharedDataPointer<QMediaTimeRangePrivate> d; -}; - -Q_MEDIASERVICES_EXPORT bool operator==(const QMediaTimeRange&, const QMediaTimeRange&); -Q_MEDIASERVICES_EXPORT bool operator!=(const QMediaTimeRange&, const QMediaTimeRange&); -Q_MEDIASERVICES_EXPORT QMediaTimeRange operator+(const QMediaTimeRange&, const QMediaTimeRange&); -Q_MEDIASERVICES_EXPORT QMediaTimeRange operator-(const QMediaTimeRange&, const QMediaTimeRange&); - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIATIMERANGE_H diff --git a/src/multimedia/mediaservices/base/qmetadatacontrol.cpp b/src/multimedia/mediaservices/base/qmetadatacontrol.cpp deleted file mode 100644 index 8bfec7e..0000000 --- a/src/multimedia/mediaservices/base/qmetadatacontrol.cpp +++ /dev/null @@ -1,185 +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 QtMediaServices module 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 <QtMediaServices/qmetadatacontrol.h> -#include "qmediacontrol_p.h" - - -QT_BEGIN_NAMESPACE - - -/*! - \class QMetaDataControl - \ingroup multimedia-serv - \since 4.7 - \preliminary - \brief The QMetaDataControl class provides access to the meta-data of a - QMediaService's media. - - If a QMediaService can provide read or write access to the meta-data of - its current media it will implement QMetaDataControl. This control - provides functions for both retrieving and setting meta-data values. - Meta-data may be addressed by the well defined keys in the - QtMediaServices::MetaData enumeration using the metaData() functions, or by - string keys using the extendedMetaData() functions. - - The functionality provided by this control is exposed to application - code by the meta-data members of QMediaObject, and so meta-data access - is potentially available in any of the media object classes. Any media - service may implement QMetaDataControl. - - The interface name of QMetaDataControl is \c com.nokia.Qt.QMetaDataControl/1.0 as - defined in QMetaDataControl_iid. - - \sa QMediaService::control(), QMediaObject -*/ - -/*! - \macro QMetaDataControl_iid - - \c com.nokia.Qt.QMetaDataControl/1.0 - - Defines the interface name of the QMetaDataControl class. - - \relates QMetaDataControl -*/ - -/*! - Construct a QMetaDataControl with \a parent. This class is meant as a base class - for service specific meta data providers so this constructor is protected. -*/ - -QMetaDataControl::QMetaDataControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destroy the meta-data object. -*/ - -QMetaDataControl::~QMetaDataControl() -{ -} - -/*! - \fn bool QMetaDataControl::isMetaDataAvailable() const - - Identifies if meta-data is available from a media service. - - Returns true if the meta-data is available and false otherwise. -*/ - -/*! - \fn bool QMetaDataControl::isWritable() const - - Identifies if a media service's meta-data can be edited. - - Returns true if the meta-data is writable and false otherwise. -*/ - -/*! - \fn QVariant QMetaDataControl::metaData(QtMediaServices::MetaData key) const - - Returns the meta-data for the given \a key. -*/ - -/*! - \fn void QMetaDataControl::setMetaData(QtMediaServices::MetaData key, const QVariant &value) - - Sets the \a value of the meta-data element with the given \a key. -*/ - -/*! - \fn QMetaDataControl::availableMetaData() const - - Returns a list of keys there is meta-data available for. -*/ - -/*! - \fn QMetaDataControl::extendedMetaData(const QString &key) const - - Returns the metaData for an abitrary string \a key. - - The valid selection of keys for extended meta-data is determined by the provider and the meaning - and type may differ between providers. -*/ - -/*! - \fn QMetaDataControl::setExtendedMetaData(const QString &key, const QVariant &value) - - Change the value of the meta-data element with an abitrary string \a key to \a value. - - The valid selection of keys for extended meta-data is determined by the provider and the meaning - and type may differ between providers. -*/ - -/*! - \fn QMetaDataControl::availableExtendedMetaData() const - - Returns a list of keys there is extended meta-data available for. -*/ - - -/*! - \fn void QMetaDataControl::metaDataChanged() - - Signal the changes of meta-data. -*/ - -/*! - \fn void QMetaDataControl::metaDataAvailableChanged(bool available) - - Signal the availability of meta-data has changed, \a available will - be true if the multimedia object has meta-data. -*/ - -/*! - \fn void QMetaDataControl::writableChanged(bool writable) - - Signal a change in the writable status of meta-data, \a writable will be - true if meta-data elements can be added or adjusted. -*/ - -#include "moc_qmetadatacontrol.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qmetadatacontrol.h b/src/multimedia/mediaservices/base/qmetadatacontrol.h deleted file mode 100644 index 48206fa..0000000 --- a/src/multimedia/mediaservices/base/qmetadatacontrol.h +++ /dev/null @@ -1,92 +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 QtMediaServices module 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 QMETADATACONTROL_H -#define QMETADATACONTROL_H - -#include <QtMediaServices/qmediacontrol.h> -#include <QtMediaServices/qmediaobject.h> -#include <QtMediaServices/qmediaresource.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class Q_MEDIASERVICES_EXPORT QMetaDataControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QMetaDataControl(); - - virtual bool isWritable() const = 0; - virtual bool isMetaDataAvailable() const = 0; - - virtual QVariant metaData(QtMediaServices::MetaData key) const = 0; - virtual void setMetaData(QtMediaServices::MetaData key, const QVariant &value) = 0; - virtual QList<QtMediaServices::MetaData> availableMetaData() const = 0; - - virtual QVariant extendedMetaData(const QString &key) const = 0; - virtual void setExtendedMetaData(const QString &key, const QVariant &value) = 0; - virtual QStringList availableExtendedMetaData() const = 0; - -Q_SIGNALS: - void metaDataChanged(); - - void writableChanged(bool writable); - void metaDataAvailableChanged(bool available); - -protected: - QMetaDataControl(QObject *parent = 0); -}; - -#define QMetaDataControl_iid "com.nokia.Qt.QMetaDataControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMetaDataControl, QMetaDataControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMETADATAPROVIDER_H diff --git a/src/multimedia/mediaservices/base/qpaintervideosurface.cpp b/src/multimedia/mediaservices/base/qpaintervideosurface.cpp deleted file mode 100644 index 302e772..0000000 --- a/src/multimedia/mediaservices/base/qpaintervideosurface.cpp +++ /dev/null @@ -1,1565 +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 QtMediaServices module 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 "qpaintervideosurface_p.h" -#include "qpaintervideosurface_mac_p.h" - -#include <qmath.h> - -#include <qpainter.h> -#include <qvariant.h> -#include <QtMultimedia/qvideosurfaceformat.h> - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) -#include <qglshaderprogram.h> -#endif - -#include <QtDebug> - - -QT_BEGIN_NAMESPACE - -QVideoSurfacePainter::~QVideoSurfacePainter() -{ -} - -class QVideoSurfaceRasterPainter : public QVideoSurfacePainter -{ -public: - QVideoSurfaceRasterPainter(); - - QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const; - - bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const; - - QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); - void stop(); - - QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame); - - QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source); - - void updateColors(int brightness, int contrast, int hue, int saturation); - -private: - QList<QVideoFrame::PixelFormat> m_imagePixelFormats; - QVideoFrame m_frame; - QSize m_imageSize; - QImage::Format m_imageFormat; - QVideoSurfaceFormat::Direction m_scanLineDirection; -}; - -QVideoSurfaceRasterPainter::QVideoSurfaceRasterPainter() - : m_imageFormat(QImage::Format_Invalid) - , m_scanLineDirection(QVideoSurfaceFormat::TopToBottom) -{ - m_imagePixelFormats - << QVideoFrame::Format_RGB32 -#ifndef QT_OPENGL_ES // The raster formats should be a subset of the GL formats. - << QVideoFrame::Format_RGB24 -#endif - << QVideoFrame::Format_ARGB32 - << QVideoFrame::Format_RGB565; -} - -QList<QVideoFrame::PixelFormat> QVideoSurfaceRasterPainter::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - return handleType == QAbstractVideoBuffer::NoHandle - ? m_imagePixelFormats - : QList<QVideoFrame::PixelFormat>(); -} - -bool QVideoSurfaceRasterPainter::isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *) const -{ - return format.handleType() == QAbstractVideoBuffer::NoHandle - && m_imagePixelFormats.contains(format.pixelFormat()) - && !format.frameSize().isEmpty(); -} - -QAbstractVideoSurface::Error QVideoSurfaceRasterPainter::start(const QVideoSurfaceFormat &format) -{ - m_frame = QVideoFrame(); - m_imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); - m_imageSize = format.frameSize(); - m_scanLineDirection = format.scanLineDirection(); - - return format.handleType() == QAbstractVideoBuffer::NoHandle - && m_imageFormat != QImage::Format_Invalid - && !m_imageSize.isEmpty() - ? QAbstractVideoSurface::NoError - : QAbstractVideoSurface::UnsupportedFormatError; -} - -void QVideoSurfaceRasterPainter::stop() -{ - m_frame = QVideoFrame(); -} - -QAbstractVideoSurface::Error QVideoSurfaceRasterPainter::setCurrentFrame(const QVideoFrame &frame) -{ - m_frame = frame; - - return QAbstractVideoSurface::NoError; -} - -QAbstractVideoSurface::Error QVideoSurfaceRasterPainter::paint( - const QRectF &target, QPainter *painter, const QRectF &source) -{ - if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { - QImage image( - m_frame.bits(), - m_imageSize.width(), - m_imageSize.height(), - m_frame.bytesPerLine(), - m_imageFormat); - - if (m_scanLineDirection == QVideoSurfaceFormat::BottomToTop) { - const QTransform oldTransform = painter->transform(); - - painter->scale(1, -1); - painter->translate(0, -target.bottom()); - painter->drawImage( - QRectF(target.x(), 0, target.width(), target.height()), image, source); - painter->setTransform(oldTransform); - } else { - painter->drawImage(target, image, source); - } - - m_frame.unmap(); - } else if (m_frame.isValid()) { - return QAbstractVideoSurface::IncorrectFormatError; - } else { - painter->fillRect(target, Qt::black); - } - return QAbstractVideoSurface::NoError; -} - -void QVideoSurfaceRasterPainter::updateColors(int, int, int, int) -{ -} - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - -#ifndef Q_WS_MAC -# ifndef APIENTRYP -# ifdef APIENTRY -# define APIENTRYP APIENTRY * -# else -# define APIENTRY -# define APIENTRYP * -# endif -# endif -#else -# define APIENTRY -# define APIENTRYP * -#endif - -#ifndef GL_TEXTURE0 -# define GL_TEXTURE0 0x84C0 -# define GL_TEXTURE1 0x84C1 -# define GL_TEXTURE2 0x84C2 -#endif -#ifndef GL_PROGRAM_ERROR_STRING_ARB -# define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#endif - -#ifndef GL_UNSIGNED_SHORT_5_6_5 -# define GL_UNSIGNED_SHORT_5_6_5 33635 -#endif - -class QVideoSurfaceGLPainter : public QVideoSurfacePainter -{ -public: - QVideoSurfaceGLPainter(QGLContext *context); - ~QVideoSurfaceGLPainter(); - QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const; - - bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const; - - QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame); - - void updateColors(int brightness, int contrast, int hue, int saturation); - -protected: - void initRgbTextureInfo(GLenum internalFormat, GLuint format, GLenum type, const QSize &size); - void initYuv420PTextureInfo(const QSize &size); - void initYv12TextureInfo(const QSize &size); - -#ifndef QT_OPENGL_ES - typedef void (APIENTRY *_glActiveTexture) (GLenum); - _glActiveTexture glActiveTexture; -#endif - - QList<QVideoFrame::PixelFormat> m_imagePixelFormats; - QList<QVideoFrame::PixelFormat> m_glPixelFormats; - QMatrix4x4 m_colorMatrix; - QVideoFrame m_frame; - - QGLContext *m_context; - QAbstractVideoBuffer::HandleType m_handleType; - QVideoSurfaceFormat::Direction m_scanLineDirection; - GLenum m_textureFormat; - GLuint m_textureInternalFormat; - GLenum m_textureType; - int m_textureCount; - GLuint m_textureIds[3]; - int m_textureWidths[3]; - int m_textureHeights[3]; - int m_textureOffsets[3]; - bool m_yuv; -}; - -QVideoSurfaceGLPainter::QVideoSurfaceGLPainter(QGLContext *context) - : m_context(context) - , m_handleType(QAbstractVideoBuffer::NoHandle) - , m_scanLineDirection(QVideoSurfaceFormat::TopToBottom) - , m_textureFormat(0) - , m_textureInternalFormat(0) - , m_textureType(0) - , m_textureCount(0) - , m_yuv(false) -{ -#ifndef QT_OPENGL_ES - glActiveTexture = (_glActiveTexture)m_context->getProcAddress(QLatin1String("glActiveTexture")); -#endif -} - -QVideoSurfaceGLPainter::~QVideoSurfaceGLPainter() -{ -} - -QList<QVideoFrame::PixelFormat> QVideoSurfaceGLPainter::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - switch (handleType) { - case QAbstractVideoBuffer::NoHandle: - return m_imagePixelFormats; - case QAbstractVideoBuffer::GLTextureHandle: - return m_glPixelFormats; - default: - return QList<QVideoFrame::PixelFormat>(); - } -} - -bool QVideoSurfaceGLPainter::isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *) const -{ - if (format.frameSize().isEmpty()) { - return false; - } else { - switch (format.handleType()) { - case QAbstractVideoBuffer::NoHandle: - return m_imagePixelFormats.contains(format.pixelFormat()); - case QAbstractVideoBuffer::GLTextureHandle: - return m_glPixelFormats.contains(format.pixelFormat()); - default: - return false; - } - } -} - -QAbstractVideoSurface::Error QVideoSurfaceGLPainter::setCurrentFrame(const QVideoFrame &frame) -{ - m_frame = frame; - - if (m_handleType == QAbstractVideoBuffer::GLTextureHandle) { - m_textureIds[0] = frame.handle().toInt(); - } else if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { - m_context->makeCurrent(); - - for (int i = 0; i < m_textureCount; ++i) { - glBindTexture(GL_TEXTURE_2D, m_textureIds[i]); - glTexImage2D( - GL_TEXTURE_2D, - 0, - m_textureInternalFormat, - m_textureWidths[i], - m_textureHeights[i], - 0, - m_textureFormat, - m_textureType, - m_frame.bits() + m_textureOffsets[i]); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - } - m_frame.unmap(); - } else if (m_frame.isValid()) { - return QAbstractVideoSurface::IncorrectFormatError; - } - - return QAbstractVideoSurface::NoError; -} - -void QVideoSurfaceGLPainter::updateColors(int brightness, int contrast, int hue, int saturation) -{ - const qreal b = brightness / 200.0; - const qreal c = contrast / 100.0 + 1.0; - const qreal h = hue / 100.0; - const qreal s = saturation / 100.0 + 1.0; - - const qreal cosH = qCos(M_PI * h); - const qreal sinH = qSin(M_PI * h); - - const qreal h11 = 0.787 * cosH - 0.213 * sinH + 0.213; - const qreal h21 = -0.213 * cosH + 0.143 * sinH + 0.213; - const qreal h31 = -0.213 * cosH - 0.787 * sinH + 0.213; - - const qreal h12 = -0.715 * cosH - 0.715 * sinH + 0.715; - const qreal h22 = 0.285 * cosH + 0.140 * sinH + 0.715; - const qreal h32 = -0.715 * cosH + 0.715 * sinH + 0.715; - - const qreal h13 = -0.072 * cosH + 0.928 * sinH + 0.072; - const qreal h23 = -0.072 * cosH - 0.283 * sinH + 0.072; - const qreal h33 = 0.928 * cosH + 0.072 * sinH + 0.072; - - const qreal sr = (1.0 - s) * 0.3086; - const qreal sg = (1.0 - s) * 0.6094; - const qreal sb = (1.0 - s) * 0.0820; - - const qreal sr_s = sr + s; - const qreal sg_s = sg + s; - const qreal sb_s = sr + s; - - const float m4 = (s + sr + sg + sb) * (0.5 - 0.5 * c + b); - - m_colorMatrix(0, 0) = c * (sr_s * h11 + sg * h21 + sb * h31); - m_colorMatrix(0, 1) = c * (sr_s * h12 + sg * h22 + sb * h32); - m_colorMatrix(0, 2) = c * (sr_s * h13 + sg * h23 + sb * h33); - m_colorMatrix(0, 3) = m4; - - m_colorMatrix(1, 0) = c * (sr * h11 + sg_s * h21 + sb * h31); - m_colorMatrix(1, 1) = c * (sr * h12 + sg_s * h22 + sb * h32); - m_colorMatrix(1, 2) = c * (sr * h13 + sg_s * h23 + sb * h33); - m_colorMatrix(1, 3) = m4; - - m_colorMatrix(2, 0) = c * (sr * h11 + sg * h21 + sb_s * h31); - m_colorMatrix(2, 1) = c * (sr * h12 + sg * h22 + sb_s * h32); - m_colorMatrix(2, 2) = c * (sr * h13 + sg * h23 + sb_s * h33); - m_colorMatrix(2, 3) = m4; - - m_colorMatrix(3, 0) = 0.0; - m_colorMatrix(3, 1) = 0.0; - m_colorMatrix(3, 2) = 0.0; - m_colorMatrix(3, 3) = 1.0; - - if (m_yuv) { - m_colorMatrix = m_colorMatrix * QMatrix4x4( - 1.0, 0.000, 1.140, -0.5700, - 1.0, -0.394, -0.581, 0.4875, - 1.0, 2.028, 0.000, -1.0140, - 0.0, 0.000, 0.000, 1.0000); - } -} - -void QVideoSurfaceGLPainter::initRgbTextureInfo( - GLenum internalFormat, GLuint format, GLenum type, const QSize &size) -{ - m_yuv = false; - m_textureInternalFormat = internalFormat; - m_textureFormat = format; - m_textureType = type; - m_textureCount = 1; - m_textureWidths[0] = size.width(); - m_textureHeights[0] = size.height(); - m_textureOffsets[0] = 0; -} - -void QVideoSurfaceGLPainter::initYuv420PTextureInfo(const QSize &size) -{ - int w = (size.width() + 3) & ~3; - int w2 = (size.width()/2 + 3) & ~3; - - m_yuv = true; - m_textureInternalFormat = GL_LUMINANCE; - m_textureFormat = GL_LUMINANCE; - m_textureType = GL_UNSIGNED_BYTE; - m_textureCount = 3; - m_textureWidths[0] = size.width(); - m_textureHeights[0] = size.height(); - m_textureOffsets[0] = 0; - m_textureWidths[1] = size.width() / 2; - m_textureHeights[1] = size.height() / 2; - m_textureOffsets[1] = w * size.height(); - m_textureWidths[2] = size.width() / 2; - m_textureHeights[2] = size.height() / 2; - m_textureOffsets[2] = w * size.height() + w2 * (size.height() / 2); -} - -void QVideoSurfaceGLPainter::initYv12TextureInfo(const QSize &size) -{ - int w = (size.width() + 3) & ~3; - int w2 = (size.width()/2 + 3) & ~3; - - m_yuv = true; - m_textureInternalFormat = GL_LUMINANCE; - m_textureFormat = GL_LUMINANCE; - m_textureType = GL_UNSIGNED_BYTE; - m_textureCount = 3; - m_textureWidths[0] = size.width(); - m_textureHeights[0] = size.height(); - m_textureOffsets[0] = 0; - m_textureWidths[1] = size.width() / 2; - m_textureHeights[1] = size.height() / 2; - m_textureOffsets[1] = w * size.height() + w2 * (size.height() / 2); - m_textureWidths[2] = size.width() / 2; - m_textureHeights[2] = size.height() / 2; - m_textureOffsets[2] = w * size.height(); -} - -#ifndef QT_OPENGL_ES - -# ifndef GL_FRAGMENT_PROGRAM_ARB -# define GL_FRAGMENT_PROGRAM_ARB 0x8804 -# define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -# endif - -// Paints an RGB32 frame -static const char *qt_arbfp_xrgbShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP xrgb;\n" - "TEX xrgb.xyz, fragment.texcoord[0], texture[0], 2D;\n" - "MOV xrgb.w, matrix[3].w;\n" - "DP4 result.color.x, xrgb.zyxw, matrix[0];\n" - "DP4 result.color.y, xrgb.zyxw, matrix[1];\n" - "DP4 result.color.z, xrgb.zyxw, matrix[2];\n" - "END"; - -// Paints an ARGB frame. -static const char *qt_arbfp_argbShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP argb;\n" - "TEX argb, fragment.texcoord[0], texture[0], 2D;\n" - "MOV argb.w, matrix[3].w;\n" - "DP4 result.color.x, argb.zyxw, matrix[0];\n" - "DP4 result.color.y, argb.zyxw, matrix[1];\n" - "DP4 result.color.z, argb.zyxw, matrix[2];\n" - "TEX result.color.w, fragment.texcoord[0], texture, 2D;\n" - "END"; - -// Paints an RGB(A) frame. -static const char *qt_arbfp_rgbShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP rgb;\n" - "TEX rgb, fragment.texcoord[0], texture[0], 2D;\n" - "MOV rgb.w, matrix[3].w;\n" - "DP4 result.color.x, rgb, matrix[0];\n" - "DP4 result.color.y, rgb, matrix[1];\n" - "DP4 result.color.z, rgb, matrix[2];\n" - "TEX result.color.w, fragment.texcoord[0], texture, 2D;\n" - "END"; - -// Paints a YUV420P or YV12 frame. -static const char *qt_arbfp_yuvPlanarShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP yuv;\n" - "TEX yuv.x, fragment.texcoord[0], texture[0], 2D;\n" - "TEX yuv.y, fragment.texcoord[0], texture[1], 2D;\n" - "TEX yuv.z, fragment.texcoord[0], texture[2], 2D;\n" - "MOV yuv.w, matrix[3].w;\n" - "DP4 result.color.x, yuv, matrix[0];\n" - "DP4 result.color.y, yuv, matrix[1];\n" - "DP4 result.color.z, yuv, matrix[2];\n" - "END"; - -// Paints a YUV444 frame. -static const char *qt_arbfp_xyuvShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP ayuv;\n" - "TEX ayuv, fragment.texcoord[0], texture[0], 2D;\n" - "MOV ayuv.x, matrix[3].w;\n" - "DP4 result.color.x, ayuv.yzwx, matrix[0];\n" - "DP4 result.color.y, ayuv.yzwx, matrix[1];\n" - "DP4 result.color.z, ayuv.yzwx, matrix[2];\n" - "END"; - -// Paints a AYUV444 frame. -static const char *qt_arbfp_ayuvShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP ayuv;\n" - "TEX ayuv, fragment.texcoord[0], texture[0], 2D;\n" - "MOV ayuv.x, matrix[3].w;\n" - "DP4 result.color.x, ayuv.yzwx, matrix[0];\n" - "DP4 result.color.y, ayuv.yzwx, matrix[1];\n" - "DP4 result.color.z, ayuv.yzwx, matrix[2];\n" - "TEX result.color.w, fragment.texcoord[0], texture, 2D;\n" - "END"; - -class QVideoSurfaceArbFpPainter : public QVideoSurfaceGLPainter -{ -public: - QVideoSurfaceArbFpPainter(QGLContext *context); - - QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); - void stop(); - - QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source); - -private: - typedef void (APIENTRY *_glProgramStringARB) (GLenum, GLenum, GLsizei, const GLvoid *); - typedef void (APIENTRY *_glBindProgramARB) (GLenum, GLuint); - typedef void (APIENTRY *_glDeleteProgramsARB) (GLsizei, const GLuint *); - typedef void (APIENTRY *_glGenProgramsARB) (GLsizei, GLuint *); - typedef void (APIENTRY *_glProgramLocalParameter4fARB) ( - GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); - typedef void (APIENTRY *_glActiveTexture) (GLenum); - - _glProgramStringARB glProgramStringARB; - _glBindProgramARB glBindProgramARB; - _glDeleteProgramsARB glDeleteProgramsARB; - _glGenProgramsARB glGenProgramsARB; - _glProgramLocalParameter4fARB glProgramLocalParameter4fARB; - - GLuint m_programId; - QSize m_frameSize; -}; - -QVideoSurfaceArbFpPainter::QVideoSurfaceArbFpPainter(QGLContext *context) - : QVideoSurfaceGLPainter(context) - , m_programId(0) -{ - glProgramStringARB = (_glProgramStringARB) m_context->getProcAddress( - QLatin1String("glProgramStringARB")); - glBindProgramARB = (_glBindProgramARB) m_context->getProcAddress( - QLatin1String("glBindProgramARB")); - glDeleteProgramsARB = (_glDeleteProgramsARB) m_context->getProcAddress( - QLatin1String("glDeleteProgramsARB")); - glGenProgramsARB = (_glGenProgramsARB) m_context->getProcAddress( - QLatin1String("glGenProgramsARB")); - glProgramLocalParameter4fARB = (_glProgramLocalParameter4fARB) m_context->getProcAddress( - QLatin1String("glProgramLocalParameter4fARB")); - - m_imagePixelFormats - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_BGR32 - << QVideoFrame::Format_ARGB32 - << QVideoFrame::Format_RGB24 - << QVideoFrame::Format_BGR24 - << QVideoFrame::Format_RGB565 - << QVideoFrame::Format_AYUV444 - << QVideoFrame::Format_YUV444 - << QVideoFrame::Format_YV12 - << QVideoFrame::Format_YUV420P; - m_glPixelFormats - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_ARGB32; -} - -QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfaceFormat &format) -{ - Q_ASSERT(m_textureCount == 0); - - QAbstractVideoSurface::Error error = QAbstractVideoSurface::NoError; - - m_context->makeCurrent(); - - const char *program = 0; - - if (format.handleType() == QAbstractVideoBuffer::NoHandle) { - switch (format.pixelFormat()) { - case QVideoFrame::Format_RGB32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_xrgbShaderProgram; - break; - case QVideoFrame::Format_BGR32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_rgbShaderProgram; - break; - case QVideoFrame::Format_ARGB32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_argbShaderProgram; - break; - case QVideoFrame::Format_RGB24: - initRgbTextureInfo(GL_RGB8, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_rgbShaderProgram; - break; - case QVideoFrame::Format_BGR24: - initRgbTextureInfo(GL_RGB8, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_xrgbShaderProgram; - break; - case QVideoFrame::Format_RGB565: - initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, format.frameSize()); - program = qt_arbfp_rgbShaderProgram; - break; - case QVideoFrame::Format_YUV444: - initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_xyuvShaderProgram; - m_yuv = true; - break; - case QVideoFrame::Format_AYUV444: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_ayuvShaderProgram; - m_yuv = true; - break; - case QVideoFrame::Format_YV12: - initYv12TextureInfo(format.frameSize()); - program = qt_arbfp_yuvPlanarShaderProgram; - break; - case QVideoFrame::Format_YUV420P: - initYuv420PTextureInfo(format.frameSize()); - program = qt_arbfp_yuvPlanarShaderProgram; - break; - default: - break; - } - } else if (format.handleType() == QAbstractVideoBuffer::GLTextureHandle) { - switch (format.pixelFormat()) { - case QVideoFrame::Format_RGB32: - case QVideoFrame::Format_ARGB32: - m_yuv = false; - m_textureCount = 1; - program = qt_arbfp_rgbShaderProgram; - break; - default: - break; - } - } - - if (!program) { - error = QAbstractVideoSurface::UnsupportedFormatError; - } else { - glGenProgramsARB(1, &m_programId); - - GLenum glError = glGetError(); - if (glError != GL_NO_ERROR) { - qWarning("QPainterVideoSurface: ARBfb Shader allocation error %x", int(glError)); - m_textureCount = 0; - m_programId = 0; - - error = QAbstractVideoSurface::ResourceError; - } else { - glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_programId); - glProgramStringARB( - GL_FRAGMENT_PROGRAM_ARB, - GL_PROGRAM_FORMAT_ASCII_ARB, - qstrlen(program), - reinterpret_cast<const GLvoid *>(program)); - - if ((glError = glGetError()) != GL_NO_ERROR) { - const GLubyte* errorString = glGetString(GL_PROGRAM_ERROR_STRING_ARB); - - qWarning("QPainterVideoSurface: ARBfp Shader compile error %x, %s", - int(glError), - reinterpret_cast<const char *>(errorString)); - glDeleteProgramsARB(1, &m_programId); - - m_textureCount = 0; - m_programId = 0; - - error = QAbstractVideoSurface::ResourceError; - } else { - m_handleType = format.handleType(); - m_scanLineDirection = format.scanLineDirection(); - m_frameSize = format.frameSize(); - - if (m_handleType == QAbstractVideoBuffer::NoHandle) - glGenTextures(m_textureCount, m_textureIds); - } - } - } - - return error; -} - -void QVideoSurfaceArbFpPainter::stop() -{ - m_context->makeCurrent(); - - if (m_handleType != QAbstractVideoBuffer::GLTextureHandle) - glDeleteTextures(m_textureCount, m_textureIds); - glDeleteProgramsARB(1, &m_programId); - - m_textureCount = 0; - m_programId = 0; - m_handleType = QAbstractVideoBuffer::NoHandle; -} - -QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::paint( - const QRectF &target, QPainter *painter, const QRectF &source) -{ - if (m_frame.isValid()) { - bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); - bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); - - painter->beginNativePainting(); - - if (stencilTestEnabled) - glEnable(GL_STENCIL_TEST); - if (scissorTestEnabled) - glEnable(GL_SCISSOR_TEST); - - const float txLeft = source.left() / m_frameSize.width(); - const float txRight = source.right() / m_frameSize.width(); - const float txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.top() / m_frameSize.height() - : source.bottom() / m_frameSize.height(); - const float txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.bottom() / m_frameSize.height() - : source.top() / m_frameSize.height(); - - - const float tx_array[] = - { - txLeft , txBottom, - txRight, txBottom, - txLeft , txTop, - txRight, txTop - }; - const float v_array[] = - { - float(target.left()) , float(target.bottom() + 1), - float(target.right() + 1), float(target.bottom() + 1), - float(target.left()) , float(target.top()), - float(target.right() + 1), float(target.top()) - }; - - glEnable(GL_FRAGMENT_PROGRAM_ARB); - glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_programId); - - glProgramLocalParameter4fARB( - GL_FRAGMENT_PROGRAM_ARB, - 0, - m_colorMatrix(0, 0), - m_colorMatrix(0, 1), - m_colorMatrix(0, 2), - m_colorMatrix(0, 3)); - glProgramLocalParameter4fARB( - GL_FRAGMENT_PROGRAM_ARB, - 1, - m_colorMatrix(1, 0), - m_colorMatrix(1, 1), - m_colorMatrix(1, 2), - m_colorMatrix(1, 3)); - glProgramLocalParameter4fARB( - GL_FRAGMENT_PROGRAM_ARB, - 2, - m_colorMatrix(2, 0), - m_colorMatrix(2, 1), - m_colorMatrix(2, 2), - m_colorMatrix(2, 3)); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, m_textureIds[0]); - - if (m_textureCount == 3) { - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, m_textureIds[1]); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, m_textureIds[2]); - glActiveTexture(GL_TEXTURE0); - } - - glVertexPointer(2, GL_FLOAT, 0, v_array); - glTexCoordPointer(2, GL_FLOAT, 0, tx_array); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - glDisable(GL_FRAGMENT_PROGRAM_ARB); - - painter->endNativePainting(); - } - return QAbstractVideoSurface::NoError; -} - -#endif - -static const char *qt_glsl_vertexShaderProgram = - "attribute highp vec4 vertexCoordArray;\n" - "attribute highp vec2 textureCoordArray;\n" - "uniform highp mat4 positionMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " gl_Position = positionMatrix * vertexCoordArray;\n" - " textureCoord = textureCoordArray;\n" - "}\n"; - -// Paints an RGB32 frame -static const char *qt_glsl_xrgbShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).bgr, 1.0);\n" - " gl_FragColor = colorMatrix * color;\n" - "}\n"; - -// Paints an ARGB frame. -static const char *qt_glsl_argbShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).bgr, 1.0);\n" - " color = colorMatrix * color;\n" - " gl_FragColor = vec4(color.rgb, texture2D(texRgb, textureCoord.st).a);\n" - "}\n"; - -// Paints an RGB(A) frame. -static const char *qt_glsl_rgbShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).rgb, 1.0);\n" - " color = colorMatrix * color;\n" - " gl_FragColor = vec4(color.rgb, texture2D(texRgb, textureCoord.st).a);\n" - "}\n"; - -// Paints a YUV420P or YV12 frame. -static const char *qt_glsl_yuvPlanarShaderProgram = - "uniform sampler2D texY;\n" - "uniform sampler2D texU;\n" - "uniform sampler2D texV;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(\n" - " texture2D(texY, textureCoord.st).r,\n" - " texture2D(texU, textureCoord.st).r,\n" - " texture2D(texV, textureCoord.st).r,\n" - " 1.0);\n" - " gl_FragColor = colorMatrix * color;\n" - "}\n"; - -// Paints a YUV444 frame. -static const char *qt_glsl_xyuvShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).gba, 1.0);\n" - " gl_FragColor = colorMatrix * color;\n" - "}\n"; - -// Paints a AYUV444 frame. -static const char *qt_glsl_ayuvShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).gba, 1.0);\n" - " color = colorMatrix * color;\n" - " gl_FragColor = vec4(color.rgb, texture2D(texRgb, textureCoord.st).r);\n" - "}\n"; - -class QVideoSurfaceGlslPainter : public QVideoSurfaceGLPainter -{ -public: - QVideoSurfaceGlslPainter(QGLContext *context); - - QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); - void stop(); - - QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source); - -private: - QGLShaderProgram m_program; - QSize m_frameSize; -}; - -QVideoSurfaceGlslPainter::QVideoSurfaceGlslPainter(QGLContext *context) - : QVideoSurfaceGLPainter(context) - , m_program(context) -{ - m_imagePixelFormats - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_BGR32 - << QVideoFrame::Format_ARGB32 -#ifndef QT_OPENGL_ES - << QVideoFrame::Format_RGB24 - << QVideoFrame::Format_BGR24 -#endif - << QVideoFrame::Format_RGB565 - << QVideoFrame::Format_YUV444 - << QVideoFrame::Format_AYUV444 - << QVideoFrame::Format_YV12 - << QVideoFrame::Format_YUV420P; - m_glPixelFormats - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_ARGB32; -} - -QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurfaceFormat &format) -{ - Q_ASSERT(m_textureCount == 0); - - QAbstractVideoSurface::Error error = QAbstractVideoSurface::NoError; - - m_context->makeCurrent(); - - const char *fragmentProgram = 0; - - if (format.handleType() == QAbstractVideoBuffer::NoHandle) { - switch (format.pixelFormat()) { - case QVideoFrame::Format_RGB32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_xrgbShaderProgram; - break; - case QVideoFrame::Format_BGR32: - initRgbTextureInfo(GL_RGB, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_rgbShaderProgram; - break; - case QVideoFrame::Format_ARGB32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_argbShaderProgram; - break; -#ifndef QT_OPENGL_ES - case QVideoFrame::Format_RGB24: - initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_rgbShaderProgram; - break; - case QVideoFrame::Format_BGR24: - initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_argbShaderProgram; - break; -#endif - case QVideoFrame::Format_RGB565: - initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, format.frameSize()); - fragmentProgram = qt_glsl_rgbShaderProgram; - break; - case QVideoFrame::Format_YUV444: - initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_xyuvShaderProgram; - m_yuv = true; - break; - case QVideoFrame::Format_AYUV444: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_ayuvShaderProgram; - m_yuv = true; - break; - case QVideoFrame::Format_YV12: - initYv12TextureInfo(format.frameSize()); - fragmentProgram = qt_glsl_yuvPlanarShaderProgram; - break; - case QVideoFrame::Format_YUV420P: - initYuv420PTextureInfo(format.frameSize()); - fragmentProgram = qt_glsl_yuvPlanarShaderProgram; - break; - default: - break; - } - } else if (format.handleType() == QAbstractVideoBuffer::GLTextureHandle) { - switch (format.pixelFormat()) { - case QVideoFrame::Format_RGB32: - case QVideoFrame::Format_ARGB32: - m_yuv = false; - m_textureCount = 1; - fragmentProgram = qt_glsl_rgbShaderProgram; - break; - default: - break; - } - } - - if (!fragmentProgram) { - error = QAbstractVideoSurface::UnsupportedFormatError; - } else if (!m_program.addShaderFromSourceCode(QGLShader::Vertex, qt_glsl_vertexShaderProgram)) { - qWarning("QPainterVideoSurface: Vertex shader compile error %s", - qPrintable(m_program.log())); - error = QAbstractVideoSurface::ResourceError; - } else if (!m_program.addShaderFromSourceCode(QGLShader::Fragment, fragmentProgram)) { - qWarning("QPainterVideoSurface: Shader compile error %s", qPrintable(m_program.log())); - error = QAbstractVideoSurface::ResourceError; - m_program.removeAllShaders(); - } else if(!m_program.link()) { - qWarning("QPainterVideoSurface: Shader link error %s", qPrintable(m_program.log())); - m_program.removeAllShaders(); - error = QAbstractVideoSurface::ResourceError; - } else { - m_handleType = format.handleType(); - m_scanLineDirection = format.scanLineDirection(); - m_frameSize = format.frameSize(); - - if (m_handleType == QAbstractVideoBuffer::NoHandle) - glGenTextures(m_textureCount, m_textureIds); - } - - return error; -} - -void QVideoSurfaceGlslPainter::stop() -{ - m_context->makeCurrent(); - - if (m_handleType != QAbstractVideoBuffer::GLTextureHandle) - glDeleteTextures(m_textureCount, m_textureIds); - m_program.removeAllShaders(); - - m_textureCount = 0; - m_handleType = QAbstractVideoBuffer::NoHandle; -} - -QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::paint( - const QRectF &target, QPainter *painter, const QRectF &source) -{ - if (m_frame.isValid()) { - bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); - bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); - - painter->beginNativePainting(); - - if (stencilTestEnabled) - glEnable(GL_STENCIL_TEST); - if (scissorTestEnabled) - glEnable(GL_SCISSOR_TEST); - - const int width = QGLContext::currentContext()->device()->width(); - const int height = QGLContext::currentContext()->device()->height(); - - const QTransform transform = painter->deviceTransform(); - - const GLfloat wfactor = 2.0 / width; - const GLfloat hfactor = -2.0 / height; - - const GLfloat positionMatrix[4][4] = - { - { - /*(0,0)*/ GLfloat(wfactor * transform.m11() - transform.m13()), - /*(0,1)*/ GLfloat(hfactor * transform.m12() + transform.m13()), - /*(0,2)*/ 0.0, - /*(0,3)*/ GLfloat(transform.m13()) - }, { - /*(1,0)*/ GLfloat(wfactor * transform.m21() - transform.m23()), - /*(1,1)*/ GLfloat(hfactor * transform.m22() + transform.m23()), - /*(1,2)*/ 0.0, - /*(1,3)*/ GLfloat(transform.m23()) - }, { - /*(2,0)*/ 0.0, - /*(2,1)*/ 0.0, - /*(2,2)*/ -1.0, - /*(2,3)*/ 0.0 - }, { - /*(3,0)*/ GLfloat(wfactor * transform.dx() - transform.m33()), - /*(3,1)*/ GLfloat(hfactor * transform.dy() + transform.m33()), - /*(3,2)*/ 0.0, - /*(3,3)*/ GLfloat(transform.m33()) - } - }; - - const GLfloat vertexCoordArray[] = - { - GLfloat(target.left()) , GLfloat(target.bottom() + 1), - GLfloat(target.right() + 1), GLfloat(target.bottom() + 1), - GLfloat(target.left()) , GLfloat(target.top()), - GLfloat(target.right() + 1), GLfloat(target.top()) - }; - - const GLfloat txLeft = source.left() / m_frameSize.width(); - const GLfloat txRight = source.right() / m_frameSize.width(); - const GLfloat txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.top() / m_frameSize.height() - : source.bottom() / m_frameSize.height(); - const GLfloat txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.bottom() / m_frameSize.height() - : source.top() / m_frameSize.height(); - - const GLfloat textureCoordArray[] = - { - txLeft , txBottom, - txRight, txBottom, - txLeft , txTop, - txRight, txTop - }; - - m_program.bind(); - - m_program.enableAttributeArray("vertexCoordArray"); - m_program.enableAttributeArray("textureCoordArray"); - m_program.setAttributeArray("vertexCoordArray", vertexCoordArray, 2); - m_program.setAttributeArray("textureCoordArray", textureCoordArray, 2); - m_program.setUniformValue("positionMatrix", positionMatrix); - - if (m_textureCount == 3) { - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, m_textureIds[0]); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, m_textureIds[1]); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, m_textureIds[2]); - glActiveTexture(GL_TEXTURE0); - - m_program.setUniformValue("texY", GLint(0)); - m_program.setUniformValue("texU", GLint(1)); - m_program.setUniformValue("texV", GLint(2)); - } else { - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, m_textureIds[0]); - - m_program.setUniformValue("texRgb", GLint(0)); - } - m_program.setUniformValue("colorMatrix", m_colorMatrix); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - m_program.release(); - - painter->endNativePainting(); - } - return QAbstractVideoSurface::NoError; -} - -#endif - -/*! - \class QPainterVideoSurface - \internal -*/ - -/*! -*/ -QPainterVideoSurface::QPainterVideoSurface(QObject *parent) - : QAbstractVideoSurface(parent) - , m_painter(0) -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - , m_glContext(0) - , m_shaderTypes(NoShaders) - , m_shaderType(NoShaders) -#endif - , m_brightness(0) - , m_contrast(0) - , m_hue(0) - , m_saturation(0) - , m_pixelFormat(QVideoFrame::Format_Invalid) - , m_colorsDirty(true) - , m_ready(false) -{ -} - -/*! -*/ -QPainterVideoSurface::~QPainterVideoSurface() -{ - if (isActive()) - m_painter->stop(); - - delete m_painter; -} - -/*! -*/ -QList<QVideoFrame::PixelFormat> QPainterVideoSurface::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - if (!m_painter) - const_cast<QPainterVideoSurface *>(this)->createPainter(); - - return m_painter->supportedPixelFormats(handleType); -} - -/*! -*/ -bool QPainterVideoSurface::isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const -{ - if (!m_painter) - const_cast<QPainterVideoSurface *>(this)->createPainter(); - - return m_painter->isFormatSupported(format, similar); -} - -/*! -*/ -bool QPainterVideoSurface::start(const QVideoSurfaceFormat &format) -{ - if (isActive()) - m_painter->stop(); - - if (!m_painter) - createPainter(); - - if (format.frameSize().isEmpty()) { - setError(UnsupportedFormatError); - } else { - QAbstractVideoSurface::Error error = m_painter->start(format); - - if (error != QAbstractVideoSurface::NoError) { - setError(error); - } else { - m_pixelFormat = format.pixelFormat(); - m_frameSize = format.frameSize(); - m_sourceRect = format.viewport(); - m_colorsDirty = true; - m_ready = true; - - return QAbstractVideoSurface::start(format); - } - } - - QAbstractVideoSurface::stop(); - - return false; -} - -/*! -*/ -void QPainterVideoSurface::stop() -{ - if (isActive()) { - m_painter->stop(); - m_ready = false; - - QAbstractVideoSurface::stop(); - } -} - -/*! -*/ -bool QPainterVideoSurface::present(const QVideoFrame &frame) -{ - if (!m_ready) { - if (!isActive()) - setError(StoppedError); - } else if (frame.isValid() - && (frame.pixelFormat() != m_pixelFormat || frame.size() != m_frameSize)) { - setError(IncorrectFormatError); - - stop(); - } else { - QAbstractVideoSurface::Error error = m_painter->setCurrentFrame(frame); - - if (error != QAbstractVideoSurface::NoError) { - setError(error); - - stop(); - } else { - m_ready = false; - - emit frameChanged(); - - return true; - } - } - return false; -} - -/*! -*/ -int QPainterVideoSurface::brightness() const -{ - return m_brightness; -} - -/*! -*/ -void QPainterVideoSurface::setBrightness(int brightness) -{ - m_brightness = brightness; - - m_colorsDirty = true; -} - -/*! -*/ -int QPainterVideoSurface::contrast() const -{ - return m_contrast; -} - -/*! -*/ -void QPainterVideoSurface::setContrast(int contrast) -{ - m_contrast = contrast; - - m_colorsDirty = true; -} - -/*! -*/ -int QPainterVideoSurface::hue() const -{ - return m_hue; -} - -/*! -*/ -void QPainterVideoSurface::setHue(int hue) -{ - m_hue = hue; - - m_colorsDirty = true; -} - -/*! -*/ -int QPainterVideoSurface::saturation() const -{ - return m_saturation; -} - -/*! -*/ -void QPainterVideoSurface::setSaturation(int saturation) -{ - m_saturation = saturation; - - m_colorsDirty = true; -} - -/*! -*/ -bool QPainterVideoSurface::isReady() const -{ - return m_ready; -} - -/*! -*/ -void QPainterVideoSurface::setReady(bool ready) -{ - m_ready = ready; -} - -/*! -*/ -void QPainterVideoSurface::paint(QPainter *painter, const QRectF &target, const QRectF &source) -{ - if (!isActive()) { - painter->fillRect(target, QBrush(Qt::black)); - } else { - if (m_colorsDirty) { - m_painter->updateColors(m_brightness, m_contrast, m_hue, m_saturation); - m_colorsDirty = false; - } - - const QRectF sourceRect( - m_sourceRect.x() + m_sourceRect.width() * source.x(), - m_sourceRect.y() + m_sourceRect.height() * source.y(), - m_sourceRect.width() * source.width(), - m_sourceRect.height() * source.height()); - - QAbstractVideoSurface::Error error = m_painter->paint(target, painter, sourceRect); - - if (error != QAbstractVideoSurface::NoError) { - setError(error); - - stop(); - } - } -} - -/*! - \fn QPainterVideoSurface::frameChanged() -*/ - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - -/*! -*/ -const QGLContext *QPainterVideoSurface::glContext() const -{ - return m_glContext; -} - -/*! -*/ -void QPainterVideoSurface::setGLContext(QGLContext *context) -{ - if (m_glContext == context) - return; - - m_glContext = context; - - m_shaderTypes = NoShaders; - - if (m_glContext) { - m_glContext->makeCurrent(); - - const QByteArray extensions(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS))); -#ifndef QT_OPENGL_ES - - if (extensions.contains("ARB_fragment_program")) - m_shaderTypes |= FragmentProgramShader; -#endif - - if (QGLShaderProgram::hasOpenGLShaderPrograms(m_glContext) - && extensions.contains("ARB_shader_objects")) - m_shaderTypes |= GlslShader; - } - - ShaderType type = (m_shaderType & m_shaderTypes) - ? m_shaderType - : NoShaders; - - if (type != m_shaderType || type != NoShaders) { - m_shaderType = type; - - if (isActive()) { - m_painter->stop(); - delete m_painter; - m_painter = 0; - m_ready = false; - - setError(ResourceError); - QAbstractVideoSurface::stop(); - } - emit supportedFormatsChanged(); - } -} - -/*! - \enum QPainterVideoSurface::ShaderType - - \value NoShaders - \value FragmentProgramShader - \value HlslShader -*/ - -/*! - \typedef QPainterVideoSurface::ShaderTypes -*/ - -/*! -*/ -QPainterVideoSurface::ShaderTypes QPainterVideoSurface::supportedShaderTypes() const -{ - return m_shaderTypes; -} - -/*! -*/ -QPainterVideoSurface::ShaderType QPainterVideoSurface::shaderType() const -{ - return m_shaderType; -} - -/*! -*/ -void QPainterVideoSurface::setShaderType(ShaderType type) -{ - if (!(type & m_shaderTypes)) - type = NoShaders; - - if (type != m_shaderType) { - m_shaderType = type; - - if (isActive()) { - m_painter->stop(); - delete m_painter; - m_painter = 0; - m_ready = false; - - setError(ResourceError); - QAbstractVideoSurface::stop(); - } else { - delete m_painter; - m_painter = 0; - } - emit supportedFormatsChanged(); - } -} - -#endif - -void QPainterVideoSurface::createPainter() -{ - Q_ASSERT(!m_painter); - -#ifdef Q_WS_MAC - if (m_glContext) - m_glContext->makeCurrent(); - - m_painter = new QVideoSurfaceCoreGraphicsPainter(m_glContext != 0); - return; -#endif - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - switch (m_shaderType) { -#ifndef QT_OPENGL_ES - case FragmentProgramShader: - Q_ASSERT(m_glContext); - m_glContext->makeCurrent(); - m_painter = new QVideoSurfaceArbFpPainter(m_glContext); - break; -#endif - case GlslShader: - Q_ASSERT(m_glContext); - m_glContext->makeCurrent(); - m_painter = new QVideoSurfaceGlslPainter(m_glContext); - break; - default: - m_painter = new QVideoSurfaceRasterPainter; - break; - } -#else - m_painter = new QVideoSurfaceRasterPainter; -#endif -} - -QT_END_NAMESPACE - -#include "moc_qpaintervideosurface_p.cpp" - - diff --git a/src/multimedia/mediaservices/base/qpaintervideosurface_mac.mm b/src/multimedia/mediaservices/base/qpaintervideosurface_mac.mm deleted file mode 100644 index 1154f86..0000000 --- a/src/multimedia/mediaservices/base/qpaintervideosurface_mac.mm +++ /dev/null @@ -1,283 +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 QtMultimedia module 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 "qpaintervideosurface_mac_p.h" - -#include <QtCore/qdatetime.h> - -#include <qmath.h> - -#include <qpainter.h> -#include <qvariant.h> -#include <QtMultimedia/qvideosurfaceformat.h> - -#include <QtDebug> - -#include <QuartzCore/CIContext.h> -#include <CGLCurrent.h> -#include <gl.h> - -QT_BEGIN_NAMESPACE - -extern CGContextRef qt_mac_cg_context(const QPaintDevice *pdev); //qpaintdevice_mac.cpp - -QVideoSurfaceCoreGraphicsPainter::QVideoSurfaceCoreGraphicsPainter(bool glSupported) - : ciContext(0) - , m_imageFormat(QImage::Format_Invalid) - , m_scanLineDirection(QVideoSurfaceFormat::TopToBottom) -{ - //qDebug() << "QVideoSurfaceCoreGraphicsPainter, GL supported:" << glSupported; - ciContext = 0; - m_imagePixelFormats - << QVideoFrame::Format_RGB32; - - m_supportedHandles - << QAbstractVideoBuffer::NoHandle - << QAbstractVideoBuffer::CoreImageHandle; - - if (glSupported) - m_supportedHandles << QAbstractVideoBuffer::GLTextureHandle; -} - -QVideoSurfaceCoreGraphicsPainter::~QVideoSurfaceCoreGraphicsPainter() -{ - [(CIContext*)ciContext release]; -} - -QList<QVideoFrame::PixelFormat> QVideoSurfaceCoreGraphicsPainter::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - return m_supportedHandles.contains(handleType) - ? m_imagePixelFormats - : QList<QVideoFrame::PixelFormat>(); -} - -bool QVideoSurfaceCoreGraphicsPainter::isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *) const -{ - return m_supportedHandles.contains(format.handleType()) - && m_imagePixelFormats.contains(format.pixelFormat()) - && !format.frameSize().isEmpty(); -} - -QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::start(const QVideoSurfaceFormat &format) -{ - m_frame = QVideoFrame(); - m_imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); - m_imageSize = format.frameSize(); - m_scanLineDirection = format.scanLineDirection(); - - return m_supportedHandles.contains(format.handleType()) - && m_imageFormat != QImage::Format_Invalid - && !m_imageSize.isEmpty() - ? QAbstractVideoSurface::NoError - : QAbstractVideoSurface::UnsupportedFormatError; -} - -void QVideoSurfaceCoreGraphicsPainter::stop() -{ - m_frame = QVideoFrame(); -} - -QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::setCurrentFrame(const QVideoFrame &frame) -{ - m_frame = frame; - - return QAbstractVideoSurface::NoError; -} - -QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::paint( - const QRectF &target, QPainter *painter, const QRectF &source) -{ - if (m_frame.handleType() == QAbstractVideoBuffer::CoreImageHandle) { - if (painter->paintEngine()->type() == QPaintEngine::CoreGraphics ) { - - CIImage *img = (CIImage*)(m_frame.handle().value<void*>()); - - if (img) { - CGContextRef cgContext = qt_mac_cg_context(painter->device()); - - if (cgContext) { - painter->beginNativePainting(); - - CGRect sRect = CGRectMake(source.x(), source.y(), source.width(), source.height()); - CGRect dRect = CGRectMake(target.x(), target.y(), target.width(), target.height()); - - NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithCIImage:img]; - - if (m_scanLineDirection == QVideoSurfaceFormat::TopToBottom) { - CGContextSaveGState( cgContext ); - CGContextTranslateCTM(cgContext, 0, dRect.origin.y + CGRectGetMaxY(dRect)); - CGContextScaleCTM(cgContext, 1, -1); - -#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4) - if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_4) { - CGContextDrawImage(cgContext, dRect, [bitmap CGImage]); - } -#endif - - CGContextRestoreGState(cgContext); - } else { -#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4) - if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_4) { - CGContextDrawImage(cgContext, dRect, [bitmap CGImage]); - } -#endif - } - - [bitmap release]; - - painter->endNativePainting(); - - return QAbstractVideoSurface::NoError; - } - } - } else if (painter->paintEngine()->type() == QPaintEngine::OpenGL2 || - painter->paintEngine()->type() == QPaintEngine::OpenGL) { - CIImage *img = (CIImage*)(m_frame.handle().value<void*>()); - - if (img) { - CGLContextObj cglContext = CGLGetCurrentContext(); - - if (cglContext) { - - if (!ciContext) { - CGLContextObj cglContext = CGLGetCurrentContext(); - NSOpenGLPixelFormat *nsglPixelFormat = [NSOpenGLView defaultPixelFormat]; - CGLPixelFormatObj cglPixelFormat = static_cast<CGLPixelFormatObj>([nsglPixelFormat CGLPixelFormatObj]); - - ciContext = [CIContext contextWithCGLContext:cglContext - pixelFormat:cglPixelFormat - options:nil]; - - [(CIContext*)ciContext retain]; - } - - CGRect sRect = CGRectMake(source.x(), source.y(), source.width(), source.height()); - CGRect dRect = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom ? - CGRectMake(target.x(), target.y()+target.height(), target.width(), -target.height()) : - CGRectMake(target.x(), target.y(), target.width(), target.height()); - - - painter->beginNativePainting(); - - [(CIContext*)ciContext drawImage:img inRect:dRect fromRect:sRect]; - - painter->endNativePainting(); - - return QAbstractVideoSurface::NoError; - } - } - } - } - - if (m_frame.handleType() == QAbstractVideoBuffer::GLTextureHandle && - (painter->paintEngine()->type() == QPaintEngine::OpenGL2 || - painter->paintEngine()->type() == QPaintEngine::OpenGL)) { - - painter->beginNativePainting(); - GLuint texture = m_frame.handle().toUInt(); - - glDisable(GL_CULL_FACE); - glEnable(GL_TEXTURE_2D); - - glBindTexture(GL_TEXTURE_2D, texture); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - const float txLeft = source.left() / m_frame.width(); - const float txRight = source.right() / m_frame.width(); - const float txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.top() / m_frame.height() - : source.bottom() / m_frame.height(); - const float txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.bottom() / m_frame.height() - : source.top() / m_frame.height(); - - glBegin(GL_QUADS); - QRectF rect = target; - glTexCoord2f(txLeft, txBottom); - glVertex2f(rect.topLeft().x(), rect.topLeft().y()); - glTexCoord2f(txRight, txBottom); - glVertex2f(rect.topRight().x() + 1, rect.topRight().y()); - glTexCoord2f(txRight, txTop); - glVertex2f(rect.bottomRight().x() + 1, rect.bottomRight().y() + 1); - glTexCoord2f(txLeft, txTop); - glVertex2f(rect.bottomLeft().x(), rect.bottomLeft().y() + 1); - glEnd(); - painter->endNativePainting(); - - return QAbstractVideoSurface::NoError; - } - - //fallback case, software rendering - if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { - QImage image( - m_frame.bits(), - m_imageSize.width(), - m_imageSize.height(), - m_frame.bytesPerLine(), - m_imageFormat); - - if (m_scanLineDirection == QVideoSurfaceFormat::BottomToTop) { - const QTransform oldTransform = painter->transform(); - - painter->scale(1, -1); - painter->translate(0, -target.bottom()); - painter->drawImage( - QRectF(target.x(), 0, target.width(), target.height()), image, source); - painter->setTransform(oldTransform); - } else { - painter->drawImage(target, image, source); - } - - m_frame.unmap(); - } else { - painter->fillRect(target, Qt::black); - } - return QAbstractVideoSurface::NoError; -} - -void QVideoSurfaceCoreGraphicsPainter::updateColors(int, int, int, int) -{ -} - -QT_END_NAMESPACE diff --git a/src/multimedia/mediaservices/base/qpaintervideosurface_mac_p.h b/src/multimedia/mediaservices/base/qpaintervideosurface_mac_p.h deleted file mode 100644 index 4f8a7a6..0000000 --- a/src/multimedia/mediaservices/base/qpaintervideosurface_mac_p.h +++ /dev/null @@ -1,100 +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 QtMediaServices module 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 QPAINTERVIDEOSURFACE_MAC_P_H -#define QPAINTERVIDEOSURFACE_MAC_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qpaintervideosurface_p.h" -#include <QtMultimedia/qvideosurfaceformat.h> -#include <QtMultimedia/qvideoframe.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QVideoSurfaceCoreGraphicsPainter : public QVideoSurfacePainter -{ -public: - QVideoSurfaceCoreGraphicsPainter(bool glSupported); - ~QVideoSurfaceCoreGraphicsPainter(); - - QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const; - - bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const; - - QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); - void stop(); - - QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame); - - QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source); - - void updateColors(int brightness, int contrast, int hue, int saturation); - -private: - void* ciContext; - QList<QVideoFrame::PixelFormat> m_imagePixelFormats; - QVideoFrame m_frame; - QSize m_imageSize; - QImage::Format m_imageFormat; - QVector<QAbstractVideoBuffer::HandleType> m_supportedHandles; - QVideoSurfaceFormat::Direction m_scanLineDirection; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qpaintervideosurface_p.h b/src/multimedia/mediaservices/base/qpaintervideosurface_p.h deleted file mode 100644 index 07b7e01..0000000 --- a/src/multimedia/mediaservices/base/qpaintervideosurface_p.h +++ /dev/null @@ -1,178 +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 QtMediaServices module 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 QPAINTERVIDEOSURFACE_P_H -#define QPAINTERVIDEOSURFACE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qsize.h> -#include <QtGui/qimage.h> -#include <QtGui/qmatrix4x4.h> -#include <QtGui/qpaintengine.h> -#include <QtMultimedia/qabstractvideosurface.h> -#include <QtMultimedia/qvideoframe.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGLContext; - -class QVideoSurfacePainter -{ -public: - virtual ~QVideoSurfacePainter(); - - virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const = 0; - - virtual bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const = 0; - - virtual QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format) = 0; - virtual void stop() = 0; - - virtual QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame) = 0; - - virtual QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source) = 0; - - virtual void updateColors(int brightness, int contrast, int hue, int saturation) = 0; -}; - -class Q_MEDIASERVICES_EXPORT QPainterVideoSurface : public QAbstractVideoSurface -{ - Q_OBJECT -public: - explicit QPainterVideoSurface(QObject *parent = 0); - ~QPainterVideoSurface(); - - QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; - - bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar = 0) const; - - bool start(const QVideoSurfaceFormat &format); - void stop(); - - bool present(const QVideoFrame &frame); - - 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); - - bool isReady() const; - void setReady(bool ready); - - void paint(QPainter *painter, const QRectF &target, const QRectF &source = QRectF(0, 0, 1, 1)); - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - const QGLContext *glContext() const; - void setGLContext(QGLContext *context); - - enum ShaderType - { - NoShaders = 0x00, - FragmentProgramShader = 0x01, - GlslShader = 0x02 - }; - - Q_DECLARE_FLAGS(ShaderTypes, ShaderType) - - ShaderTypes supportedShaderTypes() const; - - ShaderType shaderType() const; - void setShaderType(ShaderType type); -#endif - -Q_SIGNALS: - void frameChanged(); - -private: - void createPainter(); - - QVideoSurfacePainter *m_painter; -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - QGLContext *m_glContext; - ShaderTypes m_shaderTypes; - ShaderType m_shaderType; -#endif - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; - - QVideoFrame::PixelFormat m_pixelFormat; - QSize m_frameSize; - QRect m_sourceRect; - bool m_colorsDirty; - bool m_ready; -}; - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) -Q_DECLARE_OPERATORS_FOR_FLAGS(QPainterVideoSurface::ShaderTypes) -#endif - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qtmedianamespace.h b/src/multimedia/mediaservices/base/qtmedianamespace.h deleted file mode 100644 index 917c646..0000000 --- a/src/multimedia/mediaservices/base/qtmedianamespace.h +++ /dev/null @@ -1,194 +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 QtMediaServices module 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 QTMEDIANAMESPACE_H -#define QTMEDIANAMESPACE_H - -#include <QtCore/qpair.h> -#include <QtCore/qmetatype.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -namespace QtMediaServices -{ - enum MetaData - { - // Common - Title, - SubTitle, - Author, - Comment, - Description, - Category, - Genre, - Year, - Date, - UserRating, - Keywords, - Language, - Publisher, - Copyright, - ParentalRating, - RatingOrganisation, - - // Media - Size, - MediaType, - Duration, - - // Audio - AudioBitRate, - AudioCodec, - AverageLevel, - ChannelCount, - PeakValue, - SampleRate, - - // Music - AlbumTitle, - AlbumArtist, - ContributingArtist, - Composer, - Conductor, - Lyrics, - Mood, - TrackNumber, - TrackCount, - - CoverArtUrlSmall, - CoverArtUrlLarge, - - // Image/Video - Resolution, - PixelAspectRatio, - - // Video - VideoFrameRate, - VideoBitRate, - VideoCodec, - - PosterUrl, - - // Movie - ChapterNumber, - Director, - LeadPerformer, - Writer, - - // Photos - CameraManufacturer, - CameraModel, - Event, - Subject, - Orientation, - ExposureTime, - FNumber, - ExposureProgram, - ISOSpeedRatings, - ExposureBiasValue, - DateTimeOriginal, - DateTimeDigitized, - SubjectDistance, - MeteringMode, - LightSource, - Flash, - FocalLength, - ExposureMode, - WhiteBalance, - DigitalZoomRatio, - FocalLengthIn35mmFilm, - SceneCaptureType, - GainControl, - Contrast, - Saturation, - Sharpness, - DeviceSettingDescription, - - PosterImage, - CoverArtImage, - ThumbnailImage - - }; - - enum SupportEstimate - { - NotSupported, - MaybeSupported, - ProbablySupported, - PreferredService - }; - - enum EncodingQuality - { - VeryLowQuality, - LowQuality, - NormalQuality, - HighQuality, - VeryHighQuality - }; - - enum EncodingMode - { - ConstantQualityEncoding, - ConstantBitRateEncoding, - AverageBitRateEncoding, - TwoPassEncoding - }; - - enum AvailabilityError - { - NoError, - ServiceMissingError, - BusyError, - ResourceError - }; - -} - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qtmedianamespace.qdoc b/src/multimedia/mediaservices/base/qtmedianamespace.qdoc deleted file mode 100644 index 54b856f..0000000 --- a/src/multimedia/mediaservices/base/qtmedianamespace.qdoc +++ /dev/null @@ -1,214 +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 QtMultimedia module 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$ -** -****************************************************************************/ - -/*! - \namespace QtMediaServices - \ingroup multimedia-serv - - \brief The QtMediaServices namespace contains miscellaneous identifiers used - throughout the Qt Media Services library. -*/ - -/*! - \enum QtMediaServices::MetaData - - This enum provides identifiers for meta-data attributes. - - Common attributes - \value Title The title of the media. QString. - \value SubTitle The sub-title of the media. QString. - \value Author The authors of the media. QStringList. - \value Comment A user comment about the media. QString. - \value Description A description of the media. QString - \value Category The category of the media. QStringList. - \value Genre The genre of the media. QStringList. - \value Year The year of release of the media. int. - \value Date The date of the media. QDate. - \value UserRating A user rating of the media. int [0..100]. - \value Keywords A list of keywords describing the media. QStringList. - \value Language The language of media, as an ISO 639-2 code. - - \value Publisher The publisher of the media. QString. - \value Copyright The media's copyright notice. QString. - \value ParentalRating The parental rating of the media. QString. - \value RatingOrganisation The organisation responsible for the parental rating of the media. - QString. - - Media attributes - \value Size The size in bytes of the media. qint64 - \value MediaType The type of the media (audio, video, etc). QString. - \value Duration The duration in millseconds of the media. qint64. - - Audio attributes - \value AudioBitRate The bit rate of the media's audio stream in bits per second. int. - \value AudioCodec The codec of the media's audio stream. QString. - \value AverageLevel The average volume level of the media. int. - \value ChannelCount The number of channels in the media's audio stream. int. - \value PeakValue The peak volume of the media's audio stream. int - \value SampleRate The sample rate of the media's audio stream in hertz. int - - Music attributes - \value AlbumTitle The title of the album the media belongs to. QString. - \value AlbumArtist The principal artist of the album the media belongs to. QString. - \value ContributingArtist The artists contributing to the media. QStringList. - \value Composer The composer of the media. QStringList. - \value Conductor The conductor of the media. QString. - \value Lyrics The lyrics to the media. QString. - \value Mood The mood of the media. QString. - \value TrackNumber The track number of the media. int. - \value TrackCount The number of tracks on the album containing the media. int. - - \value CoverArtUrlSmall The URL of a small cover art image. QUrl. - \value CoverArtUrlLarge The URL of a large cover art image. QUrl. - \value CoverArtImage An embedded cover art image. QImage. - - Image and video attributes - \value Resolution The dimensions of an image or video. QSize. - \value PixelAspectRatio The pixel aspect ratio of an image or video. QSize. - - Video attributes - \value VideoFrameRate The frame rate of the media's video stream. qreal. - \value VideoBitRate The bit rate of the media's video stream in bits per second. int. - \value VideoCodec The codec of the media's video stream. QString. - - \value PosterUrl The URL of a poster image. QUrl. - \value PosterImage An embedded poster image. QImage. - - Movie attributes - \value ChapterNumber The chapter number of the media. int. - \value Director The director of the media. QString. - \value LeadPerformer The lead performer in the media. QStringList. - \value Writer The writer of the media. QStringList. - - Photo attributes. - \value CameraManufacturer The manufacturer of the camera used to capture the media. QString. - \value CameraModel The model of the camera used to capture the media. QString. - \value Event The event during which the media was captured. QString. - \value Subject The subject of the media. QString. - \value Orientation Orientation of image. - \value ExposureTime Exposure time, given in seconds. - \value FNumber The F Number. - \value ExposureProgram - The class of the program used by the camera to set exposure when the picture is taken. - \value ISOSpeedRatings - Indicates the ISO Speed and ISO Latitude of the camera or input device as specified in ISO 12232. - \value ExposureBiasValue - The exposure bias. - The unit is the APEX (Additive System of Photographic Exposure) setting. - \value DateTimeOriginal The date and time when the original image data was generated. - \value DateTimeDigitized The date and time when the image was stored as digital data. - \value SubjectDistance The distance to the subject, given in meters. - \value MeteringMode The metering mode. - \value LightSource - The kind of light source. - \value Flash - Status of flash when the image was shot. - \value FocalLength - The actual focal length of the lens, in mm. - \value ExposureMode - Indicates the exposure mode set when the image was shot. - \value WhiteBalance - Indicates the white balance mode set when the image was shot. - \value DigitalZoomRatio - Indicates the digital zoom ratio when the image was shot. - \value FocalLengthIn35mmFilm - Indicates the equivalent focal length assuming a 35mm film camera, in mm. - \value SceneCaptureType - Indicates the type of scene that was shot. - It can also be used to record the mode in which the image was shot. - \value GainControl - Indicates the degree of overall image gain adjustment. - \value Contrast - Indicates the direction of contrast processing applied by the camera when the image was shot. - \value Saturation - Indicates the direction of saturation processing applied by the camera when the image was shot. - \value Sharpness - Indicates the direction of sharpness processing applied by the camera when the image was shot. - \value DeviceSettingDescription - Exif tag, indicates information on the picture-taking conditions of a particular camera model. QString - - \value ThumbnailImage An embedded thumbnail image. QImage. -*/ - -/*! - \enum QtMediaServices::SupportEstimate - - Enumerates the levels of support a media service provider may have for a feature. - - \value NotSupported The feature is not supported. - \value MaybeSupported The feature may be supported. - \value ProbablySupported The feature is probably supported. - \value PreferredService The service is the preferred provider of a service. -*/ - -/*! - \enum QtMediaServices::EncodingQuality - - Enumerates quality encoding levels. - - \value VeryLowQuality - \value LowQuality - \value NormalQuality - \value HighQuality - \value VeryHighQuality -*/ - -/*! - \enum QtMediaServices::EncodingMode - - Enumerates encoding modes. - - \value ConstantQualityEncoding - \value ConstantBitRateEncoding - \value AverageBitRateEncoding - \value TwoPassEncoding -*/ - -/*! - \enum QtMediaServices::AvailabilityError - - Enumerates Service status errors. - - \value NoError - \value ServiceMissingError - \value ResourceError - \value BusyError -*/ diff --git a/src/multimedia/mediaservices/base/qvideodevicecontrol.cpp b/src/multimedia/mediaservices/base/qvideodevicecontrol.cpp deleted file mode 100644 index 30c56cf..0000000 --- a/src/multimedia/mediaservices/base/qvideodevicecontrol.cpp +++ /dev/null @@ -1,155 +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 QtMediaServices module 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 <QtMediaServices/qvideodevicecontrol.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoDeviceControl - \preliminary - \since 4.7 - \brief The QVideoDeviceControl class provides an video device selector media control. - \ingroup multimedia-serv - - The QVideoDeviceControl class provides descriptions of the video devices - available on a system and allows one to be selected as the endpoint of - a media service. - - The interface name of QVideoDeviceControl is \c com.nokia.Qt.VideoDeviceControl as - defined in QVideoDeviceControl_iid. -*/ - -/*! - \macro QVideoDeviceControl_iid - - \c com.nokia.Qt.VideoDeviceControl - - Defines the interface name of the QVideoDeviceControl class. - - \relates QVideoDeviceControl -*/ - -/*! - Constructs a video device control with the given \a parent. -*/ -QVideoDeviceControl::QVideoDeviceControl(QObject *parent) - :QMediaControl(parent) -{ -} - -/*! - Destroys a video device control. -*/ -QVideoDeviceControl::~QVideoDeviceControl() -{ -} - -/*! - \fn QVideoDeviceControl::deviceCount() const - - Returns the number of available video devices; -*/ - -/*! - \fn QVideoDeviceControl::deviceName(int index) const - - Returns the name of the video device at \a index. -*/ - -/*! - \fn QVideoDeviceControl::deviceDescription(int index) const - - Returns a description of the video device at \a index. -*/ - -/*! - \fn QVideoDeviceControl::deviceIcon(int index) const - - Returns an icon for the video device at \a index. -*/ - -/*! - \fn QVideoDeviceControl::defaultDevice() const - - Returns the index of the default video device. -*/ - -/*! - \fn QVideoDeviceControl::selectedDevice() const - - Returns the index of the selected video device. -*/ - -/*! - \fn QVideoDeviceControl::setSelectedDevice(int index) - - Sets the selected video device \a index. -*/ - -/*! - \fn QVideoDeviceControl::devicesChanged() - - Signals that the list of available video devices has changed. -*/ - -/*! - \fn QVideoDeviceControl::selectedDeviceChanged(int index) - - Signals that the selected video device \a index has changed. -*/ - -/*! - \fn QVideoDeviceControl::selectedDeviceChanged(const QString &name) - - Signals that the selected video device \a name has changed. -*/ - -QT_END_NAMESPACE - -QT_END_HEADER - -#include "moc_qvideodevicecontrol.cpp" - - diff --git a/src/multimedia/mediaservices/base/qvideodevicecontrol.h b/src/multimedia/mediaservices/base/qvideodevicecontrol.h deleted file mode 100644 index 0b9235b..0000000 --- a/src/multimedia/mediaservices/base/qvideodevicecontrol.h +++ /dev/null @@ -1,90 +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 QtMediaServices module 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 QVIDEODEVICECONTROL_H -#define QVIDEODEVICECONTROL_H - -#include <QtMediaServices/qmediacontrol.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class Q_MEDIASERVICES_EXPORT QVideoDeviceControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QVideoDeviceControl(); - - virtual int deviceCount() const = 0; - - virtual QString deviceName(int index) const = 0; - virtual QString deviceDescription(int index) const = 0; - virtual QIcon deviceIcon(int index) const = 0; - - virtual int defaultDevice() const = 0; - virtual int selectedDevice() const = 0; - -public Q_SLOTS: - virtual void setSelectedDevice(int index) = 0; - -Q_SIGNALS: - void selectedDeviceChanged(int index); - void selectedDeviceChanged(const QString &deviceName); - void devicesChanged(); - -protected: - QVideoDeviceControl(QObject *parent = 0); -}; - -#define QVideoDeviceControl_iid "com.nokia.Qt.QVideoDeviceControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoDeviceControl, QVideoDeviceControl_iid) - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QVIDEODEVICECONTROL_H diff --git a/src/multimedia/mediaservices/base/qvideooutputcontrol.cpp b/src/multimedia/mediaservices/base/qvideooutputcontrol.cpp deleted file mode 100644 index 532c892..0000000 --- a/src/multimedia/mediaservices/base/qvideooutputcontrol.cpp +++ /dev/null @@ -1,135 +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 QtMediaServices module 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 <QtMediaServices/qvideooutputcontrol.h> - - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoOutputControl - \preliminary - \since 4.7 - \brief The QVideoOutputControl class provides a means of selecting the - active video output control. - - \ingroup multimedia-serv - - There are multiple controls which a QMediaService may use to output - video ony one of which may be active at one time, QVideoOutputControl - is the means by which this active control is selected. - - The possible output controls are QVideoRendererControl, - QVideoWindowControl, and QVideoWidgetControl. - - The interface name of QVideoOutputControl is \c com.nokia.Qt.QVideoOutputControl/1.0 as - defined in QVideoOutputControl_iid. - - \sa QMediaService::control(), QVideoWidget, QVideoRendererControl, - QVideoWindowControl, QVideoWidgetControl -*/ - -/*! - \macro QVideoOutputControl_iid - - \c com.nokia.Qt.QVideoOutputControl/1.0 - - Defines the interface name of the QVideoOutputControl class. - - \relates QVideoOutputControl -*/ - -/*! - \enum QVideoOutputControl::Output - - Identifies the possible render targets of a video output. - - \value NoOutput Video is not rendered. - \value WindowOutput Video is rendered to the target of a QVideoWindowControl. - \value RendererOutput Video is rendered to the target of a QVideoRendererControl. - \value WidgetOutput Video is rendered to a QWidget provided by QVideoWidgetControl. - \value UserOutput Start value for user defined video targets. - \value MaxUserOutput End value for user defined video targets. -*/ - -/*! - Constructs a new video output control with the given \a parent. -*/ -QVideoOutputControl::QVideoOutputControl(QObject *parent) - : QMediaControl(parent) -{ -} - -/*! - Destroys a video output control. -*/ -QVideoOutputControl::~QVideoOutputControl() -{ -} - -/*! - \fn QList<QVideoOutputControl::Output> QVideoOutputControl::availableOutputs() const - - Returns a list of available video output targets. -*/ - -/*! - \fn QVideoOutputControl::output() const - - Returns the current video output target. -*/ - -/*! - \fn QVideoOutputControl::setOutput(Output output) - - Sets the current video \a output target. -*/ - -/*! - \fn QVideoOutputControl::availableOutputsChanged(const QList<QVideoOutputControl::Output> &outputs) - - Signals that available set of video \a outputs has changed. -*/ - -#include "moc_qvideooutputcontrol.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qvideooutputcontrol.h b/src/multimedia/mediaservices/base/qvideooutputcontrol.h deleted file mode 100644 index f87bb3c..0000000 --- a/src/multimedia/mediaservices/base/qvideooutputcontrol.h +++ /dev/null @@ -1,91 +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 QtMediaServices module 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 QVIDEOOUTPUTCONTROL_H -#define QVIDEOOUTPUTCONTROL_H - -#include <QtMediaServices/qmediacontrol.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MEDIASERVICES_EXPORT QVideoOutputControl : public QMediaControl -{ - Q_OBJECT - -public: - enum Output - { - NoOutput, - WindowOutput, - RendererOutput, - WidgetOutput, - UserOutput = 100, - MaxUserOutput = 1000 - }; - - ~QVideoOutputControl(); - - virtual QList<Output> availableOutputs() const = 0; - - virtual Output output() const = 0; - virtual void setOutput(Output output) = 0; - -Q_SIGNALS: - void availableOutputsChanged(const QList<QVideoOutputControl::Output> &outputs); - -protected: - QVideoOutputControl(QObject *parent = 0); -}; - -#define QVideoOutputControl_iid "com.nokia.Qt.QVideoOutputControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoOutputControl, QVideoOutputControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qvideorenderercontrol.cpp b/src/multimedia/mediaservices/base/qvideorenderercontrol.cpp deleted file mode 100644 index 6cc3138..0000000 --- a/src/multimedia/mediaservices/base/qvideorenderercontrol.cpp +++ /dev/null @@ -1,124 +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 QtMediaServices module 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 <QtMediaServices/qvideorenderercontrol.h> - -#include "qmediacontrol_p.h" - - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoRendererControl - \preliminary - \since 4.7 - \brief The QVideoRendererControl class provides a control for rendering - to a video surface. - - \ingroup multimedia-serv - - Using the surface() property of QVideoRendererControl a QAbstractVideoSurface - may be set as the video render target of a QMediaService. - - \code - QVideoRendererControl *rendererControl = mediaService->control<QVideoRendererControl *>(); - rendererControl->setSurface(myVideoSurface); - \endcode - - QVideoRendererControl is one of number of possible video output controls, - in order to receive video it must be made the active video output - control by setting the output property of QVideoOutputControl to - \l {QVideoOutputControl::RendererOutput}{RendererOutput}. Consequently any - QMediaService that implements QVideoRendererControl must also implement - QVideoOutputControl. - - \code - QVideoOutputControl *outputControl = mediaService->control<QVideoOutputControl *>(); - outputControl->setOutput(QVideoOutputControl::RendererOutput); - \endcode - - The interface name of QVideoRendererControl is \c com.nokia.Qt.QVideoRendererControl/1.0 as - defined in QVideoRendererControl_iid. - - \sa QMediaService::control(), QVideoOutputControl, QVideoWidget -*/ - -/*! - \macro QVideoRendererControl_iid - - \c com.nokia.Qt.QVideoRendererControl/1.0 - - Defines the interface name of the QVideoRendererControl class. - - \relates QVideoRendererControl -*/ - -/*! - Constructs a new video renderer media end point with the given \a parent. -*/ -QVideoRendererControl::QVideoRendererControl(QObject *parent) - : QMediaControl(parent) -{ -} - -/*! - Destroys a video renderer media end point. -*/ -QVideoRendererControl::~QVideoRendererControl() -{ -} - -/*! - \fn QVideoRendererControl::surface() const - - Returns the surface a video producer renders to. -*/ - -/*! - \fn QVideoRendererControl::setSurface(QAbstractVideoSurface *surface) - - Sets the \a surface a video producer renders to. -*/ - -#include "moc_qvideorenderercontrol.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qvideorenderercontrol.h b/src/multimedia/mediaservices/base/qvideorenderercontrol.h deleted file mode 100644 index 28e3d85..0000000 --- a/src/multimedia/mediaservices/base/qvideorenderercontrol.h +++ /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 QtMediaServices module 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 QVIDEORENDERERCONTROL_H -#define QVIDEORENDERERCONTROL_H - -#include <QtMediaServices/qmediacontrol.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAbstractVideoSurface; - -class Q_MEDIASERVICES_EXPORT QVideoRendererControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QVideoRendererControl(); - - virtual QAbstractVideoSurface *surface() const = 0; - virtual void setSurface(QAbstractVideoSurface *surface) = 0; - -protected: - QVideoRendererControl(QObject *parent = 0); -}; - -#define QVideoRendererControl_iid "com.nokia.Qt.QVideoRendererControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoRendererControl, QVideoRendererControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QVIDEORENDERERCONTROL_H diff --git a/src/multimedia/mediaservices/base/qvideowidget.cpp b/src/multimedia/mediaservices/base/qvideowidget.cpp deleted file mode 100644 index d39b1f4..0000000 --- a/src/multimedia/mediaservices/base/qvideowidget.cpp +++ /dev/null @@ -1,944 +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 QtMediaServices module 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 "qvideowidget_p.h" - -#include <QtMediaServices/qmediaobject.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qvideooutputcontrol.h> -#include <QtMediaServices/qvideowindowcontrol.h> -#include <QtMediaServices/qvideowidgetcontrol.h> - -#include "qpaintervideosurface_p.h" -#include <QtMediaServices/qvideorenderercontrol.h> -#include <QtMultimedia/qvideosurfaceformat.h> -#include <qpainter.h> - -#include <qapplication.h> -#include <qevent.h> -#include <qdialog.h> -#include <qboxlayout.h> -#include <qnamespace.h> - - -QT_BEGIN_NAMESPACE - -QVideoWidgetControlBackend::QVideoWidgetControlBackend( - QVideoWidgetControl *control, QWidget *widget) - : m_widgetControl(control) -{ - connect(control, SIGNAL(brightnessChanged(int)), widget, SLOT(_q_brightnessChanged(int))); - connect(control, SIGNAL(contrastChanged(int)), widget, SLOT(_q_contrastChanged(int))); - connect(control, SIGNAL(hueChanged(int)), widget, SLOT(_q_hueChanged(int))); - connect(control, SIGNAL(saturationChanged(int)), widget, SLOT(_q_saturationChanged(int))); - connect(control, SIGNAL(fullScreenChanged(bool)), widget, SLOT(_q_fullScreenChanged(bool))); - - QBoxLayout *layout = new QVBoxLayout; - layout->setMargin(0); - layout->setSpacing(0); - layout->addWidget(control->videoWidget()); - - widget->setLayout(layout); -} - -void QVideoWidgetControlBackend::setBrightness(int brightness) -{ - m_widgetControl->setBrightness(brightness); -} - -void QVideoWidgetControlBackend::setContrast(int contrast) -{ - m_widgetControl->setContrast(contrast); -} - -void QVideoWidgetControlBackend::setHue(int hue) -{ - m_widgetControl->setHue(hue); -} - -void QVideoWidgetControlBackend::setSaturation(int saturation) -{ - m_widgetControl->setSaturation(saturation); -} - -void QVideoWidgetControlBackend::setFullScreen(bool fullScreen) -{ - m_widgetControl->setFullScreen(fullScreen); -} - - -Qt::AspectRatioMode QVideoWidgetControlBackend::aspectRatioMode() const -{ - return m_widgetControl->aspectRatioMode(); -} - -void QVideoWidgetControlBackend::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_widgetControl->setAspectRatioMode(mode); -} - -QRendererVideoWidgetBackend::QRendererVideoWidgetBackend( - QVideoRendererControl *control, QWidget *widget) - : m_rendererControl(control) - , m_widget(widget) - , m_surface(new QPainterVideoSurface) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_updatePaintDevice(true) -{ - connect(this, SIGNAL(brightnessChanged(int)), m_widget, SLOT(_q_brightnessChanged(int))); - connect(this, SIGNAL(contrastChanged(int)), m_widget, SLOT(_q_contrastChanged(int))); - connect(this, SIGNAL(hueChanged(int)), m_widget, SLOT(_q_hueChanged(int))); - connect(this, SIGNAL(saturationChanged(int)), m_widget, SLOT(_q_saturationChanged(int))); - connect(m_surface, SIGNAL(frameChanged()), this, SLOT(frameChanged())); - connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), - this, SLOT(formatChanged(QVideoSurfaceFormat))); - - m_rendererControl->setSurface(m_surface); -} - -QRendererVideoWidgetBackend::~QRendererVideoWidgetBackend() -{ - delete m_surface; -} - -void QRendererVideoWidgetBackend::clearSurface() -{ - m_rendererControl->setSurface(0); -} - -void QRendererVideoWidgetBackend::setBrightness(int brightness) -{ - m_surface->setBrightness(brightness); - - emit brightnessChanged(brightness); -} - -void QRendererVideoWidgetBackend::setContrast(int contrast) -{ - m_surface->setContrast(contrast); - - emit contrastChanged(contrast); -} - -void QRendererVideoWidgetBackend::setHue(int hue) -{ - m_surface->setHue(hue); - - emit hueChanged(hue); -} - -void QRendererVideoWidgetBackend::setSaturation(int saturation) -{ - m_surface->setSaturation(saturation); - - emit saturationChanged(saturation); -} - -Qt::AspectRatioMode QRendererVideoWidgetBackend::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void QRendererVideoWidgetBackend::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_aspectRatioMode = mode; - - m_widget->updateGeometry(); -} - -void QRendererVideoWidgetBackend::setFullScreen(bool) -{ -} - -QSize QRendererVideoWidgetBackend::sizeHint() const -{ - return m_surface->surfaceFormat().sizeHint(); -} - -void QRendererVideoWidgetBackend::showEvent() -{ -} - -void QRendererVideoWidgetBackend::hideEvent(QHideEvent *) -{ -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - m_updatePaintDevice = true; - m_surface->setGLContext(0); -#endif -} - -void QRendererVideoWidgetBackend::resizeEvent(QResizeEvent *) -{ - updateRects(); -} - -void QRendererVideoWidgetBackend::moveEvent(QMoveEvent *) -{ -} - -void QRendererVideoWidgetBackend::paintEvent(QPaintEvent *event) -{ - QPainter painter(m_widget); - - if (m_widget->testAttribute(Qt::WA_OpaquePaintEvent)) { - QRegion borderRegion = event->region(); - borderRegion = borderRegion.subtracted(m_boundingRect); - - QBrush brush = m_widget->palette().window(); - - QVector<QRect> rects = borderRegion.rects(); - for (QVector<QRect>::iterator it = rects.begin(), end = rects.end(); it != end; ++it) { - painter.fillRect(*it, brush); - } - } - - if (m_surface->isActive() && m_boundingRect.intersects(event->rect())) { - m_surface->paint(&painter, m_boundingRect, m_sourceRect); - - m_surface->setReady(true); - } else { - #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - if (m_updatePaintDevice && (painter.paintEngine()->type() == QPaintEngine::OpenGL - || painter.paintEngine()->type() == QPaintEngine::OpenGL2)) { - m_updatePaintDevice = false; - - m_surface->setGLContext(const_cast<QGLContext *>(QGLContext::currentContext())); - if (m_surface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) { - m_surface->setShaderType(QPainterVideoSurface::GlslShader); - } else { - m_surface->setShaderType(QPainterVideoSurface::FragmentProgramShader); - } - } -#endif - } - -} - -void QRendererVideoWidgetBackend::formatChanged(const QVideoSurfaceFormat &format) -{ - m_nativeSize = format.sizeHint(); - - updateRects(); - - m_widget->updateGeometry(); - m_widget->update(); -} - -void QRendererVideoWidgetBackend::frameChanged() -{ - m_widget->update(m_boundingRect); -} - -void QRendererVideoWidgetBackend::updateRects() -{ - QRect rect = m_widget->rect(); - - if (m_nativeSize.isEmpty()) { - m_boundingRect = QRect(); - } else if (m_aspectRatioMode == Qt::IgnoreAspectRatio) { - m_boundingRect = rect; - m_sourceRect = QRectF(0, 0, 1, 1); - } else if (m_aspectRatioMode == Qt::KeepAspectRatio) { - QSize size = m_nativeSize; - size.scale(rect.size(), Qt::KeepAspectRatio); - - m_boundingRect = QRect(0, 0, size.width(), size.height()); - m_boundingRect.moveCenter(rect.center()); - - m_sourceRect = QRectF(0, 0, 1, 1); - } else if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) { - m_boundingRect = rect; - - QSizeF size = rect.size(); - size.scale(m_nativeSize, Qt::KeepAspectRatio); - - m_sourceRect = QRectF( - 0, 0, size.width() / m_nativeSize.width(), size.height() / m_nativeSize.height()); - m_sourceRect.moveCenter(QPointF(0.5, 0.5)); - } -} - -QWindowVideoWidgetBackend::QWindowVideoWidgetBackend(QVideoWindowControl *control, QWidget *widget) - : m_windowControl(control) - , m_widget(widget) - , m_aspectRatioMode(Qt::KeepAspectRatio) -{ - connect(control, SIGNAL(brightnessChanged(int)), m_widget, SLOT(_q_brightnessChanged(int))); - connect(control, SIGNAL(contrastChanged(int)), m_widget, SLOT(_q_contrastChanged(int))); - connect(control, SIGNAL(hueChanged(int)), m_widget, SLOT(_q_hueChanged(int))); - connect(control, SIGNAL(saturationChanged(int)), m_widget, SLOT(_q_saturationChanged(int))); - connect(control, SIGNAL(fullScreenChanged(bool)), m_widget, SLOT(_q_fullScreenChanged(bool))); - connect(control, SIGNAL(nativeSizeChanged()), m_widget, SLOT(_q_dimensionsChanged())); -} - -QWindowVideoWidgetBackend::~QWindowVideoWidgetBackend() -{ -} - -void QWindowVideoWidgetBackend::setBrightness(int brightness) -{ - m_windowControl->setBrightness(brightness); -} - -void QWindowVideoWidgetBackend::setContrast(int contrast) -{ - m_windowControl->setContrast(contrast); -} - -void QWindowVideoWidgetBackend::setHue(int hue) -{ - m_windowControl->setHue(hue); -} - -void QWindowVideoWidgetBackend::setSaturation(int saturation) -{ - m_windowControl->setSaturation(saturation); -} - -void QWindowVideoWidgetBackend::setFullScreen(bool fullScreen) -{ - m_windowControl->setFullScreen(fullScreen); -} - -Qt::AspectRatioMode QWindowVideoWidgetBackend::aspectRatioMode() const -{ - return m_windowControl->aspectRatioMode(); -} - -void QWindowVideoWidgetBackend::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_windowControl->setAspectRatioMode(mode); -} - -QSize QWindowVideoWidgetBackend::sizeHint() const -{ - return m_windowControl->nativeSize(); -} - -void QWindowVideoWidgetBackend::showEvent() -{ - m_windowControl->setWinId(m_widget->winId()); - - m_windowControl->setDisplayRect(m_widget->rect()); -} - -void QWindowVideoWidgetBackend::hideEvent(QHideEvent *) -{ -} - -void QWindowVideoWidgetBackend::moveEvent(QMoveEvent *) -{ - m_windowControl->setDisplayRect(m_widget->rect()); -} - -void QWindowVideoWidgetBackend::resizeEvent(QResizeEvent *) -{ - m_windowControl->setDisplayRect(m_widget->rect()); -} - -void QWindowVideoWidgetBackend::paintEvent(QPaintEvent *event) -{ - if (m_widget->testAttribute(Qt::WA_OpaquePaintEvent)) { - QPainter painter(m_widget); - - painter.fillRect(event->rect(), m_widget->palette().window()); - } - - m_windowControl->repaint(); - - event->accept(); -} - -void QVideoWidgetPrivate::setCurrentControl(QVideoWidgetControlInterface *control) -{ - if (currentControl != control) { - currentControl = control; - - currentControl->setBrightness(brightness); - currentControl->setContrast(contrast); - currentControl->setHue(hue); - currentControl->setSaturation(saturation); - currentControl->setAspectRatioMode(aspectRatioMode); - } -} - -void QVideoWidgetPrivate::show() -{ - if (outputControl) { - if (widgetBackend != 0) { - setCurrentControl(widgetBackend); - outputControl->setOutput(QVideoOutputControl::WidgetOutput); - } else if (windowBackend != 0 && (q_func()->window() == 0 - || !q_func()->window()->testAttribute(Qt::WA_DontShowOnScreen))) { - windowBackend->showEvent(); - currentBackend = windowBackend; - setCurrentControl(windowBackend); - outputControl->setOutput(QVideoOutputControl::WindowOutput); - } else if (rendererBackend != 0) { - rendererBackend->showEvent(); - currentBackend = rendererBackend; - setCurrentControl(rendererBackend); - outputControl->setOutput(QVideoOutputControl::RendererOutput); - } else { - outputControl->setOutput(QVideoOutputControl::NoOutput); - } - } -} - -void QVideoWidgetPrivate::clearService() -{ - if (service) { - QObject::disconnect(service, SIGNAL(destroyed()), q_func(), SLOT(_q_serviceDestroyed())); - - if (outputControl) - outputControl->setOutput(QVideoOutputControl::NoOutput); - - if (widgetBackend) { - QLayout *layout = q_func()->layout(); - - for (QLayoutItem *item = layout->takeAt(0); item; item = layout->takeAt(0)) { - item->widget()->setParent(0); - delete item; - } - delete layout; - - delete widgetBackend; - widgetBackend = 0; - } - - delete windowBackend; - windowBackend = 0; - - if (rendererBackend) { - rendererBackend->clearSurface(); - - delete rendererBackend; - rendererBackend = 0; - } - - currentBackend = 0; - currentControl = 0; - outputControl = 0; - service = 0; - } -} - -void QVideoWidgetPrivate::_q_serviceDestroyed() -{ - if (widgetBackend) { - delete q_func()->layout(); - - delete widgetBackend; - widgetBackend = 0; - } - - delete windowBackend; - windowBackend = 0; - - delete rendererBackend; - rendererBackend = 0; - - currentControl = 0; - currentBackend = 0; - outputControl = 0; - service = 0; -} - -void QVideoWidgetPrivate::_q_mediaObjectDestroyed() -{ - mediaObject = 0; - clearService(); -} - -void QVideoWidgetPrivate::_q_brightnessChanged(int b) -{ - if (b != brightness) - emit q_func()->brightnessChanged(brightness = b); -} - -void QVideoWidgetPrivate::_q_contrastChanged(int c) -{ - if (c != contrast) - emit q_func()->contrastChanged(contrast = c); -} - -void QVideoWidgetPrivate::_q_hueChanged(int h) -{ - if (h != hue) - emit q_func()->hueChanged(hue = h); -} - -void QVideoWidgetPrivate::_q_saturationChanged(int s) -{ - if (s != saturation) - emit q_func()->saturationChanged(saturation = s); -} - - -void QVideoWidgetPrivate::_q_fullScreenChanged(bool fullScreen) -{ - if (!fullScreen && q_func()->isFullScreen()) - q_func()->showNormal(); -} - -void QVideoWidgetPrivate::_q_dimensionsChanged() -{ - q_func()->updateGeometry(); - q_func()->update(); -} - -/*! - \class QVideoWidget - \preliminary - \since 4.7 - \brief The QVideoWidget class provides a widget which presents video - produced by a media object. - \ingroup multimedia - - Attaching a QVideoWidget to a QMediaObject allows it to display the - video or image output of that media object. A QVideoWidget is attached - to media object by passing a pointer to the QMediaObject in its - constructor, and detached by destroying the QVideoWidget. - - \code - player = new QMediaPlayer; - - widget = new QVideoWidget(player); - widget->show(); - - player->setMedia(QUrl("http://example.com/movie.mp4")); - player->play(); - \endcode - - \bold {Note}: Only a single display output can be attached to a media - object at one time. - - \sa QMediaObject, QMediaPlayer, QGraphicsVideoItem -*/ - -/*! - Constructs a new video widget. - - The \a parent is passed to QWidget. -*/ -QVideoWidget::QVideoWidget(QWidget *parent) - : QWidget(parent, 0) - , d_ptr(new QVideoWidgetPrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys a video widget. -*/ -QVideoWidget::~QVideoWidget() -{ - setMediaObject(0); - delete d_ptr; -} - -/*! - \property QVideoWidget::mediaObject - \brief the media object which provides the video displayed by a widget. -*/ - -QMediaObject *QVideoWidget::mediaObject() const -{ - return d_func()->mediaObject; -} - -void QVideoWidget::setMediaObject(QMediaObject *object) -{ - Q_D(QVideoWidget); - - if (object == d->mediaObject) - return; - - if (d->mediaObject) { - disconnect(d->mediaObject, SIGNAL(destroyed()), this, SLOT(_q_mediaObjectDestroyed())); - d->mediaObject->unbind(this); - } - - d->clearService(); - - d->mediaObject = object; - - if (d->mediaObject) { - d->service = d->mediaObject->service(); - - connect(d->mediaObject, SIGNAL(destroyed()), this, SLOT(_q_mediaObjectDestroyed())); - d->mediaObject->bind(this); - } - - if (d->service) { - connect(d->service, SIGNAL(destroyed()), SLOT(_q_serviceDestroyed())); - - d->outputControl = qobject_cast<QVideoOutputControl *>( - d->service->control(QVideoOutputControl_iid)); - - QVideoWidgetControl *widgetControl = qobject_cast<QVideoWidgetControl *>( - d->service->control(QVideoWidgetControl_iid)); - - if (widgetControl != 0) { - d->widgetBackend = new QVideoWidgetControlBackend(widgetControl, this); - } else { - QVideoWindowControl *windowControl = qobject_cast<QVideoWindowControl *>( - d->service->control(QVideoWindowControl_iid)); - - if (windowControl != 0) - d->windowBackend = new QWindowVideoWidgetBackend(windowControl, this); - - QVideoRendererControl *rendererControl = qobject_cast<QVideoRendererControl *>( - d->service->control(QVideoRendererControl_iid)); - - if (rendererControl != 0) - d->rendererBackend = new QRendererVideoWidgetBackend(rendererControl, this); - } - - if (isVisible()) - d->show(); - } -} - -/*! - \property QVideoWidget::aspectRatioMode - \brief how video is scaled with respect to its aspect ratio. -*/ - -Qt::AspectRatioMode QVideoWidget::aspectRatioMode() const -{ - return d_func()->aspectRatioMode; -} - -void QVideoWidget::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - Q_D(QVideoWidget); - - if (d->currentControl) { - d->currentControl->setAspectRatioMode(mode); - d->aspectRatioMode = d->currentControl->aspectRatioMode(); - } else { - d->aspectRatioMode = mode; - } -} - -/*! - \property QVideoWidget::fullScreen - \brief whether video display is confined to a window or is fullScreen. -*/ - -void QVideoWidget::setFullScreen(bool fullScreen) -{ - Q_D(QVideoWidget); - - if (fullScreen) { - Qt::WindowFlags flags = windowFlags(); - - d->nonFullScreenFlags = flags & (Qt::Window | Qt::SubWindow); - flags |= Qt::Window; - flags &= ~Qt::SubWindow; - setWindowFlags(flags); - - showFullScreen(); - } else { - showNormal(); - } -} - -/*! - \fn QVideoWidget::fullScreenChanged(bool fullScreen) - - Signals that the \a fullScreen mode of a video widget has changed. - - \sa fullScreen -*/ - -/*! - \property QVideoWidget::brightness - \brief an adjustment to the brightness of displayed video. - - Valid brightness values range between -100 and 100, the default is 0. -*/ - -int QVideoWidget::brightness() const -{ - return d_func()->brightness; -} - -void QVideoWidget::setBrightness(int brightness) -{ - Q_D(QVideoWidget); - - int boundedBrightness = qBound(-100, brightness, 100); - - if (d->currentControl) - d->currentControl->setBrightness(boundedBrightness); - else if (d->brightness != boundedBrightness) - emit brightnessChanged(d->brightness = boundedBrightness); -} - -/*! - \fn QVideoWidget::brightnessChanged(int brightness) - - Signals that a video widgets's \a brightness adjustment has changed. - - \sa brightness -*/ - -/*! - \property QVideoWidget::contrast - \brief an adjustment to the contrast of displayed video. - - Valid contrast values range between -100 and 100, the default is 0. - -*/ - -int QVideoWidget::contrast() const -{ - return d_func()->contrast; -} - -void QVideoWidget::setContrast(int contrast) -{ - Q_D(QVideoWidget); - - int boundedContrast = qBound(-100, contrast, 100); - - if (d->currentControl) - d->currentControl->setContrast(boundedContrast); - else if (d->contrast != boundedContrast) - emit contrastChanged(d->contrast = boundedContrast); -} - -/*! - \fn QVideoWidget::contrastChanged(int contrast) - - Signals that a video widgets's \a contrast adjustment has changed. - - \sa contrast -*/ - -/*! - \property QVideoWidget::hue - \brief an adjustment to the hue of displayed video. - - Valid hue values range between -100 and 100, the default is 0. -*/ - -int QVideoWidget::hue() const -{ - return d_func()->hue; -} - -void QVideoWidget::setHue(int hue) -{ - Q_D(QVideoWidget); - - int boundedHue = qBound(-100, hue, 100); - - if (d->currentControl) - d->currentControl->setHue(boundedHue); - else if (d->hue != boundedHue) - emit hueChanged(d->hue = boundedHue); -} - -/*! - \fn QVideoWidget::hueChanged(int hue) - - Signals that a video widgets's \a hue has changed. - - \sa hue -*/ - -/*! - \property QVideoWidget::saturation - \brief an adjustment to the saturation of displayed video. - - Valid saturation values range between -100 and 100, the default is 0. -*/ - -int QVideoWidget::saturation() const -{ - return d_func()->saturation; -} - -void QVideoWidget::setSaturation(int saturation) -{ - Q_D(QVideoWidget); - - int boundedSaturation = qBound(-100, saturation, 100); - - if (d->currentControl) - d->currentControl->setSaturation(boundedSaturation); - else if (d->saturation != boundedSaturation) - emit saturationChanged(d->saturation = boundedSaturation); - -} - -/*! - \fn QVideoWidget::saturationChanged(int saturation) - - Signals that a video widgets's \a saturation has changed. - - \sa saturation -*/ - -/*! - Returns the size hint for the current back end, - if there is one, or else the size hint from QWidget. - */ -QSize QVideoWidget::sizeHint() const -{ - Q_D(const QVideoWidget); - - if (d->currentBackend) - return d->currentBackend->sizeHint(); - else - return QWidget::sizeHint(); - - -} - -/*! - \reimp - \internal - */ -bool QVideoWidget::event(QEvent *event) -{ - Q_D(QVideoWidget); - - if (event->type() == QEvent::WindowStateChange) { - Qt::WindowFlags flags = windowFlags(); - - if (windowState() & Qt::WindowFullScreen) { - if (d->currentControl) - d->currentControl->setFullScreen(true); - - if (!d->wasFullScreen) - emit fullScreenChanged(d->wasFullScreen = true); - } else { - if (d->currentControl) - d->currentControl->setFullScreen(false); - - if (d->wasFullScreen) { - flags &= ~(Qt::Window | Qt::SubWindow); //clear the flags... - flags |= d->nonFullScreenFlags; //then we reset the flags (window and subwindow) - setWindowFlags(flags); - - emit fullScreenChanged(d->wasFullScreen = false); - } - } - } - return QWidget::event(event); -} - -/*! - Handles the show \a event. - */ -void QVideoWidget::showEvent(QShowEvent *event) -{ - Q_D(QVideoWidget); - - QWidget::showEvent(event); - - d->show(); - -} - -/*! - - Handles the hide \a event. -*/ -void QVideoWidget::hideEvent(QHideEvent *event) -{ - Q_D(QVideoWidget); - - if (d->currentBackend) - d->currentBackend->hideEvent(event); - - QWidget::hideEvent(event); -} - -/*! - Handles the resize \a event. - */ -void QVideoWidget::resizeEvent(QResizeEvent *event) -{ - Q_D(QVideoWidget); - - QWidget::resizeEvent(event); - - if (d->currentBackend) - d->currentBackend->resizeEvent(event); -} - -/*! - Handles the move \a event. - */ -void QVideoWidget::moveEvent(QMoveEvent *event) -{ - Q_D(QVideoWidget); - - if (d->currentBackend) - d->currentBackend->moveEvent(event); -} - -/*! - Handles the paint \a event. - */ -void QVideoWidget::paintEvent(QPaintEvent *event) -{ - Q_D(QVideoWidget); - - if (d->currentBackend) { - d->currentBackend->paintEvent(event); - } else if (testAttribute(Qt::WA_OpaquePaintEvent)) { - QPainter painter(this); - - painter.fillRect(event->rect(), palette().window()); - } -} - -#include "moc_qvideowidget.cpp" -#include "moc_qvideowidget_p.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qvideowidget.h b/src/multimedia/mediaservices/base/qvideowidget.h deleted file mode 100644 index a21739a..0000000 --- a/src/multimedia/mediaservices/base/qvideowidget.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 QtMediaServices module 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 QVIDEOWIDGET_H -#define QVIDEOWIDGET_H - -#include <QtGui/qwidget.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaObject; - -class QVideoWidgetPrivate; -class Q_MEDIASERVICES_EXPORT QVideoWidget : public QWidget -{ - Q_OBJECT - Q_PROPERTY(QMediaObject* mediaObject READ mediaObject WRITE setMediaObject) - Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged) - Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode NOTIFY aspectRatioModeChanged) - Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged) - Q_PROPERTY(int contrast READ contrast WRITE setContrast NOTIFY contrastChanged) - Q_PROPERTY(int hue READ hue WRITE setHue NOTIFY hueChanged) - Q_PROPERTY(int saturation READ saturation WRITE setSaturation NOTIFY saturationChanged) - -public: - QVideoWidget(QWidget *parent = 0); - ~QVideoWidget(); - - QMediaObject *mediaObject() const; - void setMediaObject(QMediaObject *object); - -#ifdef Q_QDOC - bool isFullScreen() const; -#endif - - Qt::AspectRatioMode aspectRatioMode() const; - - int brightness() const; - int contrast() const; - int hue() const; - int saturation() const; - - QSize sizeHint() const; - -public Q_SLOTS: - void setFullScreen(bool fullScreen); - void setAspectRatioMode(Qt::AspectRatioMode mode); - void setBrightness(int brightness); - void setContrast(int contrast); - void setHue(int hue); - void setSaturation(int saturation); - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - void brightnessChanged(int brightness); - void contrastChanged(int contrast); - void hueChanged(int hue); - void saturationChanged(int saturation); - -protected: - bool event(QEvent *event); - void showEvent(QShowEvent *event); - void hideEvent(QHideEvent *event); - void resizeEvent(QResizeEvent *event); - void moveEvent(QMoveEvent *event); - void paintEvent(QPaintEvent *event); - -protected: - QVideoWidgetPrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QVideoWidget) - Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed()) - Q_PRIVATE_SLOT(d_func(), void _q_mediaObjectDestroyed()) - Q_PRIVATE_SLOT(d_func(), void _q_brightnessChanged(int)) - Q_PRIVATE_SLOT(d_func(), void _q_contrastChanged(int)) - Q_PRIVATE_SLOT(d_func(), void _q_hueChanged(int)) - Q_PRIVATE_SLOT(d_func(), void _q_saturationChanged(int)) - Q_PRIVATE_SLOT(d_func(), void _q_fullScreenChanged(bool)) - Q_PRIVATE_SLOT(d_func(), void _q_dimensionsChanged()) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qvideowidget_p.h b/src/multimedia/mediaservices/base/qvideowidget_p.h deleted file mode 100644 index bb44dfa..0000000 --- a/src/multimedia/mediaservices/base/qvideowidget_p.h +++ /dev/null @@ -1,271 +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 QtMediaServices module 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 QVIDEOWIDGET_P_H -#define QVIDEOWIDGET_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtMediaServices/qvideowidget.h> - -#ifndef QT_NO_OPENGL -#include <QGLWidget> -#endif - -#include "qpaintervideosurface_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QVideoWidgetControlInterface -{ -public: - virtual ~QVideoWidgetControlInterface() {} - - virtual void setBrightness(int brightness) = 0; - virtual void setContrast(int contrast) = 0; - virtual void setHue(int hue) = 0; - virtual void setSaturation(int saturation) = 0; - - virtual void setFullScreen(bool fullScreen) = 0; - - virtual Qt::AspectRatioMode aspectRatioMode() const = 0; - virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0; -}; - -class QVideoWidgetBackend : public QObject, public QVideoWidgetControlInterface -{ - Q_OBJECT - -public: - virtual QSize sizeHint() const = 0; - - virtual void showEvent() = 0; - virtual void hideEvent(QHideEvent *event) = 0; - virtual void resizeEvent(QResizeEvent *event) = 0; - virtual void moveEvent(QMoveEvent *event) = 0; - virtual void paintEvent(QPaintEvent *event) = 0; -}; - -class QVideoWidgetControl; - -class QVideoWidgetControlBackend : public QObject, public QVideoWidgetControlInterface -{ - Q_OBJECT -public: - QVideoWidgetControlBackend(QVideoWidgetControl *control, QWidget *widget); - - void setBrightness(int brightness); - void setContrast(int contrast); - void setHue(int hue); - void setSaturation(int saturation); - - void setFullScreen(bool fullScreen); - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - -private: - QVideoWidgetControl *m_widgetControl; -}; - - -class QVideoRendererControl; - -class QRendererVideoWidgetBackend : public QVideoWidgetBackend -{ - Q_OBJECT -public: - QRendererVideoWidgetBackend(QVideoRendererControl *control, QWidget *widget); - ~QRendererVideoWidgetBackend(); - - void clearSurface(); - - void setBrightness(int brightness); - void setContrast(int contrast); - void setHue(int hue); - void setSaturation(int saturation); - - void setFullScreen(bool fullScreen); - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - QSize sizeHint() const; - - void showEvent(); - void hideEvent(QHideEvent *event); - void resizeEvent(QResizeEvent *event); - void moveEvent(QMoveEvent *event); - void paintEvent(QPaintEvent *event); - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - void brightnessChanged(int brightness); - void contrastChanged(int contrast); - void hueChanged(int hue); - void saturationChanged(int saturation); - -private Q_SLOTS: - void formatChanged(const QVideoSurfaceFormat &format); - void frameChanged(); - -private: - void updateRects(); - - QVideoRendererControl *m_rendererControl; - QWidget *m_widget; - QPainterVideoSurface *m_surface; - Qt::AspectRatioMode m_aspectRatioMode; - QRect m_boundingRect; - QRectF m_sourceRect; - QSize m_nativeSize; - bool m_updatePaintDevice; -}; - -class QVideoWindowControl; - -class QWindowVideoWidgetBackend : public QVideoWidgetBackend -{ - Q_OBJECT -public: - QWindowVideoWidgetBackend(QVideoWindowControl *control, QWidget *widget); - ~QWindowVideoWidgetBackend(); - - void setBrightness(int brightness); - void setContrast(int contrast); - void setHue(int hue); - void setSaturation(int saturation); - - void setFullScreen(bool fullScreen); - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - QSize sizeHint() const; - - void showEvent(); - void hideEvent(QHideEvent *event); - void resizeEvent(QResizeEvent *event); - void moveEvent(QMoveEvent *event); - void paintEvent(QPaintEvent *event); - -private: - QVideoWindowControl *m_windowControl; - QWidget *m_widget; - Qt::AspectRatioMode m_aspectRatioMode; - QSize m_pixelAspectRatio; -}; - -class QMediaService; -class QVideoOutputControl; - -class QVideoWidgetPrivate -{ - Q_DECLARE_PUBLIC(QVideoWidget) -public: - QVideoWidgetPrivate() - : q_ptr(0) - , mediaObject(0) - , service(0) - , outputControl(0) - , widgetBackend(0) - , windowBackend(0) - , rendererBackend(0) - , currentControl(0) - , currentBackend(0) - , brightness(0) - , contrast(0) - , hue(0) - , saturation(0) - , aspectRatioMode(Qt::KeepAspectRatio) - , nonFullScreenFlags(0) - , wasFullScreen(false) - { - } - - QVideoWidget *q_ptr; - QMediaObject *mediaObject; - QMediaService *service; - QVideoOutputControl *outputControl; - QVideoWidgetControlBackend *widgetBackend; - QWindowVideoWidgetBackend *windowBackend; - QRendererVideoWidgetBackend *rendererBackend; - QVideoWidgetControlInterface *currentControl; - QVideoWidgetBackend *currentBackend; - int brightness; - int contrast; - int hue; - int saturation; - Qt::AspectRatioMode aspectRatioMode; - Qt::WindowFlags nonFullScreenFlags; - bool wasFullScreen; - - void setCurrentControl(QVideoWidgetControlInterface *control); - void show(); - void clearService(); - - void _q_serviceDestroyed(); - void _q_mediaObjectDestroyed(); - void _q_brightnessChanged(int brightness); - void _q_contrastChanged(int contrast); - void _q_hueChanged(int hue); - void _q_saturationChanged(int saturation); - void _q_fullScreenChanged(bool fullScreen); - void _q_dimensionsChanged(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qvideowidgetcontrol.cpp b/src/multimedia/mediaservices/base/qvideowidgetcontrol.cpp deleted file mode 100644 index 538f158..0000000 --- a/src/multimedia/mediaservices/base/qvideowidgetcontrol.cpp +++ /dev/null @@ -1,235 +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 QtMediaServices module 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 <QtMediaServices/qvideowidgetcontrol.h> -#include "qmediacontrol_p.h" - - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoWidgetControl - \preliminary - \since 4.7 - \brief The QVideoWidgetControl class provides a media control which - implements a video widget. - - \ingroup multimedia-serv - - The videoWidget() property of QVideoWidgetControl provides a pointer to - a video widget implemented by the control's media service. This widget - is owned by the media service and so care should be taken not to delete it. - - \code - QVideoWidgetControl *widgetControl = mediaService->control<QVideoWidgetControl *>(); - - layout->addWidget(widgetControl->widget()); - \endcode - - QVideoWidgetControl is one of number of possible video output controls, - in order to receive video it must be made the active video output - control by setting the output property of QVideoOutputControl to \l {QVideoOutputControl::WidgetOutput}{WidgetOutput}. Consequently any - QMediaService that implements QVideoWidgetControl must also implement - QVideoOutputControl. - - The interface name of QVideoWidgetControl is \c com.nokia.Qt.QVideoWidgetControl/1.0 as - defined in QVideoWidgetControl_iid. - - \sa QMediaService::control(), QVideoOutputControl, QVideoWidget -*/ - -/*! - \macro QVideoWidgetControl_iid - - \c com.nokia.Qt.QVideoWidgetControl/1.0 - - Defines the interface name of the QVideoWidgetControl class. - - \relates QVideoWidgetControl -*/ - -/*! - Constructs a new video widget control with the given \a parent. -*/ -QVideoWidgetControl::QVideoWidgetControl(QObject *parent) - :QMediaControl(parent) -{ -} - -/*! - Destroys a video widget control. -*/ -QVideoWidgetControl::~QVideoWidgetControl() -{ -} - -/*! - \fn QVideoWidgetControl::isFullScreen() const - - Returns true if the video is shown using the complete screen. -*/ - -/*! - \fn QVideoWidgetControl::setFullScreen(bool fullScreen) - - Sets whether a video widget is in \a fullScreen mode. -*/ - -/*! - \fn QVideoWidgetControl::fullScreenChanged(bool fullScreen) - - Signals that the \a fullScreen state of a video widget has changed. -*/ - -/*! - \fn QVideoWidgetControl::aspectRatioMode() const - - Returns how video is scaled to fit the widget with respect to its aspect ratio. -*/ - -/*! - \fn QVideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode mode) - - Sets the aspect ratio \a mode which determines how video is scaled to the fit the widget with - respect to its aspect ratio. -*/ - -/*! - \fn QVideoWidgetControl::brightness() const - - Returns the brightness adjustment applied to a video. - - Valid brightness values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWidgetControl::setBrightness(int brightness) - - Sets a \a brightness adjustment for a video. - - Valid brightness values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWidgetControl::brightnessChanged(int brightness) - - Signals that a video widget's \a brightness adjustment has changed. -*/ - -/*! - \fn QVideoWidgetControl::contrast() const - - Returns the contrast adjustment applied to a video. - - Valid contrast values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWidgetControl::setContrast(int contrast) - - Sets the contrast adjustment for a video widget to \a contrast. - - Valid contrast values range between -100 and 100, the default is 0. -*/ - - -/*! - \fn QVideoWidgetControl::contrastChanged(int contrast) - - Signals that a video widget's \a contrast adjustment has changed. -*/ - -/*! - \fn QVideoWidgetControl::hue() const - - Returns the hue adjustment applied to a video widget. - - Value hue values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWidgetControl::setHue(int hue) - - Sets a \a hue adjustment for a video widget. - - Valid hue values range between -100 and 100, the default is 0. -*/ - - -/*! - \fn QVideoWidgetControl::hueChanged(int hue) - - Signals that a video widget's \a hue adjustment has changed. -*/ - -/*! - \fn QVideoWidgetControl::saturation() const - - Returns the saturation adjustment applied to a video widget. - - Value saturation values range between -100 and 100, the default is 0. -*/ - - -/*! - \fn QVideoWidgetControl::setSaturation(int saturation) - - Sets a \a saturation adjustment for a video widget. - - Valid saturation values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWidgetControl::saturationChanged(int saturation) - - Signals that a video widget's \a saturation adjustment has changed. -*/ - -/*! - \fn QVideoWidgetControl::videoWidget() - - Returns the QWidget. -*/ - -#include "moc_qvideowidgetcontrol.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qvideowidgetcontrol.h b/src/multimedia/mediaservices/base/qvideowidgetcontrol.h deleted file mode 100644 index 1013beb..0000000 --- a/src/multimedia/mediaservices/base/qvideowidgetcontrol.h +++ /dev/null @@ -1,105 +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 QtMediaServices module 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 QVIDEOWIDGETCONTROL_H -#define QVIDEOWIDGETCONTROL_H - -#include <QtGui/qwidget.h> - -#include <QtMediaServices/qvideowidget.h> -#include <QtMediaServices/qmediacontrol.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QVideoWidgetControlPrivate; - -class Q_MEDIASERVICES_EXPORT QVideoWidgetControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QVideoWidgetControl(); - - virtual QWidget *videoWidget() = 0; - - virtual Qt::AspectRatioMode aspectRatioMode() const = 0; - virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0; - - virtual bool isFullScreen() const = 0; - virtual void setFullScreen(bool fullScreen) = 0; - - virtual int brightness() const = 0; - virtual void setBrightness(int brightness) = 0; - - virtual int contrast() const = 0; - virtual void setContrast(int contrast) = 0; - - virtual int hue() const = 0; - virtual void setHue(int hue) = 0; - - virtual int saturation() const = 0; - virtual void setSaturation(int saturation) = 0; - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - void brightnessChanged(int brightness); - void contrastChanged(int contrast); - void hueChanged(int hue); - void saturationChanged(int saturation); - -protected: - QVideoWidgetControl(QObject *parent = 0); -}; - -#define QVideoWidgetControl_iid "com.nokia.Qt.QVideoWidgetControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoWidgetControl, QVideoWidgetControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/base/qvideowindowcontrol.cpp b/src/multimedia/mediaservices/base/qvideowindowcontrol.cpp deleted file mode 100644 index 967a2d6..0000000 --- a/src/multimedia/mediaservices/base/qvideowindowcontrol.cpp +++ /dev/null @@ -1,275 +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 QtMediaServices module 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 <QtMediaServices/qvideowindowcontrol.h> - - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoWindowControl - \preliminary - \since 4.7 - \ingroup multimedia-serv - \brief The QVideoWindowControl class provides a media control for rendering video to a window. - - - The winId() property QVideoWindowControl allows a platform specific - window ID to be set as the video render target of a QMediaService. The - displayRect() property is used to set the region of the window the - video should be rendered to, and the aspectRatioMode() property - indicates how the video should be scaled to fit the displayRect(). - - \code - QVideoWindowControl *windowControl = mediaService->control<QVideoWindowControl *>(); - windowControl->setWinId(widget->winId()); - windowControl->setDisplayRect(widget->rect()); - windowControl->setAspectRatioMode(Qt::KeepAspectRatio); - \endcode - - QVideoWindowControl is one of number of possible video output controls, - in order to receive video it must be made the active video output - control by setting the output property of QVideoOutputControl to \l {QVideoOutputControl::WindowOutput}{WindowOutput}. - Consequently any QMediaService that implements QVideoWindowControl must - also implement QVideoOutputControl. - - \code - QVideoOutputControl *outputControl = mediaService->control<QVideoOutputControl *>(); - outputControl->setOutput(QVideoOutputControl::WindowOutput); - \endcode - - The interface name of QVideoWindowControl is \c com.nokia.Qt.QVideoWindowControl/1.0 as - defined in QVideoWindowControl_iid. - - \sa QMediaService::control(), QVideoOutputControl, QVideoWidget -*/ - -/*! - \macro QVideoWindowControl_iid - - \c com.nokia.Qt.QVideoWindowControl/1.0 - - Defines the interface name of the QVideoWindowControl class. - - \relates QVideoWindowControl -*/ - -/*! - Constructs a new video window control with the given \a parent. -*/ -QVideoWindowControl::QVideoWindowControl(QObject *parent) - : QMediaControl(parent) -{ -} - -/*! - Destroys a video window control. -*/ -QVideoWindowControl::~QVideoWindowControl() -{ -} - -/*! - \fn QVideoWindowControl::winId() const - - Returns the ID of the window a video overlay end point renders to. -*/ - -/*! - \fn QVideoWindowControl::setWinId(WId id) - - Sets the \a id of the window a video overlay end point renders to. -*/ - -/*! - \fn QVideoWindowControl::displayRect() const - Returns the sub-rect of a window where video is displayed. -*/ - -/*! - \fn QVideoWindowControl::setDisplayRect(const QRect &rect) - Sets the sub-\a rect of a window where video is displayed. -*/ - -/*! - \fn QVideoWindowControl::isFullScreen() const - - Identifies if a video overlay is a fullScreen overlay. - - Returns true if the video overlay is fullScreen, and false otherwise. -*/ - -/*! - \fn QVideoWindowControl::setFullScreen(bool fullScreen) - - Sets whether a video overlay is a \a fullScreen overlay. -*/ - -/*! - \fn QVideoWindowControl::fullScreenChanged(bool fullScreen) - - Signals that the \a fullScreen state of a video overlay has changed. -*/ - -/*! - \fn QVideoWindowControl::repaint() - - Repaints the last frame. -*/ - -/*! - \fn QVideoWindowControl::nativeSize() const - - Returns a suggested size for the video display based on the resolution and aspect ratio of the - video. -*/ - -/*! - \fn QVideoWindowControl::nativeSizeChanged() - - Signals that the native dimensions of the video have changed. -*/ - - -/*! - \fn QVideoWindowControl::aspectRatioMode() const - - Returns how video is scaled to fit the display region with respect to its aspect ratio. -*/ - -/*! - \fn QVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode) - - Sets the aspect ratio \a mode which determines how video is scaled to the fit the display region - with respect to its aspect ratio. -*/ - -/*! - \fn QVideoWindowControl::brightness() const - - Returns the brightness adjustment applied to a video overlay. - - Valid brightness values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::setBrightness(int brightness) - - Sets a \a brightness adjustment for a video overlay. - - Valid brightness values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::brightnessChanged(int brightness) - - Signals that a video overlay's \a brightness adjustment has changed. -*/ - -/*! - \fn QVideoWindowControl::contrast() const - - Returns the contrast adjustment applied to a video overlay. - - Valid contrast values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::setContrast(int contrast) - - Sets the \a contrast adjustment for a video overlay. - - Valid contrast values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::contrastChanged(int contrast) - - Signals that a video overlay's \a contrast adjustment has changed. -*/ - -/*! - \fn QVideoWindowControl::hue() const - - Returns the hue adjustment applied to a video overlay. - - Value hue values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::setHue(int hue) - - Sets a \a hue adjustment for a video overlay. - - Valid hue values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::hueChanged(int hue) - - Signals that a video overlay's \a hue adjustment has changed. -*/ - -/*! - \fn QVideoWindowControl::saturation() const - - Returns the saturation adjustment applied to a video overlay. - - Value saturation values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::setSaturation(int saturation) - Sets a \a saturation adjustment for a video overlay. - - Valid saturation values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QVideoWindowControl::saturationChanged(int saturation) - - Signals that a video overlay's \a saturation adjustment has changed. -*/ - -#include "moc_qvideowindowcontrol.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/base/qvideowindowcontrol.h b/src/multimedia/mediaservices/base/qvideowindowcontrol.h deleted file mode 100644 index 47ba520..0000000 --- a/src/multimedia/mediaservices/base/qvideowindowcontrol.h +++ /dev/null @@ -1,111 +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 QtMediaServices module 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 QVIDEOWINDOWCONTROL_H -#define QVIDEOWINDOWCONTROL_H - -#include <QtGui/qwidget.h> - -#include <QtMediaServices/qmediacontrol.h> -#include <QtMediaServices/qvideowidget.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MEDIASERVICES_EXPORT QVideoWindowControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QVideoWindowControl(); - - virtual WId winId() const = 0; - virtual void setWinId(WId id) = 0; - - virtual QRect displayRect() const = 0; - virtual void setDisplayRect(const QRect &rect) = 0; - - virtual bool isFullScreen() const = 0; - virtual void setFullScreen(bool fullScreen) = 0; - - virtual void repaint() = 0; - - virtual QSize nativeSize() const = 0; - - virtual Qt::AspectRatioMode aspectRatioMode() const = 0; - virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0; - - virtual int brightness() const = 0; - virtual void setBrightness(int brightness) = 0; - - virtual int contrast() const = 0; - virtual void setContrast(int contrast) = 0; - - virtual int hue() const = 0; - virtual void setHue(int hue) = 0; - - virtual int saturation() const = 0; - virtual void setSaturation(int saturation) = 0; - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - void brightnessChanged(int brightness); - void contrastChanged(int contrast); - void hueChanged(int hue); - void saturationChanged(int saturation); - void nativeSizeChanged(); - -protected: - QVideoWindowControl(QObject *parent = 0); -}; - -#define QVideoWindowControl_iid "com.nokia.Qt.QVideoWindowControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoWindowControl, QVideoWindowControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimedia/mediaservices/effects/effects.pri b/src/multimedia/mediaservices/effects/effects.pri deleted file mode 100644 index 6307255..0000000 --- a/src/multimedia/mediaservices/effects/effects.pri +++ /dev/null @@ -1,26 +0,0 @@ - - -unix:!mac { - contains(QT_CONFIG, pulseaudio) { - DEFINES += QT_MULTIMEDIA_PULSEAUDIO - HEADERS += $$PWD/qsoundeffect_pulse_p.h - SOURCES += $$PWD/qsoundeffect_pulse_p.cpp - QMAKE_CXXFLAGS += $$QT_CFLAGS_PULSEAUDIO - LIBS += $$QT_LIBS_PULSEAUDIO - } else { - DEFINES += QT_MULTIMEDIA_QMEDIAPLAYER - HEADERS += $$PWD/qsoundeffect_qmedia_p.h - SOURCES += $$PWD/qsoundeffect_qmedia_p.cpp - } -} else { - HEADERS += $$PWD/qsoundeffect_qsound_p.h - SOURCES += $$PWD/qsoundeffect_qsound_p.cpp -} - -HEADERS += \ - $$PWD/qsoundeffect_p.h \ - $$PWD/wavedecoder_p.h - -SOURCES += \ - $$PWD/qsoundeffect.cpp \ - $$PWD/wavedecoder_p.cpp diff --git a/src/multimedia/mediaservices/effects/qsoundeffect.cpp b/src/multimedia/mediaservices/effects/qsoundeffect.cpp deleted file mode 100644 index 3537566..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMultimedia module 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 "qsoundeffect_p.h" - -#if defined(QT_MULTIMEDIA_PULSEAUDIO) -#include "qsoundeffect_pulse_p.h" -#elif(QT_MULTIMEDIA_QMEDIAPLAYER) -#include "qsoundeffect_qmedia_p.h" -#else -#include "qsoundeffect_qsound_p.h" -#endif - -QT_BEGIN_NAMESPACE - -/*! - \qmlclass SoundEffect QSoundEffect - \since 4.7 - \brief The SoundEffect element provides a way to play sound effects in QML. - - This element is part of the \bold{Qt.multimedia 4.7} module. - - The following example plays a wav file on mouse click. - - \qml - import Qt 4.7 - import Qt.multimedia 4.7 - - Text { - text: "Click Me!"; - font.pointSize: 24; - width: 150; height: 50; - - SoundEffect { - id: playSound - source: "soundeffect.wav" - } - MouseArea { - id: playArea - anchors.fill: parent - onPressed: { playSound.play() } - } - } - \endqml -*/ - -/*! - \qmlproperty url SoundEffect::source - - This property provides a way to control the sound to play. -*/ - -/*! - \qmlproperty int SoundEffect::loops - - This property provides a way to control the number of times to repeat the sound on each play(). -*/ - -/*! - \qmlproperty int SoundEffect::volume - - This property provides a way to control the volume for playback. -*/ - -/*! - \qmlproperty bool SoundEffect::muted - - This property provides a way to control muting. -*/ - -/*! - \qmlsignal SoundEffect::sourceChanged() - - This handler is called when the source has changed. -*/ - -/*! - \qmlsignal SoundEffect::loopsChanged() - - This handler is called when the number of loops has changes. -*/ - -/*! - \qmlsignal SoundEffect::volumeChanged() - - This handler is called when the volume has changed. -*/ - -/*! - \qmlsignal SoundEffect::mutedChanged() - - This handler is called when the mute state has changed. -*/ - - -QSoundEffect::QSoundEffect(QObject *parent) : - QObject(parent) -{ - d = new QSoundEffectPrivate(this); - connect(d, SIGNAL(volumeChanged()), SIGNAL(volumeChanged())); - connect(d, SIGNAL(mutedChanged()), SIGNAL(mutedChanged())); -} - -QSoundEffect::~QSoundEffect() -{ - d->deleteLater(); -} - -QUrl QSoundEffect::source() const -{ - return d->source(); -} - -void QSoundEffect::setSource(const QUrl &url) -{ - if (d->source() == url) - return; - - d->setSource(url); - - emit sourceChanged(); -} - -int QSoundEffect::loops() const -{ - return d->loopCount(); -} - -void QSoundEffect::setLoops(int loopCount) -{ - if (d->loopCount() == loopCount) - return; - - d->setLoopCount(loopCount); - emit loopsChanged(); -} - -int QSoundEffect::volume() const -{ - return d->volume(); -} - -void QSoundEffect::setVolume(int volume) -{ - if (d->volume() == volume) - return; - - d->setVolume(volume); - emit volumeChanged(); -} - -bool QSoundEffect::isMuted() const -{ - return d->isMuted(); -} - -void QSoundEffect::setMuted(bool muted) -{ - if (d->isMuted() == muted) - return; - - d->setMuted(muted); - emit mutedChanged(); -} - -void QSoundEffect::play() -{ - d->play(); -} - -QT_END_NAMESPACE diff --git a/src/multimedia/mediaservices/effects/qsoundeffect_p.h b/src/multimedia/mediaservices/effects/qsoundeffect_p.h deleted file mode 100644 index 64ddb77..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect_p.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices module 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 QSOUNDEFFECT_H -#define QSOUNDEFFECT_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#include <QtCore/qobject.h> -#include <QtCore/qurl.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QSoundEffectPrivate; -class Q_MEDIASERVICES_EXPORT QSoundEffect : public QObject -{ - Q_OBJECT - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopsChanged) - Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged) - Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - -public: - explicit QSoundEffect(QObject *parent = 0); - ~QSoundEffect(); - - QUrl source() const; - void setSource(const QUrl &url); - - int loops() const; - void setLoops(int loopCount); - - int volume() const; - void setVolume(int volume); - - bool isMuted() const; - void setMuted(bool muted); - -Q_SIGNALS: - void sourceChanged(); - void loopsChanged(); - void volumeChanged(); - void mutedChanged(); - -public Q_SLOTS: - void play(); - -private: - Q_DISABLE_COPY(QSoundEffect) - QSoundEffectPrivate* d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QSOUNDEFFECT_H diff --git a/src/multimedia/mediaservices/effects/qsoundeffect_pulse_p.cpp b/src/multimedia/mediaservices/effects/qsoundeffect_pulse_p.cpp deleted file mode 100644 index c856157..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect_pulse_p.cpp +++ /dev/null @@ -1,499 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices module 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qcoreapplication.h> -#include <QtMultimedia/qaudioformat.h> -#include <QtNetwork> -#include <QTime> - -#include "wavedecoder_p.h" - -#include "qsoundeffect_pulse_p.h" - -#if defined(Q_WS_MAEMO_5) -#include <pulse/ext-stream-restore.h> -#endif - -#include <unistd.h> - -// Less than ideal -#define PA_SCACHE_ENTRY_SIZE_MAX (1024*1024*16) - -QT_BEGIN_NAMESPACE - -namespace -{ -inline pa_sample_spec audioFormatToSampleSpec(const QAudioFormat &format) -{ - pa_sample_spec spec; - - spec.rate = format.frequency(); - spec.channels = format.channels(); - - if (format.sampleSize() == 8) - spec.format = PA_SAMPLE_U8; - else if (format.sampleSize() == 16) { - switch (format.byteOrder()) { - case QAudioFormat::BigEndian: spec.format = PA_SAMPLE_S16BE; break; - case QAudioFormat::LittleEndian: spec.format = PA_SAMPLE_S16LE; break; - } - } - else if (format.sampleSize() == 32) { - switch (format.byteOrder()) { - case QAudioFormat::BigEndian: spec.format = PA_SAMPLE_S32BE; break; - case QAudioFormat::LittleEndian: spec.format = PA_SAMPLE_S32LE; break; - } - } - - return spec; -} - -class PulseDaemon -{ -public: - PulseDaemon():m_prepared(false) - { - prepare(); - } - - ~PulseDaemon() - { - if (m_prepared) - release(); - } - - inline void lock() - { - pa_threaded_mainloop_lock(m_mainLoop); - } - - inline void unlock() - { - pa_threaded_mainloop_unlock(m_mainLoop); - } - - inline pa_context *context() const - { - return m_context; - } - - int volume() - { - return m_vol; - } - -private: - void prepare() - { - m_vol = 100; - - m_mainLoop = pa_threaded_mainloop_new(); - if (m_mainLoop == 0) { - qWarning("PulseAudioService: unable to create pulseaudio mainloop"); - return; - } - - if (pa_threaded_mainloop_start(m_mainLoop) != 0) { - qWarning("PulseAudioService: unable to start pulseaudio mainloop"); - pa_threaded_mainloop_free(m_mainLoop); - return; - } - - m_mainLoopApi = pa_threaded_mainloop_get_api(m_mainLoop); - - lock(); - m_context = pa_context_new(m_mainLoopApi, QString(QLatin1String("QtPulseAudio:%1")).arg(::getpid()).toAscii().constData()); - -#if defined(Q_WS_MAEMO_5) - pa_context_set_state_callback(m_context, context_state_callback, this); -#endif - if (m_context == 0) { - qWarning("PulseAudioService: Unable to create new pulseaudio context"); - pa_threaded_mainloop_free(m_mainLoop); - return; - } - - if (pa_context_connect(m_context, NULL, (pa_context_flags_t)0, NULL) < 0) { - qWarning("PulseAudioService: pa_context_connect() failed"); - pa_context_unref(m_context); - pa_threaded_mainloop_free(m_mainLoop); - return; - } - unlock(); - - m_prepared = true; - } - - void release() - { - if (!m_prepared) return; - pa_threaded_mainloop_stop(m_mainLoop); - pa_threaded_mainloop_free(m_mainLoop); - m_prepared = false; - } - -#if defined(Q_WS_MAEMO_5) - static void context_state_callback(pa_context *c, void *userdata) - { - PulseDaemon *self = reinterpret_cast<PulseDaemon*>(userdata); - switch (pa_context_get_state(c)) { - case PA_CONTEXT_CONNECTING: - case PA_CONTEXT_AUTHORIZING: - case PA_CONTEXT_SETTING_NAME: - break; - case PA_CONTEXT_READY: - pa_ext_stream_restore_set_subscribe_cb(c, &stream_restore_monitor_callback, self); - pa_ext_stream_restore_subscribe(c, 1, NULL, self); - break; - default: - break; - } - } - static void stream_restore_monitor_callback(pa_context *c, void *userdata) - { - PulseDaemon *self = reinterpret_cast<PulseDaemon*>(userdata); - pa_ext_stream_restore2_read(c, &stream_restore_info_callback, self); - } - static void stream_restore_info_callback(pa_context *c, const pa_ext_stream_restore2_info *info, - int eol, void *userdata) - { - Q_UNUSED(c) - - PulseDaemon *self = reinterpret_cast<PulseDaemon*>(userdata); - - if (!eol) { - if (QString(info->name).startsWith(QLatin1String("sink-input-by-media-role:x-maemo"))) { - const unsigned str_length = 256; - char str[str_length]; - pa_cvolume_snprint(str, str_length, &info->volume); - self->m_vol = QString(str).replace(" ","").replace("%","").mid(2).toInt(); - } - } - } -#endif - - int m_vol; - bool m_prepared; - pa_context *m_context; - pa_threaded_mainloop *m_mainLoop; - pa_mainloop_api *m_mainLoopApi; -}; -} - -Q_GLOBAL_STATIC(PulseDaemon, daemon) - - -QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): - QObject(parent), - m_retry(false), - m_muted(false), - m_playQueued(false), - m_sampleLoaded(false), - m_volume(100), - m_duration(0), - m_dataUploaded(0), - m_loopCount(1), - m_runningCount(0), - m_reply(0), - m_stream(0), - m_networkAccessManager(0) -{ -} - -QSoundEffectPrivate::~QSoundEffectPrivate() -{ - m_reply->deleteLater(); - unloadSample(); -} - -QUrl QSoundEffectPrivate::source() const -{ - return m_source; -} - -void QSoundEffectPrivate::setSource(const QUrl &url) -{ - if (url.isEmpty()) { - m_source = QUrl(); - unloadSample(); - return; - } - - m_source = url; - - if (m_networkAccessManager == 0) - m_networkAccessManager = new QNetworkAccessManager(this); - - m_stream = m_networkAccessManager->get(QNetworkRequest(m_source)); - - unloadSample(); - loadSample(); -} - -int QSoundEffectPrivate::loopCount() const -{ - return m_loopCount; -} - -void QSoundEffectPrivate::setLoopCount(int loopCount) -{ - m_loopCount = loopCount; -} - -int QSoundEffectPrivate::volume() const -{ - return m_volume; -} - -void QSoundEffectPrivate::setVolume(int volume) -{ - m_volume = volume; -} - -bool QSoundEffectPrivate::isMuted() const -{ - return m_muted; -} - -void QSoundEffectPrivate::setMuted(bool muted) -{ - m_muted = muted; -} - -void QSoundEffectPrivate::play() -{ - if (m_retry) { - m_retry = false; - setSource(m_source); - return; - } - - if (!m_sampleLoaded) { - m_playQueued = true; - return; - } - - m_runningCount += m_loopCount; - - playSample(); -} - -void QSoundEffectPrivate::decoderReady() -{ - if (m_waveDecoder->size() >= PA_SCACHE_ENTRY_SIZE_MAX) { - m_waveDecoder->deleteLater(); - qWarning("QSoundEffect(pulseaudio): Attempting to load to large a sample"); - return; - } - - if (m_name.isNull()) - m_name = QString(QLatin1String("QtPulseSample-%1-%2")).arg(::getpid()).arg(quintptr(this)).toUtf8(); - - pa_sample_spec spec = audioFormatToSampleSpec(m_waveDecoder->audioFormat()); - - daemon()->lock(); - pa_stream *stream = pa_stream_new(daemon()->context(), m_name.constData(), &spec, 0); - pa_stream_set_state_callback(stream, stream_state_callback, this); - pa_stream_set_write_callback(stream, stream_write_callback, this); - pa_stream_connect_upload(stream, (size_t)m_waveDecoder->size()); - m_pulseStream = stream; - daemon()->unlock(); -} - -void QSoundEffectPrivate::decoderError() -{ - qWarning("QSoundEffect(pulseaudio): Error decoding source"); -} - -void QSoundEffectPrivate::checkPlayTime() -{ - int elapsed = m_playbackTime.elapsed(); - - if (elapsed < m_duration) - startTimer(m_duration - elapsed); -} - -void QSoundEffectPrivate::loadSample() -{ - m_sampleLoaded = false; - m_dataUploaded = 0; - m_waveDecoder = new WaveDecoder(m_stream); - connect(m_waveDecoder, SIGNAL(formatKnown()), SLOT(decoderReady())); - connect(m_waveDecoder, SIGNAL(invalidFormat()), SLOT(decoderError())); -} - -void QSoundEffectPrivate::unloadSample() -{ - if (!m_sampleLoaded) - return; - - daemon()->lock(); - pa_context_remove_sample(daemon()->context(), m_name.constData(), NULL, NULL); - daemon()->unlock(); - - m_duration = 0; - m_dataUploaded = 0; - m_sampleLoaded = false; -} - -void QSoundEffectPrivate::uploadSample() -{ - daemon()->lock(); - - size_t bufferSize = qMin(pa_stream_writable_size(m_pulseStream), - size_t(m_waveDecoder->bytesAvailable())); - char buffer[bufferSize]; - - size_t len = 0; - while (len < (m_waveDecoder->size())) { - qint64 read = m_waveDecoder->read(buffer, qMin((int)bufferSize, - (int)(m_waveDecoder->size()-len))); - if (read > 0) { - if (pa_stream_write(m_pulseStream, buffer, size_t(read), 0, 0, PA_SEEK_RELATIVE) == 0) - len += size_t(read); - else - break; - } - } - - m_dataUploaded += len; - pa_stream_set_write_callback(m_pulseStream, NULL, NULL); - - if (m_waveDecoder->size() == m_dataUploaded) { - int err = pa_stream_finish_upload(m_pulseStream); - if(err != 0) { - qWarning("pa_stream_finish_upload() err=%d",err); - pa_stream_disconnect(m_pulseStream); - m_retry = true; - m_playQueued = false; - QMetaObject::invokeMethod(this, "play"); - daemon()->unlock(); - return; - } - m_duration = m_waveDecoder->duration(); - m_waveDecoder->deleteLater(); - m_stream->deleteLater(); - m_sampleLoaded = true; - if (m_playQueued) { - m_playQueued = false; - QMetaObject::invokeMethod(this, "play"); - } - } - daemon()->unlock(); -} - -void QSoundEffectPrivate::playSample() -{ - pa_volume_t volume = PA_VOLUME_NORM; - - daemon()->lock(); -#ifdef Q_WS_MAEMO_5 - volume = PA_VOLUME_NORM / 100 * ((daemon()->volume() + m_volume) / 2); -#endif - pa_operation_unref( - pa_context_play_sample(daemon()->context(), - m_name.constData(), - 0, - volume, - play_callback, - this) - ); - daemon()->unlock(); - - m_playbackTime.start(); -} - -void QSoundEffectPrivate::timerEvent(QTimerEvent *event) -{ - if (m_runningCount > 0) - playSample(); - - killTimer(event->timerId()); -} - -void QSoundEffectPrivate::stream_write_callback(pa_stream *s, size_t length, void *userdata) -{ - Q_UNUSED(length); - - QSoundEffectPrivate *self = reinterpret_cast<QSoundEffectPrivate*>(userdata); - - QMetaObject::invokeMethod(self, "uploadSample", Qt::QueuedConnection); -} - -void QSoundEffectPrivate::stream_state_callback(pa_stream *s, void *userdata) -{ - switch (pa_stream_get_state(s)) { - case PA_STREAM_CREATING: - case PA_STREAM_READY: - case PA_STREAM_TERMINATED: - break; - - case PA_STREAM_FAILED: - default: - qWarning("QSoundEffect(pulseaudio): Error in pulse audio stream"); - break; - } -} - -void QSoundEffectPrivate::play_callback(pa_context *c, int success, void *userdata) -{ - Q_UNUSED(c); - - QSoundEffectPrivate *self = reinterpret_cast<QSoundEffectPrivate*>(userdata); - - if (success == 1) { - self->m_runningCount--; - QMetaObject::invokeMethod(self, "checkPlayTime", Qt::QueuedConnection); - } -} - -QT_END_NAMESPACE diff --git a/src/multimedia/mediaservices/effects/qsoundeffect_pulse_p.h b/src/multimedia/mediaservices/effects/qsoundeffect_pulse_p.h deleted file mode 100644 index 1327bf5..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect_pulse_p.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices module 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 QSOUNDEFFECT_PULSE_H -#define QSOUNDEFFECT_PULSE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#include "qsoundeffect_p.h" - -#include <QtCore/qobject.h> -#include <QtCore/qdatetime.h> -#include <QtMediaServices/qmediaplayer.h> -#include <pulse/pulseaudio.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QNetworkReply; -class QNetworkAccessManager; -class WaveDecoder; - -class QSoundEffectPrivate : public QObject -{ - Q_OBJECT -public: - explicit QSoundEffectPrivate(QObject* parent); - ~QSoundEffectPrivate(); - - QUrl source() const; - void setSource(const QUrl &url); - int loopCount() const; - void setLoopCount(int loopCount); - int volume() const; - void setVolume(int volume); - bool isMuted() const; - void setMuted(bool muted); - -public Q_SLOTS: - void play(); - -Q_SIGNALS: - void volumeChanged(); - void mutedChanged(); - -private Q_SLOTS: - void decoderReady(); - void decoderError(); - void checkPlayTime(); - void uploadSample(); - -private: - void loadSample(); - void unloadSample(); - void playSample(); - - void timerEvent(QTimerEvent *event); - - static void stream_write_callback(pa_stream *s, size_t length, void *userdata); - static void stream_state_callback(pa_stream *s, void *userdata); - static void play_callback(pa_context *c, int success, void *userdata); - - pa_stream *m_pulseStream; - - bool m_retry; - bool m_muted; - bool m_playQueued; - bool m_sampleLoaded; - int m_volume; - int m_duration; - int m_dataUploaded; - int m_loopCount; - int m_runningCount; - QUrl m_source; - QTime m_playbackTime; - QByteArray m_name; - QNetworkReply *m_reply; - WaveDecoder *m_waveDecoder; - QIODevice *m_stream; - QNetworkAccessManager *m_networkAccessManager; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QSOUNDEFFECT_PULSE_H diff --git a/src/multimedia/mediaservices/effects/qsoundeffect_qmedia_p.cpp b/src/multimedia/mediaservices/effects/qsoundeffect_qmedia_p.cpp deleted file mode 100644 index 5e40bed..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect_qmedia_p.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices module 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qsoundeffect_qmedia_p.h" - -#include <QtCore/qcoreapplication.h> - -#include <QtMediaServices/qmediacontent.h> -#include <QtMediaServices/qmediaplayer.h> - - -QT_BEGIN_NAMESPACE - -QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): - QObject(parent), - m_loopCount(1), - m_runningCount(0), - m_player(0) -{ - m_player = new QMediaPlayer(this, QMediaPlayer::LowLatency); - connect(m_player, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(stateChanged(QMediaPlayer::State))); -} - -QSoundEffectPrivate::~QSoundEffectPrivate() -{ -} - -QUrl QSoundEffectPrivate::source() const -{ - return m_player->media().canonicalUrl(); -} - -void QSoundEffectPrivate::setSource(const QUrl &url) -{ - m_player->setMedia(url); -} - -int QSoundEffectPrivate::loopCount() const -{ - return m_loopCount; -} - -void QSoundEffectPrivate::setLoopCount(int loopCount) -{ - m_loopCount = loopCount; -} - -int QSoundEffectPrivate::volume() const -{ - return m_player->volume(); -} - -void QSoundEffectPrivate::setVolume(int volume) -{ - m_player->setVolume(volume); -} - -bool QSoundEffectPrivate::isMuted() const -{ - return m_player->isMuted(); -} - -void QSoundEffectPrivate::setMuted(bool muted) -{ - m_player->setMuted(muted); -} - -void QSoundEffectPrivate::play() -{ - m_runningCount += m_loopCount; - m_player->play(); -} - -void QSoundEffectPrivate::stateChanged(QMediaPlayer::State state) -{ - if (state == QMediaPlayer::StoppedState) { - if (--m_runningCount > 0) - m_player->play(); - } -} - -QT_END_NAMESPACE - diff --git a/src/multimedia/mediaservices/effects/qsoundeffect_qmedia_p.h b/src/multimedia/mediaservices/effects/qsoundeffect_qmedia_p.h deleted file mode 100644 index 82ea000..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect_qmedia_p.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices module 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 QSOUNDEFFECT_QMEDIA_H -#define QSOUNDEFFECT_QMEDIA_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#include <QtCore/qobject.h> -#include <QtCore/qurl.h> -#include <QtMediaServices/qmediaplayer.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QSoundEffectPrivate : public QObject -{ - Q_OBJECT -public: - explicit QSoundEffectPrivate(QObject* parent); - ~QSoundEffectPrivate(); - - QUrl source() const; - void setSource(const QUrl &url); - int loopCount() const; - void setLoopCount(int loopCount); - int volume() const; - void setVolume(int volume); - bool isMuted() const; - void setMuted(bool muted); - -public Q_SLOTS: - void play(); - -Q_SIGNALS: - void volumeChanged(); - void mutedChanged(); - -private Q_SLOTS: - void stateChanged(QMediaPlayer::State); - -private: - int m_loopCount; - int m_runningCount; - QMediaPlayer *m_player; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QSOUNDEFFECT_QMEDIA_H diff --git a/src/multimedia/mediaservices/effects/qsoundeffect_qsound_p.cpp b/src/multimedia/mediaservices/effects/qsoundeffect_qsound_p.cpp deleted file mode 100644 index 9247aba..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect_qsound_p.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices module 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qsoundeffect_qsound_p.h" - -#include <QtCore/qcoreapplication.h> -#include <QtGui/qsound.h> - - -QT_BEGIN_NAMESPACE - -QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): - QObject(parent), - m_muted(false), - m_loopCount(1), - m_volume(100), - m_sound(0) -{ -} - -QSoundEffectPrivate::~QSoundEffectPrivate() -{ -} - -QUrl QSoundEffectPrivate::source() const -{ - return m_source; -} - -void QSoundEffectPrivate::setSource(const QUrl &url) -{ - if (url.isEmpty() || url.scheme() != QLatin1String("file")) { - m_source = QUrl(); - return; - } - - if (m_sound != 0) - delete m_sound; - - m_source = url; - m_sound = new QSound(m_source.toLocalFile(), this); - m_sound->setLoops(m_loopCount); -} - -int QSoundEffectPrivate::loopCount() const -{ - return m_loopCount; -} - -void QSoundEffectPrivate::setLoopCount(int lc) -{ - m_loopCount = lc; - if (m_sound) - m_sound->setLoops(lc); -} - -int QSoundEffectPrivate::volume() const -{ - return m_volume; -} - -void QSoundEffectPrivate::setVolume(int v) -{ - m_volume = v; -} - -bool QSoundEffectPrivate::isMuted() const -{ - return m_muted; -} - -void QSoundEffectPrivate::setMuted(bool muted) -{ - m_muted = muted; -} - -void QSoundEffectPrivate::play() -{ - m_sound->play(); -} - -QT_END_NAMESPACE diff --git a/src/multimedia/mediaservices/effects/qsoundeffect_qsound_p.h b/src/multimedia/mediaservices/effects/qsoundeffect_qsound_p.h deleted file mode 100644 index dad7b6f..0000000 --- a/src/multimedia/mediaservices/effects/qsoundeffect_qsound_p.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices module 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 QSOUNDEFFECT_QSOUND_H -#define QSOUNDEFFECT_QSOUND_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#include <QtCore/qobject.h> -#include <QtCore/qurl.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QSound; - -class QSoundEffectPrivate : public QObject -{ - Q_OBJECT -public: - explicit QSoundEffectPrivate(QObject* parent); - ~QSoundEffectPrivate(); - - QUrl source() const; - void setSource(const QUrl &url); - int loopCount() const; - void setLoopCount(int loopCount); - int volume() const; - void setVolume(int volume); - bool isMuted() const; - void setMuted(bool muted); - -public Q_SLOTS: - void play(); - -Q_SIGNALS: - void volumeChanged(); - void mutedChanged(); - -private: - bool m_muted; - int m_loopCount; - int m_volume; - QSound *m_sound; - QUrl m_source; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QSOUNDEFFECT_QSOUND_H diff --git a/src/multimedia/mediaservices/effects/wavedecoder_p.cpp b/src/multimedia/mediaservices/effects/wavedecoder_p.cpp deleted file mode 100644 index 1c26c8f..0000000 --- a/src/multimedia/mediaservices/effects/wavedecoder_p.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices module 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 "wavedecoder_p.h" - -#include <QtCore/qtimer.h> -#include <QtCore/qendian.h> - -QT_BEGIN_NAMESPACE - -WaveDecoder::WaveDecoder(QIODevice *s, QObject *parent): - QIODevice(parent), - haveFormat(false), - dataSize(0), - remaining(0), - source(s) -{ - open(QIODevice::ReadOnly | QIODevice::Unbuffered); - - if (source->bytesAvailable() >= qint64(sizeof(CombinedHeader) + sizeof(DATAHeader) + sizeof(quint16))) - QTimer::singleShot(0, this, SLOT(handleData())); - else - connect(source, SIGNAL(readyRead()), SLOT(handleData())); -} - -WaveDecoder::~WaveDecoder() -{ -} - -QAudioFormat WaveDecoder::audioFormat() const -{ - return format; -} - -int WaveDecoder::duration() const -{ - return size() * 1000 / (format.sampleSize() / 8) / format.channels() / format.frequency(); -} - -qint64 WaveDecoder::size() const -{ - return haveFormat ? dataSize : 0; -} - -bool WaveDecoder::isSequential() const -{ - return source->isSequential(); -} - -qint64 WaveDecoder::bytesAvailable() const -{ - return haveFormat ? source->bytesAvailable() : 0; -} - -qint64 WaveDecoder::readData(char *data, qint64 maxlen) -{ - return haveFormat ? source->read(data, maxlen) : 0; -} - -qint64 WaveDecoder::writeData(const char *data, qint64 len) -{ - Q_UNUSED(data); - Q_UNUSED(len); - - return -1; -} - -void WaveDecoder::handleData() -{ - if (source->bytesAvailable() < qint64(sizeof(CombinedHeader) + sizeof(DATAHeader) + sizeof(quint16))) - return; - - source->disconnect(SIGNAL(readyRead()), this, SLOT(handleData())); - source->read((char*)&header, sizeof(CombinedHeader)); - - if (qstrncmp(header.riff.descriptor.id, "RIFF", 4) != 0 || - qstrncmp(header.riff.type, "WAVE", 4) != 0 || - qstrncmp(header.wave.descriptor.id, "fmt ", 4) != 0 || - (header.wave.audioFormat != 0 && header.wave.audioFormat != 1)) { - - emit invalidFormat(); - } - else { - DATAHeader dataHeader; - - if (qFromLittleEndian<quint32>(header.wave.descriptor.size) > sizeof(WAVEHeader)) { - // Extended data available - quint16 extraFormatBytes; - source->peek((char*)&extraFormatBytes, sizeof(quint16)); - extraFormatBytes = qFromLittleEndian<quint16>(extraFormatBytes); - source->read(sizeof(quint16) + extraFormatBytes); // dump it all - } - - source->read((char*)&dataHeader, sizeof(DATAHeader)); - - int bps = qFromLittleEndian<quint16>(header.wave.bitsPerSample); - - format.setCodec(QLatin1String("audio/pcm")); - format.setSampleType(bps == 8 ? QAudioFormat::UnSignedInt : QAudioFormat::SignedInt); - format.setByteOrder(QAudioFormat::LittleEndian); - format.setFrequency(qFromLittleEndian<quint32>(header.wave.sampleRate)); - format.setSampleSize(bps); - format.setChannels(qFromLittleEndian<quint16>(header.wave.numChannels)); - - dataSize = qFromLittleEndian<quint32>(dataHeader.descriptor.size); - - haveFormat = true; - connect(source, SIGNAL(readyRead()), SIGNAL(readyRead())); - emit formatKnown(); - } -} - -QT_END_NAMESPACE diff --git a/src/multimedia/mediaservices/effects/wavedecoder_p.h b/src/multimedia/mediaservices/effects/wavedecoder_p.h deleted file mode 100644 index dcc5453..0000000 --- a/src/multimedia/mediaservices/effects/wavedecoder_p.h +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMediaServices module 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 WAVEDECODER_H -#define WAVEDECODER_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qiodevice.h> -#include <QtMultimedia/qaudioformat.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class WaveDecoder : public QIODevice -{ - Q_OBJECT - -public: - explicit WaveDecoder(QIODevice *source, QObject *parent = 0); - ~WaveDecoder(); - - QAudioFormat audioFormat() const; - int duration() const; - - qint64 size() const; - bool isSequential() const; - qint64 bytesAvailable() const; - -Q_SIGNALS: - void formatKnown(); - void invalidFormat(); - -private Q_SLOTS: - void handleData(); - -private: - qint64 readData(char *data, qint64 maxlen); - qint64 writeData(const char *data, qint64 len); - - struct chunk - { - char id[4]; - quint32 size; - }; - struct RIFFHeader - { - chunk descriptor; - char type[4]; - }; - struct WAVEHeader - { - chunk descriptor; - quint16 audioFormat; - quint16 numChannels; - quint32 sampleRate; - quint32 byteRate; - quint16 blockAlign; - quint16 bitsPerSample; - }; - struct DATAHeader - { - chunk descriptor; - }; - struct CombinedHeader - { - RIFFHeader riff; - WAVEHeader wave; - }; - - bool haveFormat; - qint64 dataSize; - qint64 remaining; - QAudioFormat format; - QIODevice *source; - CombinedHeader header; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // WAVEDECODER_H diff --git a/src/multimedia/mediaservices/mediaservices.pro b/src/multimedia/mediaservices/mediaservices.pro deleted file mode 100644 index 8a065f4..0000000 --- a/src/multimedia/mediaservices/mediaservices.pro +++ /dev/null @@ -1,23 +0,0 @@ -TARGET = QtMediaServices -QPRO_PWD = $$PWD -QT = core gui multimedia - -contains(QT_CONFIG, opengl): QT += opengl - -DEFINES += QT_BUILD_MEDIASERVICES_LIB QT_NO_USING_NAMESPACE - -unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtMultimedia - -include(../../qbase.pri) - -include(base/base.pri) -include(playback/playback.pri) -include(effects/effects.pri) - -symbian: { - TARGET.UID3 = 0x2001E631 - contains(CONFIG, def_files) { - DEF_FILE=../../s60installs - } -} - diff --git a/src/multimedia/mediaservices/playback/playback.pri b/src/multimedia/mediaservices/playback/playback.pri deleted file mode 100644 index 09a81c9..0000000 --- a/src/multimedia/mediaservices/playback/playback.pri +++ /dev/null @@ -1,11 +0,0 @@ - -HEADERS += \ - $$PWD/qmediaplayer.h \ - $$PWD/qmediaplayercontrol.h - -SOURCES += \ - $$PWD/qmediaplayer.cpp \ - $$PWD/qmediaplayercontrol.cpp - - - diff --git a/src/multimedia/mediaservices/playback/qmediaplayer.cpp b/src/multimedia/mediaservices/playback/qmediaplayer.cpp deleted file mode 100644 index ca1f250..0000000 --- a/src/multimedia/mediaservices/playback/qmediaplayer.cpp +++ /dev/null @@ -1,996 +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 QtMediaServices module 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/qcoreevent.h> -#include <QtCore/qmetaobject.h> -#include <QtCore/qtimer.h> -#include <QtCore/qpointer.h> -#include <QtCore/qdebug.h> - -#include <QtMediaServices/qmediaplayer.h> - -#include <QtMediaServices/private/qmediaobject_p.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmediaplayercontrol.h> -#include <QtMediaServices/qmediaserviceprovider.h> -#include <QtMediaServices/qmediaplaylist.h> -#include <QtMediaServices/qmediaplaylistcontrol.h> -#include <QtMediaServices/qvideowidget.h> -#include <QtMediaServices/qgraphicsvideoitem.h> - -//#define DEBUG_PLAYER_STATE - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -/*! - \class QMediaPlayer - \brief The QMediaPlayer class allows the playing of a media source. - \ingroup multimedia - \since 4.7 - \preliminary - - The QMediaPlayer class is a high level media playback class. It can be used - to playback such content as songs, movies and internet radio. The content - to playback is specified as a QMediaContent, which can be thought of as a - main or canonical URL with addition information attached. When provided - with a QMediaContent playback may be able to commence. - - \code - player = new QMediaPlayer; - connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64))); - player->setMedia(QUrl::fromLocalFile("/Users/me/Music/coolsong.mp3")); - player->setVolume(50); - player->play(); - \endcode - - QVideoWidget can be used with QMediaPlayer for video rendering and QMediaPlaylist - for accessing playlist functionality. - - \code - player = new QMediaPlayer; - - playlist = new QMediaPlaylist; - playlist->setMediaObject(player); - playlist->append(QUrl("http://example.com/movie1.mp4")); - playlist->append(QUrl("http://example.com/movie2.mp4")); - - widget = new QVideoWidget; - widget->setMediaObject(player); - widget->show(); - - player->play(); - \endcode - - \sa QMediaObject, QMediaService, QVideoWidget, QMediaPlaylist -*/ - -namespace -{ -class MediaPlayerRegisterMetaTypes -{ -public: - MediaPlayerRegisterMetaTypes() - { - qRegisterMetaType<QMediaPlayer::State>(); - qRegisterMetaType<QMediaPlayer::MediaStatus>(); - qRegisterMetaType<QMediaPlayer::Error>(); - } -} _registerPlayerMetaTypes; -} - -class QMediaPlayerPrivate : public QMediaObjectPrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QMediaPlayer) - -public: - QMediaPlayerPrivate() - : provider(0) - , control(0) - , playlistControl(0) - , state(QMediaPlayer::StoppedState) - , error(QMediaPlayer::NoError) - , filterStates(false) - , playlist(0) - {} - - QMediaServiceProvider *provider; - QMediaPlayerControl* control; - QMediaPlaylistControl* playlistControl; - QMediaPlayer::State state; - QMediaPlayer::Error error; - QString errorString; - bool filterStates; - - QMediaPlaylist *playlist; - QPointer<QVideoWidget> videoWidget; -#ifndef QT_NO_GRAPHICSVIEW - QPointer<QGraphicsVideoItem> videoItem; -#endif - - void _q_stateChanged(QMediaPlayer::State state); - void _q_mediaStatusChanged(QMediaPlayer::MediaStatus status); - void _q_error(int error, const QString &errorString); - void _q_updateMedia(const QMediaContent&); - void _q_playlistDestroyed(); -}; - -#define ENUM_NAME(c,e,v) (c::staticMetaObject.enumerator(c::staticMetaObject.indexOfEnumerator(e)).valueToKey((v))) - -void QMediaPlayerPrivate::_q_stateChanged(QMediaPlayer::State ps) -{ - Q_Q(QMediaPlayer); - -#ifdef DEBUG_PLAYER_STATE - qDebug() << "State changed:" << ENUM_NAME(QMediaPlayer, "State", ps) << (filterStates ? "(filtered)" : ""); -#endif - - if (filterStates) - return; - - if (playlist - && !playlistControl //service should do this itself - && ps != state && ps == QMediaPlayer::StoppedState - && control->mediaStatus() == QMediaPlayer::EndOfMedia) { - playlist->next(); - ps = control->state(); - } - - if (ps != state) { - state = ps; - - if (ps == QMediaPlayer::PlayingState) - q->addPropertyWatch("position"); - else - q->removePropertyWatch("position"); - - emit q->stateChanged(ps); - } -} - -void QMediaPlayerPrivate::_q_mediaStatusChanged(QMediaPlayer::MediaStatus status) -{ - Q_Q(QMediaPlayer); - -#ifdef DEBUG_PLAYER_STATE - qDebug() << "MediaStatus changed:" << ENUM_NAME(QMediaPlayer, "MediaStatus", status); -#endif - - switch (status) { - case QMediaPlayer::StalledMedia: - case QMediaPlayer::BufferingMedia: - q->addPropertyWatch("bufferStatus"); - emit q->mediaStatusChanged(status); - break; - default: - q->removePropertyWatch("bufferStatus"); - emit q->mediaStatusChanged(status); - break; - } - -} - -void QMediaPlayerPrivate::_q_error(int error, const QString &errorString) -{ - Q_Q(QMediaPlayer); - - this->error = QMediaPlayer::Error(error); - this->errorString = errorString; - - emit q->error(this->error); -} - -void QMediaPlayerPrivate::_q_updateMedia(const QMediaContent &media) -{ - const QMediaPlayer::State currentState = state; - - filterStates = true; - control->setMedia(media, 0); - - if (!media.isNull()) { - switch (currentState) { - case QMediaPlayer::PlayingState: - control->play(); - break; - case QMediaPlayer::PausedState: - control->pause(); - break; - default: - break; - } - } - filterStates = false; - - state = control->state(); - - if (state != currentState) { -#ifdef DEBUG_PLAYER_STATE - qDebug() << "State changed:" << ENUM_NAME(QMediaPlayer, "State", state); -#endif - emit q_func()->stateChanged(state); - } -} - -void QMediaPlayerPrivate::_q_playlistDestroyed() -{ - playlist = 0; - - control->setMedia(QMediaContent(), 0); -} - -static QMediaService *playerService(QMediaPlayer::Flags flags, QMediaServiceProvider *provider) -{ - if (flags) { - QMediaServiceProviderHint::Features features = 0; - if (flags & QMediaPlayer::LowLatency) - features |= QMediaServiceProviderHint::LowLatencyPlayback; - - if (flags & QMediaPlayer::StreamPlayback) - features |= QMediaServiceProviderHint::StreamPlayback; - - return provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER, - QMediaServiceProviderHint(features)); - } else - return provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER); -} - - -/*! - Construct a QMediaPlayer that uses the playback service from \a provider, - parented to \a parent and with \a flags. - - If a playback service is not specified the system default will be used. -*/ - -QMediaPlayer::QMediaPlayer(QObject *parent, QMediaPlayer::Flags flags, QMediaServiceProvider *provider): - QMediaObject(*new QMediaPlayerPrivate, - parent, - playerService(flags,provider)) -{ - Q_D(QMediaPlayer); - - d->provider = provider; - - if (d->service == 0) { - d->error = ServiceMissingError; - } else { - d->control = qobject_cast<QMediaPlayerControl*>(d->service->control(QMediaPlayerControl_iid)); - d->playlistControl = qobject_cast<QMediaPlaylistControl*>(d->service->control(QMediaPlaylistControl_iid)); - if (d->control != 0) { - connect(d->control, SIGNAL(mediaChanged(QMediaContent)), SIGNAL(mediaChanged(QMediaContent))); - connect(d->control, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(_q_stateChanged(QMediaPlayer::State))); - connect(d->control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), - SLOT(_q_mediaStatusChanged(QMediaPlayer::MediaStatus))); - connect(d->control, SIGNAL(error(int,QString)), SLOT(_q_error(int,QString))); - - connect(d->control, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged(qint64))); - connect(d->control, SIGNAL(positionChanged(qint64)), SIGNAL(positionChanged(qint64))); - connect(d->control, SIGNAL(audioAvailableChanged(bool)), SIGNAL(audioAvailableChanged(bool))); - connect(d->control, SIGNAL(videoAvailableChanged(bool)), SIGNAL(videoAvailableChanged(bool))); - connect(d->control, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged(int))); - connect(d->control, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool))); - connect(d->control, SIGNAL(seekableChanged(bool)), SIGNAL(seekableChanged(bool))); - connect(d->control, SIGNAL(playbackRateChanged(qreal)), SIGNAL(playbackRateChanged(qreal))); - - if (d->control->state() == PlayingState) - addPropertyWatch("position"); - - if (d->control->mediaStatus() == StalledMedia || d->control->mediaStatus() == BufferingMedia) - addPropertyWatch("bufferStatus"); - } - } -} - - -/*! - Destroys the player object. -*/ - -QMediaPlayer::~QMediaPlayer() -{ - Q_D(QMediaPlayer); - - d->provider->releaseService(d->service); -} - -QMediaContent QMediaPlayer::media() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->media(); - - return QMediaContent(); -} - -/*! - Returns the stream source of media data. - - This is only valid if a stream was passed to setMedia(). - - \sa setMedia() -*/ - -const QIODevice *QMediaPlayer::mediaStream() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->mediaStream(); - - return 0; -} - -QMediaPlayer::State QMediaPlayer::state() const -{ - return d_func()->state; -} - -QMediaPlayer::MediaStatus QMediaPlayer::mediaStatus() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->mediaStatus(); - - return QMediaPlayer::UnknownMediaStatus; -} - -qint64 QMediaPlayer::duration() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->duration(); - - return -1; -} - -qint64 QMediaPlayer::position() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->position(); - - return 0; -} - -int QMediaPlayer::volume() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->volume(); - - return 0; -} - -bool QMediaPlayer::isMuted() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->isMuted(); - - return false; -} - -int QMediaPlayer::bufferStatus() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->bufferStatus(); - - return 0; -} - -bool QMediaPlayer::isAudioAvailable() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->isAudioAvailable(); - - return false; -} - -bool QMediaPlayer::isVideoAvailable() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->isVideoAvailable(); - - return false; -} - -bool QMediaPlayer::isSeekable() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->isSeekable(); - - return false; -} - -qreal QMediaPlayer::playbackRate() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->playbackRate(); - - return 0.0; -} - -/*! - Returns the current error state. -*/ - -QMediaPlayer::Error QMediaPlayer::error() const -{ - return d_func()->error; -} - -QString QMediaPlayer::errorString() const -{ - return d_func()->errorString; -} - -//public Q_SLOTS: -/*! - Start or resume playing the current source. -*/ - -void QMediaPlayer::play() -{ - Q_D(QMediaPlayer); - - if (d->control == 0) { - QMetaObject::invokeMethod(this, "_q_error", Qt::QueuedConnection, - Q_ARG(int, QMediaPlayer::ServiceMissingError), - Q_ARG(QString, tr("The QMediaPlayer object does not have a valid service"))); - return; - } - - //if playlist control is available, the service should advance itself - if (d->playlist && !d->playlistControl && d->playlist->currentIndex() == -1 && !d->playlist->isEmpty()) - d->playlist->setCurrentIndex(0); - - // Reset error conditions - d->error = NoError; - d->errorString = QString(); - - d->control->play(); -} - -/*! - Pause playing the current source. -*/ - -void QMediaPlayer::pause() -{ - Q_D(QMediaPlayer); - - if (d->control != 0) - d->control->pause(); -} - -/*! - Stop playing, and reset the play position to the beginning. -*/ - -void QMediaPlayer::stop() -{ - Q_D(QMediaPlayer); - - if (d->control != 0) - d->control->stop(); -} - -void QMediaPlayer::setPosition(qint64 position) -{ - Q_D(QMediaPlayer); - - if (d->control == 0 || !isSeekable()) - return; - - d->control->setPosition(qBound(qint64(0), duration(), position)); -} - -void QMediaPlayer::setVolume(int v) -{ - Q_D(QMediaPlayer); - - if (d->control == 0) - return; - - int clamped = qBound(0, v, 100); - if (clamped == volume()) - return; - - d->control->setVolume(clamped); -} - -void QMediaPlayer::setMuted(bool muted) -{ - Q_D(QMediaPlayer); - - if (d->control == 0 || muted == isMuted()) - return; - - d->control->setMuted(muted); -} - -void QMediaPlayer::setPlaybackRate(qreal rate) -{ - Q_D(QMediaPlayer); - - if (d->control != 0) - d->control->setPlaybackRate(rate); -} - -/*! - Sets the current \a media source. - - If a \a stream is supplied; media data will be read from it instead of resolving the media - source. In this case the media source may still be used to resolve additional information - about the media such as mime type. - - Setting the media to a null QMediaContent will cause the player to discard all - information relating to the current media source and to cease all I/O operations related - to that media. -*/ - -void QMediaPlayer::setMedia(const QMediaContent &media, QIODevice *stream) -{ - Q_D(QMediaPlayer); - - if (d->control != 0) - d_func()->control->setMedia(media, stream); -} - -/*! - \internal -*/ - -void QMediaPlayer::bind(QObject *obj) -{ - Q_D(QMediaPlayer); - - if (d->control != 0) { - QMediaPlaylist *playlist = qobject_cast<QMediaPlaylist*>(obj); - - if (playlist) { - if (d->playlist) - d->playlist->setMediaObject(0); - - d->playlist = playlist; - connect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), - this, SLOT(_q_updateMedia(QMediaContent))); - connect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); - - setMedia(playlist->currentMedia()); - - return; - } - - QVideoWidget *videoWidget = qobject_cast<QVideoWidget*>(obj); -#ifndef QT_NO_GRAPHICSVIEW - QGraphicsVideoItem *videoItem = qobject_cast<QGraphicsVideoItem*>(obj); -#endif - - if (videoWidget -#ifndef QT_NO_GRAPHICSVIEW - || videoItem -#endif - ) { - //detach the current video output - if (d->videoWidget) { - d->videoWidget->setMediaObject(0); - d->videoWidget = 0; - } - -#ifndef QT_NO_GRAPHICSVIEW - if (d->videoItem) { - d->videoItem->setMediaObject(0); - d->videoItem = 0; - } -#endif - } - - if (videoWidget) - d->videoWidget = videoWidget; - -#ifndef QT_NO_GRAPHICSVIEW - if (videoItem) - d->videoItem = videoItem; -#endif - } -} - -/*! - \internal -*/ - -void QMediaPlayer::unbind(QObject *obj) -{ - Q_D(QMediaPlayer); - - if (obj == d->videoWidget) { - d->videoWidget = 0; -#ifndef QT_NO_GRAPHICSVIEW - } else if (obj == d->videoItem) { - d->videoItem = 0; -#endif - } else if (obj == d->playlist) { - disconnect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), - this, SLOT(_q_updateMedia(QMediaContent))); - disconnect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); - d->playlist = 0; - setMedia(QMediaContent()); - } -} - -/*! - Returns the level of support a media player has for a \a mimeType and a set of \a codecs. - - The \a flags argument allows additional requirements such as performance indicators to be - specified. -*/ -QtMediaServices::SupportEstimate QMediaPlayer::hasSupport(const QString &mimeType, - const QStringList& codecs, - Flags flags) -{ - return QMediaServiceProvider::defaultServiceProvider()->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), - mimeType, - codecs, - flags); -} - -/*! - Returns a list of MIME types supported by the media player. - - The \a flags argument causes the resultant list to be restricted to MIME types which can be supported - given additional requirements, such as performance indicators. -*/ -QStringList QMediaPlayer::supportedMimeTypes(Flags flags) -{ - return QMediaServiceProvider::defaultServiceProvider()->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), - flags); -} - - -// Enums -/*! - \enum QMediaPlayer::State - - Defines the current state of a media player. - - \value PlayingState The media player is currently playing content. - \value PausedState The media player has paused playback, playback of the current track will - resume from the position the player was paused at. - \value StoppedState The media player is not playing content, playback will begin from the start - of the current track. -*/ - -/*! - \enum QMediaPlayer::MediaStatus - - Defines the status of a media player's current media. - - \value UnknownMediaStatus The status of the media cannot be determined. - \value NoMedia The is no current media. The player is in the StoppedState. - \value LoadingMedia The current media is being loaded. The player may be in any state. - \value LoadedMedia The current media has been loaded. The player is in the StoppedState. - \value StalledMedia Playback of the current media has stalled due to insufficient buffering or - some other temporary interruption. The player is in the PlayingState or PausedState. - \value BufferingMedia The player is buffering data but has enough data buffered for playback to - continue for the immediate future. The player is in the PlayingState or PausedState. - \value BufferedMedia The player has fully buffered the current media. The player is in the - PlayingState or PausedState. - \value EndOfMedia Playback has reached the end of the current media. The player is in the - StoppedState. - \value InvalidMedia The current media cannot be played. The player is in the StoppedState. -*/ - -/*! - \enum QMediaPlayer::Error - - Defines a media player error condition. - - \value NoError No error has occurred. - \value ResourceError A media resource couldn't be resolved. - \value FormatError The format of a media resource isn't (fully) supported. Playback may still - be possible, but without an audio or video component. - \value NetworkError A network error occurred. - \value AccessDeniedError There are not the appropriate permissions to play a media resource. - \value ServiceMissingError A valid playback service was not found, playback cannot proceed. -*/ - -// Signals -/*! - \fn QMediaPlayer::error(QMediaPlayer::Error error) - - Signals that an \a error condition has occurred. - - \sa errorString() -*/ - -/*! - \fn void QMediaPlayer::stateChanged(State state) - - Signal the \a state of the Player object has changed. -*/ - -/*! - \fn QMediaPlayer::mediaStatusChanged(QMediaPlayer::MediaStatus status) - - Signals that the \a status of the current media has changed. - - \sa mediaStatus() -*/ - -/*! - \fn void QMediaPlayer::mediaChanged(const QMediaContent &media); - - Signals that the current playing content will be obtained from \a media. - - \sa media() -*/ - -/*! - \fn void QMediaPlayer::playbackRateChanged(qreal rate); - - Signals the playbackRate has changed to \a rate. -*/ - -/*! - \fn void QMediaPlayer::seekableChanged(bool seekable); - - Signals the \a seekable status of the player object has changed. -*/ - -// Properties -/*! - \property QMediaPlayer::state - \brief the media player's playback state. - - By default this property is QMediaPlayer::Stopped - - \sa mediaStatus(), play(), pause(), stop() -*/ - -/*! - \property QMediaPlayer::error - \brief a string describing the last error condition. - - \sa error() -*/ - -/*! - \property QMediaPlayer::media - \brief the active media source being used by the player object. - - The player object will use the QMediaContent for selection of the content to - be played. - - By default this property has a null QMediaContent. - - Setting this property to a null QMediaContent will cause the player to discard all - information relating to the current media source and to cease all I/O operations related - to that media. - - \sa QMediaContent -*/ - -/*! - \property QMediaPlayer::mediaStatus - \brief the status of the current media stream. - - The stream status describes how the playback of the current stream is - progressing. - - By default this property is QMediaPlayer::NoMedia - - \sa state -*/ - -/*! - \property QMediaPlayer::duration - \brief the duration of the current media. - - The value is the total playback time in milliseconds of the current media. - The value may change across the life time of the QMediaPlayer object and - may not be available when initial playback begins, connect to the - durationChanged() signal to receive status notifications. -*/ - -/*! - \property QMediaPlayer::position - \brief the playback position of the current media. - - The value is the current playback position, expressed in milliseconds since - the beginning of the media. Periodically changes in the position will be - indicated with the signal positionChanged(), the interval between updates - can be set with QMediaObject's method setNotifyInterval(). -*/ - -/*! - \property QMediaPlayer::volume - \brief the current playback volume. - - The playback volume is a linear in effect and the value can range from 0 - - 100, values outside this range will be clamped. -*/ - -/*! - \property QMediaPlayer::muted - \brief the muted state of the current media. - - The value will be true if the playback volume is muted; otherwise false. -*/ - -/*! - \property QMediaPlayer::bufferStatus - \brief the percentage of the temporary buffer filled before playback begins. - - When the player object is buffering; this property holds the percentage of - the temporary buffer that is filled. The buffer will need to reach 100% - filled before playback can resume, at which time the MediaStatus will be - BufferedMedia. - - \sa mediaStatus() -*/ - -/*! - \property QMediaPlayer::audioAvailable - \brief the audio availabilty status for the current media. - - As the life time of QMediaPlayer can be longer than the playback of one - QMediaContent, this property may change over time, the - audioAvailableChanged signal can be used to monitor it's status. -*/ - -/*! - \property QMediaPlayer::videoAvailable - \brief the video availability status for the current media. - - If available, the QVideoWidget class can be used to view the video. As the - life time of QMediaPlayer can be longer than the playback of one - QMediaContent, this property may change over time, the - videoAvailableChanged signal can be used to monitor it's status. - - \sa QVideoWidget, QMediaContent -*/ - -/*! - \property QMediaPlayer::seekable - \brief the seek-able status of the current media - - If seeking is supported this property will be true; false otherwise. The - status of this property may change across the life time of the QMediaPlayer - object, use the seekableChanged signal to monitor changes. -*/ - -/*! - \property QMediaPlayer::playbackRate - \brief the playback rate of the current media. - - This value is a multiplier applied to the media's standard play rate. By - default this value is 1.0, indicating that the media is playing at the - standard pace. Values higher than 1.0 will increase the rate of play. - Values less than zero can be set and indicate the media will rewind at the - multiplier of the standard pace. - - Not all playback services support change of the playback rate. It is - framework defined as to the status and quality of audio and video - while fast forwarding or rewinding. -*/ - -/*! - \fn void QMediaPlayer::durationChanged(qint64 duration) - - Signal the duration of the content has changed to \a duration, expressed in milliseconds. -*/ - -/*! - \fn void QMediaPlayer::positionChanged(qint64 position) - - Signal the position of the content has changed to \a position, expressed in - milliseconds. -*/ - -/*! - \fn void QMediaPlayer::volumeChanged(int volume) - - Signal the playback volume has changed to \a volume. -*/ - -/*! - \fn void QMediaPlayer::mutedChanged(bool muted) - - Signal the mute state has changed to \a muted. -*/ - -/*! - \fn void QMediaPlayer::audioAvailableChanged(bool available) - - Signals the availability of audio content has changed to \a available. -*/ - -/*! - \fn void QMediaPlayer::videoAvailableChanged(bool videoAvailable) - - Signal the availability of visual content has changed to \a videoAvailable. -*/ - -/*! - \fn void QMediaPlayer::bufferStatusChanged(int percentFilled) - - Signal the amount of the local buffer filled as a percentage by \a percentFilled. -*/ - -/*! - \enum QMediaPlayer::Flag - - \value LowLatency - The player is expected to be used with simple audio formats, - but playback should start without significant delay. - Such playback service can be used for beeps, ringtones, etc. - - \value StreamPlayback - The player is expected to play QIODevice based streams. - If passed to QMediaPlayer constructor, the service supporting - streams playback will be choosen. -*/ - -QT_END_NAMESPACE - -QT_END_HEADER - -#include "moc_qmediaplayer.cpp" diff --git a/src/multimedia/mediaservices/playback/qmediaplayer.h b/src/multimedia/mediaservices/playback/qmediaplayer.h deleted file mode 100644 index d75c58a..0000000 --- a/src/multimedia/mediaservices/playback/qmediaplayer.h +++ /dev/null @@ -1,203 +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 QtMediaServices module 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 QMEDIAPLAYER_H -#define QMEDIAPLAYER_H - -#include <QtMediaServices/qmediaserviceprovider.h> -#include <QtMediaServices/qmediaobject.h> -#include <QtMediaServices/qmediacontent.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylist; - -class QMediaPlayerPrivate; -class Q_MEDIASERVICES_EXPORT QMediaPlayer : public QMediaObject -{ - Q_OBJECT - Q_PROPERTY(QMediaContent media READ media WRITE setMedia NOTIFY mediaChanged) - Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged) - Q_PROPERTY(qint64 position READ position WRITE setPosition NOTIFY positionChanged) - Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged) - Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - Q_PROPERTY(int bufferStatus READ bufferStatus NOTIFY bufferStatusChanged) - Q_PROPERTY(bool audioAvailable READ isAudioAvailable NOTIFY audioAvailableChanged) - Q_PROPERTY(bool videoAvailable READ isVideoAvailable NOTIFY videoAvailableChanged) - Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged) - Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged) - Q_PROPERTY(State state READ state NOTIFY stateChanged) - Q_PROPERTY(MediaStatus mediaStatus READ mediaStatus NOTIFY mediaStatusChanged) - Q_PROPERTY(QString error READ errorString) - Q_ENUMS(State) - Q_ENUMS(MediaStatus) - -public: - enum State - { - StoppedState, - PlayingState, - PausedState - }; - - enum MediaStatus - { - UnknownMediaStatus, - NoMedia, - LoadingMedia, - LoadedMedia, - StalledMedia, - BufferingMedia, - BufferedMedia, - EndOfMedia, - InvalidMedia - }; - - enum Flag - { - LowLatency = 0x01, - StreamPlayback = 0x02 - }; - Q_DECLARE_FLAGS(Flags, Flag) - - enum Error - { - NoError, - ResourceError, - FormatError, - NetworkError, - AccessDeniedError, - ServiceMissingError - }; - - QMediaPlayer(QObject *parent = 0, Flags flags = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider()); - ~QMediaPlayer(); - - static QtMediaServices::SupportEstimate hasSupport(const QString &mimeType, - const QStringList& codecs = QStringList(), - Flags flags = 0); - static QStringList supportedMimeTypes(Flags flags = 0); - - QMediaContent media() const; - const QIODevice *mediaStream() const; - - State state() const; - MediaStatus mediaStatus() const; - - qint64 duration() const; - qint64 position() const; - - int volume() const; - bool isMuted() const; - bool isAudioAvailable() const; - bool isVideoAvailable() const; - - int bufferStatus() const; - - bool isSeekable() const; - qreal playbackRate() const; - - Error error() const; - QString errorString() const; - -public Q_SLOTS: - void play(); - void pause(); - void stop(); - - void setPosition(qint64 position); - void setVolume(int volume); - void setMuted(bool muted); - - void setPlaybackRate(qreal rate); - - void setMedia(const QMediaContent &media, QIODevice *stream = 0); - -Q_SIGNALS: - void mediaChanged(const QMediaContent &media); - - void stateChanged(QMediaPlayer::State newState); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - - void durationChanged(qint64 duration); - void positionChanged(qint64 position); - - void volumeChanged(int volume); - void mutedChanged(bool muted); - void audioAvailableChanged(bool audioAvailable); - void videoAvailableChanged(bool videoAvailable); - - void bufferStatusChanged(int percentFilled); - - void seekableChanged(bool seekable); - void playbackRateChanged(qreal rate); - - void error(QMediaPlayer::Error error); - -public: - virtual void bind(QObject*); - virtual void unbind(QObject*); - -private: - Q_DISABLE_COPY(QMediaPlayer) - Q_DECLARE_PRIVATE(QMediaPlayer) - Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QMediaPlayer::State)) - Q_PRIVATE_SLOT(d_func(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus)) - Q_PRIVATE_SLOT(d_func(), void _q_error(int, const QString &)) - Q_PRIVATE_SLOT(d_func(), void _q_updateMedia(const QMediaContent&)) - Q_PRIVATE_SLOT(d_func(), void _q_playlistDestroyed()) -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaPlayer::State) -Q_DECLARE_METATYPE(QMediaPlayer::MediaStatus) -Q_DECLARE_METATYPE(QMediaPlayer::Error) - -QT_END_HEADER - -#endif // QMEDIAPLAYER_H diff --git a/src/multimedia/mediaservices/playback/qmediaplayercontrol.cpp b/src/multimedia/mediaservices/playback/qmediaplayercontrol.cpp deleted file mode 100644 index ca58ce4..0000000 --- a/src/multimedia/mediaservices/playback/qmediaplayercontrol.cpp +++ /dev/null @@ -1,378 +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 QtMediaServices module 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 <QtMediaServices/qmediaplayercontrol.h> -#include <QtMediaServices/private/qmediacontrol_p.h> -#include <QtMediaServices/qmediaplayer.h> - - -QT_BEGIN_NAMESPACE - - -/*! - \class QMediaPlayerControl - \ingroup multimedia-serv - \since 4.7 - \preliminary - \brief The QMediaPlayerControl class provides access to the media playing - functionality of a QMediaService. - - If a QMediaService can play media is will implement QMediaPlayerControl. - This control provides a means to set the \l {setMedia()}{media} to play, - \l {play()}{start}, \l {pause()} {pause} and \l {stop()}{stop} playback, - \l {setPosition()}{seek}, and control the \l {setVolume()}{volume}. - It also provides feedback on the \l {duration()}{duration} of the media, - the current \l {position()}{position}, and \l {bufferStatus()}{buffering} - progress. - - The functionality provided by this control is exposed to application - code through the QMediaPlayer class. - - The interface name of QMediaPlayerControl is \c com.nokia.Qt.QMediaPlayerControl/1.0 as - defined in QMediaPlayerControl_iid. - - \sa QMediaService::control(), QMediaPlayer -*/ - -/*! - \macro QMediaPlayerControl_iid - - \c com.nokia.Qt.QMediaPlayerControl/1.0 - - Defines the interface name of the QMediaPlayerControl class. - - \relates QMediaPlayerControl -*/ - -/*! - Destroys a media player control. -*/ -QMediaPlayerControl::~QMediaPlayerControl() -{ -} - -/*! - Constructs a new media player control with the given \a parent. -*/ -QMediaPlayerControl::QMediaPlayerControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - \fn QMediaPlayerControl::state() const - - Returns the state of a player control. -*/ - -/*! - \fn QMediaPlayerControl::stateChanged(QMediaPlayer::State state) - - Signals that the \a state of a player control has changed. - - \sa state() -*/ - -/*! - \fn QMediaPlayerControl::mediaStatus() const - - Returns the status of the current media. -*/ - -/*! - \fn QMediaPlayerControl::mediaStatusChanged(QMediaPlayer::MediaStatus status) - - Signals that the \a status of the current media has changed. - - \sa mediaStatus() -*/ - - -/*! - \fn QMediaPlayerControl::duration() const - - Returns the duration of the current media in milliseconds. -*/ - -/*! - \fn QMediaPlayerControl::durationChanged(qint64 duration) - - Signals that the \a duration of the current media has changed. - - \sa duration() -*/ - -/*! - \fn QMediaPlayerControl::position() const - - Returns the current playback position in milliseconds. -*/ - -/*! - \fn QMediaPlayerControl::setPosition(qint64 position) - - Sets the playback \a position of the current media. This will initiate a seek and it may take - some time for playback to reach the position set. -*/ - -/*! - \fn QMediaPlayerControl::positionChanged(qint64 position) - - Signals the playback \a position has changed. - - This is only emitted in when there has been a discontinous change in the playback postion, such - as a seek or the position being reset. - - \sa position() -*/ - -/*! - \fn QMediaPlayerControl::volume() const - - Returns the audio volume of a player control. -*/ - -/*! - \fn QMediaPlayerControl::setVolume(int volume) - - Sets the audio \a volume of a player control. -*/ - -/*! - \fn QMediaPlayerControl::volumeChanged(int volume) - - Signals the audio \a volume of a player control has changed. - - \sa volume() -*/ - -/*! - \fn QMediaPlayerControl::isMuted() const - - Returns the mute state of a player control. -*/ - -/*! - \fn QMediaPlayerControl::setMuted(bool mute) - - Sets the \a mute state of a player control. -*/ - -/*! - \fn QMediaPlayerControl::mutedChanged(bool mute) - - Signals a change in the \a mute status of a player control. - - \sa isMuted() -*/ - -/*! - \fn QMediaPlayerControl::bufferStatus() const - - Returns the buffering progress of the current media. Progress is measured in the percentage - of the buffer filled. -*/ - -/*! - \fn QMediaPlayerControl::bufferStatusChanged(int progress) - - Signals that buffering \a progress has changed. - - \sa bufferStatus() -*/ - -/*! - \fn QMediaPlayerControl::isAudioAvailable() const - - Identifies if there is audio output available for the current media. - - Returns true if audio output is available and false otherwise. -*/ - -/*! - \fn QMediaPlayerControl::audioAvailableChanged(bool audio) - - Signals that there has been a change in the availability of \a audio output. - - \sa isAudioAvailable() -*/ - -/*! - \fn QMediaPlayerControl::isVideoAvailable() const - - Identifies if there is video output available for the current media. - - Returns true if video output is available and false otherwise. -*/ - -/*! - \fn QMediaPlayerControl::videoAvailableChanged(bool video) - - Signals that there has been a change in the availability of \a video output. - - \sa isVideoAvailable() -*/ - -/*! - \fn QMediaPlayerControl::isSeekable() const - - Identifies if the current media is seekable. - - Returns true if it possible to seek within the current media, and false otherwise. -*/ - -/*! - \fn QMediaPlayerControl::seekableChanged(bool seekable) - - Signals that the \a seekable state of a player control has changed. - - \sa isSeekable() -*/ - -/*! - \fn QMediaPlayerControl::availablePlaybackRanges() const - - Returns a range of times in milliseconds that can be played back. - - Usually for local files this is a continuous interval equal to [0..duration()] - or an empty time range if seeking is not supported, but for network sources - it refers to the buffered parts of the media. -*/ - -/*! - \fn QMediaPlayerControl::availablePlaybackRangesChanged(const QMediaTimeRange &ranges) - - Signals that the available media playback \a ranges have changed. - - \sa QMediaPlayerControl::availablePlaybackRanges() -*/ - -/*! - \fn qreal QMediaPlayerControl::playbackRate() const - - Returns the rate of playback. -*/ - -/*! - \fn QMediaPlayerControl::setPlaybackRate(qreal rate) - - Sets the \a rate of playback. -*/ - -/*! - \fn QMediaPlayerControl::media() const - - Returns the current media source. -*/ - -/*! - \fn QMediaPlayerControl::mediaStream() const - - Returns the current media stream. This is only a valid if a stream was passed to setMedia(). - - \sa setMedia() -*/ - -/*! - \fn QMediaPlayerControl::setMedia(const QMediaContent &media, QIODevice *stream) - - Sets the current \a media source. If a \a stream is supplied; data will be read from that - instead of attempting to resolve the media source. The media source may still be used to - supply media information such as mime type. - - Setting the media to a null QMediaContent will cause the control to discard all - information relating to the current media source and to cease all I/O operations related - to that media. -*/ - -/*! - \fn QMediaPlayerControl::mediaChanged(const QMediaContent& content) - - Signals that the current media \a content has changed. -*/ - -/*! - \fn QMediaPlayerControl::play() - - Starts playback of the current media. - - If successful the player control will immediately enter the \l {QMediaPlayer::PlayingState} - {playing} state. - - \sa state() -*/ - -/*! - \fn QMediaPlayerControl::pause() - - Pauses playback of the current media. - - If sucessful the player control will immediately enter the \l {QMediaPlayer::PausedState} - {paused} state. - - \sa state(), play(), stop() -*/ - -/*! - \fn QMediaPlayerControl::stop() - - Stops playback of the current media. - - If succesful the player control will immediately enter the \l {QMediaPlayer::StoppedState} - {stopped} state. -*/ - -/*! - \fn QMediaPlayerControl::error(int error, const QString &errorString) - - Signals that an \a error has occurred. The \a errorString provides a more detailed explanation. -*/ - -/*! - \fn QMediaPlayerControl::playbackRateChanged(qreal rate) - - Signal emitted when playback rate changes to \a rate. -*/ - -QT_END_NAMESPACE - -#include "moc_qmediaplayercontrol.cpp" - diff --git a/src/multimedia/mediaservices/playback/qmediaplayercontrol.h b/src/multimedia/mediaservices/playback/qmediaplayercontrol.h deleted file mode 100644 index 7a3c24e..0000000 --- a/src/multimedia/mediaservices/playback/qmediaplayercontrol.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 QtMediaServices module 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 QMEDIAPLAYERCONTROL_H -#define QMEDIAPLAYERCONTROL_H - -#include <QtCore/qpair.h> - -#include <QtMediaServices/qmediacontrol.h> -#include <QtMediaServices/qmediaplayer.h> -#include <QtMediaServices/qmediatimerange.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylist; - -class Q_MEDIASERVICES_EXPORT QMediaPlayerControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QMediaPlayerControl(); - - virtual QMediaPlayer::State state() const = 0; - - virtual QMediaPlayer::MediaStatus mediaStatus() const = 0; - - virtual qint64 duration() const = 0; - - virtual qint64 position() const = 0; - virtual void setPosition(qint64 position) = 0; - - virtual int volume() const = 0; - virtual void setVolume(int volume) = 0; - - virtual bool isMuted() const = 0; - virtual void setMuted(bool muted) = 0; - - virtual int bufferStatus() const = 0; - - virtual bool isAudioAvailable() const = 0; - virtual bool isVideoAvailable() const = 0; - - virtual bool isSeekable() const = 0; - - virtual QMediaTimeRange availablePlaybackRanges() const = 0; - - virtual qreal playbackRate() const = 0; - virtual void setPlaybackRate(qreal rate) = 0; - - virtual QMediaContent media() const = 0; - virtual const QIODevice *mediaStream() const = 0; - virtual void setMedia(const QMediaContent &media, QIODevice *stream) = 0; - - virtual void play() = 0; - virtual void pause() = 0; - virtual void stop() = 0; - -Q_SIGNALS: - void mediaChanged(const QMediaContent& content); - void durationChanged(qint64 duration); - void positionChanged(qint64 position); - void stateChanged(QMediaPlayer::State newState); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void audioAvailableChanged(bool audioAvailable); - void videoAvailableChanged(bool videoAvailable); - void bufferStatusChanged(int percentFilled); - void seekableChanged(bool); - void availablePlaybackRangesChanged(const QMediaTimeRange&); - void playbackRateChanged(qreal rate); - void error(int error, const QString &errorString); - -protected: - QMediaPlayerControl(QObject* parent = 0); -}; - -#define QMediaPlayerControl_iid "com.nokia.Qt.QMediaPlayerControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMediaPlayerControl, QMediaPlayerControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMEDIAPLAYERCONTROL_H - diff --git a/src/multimedia/multimedia.pro b/src/multimedia/multimedia.pro index 8cdcb38..93da612 100644 --- a/src/multimedia/multimedia.pro +++ b/src/multimedia/multimedia.pro @@ -1,8 +1,19 @@ -TEMPLATE = subdirs +TARGET = QtMultimedia +QPRO_PWD = $$PWD +QT = core gui -contains(QT_CONFIG, multimedia) { - SUBDIRS += multimedia +DEFINES += QT_BUILD_MULTIMEDIA_LIB QT_NO_USING_NAMESPACE - contains(QT_CONFIG, mediaservices):SUBDIRS += mediaservices -} +unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui + +include(../qbase.pri) +include(audio/audio.pri) +include(video/video.pri) + +symbian: { + TARGET.UID3 = 0x2001E627 + contains(CONFIG, def_files) { + DEF_FILE=../../s60installs + } +} diff --git a/src/multimedia/multimedia/multimedia.pro b/src/multimedia/multimedia/multimedia.pro deleted file mode 100644 index ee700b6..0000000 --- a/src/multimedia/multimedia/multimedia.pro +++ /dev/null @@ -1,19 +0,0 @@ -TARGET = QtMultimedia -QPRO_PWD = $$PWD -QT = core gui - -DEFINES += QT_BUILD_MULTIMEDIA_LIB QT_NO_USING_NAMESPACE - -unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui - -include(../../qbase.pri) - -include(audio/audio.pri) -include(video/video.pri) - -symbian: { - TARGET.UID3 = 0x2001E627 - contains(CONFIG, def_files) { - DEF_FILE=../../s60installs - } -} diff --git a/src/multimedia/multimedia/video/qabstractvideobuffer.cpp b/src/multimedia/video/qabstractvideobuffer.cpp index e9d30d0..e9d30d0 100644 --- a/src/multimedia/multimedia/video/qabstractvideobuffer.cpp +++ b/src/multimedia/video/qabstractvideobuffer.cpp diff --git a/src/multimedia/multimedia/video/qabstractvideobuffer.h b/src/multimedia/video/qabstractvideobuffer.h index a8389db..a8389db 100644 --- a/src/multimedia/multimedia/video/qabstractvideobuffer.h +++ b/src/multimedia/video/qabstractvideobuffer.h diff --git a/src/multimedia/multimedia/video/qabstractvideobuffer_p.h b/src/multimedia/video/qabstractvideobuffer_p.h index c72f303..c72f303 100644 --- a/src/multimedia/multimedia/video/qabstractvideobuffer_p.h +++ b/src/multimedia/video/qabstractvideobuffer_p.h diff --git a/src/multimedia/multimedia/video/qabstractvideosurface.cpp b/src/multimedia/video/qabstractvideosurface.cpp index 3dabb6b..3dabb6b 100644 --- a/src/multimedia/multimedia/video/qabstractvideosurface.cpp +++ b/src/multimedia/video/qabstractvideosurface.cpp diff --git a/src/multimedia/multimedia/video/qabstractvideosurface.h b/src/multimedia/video/qabstractvideosurface.h index f2cae17..f2cae17 100644 --- a/src/multimedia/multimedia/video/qabstractvideosurface.h +++ b/src/multimedia/video/qabstractvideosurface.h diff --git a/src/multimedia/multimedia/video/qabstractvideosurface_p.h b/src/multimedia/video/qabstractvideosurface_p.h index 42df112..42df112 100644 --- a/src/multimedia/multimedia/video/qabstractvideosurface_p.h +++ b/src/multimedia/video/qabstractvideosurface_p.h diff --git a/src/multimedia/multimedia/video/qimagevideobuffer.cpp b/src/multimedia/video/qimagevideobuffer.cpp index e3e1585..e3e1585 100644 --- a/src/multimedia/multimedia/video/qimagevideobuffer.cpp +++ b/src/multimedia/video/qimagevideobuffer.cpp diff --git a/src/multimedia/multimedia/video/qimagevideobuffer_p.h b/src/multimedia/video/qimagevideobuffer_p.h index 82075d7..82075d7 100644 --- a/src/multimedia/multimedia/video/qimagevideobuffer_p.h +++ b/src/multimedia/video/qimagevideobuffer_p.h diff --git a/src/multimedia/multimedia/video/qmemoryvideobuffer.cpp b/src/multimedia/video/qmemoryvideobuffer.cpp index 2e892b7..2e892b7 100644 --- a/src/multimedia/multimedia/video/qmemoryvideobuffer.cpp +++ b/src/multimedia/video/qmemoryvideobuffer.cpp diff --git a/src/multimedia/multimedia/video/qmemoryvideobuffer_p.h b/src/multimedia/video/qmemoryvideobuffer_p.h index c66cf93..c66cf93 100644 --- a/src/multimedia/multimedia/video/qmemoryvideobuffer_p.h +++ b/src/multimedia/video/qmemoryvideobuffer_p.h diff --git a/src/multimedia/multimedia/video/qvideoframe.cpp b/src/multimedia/video/qvideoframe.cpp index 2d66d9e..2d66d9e 100644 --- a/src/multimedia/multimedia/video/qvideoframe.cpp +++ b/src/multimedia/video/qvideoframe.cpp diff --git a/src/multimedia/multimedia/video/qvideoframe.h b/src/multimedia/video/qvideoframe.h index 668a738..668a738 100644 --- a/src/multimedia/multimedia/video/qvideoframe.h +++ b/src/multimedia/video/qvideoframe.h diff --git a/src/multimedia/multimedia/video/qvideosurfaceformat.cpp b/src/multimedia/video/qvideosurfaceformat.cpp index 1fc13a6..1fc13a6 100644 --- a/src/multimedia/multimedia/video/qvideosurfaceformat.cpp +++ b/src/multimedia/video/qvideosurfaceformat.cpp diff --git a/src/multimedia/multimedia/video/qvideosurfaceformat.h b/src/multimedia/video/qvideosurfaceformat.h index 9c73f5f..9c73f5f 100644 --- a/src/multimedia/multimedia/video/qvideosurfaceformat.h +++ b/src/multimedia/video/qvideosurfaceformat.h diff --git a/src/multimedia/multimedia/video/video.pri b/src/multimedia/video/video.pri index 0547a4c..0547a4c 100644 --- a/src/multimedia/multimedia/video/video.pri +++ b/src/multimedia/video/video.pri diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 31c64f0..1afabec 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -723,6 +723,7 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply) // This function must be called from the event loop. The only // exception is documented in QHttpNetworkConnectionPrivate::queueRequest +// although it is called _q_startNextRequest, it will actually start multiple requests when possible void QHttpNetworkConnectionPrivate::_q_startNextRequest() { //resend the necessary ones. @@ -740,26 +741,23 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest() // dequeue new ones - QAbstractSocket *socket = 0; + // return fast if there is nothing to do + if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty()) + return; + // try to get a free AND connected socket for (int i = 0; i < channelCount; ++i) { - QAbstractSocket *chSocket = channels[i].socket; - // try to get a free AND connected socket if (!channels[i].isSocketBusy() && channels[i].socket->state() == QAbstractSocket::ConnectedState) { - socket = chSocket; - dequeueAndSendRequest(socket); - break; + dequeueAndSendRequest(channels[i].socket); } } - if (!socket) { - for (int i = 0; i < channelCount; ++i) { - QAbstractSocket *chSocket = channels[i].socket; - // try to get a free unconnected socket - if (!channels[i].isSocketBusy()) { - socket = chSocket; - dequeueAndSendRequest(socket); - break; - } + // return fast if there is nothing to do + if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty()) + return; + // try to get a free unconnected socket + for (int i = 0; i < channelCount; ++i) { + if (!channels[i].isSocketBusy()) { + dequeueAndSendRequest(channels[i].socket); } } diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index d24eb1f..d3576dd 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -294,7 +294,8 @@ bool QHttpNetworkConnectionChannel::sendRequest() // ensure we try to receive a reply in all cases, even if _q_readyRead_ hat not been called // this is needed if the sends an reply before we have finished sending the request. In that // case receiveReply had been called before but ignored the server reply - QMetaObject::invokeMethod(this, "_q_receiveReply", Qt::QueuedConnection); + if (socket->bytesAvailable()) + QMetaObject::invokeMethod(this, "_q_receiveReply", Qt::QueuedConnection); break; } case QHttpNetworkConnectionChannel::ReadingState: diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index 338236e..108ba8a 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -179,6 +179,9 @@ qint64 QHttpNetworkReply::bytesAvailableNextBlock() const QByteArray QHttpNetworkReply::readAny() { Q_D(QHttpNetworkReply); + if (d->responseData.bufferCount() == 0) + return QByteArray(); + // we'll take the last buffer, so schedule another read from http if (d->downstreamLimited && d->responseData.bufferCount() == 1) d->connection->d_func()->readMoreLater(this); diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp index 2a02c99..60f7dc6 100644 --- a/src/network/access/qnetworkaccessbackend.cpp +++ b/src/network/access/qnetworkaccessbackend.cpp @@ -74,7 +74,7 @@ Q_GLOBAL_STATIC(QNetworkAccessBackendFactoryData, factoryData) QNetworkAccessBackendFactory::QNetworkAccessBackendFactory() { QMutexLocker locker(&factoryData()->mutex); - factoryData()->prepend(this); + factoryData()->append(this); } QNetworkAccessBackendFactory::~QNetworkAccessBackendFactory() diff --git a/src/network/access/qnetworkaccesshttpbackend_p.h b/src/network/access/qnetworkaccesshttpbackend_p.h index 254907f..c4c88ae 100644 --- a/src/network/access/qnetworkaccesshttpbackend_p.h +++ b/src/network/access/qnetworkaccesshttpbackend_p.h @@ -94,8 +94,6 @@ public: #endif QNetworkCacheMetaData fetchCacheMetaData(const QNetworkCacheMetaData &metaData) const; - qint64 deviceReadData(char *buffer, qint64 maxlen); - // we return true since HTTP needs to send PUT/POST data again after having authenticated bool needsResetableUploadData() { return true; } diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 28a6c84..8ae1305 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -44,14 +44,10 @@ #include "QtCore/qscopedpointer.h" #include <qabstracteventdispatcher.h> -#include <private/qunicodetables_p.h> #include <qcoreapplication.h> #include <qmetaobject.h> -#include <qregexp.h> -#include <private/qnativesocketengine_p.h> #include <qstringlist.h> #include <qthread.h> -#include <qtimer.h> #include <qurl.h> #ifdef Q_OS_UNIX diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp index a186e78..90751f4 100644 --- a/src/network/kernel/qhostinfo_unix.cpp +++ b/src/network/kernel/qhostinfo_unix.cpp @@ -44,6 +44,7 @@ #include "qplatformdefs.h" #include "qhostinfo_p.h" +#include "private/qnativesocketengine_p.h" #include "qiodevice.h" #include <qbytearray.h> #include <qlibrary.h> diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp index 4264f60..b30204b 100644 --- a/src/network/kernel/qhostinfo_win.cpp +++ b/src/network/kernel/qhostinfo_win.cpp @@ -50,7 +50,6 @@ #include "private/qnativesocketengine_p.h" #include <ws2tcpip.h> #include <qlibrary.h> -#include <qtimer.h> #include <qmutex.h> #include <qurl.h> #include <private/qmutexpool_p.h> diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index ac25597..40b3641 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -266,10 +266,12 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS do { QByteArray source; - source.append(qShaderSnippets[prog.mainFragShader]); - source.append(qShaderSnippets[prog.srcPixelFragShader]); + // Insert the custom stage before the srcPixel shader to work around an ATI driver bug + // where you cannot forward declare a function that takes a sampler as argument. if (prog.srcPixelFragShader == CustomImageSrcFragmentShader) source.append(prog.customStageSource); + source.append(qShaderSnippets[prog.mainFragShader]); + source.append(qShaderSnippets[prog.srcPixelFragShader]); if (prog.compositionFragShader) source.append(qShaderSnippets[prog.compositionFragShader]); if (prog.maskFragShader) @@ -777,8 +779,8 @@ bool QGLEngineShaderManager::useCorrectShaderProg() // doesn't use are disabled) QGLContextPrivate* ctx_d = ctx->d_func(); ctx_d->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true); - ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, currentShaderProg->useTextureCoords); - ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, currentShaderProg->useOpacityAttribute); + ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, currentShaderProg && currentShaderProg->useTextureCoords); + ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, currentShaderProg && currentShaderProg->useOpacityAttribute); shaderProgNeedsChanging = false; return true; diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index 8dba951..a7ece0f 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -351,7 +351,6 @@ static const char* const qglslImageSrcFragmentShader = "\n\ static const char* const qglslCustomSrcFragmentShader = "\n\ varying highp vec2 textureCoords; \n\ uniform lowp sampler2D imageTexture; \n\ - lowp vec4 customShader(lowp sampler2D texture, highp vec2 coords); \n\ lowp vec4 srcPixel() \n\ { \n\ return customShader(imageTexture, textureCoords); \n\ diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index d5a11d9..bfa5ef1 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -591,10 +591,11 @@ bool QGLPixmapDropShadowFilter::processGL(QPainter *painter, const QPointF &pos, qt_blurImage(image, r * qreal(0.5), false, 1); - GLuint texture = generateBlurTexture(image.size(), GL_ALPHA); - - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image.width(), image.height(), GL_ALPHA, - GL_UNSIGNED_BYTE, image.bits()); + GLuint texture; + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, image.width(), image.height(), + 0, GL_ALPHA, GL_UNSIGNED_BYTE, image.bits()); info = new QGLBlurTextureInfo(image, texture, r); } diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 08a50cb..28d37bc 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -1451,6 +1451,11 @@ bool QOpenGLPaintEngine::end() d->device->endPaint(); qt_mask_texture_cache()->maintainCache(); +#if defined(Q_WS_X11) + // clear out the references we hold for textures bound with the + // texture_from_pixmap extension + ctx->d_func()->boundPixmaps.clear(); +#endif return true; } diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index f602c73..76a605a 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -119,6 +119,35 @@ private: class QVGPaintEnginePrivate : public QPaintEngineExPrivate { public: + // Extra blending modes from VG_KHR_advanced_blending extension. + // Use the QT_VG prefix to avoid conflicts with any definitions + // that may come in via <VG/vgext.h>. + enum AdvancedBlending { + QT_VG_BLEND_OVERLAY_KHR = 0x2010, + QT_VG_BLEND_HARDLIGHT_KHR = 0x2011, + QT_VG_BLEND_SOFTLIGHT_SVG_KHR = 0x2012, + QT_VG_BLEND_SOFTLIGHT_KHR = 0x2013, + QT_VG_BLEND_COLORDODGE_KHR = 0x2014, + QT_VG_BLEND_COLORBURN_KHR = 0x2015, + QT_VG_BLEND_DIFFERENCE_KHR = 0x2016, + QT_VG_BLEND_SUBTRACT_KHR = 0x2017, + QT_VG_BLEND_INVERT_KHR = 0x2018, + QT_VG_BLEND_EXCLUSION_KHR = 0x2019, + QT_VG_BLEND_LINEARDODGE_KHR = 0x201a, + QT_VG_BLEND_LINEARBURN_KHR = 0x201b, + QT_VG_BLEND_VIVIDLIGHT_KHR = 0x201c, + QT_VG_BLEND_LINEARLIGHT_KHR = 0x201d, + QT_VG_BLEND_PINLIGHT_KHR = 0x201e, + QT_VG_BLEND_HARDMIX_KHR = 0x201f, + QT_VG_BLEND_CLEAR_KHR = 0x2020, + QT_VG_BLEND_DST_KHR = 0x2021, + QT_VG_BLEND_SRC_OUT_KHR = 0x2022, + QT_VG_BLEND_DST_OUT_KHR = 0x2023, + QT_VG_BLEND_SRC_ATOP_KHR = 0x2024, + QT_VG_BLEND_DST_ATOP_KHR = 0x2025, + QT_VG_BLEND_XOR_KHR = 0x2026 + }; + QVGPaintEnginePrivate(); ~QVGPaintEnginePrivate(); @@ -216,6 +245,8 @@ public: QVGFontEngineCleaner *fontEngineCleaner; #endif + bool hasAdvancedBlending; + QScopedPointer<QPixmapFilter> convolutionFilter; QScopedPointer<QPixmapFilter> colorizeFilter; QScopedPointer<QPixmapFilter> dropShadowFilter; @@ -369,6 +400,8 @@ void QVGPaintEnginePrivate::init() fontEngineCleaner = 0; #endif + hasAdvancedBlending = false; + clearModes(); } @@ -445,6 +478,10 @@ void QVGPaintEnginePrivate::initObjects() VG_PATH_CAPABILITY_ALL); vgAppendPathData(linePath, 2, segments, coords); #endif + + const char *extensions = reinterpret_cast<const char *>(vgGetString(VG_EXTENSIONS)); + if (extensions) + hasAdvancedBlending = strstr(extensions, "VG_KHR_advanced_blending") != 0; } void QVGPaintEnginePrivate::destroy() @@ -2288,7 +2325,7 @@ void QVGPaintEngine::compositionModeChanged() Q_D(QVGPaintEngine); d->dirty |= QPaintEngine::DirtyCompositionMode; - VGBlendMode vgMode = VG_BLEND_SRC_OVER; + VGint vgMode = VG_BLEND_SRC_OVER; switch (state()->composition_mode) { case QPainter::CompositionMode_SourceOver: @@ -2322,11 +2359,53 @@ void QVGPaintEngine::compositionModeChanged() vgMode = VG_BLEND_LIGHTEN; break; default: - qWarning() << "QVGPaintEngine::compositionModeChanged unsupported mode" << state()->composition_mode; - break; // Fall back to VG_BLEND_SRC_OVER. + if (d->hasAdvancedBlending) { + switch (state()->composition_mode) { + case QPainter::CompositionMode_Overlay: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_OVERLAY_KHR; + break; + case QPainter::CompositionMode_ColorDodge: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_COLORDODGE_KHR; + break; + case QPainter::CompositionMode_ColorBurn: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_COLORBURN_KHR; + break; + case QPainter::CompositionMode_HardLight: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_HARDLIGHT_KHR; + break; + case QPainter::CompositionMode_SoftLight: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SOFTLIGHT_KHR; + break; + case QPainter::CompositionMode_Difference: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DIFFERENCE_KHR; + break; + case QPainter::CompositionMode_Exclusion: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_EXCLUSION_KHR; + break; + case QPainter::CompositionMode_SourceOut: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SRC_OUT_KHR; + break; + case QPainter::CompositionMode_DestinationOut: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DST_OUT_KHR; + break; + case QPainter::CompositionMode_SourceAtop: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SRC_ATOP_KHR; + break; + case QPainter::CompositionMode_DestinationAtop: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DST_ATOP_KHR; + break; + case QPainter::CompositionMode_Xor: + vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_XOR_KHR; + break; + default: break; // Fall back to VG_BLEND_SRC_OVER. + } + } + if (vgMode == VG_BLEND_SRC_OVER) + qWarning() << "QVGPaintEngine::compositionModeChanged unsupported mode" << state()->composition_mode; + break; } - d->setBlendMode(vgMode); + d->setBlendMode(VGBlendMode(vgMode)); } void QVGPaintEngine::renderHintsChanged() diff --git a/src/plugins/mediaservices/directshow/directshow.pro b/src/plugins/mediaservices/directshow/directshow.pro deleted file mode 100644 index 065e391..0000000 --- a/src/plugins/mediaservices/directshow/directshow.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qdsengine -include(../../qpluginbase.pri) - -QT += multimedia mediaservices - -HEADERS += dsserviceplugin.h -SOURCES += dsserviceplugin.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/directshow/dsserviceplugin.cpp b/src/plugins/mediaservices/directshow/dsserviceplugin.cpp deleted file mode 100644 index c482fd5..0000000 --- a/src/plugins/mediaservices/directshow/dsserviceplugin.cpp +++ /dev/null @@ -1,188 +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 <QtCore/QFile> - -#include "dsserviceplugin.h" - -#ifdef QMEDIA_DIRECTSHOW_CAMERA -#include "dscameraservice.h" -#endif - -#ifdef QMEDIA_DIRECTSHOW_PLAYER -#include "directshowplayerservice.h" -#endif - -#include <qmediaserviceprovider.h> - - -#ifdef QMEDIA_DIRECTSHOW_CAMERA -#ifndef _STRSAFE_H_INCLUDED_ -#include <tchar.h> -#endif -#include <dshow.h> -#include <objbase.h> -#include <initguid.h> -#pragma comment(lib, "strmiids.lib") -#pragma comment(lib, "ole32.lib") -#include <windows.h> -#endif - - -QT_BEGIN_NAMESPACE - -QStringList DSServicePlugin::keys() const -{ - return QStringList() -#ifdef QMEDIA_DIRECTSHOW_CAMERA - << QLatin1String(Q_MEDIASERVICE_CAMERA) -#endif -#ifdef QMEDIA_DIRECTSHOW_PLAYER - << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER) -#endif - ; -} - -QMediaService* DSServicePlugin::create(QString const& key) -{ -#ifdef QMEDIA_DIRECTSHOW_CAMERA - if (key == QLatin1String(Q_MEDIASERVICE_CAMERA)) - return new DSCameraService; -#endif -#ifdef QMEDIA_DIRECTSHOW_PLAYER - if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)) - return new DirectShowPlayerService; -#endif - - qWarning() << "DirectShow service plugin: unsupported service -" << key; - return 0; -} - -void DSServicePlugin::release(QMediaService *service) -{ - delete service; -} - -QList<QByteArray> DSServicePlugin::devices(const QByteArray &service) const -{ -#ifdef QMEDIA_DIRECTSHOW_CAMERA - if (service == Q_MEDIASERVICE_CAMERA) { - if (m_cameraDevices.isEmpty()) - updateDevices(); - - return m_cameraDevices; - } -#endif - - return QList<QByteArray>(); -} - -QString DSServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device) -{ -#ifdef QMEDIA_DIRECTSHOW_CAMERA - 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(); -} - -#ifdef QMEDIA_DIRECTSHOW_CAMERA -void DSServicePlugin::updateDevices() const -{ - m_cameraDevices.clear(); - m_cameraDescriptions.clear(); - - CoInitialize(NULL); - ICreateDevEnum* pDevEnum = NULL; - IEnumMoniker* pEnum = NULL; - // Create the System device enumerator - HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, - CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, - reinterpret_cast<void**>(&pDevEnum)); - if(SUCCEEDED(hr)) { - // Create the enumerator for the video capture category - hr = pDevEnum->CreateClassEnumerator( - CLSID_VideoInputDeviceCategory, &pEnum, 0); - pEnum->Reset(); - // go through and find all video capture devices - IMoniker* pMoniker = NULL; - while(pEnum->Next(1, &pMoniker, NULL) == S_OK) { - IPropertyBag *pPropBag; - hr = pMoniker->BindToStorage(0,0,IID_IPropertyBag, - (void**)(&pPropBag)); - if(FAILED(hr)) { - pMoniker->Release(); - continue; // skip this one - } - // Find the description - WCHAR str[120]; - VARIANT varName; - varName.vt = VT_BSTR; - hr = pPropBag->Read(L"FriendlyName", &varName, 0); - if(SUCCEEDED(hr)) { - StringCchCopyW(str,sizeof(str)/sizeof(str[0]),varName.bstrVal); - QString temp(QString::fromUtf16((unsigned short*)str)); - m_cameraDevices.append(QString("ds:%1").arg(temp).toLocal8Bit().constData()); - hr = pPropBag->Read(L"Description", &varName, 0); - StringCchCopyW(str,sizeof(str)/sizeof(str[0]),varName.bstrVal); - QString temp2(QString::fromUtf16((unsigned short*)str)); - m_cameraDescriptions.append(temp2); - } - pPropBag->Release(); - pMoniker->Release(); - } - } - CoUninitialize(); -} -#endif - -QT_END_NAMESPACE - -Q_EXPORT_PLUGIN2(dsengine, DSServicePlugin); - diff --git a/src/plugins/mediaservices/directshow/dsserviceplugin.h b/src/plugins/mediaservices/directshow/dsserviceplugin.h deleted file mode 100644 index 3c6f1b8..0000000 --- a/src/plugins/mediaservices/directshow/dsserviceplugin.h +++ /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$ -** -****************************************************************************/ - -#ifndef DSSERVICEPLUGIN_H -#define DSSERVICEPLUGIN_H - -#include <qmediaserviceproviderplugin.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class DSServicePlugin : 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: -#ifdef QMEDIA_DIRECTSHOW_CAMERA - void updateDevices() const; - - mutable QList<QByteArray> m_cameraDevices; - mutable QStringList m_cameraDescriptions; -#endif -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // DSSERVICEPLUGIN_H diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowaudioendpointcontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowaudioendpointcontrol.cpp deleted file mode 100644 index 5f72ca6..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowaudioendpointcontrol.cpp +++ /dev/null @@ -1,166 +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 "directshowaudioendpointcontrol.h" - -#include "directshowglobal.h" -#include "directshowplayerservice.h" - - -QT_BEGIN_NAMESPACE - -DirectShowAudioEndpointControl::DirectShowAudioEndpointControl( - DirectShowPlayerService *service, QObject *parent) - : QMediaControl(parent) - , m_service(service) - , m_bindContext(0) - , m_deviceEnumerator(0) -{ - if (CreateBindCtx(0, &m_bindContext) == S_OK) { - m_deviceEnumerator = com_new<ICreateDevEnum>(CLSID_SystemDeviceEnum, IID_ICreateDevEnum); - - updateEndpoints(); - - setActiveEndpoint(m_defaultEndpoint); - } -} - -DirectShowAudioEndpointControl::~DirectShowAudioEndpointControl() -{ - foreach (IMoniker *moniker, m_devices) - moniker->Release(); - - if (m_bindContext) - m_bindContext->Release(); - - if (m_deviceEnumerator) - m_deviceEnumerator->Release(); -} - -QList<QString> DirectShowAudioEndpointControl::availableEndpoints() const -{ - return m_devices.keys(); -} - -QString DirectShowAudioEndpointControl::endpointDescription(const QString &name) const -{ -#ifdef __IPropertyBag_INTERFACE_DEFINED__ - QString description; - - if (IMoniker *moniker = m_devices.value(name, 0)) { - IPropertyBag *propertyBag = 0; - if (SUCCEEDED(moniker->BindToStorage( - 0, 0, IID_IPropertyBag, reinterpret_cast<void **>(&propertyBag)))) { - VARIANT name; - VariantInit(&name); - if (SUCCEEDED(propertyBag->Read(L"FriendlyName", &name, 0))) - description = QString::fromWCharArray(name.bstrVal); - VariantClear(&name); - propertyBag->Release(); - } - } - - return description; -#else - return name.section(QLatin1Char('\\'), -1); -#endif -} - -QString DirectShowAudioEndpointControl::defaultEndpoint() const -{ - return m_defaultEndpoint; -} - -QString DirectShowAudioEndpointControl::activeEndpoint() const -{ - return m_activeEndpoint; -} - -void DirectShowAudioEndpointControl::setActiveEndpoint(const QString &name) -{ - if (m_activeEndpoint == name) - return; - - if (IMoniker *moniker = m_devices.value(name, 0)) { - IBaseFilter *filter = 0; - - if (moniker->BindToObject( - m_bindContext, - 0, - IID_IBaseFilter, - reinterpret_cast<void **>(&filter)) == S_OK) { - m_service->setAudioOutput(filter); - - filter->Release(); - } - } -} - -void DirectShowAudioEndpointControl::updateEndpoints() -{ - IMalloc *oleMalloc = 0; - if (m_deviceEnumerator && CoGetMalloc(1, &oleMalloc) == S_OK) { - IEnumMoniker *monikers = 0; - - if (m_deviceEnumerator->CreateClassEnumerator( - CLSID_AudioRendererCategory, &monikers, 0) == S_OK) { - for (IMoniker *moniker = 0; monikers->Next(1, &moniker, 0) == S_OK; moniker->Release()) { - OLECHAR *string = 0; - if (moniker->GetDisplayName(m_bindContext, 0, &string) == S_OK) { - QString deviceId = QString::fromWCharArray(string); - oleMalloc->Free(string); - - moniker->AddRef(); - m_devices.insert(deviceId, moniker); - - if (m_defaultEndpoint.isEmpty() - || deviceId.endsWith(QLatin1String("Default DirectSound Device"))) { - m_defaultEndpoint = deviceId; - } - } - } - monikers->Release(); - } - oleMalloc->Release(); - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowaudioendpointcontrol.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowaudioendpointcontrol.h deleted file mode 100644 index 8d23751..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowaudioendpointcontrol.h +++ /dev/null @@ -1,90 +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 DIRECTSHOWAUDIOENDPOINTCONTROL_H -#define DIRECTSHOWAUDIOENDPOINTCONTROL_H - -#include <QtMediaServices/qmediacontrol.h> - -#include <dshow.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowPlayerService; - -class DirectShowAudioEndpointControl : public QMediaControl -{ - Q_OBJECT -public: - DirectShowAudioEndpointControl(DirectShowPlayerService *service, QObject *parent = 0); - ~DirectShowAudioEndpointControl(); - - QList<QString> availableEndpoints() const; - - QString endpointDescription(const QString &name) const; - - QString defaultEndpoint() const; - QString activeEndpoint() const; - - void setActiveEndpoint(const QString& name); - -private: - void updateEndpoints(); - - DirectShowPlayerService *m_service; - IBindCtx *m_bindContext; - ICreateDevEnum *m_deviceEnumerator; - - QMap<QString, IMoniker *> m_devices; - QString m_defaultEndpoint; - QString m_activeEndpoint; -}; - -#define QAudioEndpointSelector_iid "com.nokia.Qt.QAudioEndpointSelector/1.0" - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif - diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshoweventloop.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshoweventloop.cpp deleted file mode 100644 index 07541c2..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshoweventloop.cpp +++ /dev/null @@ -1,161 +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 <directshoweventloop.h> - -#include <QtCore/qcoreapplication.h> -#include <QtCore/qcoreevent.h> - - -QT_BEGIN_NAMESPACE - - -class DirectShowPostedEvent -{ -public: - DirectShowPostedEvent(QObject *receiver, QEvent *event) - : receiver(receiver) - , event(event) - , next(0) - { - } - - ~DirectShowPostedEvent() - { - delete event; - } - - QObject *receiver; - QEvent *event; - DirectShowPostedEvent *next; -}; - -DirectShowEventLoop::DirectShowEventLoop(QObject *parent) - : QWinEventNotifier(parent) - , m_postsHead(0) - , m_postsTail(0) - , m_eventHandle(::CreateEvent(0, 0, 0, 0)) - , m_waitHandle(::CreateEvent(0, 0, 0, 0)) -{ - setHandle(m_eventHandle); - setEnabled(true); -} - -DirectShowEventLoop::~DirectShowEventLoop() -{ - setEnabled(false); - - ::CloseHandle(m_eventHandle); - ::CloseHandle(m_waitHandle); - - for (DirectShowPostedEvent *post = m_postsHead; post; post = m_postsHead) { - m_postsHead = m_postsHead->next; - - delete post; - } -} - -void DirectShowEventLoop::wait(QMutex *mutex) -{ - ::ResetEvent(m_waitHandle); - - mutex->unlock(); - - HANDLE handles[] = { m_eventHandle, m_waitHandle }; - while (::WaitForMultipleObjects(2, handles, false, INFINITE) == WAIT_OBJECT_0) - processEvents(); - - mutex->lock(); -} - -void DirectShowEventLoop::wake() -{ - ::SetEvent(m_waitHandle); -} - -void DirectShowEventLoop::postEvent(QObject *receiver, QEvent *event) -{ - QMutexLocker locker(&m_mutex); - - DirectShowPostedEvent *post = new DirectShowPostedEvent(receiver, event); - - if (m_postsTail) - m_postsTail->next = post; - else - m_postsHead = post; - - m_postsTail = post; - - ::SetEvent(m_eventHandle); -} - -bool DirectShowEventLoop::event(QEvent *event) -{ - if (event->type() == QEvent::WinEventAct) { - processEvents(); - - return true; - } else { - return QWinEventNotifier::event(event); - } -} - -void DirectShowEventLoop::processEvents() -{ - QMutexLocker locker(&m_mutex); - - while(m_postsHead) { - ::ResetEvent(m_eventHandle); - - DirectShowPostedEvent *post = m_postsHead; - m_postsHead = m_postsHead->next; - - if (!m_postsHead) - m_postsTail = 0; - - locker.unlock(); - QCoreApplication::sendEvent(post->receiver, post->event); - delete post; - locker.relock(); - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshoweventloop.h b/src/plugins/mediaservices/directshow/mediaplayer/directshoweventloop.h deleted file mode 100644 index f46e65a..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshoweventloop.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 DIRECTSHOWEVENTLOOP_H -#define DIRECTSHOWEVENTLOOP_H - -#include <QtCore/qmutex.h> -#include <QtCore/private/qwineventnotifier_p.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowPostedEvent; - -class DirectShowEventLoop : public QWinEventNotifier -{ - Q_OBJECT -public: - DirectShowEventLoop(QObject *parent = 0); - ~DirectShowEventLoop(); - - void wait(QMutex *mutex); - void wake(); - - void postEvent(QObject *object, QEvent *event); - - bool event(QEvent *event); - -private: - void processEvents(); - - DirectShowPostedEvent *m_postsHead; - DirectShowPostedEvent *m_postsTail; - HANDLE m_eventHandle; - HANDLE m_waitHandle; - QMutex m_mutex; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowglobal.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowglobal.h deleted file mode 100644 index e43e2a7..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowglobal.h +++ /dev/null @@ -1,147 +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 DIRECTSHOWGLOBAL_H -#define DIRECTSHOWGLOBAL_H - -#include <QtCore/qglobal.h> - -#include <dshow.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -template <typename T> T *com_cast(IUnknown *unknown, const IID &iid) -{ - T *iface = 0; - return unknown && unknown->QueryInterface(iid, reinterpret_cast<void **>(&iface)) == S_OK - ? iface - : 0; -} - -template <typename T> T *com_new(const IID &clsid, const IID &iid) -{ - T *object = 0; - return CoCreateInstance( - clsid, - NULL, - CLSCTX_INPROC_SERVER, - iid, - reinterpret_cast<void **>(&object)) == S_OK - ? object - : 0; -} - -QT_END_NAMESPACE - -QT_END_HEADER - -#ifndef __IFilterGraph2_INTERFACE_DEFINED__ -#define __IFilterGraph2_INTERFACE_DEFINED__ -#define INTERFACE IFilterGraph2 -DECLARE_INTERFACE_(IFilterGraph2 ,IGraphBuilder) -{ - STDMETHOD(AddSourceFilterForMoniker)(THIS_ IMoniker *, IBindCtx *, LPCWSTR,IBaseFilter **) PURE; - STDMETHOD(ReconnectEx)(THIS_ IPin *, const AM_MEDIA_TYPE *) PURE; - STDMETHOD(RenderEx)(IPin *, DWORD, DWORD *) PURE; -}; -#undef INTERFACE -#endif - -#ifndef __IAMFilterMiscFlags_INTERFACE_DEFINED__ -#define __IAMFilterMiscFlags_INTERFACE_DEFINED__ -#define INTERFACE IAMFilterMiscFlags -DECLARE_INTERFACE_(IAMFilterMiscFlags ,IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - STDMETHOD_(ULONG,GetMiscFlags)(THIS) PURE; -}; -#undef INTERFACE -#endif - -#ifndef __IFileSourceFilter_INTERFACE_DEFINED__ -#define __IFileSourceFilter_INTERFACE_DEFINED__ -#define INTERFACE IFileSourceFilter -DECLARE_INTERFACE_(IFileSourceFilter ,IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - STDMETHOD(Load)(THIS_ LPCOLESTR, const AM_MEDIA_TYPE *) PURE; - STDMETHOD(GetCurFile)(THIS_ LPOLESTR *ppszFileName, AM_MEDIA_TYPE *) PURE; -}; -#undef INTERFACE -#endif - -#ifndef __IAMOpenProgress_INTERFACE_DEFINED__ -#define __IAMOpenProgress_INTERFACE_DEFINED__ -#define INTERFACE IAMOpenProgress -DECLARE_INTERFACE_(IAMOpenProgress ,IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - STDMETHOD(QueryProgress)(THIS_ LONGLONG *, LONGLONG *) PURE; - STDMETHOD(AbortOperation)(THIS) PURE; -}; -#undef INTERFACE -#endif - -#ifndef __IFilterChain_INTERFACE_DEFINED__ -#define __IFilterChain_INTERFACE_DEFINED__ -#define INTERFACE IFilterChain -DECLARE_INTERFACE_(IFilterChain ,IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - STDMETHOD(StartChain)(IBaseFilter *, IBaseFilter *) PURE; - STDMETHOD(PauseChain)(IBaseFilter *, IBaseFilter *) PURE; - STDMETHOD(StopChain)(IBaseFilter *, IBaseFilter *) PURE; - STDMETHOD(RemoveChain)(IBaseFilter *, IBaseFilter *) PURE; -}; -#undef INTERFACE -#endif - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowioreader.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowioreader.cpp deleted file mode 100644 index 7369099..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowioreader.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 "directshowioreader.h" - -#include "directshoweventloop.h" -#include "directshowglobal.h" -#include "directshowiosource.h" - -#include <QtCore/qcoreapplication.h> -#include <QtCore/qcoreevent.h> -#include <QtCore/qiodevice.h> -#include <QtCore/qthread.h> - - -QT_BEGIN_NAMESPACE - -class DirectShowSampleRequest -{ -public: - DirectShowSampleRequest( - IMediaSample *sample, DWORD_PTR userData, LONGLONG position, LONG length, BYTE *buffer) - : next(0) - , sample(sample) - , userData(userData) - , position(position) - , length(length) - , buffer(buffer) - , result(S_FALSE) - { - } - - DirectShowSampleRequest *remove() { DirectShowSampleRequest *n = next; delete this; return n; } - - DirectShowSampleRequest *next; - IMediaSample *sample; - DWORD_PTR userData; - LONGLONG position; - LONG length; - BYTE *buffer; - HRESULT result; -}; - -DirectShowIOReader::DirectShowIOReader( - QIODevice *device, DirectShowIOSource *source, DirectShowEventLoop *loop) - : m_source(source) - , m_device(device) - , m_loop(loop) - , m_pendingHead(0) - , m_pendingTail(0) - , m_readyHead(0) - , m_readyTail(0) - , m_synchronousPosition(0) - , m_synchronousLength(0) - , m_synchronousBytesRead(0) - , m_synchronousBuffer(0) - , m_synchronousResult(S_OK) - , m_totalLength(0) - , m_availableLength(0) - , m_flushing(false) -{ - moveToThread(device->thread()); - - connect(device, SIGNAL(readyRead()), this, SLOT(readyRead())); -} - -DirectShowIOReader::~DirectShowIOReader() -{ - flushRequests(); -} - -HRESULT DirectShowIOReader::QueryInterface(REFIID riid, void **ppvObject) -{ - return m_source->QueryInterface(riid, ppvObject); -} - -ULONG DirectShowIOReader::AddRef() -{ - return m_source->AddRef(); -} - -ULONG DirectShowIOReader::Release() -{ - return m_source->Release(); -} - -// IAsyncReader -HRESULT DirectShowIOReader::RequestAllocator( - IMemAllocator *pPreferred, ALLOCATOR_PROPERTIES *pProps, IMemAllocator **ppActual) -{ - if (!ppActual || !pProps) { - return E_POINTER; - } else { - ALLOCATOR_PROPERTIES actualProperties; - - if (pProps->cbAlign == 0) - pProps->cbAlign = 1; - - if (pPreferred && pPreferred->SetProperties(pProps, &actualProperties) == S_OK) { - pPreferred->AddRef(); - - *ppActual = pPreferred; - - m_source->setAllocator(*ppActual); - - return S_OK; - } else { - *ppActual = com_new<IMemAllocator>(CLSID_MemoryAllocator, IID_IMemAllocator); - - if (*ppActual) { - if ((*ppActual)->SetProperties(pProps, &actualProperties) != S_OK) { - (*ppActual)->Release(); - } else { - m_source->setAllocator(*ppActual); - - return S_OK; - } - } - } - ppActual = 0; - - return E_FAIL; - } -} - -HRESULT DirectShowIOReader::Request(IMediaSample *pSample, DWORD_PTR dwUser) -{ - QMutexLocker locker(&m_mutex); - - if (!pSample) { - return E_POINTER; - } else if (m_flushing) { - return VFW_E_WRONG_STATE; - } else { - REFERENCE_TIME startTime = 0; - REFERENCE_TIME endTime = 0; - BYTE *buffer; - - if (pSample->GetTime(&startTime, &endTime) != S_OK - || pSample->GetPointer(&buffer) != S_OK) { - return VFW_E_SAMPLE_TIME_NOT_SET; - } else { - LONGLONG position = startTime / 10000000; - LONG length = (endTime - startTime) / 10000000; - - DirectShowSampleRequest *request = new DirectShowSampleRequest( - pSample, dwUser, position, length, buffer); - - if (m_pendingTail) { - m_pendingTail->next = request; - } else { - m_pendingHead = request; - - m_loop->postEvent(this, new QEvent(QEvent::User)); - } - m_pendingTail = request; - - return S_OK; - } - } -} - -HRESULT DirectShowIOReader::WaitForNext( - DWORD dwTimeout, IMediaSample **ppSample, DWORD_PTR *pdwUser) -{ - if (!ppSample || !pdwUser) - return E_POINTER; - - QMutexLocker locker(&m_mutex); - - do { - if (m_readyHead) { - DirectShowSampleRequest *request = m_readyHead; - - *ppSample = request->sample; - *pdwUser = request->userData; - - HRESULT hr = request->result; - - m_readyHead = request->next; - - if (!m_readyHead) - m_readyTail = 0; - - delete request; - - return hr; - } else if (m_flushing) { - *ppSample = 0; - *pdwUser = 0; - - return VFW_E_WRONG_STATE; - } - } while (m_wait.wait(&m_mutex, dwTimeout)); - - *ppSample = 0; - *pdwUser = 0; - - return VFW_E_TIMEOUT; -} - -HRESULT DirectShowIOReader::SyncReadAligned(IMediaSample *pSample) -{ - if (!pSample) { - return E_POINTER; - } else { - REFERENCE_TIME startTime = 0; - REFERENCE_TIME endTime = 0; - BYTE *buffer; - - if (pSample->GetTime(&startTime, &endTime) != S_OK - || pSample->GetPointer(&buffer) != S_OK) { - return VFW_E_SAMPLE_TIME_NOT_SET; - } else { - LONGLONG position = startTime / 10000000; - LONG length = (endTime - startTime) / 10000000; - - QMutexLocker locker(&m_mutex); - - if (thread() == QThread::currentThread()) { - qint64 bytesRead = 0; - - HRESULT hr = blockingRead(position, length, buffer, &bytesRead); - - if (SUCCEEDED(hr)) - pSample->SetActualDataLength(bytesRead); - - return hr; - } else { - m_synchronousPosition = position; - m_synchronousLength = length; - m_synchronousBuffer = buffer; - - m_loop->postEvent(this, new QEvent(QEvent::User)); - - m_wait.wait(&m_mutex); - - m_synchronousBuffer = 0; - - if (SUCCEEDED(m_synchronousResult)) - pSample->SetActualDataLength(m_synchronousBytesRead); - - return m_synchronousResult; - } - } - } -} - -HRESULT DirectShowIOReader::SyncRead(LONGLONG llPosition, LONG lLength, BYTE *pBuffer) -{ - if (!pBuffer) { - return E_POINTER; - } else { - if (thread() == QThread::currentThread()) { - qint64 bytesRead; - - return blockingRead(llPosition, lLength, pBuffer, &bytesRead); - } else { - QMutexLocker locker(&m_mutex); - - m_synchronousPosition = llPosition; - m_synchronousLength = lLength; - m_synchronousBuffer = pBuffer; - - m_loop->postEvent(this, new QEvent(QEvent::User)); - - m_wait.wait(&m_mutex); - - m_synchronousBuffer = 0; - - return m_synchronousResult; - } - } -} - -HRESULT DirectShowIOReader::Length(LONGLONG *pTotal, LONGLONG *pAvailable) -{ - if (!pTotal || !pAvailable) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - *pTotal = m_totalLength; - *pAvailable = m_availableLength; - - return S_OK; - } -} - - -HRESULT DirectShowIOReader::BeginFlush() -{ - QMutexLocker locker(&m_mutex); - - if (m_flushing) - return S_FALSE; - - m_flushing = true; - - flushRequests(); - - m_wait.wakeAll(); - - return S_OK; -} - -HRESULT DirectShowIOReader::EndFlush() -{ - QMutexLocker locker(&m_mutex); - - if (!m_flushing) - return S_FALSE; - - m_flushing = false; - - return S_OK; -} - -void DirectShowIOReader::customEvent(QEvent *event) -{ - if (event->type() == QEvent::User) { - readyRead(); - } else { - QObject::customEvent(event); - } -} - -void DirectShowIOReader::readyRead() -{ - QMutexLocker locker(&m_mutex); - - m_availableLength = m_device->bytesAvailable() + m_device->pos(); - m_totalLength = m_device->size(); - - if (m_synchronousBuffer) { - if (nonBlockingRead( - m_synchronousPosition, - m_synchronousLength, - m_synchronousBuffer, - &m_synchronousBytesRead, - &m_synchronousResult)) { - m_wait.wakeAll(); - } - } else { - qint64 bytesRead = 0; - - while (m_pendingHead && nonBlockingRead( - m_pendingHead->position, - m_pendingHead->length, - m_pendingHead->buffer, - &bytesRead, - &m_pendingHead->result)) { - m_pendingHead->sample->SetActualDataLength(bytesRead); - - if (m_readyTail) - m_readyTail->next = m_pendingHead; - m_readyTail = m_pendingHead; - - m_pendingHead = m_pendingHead->next; - - m_readyTail->next = 0; - - if (!m_pendingHead) - m_pendingTail = 0; - - if (!m_readyHead) - m_readyHead = m_readyTail; - - m_wait.wakeAll(); - } - } -} - -HRESULT DirectShowIOReader::blockingRead( - LONGLONG position, LONG length, BYTE *buffer, qint64 *bytesRead) -{ - *bytesRead = 0; - - if (qint64(position) > m_device->size()) - return S_FALSE; - - const qint64 maxSize = qMin<qint64>(m_device->size(), position + length); - - while (m_device->bytesAvailable() + m_device->pos() < maxSize) { - if (!m_device->waitForReadyRead(-1)) - return S_FALSE; - } - - if (m_device->pos() != position && !m_device->seek(position)) - return S_FALSE; - - const qint64 maxBytes = qMin<qint64>(length, m_device->bytesAvailable()); - - *bytesRead = m_device->read(reinterpret_cast<char *>(buffer), maxBytes); - - if (*bytesRead != length) { - qMemSet(buffer + *bytesRead, 0, length - *bytesRead); - - return S_FALSE; - } else { - return S_OK; - } -} - -bool DirectShowIOReader::nonBlockingRead( - LONGLONG position, LONG length, BYTE *buffer, qint64 *bytesRead, HRESULT *result) -{ - const qint64 maxSize = qMin<qint64>(m_device->size(), position + length); - - if (position > m_device->size()) { - *bytesRead = 0; - *result = S_FALSE; - - return true; - } else if (m_device->bytesAvailable() + m_device->pos() >= maxSize) { - if (m_device->pos() != position && !m_device->seek(position)) { - *bytesRead = 0; - *result = S_FALSE; - - return true; - } else { - const qint64 maxBytes = qMin<qint64>(length, m_device->bytesAvailable()); - - *bytesRead = m_device->read(reinterpret_cast<char *>(buffer), maxBytes); - - if (*bytesRead != length) { - qMemSet(buffer + *bytesRead, 0, length - *bytesRead); - - *result = S_FALSE; - } else { - *result = S_OK; - } - - return true; - } - } else { - return false; - } -} - -void DirectShowIOReader::flushRequests() -{ - while (m_pendingHead) { - m_pendingHead->result = VFW_E_WRONG_STATE; - - if (m_readyTail) - m_readyTail->next = m_pendingHead; - - m_readyTail = m_pendingHead; - - m_pendingHead = m_pendingHead->next; - - m_readyTail->next = 0; - - if (!m_pendingHead) - m_pendingTail = 0; - - if (!m_readyHead) - m_readyHead = m_readyTail; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowioreader.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowioreader.h deleted file mode 100644 index 8cbc2f1..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowioreader.h +++ /dev/null @@ -1,126 +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 DIRECTSHOWIOREADER_H -#define DIRECTSHOWIOREADER_H - -#include <QtCore/qmutex.h> -#include <QtCore/qobject.h> -#include <QtCore/qwaitcondition.h> - -#include <dshow.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QIODevice; - -class DirectShowEventLoop; -class DirectShowIOSource; -class DirectShowSampleRequest; - -class DirectShowIOReader : public QObject, public IAsyncReader -{ - Q_OBJECT -public: - DirectShowIOReader(QIODevice *device, DirectShowIOSource *source, DirectShowEventLoop *loop); - ~DirectShowIOReader(); - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); - - // IAsyncReader - HRESULT STDMETHODCALLTYPE RequestAllocator( - IMemAllocator *pPreferred, ALLOCATOR_PROPERTIES *pProps, IMemAllocator **ppActual); - - HRESULT STDMETHODCALLTYPE Request(IMediaSample *pSample, DWORD_PTR dwUser); - - HRESULT STDMETHODCALLTYPE WaitForNext( - DWORD dwTimeout, IMediaSample **ppSample, DWORD_PTR *pdwUser); - - HRESULT STDMETHODCALLTYPE SyncReadAligned(IMediaSample *pSample); - - HRESULT STDMETHODCALLTYPE SyncRead(LONGLONG llPosition, LONG lLength, BYTE *pBuffer); - - HRESULT STDMETHODCALLTYPE Length(LONGLONG *pTotal, LONGLONG *pAvailable); - - HRESULT STDMETHODCALLTYPE BeginFlush(); - HRESULT STDMETHODCALLTYPE EndFlush(); - -protected: - void customEvent(QEvent *event); - -private Q_SLOTS: - void readyRead(); - -private: - HRESULT blockingRead(LONGLONG position, LONG length, BYTE *buffer, qint64 *bytesRead); - bool nonBlockingRead( - LONGLONG position, LONG length, BYTE *buffer, qint64 *bytesRead, HRESULT *result); - void flushRequests(); - - DirectShowIOSource *m_source; - QIODevice *m_device; - DirectShowEventLoop *m_loop; - DirectShowSampleRequest *m_pendingHead; - DirectShowSampleRequest *m_pendingTail; - DirectShowSampleRequest *m_readyHead; - DirectShowSampleRequest *m_readyTail; - LONGLONG m_synchronousPosition; - LONG m_synchronousLength; - qint64 m_synchronousBytesRead; - BYTE *m_synchronousBuffer; - HRESULT m_synchronousResult; - LONGLONG m_totalLength; - LONGLONG m_availableLength; - bool m_flushing; - QMutex m_mutex; - QWaitCondition m_wait; -}; - -QT_END_NAMESPACE - -QT_END_HEADER -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowiosource.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowiosource.cpp deleted file mode 100644 index 7b66d56..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowiosource.cpp +++ /dev/null @@ -1,639 +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 "directshowiosource.h" - -#include "directshowglobal.h" -#include "directshowmediatype.h" -#include "directshowpinenum.h" - -#include <QtCore/qcoreapplication.h> -#include <QtCore/qurl.h> - -QT_BEGIN_NAMESPACE - -static const GUID directshow_subtypes[] = -{ - MEDIASUBTYPE_Avi, - MEDIASUBTYPE_WAVE, - MEDIASUBTYPE_NULL -}; - -DirectShowIOSource::DirectShowIOSource(DirectShowEventLoop *loop) - : m_ref(1) - , m_state(State_Stopped) - , m_reader(0) - , m_loop(loop) - , m_graph(0) - , m_clock(0) - , m_allocator(0) - , m_peerPin(0) - , m_pinId(QLatin1String("Data")) -{ - QVector<AM_MEDIA_TYPE> mediaTypes; - - AM_MEDIA_TYPE type = - { - MEDIATYPE_Stream, // majortype - MEDIASUBTYPE_NULL, // subtype - TRUE, // bFixedSizeSamples - FALSE, // bTemporalCompression - 1, // lSampleSize - GUID_NULL, // formattype - 0, // pUnk - 0, // cbFormat - 0, // pbFormat - }; - - static const int count = sizeof(directshow_subtypes) / sizeof(GUID); - - for (int i = 0; i < count; ++i) { - type.subtype = directshow_subtypes[i]; - mediaTypes.append(type); - } - - setMediaTypes(mediaTypes); -} - -DirectShowIOSource::~DirectShowIOSource() -{ - Q_ASSERT(m_ref == 0); - - delete m_reader; -} - -void DirectShowIOSource::setDevice(QIODevice *device) -{ - Q_ASSERT(!m_reader); - - m_reader = new DirectShowIOReader(device, this, m_loop); -} - -void DirectShowIOSource::setAllocator(IMemAllocator *allocator) -{ - if (m_allocator) - m_allocator->Release(); - - m_allocator = allocator; - - if (m_allocator) - m_allocator->AddRef(); -} - -// IUnknown -HRESULT DirectShowIOSource::QueryInterface(REFIID riid, void **ppvObject) -{ - // 2dd74950-a890-11d1-abe8-00a0c905f375 - static const GUID iid_IAmFilterMiscFlags = { - 0x2dd74950, 0xa890, 0x11d1, {0xab, 0xe8, 0x00, 0xa0, 0xc9, 0x05, 0xf3, 0x75}}; - - if (!ppvObject) { - return E_POINTER; - } else if (riid == IID_IUnknown - || riid == IID_IPersist - || riid == IID_IMediaFilter - || riid == IID_IBaseFilter) { - *ppvObject = static_cast<IBaseFilter *>(this); - } else if (riid == iid_IAmFilterMiscFlags) { - *ppvObject = static_cast<IAMFilterMiscFlags *>(this); - } else if (riid == IID_IPin) { - *ppvObject = static_cast<IPin *>(this); - } else if (riid == IID_IAsyncReader) { - *ppvObject = static_cast<IAsyncReader *>(m_reader); - } else { - *ppvObject = 0; - - return E_NOINTERFACE; - } - - AddRef(); - - return S_OK; -} - -ULONG DirectShowIOSource::AddRef() -{ - return InterlockedIncrement(&m_ref); -} - -ULONG DirectShowIOSource::Release() -{ - ULONG ref = InterlockedDecrement(&m_ref); - - if (ref == 0) { - delete this; - } - - return ref; -} - -// IPersist -HRESULT DirectShowIOSource::GetClassID(CLSID *pClassID) -{ - *pClassID = CLSID_NULL; - - return S_OK; -} - -// IMediaFilter -HRESULT DirectShowIOSource::Run(REFERENCE_TIME tStart) -{ - QMutexLocker locker(&m_mutex); - - m_state = State_Running; - - return S_OK; -} - -HRESULT DirectShowIOSource::Pause() -{ - QMutexLocker locker(&m_mutex); - - m_state = State_Paused; - - return S_OK; -} - -HRESULT DirectShowIOSource::Stop() -{ - QMutexLocker locker(&m_mutex); - - m_state = State_Stopped; - - return S_OK; -} - -HRESULT DirectShowIOSource::GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *pState) -{ - Q_UNUSED(dwMilliSecsTimeout); - - if (!pState) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - *pState = m_state; - - return S_OK; - } -} - -HRESULT DirectShowIOSource::SetSyncSource(IReferenceClock *pClock) -{ - QMutexLocker locker(&m_mutex); - - if (m_clock) - m_clock->Release(); - - m_clock = pClock; - - if (m_clock) - m_clock->AddRef(); - - return S_OK; -} - -HRESULT DirectShowIOSource::GetSyncSource(IReferenceClock **ppClock) -{ - if (!ppClock) { - return E_POINTER; - } else { - if (!m_clock) { - *ppClock = 0; - - return S_FALSE; - } else { - m_clock->AddRef(); - - *ppClock = m_clock; - - return S_OK; - } - } -} - -// IBaseFilter -HRESULT DirectShowIOSource::EnumPins(IEnumPins **ppEnum) -{ - if (!ppEnum) { - return E_POINTER; - } else { - *ppEnum = new DirectShowPinEnum(QList<IPin *>() << this); - - return S_OK; - } -} - -HRESULT DirectShowIOSource::FindPin(LPCWSTR Id, IPin **ppPin) -{ - if (!ppPin || !Id) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - if (QString::fromWCharArray(Id) == m_pinId) { - AddRef(); - - *ppPin = this; - - return S_OK; - } else { - *ppPin = 0; - - return VFW_E_NOT_FOUND; - } - } -} - -HRESULT DirectShowIOSource::JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName) -{ - QMutexLocker locker(&m_mutex); - - m_graph = pGraph; - m_filterName = QString::fromWCharArray(pName); - - return S_OK; -} - -HRESULT DirectShowIOSource::QueryFilterInfo(FILTER_INFO *pInfo) -{ - if (!pInfo) { - return E_POINTER; - } else { - QString name = m_filterName; - - if (name.length() >= MAX_FILTER_NAME) - name.truncate(MAX_FILTER_NAME - 1); - - int length = name.toWCharArray(pInfo->achName); - pInfo->achName[length] = '\0'; - - if (m_graph) - m_graph->AddRef(); - - pInfo->pGraph = m_graph; - - return S_OK; - } -} - -HRESULT DirectShowIOSource::QueryVendorInfo(LPWSTR *pVendorInfo) -{ - Q_UNUSED(pVendorInfo); - - return E_NOTIMPL; -} - -// IAMFilterMiscFlags -ULONG DirectShowIOSource::GetMiscFlags() -{ - return AM_FILTER_MISC_FLAGS_IS_SOURCE; -} - -// IPin -HRESULT DirectShowIOSource::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) -{ - QMutexLocker locker(&m_mutex); - if (!pReceivePin) { - return E_POINTER; - } else if (m_state != State_Stopped) { - return VFW_E_NOT_STOPPED; - } else if (m_peerPin) { - return VFW_E_ALREADY_CONNECTED; - } else { - HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED; - - m_peerPin = pReceivePin; - m_peerPin->AddRef(); - - if (!pmt) { - IEnumMediaTypes *mediaTypes = 0; - if (pReceivePin->EnumMediaTypes(&mediaTypes) == S_OK) { - for (AM_MEDIA_TYPE *type = 0; - mediaTypes->Next(1, &type, 0) == S_OK; - DirectShowMediaType::deleteType(type)) { - switch (tryConnect(pReceivePin, type)) { - case S_OK: - DirectShowMediaType::freeData(type); - mediaTypes->Release(); - return S_OK; - case VFW_E_NO_TRANSPORT: - hr = VFW_E_NO_TRANSPORT; - break; - default: - break; - } - } - mediaTypes->Release(); - } - AM_MEDIA_TYPE type = - { - MEDIATYPE_Stream, // majortype - MEDIASUBTYPE_NULL, // subtype - TRUE, // bFixedSizeSamples - FALSE, // bTemporalCompression - 1, // lSampleSize - GUID_NULL, // formattype - 0, // pUnk - 0, // cbFormat - 0, // pbFormat - }; - - static const int count = sizeof(directshow_subtypes) / sizeof(GUID); - - for (int i = 0; i < count; ++i) { - type.subtype = directshow_subtypes[i]; - - switch (tryConnect(pReceivePin, &type)) { - case S_OK: - return S_OK; - case VFW_E_NO_TRANSPORT: - hr = VFW_E_NO_TRANSPORT; - break; - default: - break; - } - } - } else if (pmt->majortype == MEDIATYPE_Stream && (hr = tryConnect(pReceivePin, pmt))) { - return S_OK; - } - - m_peerPin->Release(); - m_peerPin = 0; - - m_mediaType.clear(); - - return hr; - } -} - -HRESULT DirectShowIOSource::tryConnect(IPin *pin, const AM_MEDIA_TYPE *type) -{ - m_mediaType = *type; - - HRESULT hr = pin->ReceiveConnection(this, type); - - if (!SUCCEEDED(hr)) { - if (m_allocator) { - m_allocator->Release(); - m_allocator = 0; - } - } else if (!m_allocator) { - hr = VFW_E_NO_TRANSPORT; - - if (IMemInputPin *memPin = com_cast<IMemInputPin>(pin, IID_IMemInputPin)) { - if ((m_allocator = com_new<IMemAllocator>(CLSID_MemoryAllocator, IID_IMemAllocator))) { - ALLOCATOR_PROPERTIES properties; - if (memPin->GetAllocatorRequirements(&properties) == S_OK - || m_allocator->GetProperties(&properties) == S_OK) { - if (properties.cbAlign == 0) - properties.cbAlign = 1; - - ALLOCATOR_PROPERTIES actualProperties; - if (SUCCEEDED(hr = m_allocator->SetProperties(&properties, &actualProperties))) - hr = memPin->NotifyAllocator(m_allocator, TRUE); - } - if (!SUCCEEDED(hr)) { - m_allocator->Release(); - m_allocator = 0; - } - } - memPin->Release(); - } - if (!SUCCEEDED(hr)) - pin->Disconnect(); - } - return hr; -} - -HRESULT DirectShowIOSource::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt) -{ - Q_UNUSED(pConnector); - Q_UNUSED(pmt); - // Output pin. - return E_NOTIMPL; -} - -HRESULT DirectShowIOSource::Disconnect() -{ - if (!m_peerPin) { - return S_FALSE; - } else if (m_state != State_Stopped) { - return VFW_E_NOT_STOPPED; - } else { - HRESULT hr = m_peerPin->Disconnect(); - - if (!SUCCEEDED(hr)) - return hr; - - if (m_allocator) { - m_allocator->Release(); - m_allocator = 0; - } - - m_peerPin->Release(); - m_peerPin = 0; - - m_mediaType.clear(); - - return S_OK; - } -} - -HRESULT DirectShowIOSource::ConnectedTo(IPin **ppPin) -{ - if (!ppPin) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - if (!m_peerPin) { - *ppPin = 0; - - return VFW_E_NOT_CONNECTED; - } else { - m_peerPin->AddRef(); - - *ppPin = m_peerPin; - - return S_OK; - } - } -} - -HRESULT DirectShowIOSource::ConnectionMediaType(AM_MEDIA_TYPE *pmt) -{ - if (!pmt) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - if (!m_peerPin) { - pmt = 0; - - return VFW_E_NOT_CONNECTED; - } else { - DirectShowMediaType::copy(pmt, m_mediaType); - - return S_OK; - } - } -} - -HRESULT DirectShowIOSource::QueryPinInfo(PIN_INFO *pInfo) -{ - if (!pInfo) { - return E_POINTER; - } else { - AddRef(); - - pInfo->pFilter = this; - pInfo->dir = PINDIR_OUTPUT; - - const int bytes = qMin(MAX_FILTER_NAME, (m_pinId.length() + 1) * 2); - - qMemCopy(pInfo->achName, m_pinId.utf16(), bytes); - - return S_OK; - } -} - -HRESULT DirectShowIOSource::QueryId(LPWSTR *Id) -{ - if (!Id) { - return E_POINTER; - } else { - const int bytes = (m_pinId.length() + 1) * 2; - - *Id = static_cast<LPWSTR>(::CoTaskMemAlloc(bytes)); - - qMemCopy(*Id, m_pinId.utf16(), bytes); - - return S_OK; - } -} - -HRESULT DirectShowIOSource::QueryAccept(const AM_MEDIA_TYPE *pmt) -{ - if (!pmt) { - return E_POINTER; - } else if (pmt->majortype == MEDIATYPE_Stream) { - return S_OK; - } else { - return S_FALSE; - } -} - -HRESULT DirectShowIOSource::EnumMediaTypes(IEnumMediaTypes **ppEnum) -{ - if (!ppEnum) { - return E_POINTER; - } else { - *ppEnum = createMediaTypeEnum(); - - return S_OK; - } -} - -HRESULT DirectShowIOSource::QueryInternalConnections(IPin **apPin, ULONG *nPin) -{ - Q_UNUSED(apPin); - Q_UNUSED(nPin); - - return E_NOTIMPL; -} - -HRESULT DirectShowIOSource::EndOfStream() -{ - return S_OK; -} - -HRESULT DirectShowIOSource::BeginFlush() -{ - return m_reader->BeginFlush(); -} - -HRESULT DirectShowIOSource::EndFlush() -{ - return m_reader->EndFlush(); -} - -HRESULT DirectShowIOSource::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) -{ - Q_UNUSED(tStart); - Q_UNUSED(tStop); - Q_UNUSED(dRate); - - return S_OK; -} - -HRESULT DirectShowIOSource::QueryDirection(PIN_DIRECTION *pPinDir) -{ - if (!pPinDir) { - return E_POINTER; - } else { - *pPinDir = PINDIR_OUTPUT; - - return S_OK; - } -} - -QT_END_NAMESPACE - -DirectShowRcSource::DirectShowRcSource(DirectShowEventLoop *loop) - : DirectShowIOSource(loop) -{ -} - -bool DirectShowRcSource::open(const QUrl &url) -{ - m_file.moveToThread(QCoreApplication::instance()->thread()); - - m_file.setFileName(QLatin1Char(':') + url.path()); - - if (m_file.open(QIODevice::ReadOnly)) { - - setDevice(&m_file); - - return true; - } else { - return false; - } -} diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowiosource.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowiosource.h deleted file mode 100644 index 1d917df..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowiosource.h +++ /dev/null @@ -1,157 +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 DIRECTSHOWIOSOURCE_H -#define DIRECTSHOWIOSOURCE_H - -#include "directshowglobal.h" -#include "directshowioreader.h" -#include "directshowmediatype.h" -#include "directshowmediatypelist.h" - -#include <QtCore/qfile.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowIOSource - : public DirectShowMediaTypeList - , public IBaseFilter - , public IAMFilterMiscFlags - , public IPin -{ -public: - DirectShowIOSource(DirectShowEventLoop *loop); - ~DirectShowIOSource(); - - void setDevice(QIODevice *device); - void setAllocator(IMemAllocator *allocator); - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); - - // IPersist - HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID); - - // IMediaFilter - HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart); - HRESULT STDMETHODCALLTYPE Pause(); - HRESULT STDMETHODCALLTYPE Stop(); - - HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *pState); - - HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock); - HRESULT STDMETHODCALLTYPE GetSyncSource(IReferenceClock **ppClock); - - // IBaseFilter - HRESULT STDMETHODCALLTYPE EnumPins(IEnumPins **ppEnum); - HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, IPin **ppPin); - - HRESULT STDMETHODCALLTYPE JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName); - - HRESULT STDMETHODCALLTYPE QueryFilterInfo(FILTER_INFO *pInfo); - HRESULT STDMETHODCALLTYPE QueryVendorInfo(LPWSTR *pVendorInfo); - - // IAMFilterMiscFlags - ULONG STDMETHODCALLTYPE GetMiscFlags(); - - // IPin - HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt); - HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt); - HRESULT STDMETHODCALLTYPE Disconnect(); - HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **ppPin); - - HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt); - - HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo); - HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id); - - HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt); - - HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum); - - HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin); - - HRESULT STDMETHODCALLTYPE EndOfStream(); - - HRESULT STDMETHODCALLTYPE BeginFlush(); - HRESULT STDMETHODCALLTYPE EndFlush(); - - HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); - - HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir); - -private: - HRESULT tryConnect(IPin *pin, const AM_MEDIA_TYPE *type); - - volatile LONG m_ref; - FILTER_STATE m_state; - DirectShowIOReader *m_reader; - DirectShowEventLoop *m_loop; - IFilterGraph *m_graph; - IReferenceClock *m_clock; - IMemAllocator *m_allocator; - IPin *m_peerPin; - DirectShowMediaType m_mediaType; - QString m_filterName; - const QString m_pinId; - QMutex m_mutex; -}; - -class DirectShowRcSource : public DirectShowIOSource -{ -public: - DirectShowRcSource(DirectShowEventLoop *loop); - - bool open(const QUrl &url); - -private: - QFile m_file; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.cpp deleted file mode 100644 index f8f519d..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.cpp +++ /dev/null @@ -1,205 +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 "directshowmediatype.h" - - -QT_BEGIN_NAMESPACE - -namespace -{ - struct TypeLookup - { - QVideoFrame::PixelFormat pixelFormat; - GUID mediaType; - }; - - static const TypeLookup qt_typeLookup[] = - { - { QVideoFrame::Format_RGB32, /*MEDIASUBTYPE_RGB32*/ {0xe436eb7e, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}} }, - { QVideoFrame::Format_BGR24, /*MEDIASUBTYPE_RGB24*/ {0xe436eb7d, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}} }, - { QVideoFrame::Format_RGB565, /*MEDIASUBTYPE_RGB565*/ {0xe436eb7b, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}} }, - { QVideoFrame::Format_RGB555, /*MEDIASUBTYPE_RGB555*/ {0xe436eb7c, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}} }, - { QVideoFrame::Format_AYUV444, /*MEDIASUBTYPE_AYUV*/ {0x56555941, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_YUYV, /*MEDIASUBTYPE_YUY2*/ {0x32595559, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_UYVY, /*MEDIASUBTYPE_UYVY*/ {0x59565955, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_IMC1, /*MEDIASUBTYPE_IMC1*/ {0x31434D49, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_IMC2, /*MEDIASUBTYPE_IMC2*/ {0x32434D49, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_IMC3, /*MEDIASUBTYPE_IMC3*/ {0x33434D49, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_IMC4, /*MEDIASUBTYPE_IMC4*/ {0x34434D49, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_YV12, /*MEDIASUBTYPE_YV12*/ {0x32315659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_NV12, /*MEDIASUBTYPE_NV12*/ {0x3231564E, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} }, - { QVideoFrame::Format_YUV420P, /*MEDIASUBTYPE_IYUV*/ {0x56555949, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} } - }; -} - -void DirectShowMediaType::copy(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE &source) -{ - *target = source; - - if (source.cbFormat > 0) { - target->pbFormat = reinterpret_cast<PBYTE>(CoTaskMemAlloc(source.cbFormat)); - memcpy(target->pbFormat, source.pbFormat, source.cbFormat); - } - if (target->pUnk) - target->pUnk->AddRef(); -} - -void DirectShowMediaType::deleteType(AM_MEDIA_TYPE *type) -{ - freeData(type); - - CoTaskMemFree(type); -} - -void DirectShowMediaType::freeData(AM_MEDIA_TYPE *type) -{ - if (type->cbFormat > 0) - CoTaskMemFree(type->pbFormat); - - if (type->pUnk) - type->pUnk->Release(); -} - - -GUID DirectShowMediaType::convertPixelFormat(QVideoFrame::PixelFormat format) -{ - // MEDIASUBTYPE_None; - static const GUID none = { - 0xe436eb8e, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70} }; - - const int count = sizeof(qt_typeLookup) / sizeof(TypeLookup); - - for (int i = 0; i < count; ++i) - if (qt_typeLookup[i].pixelFormat == format) - return qt_typeLookup[i].mediaType; - return none; -} - -QVideoSurfaceFormat DirectShowMediaType::formatFromType(const AM_MEDIA_TYPE &type) -{ - const int count = sizeof(qt_typeLookup) / sizeof(TypeLookup); - - for (int i = 0; i < count; ++i) { - if (IsEqualGUID(qt_typeLookup[i].mediaType, type.subtype) && type.cbFormat > 0) { - if (IsEqualGUID(type.formattype, FORMAT_VideoInfo)) { - VIDEOINFOHEADER *header = reinterpret_cast<VIDEOINFOHEADER *>(type.pbFormat); - - QVideoSurfaceFormat format( - QSize(header->bmiHeader.biWidth, qAbs(header->bmiHeader.biHeight)), - qt_typeLookup[i].pixelFormat); - - if (header->AvgTimePerFrame > 0) - format.setFrameRate(10000 /header->AvgTimePerFrame); - - switch (qt_typeLookup[i].pixelFormat) { - case QVideoFrame::Format_RGB32: - case QVideoFrame::Format_BGR24: - case QVideoFrame::Format_RGB565: - case QVideoFrame::Format_RGB555: - if (header->bmiHeader.biHeight >= 0) - format.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); - break; - default: - break; - } - - return format; - } else if (IsEqualGUID(type.formattype, FORMAT_VideoInfo2)) { - VIDEOINFOHEADER2 *header = reinterpret_cast<VIDEOINFOHEADER2 *>(type.pbFormat); - - QVideoSurfaceFormat format( - QSize(header->bmiHeader.biWidth, qAbs(header->bmiHeader.biHeight)), - qt_typeLookup[i].pixelFormat); - - if (header->AvgTimePerFrame > 0) - format.setFrameRate(10000 / header->AvgTimePerFrame); - - switch (qt_typeLookup[i].pixelFormat) { - case QVideoFrame::Format_RGB32: - case QVideoFrame::Format_BGR24: - case QVideoFrame::Format_RGB565: - case QVideoFrame::Format_RGB555: - if (header->bmiHeader.biHeight >= 0) - format.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); - break; - default: - break; - } - - return format; - } - } - } - return QVideoSurfaceFormat(); -} - -int DirectShowMediaType::bytesPerLine(const QVideoSurfaceFormat &format) -{ - switch (format.pixelFormat()) { - // 32 bpp packed formats. - case QVideoFrame::Format_RGB32: - case QVideoFrame::Format_AYUV444: - return format.frameWidth() * 4; - // 24 bpp packed formats. - case QVideoFrame::Format_RGB24: - return format.frameWidth() * 3 + 3 - format.frameWidth() % 4; - // 16 bpp packed formats. - case QVideoFrame::Format_RGB565: - case QVideoFrame::Format_RGB555: - case QVideoFrame::Format_YUYV: - case QVideoFrame::Format_UYVY: - return format.frameWidth() * 2 + 3 - format.frameWidth() % 4; - // Planar formats. - case QVideoFrame::Format_IMC1: - case QVideoFrame::Format_IMC2: - case QVideoFrame::Format_IMC3: - case QVideoFrame::Format_IMC4: - case QVideoFrame::Format_YV12: - case QVideoFrame::Format_NV12: - case QVideoFrame::Format_YUV420P: - return format.frameWidth() + 3 - format.frameWidth() % 4; - default: - return 0; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.h deleted file mode 100644 index 3cc7307..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.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 DIRECTSHOWMEDIATYPE_H -#define DIRECTSHOWMEDIATYPE_H - -#include <QtMultimedia/qvideosurfaceformat.h> - -#include <dshow.h> -#include <dvdmedia.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class DirectShowMediaType : public AM_MEDIA_TYPE -{ -public: - DirectShowMediaType() { memset(this, 0, sizeof(DirectShowMediaType)); } - DirectShowMediaType(const AM_MEDIA_TYPE &type) { copy(this, type); } - DirectShowMediaType(const DirectShowMediaType &other) { copy(this, other); } - DirectShowMediaType &operator =(const AM_MEDIA_TYPE &type) { - freeData(this); copy(this, type); return *this; } - DirectShowMediaType &operator =(const DirectShowMediaType &other) { - freeData(this); copy(this, other); return *this; } - ~DirectShowMediaType() { freeData(this); } - - void clear() { freeData(this); memset(this, 0, sizeof(DirectShowMediaType)); } - - static void copy(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE &source); - static void freeData(AM_MEDIA_TYPE *type); - static void deleteType(AM_MEDIA_TYPE *type); - - static GUID convertPixelFormat(QVideoFrame::PixelFormat format); - static QVideoSurfaceFormat formatFromType(const AM_MEDIA_TYPE &type); - - static int bytesPerLine(const QVideoSurfaceFormat &format); -}; - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatypelist.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatypelist.cpp deleted file mode 100644 index f67794a..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatypelist.cpp +++ /dev/null @@ -1,229 +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 "directshowmediatypelist.h" - -#include "directshowmediatype.h" -#include "videosurfacefilter.h" - - -QT_BEGIN_NAMESPACE - -class DirectShowMediaTypeEnum : public IEnumMediaTypes -{ -public: - DirectShowMediaTypeEnum(DirectShowMediaTypeList *list, int token, int index = 0); - ~DirectShowMediaTypeEnum(); - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); - - // IEnumMediaTypes - HRESULT STDMETHODCALLTYPE Next( - ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched); - HRESULT STDMETHODCALLTYPE Skip(ULONG cMediaTypes); - HRESULT STDMETHODCALLTYPE Reset(); - - HRESULT STDMETHODCALLTYPE Clone(IEnumMediaTypes **ppEnum); - -private: - LONG m_ref; - DirectShowMediaTypeList *m_list; - int m_mediaTypeToken; - int m_index; -}; - - -DirectShowMediaTypeEnum::DirectShowMediaTypeEnum( - DirectShowMediaTypeList *list, int token, int index) - : m_ref(1) - , m_list(list) - , m_mediaTypeToken(token) - , m_index(index) -{ - m_list->AddRef(); -} - -DirectShowMediaTypeEnum::~DirectShowMediaTypeEnum() -{ - m_list->Release(); -} - -HRESULT DirectShowMediaTypeEnum::QueryInterface(REFIID riid, void **ppvObject) -{ - if (!ppvObject) { - return E_POINTER; - } else if (riid == IID_IUnknown - || riid == IID_IEnumMediaTypes) { - *ppvObject = static_cast<IEnumMediaTypes *>(this); - } else { - *ppvObject = 0; - - return E_NOINTERFACE; - } - - AddRef(); - - return S_OK; -} - -ULONG DirectShowMediaTypeEnum::AddRef() -{ - return InterlockedIncrement(&m_ref); -} - -ULONG DirectShowMediaTypeEnum::Release() -{ - ULONG ref = InterlockedDecrement(&m_ref); - - if (ref == 0) { - delete this; - } - - return ref; -} - -HRESULT DirectShowMediaTypeEnum::Next( - ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched) -{ - return m_list->nextMediaType(m_mediaTypeToken, &m_index, cMediaTypes, ppMediaTypes, pcFetched); -} - -HRESULT DirectShowMediaTypeEnum::Skip(ULONG cMediaTypes) -{ - return m_list->skipMediaType(m_mediaTypeToken, &m_index, cMediaTypes); -} - -HRESULT DirectShowMediaTypeEnum::Reset() -{ - m_mediaTypeToken = m_list->currentMediaTypeToken(); - m_index = 0; - - return S_OK; -} - -HRESULT DirectShowMediaTypeEnum::Clone(IEnumMediaTypes **ppEnum) -{ - return m_list->cloneMediaType(m_mediaTypeToken, m_index, ppEnum); -} - - -DirectShowMediaTypeList::DirectShowMediaTypeList() - : m_mediaTypeToken(0) -{ -} - -IEnumMediaTypes *DirectShowMediaTypeList::createMediaTypeEnum() -{ - return new DirectShowMediaTypeEnum(this, m_mediaTypeToken, 0); -} - - -void DirectShowMediaTypeList::setMediaTypes(const QVector<AM_MEDIA_TYPE> &types) -{ - ++m_mediaTypeToken; - - m_mediaTypes = types; -} - - -int DirectShowMediaTypeList::currentMediaTypeToken() -{ - return m_mediaTypeToken; -} - -HRESULT DirectShowMediaTypeList::nextMediaType( - int token, int *index, ULONG count, AM_MEDIA_TYPE **types, ULONG *fetchedCount) -{ - if (!types || (count != 1 && !fetchedCount)) { - return E_POINTER; - } else if (m_mediaTypeToken != token) { - return VFW_E_ENUM_OUT_OF_SYNC; - } else { - int boundedCount = qBound<int>(0, count, m_mediaTypes.count() - *index); - - for (int i = 0; i < boundedCount; ++i, ++(*index)) { - types[i] = reinterpret_cast<AM_MEDIA_TYPE *>(CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))); - - if (types[i]) { - DirectShowMediaType::copy(types[i], m_mediaTypes.at(*index)); - } else { - for (--i; i >= 0; --i) - CoTaskMemFree(types[i]); - - if (fetchedCount) - *fetchedCount = 0; - - return E_OUTOFMEMORY; - } - } - if (fetchedCount) - *fetchedCount = boundedCount; - - return boundedCount == count ? S_OK : S_FALSE; - } -} - -HRESULT DirectShowMediaTypeList::skipMediaType(int token, int *index, ULONG count) -{ - if (m_mediaTypeToken != token) { - return VFW_E_ENUM_OUT_OF_SYNC; - } else { - *index = qMin<int>(*index + count, m_mediaTypes.size()); - - return *index < m_mediaTypes.size() ? S_OK : S_FALSE; - } -} - -HRESULT DirectShowMediaTypeList::cloneMediaType(int token, int index, IEnumMediaTypes **enumeration) -{ - if (m_mediaTypeToken != token) { - return VFW_E_ENUM_OUT_OF_SYNC; - } else { - *enumeration = new DirectShowMediaTypeEnum(this, token, index); - - return S_OK; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatypelist.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatypelist.h deleted file mode 100644 index b49f24c..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatypelist.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 DIRECTSHOWMEDIATYPELIST_H -#define DIRECTSHOWMEDIATYPELIST_H - -#include <QtCore/qvector.h> - -#include <dshow.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowMediaTypeList : public IUnknown -{ -public: - DirectShowMediaTypeList(); - - IEnumMediaTypes *createMediaTypeEnum(); - - void setMediaTypes(const QVector<AM_MEDIA_TYPE> &types); - - virtual int currentMediaTypeToken(); - virtual HRESULT nextMediaType( - int token, int *index, ULONG count, AM_MEDIA_TYPE **types, ULONG *fetchedCount); - virtual HRESULT skipMediaType(int token, int *index, ULONG count); - virtual HRESULT cloneMediaType(int token, int index, IEnumMediaTypes **enumeration); - -private: - int m_mediaTypeToken; - QVector<AM_MEDIA_TYPE> m_mediaTypes; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowmetadatacontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowmetadatacontrol.cpp deleted file mode 100644 index 7f67a82..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowmetadatacontrol.cpp +++ /dev/null @@ -1,370 +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 <dshow.h> -#include <initguid.h> -#include <qnetwork.h> - -#include "directshowmetadatacontrol.h" - -#include "directshowplayerservice.h" - -#include <QtCore/qcoreapplication.h> - - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_WMSDK -namespace -{ - struct QWMMetaDataKeyLookup - { - QtMediaServices::MetaData key; - const wchar_t *token; - }; -} - -static const QWMMetaDataKeyLookup qt_wmMetaDataKeys[] = -{ - { QtMediaServices::Title, L"Title" }, - { QtMediaServices::SubTitle, L"WM/SubTitle" }, - { QtMediaServices::Author, L"Author" }, - { QtMediaServices::Comment, L"Comment" }, - { QtMediaServices::Description, L"Description" }, - { QtMediaServices::Category, L"WM/Category" }, - { QtMediaServices::Genre, L"WM/Genre" }, - //{ QtMediaServices::Date, 0 }, - { QtMediaServices::Year, L"WM/Year" }, - { QtMediaServices::UserRating, L"UserRating" }, - //{ QtMediaServices::MetaDatawords, 0 }, - { QtMediaServices::Language, L"Language" }, - { QtMediaServices::Publisher, L"WM/Publisher" }, - { QtMediaServices::Copyright, L"Copyright" }, - { QtMediaServices::ParentalRating, L"ParentalRating" }, - { QtMediaServices::RatingOrganisation, L"RatingOrganisation" }, - - // Media - { QtMediaServices::Size, L"FileSize" }, - { QtMediaServices::MediaType, L"MediaType" }, - { QtMediaServices::Duration, L"Duration" }, - - // Audio - { QtMediaServices::AudioBitRate, L"AudioBitRate" }, - { QtMediaServices::AudioCodec, L"AudioCodec" }, - { QtMediaServices::ChannelCount, L"ChannelCount" }, - { QtMediaServices::SampleRate, L"Frequency" }, - - // Music - { QtMediaServices::AlbumTitle, L"WM/AlbumTitle" }, - { QtMediaServices::AlbumArtist, L"WM/AlbumArtist" }, - { QtMediaServices::ContributingArtist, L"Author" }, - { QtMediaServices::Composer, L"WM/Composer" }, - { QtMediaServices::Conductor, L"WM/Conductor" }, - { QtMediaServices::Lyrics, L"WM/Lyrics" }, - { QtMediaServices::Mood, L"WM/Mood" }, - { QtMediaServices::TrackNumber, L"WM/TrackNumber" }, - //{ QtMediaServices::TrackCount, 0 }, - //{ QtMediaServices::CoverArtUriSmall, 0 }, - //{ QtMediaServices::CoverArtUriLarge, 0 }, - - // Image/Video - //{ QtMediaServices::Resolution, 0 }, - //{ QtMediaServices::PixelAspectRatio, 0 }, - - // Video - //{ QtMediaServices::FrameRate, 0 }, - { QtMediaServices::VideoBitRate, L"VideoBitRate" }, - { QtMediaServices::VideoCodec, L"VideoCodec" }, - - //{ QtMediaServices::PosterUri, 0 }, - - // Movie - { QtMediaServices::ChapterNumber, L"ChapterNumber" }, - { QtMediaServices::Director, L"WM/Director" }, - { QtMediaServices::LeadPerformer, L"LeadPerformer" }, - { QtMediaServices::Writer, L"WM/Writer" }, - - // Photos - { QtMediaServices::CameraManufacturer, L"CameraManufacturer" }, - { QtMediaServices::CameraModel, L"CameraModel" }, - { QtMediaServices::Event, L"Event" }, - { QtMediaServices::Subject, L"Subject" } -}; - -static QVariant getValue(IWMHeaderInfo *header, const wchar_t *key) -{ - WORD streamNumber = 0; - WMT_ATTR_DATATYPE type = WMT_TYPE_DWORD; - WORD size = 0; - - if (header->GetAttributeByName(&streamNumber, key, &type, 0, &size) == S_OK) { - switch (type) { - case WMT_TYPE_DWORD: - if (size == sizeof(DWORD)) { - DWORD word; - if (header->GetAttributeByName( - &streamNumber, - key, - &type, - reinterpret_cast<BYTE *>(&word), - &size) == S_OK) { - return int(word); - } - } - break; - case WMT_TYPE_STRING: - { - QString string; - string.resize(size / 2 - 1); - - if (header->GetAttributeByName( - &streamNumber, - key, - &type, - reinterpret_cast<BYTE *>(const_cast<ushort *>(string.utf16())), - &size) == S_OK) { - return string; - } - } - break; - case WMT_TYPE_BINARY: - { - QByteArray bytes; - bytes.resize(size); - if (header->GetAttributeByName( - &streamNumber, - key, - &type, - reinterpret_cast<BYTE *>(bytes.data()), - &size) == S_OK) { - return bytes; - } - } - break; - case WMT_TYPE_BOOL: - if (size == sizeof(DWORD)) { - DWORD word; - if (header->GetAttributeByName( - &streamNumber, - key, - &type, - reinterpret_cast<BYTE *>(&word), - &size) == S_OK) { - return bool(word); - } - } - break; - case WMT_TYPE_QWORD: - if (size == sizeof(QWORD)) { - QWORD word; - if (header->GetAttributeByName( - &streamNumber, - key, - &type, - reinterpret_cast<BYTE *>(&word), - &size) == S_OK) { - return qint64(word); - } - } - break; - case WMT_TYPE_WORD: - if (size == sizeof(WORD)){ - WORD word; - if (header->GetAttributeByName( - &streamNumber, - key, - &type, - reinterpret_cast<BYTE *>(&word), - &size) == S_OK) { - return short(word); - } - } - break; - case WMT_TYPE_GUID: - if (size == 16) { - } - break; - default: - break; - } - } - return QVariant(); -} -#endif - -DirectShowMetaDataControl::DirectShowMetaDataControl(QObject *parent) - : QMetaDataControl(parent) - , m_content(0) -#ifndef QT_NO_WMSDK - , m_headerInfo(0) -#endif -{ -} - -DirectShowMetaDataControl::~DirectShowMetaDataControl() -{ -} - -bool DirectShowMetaDataControl::isWritable() const -{ - return false; -} - -bool DirectShowMetaDataControl::isMetaDataAvailable() const -{ -#ifndef QT_NO_WMSDK - return m_content || m_headerInfo; -#else - return m_content; -#endif -} - -QVariant DirectShowMetaDataControl::metaData(QtMediaServices::MetaData key) const -{ - QVariant value; - -#ifndef QT_NO_WMSDK - if (m_headerInfo) { - static const int count = sizeof(qt_wmMetaDataKeys) / sizeof(QWMMetaDataKeyLookup); - for (int i = 0; i < count; ++i) { - if (qt_wmMetaDataKeys[i].key == key) { - value = getValue(m_headerInfo, qt_wmMetaDataKeys[i].token); - break; - } - } - } else if (m_content) { -#else - if (m_content) { -#endif - BSTR string = 0; - - switch (key) { - case QtMediaServices::Author: - m_content->get_AuthorName(&string); - break; - case QtMediaServices::Title: - m_content->get_Title(&string); - break; - case QtMediaServices::ParentalRating: - m_content->get_Rating(&string); - break; - case QtMediaServices::Description: - m_content->get_Description(&string); - break; - case QtMediaServices::Copyright: - m_content->get_Copyright(&string); - break; - default: - break; - } - - if (string) { - value = QString::fromUtf16(reinterpret_cast<ushort *>(string), ::SysStringLen(string)); - - ::SysFreeString(string); - } - } - return value; -} - -void DirectShowMetaDataControl::setMetaData(QtMediaServices::MetaData, const QVariant &) -{ -} - -QList<QtMediaServices::MetaData> DirectShowMetaDataControl::availableMetaData() const -{ - return QList<QtMediaServices::MetaData>(); -} - -QVariant DirectShowMetaDataControl::extendedMetaData(const QString &) const -{ - return QVariant(); -} - -void DirectShowMetaDataControl::setExtendedMetaData(const QString &, const QVariant &) -{ -} - -QStringList DirectShowMetaDataControl::availableExtendedMetaData() const -{ - return QStringList(); -} - -void DirectShowMetaDataControl::updateGraph(IFilterGraph2 *graph, IBaseFilter *source) -{ - if (m_content) - m_content->Release(); - - if (!graph || graph->QueryInterface( - IID_IAMMediaContent, reinterpret_cast<void **>(&m_content)) != S_OK) { - m_content = 0; - } - -#ifdef QT_NO_WMSDK - Q_UNUSED(source); -#else - if (m_headerInfo) - m_headerInfo->Release(); - - m_headerInfo = com_cast<IWMHeaderInfo>(source, IID_IWMHeaderInfo); -#endif - // DirectShowMediaPlayerService holds a lock at this point so defer emitting signals to a later - // time. - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(MetaDataChanged))); -} - -void DirectShowMetaDataControl::customEvent(QEvent *event) -{ - if (event->type() == QEvent::Type(MetaDataChanged)) { - event->accept(); - - emit metaDataChanged(); -#ifndef QT_NO_WMSDK - emit metaDataAvailableChanged(m_content || m_headerInfo); -#else - emit metaDataAvailableChanged(m_content); -#endif - } else { - QMetaDataControl::customEvent(event); - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowmetadatacontrol.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowmetadatacontrol.h deleted file mode 100644 index e368f00..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowmetadatacontrol.h +++ /dev/null @@ -1,104 +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 DIRECTSHOWMETADATACONTROL_H -#define DIRECTSHOWMETADATACONTROL_H - -#include "directshowglobal.h" - -#include <QtMediaServices/qmetadatacontrol.h> - -#include <qnetwork.h> - -#ifndef QT_NO_WMSDK -#include <wmsdk.h> -#endif - -#include <QtCore/qcoreevent.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowPlayerService; - - -class DirectShowMetaDataControl : public QMetaDataControl -{ - Q_OBJECT -public: - DirectShowMetaDataControl(QObject *parent = 0); - ~DirectShowMetaDataControl(); - - bool isWritable() const; - bool isMetaDataAvailable() 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; - - void updateGraph(IFilterGraph2 *graph, IBaseFilter *source); - -protected: - void customEvent(QEvent *event); - -private: - enum Event - { - MetaDataChanged = QEvent::User - }; - - IAMMediaContent *m_content; -#ifndef QT_NO_WMSDK - IWMHeaderInfo *m_headerInfo; -#endif -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowpinenum.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowpinenum.cpp deleted file mode 100644 index 02b1a3b..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowpinenum.cpp +++ /dev/null @@ -1,140 +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 "directshowpinenum.h" - -#include <QtMediaServices> - - -QT_BEGIN_NAMESPACE - -DirectShowPinEnum::DirectShowPinEnum(const QList<IPin *> &pins) - : m_ref(1) - , m_pins(pins) - , m_index(0) -{ - foreach (IPin *pin, m_pins) - pin->AddRef(); -} - -DirectShowPinEnum::~DirectShowPinEnum() -{ - foreach (IPin *pin, m_pins) - pin->Release(); -} - -HRESULT DirectShowPinEnum::QueryInterface(REFIID riid, void **ppvObject) -{ - if (riid == IID_IUnknown - || riid == IID_IEnumPins) { - AddRef(); - - *ppvObject = static_cast<IEnumPins *>(this); - - return S_OK; - } else { - *ppvObject = 0; - - return E_NOINTERFACE; - } -} - -ULONG DirectShowPinEnum::AddRef() -{ - return InterlockedIncrement(&m_ref); -} - -ULONG DirectShowPinEnum::Release() -{ - ULONG ref = InterlockedDecrement(&m_ref); - - if (ref == 0) { - delete this; - } - - return ref; -} - -HRESULT DirectShowPinEnum::Next(ULONG cPins, IPin **ppPins, ULONG *pcFetched) -{ - if (ppPins && (pcFetched || cPins == 1)) { - ULONG count = qBound<ULONG>(0, cPins, m_pins.count() - m_index); - - for (ULONG i = 0; i < count; ++i, ++m_index) { - ppPins[i] = m_pins.at(m_index); - ppPins[i]->AddRef(); - } - - if (pcFetched) - *pcFetched = count; - - return count == cPins ? S_OK : S_FALSE; - } else { - return E_POINTER; - } -} - -HRESULT DirectShowPinEnum::Skip(ULONG cPins) -{ - m_index = qMin(int(m_index + cPins), m_pins.count()); - - return m_index < m_pins.count() ? S_OK : S_FALSE; -} - -HRESULT DirectShowPinEnum::Reset() -{ - m_index = 0; - - return S_OK; -} - -HRESULT DirectShowPinEnum::Clone(IEnumPins **ppEnum) -{ - if (ppEnum) { - *ppEnum = new DirectShowPinEnum(m_pins); - - return S_OK; - } else { - return E_POINTER; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowpinenum.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowpinenum.h deleted file mode 100644 index 40d99ea..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowpinenum.h +++ /dev/null @@ -1,81 +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 DIRECTSHOWPINENUM_H -#define DIRECTSHOWPINENUM_H - -#include <QtCore/qlist.h> - -#include <dshow.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowPinEnum : public IEnumPins -{ -public: - DirectShowPinEnum(const QList<IPin *> &pins); - ~DirectShowPinEnum(); - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); - - // IEnumPins - HRESULT STDMETHODCALLTYPE Next(ULONG cPins, IPin **ppPins, ULONG *pcFetched); - HRESULT STDMETHODCALLTYPE Skip(ULONG cPins); - HRESULT STDMETHODCALLTYPE Reset(); - HRESULT STDMETHODCALLTYPE Clone(IEnumPins **ppEnum); - -private: - LONG m_ref; - QList<IPin *> m_pins; - int m_index; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.cpp deleted file mode 100644 index 67d07e1..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.cpp +++ /dev/null @@ -1,395 +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 "directshowplayercontrol.h" - -#include "directshowplayerservice.h" - -#include <QtCore/qcoreapplication.h> -#include <QtCore/qmath.h> - - -QT_BEGIN_NAMESPACE - -static int volumeToDecibels(int volume) -{ - if (volume == 0) { - return -10000; - } else if (volume == 100) { - return 0; -#ifdef QT_USE_MATH_H_FLOATS - } else if (sizeof(qreal) == sizeof(float)) { - return qRound(::log10f(float(volume) / 100) * 5000); -#endif - } else { - return qRound(::log10(qreal(volume) / 100) * 5000); - } -} - -static int decibelsToVolume(int dB) -{ - if (dB == -10000) { - return 0; - } else if (dB == 0) { - return 100; - } else { - return qRound(100 * qPow(10, qreal(dB) / 5000)); - } -} - -DirectShowPlayerControl::DirectShowPlayerControl(DirectShowPlayerService *service, QObject *parent) - : QMediaPlayerControl(parent) - , m_service(service) - , m_audio(0) - , m_updateProperties(0) - , m_state(QMediaPlayer::StoppedState) - , m_status(QMediaPlayer::UnknownMediaStatus) - , m_error(QMediaPlayer::NoError) - , m_streamTypes(0) - , m_muteVolume(-1) - , m_position(0) - , m_duration(0) - , m_playbackRate(1.0) - , m_seekable(false) -{ -} - -DirectShowPlayerControl::~DirectShowPlayerControl() -{ - if (m_audio) - m_audio->Release(); -} - -QMediaPlayer::State DirectShowPlayerControl::state() const -{ - return m_state; -} - -QMediaPlayer::MediaStatus DirectShowPlayerControl::mediaStatus() const -{ - return m_status; -} - -qint64 DirectShowPlayerControl::duration() const -{ - return m_duration; -} - -qint64 DirectShowPlayerControl::position() const -{ - return const_cast<qint64 &>(m_position) = m_service->position(); -} - -void DirectShowPlayerControl::setPosition(qint64 position) -{ - m_service->seek(position); -} - -int DirectShowPlayerControl::volume() const -{ - if (m_muteVolume >= 0) { - return m_muteVolume; - } else if (m_audio) { - long dB = 0; - - m_audio->get_Volume(&dB); - - return decibelsToVolume(dB); - } else { - return 0; - } -} - -void DirectShowPlayerControl::setVolume(int volume) -{ - int boundedVolume = qBound(0, volume, 100); - - if (m_muteVolume >= 0) { - m_muteVolume = boundedVolume; - - emit volumeChanged(m_muteVolume); - } else if (m_audio) { - m_audio->put_Volume(volumeToDecibels(volume)); - - emit volumeChanged(boundedVolume); - } -} - -bool DirectShowPlayerControl::isMuted() const -{ - return m_muteVolume >= 0; -} - -void DirectShowPlayerControl::setMuted(bool muted) -{ - if (muted && m_muteVolume < 0) { - if (m_audio) { - long dB = 0; - - m_audio->get_Volume(&dB); - - m_muteVolume = decibelsToVolume(dB); - - m_audio->put_Volume(-10000); - } else { - m_muteVolume = 0; - } - - emit mutedChanged(muted); - } else if (!muted && m_muteVolume >= 0) { - if (m_audio) { - m_audio->put_Volume(volumeToDecibels(m_muteVolume)); - } - m_muteVolume = -1; - - emit mutedChanged(muted); - } -} - -int DirectShowPlayerControl::bufferStatus() const -{ - return m_service->bufferStatus(); -} - -bool DirectShowPlayerControl::isAudioAvailable() const -{ - return m_streamTypes & DirectShowPlayerService::AudioStream; -} - -bool DirectShowPlayerControl::isVideoAvailable() const -{ - return m_streamTypes & DirectShowPlayerService::VideoStream; -} - -bool DirectShowPlayerControl::isSeekable() const -{ - return m_seekable; -} - -QMediaTimeRange DirectShowPlayerControl::availablePlaybackRanges() const -{ - return m_service->availablePlaybackRanges(); -} - -qreal DirectShowPlayerControl::playbackRate() const -{ - return m_playbackRate; -} - -void DirectShowPlayerControl::setPlaybackRate(qreal rate) -{ - if (m_playbackRate != rate) { - m_service->setRate(rate); - - emit playbackRateChanged(m_playbackRate = rate); - } -} - -QMediaContent DirectShowPlayerControl::media() const -{ - return m_media; -} - -const QIODevice *DirectShowPlayerControl::mediaStream() const -{ - return m_stream; -} - -void DirectShowPlayerControl::setMedia(const QMediaContent &media, QIODevice *stream) -{ - m_media = media; - m_stream = stream; - - m_updateProperties &= PlaybackRateProperty; - - m_service->load(media, stream); - - emitPropertyChanges(); -} - -void DirectShowPlayerControl::play() -{ - m_service->play(); - emit stateChanged(m_state = QMediaPlayer::PlayingState); -} - -void DirectShowPlayerControl::pause() -{ - m_service->pause(); - emit stateChanged(m_state = QMediaPlayer::PausedState); -} - -void DirectShowPlayerControl::stop() -{ - m_service->stop(); - emit stateChanged(m_state = QMediaPlayer::StoppedState); -} - -void DirectShowPlayerControl::customEvent(QEvent *event) -{ - if (event->type() == QEvent::Type(PropertiesChanged)) { - emitPropertyChanges(); - - event->accept(); - } else { - QMediaPlayerControl::customEvent(event); - } -} - -void DirectShowPlayerControl::emitPropertyChanges() -{ - int properties = m_updateProperties; - m_updateProperties = 0; - - if ((properties & ErrorProperty) && m_error != QMediaPlayer::NoError) - emit error(m_error, m_errorString); - - if (properties & PlaybackRateProperty) - emit playbackRateChanged(m_playbackRate); - - if (properties & StreamTypesProperty) { - emit audioAvailableChanged(m_streamTypes & DirectShowPlayerService::AudioStream); - emit videoAvailableChanged(m_streamTypes & DirectShowPlayerService::VideoStream); - } - - if (properties & PositionProperty) - emit positionChanged(m_position); - - if (properties & DurationProperty) - emit durationChanged(m_duration); - - if (properties & SeekableProperty) - emit seekableChanged(m_seekable); - - if (properties & StatusProperty) - emit mediaStatusChanged(m_status); - - if (properties & StateProperty) - emit stateChanged(m_state); -} - -void DirectShowPlayerControl::scheduleUpdate(int properties) -{ - if (m_updateProperties == 0) - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(PropertiesChanged))); - - m_updateProperties |= properties; -} - -void DirectShowPlayerControl::updateState(QMediaPlayer::State state) -{ - if (m_state != state) { - m_state = state; - - scheduleUpdate(StateProperty); - } -} - -void DirectShowPlayerControl::updateStatus(QMediaPlayer::MediaStatus status) -{ - if (m_status != status) { - m_status = status; - - scheduleUpdate(StatusProperty); - } -} - -void DirectShowPlayerControl::updateMediaInfo(qint64 duration, int streamTypes, bool seekable) -{ - int properties = 0; - - if (m_duration != duration) { - m_duration = duration; - - properties |= DurationProperty; - } - if (m_streamTypes != streamTypes) { - m_streamTypes = streamTypes; - - properties |= StreamTypesProperty; - } - - if (m_seekable != seekable) { - m_seekable = seekable; - - properties |= SeekableProperty; - } - - if (properties != 0) - scheduleUpdate(properties); -} - -void DirectShowPlayerControl::updatePlaybackRate(qreal rate) -{ - if (m_playbackRate != rate) { - m_playbackRate = rate; - - scheduleUpdate(PlaybackRateProperty); - } -} - -void DirectShowPlayerControl::updateAudioOutput(IBaseFilter *filter) -{ - if (m_audio) - m_audio->Release(); - - m_audio = com_cast<IBasicAudio>(filter, IID_IBasicAudio); -} - -void DirectShowPlayerControl::updateError(QMediaPlayer::Error error, const QString &errorString) -{ - m_error = error; - m_errorString = errorString; - - if (m_error != QMediaPlayer::NoError) - scheduleUpdate(ErrorProperty); -} - -void DirectShowPlayerControl::updatePosition(qint64 position) -{ - if (m_position != position) { - m_position = position; - - scheduleUpdate(PositionProperty); - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.h deleted file mode 100644 index 6b5203e..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.h +++ /dev/null @@ -1,153 +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 DIRECTSHOWPLAYERCONTROL_H -#define DIRECTSHOWPLAYERCONTROL_H - -#include <QtMediaServices/qmediacontent.h> -#include <QtMediaServices/qmediaplayercontrol.h> - -#include <QtCore/qcoreevent.h> - -#include "directshowplayerservice.h" - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowPlayerControl : public QMediaPlayerControl -{ - Q_OBJECT -public: - DirectShowPlayerControl(DirectShowPlayerService *service, QObject *parent = 0); - ~DirectShowPlayerControl(); - - QMediaPlayer::State state() const; - - QMediaPlayer::MediaStatus mediaStatus() const; - - qint64 duration() const; - - qint64 position() const; - void setPosition(qint64 position); - - int volume() const; - void setVolume(int volume); - - bool isMuted() const; - void setMuted(bool muted); - - int bufferStatus() const; - - bool isAudioAvailable() const; - bool isVideoAvailable() const; - - bool isSeekable() const; - - QMediaTimeRange availablePlaybackRanges() const; - - qreal playbackRate() const; - void setPlaybackRate(qreal rate); - - QMediaContent media() const; - const QIODevice *mediaStream() const; - void setMedia(const QMediaContent &media, QIODevice *stream); - - void play(); - void pause(); - void stop(); - - void updateState(QMediaPlayer::State state); - void updateStatus(QMediaPlayer::MediaStatus status); - void updateMediaInfo(qint64 duration, int streamTypes, bool seekable); - void updatePlaybackRate(qreal rate); - void updateAudioOutput(IBaseFilter *filter); - void updateError(QMediaPlayer::Error error, const QString &errorString); - void updatePosition(qint64 position); - -protected: - void customEvent(QEvent *event); - -private: - enum Properties - { - StateProperty = 0x01, - StatusProperty = 0x02, - StreamTypesProperty = 0x04, - DurationProperty = 0x08, - PlaybackRateProperty = 0x10, - SeekableProperty = 0x20, - ErrorProperty = 0x40, - PositionProperty = 0x80 - }; - - enum Event - { - PropertiesChanged = QEvent::User - }; - - void scheduleUpdate(int properties); - void emitPropertyChanges(); - - DirectShowPlayerService *m_service; - IBasicAudio *m_audio; - QIODevice *m_stream; - int m_updateProperties; - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_status; - QMediaPlayer::Error m_error; - int m_streamTypes; - int m_muteVolume; - qint64 m_position; - qint64 m_duration; - qreal m_playbackRate; - bool m_seekable; - QMediaContent m_media; - QString m_errorString; - -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp deleted file mode 100644 index 8ad8cff..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp +++ /dev/null @@ -1,1410 +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 "directshowplayerservice.h" - -#include "directshowaudioendpointcontrol.h" -#include "directshowiosource.h" -#include "directshowmetadatacontrol.h" -#include "directshowplayercontrol.h" -#include "directshowvideooutputcontrol.h" -#include "directshowvideorenderercontrol.h" -#include "vmr9videowindowcontrol.h" - -#include <QtMediaServices/qmediacontent.h> - -#include <QtCore/qcoreapplication.h> -#include <QtCore/qdatetime.h> -#include <QtCore/qthread.h> -#include <QtCore/qvarlengtharray.h> - -Q_GLOBAL_STATIC(DirectShowEventLoop, qt_directShowEventLoop) - -QT_BEGIN_NAMESPACE - -class DirectShowPlayerServiceThread : public QThread -{ -public: - DirectShowPlayerServiceThread(DirectShowPlayerService *service) - : m_service(service) - { - } - -protected: - void run() { m_service->run(); } - -private: - DirectShowPlayerService *m_service; -}; - -DirectShowPlayerService::DirectShowPlayerService(QObject *parent) - : QMediaService(parent) - , m_playerControl(0) - , m_metaDataControl(0) - , m_videoOutputControl(0) - , m_videoRendererControl(0) - , m_videoWindowControl(0) - , m_audioEndpointControl(0) - , m_taskThread(0) - , m_loop(qt_directShowEventLoop()) - , m_pendingTasks(0) - , m_executingTask(0) - , m_executedTasks(0) - , m_taskHandle(::CreateEvent(0, 0, 0, 0)) - , m_eventHandle(0) - , m_graphStatus(NoMedia) - , m_stream(0) - , m_graph(0) - , m_source(0) - , m_audioOutput(0) - , m_videoOutput(0) - , m_rate(1.0) - , m_position(0) - , m_duration(0) - , m_buffering(false) - , m_seekable(false) - , m_atEnd(false) -{ - m_playerControl = new DirectShowPlayerControl(this); - m_metaDataControl = new DirectShowMetaDataControl(this); - m_videoOutputControl = new DirectShowVideoOutputControl; - m_audioEndpointControl = new DirectShowAudioEndpointControl(this); - m_videoRendererControl = new DirectShowVideoRendererControl(m_loop); - m_videoWindowControl = new Vmr9VideoWindowControl; - - m_taskThread = new DirectShowPlayerServiceThread(this); - m_taskThread->start(); - - connect(m_videoOutputControl, SIGNAL(outputChanged()), this, SLOT(videoOutputChanged())); - connect(m_videoRendererControl, SIGNAL(filterChanged()), this, SLOT(videoOutputChanged())); -} - -DirectShowPlayerService::~DirectShowPlayerService() -{ - { - QMutexLocker locker(&m_mutex); - - releaseGraph(); - - m_pendingTasks = Shutdown; - ::SetEvent(m_taskHandle); - } - - m_taskThread->wait(); - delete m_taskThread; - - if (m_audioOutput) { - m_audioOutput->Release(); - m_audioOutput = 0; - } - - if (m_videoOutput) { - m_videoOutput->Release(); - m_videoOutput = 0; - } - - delete m_playerControl; - delete m_audioEndpointControl; - delete m_metaDataControl; - delete m_videoOutputControl; - delete m_videoRendererControl; - delete m_videoWindowControl; - - ::CloseHandle(m_taskHandle); -} - -QMediaControl *DirectShowPlayerService::control(const char *name) const -{ - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) - return m_playerControl; - else if (qstrcmp(name, QAudioEndpointSelector_iid) == 0) - return m_audioEndpointControl; - else if (qstrcmp(name, QMetaDataControl_iid) == 0) - return m_metaDataControl; - else if (qstrcmp(name, QVideoOutputControl_iid) == 0) - return m_videoOutputControl; - else if (qstrcmp(name, QVideoRendererControl_iid) == 0) - return m_videoRendererControl; - else if (qstrcmp(name, QVideoWindowControl_iid) == 0) - return m_videoWindowControl; - else - return 0; -} - -void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream) -{ - QMutexLocker locker(&m_mutex); - - m_pendingTasks = 0; - - if (m_graph) - releaseGraph(); - - m_resources = media.resources(); - m_stream = stream; - m_error = QMediaPlayer::NoError; - m_errorString = QString(); - m_position = 0; - m_duration = 0; - m_streamTypes = 0; - m_executedTasks = 0; - m_buffering = false; - m_seekable = false; - m_atEnd = false; - m_metaDataControl->updateGraph(0, 0); - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(VideoOutputChange))); - - if (m_resources.isEmpty() && !stream) { - m_pendingTasks = 0; - m_graphStatus = NoMedia; - - m_url.clear(); - } else if (stream && (!stream->isReadable() || stream->isSequential())) { - m_pendingTasks = 0; - m_graphStatus = InvalidMedia; - m_error = QMediaPlayer::ResourceError; - } else { - // {36b73882-c2c8-11cf-8b46-00805f6cef60} - static const GUID iid_IFilterGraph2 = { - 0x36b73882, 0xc2c8, 0x11cf, {0x8b, 0x46, 0x00, 0x80, 0x5f, 0x6c, 0xef, 0x60} }; - m_graphStatus = Loading; - - m_graph = com_new<IFilterGraph2>(CLSID_FilterGraph, iid_IFilterGraph2); - - if (stream) - m_pendingTasks = SetStreamSource; - else - m_pendingTasks = SetUrlSource; - - ::SetEvent(m_taskHandle); - } - - m_playerControl->updateError(m_error, m_errorString); - m_playerControl->updateMediaInfo(m_duration, m_streamTypes, m_seekable); - m_playerControl->updateState(QMediaPlayer::StoppedState); - m_playerControl->updatePosition(m_position); - updateStatus(); -} - -void DirectShowPlayerService::doSetUrlSource(QMutexLocker *locker) -{ - IBaseFilter *source = 0; - - QMediaResource resource = m_resources.takeFirst(); - QUrl url = resource.url(); - - HRESULT hr = E_FAIL; - - if (url.scheme() == QLatin1String("http") || url.scheme() == QLatin1String("https")) { - static const GUID clsid_WMAsfReader = { - 0x187463a0, 0x5bb7, 0x11d3, {0xac, 0xbe, 0x00, 0x80, 0xc7, 0x5e, 0x24, 0x6e} }; - - // {56a868a6-0ad4-11ce-b03a-0020af0ba770} - static const GUID iid_IFileSourceFilter = { - 0x56a868a6, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70} }; - - if (IFileSourceFilter *fileSource = com_new<IFileSourceFilter>( - clsid_WMAsfReader, iid_IFileSourceFilter)) { - locker->unlock(); - hr = fileSource->Load(reinterpret_cast<const OLECHAR *>(url.toString().utf16()), 0); - locker->relock(); - - if (SUCCEEDED(hr)) { - source = com_cast<IBaseFilter>(fileSource, IID_IBaseFilter); - - if (!SUCCEEDED(hr = m_graph->AddFilter(source, L"Source")) && source) { - source->Release(); - source = 0; - } - } - - fileSource->Release(); - } - } else if (url.scheme() == QLatin1String("qrc")) { - DirectShowRcSource *rcSource = new DirectShowRcSource(m_loop); - - if (rcSource->open(url) && SUCCEEDED(hr = m_graph->AddFilter(rcSource, L"Source"))) - source = rcSource; - else - rcSource->Release(); - } - - if (!SUCCEEDED(hr)) { - locker->unlock(); - hr = m_graph->AddSourceFilter( - reinterpret_cast<const OLECHAR *>(url.toString().utf16()), L"Source", &source); - locker->relock(); - } - - if (SUCCEEDED(hr)) { - m_executedTasks |= SetSource; - m_pendingTasks |= Render; - - if (m_audioOutput) - m_pendingTasks |= SetAudioOutput; - if (m_videoOutput) - m_pendingTasks |= SetVideoOutput; - - if (m_rate != 1.0 && m_rate != 0.0) - m_pendingTasks |= SetRate; - - m_source = source; - } else if (!m_resources.isEmpty()) { - m_pendingTasks |= SetUrlSource; - } else { - m_pendingTasks = 0; - m_graphStatus = InvalidMedia; - - switch (hr) { - case VFW_E_UNKNOWN_FILE_TYPE: - m_error = QMediaPlayer::FormatError; - m_errorString = QString(); - break; - case E_OUTOFMEMORY: - case VFW_E_CANNOT_LOAD_SOURCE_FILTER: - case VFW_E_NOT_FOUND: - m_error = QMediaPlayer::ResourceError; - m_errorString = QString(); - default: - m_error = QMediaPlayer::ResourceError; - m_errorString = QString(); - qWarning("DirectShowPlayerService::doSetUrlSource: Unresolved error code %x", uint(hr)); - break; - } - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(Error))); - } -} - -void DirectShowPlayerService::doSetStreamSource(QMutexLocker *locker) -{ - DirectShowIOSource *source = new DirectShowIOSource(m_loop); - source->setDevice(m_stream); - - if (SUCCEEDED(m_graph->AddFilter(source, L"Source"))) { - m_executedTasks |= SetSource; - m_pendingTasks |= Render; - - if (m_audioOutput) - m_pendingTasks |= SetAudioOutput; - if (m_videoOutput) - m_pendingTasks |= SetVideoOutput; - - if (m_rate != 1.0 && m_rate != 0.0) - m_pendingTasks |= SetRate; - - m_source = source; - } else { - source->Release(); - - m_pendingTasks = 0; - m_graphStatus = InvalidMedia; - - m_error = QMediaPlayer::ResourceError; - m_errorString = QString(); - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(Error))); - } -} - -void DirectShowPlayerService::doRender(QMutexLocker *locker) -{ - if (m_executedTasks & Pause) - m_pendingTasks |= Pause; - else if (m_executedTasks & Play && m_rate != 0.0) - m_pendingTasks |= Play; - - if (IMediaControl *control = com_cast<IMediaControl>(m_graph, IID_IMediaControl)) { - control->Stop(); - control->Release(); - } - - if (m_pendingTasks & SetAudioOutput) { - m_graph->AddFilter(m_audioOutput, L"AudioOutput"); - - m_pendingTasks ^= SetAudioOutput; - m_executedTasks |= SetAudioOutput; - } - if (m_pendingTasks & SetVideoOutput) { - m_graph->AddFilter(m_videoOutput, L"VideoOutput"); - - m_pendingTasks ^= SetVideoOutput; - m_executedTasks |= SetVideoOutput; - } - - IFilterGraph2 *graph = m_graph; - graph->AddRef(); - - QVarLengthArray<IBaseFilter *, 16> filters; - m_source->AddRef(); - filters.append(m_source); - - bool rendered = false; - - HRESULT renderHr = S_OK; - - while (!filters.isEmpty()) { - IEnumPins *pins = 0; - IBaseFilter *filter = filters[filters.size() - 1]; - filters.removeLast(); - - if (!(m_pendingTasks & ReleaseFilters) && SUCCEEDED(filter->EnumPins(&pins))) { - int outputs = 0; - for (IPin *pin = 0; pins->Next(1, &pin, 0) == S_OK; pin->Release()) { - PIN_DIRECTION direction; - if (pin->QueryDirection(&direction) == S_OK && direction == PINDIR_OUTPUT) { - ++outputs; - - IPin *peer = 0; - if (pin->ConnectedTo(&peer) == S_OK) { - PIN_INFO peerInfo; - if (SUCCEEDED(peer->QueryPinInfo(&peerInfo))) - filters.append(peerInfo.pFilter); - peer->Release(); - } else { - locker->unlock(); - HRESULT hr; - if (SUCCEEDED(hr = graph->RenderEx( - pin, /*AM_RENDEREX_RENDERTOEXISTINGRENDERERS*/ 1, 0))) { - rendered = true; - } else if (renderHr == S_OK || renderHr == VFW_E_NO_DECOMPRESSOR){ - renderHr = hr; - } - locker->relock(); - } - } - } - - pins->Release(); - - if (outputs == 0) - rendered = true; - } - filter->Release(); - } - - if (m_audioOutput && !isConnected(m_audioOutput, PINDIR_INPUT)) { - graph->RemoveFilter(m_audioOutput); - - m_executedTasks &= ~SetAudioOutput; - } - - if (m_videoOutput && !isConnected(m_videoOutput, PINDIR_INPUT)) { - graph->RemoveFilter(m_videoOutput); - - m_executedTasks &= ~SetVideoOutput; - } - - graph->Release(); - - if (!(m_pendingTasks & ReleaseFilters)) { - if (rendered) { - if (!(m_executedTasks & FinalizeLoad)) - m_pendingTasks |= FinalizeLoad; - } else { - m_pendingTasks = 0; - - m_graphStatus = InvalidMedia; - - if (!m_audioOutput && !m_videoOutput) { - m_error = QMediaPlayer::ResourceError; - m_errorString = QString(); - } else { - switch (renderHr) { - case VFW_E_UNSUPPORTED_AUDIO: - case VFW_E_UNSUPPORTED_VIDEO: - case VFW_E_UNSUPPORTED_STREAM: - m_error = QMediaPlayer::FormatError; - m_errorString = QString(); - default: - m_error = QMediaPlayer::ResourceError; - m_errorString = QString(); - qWarning("DirectShowPlayerService::doRender: Unresolved error code %x", - uint(renderHr)); - } - } - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(Error))); - } - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(VideoOutputChange))); - - m_executedTasks |= Render; - } -} - -void DirectShowPlayerService::doFinalizeLoad(QMutexLocker *locker) -{ - if (m_graphStatus != Loaded) { - if (IMediaEvent *event = com_cast<IMediaEvent>(m_graph, IID_IMediaEvent)) { - event->GetEventHandle(reinterpret_cast<OAEVENT *>(&m_eventHandle)); - event->Release(); - } - if (IMediaSeeking *seeking = com_cast<IMediaSeeking>(m_graph, IID_IMediaSeeking)) { - LONGLONG duration = 0; - seeking->GetDuration(&duration); - m_duration = duration / 10; - - DWORD capabilities = 0; - seeking->GetCapabilities(&capabilities); - m_seekable = capabilities & AM_SEEKING_CanSeekAbsolute; - - seeking->Release(); - } - } - - if ((m_executedTasks & SetOutputs) == SetOutputs) { - m_streamTypes = AudioStream | VideoStream; - } else { - m_streamTypes = findStreamTypes(m_source); - } - - m_executedTasks |= FinalizeLoad; - - m_graphStatus = Loaded; - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(FinalizedLoad))); -} - -void DirectShowPlayerService::releaseGraph() -{ - if (m_graph) { - if (m_executingTask != 0) { - // {8E1C39A1-DE53-11cf-AA63-0080C744528D} - static const GUID iid_IAMOpenProgress = { - 0x8E1C39A1, 0xDE53, 0x11cf, {0xAA, 0x63, 0x00, 0x80, 0xC7, 0x44, 0x52, 0x8D} }; - - if (IAMOpenProgress *progress = com_cast<IAMOpenProgress>( - m_graph, iid_IAMOpenProgress)) { - progress->AbortOperation(); - progress->Release(); - } - m_graph->Abort(); - } - - m_pendingTasks = ReleaseGraph; - - ::SetEvent(m_taskHandle); - - m_loop->wait(&m_mutex); - } -} - -void DirectShowPlayerService::doReleaseGraph(QMutexLocker *locker) -{ - Q_UNUSED(locker); - - if (IMediaControl *control = com_cast<IMediaControl>(m_graph, IID_IMediaControl)) { - control->Stop(); - control->Release(); - } - - if (m_source) { - m_source->Release(); - m_source = 0; - } - - m_eventHandle = 0; - - m_graph->Release(); - m_graph = 0; - - m_loop->wake(); -} - -int DirectShowPlayerService::findStreamTypes(IBaseFilter *source) const -{ - QVarLengthArray<IBaseFilter *, 16> filters; - source->AddRef(); - filters.append(source); - - int streamTypes = 0; - - while (!filters.isEmpty()) { - IEnumPins *pins = 0; - IBaseFilter *filter = filters[filters.size() - 1]; - filters.removeLast(); - - if (SUCCEEDED(filter->EnumPins(&pins))) { - for (IPin *pin = 0; pins->Next(1, &pin, 0) == S_OK; pin->Release()) { - PIN_DIRECTION direction; - if (pin->QueryDirection(&direction) == S_OK && direction == PINDIR_OUTPUT) { - AM_MEDIA_TYPE connectionType; - if (SUCCEEDED(pin->ConnectionMediaType(&connectionType))) { - IPin *peer = 0; - - if (connectionType.majortype == MEDIATYPE_Audio) { - streamTypes |= AudioStream; - } else if (connectionType.majortype == MEDIATYPE_Video) { - streamTypes |= VideoStream; - } else if (SUCCEEDED(pin->ConnectedTo(&peer))) { - PIN_INFO peerInfo; - if (SUCCEEDED(peer->QueryPinInfo(&peerInfo))) - filters.append(peerInfo.pFilter); - peer->Release(); - } - } else { - streamTypes |= findStreamType(pin); - } - } - } - } - filter->Release(); - } - return streamTypes; -} - -int DirectShowPlayerService::findStreamType(IPin *pin) const -{ - IEnumMediaTypes *types; - - if (SUCCEEDED(pin->EnumMediaTypes(&types))) { - bool video = false; - bool audio = false; - bool other = false; - - for (AM_MEDIA_TYPE *type = 0; - types->Next(1, &type, 0) == S_OK; - DirectShowMediaType::deleteType(type)) { - if (type->majortype == MEDIATYPE_Audio) - audio = true; - else if (type->majortype == MEDIATYPE_Video) - video = true; - else - other = true; - } - types->Release(); - - if (other) - return 0; - else if (audio && !video) - return AudioStream; - else if (!audio && video) - return VideoStream; - else - return 0; - } else { - return 0; - } -} - -void DirectShowPlayerService::play() -{ - QMutexLocker locker(&m_mutex); - - if (m_rate != 0.0) { - m_pendingTasks &= ~Pause; - m_pendingTasks |= Play; - } else { - m_pendingTasks |= Pause; - m_executedTasks |= Play; - } - - if (m_executedTasks & Render) { - if (m_executedTasks & Stop) { - m_atEnd = false; - m_position = 0; - m_pendingTasks |= Seek; - m_executedTasks ^= Stop; - } - - ::SetEvent(m_taskHandle); - } -} - -void DirectShowPlayerService::doPlay(QMutexLocker *locker) -{ - if (IMediaControl *control = com_cast<IMediaControl>(m_graph, IID_IMediaControl)) { - locker->unlock(); - HRESULT hr = control->Run(); - locker->relock(); - - control->Release(); - - if (SUCCEEDED(hr)) { - m_executedTasks |= Play; - m_executedTasks &= ~Pause; - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(StatusChange))); - } else { - m_error = QMediaPlayer::ResourceError; - m_errorString = QString(); - qWarning("DirectShowPlayerService::doPlay: Unresolved error code %x", uint(hr)); - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(Error))); - } - } -} - -void DirectShowPlayerService::pause() -{ - QMutexLocker locker(&m_mutex); - - m_pendingTasks &= ~Play; - m_pendingTasks |= Pause; - - if (m_executedTasks & Render) { - if (m_executedTasks & Stop) { - m_atEnd = false; - m_position = 0; - m_pendingTasks |= Seek; - m_executedTasks ^= Stop; - } - - ::SetEvent(m_taskHandle); - } -} - -void DirectShowPlayerService::doPause(QMutexLocker *locker) -{ - if (IMediaControl *control = com_cast<IMediaControl>(m_graph, IID_IMediaControl)) { - locker->unlock(); - HRESULT hr = control->Pause(); - locker->relock(); - - control->Release(); - - if (SUCCEEDED(hr)) { - if (IMediaSeeking *seeking = com_cast<IMediaSeeking>(m_graph, IID_IMediaSeeking)) { - LONGLONG position = 0; - - seeking->GetCurrentPosition(&position); - seeking->Release(); - - m_position = position / 10; - } else { - m_position = 0; - } - - m_executedTasks |= Pause; - - if (m_rate != 0.0) - m_executedTasks &= ~Play; - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(StatusChange))); - } else { - m_error = QMediaPlayer::ResourceError; - m_errorString = QString(); - qWarning("DirectShowPlayerService::doPause: Unresolved error code %x", uint(hr)); - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(Error))); - } - } -} - -void DirectShowPlayerService::stop() -{ - QMutexLocker locker(&m_mutex); - - m_pendingTasks &= ~(Play | Pause | Seek); - - if ((m_executingTask | m_executedTasks) & (Play | Pause | Seek)) { - m_pendingTasks |= Stop; - - ::SetEvent(m_taskHandle); - - m_loop->wait(&m_mutex); - } - -} - -void DirectShowPlayerService::doStop(QMutexLocker *locker) -{ - if (m_executedTasks & (Play | Pause)) { - if (IMediaControl *control = com_cast<IMediaControl>(m_graph, IID_IMediaControl)) { - control->Stop(); - control->Release(); - } - - if (IMediaSeeking *seeking = com_cast<IMediaSeeking>(m_graph, IID_IMediaSeeking)) { - LONGLONG position = 0; - - seeking->GetCurrentPosition(&position); - seeking->Release(); - - m_position = position / 10; - } else { - m_position = 0; - } - - m_executedTasks &= ~(Play | Pause); - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(StatusChange))); - } - - m_executedTasks |= Stop; - - m_loop->wake(); -} - -void DirectShowPlayerService::setRate(qreal rate) -{ - QMutexLocker locker(&m_mutex); - - if (m_rate == rate) - return; - - if (rate == 0.0) { - if (m_pendingTasks & Play) { - m_executedTasks |= Play; - m_pendingTasks &= ~(Play | SetRate); - - if (!((m_executingTask | m_executedTasks) & Pause)) - m_pendingTasks |= Pause; - } else if ((m_executingTask | m_executedTasks) & Play) { - m_pendingTasks |= Pause; - } - } else { - m_pendingTasks |= SetRate; - - if (m_rate == 0.0 && (m_executedTasks & Play) && !(m_executingTask & Play)) - m_pendingTasks |= Play; - } - - m_rate = rate; - - if (m_executedTasks & FinalizeLoad) - ::SetEvent(m_taskHandle); -} - -void DirectShowPlayerService::doSetRate(QMutexLocker *locker) -{ - if (IMediaSeeking *seeking = com_cast<IMediaSeeking>(m_graph, IID_IMediaSeeking)) { - // Cache current values as we can't query IMediaSeeking during a seek due to the - // possibility of a deadlock when flushing the VideoSurfaceFilter. - LONGLONG currentPosition = 0; - seeking->GetCurrentPosition(¤tPosition); - m_position = currentPosition / 10; - - LONGLONG minimum = 0; - LONGLONG maximum = 0; - m_playbackRange = SUCCEEDED(seeking->GetAvailable(&minimum, &maximum)) - ? QMediaTimeRange(minimum / 10, maximum / 10) - : QMediaTimeRange(); - - locker->unlock(); - HRESULT hr = seeking->SetRate(m_rate); - locker->relock(); - - if (!SUCCEEDED(hr)) { - double rate = 0.0; - m_rate = seeking->GetRate(&rate) - ? rate - : 1.0; - } - - seeking->Release(); - } else if (m_rate != 1.0) { - m_rate = 1.0; - } - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(RateChange))); -} - -qint64 DirectShowPlayerService::position() const -{ - QMutexLocker locker(const_cast<QMutex *>(&m_mutex)); - - if (m_graphStatus == Loaded) { - if (m_executingTask == Seek || m_executingTask == SetRate) { - return m_position; - } else if (IMediaSeeking *seeking = com_cast<IMediaSeeking>(m_graph, IID_IMediaSeeking)) { - LONGLONG position = 0; - - seeking->GetCurrentPosition(&position); - seeking->Release(); - - const_cast<qint64 &>(m_position) = position / 10; - - return m_position; - } - } - return 0; -} - -QMediaTimeRange DirectShowPlayerService::availablePlaybackRanges() const -{ - QMutexLocker locker(const_cast<QMutex *>(&m_mutex)); - - if (m_graphStatus == Loaded) { - if (m_executingTask == Seek || m_executingTask == SetRate) { - return m_playbackRange; - } else if (IMediaSeeking *seeking = com_cast<IMediaSeeking>(m_graph, IID_IMediaSeeking)) { - LONGLONG minimum = 0; - LONGLONG maximum = 0; - - HRESULT hr = seeking->GetAvailable(&minimum, &maximum); - seeking->Release(); - - if (SUCCEEDED(hr)) - return QMediaTimeRange(minimum, maximum); - } - } - return QMediaTimeRange(); -} - -void DirectShowPlayerService::seek(qint64 position) -{ - QMutexLocker locker(&m_mutex); - - m_position = position; - - m_pendingTasks |= Seek; - - if (m_executedTasks & FinalizeLoad) - ::SetEvent(m_taskHandle); -} - -void DirectShowPlayerService::doSeek(QMutexLocker *locker) -{ - if (IMediaSeeking *seeking = com_cast<IMediaSeeking>(m_graph, IID_IMediaSeeking)) { - LONGLONG seekPosition = LONGLONG(m_position) * 10; - - // Cache current values as we can't query IMediaSeeking during a seek due to the - // possibility of a deadlock when flushing the VideoSurfaceFilter. - LONGLONG currentPosition = 0; - seeking->GetCurrentPosition(¤tPosition); - m_position = currentPosition / 10; - - LONGLONG minimum = 0; - LONGLONG maximum = 0; - m_playbackRange = SUCCEEDED(seeking->GetAvailable(&minimum, &maximum)) - ? QMediaTimeRange(minimum / 10, maximum / 10) - : QMediaTimeRange(); - - locker->unlock(); - seeking->SetPositions( - &seekPosition, AM_SEEKING_AbsolutePositioning, 0, AM_SEEKING_NoPositioning); - locker->relock(); - - seeking->GetCurrentPosition(¤tPosition); - m_position = currentPosition / 10; - - seeking->Release(); - } else { - m_position = 0; - } - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(PositionChange))); -} - -int DirectShowPlayerService::bufferStatus() const -{ -#ifndef QT_NO_WMSDK - QMutexLocker locker(const_cast<QMutex *>(&m_mutex)); - - if (IWMReaderAdvanced2 *reader = com_cast<IWMReaderAdvanced2>( - m_source, IID_IWMReaderAdvanced2)) { - DWORD percentage = 0; - - reader->GetBufferProgress(&percentage, 0); - reader->Release(); - - return percentage; - } else { - return 0; - } -#else - return 0; -#endif -} - -void DirectShowPlayerService::setAudioOutput(IBaseFilter *filter) -{ - QMutexLocker locker(&m_mutex); - - if (m_graph) { - if (m_audioOutput) { - if (m_executedTasks & SetAudioOutput) { - m_pendingTasks |= ReleaseAudioOutput; - - ::SetEvent(m_taskHandle); - - m_loop->wait(&m_mutex); - } - m_audioOutput->Release(); - } - - m_audioOutput = filter; - - if (m_audioOutput) { - m_audioOutput->AddRef(); - - m_pendingTasks |= SetAudioOutput; - - if (m_executedTasks & SetSource) { - m_pendingTasks |= Render; - - ::SetEvent(m_taskHandle); - } - } else { - m_pendingTasks &= ~ SetAudioOutput; - } - } else { - if (m_audioOutput) - m_audioOutput->Release(); - - m_audioOutput = filter; - - if (m_audioOutput) - m_audioOutput->AddRef(); - } - - m_playerControl->updateAudioOutput(m_audioOutput); -} - -void DirectShowPlayerService::doReleaseAudioOutput(QMutexLocker *locker) -{ - m_pendingTasks |= m_executedTasks & (Play | Pause); - - if (IMediaControl *control = com_cast<IMediaControl>(m_graph, IID_IMediaControl)) { - control->Stop(); - control->Release(); - } - - IBaseFilter *decoder = getConnected(m_audioOutput, PINDIR_INPUT); - if (!decoder) { - decoder = m_audioOutput; - decoder->AddRef(); - } - - // {DCFBDCF6-0DC2-45f5-9AB2-7C330EA09C29} - static const GUID iid_IFilterChain = { - 0xDCFBDCF6, 0x0DC2, 0x45f5, {0x9A, 0xB2, 0x7C, 0x33, 0x0E, 0xA0, 0x9C, 0x29} }; - - if (IFilterChain *chain = com_cast<IFilterChain>(m_graph, iid_IFilterChain)) { - chain->RemoveChain(decoder, m_audioOutput); - chain->Release(); - } else { - m_graph->RemoveFilter(m_audioOutput); - } - - decoder->Release(); - - m_executedTasks &= ~SetAudioOutput; - - m_loop->wake(); -} - -void DirectShowPlayerService::setVideoOutput(IBaseFilter *filter) -{ - QMutexLocker locker(&m_mutex); - - if (m_graph) { - if (m_videoOutput) { - if (m_executedTasks & SetVideoOutput) { - m_pendingTasks |= ReleaseVideoOutput; - - ::SetEvent(m_taskHandle); - - m_loop->wait(&m_mutex); - } - m_videoOutput->Release(); - } - - m_videoOutput = filter; - - if (m_videoOutput) { - m_videoOutput->AddRef(); - - m_pendingTasks |= SetVideoOutput; - - if (m_executedTasks & SetSource) { - m_pendingTasks |= Render; - - ::SetEvent(m_taskHandle); - } - } - } else { - if (m_videoOutput) - m_videoOutput->Release(); - - m_videoOutput = filter; - - if (m_videoOutput) - m_videoOutput->AddRef(); - } -} - -void DirectShowPlayerService::doReleaseVideoOutput(QMutexLocker *locker) -{ - m_pendingTasks |= m_executedTasks & (Play | Pause); - - if (IMediaControl *control = com_cast<IMediaControl>(m_graph, IID_IMediaControl)) { - control->Stop(); - control->Release(); - } - - IBaseFilter *intermediate = 0; - if (!SUCCEEDED(m_graph->FindFilterByName(L"Color Space Converter", &intermediate))) { - intermediate = m_videoOutput; - intermediate->AddRef(); - } - - IBaseFilter *decoder = getConnected(intermediate, PINDIR_INPUT); - if (!decoder) { - decoder = intermediate; - decoder->AddRef(); - } - - // {DCFBDCF6-0DC2-45f5-9AB2-7C330EA09C29} - static const GUID iid_IFilterChain = { - 0xDCFBDCF6, 0x0DC2, 0x45f5, {0x9A, 0xB2, 0x7C, 0x33, 0x0E, 0xA0, 0x9C, 0x29} }; - - if (IFilterChain *chain = com_cast<IFilterChain>(m_graph, iid_IFilterChain)) { - chain->RemoveChain(decoder, m_videoOutput); - chain->Release(); - } else { - m_graph->RemoveFilter(m_videoOutput); - } - - intermediate->Release(); - decoder->Release(); - - m_executedTasks &= ~SetVideoOutput; - - m_loop->wake(); -} - -void DirectShowPlayerService::customEvent(QEvent *event) -{ - if (event->type() == QEvent::Type(FinalizedLoad)) { - QMutexLocker locker(&m_mutex); - - m_playerControl->updateMediaInfo(m_duration, m_streamTypes, m_seekable); - m_metaDataControl->updateGraph(m_graph, m_source); - - updateStatus(); - } else if (event->type() == QEvent::Type(Error)) { - QMutexLocker locker(&m_mutex); - - if (m_error != QMediaPlayer::NoError) { - m_playerControl->updateError(m_error, m_errorString); - m_playerControl->updateMediaInfo(m_duration, m_streamTypes, m_seekable); - m_playerControl->updateState(QMediaPlayer::StoppedState); - updateStatus(); - } - } else if (event->type() == QEvent::Type(RateChange)) { - QMutexLocker locker(&m_mutex); - - m_playerControl->updatePlaybackRate(m_rate); - } else if (event->type() == QEvent::Type(StatusChange)) { - QMutexLocker locker(&m_mutex); - - updateStatus(); - m_playerControl->updatePosition(m_position); - } else if (event->type() == QEvent::Type(DurationChange)) { - QMutexLocker locker(&m_mutex); - - m_playerControl->updateMediaInfo(m_duration, m_streamTypes, m_seekable); - } else if (event->type() == QEvent::Type(EndOfMedia)) { - QMutexLocker locker(&m_mutex); - - if (m_atEnd) { - m_playerControl->updateState(QMediaPlayer::StoppedState); - m_playerControl->updateStatus(QMediaPlayer::EndOfMedia); - m_playerControl->updatePosition(m_position); - } - } else if (event->type() == QEvent::Type(PositionChange)) { - QMutexLocker locker(&m_mutex); - - m_playerControl->updatePosition(m_position); - } else if (event->type() == QEvent::Type(VideoOutputChange)) { - if (m_videoWindowControl) - m_videoWindowControl->updateNativeSize(); - } else { - QMediaService::customEvent(event); - } -} - -void DirectShowPlayerService::videoOutputChanged() -{ - IBaseFilter *videoOutput = 0; - - switch (m_videoOutputControl->output()) { - case QVideoOutputControl::RendererOutput: - videoOutput = m_videoRendererControl->filter(); - break; - case QVideoOutputControl::WindowOutput: - videoOutput = m_videoWindowControl->filter(); - break; - default: - break; - } - - setVideoOutput(videoOutput); -} - -void DirectShowPlayerService::graphEvent(QMutexLocker *locker) -{ - if (IMediaEvent *event = com_cast<IMediaEvent>(m_graph, IID_IMediaEvent)) { - long eventCode; - LONG_PTR param1; - LONG_PTR param2; - - while (event->GetEvent(&eventCode, ¶m1, ¶m2, 0) == S_OK) { - switch (eventCode) { - case EC_BUFFERING_DATA: - m_buffering = param1; - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(StatusChange))); - break; - case EC_COMPLETE: - m_executedTasks &= ~(Play | Pause); - m_executedTasks |= Stop; - - m_buffering = false; - m_atEnd = true; - - if (IMediaSeeking *seeking = com_cast<IMediaSeeking>(m_graph, IID_IMediaSeeking)) { - LONGLONG position = 0; - - seeking->GetCurrentPosition(&position); - seeking->Release(); - - m_position = position / 10; - } - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(EndOfMedia))); - break; - case EC_LENGTH_CHANGED: - if (IMediaSeeking *seeking = com_cast<IMediaSeeking>(m_graph, IID_IMediaSeeking)) { - LONGLONG duration = 0; - seeking->GetDuration(&duration); - m_duration = duration / 10; - - DWORD capabilities = 0; - seeking->GetCapabilities(&capabilities); - m_seekable = capabilities & AM_SEEKING_CanSeekAbsolute; - - seeking->Release(); - - QCoreApplication::postEvent(this, new QEvent(QEvent::Type(DurationChange))); - } - break; - default: - break; - } - - event->FreeEventParams(eventCode, param1, param2); - } - event->Release(); - } -} - -void DirectShowPlayerService::updateStatus() -{ - switch (m_graphStatus) { - case NoMedia: - m_playerControl->updateStatus(QMediaPlayer::NoMedia); - break; - case Loading: - m_playerControl->updateStatus(QMediaPlayer::LoadingMedia); - break; - case Loaded: - if ((m_pendingTasks | m_executingTask | m_executedTasks) & (Play | Pause)) { - if (m_buffering) - m_playerControl->updateStatus(QMediaPlayer::BufferingMedia); - else - m_playerControl->updateStatus(QMediaPlayer::BufferedMedia); - } else { - m_playerControl->updateStatus(QMediaPlayer::LoadedMedia); - } - break; - case InvalidMedia: - m_playerControl->updateStatus(QMediaPlayer::InvalidMedia); - break; - default: - m_playerControl->updateStatus(QMediaPlayer::UnknownMediaStatus); - } -} - -bool DirectShowPlayerService::isConnected(IBaseFilter *filter, PIN_DIRECTION direction) const -{ - bool connected = false; - - IEnumPins *pins = 0; - - if (SUCCEEDED(filter->EnumPins(&pins))) { - for (IPin *pin = 0; pins->Next(1, &pin, 0) == S_OK; pin->Release()) { - PIN_DIRECTION dir; - if (SUCCEEDED(pin->QueryDirection(&dir)) && dir == direction) { - IPin *peer = 0; - if (SUCCEEDED(pin->ConnectedTo(&peer))) { - connected = true; - - peer->Release(); - } - } - } - pins->Release(); - } - return connected; -} - -IBaseFilter *DirectShowPlayerService::getConnected( - IBaseFilter *filter, PIN_DIRECTION direction) const -{ - IBaseFilter *connected = 0; - - IEnumPins *pins = 0; - - if (SUCCEEDED(filter->EnumPins(&pins))) { - for (IPin *pin = 0; pins->Next(1, &pin, 0) == S_OK; pin->Release()) { - PIN_DIRECTION dir; - if (SUCCEEDED(pin->QueryDirection(&dir)) && dir == direction) { - IPin *peer = 0; - if (SUCCEEDED(pin->ConnectedTo(&peer))) { - PIN_INFO info; - - if (SUCCEEDED(peer->QueryPinInfo(&info))) { - if (connected) { - qWarning("DirectShowPlayerService::getConnected: " - "Multiple connected filters"); - connected->Release(); - } - connected = info.pFilter; - } - peer->Release(); - } - } - } - pins->Release(); - } - return connected; -} - -void DirectShowPlayerService::run() -{ - QMutexLocker locker(&m_mutex); - - for (;;) { - ::ResetEvent(m_taskHandle); - - while (m_pendingTasks == 0) { - DWORD result = 0; - - locker.unlock(); - if (m_eventHandle) { - HANDLE handles[] = { m_taskHandle, m_eventHandle }; - - result = ::WaitForMultipleObjects(2, handles, false, INFINITE); - } else { - result = ::WaitForSingleObject(m_taskHandle, INFINITE); - } - locker.relock(); - - if (result == WAIT_OBJECT_0 + 1) { - graphEvent(&locker); - } - } - - if (m_pendingTasks & ReleaseGraph) { - m_pendingTasks ^= ReleaseGraph; - m_executingTask = ReleaseGraph; - - doReleaseGraph(&locker); - } else if (m_pendingTasks & Shutdown) { - return; - } else if (m_pendingTasks & ReleaseAudioOutput) { - m_pendingTasks ^= ReleaseAudioOutput; - m_executingTask = ReleaseAudioOutput; - - doReleaseAudioOutput(&locker); - } else if (m_pendingTasks & ReleaseVideoOutput) { - m_pendingTasks ^= ReleaseVideoOutput; - m_executingTask = ReleaseVideoOutput; - - doReleaseVideoOutput(&locker); - } else if (m_pendingTasks & SetUrlSource) { - m_pendingTasks ^= SetUrlSource; - m_executingTask = SetUrlSource; - - doSetUrlSource(&locker); - } else if (m_pendingTasks & SetStreamSource) { - m_pendingTasks ^= SetStreamSource; - m_executingTask = SetStreamSource; - - doSetStreamSource(&locker); - } else if (m_pendingTasks & Render) { - m_pendingTasks ^= Render; - m_executingTask = Render; - - doRender(&locker); - } else if (!(m_executedTasks & Render)) { - m_pendingTasks &= ~(FinalizeLoad | SetRate | Stop | Pause | Seek | Play); - } else if (m_pendingTasks & FinalizeLoad) { - m_pendingTasks ^= FinalizeLoad; - m_executingTask = FinalizeLoad; - - doFinalizeLoad(&locker); - } else if (m_pendingTasks & Stop) { - m_pendingTasks ^= Stop; - m_executingTask = Stop; - - doStop(&locker); - } else if (m_pendingTasks & Pause) { - m_pendingTasks ^= Pause; - m_executingTask = Pause; - - doPause(&locker); - } else if (m_pendingTasks & SetRate) { - m_pendingTasks ^= SetRate; - m_executingTask = SetRate; - - doSetRate(&locker); - } else if (m_pendingTasks & Seek) { - m_pendingTasks ^= Seek; - m_executingTask = Seek; - - doSeek(&locker); - } else if (m_pendingTasks & Play) { - m_pendingTasks ^= Play; - m_executingTask = Play; - - doPlay(&locker); - } - m_executingTask = 0; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.h deleted file mode 100644 index a3f94e1..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.h +++ /dev/null @@ -1,220 +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 DIRECTSHOWPLAYERSERVICE_H -#define DIRECTSHOWPLAYERSERVICE_H - -#include <QtMediaServices/qmediaplayer.h> -#include <QtMediaServices/qmediaresource.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmediatimerange.h> - -#include "directshoweventloop.h" -#include "directshowglobal.h" - -#include <QtCore/qcoreevent.h> -#include <QtCore/qmutex.h> -#include <QtCore/qurl.h> -#include <QtCore/qwaitcondition.h> - -#include <QtCore/private/qwineventnotifier_p.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowAudioEndpointControl; -class DirectShowMetaDataControl; -class DirectShowPlayerControl; -class DirectShowVideoOutputControl; -class DirectShowVideoRendererControl; -class Vmr9VideoWindowControl; - -class DirectShowPlayerService : public QMediaService -{ - Q_OBJECT -public: - enum StreamType - { - AudioStream = 0x01, - VideoStream = 0x02 - }; - - DirectShowPlayerService(QObject *parent = 0); - ~DirectShowPlayerService(); - - QMediaControl* control(const char *name) const; - - void load(const QMediaContent &media, QIODevice *stream); - void play(); - void pause(); - void stop(); - - qint64 position() const; - QMediaTimeRange availablePlaybackRanges() const; - - void seek(qint64 position); - void setRate(qreal rate); - - int bufferStatus() const; - - void setAudioOutput(IBaseFilter *filter); - void setVideoOutput(IBaseFilter *filter); - -protected: - void customEvent(QEvent *event); - -private Q_SLOTS: - void videoOutputChanged(); - -private: - void releaseGraph(); - void updateStatus(); - - int findStreamTypes(IBaseFilter *source) const; - int findStreamType(IPin *pin) const; - - bool isConnected(IBaseFilter *filter, PIN_DIRECTION direction) const; - IBaseFilter *getConnected(IBaseFilter *filter, PIN_DIRECTION direction) const; - - void run(); - - void doSetUrlSource(QMutexLocker *locker); - void doSetStreamSource(QMutexLocker *locker); - void doRender(QMutexLocker *locker); - void doFinalizeLoad(QMutexLocker *locker); - void doSetRate(QMutexLocker *locker); - void doSeek(QMutexLocker *locker); - void doPlay(QMutexLocker *locker); - void doPause(QMutexLocker *locker); - void doStop(QMutexLocker *locker); - void doReleaseAudioOutput(QMutexLocker *locker); - void doReleaseVideoOutput(QMutexLocker *locker); - void doReleaseGraph(QMutexLocker *locker); - - void graphEvent(QMutexLocker *locker); - - enum Task - { - Shutdown = 0x0001, - SetUrlSource = 0x0002, - SetStreamSource = 0x0004, - SetSource = SetUrlSource | SetStreamSource, - SetAudioOutput = 0x0008, - SetVideoOutput = 0x0010, - SetOutputs = SetAudioOutput | SetVideoOutput, - Render = 0x0020, - FinalizeLoad = 0x0040, - SetRate = 0x0080, - Seek = 0x0100, - Play = 0x0200, - Pause = 0x0400, - Stop = 0x0800, - ReleaseGraph = 0x1000, - ReleaseAudioOutput = 0x2000, - ReleaseVideoOutput = 0x4000, - ReleaseFilters = ReleaseGraph | ReleaseAudioOutput | ReleaseVideoOutput - }; - - enum Event - { - FinalizedLoad = QEvent::User, - Error, - RateChange, - Started, - Paused, - DurationChange, - StatusChange, - EndOfMedia, - PositionChange, - VideoOutputChange - }; - - enum GraphStatus - { - NoMedia, - Loading, - Loaded, - InvalidMedia - }; - - DirectShowPlayerControl *m_playerControl; - DirectShowMetaDataControl *m_metaDataControl; - DirectShowVideoOutputControl *m_videoOutputControl; - DirectShowVideoRendererControl *m_videoRendererControl; - Vmr9VideoWindowControl *m_videoWindowControl; - DirectShowAudioEndpointControl *m_audioEndpointControl; - - QThread *m_taskThread; - DirectShowEventLoop *m_loop; - int m_pendingTasks; - int m_executingTask; - int m_executedTasks; - HANDLE m_taskHandle; - HANDLE m_eventHandle; - GraphStatus m_graphStatus; - QMediaPlayer::Error m_error; - QIODevice *m_stream; - IFilterGraph2 *m_graph; - IBaseFilter *m_source; - IBaseFilter *m_audioOutput; - IBaseFilter *m_videoOutput; - int m_streamTypes; - qreal m_rate; - qint64 m_position; - qint64 m_duration; - bool m_buffering; - bool m_seekable; - bool m_atEnd; - QMediaTimeRange m_playbackRange; - QUrl m_url; - QMediaResourceList m_resources; - QString m_errorString; - QMutex m_mutex; - - friend class DirectShowPlayerServiceThread; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp deleted file mode 100644 index 23675fb..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp +++ /dev/null @@ -1,403 +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 "directshowsamplescheduler.h" - -#include <QtCore/qcoreevent.h> - - -QT_BEGIN_NAMESPACE - -class DirectShowTimedSample -{ -public: - DirectShowTimedSample(IMediaSample *sample) - : m_next(0) - , m_sample(sample) - , m_cookie(0) - , m_lastSample(false) - { - m_sample->AddRef(); - } - - ~DirectShowTimedSample() - { - m_sample->Release(); - } - - IMediaSample *sample() const { return m_sample; } - - DirectShowTimedSample *nextSample() const { return m_next; } - void setNextSample(DirectShowTimedSample *sample) { Q_ASSERT(!m_next); m_next = sample; } - - DirectShowTimedSample *remove() { - DirectShowTimedSample *next = m_next; delete this; return next; } - - bool schedule(IReferenceClock *clock, REFERENCE_TIME startTime, HANDLE handle); - void unschedule(IReferenceClock *clock); - - bool isReady(IReferenceClock *clock) const; - - bool isLast() const { return m_lastSample; } - void setLast() { m_lastSample = true; } - -private: - DirectShowTimedSample *m_next; - IMediaSample *m_sample; - DWORD_PTR m_cookie; - bool m_lastSample; -}; - -bool DirectShowTimedSample::schedule( - IReferenceClock *clock, REFERENCE_TIME startTime, HANDLE handle) -{ - REFERENCE_TIME sampleStartTime; - REFERENCE_TIME sampleEndTime; - if (m_sample->GetTime(&sampleStartTime, &sampleEndTime) == S_OK) { - if (clock->AdviseTime( - startTime, sampleStartTime, reinterpret_cast<HEVENT>(handle), &m_cookie) == S_OK) { - return true; - } - } - return false; -} - -void DirectShowTimedSample::unschedule(IReferenceClock *clock) -{ - clock->Unadvise(m_cookie); -} - -bool DirectShowTimedSample::isReady(IReferenceClock *clock) const -{ - REFERENCE_TIME sampleStartTime; - REFERENCE_TIME sampleEndTime; - REFERENCE_TIME currentTime; - if (m_sample->GetTime(&sampleStartTime, &sampleEndTime) == S_OK) { - if (clock->GetTime(¤tTime) == S_OK) - return currentTime >= sampleStartTime; - } - return true; -} - -DirectShowSampleScheduler::DirectShowSampleScheduler(IUnknown *pin, QObject *parent) - : QObject(parent) - , m_pin(pin) - , m_clock(0) - , m_allocator(0) - , m_head(0) - , m_tail(0) - , m_maximumSamples(2) - , m_state(Stopped) - , m_startTime(0) - , m_timeoutEvent(::CreateEvent(0, 0, 0, 0)) -{ - m_semaphore.release(m_maximumSamples); - - m_eventNotifier.setHandle(m_timeoutEvent); - m_eventNotifier.setEnabled(true); - - connect(&m_eventNotifier, SIGNAL(activated(HANDLE)), this, SIGNAL(sampleReady())); -} - -DirectShowSampleScheduler::~DirectShowSampleScheduler() -{ - m_eventNotifier.setEnabled(false); - - ::CloseHandle(m_timeoutEvent); - - Q_ASSERT(!m_clock); - Q_ASSERT(!m_allocator); -} - -HRESULT DirectShowSampleScheduler::QueryInterface(REFIID riid, void **ppvObject) -{ - return m_pin->QueryInterface(riid, ppvObject); -} - -ULONG DirectShowSampleScheduler::AddRef() -{ - return m_pin->AddRef(); -} - -ULONG DirectShowSampleScheduler::Release() -{ - return m_pin->Release(); -} - -// IMemInputPin -HRESULT DirectShowSampleScheduler::GetAllocator(IMemAllocator **ppAllocator) -{ - if (!ppAllocator) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - if (!m_allocator) { - return VFW_E_NO_ALLOCATOR; - } else { - *ppAllocator = m_allocator; - - return S_OK; - } - } -} - -HRESULT DirectShowSampleScheduler::NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly) -{ - Q_UNUSED(bReadOnly); - - HRESULT hr; - ALLOCATOR_PROPERTIES properties; - - if (!pAllocator) { - if (m_allocator) - m_allocator->Release(); - - m_allocator = 0; - - return S_OK; - } else if ((hr = pAllocator->GetProperties(&properties)) != S_OK) { - return hr; - } else { - if (properties.cBuffers == 1) { - ALLOCATOR_PROPERTIES actual; - - properties.cBuffers = 2; - if ((hr = pAllocator->SetProperties(&properties, &actual)) != S_OK) - return hr; - } - - QMutexLocker locker(&m_mutex); - - if (m_allocator) - m_allocator->Release(); - - m_allocator = pAllocator; - m_allocator->AddRef(); - - return S_OK; - } -} - -HRESULT DirectShowSampleScheduler::GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps) -{ - if (!pProps) - return E_POINTER; - - pProps->cBuffers = 2; - - return S_OK; -} - -HRESULT DirectShowSampleScheduler::Receive(IMediaSample *pSample) -{ - if (!pSample) - return E_POINTER; - - m_semaphore.acquire(1); - - QMutexLocker locker(&m_mutex); - - if (m_state & Flushing) { - m_semaphore.release(1); - - return S_FALSE; - } else if (m_state == Stopped) { - m_semaphore.release(); - - return VFW_E_WRONG_STATE; - } else { - DirectShowTimedSample *timedSample = new DirectShowTimedSample(pSample); - - if (m_tail) - m_tail->setNextSample(timedSample); - else - m_head = timedSample; - - m_tail = timedSample; - - if (m_state == Running) { - if (!timedSample->schedule(m_clock, m_startTime, m_timeoutEvent)) { - // Timing information is unavailable, so schedule frames immediately. - QMetaObject::invokeMethod(this, "sampleReady", Qt::QueuedConnection); - } - } else if (m_tail == m_head) { - // If this is the first frame make is available. - QMetaObject::invokeMethod(this, "sampleReady", Qt::QueuedConnection); - } - - return S_OK; - } -} - -HRESULT DirectShowSampleScheduler::ReceiveMultiple( - IMediaSample **pSamples, long nSamples, long *nSamplesProcessed) -{ - if (!pSamples || !nSamplesProcessed) - return E_POINTER; - - for (*nSamplesProcessed = 0; *nSamplesProcessed < nSamples; ++(*nSamplesProcessed)) { - HRESULT hr = Receive(pSamples[*nSamplesProcessed]); - - if (hr != S_OK) - return hr; - } - return S_OK; -} - -HRESULT DirectShowSampleScheduler::ReceiveCanBlock() -{ - return S_OK; -} - -void DirectShowSampleScheduler::run(REFERENCE_TIME startTime) -{ - QMutexLocker locker(&m_mutex); - - m_state = (m_state & Flushing) | Running; - m_startTime = startTime; - - for (DirectShowTimedSample *sample = m_head; sample; sample = sample->nextSample()) { - sample->schedule(m_clock, m_startTime, m_timeoutEvent); - } -} - -void DirectShowSampleScheduler::pause() -{ - QMutexLocker locker(&m_mutex); - - m_state = (m_state & Flushing) | Paused; - - for (DirectShowTimedSample *sample = m_head; sample; sample = sample->nextSample()) - sample->unschedule(m_clock); -} - -void DirectShowSampleScheduler::stop() -{ - QMutexLocker locker(&m_mutex); - - m_state = m_state & Flushing; - - for (DirectShowTimedSample *sample = m_head; sample; sample = sample->remove()) { - sample->unschedule(m_clock); - - m_semaphore.release(1); - } - - m_head = 0; - m_tail = 0; -} - -void DirectShowSampleScheduler::setFlushing(bool flushing) -{ - QMutexLocker locker(&m_mutex); - - const bool isFlushing = m_state & Flushing; - - if (isFlushing != flushing) { - if (flushing) { - m_state |= Flushing; - - for (DirectShowTimedSample *sample = m_head; sample; sample = sample->remove()) { - sample->unschedule(m_clock); - - m_semaphore.release(1); - } - m_head = 0; - m_tail = 0; - } else { - m_state &= ~Flushing; - } - } -} - -void DirectShowSampleScheduler::setClock(IReferenceClock *clock) -{ - QMutexLocker locker(&m_mutex); - - if (m_clock) - m_clock->Release(); - - m_clock = clock; - - if (m_clock) - m_clock->AddRef(); -} - -IMediaSample *DirectShowSampleScheduler::takeSample(bool *eos) -{ - QMutexLocker locker(&m_mutex); - - if (m_head && m_head->isReady(m_clock)) { - IMediaSample *sample = m_head->sample(); - sample->AddRef(); - - if (m_state == Running) { - *eos = m_head->isLast(); - - m_head = m_head->remove(); - - if (!m_head) - m_tail = 0; - - m_semaphore.release(1); - } - - return sample; - } else { - return 0; - } -} - -bool DirectShowSampleScheduler::scheduleEndOfStream() -{ - QMutexLocker locker(&m_mutex); - - if (m_tail) { - m_tail->setLast(); - - return true; - } else { - return false; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h deleted file mode 100644 index 21823c3..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h +++ /dev/null @@ -1,126 +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 DIRECTSHOWSAMPLESCHEDULER_H -#define DIRECTSHOWSAMPLESCHEDULER_H - -#include <QtCore/qmutex.h> -#include <QtCore/qobject.h> -#include <QtCore/qsemaphore.h> - -#include <QtCore/private/qwineventnotifier_p.h> - -#include <dshow.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowTimedSample; - -class DirectShowSampleScheduler : public QObject, public IMemInputPin -{ - Q_OBJECT -public: - - enum State - { - Stopped = 0x00, - Running = 0x01, - Paused = 0x02, - RunMask = 0x03, - Flushing = 0x04 - }; - - DirectShowSampleScheduler(IUnknown *pin, QObject *parent = 0); - ~DirectShowSampleScheduler(); - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); - - // IMemInputPin - HRESULT STDMETHODCALLTYPE GetAllocator(IMemAllocator **ppAllocator); - HRESULT STDMETHODCALLTYPE NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly); - HRESULT STDMETHODCALLTYPE GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps); - - HRESULT STDMETHODCALLTYPE Receive(IMediaSample *pSample); - HRESULT STDMETHODCALLTYPE ReceiveMultiple(IMediaSample **pSamples, long nSamples, long *nSamplesProcessed); - HRESULT STDMETHODCALLTYPE ReceiveCanBlock(); - - void run(REFERENCE_TIME startTime); - void pause(); - void stop(); - void setFlushing(bool flushing); - - IReferenceClock *clock() const { return m_clock; } - void setClock(IReferenceClock *clock); - - bool schedule(IMediaSample *sample); - bool scheduleEndOfStream(); - - IMediaSample *takeSample(bool *eos); - -Q_SIGNALS: - void sampleReady(); - -private: - IUnknown *m_pin; - IReferenceClock *m_clock; - IMemAllocator *m_allocator; - DirectShowTimedSample *m_head; - DirectShowTimedSample *m_tail; - int m_maximumSamples; - int m_state; - REFERENCE_TIME m_startTime; - HANDLE m_timeoutEvent; - QSemaphore m_semaphore; - QMutex m_mutex; - QWinEventNotifier m_eventNotifier; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideooutputcontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowvideooutputcontrol.cpp deleted file mode 100644 index ee2bea8..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideooutputcontrol.cpp +++ /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$ -** -****************************************************************************/ - -#include "directshowvideooutputcontrol.h" - - -QT_BEGIN_NAMESPACE - -DirectShowVideoOutputControl::DirectShowVideoOutputControl(QObject *parent) - : QVideoOutputControl(parent) - , m_output(NoOutput) -{ - -} - -DirectShowVideoOutputControl::~DirectShowVideoOutputControl() -{ -} - -QList<QVideoOutputControl::Output> DirectShowVideoOutputControl::availableOutputs() const -{ - return QList<Output>() - << RendererOutput - << WindowOutput; -} - - -QVideoOutputControl::Output DirectShowVideoOutputControl::output() const -{ - return m_output; -} - -void DirectShowVideoOutputControl::setOutput(Output output) -{ - if (output != m_output) { - switch (output) { - case NoOutput: - case RendererOutput: - case WindowOutput: - m_output = output; - emit outputChanged(); - break; - default: - break; - } - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideooutputcontrol.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowvideooutputcontrol.h deleted file mode 100644 index 9b857ce..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideooutputcontrol.h +++ /dev/null @@ -1,75 +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 DIRECTSHOWVIDEOUTPUTCONTROL_H -#define DIRECTSHOWVIDEOOUPUTCONTROL_H - -#include <QtMediaServices/qvideooutputcontrol.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowVideoOutputControl : public QVideoOutputControl -{ - Q_OBJECT -public: - DirectShowVideoOutputControl(QObject *parent = 0); - ~DirectShowVideoOutputControl(); - - QList<Output> availableOutputs() const; - - Output output() const; - void setOutput(Output output); - -Q_SIGNALS: - void outputChanged(); - -private: - Output m_output; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideorenderercontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowvideorenderercontrol.cpp deleted file mode 100644 index f27cb10..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideorenderercontrol.cpp +++ /dev/null @@ -1,93 +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 "directshowvideorenderercontrol.h" - -#include "videosurfacefilter.h" - - -QT_BEGIN_NAMESPACE - - -DirectShowVideoRendererControl::DirectShowVideoRendererControl(DirectShowEventLoop *loop, QObject *parent) - : QVideoRendererControl(parent) - , m_loop(loop) - , m_surface(0) - , m_filter(0) -{ -} - -DirectShowVideoRendererControl::~DirectShowVideoRendererControl() -{ - delete m_filter; -} - -QAbstractVideoSurface *DirectShowVideoRendererControl::surface() const -{ - return m_surface; -} - -void DirectShowVideoRendererControl::setSurface(QAbstractVideoSurface *surface) -{ - if (surface != m_surface) { - m_surface = surface; - - VideoSurfaceFilter *existingFilter = m_filter; - - if (surface) { - m_filter = new VideoSurfaceFilter(surface, m_loop); - } else { - m_filter = 0; - } - - emit filterChanged(); - - delete existingFilter; - } -} - -IBaseFilter *DirectShowVideoRendererControl::filter() -{ - return m_filter; -} - - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideorenderercontrol.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowvideorenderercontrol.h deleted file mode 100644 index adaa0f8..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowvideorenderercontrol.h +++ /dev/null @@ -1,82 +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 DIRECTSHOWVIDEORENDERERCONTROL_H -#define DIRECTSHOWVIDEORENDERERCONTROL_H - -#include <QtMediaServices/qvideorenderercontrol.h> - -#include <dshow.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class DirectShowEventLoop; -class VideoSurfaceFilter; - -class DirectShowVideoRendererControl : public QVideoRendererControl -{ - Q_OBJECT -public: - DirectShowVideoRendererControl(DirectShowEventLoop *loop, QObject *parent = 0); - ~DirectShowVideoRendererControl(); - - QAbstractVideoSurface *surface() const; - void setSurface(QAbstractVideoSurface *surface); - - IBaseFilter *filter(); - -Q_SIGNALS: - void filterChanged(); - -private: - DirectShowEventLoop *m_loop; - QAbstractVideoSurface *m_surface; - VideoSurfaceFilter *m_filter; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/mediaplayer.pri b/src/plugins/mediaservices/directshow/mediaplayer/mediaplayer.pri deleted file mode 100644 index 99a1191..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/mediaplayer.pri +++ /dev/null @@ -1,45 +0,0 @@ -INCLUDEPATH += $$PWD - -DEFINES += QMEDIA_DIRECTSHOW_PLAYER - -!contains(QT_CONFIG, wmsdk): DEFINES += QT_NO_WMSDK - -HEADERS += \ - $$PWD/directshowaudioendpointcontrol.h \ - $$PWD/directshoweventloop.h \ - $$PWD/directshowglobal.h \ - $$PWD/directshowioreader.h \ - $$PWD/directshowiosource.h \ - $$PWD/directshowmediatype.h \ - $$PWD/directshowmediatypelist.h \ - $$PWD/directshowmetadatacontrol.h \ - $$PWD/directshowpinenum.h \ - $$PWD/directshowplayercontrol.h \ - $$PWD/directshowplayerservice.h \ - $$PWD/directshowsamplescheduler.h \ - $$PWD/directshowvideooutputcontrol.h \ - $$PWD/directshowvideorenderercontrol.h \ - $$PWD/mediasamplevideobuffer.h \ - $$PWD/videosurfacefilter.h \ - $$PWD/vmr9videowindowcontrol.h - -SOURCES += \ - $$PWD/directshowaudioendpointcontrol.cpp \ - $$PWD/directshoweventloop.cpp \ - $$PWD/directshowioreader.cpp \ - $$PWD/directshowiosource.cpp \ - $$PWD/directshowmediatype.cpp \ - $$PWD/directshowmediatypelist.cpp \ - $$PWD/directshowmetadatacontrol.cpp \ - $$PWD/directshowpinenum.cpp \ - $$PWD/directshowplayercontrol.cpp \ - $$PWD/directshowplayerservice.cpp \ - $$PWD/directshowsamplescheduler.cpp \ - $$PWD/directshowvideooutputcontrol.cpp \ - $$PWD/directshowvideorenderercontrol.cpp \ - $$PWD/mediasamplevideobuffer.cpp \ - $$PWD/videosurfacefilter.cpp \ - $$PWD/vmr9videowindowcontrol.cpp - -LIBS += -lstrmiids -ldmoguids -luuid -lmsdmo -lole32 -loleaut32 - diff --git a/src/plugins/mediaservices/directshow/mediaplayer/mediasamplevideobuffer.cpp b/src/plugins/mediaservices/directshow/mediaplayer/mediasamplevideobuffer.cpp deleted file mode 100644 index 7eff226..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/mediasamplevideobuffer.cpp +++ /dev/null @@ -1,91 +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 "mediasamplevideobuffer.h" - - -QT_BEGIN_NAMESPACE - -MediaSampleVideoBuffer::MediaSampleVideoBuffer(IMediaSample *sample, int bytesPerLine) - : QAbstractVideoBuffer(NoHandle) - , m_sample(sample) - , m_bytesPerLine(m_bytesPerLine) - , m_mapMode(NotMapped) -{ - m_sample->AddRef(); -} - -MediaSampleVideoBuffer::~MediaSampleVideoBuffer() -{ - m_sample->Release(); -} - -uchar *MediaSampleVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) -{ - if (m_mapMode == NotMapped && mode != NotMapped) { - if (numBytes) - *numBytes = m_sample->GetActualDataLength(); - - if (bytesPerLine) - *bytesPerLine = m_bytesPerLine; - - BYTE *bytes = 0; - - if (m_sample->GetPointer(&bytes) == S_OK) { - m_mapMode = mode; - - return reinterpret_cast<uchar *>(bytes); - } - } - return 0; -} - -void MediaSampleVideoBuffer::unmap() -{ - m_mapMode = NotMapped; -} - -QAbstractVideoBuffer::MapMode MediaSampleVideoBuffer::mapMode() const -{ - return m_mapMode; -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/mediasamplevideobuffer.h b/src/plugins/mediaservices/directshow/mediaplayer/mediasamplevideobuffer.h deleted file mode 100644 index 06dc31c..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/mediasamplevideobuffer.h +++ /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$ -** -****************************************************************************/ - -#ifndef MEDIASAMPLEVIDEOBUFFER_H -#define MEDIASAMPLEVIDEOBUFFER_H - -#include <QtMultimedia/qabstractvideobuffer.h> - -#include <dshow.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class MediaSampleVideoBuffer : public QAbstractVideoBuffer -{ -public: - MediaSampleVideoBuffer(IMediaSample *sample, int bytesPerLine); - ~MediaSampleVideoBuffer(); - - IMediaSample *sample() { return m_sample; } - - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); - void unmap(); - - MapMode mapMode() const; - -private: - IMediaSample *m_sample; - int m_bytesPerLine; - MapMode m_mapMode; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/videosurfacefilter.cpp b/src/plugins/mediaservices/directshow/mediaplayer/videosurfacefilter.cpp deleted file mode 100644 index a471c68..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/videosurfacefilter.cpp +++ /dev/null @@ -1,633 +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 "videosurfacefilter.h" - -#include "directshoweventloop.h" -#include "directshowglobal.h" -#include "directshowpinenum.h" -#include "mediasamplevideobuffer.h" - -#include <QtCore/qcoreapplication.h> -#include <QtCore/qcoreevent.h> -#include <QtCore/qthread.h> -#include <QtMultimedia/qabstractvideosurface.h> - -#include <initguid.h> - - -QT_BEGIN_NAMESPACE - -// { e23cad72-153d-406c-bf3f-4c4b523d96f2 } -DEFINE_GUID(CLSID_VideoSurfaceFilter, -0xe23cad72, 0x153d, 0x406c, 0xbf, 0x3f, 0x4c, 0x4b, 0x52, 0x3d, 0x96, 0xf2); - -VideoSurfaceFilter::VideoSurfaceFilter( - QAbstractVideoSurface *surface, DirectShowEventLoop *loop, QObject *parent) - : QObject(parent) - , m_ref(1) - , m_state(State_Stopped) - , m_surface(surface) - , m_loop(loop) - , m_graph(0) - , m_peerPin(0) - , m_bytesPerLine(0) - , m_startResult(S_OK) - , m_pinId(QString::fromLatin1("reference")) - , m_sampleScheduler(static_cast<IPin *>(this)) -{ - connect(surface, SIGNAL(supportedFormatsChanged()), this, SLOT(supportedFormatsChanged())); - connect(&m_sampleScheduler, SIGNAL(sampleReady()), this, SLOT(sampleReady())); -} - -VideoSurfaceFilter::~VideoSurfaceFilter() -{ - Q_ASSERT(m_ref == 1); -} - -HRESULT VideoSurfaceFilter::QueryInterface(REFIID riid, void **ppvObject) -{ - // 2dd74950-a890-11d1-abe8-00a0c905f375 - static const GUID iid_IAmFilterMiscFlags = { - 0x2dd74950, 0xa890, 0x11d1, {0xab, 0xe8, 0x00, 0xa0, 0xc9, 0x05, 0xf3, 0x75} }; - - if (!ppvObject) { - return E_POINTER; - } else if (riid == IID_IUnknown - || riid == IID_IPersist - || riid == IID_IMediaFilter - || riid == IID_IBaseFilter) { - *ppvObject = static_cast<IBaseFilter *>(this); - } else if (riid == iid_IAmFilterMiscFlags) { - *ppvObject = static_cast<IAMFilterMiscFlags *>(this); - } else if (riid == IID_IPin) { - *ppvObject = static_cast<IPin *>(this); - } else if (riid == IID_IMemInputPin) { - *ppvObject = static_cast<IMemInputPin *>(&m_sampleScheduler); - } else { - *ppvObject = 0; - - return E_NOINTERFACE; - } - - AddRef(); - - return S_OK; -} - -ULONG VideoSurfaceFilter::AddRef() -{ - return InterlockedIncrement(&m_ref); -} - -ULONG VideoSurfaceFilter::Release() -{ - ULONG ref = InterlockedDecrement(&m_ref); - - Q_ASSERT(ref != 0); - - return ref; -} - -HRESULT VideoSurfaceFilter::GetClassID(CLSID *pClassID) -{ - *pClassID = CLSID_VideoSurfaceFilter; - - return S_OK; -} - -HRESULT VideoSurfaceFilter::Run(REFERENCE_TIME tStart) -{ - m_state = State_Running; - - m_sampleScheduler.run(tStart); - - return S_OK; -} - -HRESULT VideoSurfaceFilter::Pause() -{ - m_state = State_Paused; - - m_sampleScheduler.pause(); - - return S_OK; -} - -HRESULT VideoSurfaceFilter::Stop() -{ - m_state = State_Stopped; - - m_sampleScheduler.stop(); - - return S_OK; -} - -HRESULT VideoSurfaceFilter::GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *pState) -{ - if (!pState) - return E_POINTER; - - *pState = m_state; - - return S_OK; -} - -HRESULT VideoSurfaceFilter::SetSyncSource(IReferenceClock *pClock) -{ - - m_sampleScheduler.setClock(pClock); - - return S_OK; -} - -HRESULT VideoSurfaceFilter::GetSyncSource(IReferenceClock **ppClock) -{ - if (!ppClock) { - return E_POINTER; - } else { - *ppClock = m_sampleScheduler.clock(); - - if (*ppClock) { - (*ppClock)->AddRef(); - - return S_OK; - } else { - return S_FALSE; - } - } -} - -HRESULT VideoSurfaceFilter::EnumPins(IEnumPins **ppEnum) -{ - if (ppEnum) { - *ppEnum = new DirectShowPinEnum(QList<IPin *>() << this); - - return S_OK; - } else { - return E_POINTER; - } -} - -HRESULT VideoSurfaceFilter::FindPin(LPCWSTR pId, IPin **ppPin) -{ - if (!ppPin || !pId) { - return E_POINTER; - } else if (QString::fromWCharArray(pId) == m_pinId) { - AddRef(); - - *ppPin = this; - - return S_OK; - } else { - return VFW_E_NOT_FOUND; - } -} - -HRESULT VideoSurfaceFilter::JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName) -{ - m_graph = pGraph; - m_name = QString::fromWCharArray(pName); - - return S_OK; -} - -HRESULT VideoSurfaceFilter::QueryFilterInfo(FILTER_INFO *pInfo) -{ - if (pInfo) { - QString name = m_name; - - if (name.length() >= MAX_FILTER_NAME) - name.truncate(MAX_FILTER_NAME - 1); - - int length = name.toWCharArray(pInfo->achName); - pInfo->achName[length] = '\0'; - - if (m_graph) - m_graph->AddRef(); - - pInfo->pGraph = m_graph; - - return S_OK; - } else { - return E_POINTER; - } -} - -HRESULT VideoSurfaceFilter::QueryVendorInfo(LPWSTR *pVendorInfo) -{ - Q_UNUSED(pVendorInfo); - - return E_NOTIMPL; -} - -ULONG VideoSurfaceFilter::GetMiscFlags() -{ - return AM_FILTER_MISC_FLAGS_IS_RENDERER; -} - - -HRESULT VideoSurfaceFilter::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) -{ - // This is an input pin, you shouldn't be calling Connect on it. - return E_POINTER; -} - -HRESULT VideoSurfaceFilter::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt) -{ - if (!pConnector) { - return E_POINTER; - } else if (!pmt) { - return E_POINTER; - } else { - HRESULT hr; - QMutexLocker locker(&m_mutex); - - if (m_peerPin) { - hr = VFW_E_ALREADY_CONNECTED; - } else if (pmt->majortype != MEDIATYPE_Video) { - hr = VFW_E_TYPE_NOT_ACCEPTED; - } else { - m_surfaceFormat = DirectShowMediaType::formatFromType(*pmt); - m_bytesPerLine = DirectShowMediaType::bytesPerLine(m_surfaceFormat); - - if (thread() == QThread::currentThread()) { - hr = start(); - } else { - m_loop->postEvent(this, new QEvent(QEvent::Type(StartSurface))); - - m_wait.wait(&m_mutex); - - hr = m_startResult; - } - } - if (hr == S_OK) { - m_peerPin = pConnector; - m_peerPin->AddRef(); - - DirectShowMediaType::copy(&m_mediaType, *pmt); - } - return hr; - } -} - -HRESULT VideoSurfaceFilter::start() -{ - if (!m_surface->start(m_surfaceFormat)) { - return VFW_E_TYPE_NOT_ACCEPTED; - } else { - return S_OK; - } -} - -HRESULT VideoSurfaceFilter::Disconnect() -{ - QMutexLocker locker(&m_mutex); - - if (!m_peerPin) - return S_FALSE; - - if (thread() == QThread::currentThread()) { - stop(); - } else { - m_loop->postEvent(this, new QEvent(QEvent::Type(StopSurface))); - - m_wait.wait(&m_mutex); - } - - m_mediaType.clear(); - - m_sampleScheduler.NotifyAllocator(0, FALSE); - - m_peerPin->Release(); - m_peerPin = 0; - - return S_OK; -} - -void VideoSurfaceFilter::stop() -{ - m_surface->stop(); -} - -HRESULT VideoSurfaceFilter::ConnectedTo(IPin **ppPin) -{ - if (!ppPin) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - if (!m_peerPin) { - return VFW_E_NOT_CONNECTED; - } else { - m_peerPin->AddRef(); - - *ppPin = m_peerPin; - - return S_OK; - } - } -} - -HRESULT VideoSurfaceFilter::ConnectionMediaType(AM_MEDIA_TYPE *pmt) -{ - if (!pmt) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - if (!m_peerPin) { - return VFW_E_NOT_CONNECTED; - } else { - DirectShowMediaType::copy(pmt, m_mediaType); - - return S_OK; - } - } -} - -HRESULT VideoSurfaceFilter::QueryPinInfo(PIN_INFO *pInfo) -{ - if (!pInfo) { - return E_POINTER; - } else { - AddRef(); - - pInfo->pFilter = this; - pInfo->dir = PINDIR_INPUT; - - const int bytes = qMin(MAX_FILTER_NAME, (m_pinId.length() + 1) * 2); - - qMemCopy(pInfo->achName, m_pinId.utf16(), bytes); - - return S_OK; - } -} - -HRESULT VideoSurfaceFilter::QueryId(LPWSTR *Id) -{ - if (!Id) { - return E_POINTER; - } else { - const int bytes = (m_pinId.length() + 1) * 2; - - *Id = static_cast<LPWSTR>(::CoTaskMemAlloc(bytes)); - - qMemCopy(*Id, m_pinId.utf16(), bytes); - - return S_OK; - } -} - -HRESULT VideoSurfaceFilter::QueryAccept(const AM_MEDIA_TYPE *pmt) -{ - return !m_surface->isFormatSupported(DirectShowMediaType::formatFromType(*pmt)) - ? S_OK - : S_FALSE; -} - -HRESULT VideoSurfaceFilter::EnumMediaTypes(IEnumMediaTypes **ppEnum) -{ - if (!ppEnum) { - return E_POINTER; - } else { - QMutexLocker locker(&m_mutex); - - *ppEnum = createMediaTypeEnum(); - - return S_OK; - } -} - -HRESULT VideoSurfaceFilter::QueryInternalConnections(IPin **apPin, ULONG *nPin) -{ - Q_UNUSED(apPin); - Q_UNUSED(nPin); - - return E_NOTIMPL; -} - -HRESULT VideoSurfaceFilter::EndOfStream() -{ - QMutexLocker locker(&m_mutex); - - if (!m_sampleScheduler.scheduleEndOfStream()) { - if (IMediaEventSink *sink = com_cast<IMediaEventSink>(m_graph, IID_IMediaEventSink)) { - sink->Notify( - EC_COMPLETE, - S_OK, - reinterpret_cast<LONG_PTR>(static_cast<IBaseFilter *>(this))); - sink->Release(); - } - } - - return S_OK; -} - -HRESULT VideoSurfaceFilter::BeginFlush() -{ - QMutexLocker locker(&m_mutex); - - m_sampleScheduler.setFlushing(true); - - if (thread() == QThread::currentThread()) { - flush(); - } else { - m_loop->postEvent(this, new QEvent(QEvent::Type(FlushSurface))); - - m_wait.wait(&m_mutex); - } - - return S_OK; -} - -HRESULT VideoSurfaceFilter::EndFlush() -{ - QMutexLocker locker(&m_mutex); - - m_sampleScheduler.setFlushing(false); - - return S_OK; -} - -void VideoSurfaceFilter::flush() -{ - m_surface->present(QVideoFrame()); - - m_wait.wakeAll(); -} - -HRESULT VideoSurfaceFilter::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) -{ - Q_UNUSED(tStart); - Q_UNUSED(tStop); - Q_UNUSED(dRate); - - return S_OK; -} - -HRESULT VideoSurfaceFilter::QueryDirection(PIN_DIRECTION *pPinDir) -{ - if (!pPinDir) { - return E_POINTER; - } else { - *pPinDir = PINDIR_INPUT; - - return S_OK; - } -} - -int VideoSurfaceFilter::currentMediaTypeToken() -{ - QMutexLocker locker(&m_mutex); - - return DirectShowMediaTypeList::currentMediaTypeToken(); -} - -HRESULT VideoSurfaceFilter::nextMediaType( - int token, int *index, ULONG count, AM_MEDIA_TYPE **types, ULONG *fetchedCount) -{ - QMutexLocker locker(&m_mutex); - - return DirectShowMediaTypeList::nextMediaType(token, index, count, types, fetchedCount); - -} - -HRESULT VideoSurfaceFilter::skipMediaType(int token, int *index, ULONG count) -{ - QMutexLocker locker(&m_mutex); - - return DirectShowMediaTypeList::skipMediaType(token, index, count); -} - -HRESULT VideoSurfaceFilter::cloneMediaType(int token, int index, IEnumMediaTypes **enumeration) -{ - QMutexLocker locker(&m_mutex); - - return DirectShowMediaTypeList::cloneMediaType(token, index, enumeration); -} - -void VideoSurfaceFilter::customEvent(QEvent *event) -{ - if (event->type() == StartSurface) { - QMutexLocker locker(&m_mutex); - - m_startResult = start(); - - m_wait.wakeAll(); - } else if (event->type() == StopSurface) { - QMutexLocker locker(&m_mutex); - - stop(); - - m_wait.wakeAll(); - } else if (event->type() == FlushSurface) { - QMutexLocker locker(&m_mutex); - - flush(); - - m_wait.wakeAll(); - } else { - QObject::customEvent(event); - } -} - -void VideoSurfaceFilter::supportedFormatsChanged() -{ - QMutexLocker locker(&m_mutex); - - // MEDIASUBTYPE_None; - static const GUID none = { - 0xe436eb8e, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70} }; - - QList<QVideoFrame::PixelFormat> formats = m_surface->supportedPixelFormats(); - - QVector<AM_MEDIA_TYPE> mediaTypes; - mediaTypes.reserve(formats.count()); - - AM_MEDIA_TYPE type; - type.majortype = MEDIATYPE_Video; - type.bFixedSizeSamples = TRUE; - type.bTemporalCompression = FALSE; - type.lSampleSize = 0; - type.formattype = GUID_NULL; - type.pUnk = 0; - type.cbFormat = 0; - type.pbFormat = 0; - - foreach (QVideoFrame::PixelFormat format, formats) { - type.subtype = DirectShowMediaType::convertPixelFormat(format); - - if (type.subtype != none) - mediaTypes.append(type); - } - - setMediaTypes(mediaTypes); -} - -void VideoSurfaceFilter::sampleReady() -{ - bool eos = false; - - IMediaSample *sample = m_sampleScheduler.takeSample(&eos); - - if (sample) { - m_surface->present(QVideoFrame( - new MediaSampleVideoBuffer(sample, m_bytesPerLine), - m_surfaceFormat.frameSize(), - m_surfaceFormat.pixelFormat())); - - sample->Release(); - - if (eos) { - if (IMediaEventSink *sink = com_cast<IMediaEventSink>(m_graph, IID_IMediaEventSink)) { - sink->Notify( - EC_COMPLETE, - S_OK, - reinterpret_cast<LONG_PTR>(static_cast<IBaseFilter *>(this))); - sink->Release(); - } - } - } -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/directshow/mediaplayer/videosurfacefilter.h b/src/plugins/mediaservices/directshow/mediaplayer/videosurfacefilter.h deleted file mode 100644 index 0607fd3..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/videosurfacefilter.h +++ /dev/null @@ -1,180 +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 VIDEOSURFACEFILTER_H -#define VIDEOSURFACEFILTER_H - -#include "directshowglobal.h" -#include "directshowmediatypelist.h" -#include "directshowsamplescheduler.h" -#include "directshowmediatype.h" - -#include <QtCore/qbasictimer.h> -#include <QtCore/qcoreevent.h> -#include <QtCore/qmutex.h> -#include <QtCore/qsemaphore.h> -#include <QtCore/qstring.h> -#include <QtCore/qwaitcondition.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QAbstractVideoSurface; - -class DirectShowEventLoop; - -class VideoSurfaceFilter - : public QObject - , public DirectShowMediaTypeList - , public IBaseFilter - , public IAMFilterMiscFlags - , public IPin -{ - Q_OBJECT -public: - VideoSurfaceFilter( - QAbstractVideoSurface *surface, DirectShowEventLoop *loop, QObject *parent = 0); - ~VideoSurfaceFilter(); - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); - - // IPersist - HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID); - - // IMediaFilter - HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart); - HRESULT STDMETHODCALLTYPE Pause(); - HRESULT STDMETHODCALLTYPE Stop(); - - HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *pState); - - HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock); - HRESULT STDMETHODCALLTYPE GetSyncSource(IReferenceClock **ppClock); - - // IBaseFilter - HRESULT STDMETHODCALLTYPE EnumPins(IEnumPins **ppEnum); - HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, IPin **ppPin); - - HRESULT STDMETHODCALLTYPE JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName); - - HRESULT STDMETHODCALLTYPE QueryFilterInfo(FILTER_INFO *pInfo); - HRESULT STDMETHODCALLTYPE QueryVendorInfo(LPWSTR *pVendorInfo); - - // IAMFilterMiscFlags - ULONG STDMETHODCALLTYPE GetMiscFlags(); - - // IPin - HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt); - HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt); - HRESULT STDMETHODCALLTYPE Disconnect(); - HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **ppPin); - - HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt); - - HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo); - HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id); - - HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt); - - HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum); - - HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin); - - HRESULT STDMETHODCALLTYPE EndOfStream(); - - HRESULT STDMETHODCALLTYPE BeginFlush(); - HRESULT STDMETHODCALLTYPE EndFlush(); - - HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); - - HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir); - - int currentMediaTypeToken(); - HRESULT nextMediaType( - int token, int *index, ULONG count, AM_MEDIA_TYPE **types, ULONG *fetchedCount); - HRESULT skipMediaType(int token, int *index, ULONG count); - HRESULT cloneMediaType(int token, int index, IEnumMediaTypes **enumeration); - -protected: - void customEvent(QEvent *event); - -private Q_SLOTS: - void supportedFormatsChanged(); - void sampleReady(); - -private: - HRESULT start(); - void stop(); - void flush(); - - enum - { - StartSurface = QEvent::User, - StopSurface, - FlushSurface - }; - - LONG m_ref; - FILTER_STATE m_state; - QAbstractVideoSurface *m_surface; - DirectShowEventLoop *m_loop; - IFilterGraph *m_graph; - IPin *m_peerPin; - int m_bytesPerLine; - HRESULT m_startResult; - QString m_name; - QString m_pinId; - DirectShowMediaType m_mediaType; - QVideoSurfaceFormat m_surfaceFormat; - QMutex m_mutex; - QWaitCondition m_wait; - DirectShowSampleScheduler m_sampleScheduler; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp deleted file mode 100644 index 1c6df2c..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp +++ /dev/null @@ -1,317 +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 "vmr9videowindowcontrol.h" - -#include "directshowglobal.h" - - -QT_BEGIN_NAMESPACE - -Vmr9VideoWindowControl::Vmr9VideoWindowControl(QObject *parent) - : QVideoWindowControl(parent) - , m_filter(com_new<IBaseFilter>(CLSID_VideoMixingRenderer9, IID_IBaseFilter)) - , m_windowId(0) - , m_dirtyValues(0) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_brightness(0) - , m_contrast(0) - , m_hue(0) - , m_saturation(0) - , m_fullScreen(false) -{ - if (IVMRFilterConfig9 *config = com_cast<IVMRFilterConfig9>(m_filter, IID_IVMRFilterConfig9)) { - config->SetRenderingMode(VMR9Mode_Windowless); - config->SetNumberOfStreams(1); - config->SetRenderingPrefs(RenderPrefs9_DoNotRenderBorder); - config->Release(); - } -} - -Vmr9VideoWindowControl::~Vmr9VideoWindowControl() -{ - if (m_filter) - m_filter->Release(); -} - - -WId Vmr9VideoWindowControl::winId() const -{ - return m_windowId; - -} - -void Vmr9VideoWindowControl::setWinId(WId id) -{ - m_windowId = id; - - if (IVMRWindowlessControl9 *control = com_cast<IVMRWindowlessControl9>( - m_filter, IID_IVMRWindowlessControl9)) { - control->SetVideoClippingWindow(m_windowId); - control->Release(); - } -} - -QRect Vmr9VideoWindowControl::displayRect() const -{ - return m_displayRect; -} - -void Vmr9VideoWindowControl::setDisplayRect(const QRect &rect) -{ - m_displayRect = rect; - - if (IVMRWindowlessControl9 *control = com_cast<IVMRWindowlessControl9>( - m_filter, IID_IVMRWindowlessControl9)) { - RECT sourceRect = { 0, 0, 0, 0 }; - RECT displayRect = { rect.left(), rect.top(), rect.right(), rect.bottom() }; - - control->GetNativeVideoSize(&sourceRect.right, &sourceRect.bottom, 0, 0); - - if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) { - QSize clippedSize = rect.size(); - clippedSize.scale(sourceRect.right, sourceRect.bottom, Qt::KeepAspectRatio); - - sourceRect.left = (sourceRect.right - clippedSize.width()) / 2; - sourceRect.top = (sourceRect.bottom - clippedSize.height()) / 2; - sourceRect.right = sourceRect.left + clippedSize.width(); - sourceRect.bottom = sourceRect.top + clippedSize.height(); - } - - control->SetVideoPosition(&sourceRect, &displayRect); - control->Release(); - } -} - -bool Vmr9VideoWindowControl::isFullScreen() const -{ - return m_fullScreen; -} - -void Vmr9VideoWindowControl::setFullScreen(bool fullScreen) -{ - emit fullScreenChanged(m_fullScreen = fullScreen); -} - -void Vmr9VideoWindowControl::repaint() -{ - if (QWidget *widget = QWidget::find(m_windowId)) { - HDC dc = widget->getDC(); - if (IVMRWindowlessControl9 *control = com_cast<IVMRWindowlessControl9>( - m_filter, IID_IVMRWindowlessControl9)) { - control->RepaintVideo(m_windowId, dc); - control->Release(); - } - widget->releaseDC(dc); - } -} - -QSize Vmr9VideoWindowControl::nativeSize() const -{ - QSize size; - - if (IVMRWindowlessControl9 *control = com_cast<IVMRWindowlessControl9>( - m_filter, IID_IVMRWindowlessControl9)) { - LONG width; - LONG height; - - if (control->GetNativeVideoSize(&width, &height, 0, 0) == S_OK) - size = QSize(width, height); - control->Release(); - } - return size; -} - -Qt::AspectRatioMode Vmr9VideoWindowControl::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void Vmr9VideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_aspectRatioMode = mode; - - if (IVMRWindowlessControl9 *control = com_cast<IVMRWindowlessControl9>( - m_filter, IID_IVMRWindowlessControl9)) { - switch (mode) { - case Qt::IgnoreAspectRatio: - control->SetAspectRatioMode(VMR9ARMode_None); - break; - case Qt::KeepAspectRatio: - control->SetAspectRatioMode(VMR9ARMode_LetterBox); - break; - case Qt::KeepAspectRatioByExpanding: - control->SetAspectRatioMode(VMR9ARMode_LetterBox); - break; - default: - break; - } - control->Release(); - - setDisplayRect(m_displayRect); - } -} - -int Vmr9VideoWindowControl::brightness() const -{ - return m_brightness; -} - -void Vmr9VideoWindowControl::setBrightness(int brightness) -{ - m_brightness = brightness; - - m_dirtyValues |= ProcAmpControl9_Brightness; - - setProcAmpValues(); - - emit brightnessChanged(brightness); -} - -int Vmr9VideoWindowControl::contrast() const -{ - return m_contrast; -} - -void Vmr9VideoWindowControl::setContrast(int contrast) -{ - m_contrast = contrast; - - m_dirtyValues |= ProcAmpControl9_Contrast; - - setProcAmpValues(); - - emit contrastChanged(contrast); -} - -int Vmr9VideoWindowControl::hue() const -{ - return m_hue; -} - -void Vmr9VideoWindowControl::setHue(int hue) -{ - m_hue = hue; - - m_dirtyValues |= ProcAmpControl9_Hue; - - setProcAmpValues(); - - emit hueChanged(hue); -} - -int Vmr9VideoWindowControl::saturation() const -{ - return m_saturation; -} - -void Vmr9VideoWindowControl::setSaturation(int saturation) -{ - m_saturation = saturation; - - m_dirtyValues |= ProcAmpControl9_Saturation; - - setProcAmpValues(); - - emit saturationChanged(saturation); -} - -void Vmr9VideoWindowControl::updateNativeSize() -{ - setDisplayRect(m_displayRect); - - emit nativeSizeChanged(); -} - -void Vmr9VideoWindowControl::setProcAmpValues() -{ - if (IVMRMixerControl9 *control = com_cast<IVMRMixerControl9>(m_filter, IID_IVMRMixerControl9)) { - VMR9ProcAmpControl procAmp; - procAmp.dwSize = sizeof(VMR9ProcAmpControl); - procAmp.dwFlags = m_dirtyValues; - - if (m_dirtyValues & ProcAmpControl9_Brightness) { - procAmp.Brightness = scaleProcAmpValue( - control, ProcAmpControl9_Brightness, m_brightness); - } - if (m_dirtyValues & ProcAmpControl9_Contrast) { - procAmp.Contrast = scaleProcAmpValue( - control, ProcAmpControl9_Contrast, m_contrast); - } - if (m_dirtyValues & ProcAmpControl9_Hue) { - procAmp.Hue = scaleProcAmpValue( - control, ProcAmpControl9_Hue, m_hue); - } - if (m_dirtyValues & ProcAmpControl9_Saturation) { - procAmp.Saturation = scaleProcAmpValue( - control, ProcAmpControl9_Saturation, m_saturation); - } - - if (SUCCEEDED(control->SetProcAmpControl(0, &procAmp))) { - m_dirtyValues = 0; - } - - control->Release(); - } -} - -float Vmr9VideoWindowControl::scaleProcAmpValue( - IVMRMixerControl9 *control, VMR9ProcAmpControlFlags property, int value) const -{ - float scaledValue = 0.0; - - VMR9ProcAmpControlRange range; - range.dwSize = sizeof(VMR9ProcAmpControlRange); - range.dwProperty = property; - - if (SUCCEEDED(control->GetProcAmpControlRange(0, &range))) { - scaledValue = range.DefaultValue; - if (value > 0) - scaledValue += float(value) * (range.MaxValue - range.DefaultValue) / 100; - else if (value < 0) - scaledValue -= float(value) * (range.MinValue - range.DefaultValue) / 100; - } - - return scaledValue; -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.h b/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.h deleted file mode 100644 index 702dfd6..0000000 --- a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.h +++ /dev/null @@ -1,116 +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 VMR9VIDEOWINDOWCONTROL_H -#define VMR9VIDEOWINDOWCONTROL_H - -#include <QtMediaServices/qvideowindowcontrol.h> - -#include <dshow.h> -#include <d3d9.h> -#include <vmr9.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class Vmr9VideoWindowControl : public QVideoWindowControl -{ - Q_OBJECT -public: - Vmr9VideoWindowControl(QObject *parent = 0); - ~Vmr9VideoWindowControl(); - - IBaseFilter *filter() const { return m_filter; } - - WId winId() const; - void setWinId(WId id); - - QRect displayRect() const; - void setDisplayRect(const QRect &rect); - - bool isFullScreen() const; - void setFullScreen(bool fullScreen); - - void repaint(); - - QSize nativeSize() const; - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - 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 updateNativeSize(); - -private: - void setProcAmpValues(); - float scaleProcAmpValue( - IVMRMixerControl9 *control, VMR9ProcAmpControlFlags property, int value) const; - - IBaseFilter *m_filter; - WId m_windowId; - DWORD m_dirtyValues; - Qt::AspectRatioMode m_aspectRatioMode; - QRect m_displayRect; - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; - bool m_fullScreen; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif 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 diff --git a/src/plugins/mediaservices/mediaservices.pro b/src/plugins/mediaservices/mediaservices.pro deleted file mode 100644 index 0f0b021..0000000 --- a/src/plugins/mediaservices/mediaservices.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = subdirs - -contains(QT_CONFIG, media-backend) { - win32:!wince*: SUBDIRS += directshow - - mac: SUBDIRS += qt7 - - unix:!mac:!symbian:contains(QT_CONFIG, gstreamer) { - SUBDIRS += gstreamer - } - - symbian:contains(QT_CONFIG, audio-routing-available) { - SUBDIRS += symbian - } -} diff --git a/src/plugins/mediaservices/qt7/mediaplayer/mediaplayer.pri b/src/plugins/mediaservices/qt7/mediaplayer/mediaplayer.pri deleted file mode 100644 index 577209e..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/mediaplayer.pri +++ /dev/null @@ -1,18 +0,0 @@ -INCLUDEPATH += $$PWD - -DEFINES += QMEDIA_QT7_PLAYER - -HEADERS += \ - $$PWD/qt7playercontrol.h \ - $$PWD/qt7playermetadata.h \ - $$PWD/qt7playerservice.h \ - $$PWD/qt7playersession.h - -OBJECTIVE_SOURCES += \ - $$PWD/qt7playercontrol.mm \ - $$PWD/qt7playermetadata.mm \ - $$PWD/qt7playerservice.mm \ - $$PWD/qt7playersession.mm - - - diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.h b/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.h deleted file mode 100644 index 5ac97b1..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.h +++ /dev/null @@ -1,128 +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 QT7PLAYERCONTROL_H -#define QT7PLAYERCONTROL_H - -#include <QtCore/qobject.h> -#include <QtGui/qmacdefines_mac.h> - -#include <QtMediaServices/qmediaplayercontrol.h> -#include <QtMediaServices/qmediaplayer.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QT7PlayerSession; -class QT7PlayerService; -class QMediaPlaylist; -class QMediaPlaylistNavigator; - -class QT7PlayerControl : public QMediaPlayerControl -{ -Q_OBJECT -public: - QT7PlayerControl(QObject *parent = 0); - ~QT7PlayerControl(); - - void setSession(QT7PlayerSession *session); - - QMediaPlayer::State state() const; - QMediaPlayer::MediaStatus mediaStatus() const; - - QMediaContent media() const; - const QIODevice *mediaStream() const; - void setMedia(const QMediaContent &content, QIODevice *stream); - - qint64 position() const; - qint64 duration() const; - - int bufferStatus() const; - - int volume() const; - bool isMuted() const; - - bool isAudioAvailable() const; - bool isVideoAvailable() const; - - bool isSeekable() const; - - QMediaTimeRange availablePlaybackRanges() const; - - qreal playbackRate() const; - void setPlaybackRate(qreal rate); - -public Q_SLOTS: - void setPosition(qint64 pos); - - void play(); - void pause(); - void stop(); - - void setVolume(int volume); - void setMuted(bool muted); - -Q_SIGNALS: - void mediaChanged(const QMediaContent& content); - void durationChanged(qint64 duration); - void positionChanged(qint64 position); - void stateChanged(QMediaPlayer::State newState); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void videoAvailableChanged(bool videoAvailable); - void bufferStatusChanged(int percentFilled); - void seekableChanged(bool); - void seekRangeChanged(const QPair<qint64,qint64>&); - void playbackRateChanged(qreal rate); - void error(int error, const QString &errorString); - -private: - QT7PlayerSession *m_session; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.mm deleted file mode 100644 index ba22552..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playercontrol.mm +++ /dev/null @@ -1,193 +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 "qt7playercontrol.h" -#include "qt7playersession.h" - -#include <QtMediaServices/qmediaplaylistnavigator.h> - -#include <QtCore/qurl.h> -#include <QtCore/qdebug.h> - - -QT_BEGIN_NAMESPACE - -QT7PlayerControl::QT7PlayerControl(QObject *parent) - : QMediaPlayerControl(parent) -{ -} - -QT7PlayerControl::~QT7PlayerControl() -{ -} - -void QT7PlayerControl::setSession(QT7PlayerSession *session) -{ - m_session = session; - - connect(m_session, SIGNAL(positionChanged(qint64)), this, SIGNAL(positionChanged(qint64))); - connect(m_session, SIGNAL(durationChanged(qint64)), this, SIGNAL(durationChanged(qint64))); - connect(m_session, SIGNAL(stateChanged(QMediaPlayer::State)), - this, SIGNAL(stateChanged(QMediaPlayer::State))); - connect(m_session, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), - this, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - connect(m_session, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int))); - connect(m_session, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool))); - connect(m_session, SIGNAL(audioAvailableChanged(bool)), this, SIGNAL(audioAvailableChanged(bool))); - connect(m_session, SIGNAL(videoAvailableChanged(bool)), this, SIGNAL(videoAvailableChanged(bool))); - connect(m_session, SIGNAL(error(int,QString)), this, SIGNAL(error(int,QString))); -} - -qint64 QT7PlayerControl::position() const -{ - return m_session->position(); -} - -qint64 QT7PlayerControl::duration() const -{ - return m_session->duration(); -} - -QMediaPlayer::State QT7PlayerControl::state() const -{ - return m_session->state(); -} - -QMediaPlayer::MediaStatus QT7PlayerControl::mediaStatus() const -{ - return m_session->mediaStatus(); -} - -int QT7PlayerControl::bufferStatus() const -{ - return m_session->bufferStatus(); -} - -int QT7PlayerControl::volume() const -{ - return m_session->volume(); -} - -bool QT7PlayerControl::isMuted() const -{ - return m_session->isMuted(); -} - -bool QT7PlayerControl::isSeekable() const -{ - return m_session->isSeekable(); -} - -QMediaTimeRange QT7PlayerControl::availablePlaybackRanges() const -{ - return isSeekable() ? QMediaTimeRange(0, duration()) : QMediaTimeRange(); -} - -qreal QT7PlayerControl::playbackRate() const -{ - return m_session->playbackRate(); -} - -void QT7PlayerControl::setPlaybackRate(qreal rate) -{ - m_session->setPlaybackRate(rate); -} - -void QT7PlayerControl::setPosition(qint64 pos) -{ - m_session->setPosition(pos); -} - -void QT7PlayerControl::play() -{ - m_session->play(); -} - -void QT7PlayerControl::pause() -{ - m_session->pause(); -} - -void QT7PlayerControl::stop() -{ - m_session->stop(); -} - -void QT7PlayerControl::setVolume(int volume) -{ - m_session->setVolume(volume); -} - -void QT7PlayerControl::setMuted(bool muted) -{ - m_session->setMuted(muted); -} - -QMediaContent QT7PlayerControl::media() const -{ - return m_session->media(); -} - -const QIODevice *QT7PlayerControl::mediaStream() const -{ - return m_session->mediaStream(); -} - -void QT7PlayerControl::setMedia(const QMediaContent &content, QIODevice *stream) -{ - m_session->setMedia(content, stream); - - emit mediaChanged(content); -} - -bool QT7PlayerControl::isAudioAvailable() const -{ - return m_session->isAudioAvailable(); -} - -bool QT7PlayerControl::isVideoAvailable() const -{ - return m_session->isVideoAvailable(); -} - -#include "moc_qt7playercontrol.cpp" - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.h b/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.h deleted file mode 100644 index 8cbc29a..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.h +++ /dev/null @@ -1,84 +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 QT7PLAYERMETADATACONTROL_H -#define QT7PLAYERMETADATACONTROL_H - -#include <QtMediaServices/qmetadatacontrol.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QT7PlayerSession; - -class QT7PlayerMetaDataControl : public QMetaDataControl -{ - Q_OBJECT -public: - QT7PlayerMetaDataControl(QT7PlayerSession *session, QObject *parent); - virtual ~QT7PlayerMetaDataControl(); - - 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: - QT7PlayerSession *m_session; - QMap<QtMediaServices::MetaData, QVariant> m_tags; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm deleted file mode 100644 index 2ea778d..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm +++ /dev/null @@ -1,274 +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 "qt7backend.h" -#include "qt7playermetadata.h" -#include "qt7playersession.h" -#include <QtCore/qvarlengtharray.h> - -#import <QTKit/QTMovie.h> - -#ifdef QUICKTIME_C_API_AVAILABLE - #include <QuickTime/QuickTime.h> - #undef check // avoid name clash; -#endif - -QT_BEGIN_NAMESPACE - -QT7PlayerMetaDataControl::QT7PlayerMetaDataControl(QT7PlayerSession *session, QObject *parent) - :QMetaDataControl(parent), m_session(session) -{ -} - -QT7PlayerMetaDataControl::~QT7PlayerMetaDataControl() -{ -} - -bool QT7PlayerMetaDataControl::isMetaDataAvailable() const -{ - return !m_tags.isEmpty(); -} - -bool QT7PlayerMetaDataControl::isWritable() const -{ - return false; -} - -QVariant QT7PlayerMetaDataControl::metaData(QtMediaServices::MetaData key) const -{ - return m_tags.value(key); -} - -void QT7PlayerMetaDataControl::setMetaData(QtMediaServices::MetaData key, QVariant const &value) -{ - Q_UNUSED(key); - Q_UNUSED(value); -} - -QList<QtMediaServices::MetaData> QT7PlayerMetaDataControl::availableMetaData() const -{ - return m_tags.keys(); -} - -QVariant QT7PlayerMetaDataControl::extendedMetaData(const QString &key) const -{ - Q_UNUSED(key); - return QVariant(); -} - -void QT7PlayerMetaDataControl::setExtendedMetaData(const QString &key, QVariant const &value) -{ - Q_UNUSED(key); - Q_UNUSED(value); -} - -QStringList QT7PlayerMetaDataControl::availableExtendedMetaData() const -{ - return QStringList(); -} - -#ifdef QUICKTIME_C_API_AVAILABLE - -static QString stripCopyRightSymbol(const QString &key) -{ - return key.right(key.length()-1); -} - -static QString convertQuickTimeKeyToUserKey(const QString &key) -{ - if (key == QLatin1String("com.apple.quicktime.displayname")) - return QLatin1String("nam"); - else if (key == QLatin1String("com.apple.quicktime.album")) - return QLatin1String("alb"); - else if (key == QLatin1String("com.apple.quicktime.artist")) - return QLatin1String("ART"); - else - return QLatin1String("???"); -} - -static OSStatus readMetaValue(QTMetaDataRef metaDataRef, QTMetaDataItem item, QTPropertyClass propClass, - QTPropertyID id, QTPropertyValuePtr *value, ByteCount *size) -{ - QTPropertyValueType type; - ByteCount propSize; - UInt32 propFlags; - OSStatus err = QTMetaDataGetItemPropertyInfo(metaDataRef, item, propClass, id, &type, &propSize, &propFlags); - - if (err == noErr) { - *value = malloc(propSize); - if (*value != 0) { - err = QTMetaDataGetItemProperty(metaDataRef, item, propClass, id, propSize, *value, size); - - if (err == noErr && (type == 'code' || type == 'itsk' || type == 'itlk')) { - // convert from native endian to big endian - OSTypePtr pType = (OSTypePtr)*value; - *pType = EndianU32_NtoB(*pType); - } - } - else - return -1; - } - - return err; -} - -static UInt32 getMetaType(QTMetaDataRef metaDataRef, QTMetaDataItem item) -{ - QTPropertyValuePtr value = 0; - ByteCount ignore = 0; - OSStatus err = readMetaValue( - metaDataRef, item, kPropertyClass_MetaDataItem, kQTMetaDataItemPropertyID_DataType, &value, &ignore); - - if (err == noErr) { - UInt32 type = *((UInt32 *) value); - if (value) - free(value); - return type; - } - - return 0; -} - -static QString cFStringToQString(CFStringRef str) -{ - if(!str) - return QString(); - CFIndex length = CFStringGetLength(str); - const UniChar *chars = CFStringGetCharactersPtr(str); - if (chars) - return QString(reinterpret_cast<const QChar *>(chars), length); - - QVarLengthArray<UniChar> buffer(length); - CFStringGetCharacters(str, CFRangeMake(0, length), buffer.data()); - return QString(reinterpret_cast<const QChar *>(buffer.constData()), length); -} - - -static QString getMetaValue(QTMetaDataRef metaDataRef, QTMetaDataItem item, SInt32 id) -{ - QTPropertyValuePtr value = 0; - ByteCount size = 0; - OSStatus err = readMetaValue(metaDataRef, item, kPropertyClass_MetaDataItem, id, &value, &size); - QString string; - - if (err == noErr) { - UInt32 dataType = getMetaType(metaDataRef, item); - switch (dataType){ - case kQTMetaDataTypeUTF8: - case kQTMetaDataTypeMacEncodedText: - string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF8, false)); - break; - case kQTMetaDataTypeUTF16BE: - string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF16BE, false)); - break; - default: - break; - } - - if (value) - free(value); - } - - return string; -} - - -static void readFormattedData(QTMetaDataRef metaDataRef, OSType format, QMultiMap<QString, QString> &result) -{ - QTMetaDataItem item = kQTMetaDataItemUninitialized; - OSStatus err = QTMetaDataGetNextItem(metaDataRef, format, item, kQTMetaDataKeyFormatWildcard, 0, 0, &item); - while (err == noErr){ - QString key = getMetaValue(metaDataRef, item, kQTMetaDataItemPropertyID_Key); - if (format == kQTMetaDataStorageFormatQuickTime) - key = convertQuickTimeKeyToUserKey(key); - else - key = stripCopyRightSymbol(key); - - if (!result.contains(key)){ - QString val = getMetaValue(metaDataRef, item, kQTMetaDataItemPropertyID_Value); - result.insert(key, val); - } - err = QTMetaDataGetNextItem(metaDataRef, format, item, kQTMetaDataKeyFormatWildcard, 0, 0, &item); - } -} -#endif - - -void QT7PlayerMetaDataControl::updateTags() -{ - bool wasEmpty = m_tags.isEmpty(); - m_tags.clear(); - - QTMovie *movie = (QTMovie*)m_session->movie(); - - if (movie) { - QMultiMap<QString, QString> metaMap; - -#ifdef QUICKTIME_C_API_AVAILABLE - QTMetaDataRef metaDataRef; - OSStatus err = QTCopyMovieMetaData([movie quickTimeMovie], &metaDataRef); - if (err == noErr) { - readFormattedData(metaDataRef, kQTMetaDataStorageFormatUserData, metaMap); - readFormattedData(metaDataRef, kQTMetaDataStorageFormatQuickTime, metaMap); - readFormattedData(metaDataRef, kQTMetaDataStorageFormatiTunes, metaMap); - } -#else - AutoReleasePool pool; - NSString *name = [movie attributeForKey:@"QTMovieDisplayNameAttribute"]; - metaMap.insert(QLatin1String("nam"), QString::fromUtf8([name UTF8String])); -#endif // QUICKTIME_C_API_AVAILABLE - - m_tags.insert(QtMediaServices::AlbumArtist, metaMap.value(QLatin1String("ART"))); - m_tags.insert(QtMediaServices::AlbumTitle, metaMap.value(QLatin1String("alb"))); - m_tags.insert(QtMediaServices::Title, metaMap.value(QLatin1String("nam"))); - m_tags.insert(QtMediaServices::Date, metaMap.value(QLatin1String("day"))); - m_tags.insert(QtMediaServices::Genre, metaMap.value(QLatin1String("gnre"))); - m_tags.insert(QtMediaServices::TrackNumber, metaMap.value(QLatin1String("trk"))); - m_tags.insert(QtMediaServices::Description, metaMap.value(QLatin1String("des"))); - } - - if (!wasEmpty || !m_tags.isEmpty()) - emit metaDataChanged(); -} - -QT_END_NAMESPACE - -#include "moc_qt7playermetadata.cpp" diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.h b/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.h deleted file mode 100644 index 9a22c31..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.h +++ /dev/null @@ -1,90 +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 QT7PLAYERSERVICE_H -#define QT7PLAYERSERVICE_H - -#include <QtCore/qobject.h> -#include <QtMediaServices/qmediaservice.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaMetaData; -class QMediaPlayerControl; -class QMediaPlaylist; -class QMediaPlaylistNavigator; -class QT7PlayerControl; -class QT7PlayerMetaDataControl; -class QT7VideoOutputControl; -class QT7VideoWindowControl; -class QT7VideoWidgetControl; -class QT7VideoRendererControl; -class QT7VideoOutput; -class QT7PlayerSession; - -class QT7PlayerService : public QMediaService -{ -Q_OBJECT -public: - QT7PlayerService(QObject *parent = 0); - ~QT7PlayerService(); - - QMediaControl *control(const char *name) const; - -private slots: - void updateVideoOutput(); - -private: - QT7PlayerSession *m_session; - QT7PlayerControl *m_control; - QT7VideoOutputControl *m_videoOutputControl; - QT7VideoWindowControl *m_videoWidnowControl; - QT7VideoWidgetControl *m_videoWidgetControl; - QT7VideoRendererControl *m_videoRendererControl; - QT7PlayerMetaDataControl *m_playerMetaDataControl; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.mm deleted file mode 100644 index cf79622..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.mm +++ /dev/null @@ -1,152 +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 "qt7backend.h" -#include "qt7playerservice.h" -#include "qt7playercontrol.h" -#include "qt7playersession.h" -#include "qt7videooutputcontrol.h" -#include "qt7movieviewoutput.h" -#include "qt7movieviewrenderer.h" -#include "qt7movierenderer.h" -#include "qt7movievideowidget.h" -#include "qt7playermetadata.h" - -#include <QtMediaServices/qmediaplaylistnavigator.h> -#include <QtMediaServices/qmediaplaylist.h> - -QT_BEGIN_NAMESPACE - -QT7PlayerService::QT7PlayerService(QObject *parent): - QMediaService(parent) -{ - m_session = new QT7PlayerSession(this); - - m_control = new QT7PlayerControl(this); - m_control->setSession(m_session); - - m_playerMetaDataControl = new QT7PlayerMetaDataControl(m_session, this); - connect(m_control, SIGNAL(mediaChanged(QMediaContent)), m_playerMetaDataControl, SLOT(updateTags())); - - m_videoOutputControl = new QT7VideoOutputControl(this); - - m_videoWidnowControl = 0; - m_videoWidgetControl = 0; - m_videoRendererControl = 0; - -#if defined(QT_MAC_USE_COCOA) - m_videoWidnowControl = new QT7MovieViewOutput(this); - m_videoOutputControl->enableOutput(QVideoOutputControl::WindowOutput); -// qDebug() << "Using cocoa"; -#endif - -#ifdef QUICKTIME_C_API_AVAILABLE - m_videoRendererControl = new QT7MovieRenderer(this); - m_videoOutputControl->enableOutput(QVideoOutputControl::RendererOutput); - - m_videoWidgetControl = new QT7MovieVideoWidget(this); - m_videoOutputControl->enableOutput(QVideoOutputControl::WidgetOutput); -// qDebug() << "QuickTime C API is available"; -#else - m_videoRendererControl = new QT7MovieViewRenderer(this); - m_videoOutputControl->enableOutput(QVideoOutputControl::RendererOutput); -// qDebug() << "QuickTime C API is not available"; -#endif - - - connect(m_videoOutputControl, SIGNAL(videoOutputChanged(QVideoOutputControl::Output)), - this, SLOT(updateVideoOutput())); -} - -QT7PlayerService::~QT7PlayerService() -{ - m_session->setVideoOutput(0); -} - -QMediaControl *QT7PlayerService::control(const char *name) const -{ - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) - return m_control; - - if (qstrcmp(name, QVideoOutputControl_iid) == 0) - return m_videoOutputControl; - - if (qstrcmp(name, QVideoWindowControl_iid) == 0) - return m_videoWidnowControl; - - if (qstrcmp(name, QVideoRendererControl_iid) == 0) - return m_videoRendererControl; - - if (qstrcmp(name, QVideoWidgetControl_iid) == 0) - return m_videoWidgetControl; - - if (qstrcmp(name, QMetaDataControl_iid) == 0) - return m_playerMetaDataControl; - - return 0; -} - -void QT7PlayerService::updateVideoOutput() -{ -// qDebug() << "QT7PlayerService::updateVideoOutput" << m_videoOutputControl->output(); - - switch (m_videoOutputControl->output()) { - case QVideoOutputControl::WindowOutput: - m_session->setVideoOutput(m_videoWidnowControl); - break; - case QVideoOutputControl::RendererOutput: - m_session->setVideoOutput(m_videoRendererControl); - break; - case QVideoOutputControl::WidgetOutput: - m_session->setVideoOutput(m_videoWidgetControl); - break; - default: - m_session->setVideoOutput(0); - } -} - -QT_END_NAMESPACE - -#include "moc_qt7playerservice.cpp" diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h deleted file mode 100644 index 2450cf8..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h +++ /dev/null @@ -1,151 +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 QT7PLAYERSESSION_H -#define QT7PLAYERSESSION_H - -#include <QtCore/qobject.h> -#include <QtGui/qmacdefines_mac.h> - -#include <QtMediaServices/qmediaplayercontrol.h> -#include <QtMediaServices/qmediaplayer.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QT7PlayerControl; -class QMediaPlaylist; -class QMediaPlaylistNavigator; -class QT7VideoOutput; -class QT7PlayerSession; -class QT7PlayerService; - -class QT7PlayerSession : public QObject -{ -Q_OBJECT -public: - QT7PlayerSession(QObject *parent = 0); - ~QT7PlayerSession(); - - void *movie() const; - - void setControl(QT7PlayerControl *control); - void setVideoOutput(QT7VideoOutput *output); - - QMediaPlayer::State state() const; - QMediaPlayer::MediaStatus mediaStatus() const; - - QMediaContent media() const; - const QIODevice *mediaStream() const; - void setMedia(const QMediaContent &content, QIODevice *stream); - - qint64 position() const; - qint64 duration() const; - - int bufferStatus() const; - - int volume() const; - bool isMuted() const; - - bool isAudioAvailable() const; - bool isVideoAvailable() const; - - bool isSeekable() const; - - qreal playbackRate() const; - -public slots: - void setPlaybackRate(qreal rate); - - void setPosition(qint64 pos); - - void play(); - void pause(); - void stop(); - - void setVolume(int volume); - void setMuted(bool muted); - - void processEOS(); - void processLoadStateChange(); - void processVolumeChange(); - void processNaturalSizeChange(); - -signals: - void positionChanged(qint64 position); - void durationChanged(qint64 duration); - void stateChanged(QMediaPlayer::State newState); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void audioAvailableChanged(bool audioAvailable); - void videoAvailableChanged(bool videoAvailable); - void error(int error, const QString &errorString); - -private: - void *m_QTMovie; - void *m_movieObserver; - - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_mediaStatus; - QIODevice *m_mediaStream; - QMediaContent m_resources; - - QT7VideoOutput *m_videoOutput; - - mutable qint64 m_currentTime; - - bool m_muted; - int m_volume; - qreal m_rate; - - qint64 m_duration; - bool m_videoAvailable; - bool m_audioAvailable; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm deleted file mode 100644 index 0405bbd..0000000 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm +++ /dev/null @@ -1,552 +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$ -** -****************************************************************************/ - -#import <QTKit/QTDataReference.h> -#import <QTKit/QTMovie.h> - -#include "qt7backend.h" - -#include "qt7playersession.h" -#include "qt7playercontrol.h" -#include "qt7videooutputcontrol.h" - -#include <QtNetwork/qnetworkcookie.h> -#include <QtMediaServices/qmediaplaylistnavigator.h> - -#include <CoreFoundation/CoreFoundation.h> -#include <Foundation/Foundation.h> - -#include <QtCore/qdatetime.h> -#include <QtCore/qurl.h> -#include <QtCore/qdebug.h> - -@interface QTMovieObserver : NSObject -{ -@private - QT7PlayerSession *m_session; - QTMovie *m_movie; -} - -- (QTMovieObserver *) initWithPlayerSession:(QT7PlayerSession*)session; -- (void) setMovie:(QTMovie *)movie; -- (void) processEOS:(NSNotification *)notification; -- (void) processLoadStateChange:(NSNotification *)notification; -- (void) processVolumeChange:(NSNotification *)notification; -- (void) processNaturalSizeChange :(NSNotification *)notification; -@end - -@implementation QTMovieObserver - -- (QTMovieObserver *) initWithPlayerSession:(QT7PlayerSession*)session -{ - if (!(self = [super init])) - return nil; - - self->m_session = session; - return self; -} - -- (void) setMovie:(QTMovie *)movie -{ - if (m_movie == movie) - return; - - if (m_movie) { - [[NSNotificationCenter defaultCenter] removeObserver:self]; - [m_movie release]; - } - - m_movie = movie; - - if (movie) { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(processEOS:) - name:QTMovieDidEndNotification - object:m_movie]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(processLoadStateChange:) - name:QTMovieLoadStateDidChangeNotification - object:m_movie]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(processVolumeChange:) - name:QTMovieVolumeDidChangeNotification - object:m_movie]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(processNaturalSizeChange:) - name: -#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6) - QTMovieNaturalSizeDidChangeNotification -#else - QTMovieEditedNotification -#endif - object:m_movie]; - [movie retain]; - } -} - -- (void) processEOS:(NSNotification *)notification -{ - Q_UNUSED(notification); - QMetaObject::invokeMethod(m_session, "processEOS", Qt::AutoConnection); -} - -- (void) processLoadStateChange:(NSNotification *)notification -{ - Q_UNUSED(notification); - QMetaObject::invokeMethod(m_session, "processLoadStateChange", Qt::AutoConnection); -} - -- (void) processVolumeChange:(NSNotification *)notification -{ - Q_UNUSED(notification); - QMetaObject::invokeMethod(m_session, "processVolumeChange", Qt::AutoConnection); -} - -- (void) processNaturalSizeChange :(NSNotification *)notification -{ - Q_UNUSED(notification); - QMetaObject::invokeMethod(m_session, "processNaturalSizeChange", Qt::AutoConnection); -} - -@end - -QT_BEGIN_NAMESPACE - -static inline NSString *qString2CFStringRef(const QString &string) -{ - return [NSString stringWithCharacters:reinterpret_cast<const UniChar *>(string.unicode()) length:string.length()]; -} - -QT7PlayerSession::QT7PlayerSession(QObject *parent) - : QObject(parent) - , m_QTMovie(0) - , m_state(QMediaPlayer::StoppedState) - , m_mediaStatus(QMediaPlayer::NoMedia) - , m_mediaStream(0) - , m_videoOutput(0) - , m_muted(false) - , m_volume(100) - , m_rate(1.0) - , m_duration(0) - , m_videoAvailable(false) - , m_audioAvailable(false) -{ - m_movieObserver = [[QTMovieObserver alloc] initWithPlayerSession:this]; -} - -QT7PlayerSession::~QT7PlayerSession() -{ - [(QTMovieObserver*)m_movieObserver setMovie:nil]; - [(QTMovieObserver*)m_movieObserver release]; - [(QTMovie*)m_QTMovie release]; -} - -void *QT7PlayerSession::movie() const -{ - return m_QTMovie; -} - -void QT7PlayerSession::setVideoOutput(QT7VideoOutput *output) -{ - if (m_videoOutput == output) - return; - - if (m_videoOutput) - m_videoOutput->setMovie(0); - - m_videoOutput = output; - - if (m_videoOutput && m_state != QMediaPlayer::StoppedState) - m_videoOutput->setMovie(m_QTMovie); -} - - -qint64 QT7PlayerSession::position() const -{ - if (!m_QTMovie || m_state == QMediaPlayer::PausedState) - return m_currentTime; - - AutoReleasePool pool; - - QTTime qtTime = [(QTMovie*)m_QTMovie currentTime]; - quint64 t = static_cast<quint64>(float(qtTime.timeValue) / float(qtTime.timeScale) * 1000.0f); - m_currentTime = t; - - return m_currentTime; -} - -qint64 QT7PlayerSession::duration() const -{ - if (!m_QTMovie) - return 0; - - AutoReleasePool pool; - - QTTime qtTime = [(QTMovie*)m_QTMovie duration]; - - return static_cast<quint64>(float(qtTime.timeValue) / float(qtTime.timeScale) * 1000.0f); -} - -QMediaPlayer::State QT7PlayerSession::state() const -{ - return m_state; -} - -QMediaPlayer::MediaStatus QT7PlayerSession::mediaStatus() const -{ - return m_mediaStatus; -} - -int QT7PlayerSession::bufferStatus() const -{ - return 100; -} - -int QT7PlayerSession::volume() const -{ - return m_volume; -} - -bool QT7PlayerSession::isMuted() const -{ - return m_muted; -} - -bool QT7PlayerSession::isSeekable() const -{ - return true; -} - -qreal QT7PlayerSession::playbackRate() const -{ - return m_rate; -} - -void QT7PlayerSession::setPlaybackRate(qreal rate) -{ - if (qFuzzyCompare(m_rate, rate)) - return; - - m_rate = rate; - - if (m_QTMovie && m_state == QMediaPlayer::PlayingState) { - float preferredRate = [[(QTMovie*)m_QTMovie attributeForKey:@"QTMoviePreferredRateAttribute"] floatValue]; - [(QTMovie*)m_QTMovie setRate:preferredRate*m_rate]; - } -} - -void QT7PlayerSession::setPosition(qint64 pos) -{ - if ( !isSeekable() || pos == position()) - return; - - AutoReleasePool pool; - - pos = qMin(pos, duration()); - - QTTime newQTTime = [(QTMovie*)m_QTMovie currentTime]; - newQTTime.timeValue = (pos / 1000.0f) * newQTTime.timeScale; - [(QTMovie*)m_QTMovie setCurrentTime:newQTTime]; -} - -void QT7PlayerSession::play() -{ - if (m_videoOutput) - m_videoOutput->setMovie(m_QTMovie); - - float preferredRate = [[(QTMovie*)m_QTMovie attributeForKey:@"QTMoviePreferredRateAttribute"] floatValue]; - [(QTMovie*)m_QTMovie setRate:preferredRate*m_rate]; - - if (m_state != QMediaPlayer::PlayingState) - emit stateChanged(m_state = QMediaPlayer::PlayingState); -} - -void QT7PlayerSession::pause() -{ - if (m_videoOutput) - m_videoOutput->setMovie(m_QTMovie); - - m_state = QMediaPlayer::PausedState; - - [(QTMovie*)m_QTMovie setRate:0]; - - emit stateChanged(m_state); -} - -void QT7PlayerSession::stop() -{ - m_state = QMediaPlayer::StoppedState; - - [(QTMovie*)m_QTMovie setRate:0]; - setPosition(0); - - if (m_videoOutput) - m_videoOutput->setMovie(0); - - if (m_state == QMediaPlayer::StoppedState) - emit stateChanged(m_state); -} - -void QT7PlayerSession::setVolume(int volume) -{ - if (m_QTMovie) { - m_volume = volume; - [(QTMovie*)m_QTMovie setVolume:(volume/100.0f)]; - } -} - -void QT7PlayerSession::setMuted(bool muted) -{ - if (m_muted != muted) { - m_muted = muted; - - if (m_QTMovie) - [(QTMovie*)m_QTMovie setMuted:m_muted]; - - emit mutedChanged(muted); - } -} - -QMediaContent QT7PlayerSession::media() const -{ - return m_resources; -} - -const QIODevice *QT7PlayerSession::mediaStream() const -{ - return m_mediaStream; -} - -void QT7PlayerSession::setMedia(const QMediaContent &content, QIODevice *stream) -{ - AutoReleasePool pool; - - if (m_QTMovie) { - [(QTMovieObserver*)m_movieObserver setMovie:nil]; - - if (m_videoOutput) - m_videoOutput->setMovie(0); - - [(QTMovie*)m_QTMovie release]; - m_QTMovie = 0; - } - - m_resources = content; - m_mediaStream = stream; - m_mediaStatus = QMediaPlayer::NoMedia; - - QNetworkRequest request; - - if (!content.isNull()) - request = content.canonicalResource().request(); - else - return; - - QVariant cookies = request.header(QNetworkRequest::CookieHeader); - if (cookies.isValid()) { - NSHTTPCookieStorage *store = [NSHTTPCookieStorage sharedHTTPCookieStorage]; - QList<QNetworkCookie> cookieList = cookies.value<QList<QNetworkCookie> >(); - - foreach (const QNetworkCookie &requestCookie, cookieList) { - NSMutableDictionary *p = [NSMutableDictionary dictionaryWithObjectsAndKeys: - qString2CFStringRef(requestCookie.name()), NSHTTPCookieName, - qString2CFStringRef(requestCookie.value()), NSHTTPCookieValue, - qString2CFStringRef(requestCookie.domain()), NSHTTPCookieDomain, - qString2CFStringRef(requestCookie.path()), NSHTTPCookiePath, - nil - ]; - if (requestCookie.isSessionCookie()) - [p setObject:[NSString stringWithUTF8String:"TRUE"] forKey:NSHTTPCookieDiscard]; - else - [p setObject:[NSDate dateWithTimeIntervalSince1970:requestCookie.expirationDate().toTime_t()] forKey:NSHTTPCookieExpires]; - - [store setCookie:[NSHTTPCookie cookieWithProperties:p]]; - } - } - - NSError *err = 0; - NSString *urlString = qString2CFStringRef(request.url().toString()); - - NSDictionary *attr = [NSDictionary dictionaryWithObjectsAndKeys: - [NSURL URLWithString:urlString], QTMovieURLAttribute, - [NSNumber numberWithBool:YES], QTMovieOpenAsyncOKAttribute, - [NSNumber numberWithBool:YES], QTMovieIsActiveAttribute, - [NSNumber numberWithBool:YES], QTMovieResolveDataRefsAttribute, - [NSNumber numberWithBool:YES], QTMovieDontInteractWithUserAttribute, - nil]; - - m_QTMovie = [[QTMovie movieWithAttributes:attr error:&err] retain]; - - if (err) { - [(QTMovie*)m_QTMovie release]; - m_QTMovie = 0; - QString description = QString::fromUtf8([[err localizedDescription] UTF8String]); - - emit error(QMediaPlayer::FormatError, description ); - } else { - [(QTMovieObserver*)m_movieObserver setMovie:(QTMovie*)m_QTMovie]; - - if (m_videoOutput && m_state != QMediaPlayer::StoppedState) - m_videoOutput->setMovie(m_QTMovie); - - processLoadStateChange(); - - [(QTMovie*)m_QTMovie setMuted:m_muted]; - setVolume(m_volume); - } -} - -bool QT7PlayerSession::isAudioAvailable() const -{ - if (!m_QTMovie) - return false; - - AutoReleasePool pool; - return [[(QTMovie*)m_QTMovie attributeForKey:@"QTMovieHasAudioAttribute"] boolValue] == YES; -} - -bool QT7PlayerSession::isVideoAvailable() const -{ - if (!m_QTMovie) - return false; - - AutoReleasePool pool; - return [[(QTMovie*)m_QTMovie attributeForKey:@"QTMovieHasVideoAttribute"] boolValue] == YES; -} - -void QT7PlayerSession::processEOS() -{ - m_mediaStatus = QMediaPlayer::EndOfMedia; - if (m_videoOutput) - m_videoOutput->setMovie(0); - emit stateChanged(m_state = QMediaPlayer::StoppedState); - emit mediaStatusChanged(m_mediaStatus); -} - -void QT7PlayerSession::processLoadStateChange() -{ - if (!m_QTMovie) - return; - - signed long state = [[(QTMovie*)m_QTMovie attributeForKey:QTMovieLoadStateAttribute] - longValue]; -// qDebug() << "Moview load state changed:" << state; - -#ifndef QUICKTIME_C_API_AVAILABLE - enum { - kMovieLoadStateError = -1L, - kMovieLoadStateLoading = 1000, - kMovieLoadStateLoaded = 2000, - kMovieLoadStatePlayable = 10000, - kMovieLoadStatePlaythroughOK = 20000, - kMovieLoadStateComplete = 100000 - }; -#endif - - QMediaPlayer::MediaStatus newStatus = QMediaPlayer::NoMedia; - bool isPlaying = (m_state != QMediaPlayer::StoppedState); - - if (state >= kMovieLoadStateComplete) { - newStatus = isPlaying ? QMediaPlayer::BufferedMedia : QMediaPlayer::LoadedMedia; - } else if (state >= kMovieLoadStatePlayable) - newStatus = isPlaying ? QMediaPlayer::BufferingMedia : QMediaPlayer::LoadingMedia; - else if (state >= kMovieLoadStateLoading) - newStatus = isPlaying ? QMediaPlayer::StalledMedia : QMediaPlayer::LoadingMedia; - - if (state == kMovieLoadStateError) { - newStatus = QMediaPlayer::InvalidMedia; - if (m_videoOutput) - m_videoOutput->setMovie(0); - - emit error(QMediaPlayer::FormatError, tr("Failed to load media")); - emit stateChanged(m_state = QMediaPlayer::StoppedState); - } - - if (state >= kMovieLoadStatePlayable && - m_state == QMediaPlayer::PlayingState && - [(QTMovie*)m_QTMovie rate] == 0) { - QMetaObject::invokeMethod(this, "play", Qt::QueuedConnection); - } - - if (state >= kMovieLoadStateLoaded) { - qint64 currentDuration = duration(); - if (m_duration != currentDuration) - emit durationChanged(m_duration = currentDuration); - - if (m_audioAvailable != isAudioAvailable()) - emit audioAvailableChanged(m_audioAvailable = !m_audioAvailable); - - if (m_videoAvailable != isVideoAvailable()) - emit videoAvailableChanged(m_videoAvailable = !m_videoAvailable); - } - - if (newStatus != m_mediaStatus) - emit mediaStatusChanged(m_mediaStatus = newStatus); -} - -void QT7PlayerSession::processVolumeChange() -{ - if (!m_QTMovie) - return; - - int newVolume = qRound(100.0f*[((QTMovie*)m_QTMovie) volume]); - - if (newVolume != m_volume) { - emit volumeChanged(m_volume = newVolume); - } -} - -void QT7PlayerSession::processNaturalSizeChange() -{ - if (m_videoOutput) { - NSSize size = [[(QTMovie*)m_QTMovie attributeForKey:@"QTMovieNaturalSizeAttribute"] sizeValue]; -// qDebug() << "Native size changed:" << QSize(size.width, size.height); - m_videoOutput->updateNaturalSize(QSize(size.width, size.height)); - } -} - -#include "moc_qt7playersession.cpp" - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/qt7/qcvdisplaylink.h b/src/plugins/mediaservices/qt7/qcvdisplaylink.h deleted file mode 100644 index 5a1180d..0000000 --- a/src/plugins/mediaservices/qt7/qcvdisplaylink.h +++ /dev/null @@ -1,90 +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 QCVDISPLAYLINK_H -#define QCVDISPLAYLINK_H - -#include <QtCore/qobject.h> -#include <QtCore/qmutex.h> - -#include <QuartzCore/CVDisplayLink.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QCvDisplayLink : public QObject -{ -Q_OBJECT -public: - QCvDisplayLink(QObject *parent = 0); - virtual ~QCvDisplayLink(); - - bool isValid(); - bool isActive() const; - -public slots: - void start(); - void stop(); - -signals: - void tick(const CVTimeStamp &ts); - -public: - void displayLinkEvent(const CVTimeStamp *); - -protected: - virtual bool event(QEvent *); - -private: - CVDisplayLinkRef m_displayLink; - QMutex m_displayLinkMutex; - bool m_pendingDisplayLinkEvent; - bool m_isActive; - CVTimeStamp m_frameTimeStamp; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif - diff --git a/src/plugins/mediaservices/qt7/qcvdisplaylink.mm b/src/plugins/mediaservices/qt7/qcvdisplaylink.mm deleted file mode 100644 index 00b4dc5..0000000 --- a/src/plugins/mediaservices/qt7/qcvdisplaylink.mm +++ /dev/null @@ -1,158 +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 "qcvdisplaylink.h" - -#include <QtCore/qcoreapplication.h> -#include <QtCore/qdebug.h> - -QT_BEGIN_NAMESPACE - -static CVReturn CVDisplayLinkCallback(CVDisplayLinkRef displayLink, - const CVTimeStamp *inNow, - const CVTimeStamp *inOutputTime, - CVOptionFlags flagsIn, - CVOptionFlags *flagsOut, - void *displayLinkContext) -{ - Q_UNUSED(displayLink); - Q_UNUSED(inNow); - Q_UNUSED(flagsIn); - Q_UNUSED(flagsOut); - - QCvDisplayLink *link = (QCvDisplayLink *)displayLinkContext; - - link->displayLinkEvent(inOutputTime); - return kCVReturnSuccess; -} - - -QCvDisplayLink::QCvDisplayLink(QObject *parent) - :QObject(parent), - m_pendingDisplayLinkEvent(false), - m_isActive(false) -{ - // create display link for the main display - CVDisplayLinkCreateWithCGDisplay(kCGDirectMainDisplay, &m_displayLink); - if (m_displayLink) { - // set the current display of a display link. - CVDisplayLinkSetCurrentCGDisplay(m_displayLink, kCGDirectMainDisplay); - - // set the renderer output callback function - CVDisplayLinkSetOutputCallback(m_displayLink, &CVDisplayLinkCallback, this); - } -} - -QCvDisplayLink::~QCvDisplayLink() -{ - if (m_displayLink) { - CVDisplayLinkStop(m_displayLink); - CVDisplayLinkRelease(m_displayLink); - m_displayLink = NULL; - } -} - -bool QCvDisplayLink::isValid() -{ - return m_displayLink != 0; -} - -bool QCvDisplayLink::isActive() const -{ - return m_isActive; -} - -void QCvDisplayLink::start() -{ - if (m_displayLink && !m_isActive) { - CVDisplayLinkStart(m_displayLink); - m_isActive = true; - } -} - -void QCvDisplayLink::stop() -{ - if (m_displayLink && m_isActive) { - CVDisplayLinkStop(m_displayLink); - m_isActive = false; - } -} - -void QCvDisplayLink::displayLinkEvent(const CVTimeStamp *ts) -{ - // This function is called from a - // thread != gui thread. So we post the event. - // But we need to make sure that we don't post faster - // than the event loop can eat: - m_displayLinkMutex.lock(); - bool pending = m_pendingDisplayLinkEvent; - m_pendingDisplayLinkEvent = true; - m_frameTimeStamp = *ts; - m_displayLinkMutex.unlock(); - - if (!pending) - qApp->postEvent(this, new QEvent(QEvent::User), Qt::HighEventPriority); -} - -bool QCvDisplayLink::event(QEvent *event) -{ - switch (event->type()){ - case QEvent::User: { - m_displayLinkMutex.lock(); - m_pendingDisplayLinkEvent = false; - CVTimeStamp ts = m_frameTimeStamp; - m_displayLinkMutex.unlock(); - - emit tick(ts); - - return false; - } - break; - default: - break; - } - return QObject::event(event); -} - -QT_END_NAMESPACE - -#include "moc_qcvdisplaylink.cpp" - diff --git a/src/plugins/mediaservices/qt7/qt7.pro b/src/plugins/mediaservices/qt7/qt7.pro deleted file mode 100644 index baac224..0000000 --- a/src/plugins/mediaservices/qt7/qt7.pro +++ /dev/null @@ -1,47 +0,0 @@ -TARGET = qqt7 -include(../../qpluginbase.pri) - -QT += opengl mediaservices - -LIBS += -framework AppKit -framework AudioUnit \ - -framework AudioToolbox -framework CoreAudio \ - -framework QuartzCore -framework QTKit - -# The Quicktime framework is only awailable for 32-bit builds, so we -# need to check for this before linking against it. -# QMAKE_MAC_XARCH is not awailable on Tiger, but at the same time, -# we never build for 64-bit architechtures on Tiger either: -contains(QMAKE_MAC_XARCH, no) { - LIBS += -framework QuickTime -} else { - LIBS += -Xarch_i386 -framework QuickTime -Xarch_ppc -framework QuickTime -} - -HEADERS += \ - qt7backend.h \ - qt7videooutputcontrol.h \ - qt7movieviewoutput.h \ - qt7movievideowidget.h \ - qt7movieviewrenderer.h \ - qt7serviceplugin.h \ - qt7movierenderer.h \ - qt7ciimagevideobuffer.h \ - qcvdisplaylink.h - -OBJECTIVE_SOURCES += \ - qt7backend.mm \ - qt7serviceplugin.mm \ - qt7movieviewoutput.mm \ - qt7movievideowidget.mm \ - qt7movieviewrenderer.mm \ - qt7movierenderer.mm \ - qt7videooutputcontrol.mm \ - qt7ciimagevideobuffer.mm \ - qcvdisplaylink.mm - -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/qt7/qt7backend.h b/src/plugins/mediaservices/qt7/qt7backend.h deleted file mode 100644 index 5668965..0000000 --- a/src/plugins/mediaservices/qt7/qt7backend.h +++ /dev/null @@ -1,68 +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 QT7BACKEND_H -#define QT7BACKEND_H - -#include <QtCore/qstring.h> - -#ifndef Q_WS_MAC64 -#define QUICKTIME_C_API_AVAILABLE -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class AutoReleasePool -{ -private: - void *pool; -public: - AutoReleasePool(); - ~AutoReleasePool(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/qt7backend.mm b/src/plugins/mediaservices/qt7/qt7backend.mm deleted file mode 100644 index 478589b..0000000 --- a/src/plugins/mediaservices/qt7/qt7backend.mm +++ /dev/null @@ -1,60 +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 "qt7backend.h" - -#import <Foundation/NSAutoreleasePool.h> -#include <CoreFoundation/CFBase.h> - - -QT_BEGIN_NAMESPACE - -AutoReleasePool::AutoReleasePool() -{ - pool = (void*)[[NSAutoreleasePool alloc] init]; -} - -AutoReleasePool::~AutoReleasePool() -{ - [(NSAutoreleasePool*)pool release]; -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.h b/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.h deleted file mode 100644 index 669724f..0000000 --- a/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.h +++ /dev/null @@ -1,90 +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 QT7CIIMAGEVIDEOBUFFER_H -#define QT7CIIMAGEVIDEOBUFFER_H - -#include "qt7backend.h" -#import <QTKit/QTKit.h> - -#include <QtCore/qvariant.h> -#include <QtMultimedia/qabstractvideobuffer.h> - - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QT7CIImageVideoBuffer : public QAbstractVideoBuffer -{ -public: - QT7CIImageVideoBuffer(CIImage *image); - - virtual ~QT7CIImageVideoBuffer(); - - MapMode mapMode() const; - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); - void unmap(); - QVariant handle() const; - -private: - CIImage *m_image; - NSBitmapImageRep *m_buffer; - MapMode m_mode; -}; - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.mm b/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.mm deleted file mode 100644 index 7c02f9f..0000000 --- a/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.mm +++ /dev/null @@ -1,107 +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 "qt7ciimagevideobuffer.h" - -#include <QuartzCore/CIFilter.h> -#include <QuartzCore/CIVector.h> - -QT7CIImageVideoBuffer::QT7CIImageVideoBuffer(CIImage *image) - : QAbstractVideoBuffer(CoreImageHandle) - , m_image(image) - , m_buffer(0) - , m_mode(NotMapped) -{ - [m_image retain]; -} - -QT7CIImageVideoBuffer::~QT7CIImageVideoBuffer() -{ - [m_image release]; - [m_buffer release]; -} - -QAbstractVideoBuffer::MapMode QT7CIImageVideoBuffer::mapMode() const -{ - return m_mode; -} - -uchar *QT7CIImageVideoBuffer::map(QAbstractVideoBuffer::MapMode mode, int *numBytes, int *bytesPerLine) -{ - if (mode == NotMapped || m_mode != NotMapped || !m_image) - return 0; - - if (!m_buffer) { - //swap R and B channels - CIFilter *colorSwapFilter = [CIFilter filterWithName: @"CIColorMatrix" keysAndValues: - @"inputImage", m_image, - @"inputRVector", [CIVector vectorWithX: 0 Y: 0 Z: 1 W: 0], - @"inputGVector", [CIVector vectorWithX: 0 Y: 1 Z: 0 W: 0], - @"inputBVector", [CIVector vectorWithX: 1 Y: 0 Z: 0 W: 0], - @"inputAVector", [CIVector vectorWithX: 0 Y: 0 Z: 0 W: 1], - @"inputBiasVector", [CIVector vectorWithX: 0 Y: 0 Z: 0 W: 0], - nil]; - CIImage *img = [colorSwapFilter valueForKey: @"outputImage"]; - - m_buffer = [[NSBitmapImageRep alloc] initWithCIImage:img]; - } - - if (numBytes) - *numBytes = [m_buffer bytesPerPlane]; - - if (bytesPerLine) - *bytesPerLine = [m_buffer bytesPerRow]; - - m_mode = mode; - - return [m_buffer bitmapData]; -} - -void QT7CIImageVideoBuffer::unmap() -{ - m_mode = NotMapped; -} - -QVariant QT7CIImageVideoBuffer::handle() const -{ - return QVariant::fromValue<void*>(m_image); -} - diff --git a/src/plugins/mediaservices/qt7/qt7movierenderer.h b/src/plugins/mediaservices/qt7/qt7movierenderer.h deleted file mode 100644 index 5953b54..0000000 --- a/src/plugins/mediaservices/qt7/qt7movierenderer.h +++ /dev/null @@ -1,112 +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 QT7MOVIERENDERER_H -#define QT7MOVIERENDERER_H - -#include "qt7backend.h" - -#include <QtCore/qobject.h> -#include <QtCore/qmutex.h> - -#include <qvideorenderercontrol.h> -#include <qmediaplayer.h> - -#include <QtGui/qmacdefines_mac.h> -#include "qt7videooutputcontrol.h" - -#include <QuartzCore/CVOpenGLTexture.h> -#include <QuickTime/QuickTime.h> - - -QT_BEGIN_HEADER - -class QGLContext; - -QT_BEGIN_NAMESPACE - -class QCvDisplayLink; -class QT7PlayerSession; -class QT7PlayerService; - -class QT7MovieRenderer : public QT7VideoRendererControl -{ -Q_OBJECT -public: - QT7MovieRenderer(QObject *parent = 0); - virtual ~QT7MovieRenderer(); - - void setMovie(void *movie); - void updateNaturalSize(const QSize &newSize); - - QAbstractVideoSurface *surface() const; - void setSurface(QAbstractVideoSurface *surface); - - QSize nativeSize() const; - -private slots: - void updateVideoFrame(const CVTimeStamp &ts); - -private: - void setupVideoOutput(); - bool createPixelBufferVisualContext(); - bool createGLVisualContext(); - - void *m_movie; - - QMutex m_mutex; - - QCvDisplayLink *m_displayLink; -#ifdef QUICKTIME_C_API_AVAILABLE - QTVisualContextRef m_visualContext; - bool m_usingGLContext; - const QGLContext *m_currentGLContext; - QSize m_pixelBufferContextGeometry; -#endif - QAbstractVideoSurface *m_surface; - QSize m_nativeSize; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/qt7movierenderer.mm b/src/plugins/mediaservices/qt7/qt7movierenderer.mm deleted file mode 100644 index 95f5d4c..0000000 --- a/src/plugins/mediaservices/qt7/qt7movierenderer.mm +++ /dev/null @@ -1,465 +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$ -** -****************************************************************************/ - -#import <QTKit/QTKit.h> - -#include "qt7backend.h" - -#include "qt7playercontrol.h" -#include "qt7movierenderer.h" -#include "qt7playersession.h" -#include "qt7ciimagevideobuffer.h" -#include "qcvdisplaylink.h" -#include <QtCore/qdebug.h> -#include <QtCore/qcoreapplication.h> - -#include <QGLWidget> - -#include <QtMultimedia/qabstractvideobuffer.h> -#include <QtMultimedia/qabstractvideosurface.h> -#include <QtMultimedia/qvideosurfaceformat.h> - -QT_BEGIN_NAMESPACE - -//#define USE_MAIN_MONITOR_COLOR_SPACE 1 - -class CVGLTextureVideoBuffer : public QAbstractVideoBuffer -{ -public: - CVGLTextureVideoBuffer(CVOpenGLTextureRef buffer) - : QAbstractVideoBuffer(GLTextureHandle) - , m_buffer(buffer) - , m_mode(NotMapped) - { - CVOpenGLTextureRetain(m_buffer); - } - - virtual ~CVGLTextureVideoBuffer() - { - CVOpenGLTextureRelease(m_buffer); - } - - QVariant handle() const - { - GLuint id = CVOpenGLTextureGetName(m_buffer); - return QVariant(int(id)); - } - - MapMode mapMode() const { return m_mode; } - - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine) - { - if (numBytes) - *numBytes = 0; - - if (bytesPerLine) - *bytesPerLine = 0; - - m_mode = mode; - return 0; - } - - void unmap() { m_mode = NotMapped; } - -private: - CVOpenGLTextureRef m_buffer; - MapMode m_mode; -}; - - -class CVPixelBufferVideoBuffer : public QAbstractVideoBuffer -{ -public: - CVPixelBufferVideoBuffer(CVPixelBufferRef buffer) - : QAbstractVideoBuffer(NoHandle) - , m_buffer(buffer) - , m_mode(NotMapped) - { - CVPixelBufferRetain(m_buffer); - } - - virtual ~CVPixelBufferVideoBuffer() - { - CVPixelBufferRelease(m_buffer); - } - - MapMode mapMode() const { return m_mode; } - - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine) - { - if (mode != NotMapped && m_mode == NotMapped) { - CVPixelBufferLockBaseAddress(m_buffer, 0); - - if (numBytes) - *numBytes = CVPixelBufferGetDataSize(m_buffer); - - if (bytesPerLine) - *bytesPerLine = CVPixelBufferGetBytesPerRow(m_buffer); - - m_mode = mode; - - return (uchar*)CVPixelBufferGetBaseAddress(m_buffer); - } else { - return 0; - } - } - - void unmap() - { - if (m_mode != NotMapped) { - m_mode = NotMapped; - CVPixelBufferUnlockBaseAddress(m_buffer, 0); - } - } - -private: - CVPixelBufferRef m_buffer; - MapMode m_mode; -}; - - - -QT7MovieRenderer::QT7MovieRenderer(QObject *parent) - :QT7VideoRendererControl(parent), - m_movie(0), -#ifdef QUICKTIME_C_API_AVAILABLE - m_visualContext(0), - m_usingGLContext(false), - m_currentGLContext(0), -#endif - m_surface(0) -{ -// qDebug() << "QT7MovieRenderer"; - - m_displayLink = new QCvDisplayLink(this); - connect(m_displayLink, SIGNAL(tick(CVTimeStamp)), SLOT(updateVideoFrame(CVTimeStamp))); -} - - -bool QT7MovieRenderer::createGLVisualContext() -{ -#ifdef QUICKTIME_C_API_AVAILABLE - AutoReleasePool pool; - CGLContextObj cglContext = CGLGetCurrentContext(); - NSOpenGLPixelFormat *nsglPixelFormat = [NSOpenGLView defaultPixelFormat]; - CGLPixelFormatObj cglPixelFormat = static_cast<CGLPixelFormatObj>([nsglPixelFormat CGLPixelFormatObj]); - - OSStatus err = QTOpenGLTextureContextCreate(kCFAllocatorDefault, cglContext, - cglPixelFormat, NULL, &m_visualContext); - if (err != noErr) - qWarning() << "Could not create visual context (OpenGL)"; - - return (err == noErr); -#endif // QUICKTIME_C_API_AVAILABLE - - return false; -} - -#ifdef QUICKTIME_C_API_AVAILABLE -static bool DictionarySetValue(CFMutableDictionaryRef dict, CFStringRef key, SInt32 value) -{ - CFNumberRef number = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value); - - if (number) { - CFDictionarySetValue( dict, key, number ); - CFRelease( number ); - return true; - } - return false; -} -#endif // QUICKTIME_C_API_AVAILABLE - -bool QT7MovieRenderer::createPixelBufferVisualContext() -{ -#ifdef QUICKTIME_C_API_AVAILABLE - if (m_visualContext) { - QTVisualContextRelease(m_visualContext); - m_visualContext = 0; - } - - m_pixelBufferContextGeometry = m_nativeSize; - - CFMutableDictionaryRef pixelBufferOptions = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - //DictionarySetValue(pixelBufferOptions, kCVPixelBufferPixelFormatTypeKey, k32ARGBPixelFormat ); - DictionarySetValue(pixelBufferOptions, kCVPixelBufferPixelFormatTypeKey, k32BGRAPixelFormat ); - DictionarySetValue(pixelBufferOptions, kCVPixelBufferWidthKey, m_nativeSize.width() ); - DictionarySetValue(pixelBufferOptions, kCVPixelBufferHeightKey, m_nativeSize.height() ); - DictionarySetValue(pixelBufferOptions, kCVPixelBufferBytesPerRowAlignmentKey, 16); - //CFDictionarySetValue(pixelBufferOptions, kCVPixelBufferOpenGLCompatibilityKey, kCFBooleanTrue); - - CFMutableDictionaryRef visualContextOptions = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - CFDictionarySetValue(visualContextOptions, kQTVisualContextPixelBufferAttributesKey, pixelBufferOptions); - - CGColorSpaceRef colorSpace = NULL; - -#if USE_MAIN_MONITOR_COLOR_SPACE - CMProfileRef sysprof = NULL; - - // Get the Systems Profile for the main display - if (CMGetSystemProfile(&sysprof) == noErr) { - // Create a colorspace with the systems profile - colorSpace = CGColorSpaceCreateWithPlatformColorSpace(sysprof); - CMCloseProfile(sysprof); - } -#endif - - if (!colorSpace) - colorSpace = CGColorSpaceCreateDeviceRGB(); - - CFDictionarySetValue(visualContextOptions, kQTVisualContextOutputColorSpaceKey, colorSpace); - - OSStatus err = QTPixelBufferContextCreate(kCFAllocatorDefault, - visualContextOptions, - &m_visualContext); - CFRelease(pixelBufferOptions); - CFRelease(visualContextOptions); - - if (err != noErr) { - qWarning() << "Could not create visual context (PixelBuffer)"; - return false; - } - - return true; -#endif // QUICKTIME_C_API_AVAILABLE - - return false; -} - - -QT7MovieRenderer::~QT7MovieRenderer() -{ - m_displayLink->stop(); -} - -void QT7MovieRenderer::setupVideoOutput() -{ - AutoReleasePool pool; - -// qDebug() << "QT7MovieRenderer::setupVideoOutput" << m_movie; - - if (m_movie == 0 || m_surface == 0) { - m_displayLink->stop(); - return; - } - - NSSize size = [[(QTMovie*)m_movie attributeForKey:@"QTMovieNaturalSizeAttribute"] sizeValue]; - m_nativeSize = QSize(size.width, size.height); - -#ifdef QUICKTIME_C_API_AVAILABLE - bool usedGLContext = m_usingGLContext; - - if (!m_nativeSize.isEmpty()) { - - bool glSupported = !m_surface->supportedPixelFormats(QAbstractVideoBuffer::GLTextureHandle).isEmpty(); - - //Try rendering using opengl textures first: - if (glSupported) { - QVideoSurfaceFormat format(m_nativeSize, QVideoFrame::Format_RGB32, QAbstractVideoBuffer::GLTextureHandle); - - if (m_surface->isActive()) - m_surface->stop(); - -// qDebug() << "Starting the surface with format" << format; - if (!m_surface->start(format)) { -// qDebug() << "failed to start video surface" << m_surface->error(); - glSupported = false; - } else { - m_usingGLContext = true; - } - - } - - if (!glSupported) { - m_usingGLContext = false; - QVideoSurfaceFormat format(m_nativeSize, QVideoFrame::Format_RGB32); - - if (m_surface->isActive() && m_surface->surfaceFormat() != format) { -// qDebug() << "Surface format was changed, stop the surface."; - m_surface->stop(); - } - - if (!m_surface->isActive()) { -// qDebug() << "Starting the surface with format" << format; - m_surface->start(format); -// if (!m_surface->start(format)) -// qDebug() << "failed to start video surface" << m_surface->error(); - } - } - } - - - if (m_visualContext) { - //check if the visual context still can be reused - if (usedGLContext != m_usingGLContext || - (m_usingGLContext && (m_currentGLContext != QGLContext::currentContext())) || - (!m_usingGLContext && (m_pixelBufferContextGeometry != m_nativeSize))) { - QTVisualContextRelease(m_visualContext); - m_pixelBufferContextGeometry = QSize(); - m_visualContext = 0; - } - } - - if (!m_nativeSize.isEmpty()) { - if (!m_visualContext) { - if (m_usingGLContext) { -// qDebug() << "Building OpenGL visual context" << m_nativeSize; - m_currentGLContext = QGLContext::currentContext(); - if (!createGLVisualContext()) { - qWarning() << "QT7MovieRenderer: failed to create visual context"; - return; - } - } else { -// qDebug() << "Building Pixel Buffer visual context" << m_nativeSize; - if (!createPixelBufferVisualContext()) { - qWarning() << "QT7MovieRenderer: failed to create visual context"; - return; - } - } - } - - // targets a Movie to render into a visual context - SetMovieVisualContext([(QTMovie*)m_movie quickTimeMovie], m_visualContext); - - m_displayLink->start(); - } -#endif - -} - -void QT7MovieRenderer::setMovie(void *movie) -{ -// qDebug() << "QT7MovieRenderer::setMovie" << movie; - -#ifdef QUICKTIME_C_API_AVAILABLE - QMutexLocker locker(&m_mutex); - - if (m_movie != movie) { - if (m_movie) { - //ensure the old movie doesn't hold the visual context, otherwise it can't be reused - SetMovieVisualContext([(QTMovie*)m_movie quickTimeMovie], nil); - [(QTMovie*)m_movie release]; - } - - m_movie = movie; - [(QTMovie*)m_movie retain]; - - setupVideoOutput(); - } -#endif -} - -void QT7MovieRenderer::updateNaturalSize(const QSize &newSize) -{ - if (m_nativeSize != newSize) { - m_nativeSize = newSize; - setupVideoOutput(); - } -} - -QAbstractVideoSurface *QT7MovieRenderer::surface() const -{ - return m_surface; -} - -void QT7MovieRenderer::setSurface(QAbstractVideoSurface *surface) -{ -// qDebug() << "Set video surface" << surface; - - if (surface == m_surface) - return; - - QMutexLocker locker(&m_mutex); - - if (m_surface && m_surface->isActive()) - m_surface->stop(); - - m_surface = surface; - setupVideoOutput(); -} - - -QSize QT7MovieRenderer::nativeSize() const -{ - return m_nativeSize; -} - -void QT7MovieRenderer::updateVideoFrame(const CVTimeStamp &ts) -{ -#ifdef QUICKTIME_C_API_AVAILABLE - - QMutexLocker locker(&m_mutex); - - if (m_surface && m_surface->isActive() && - m_visualContext && QTVisualContextIsNewImageAvailable(m_visualContext, &ts)) { - - CVImageBufferRef imageBuffer = NULL; - - OSStatus status = QTVisualContextCopyImageForTime(m_visualContext, NULL, &ts, &imageBuffer); - - if (status == noErr && imageBuffer) { - QAbstractVideoBuffer *buffer = 0; - - if (m_usingGLContext) { - buffer = new QT7CIImageVideoBuffer([CIImage imageWithCVImageBuffer:imageBuffer]); - CVOpenGLTextureRelease((CVOpenGLTextureRef)imageBuffer); - } else { - buffer = new CVPixelBufferVideoBuffer((CVPixelBufferRef)imageBuffer); - //buffer = new QT7CIImageVideoBuffer( [CIImage imageWithCVImageBuffer:imageBuffer] ); - CVPixelBufferRelease((CVPixelBufferRef)imageBuffer); - } - - QVideoFrame frame(buffer, m_nativeSize, QVideoFrame::Format_RGB32); - m_surface->present(frame); - QTVisualContextTask(m_visualContext); - } - } -#else - Q_UNUSED(ts); -#endif -} - -#include "moc_qt7movierenderer.cpp" - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/qt7movievideowidget.h b/src/plugins/mediaservices/qt7/qt7movievideowidget.h deleted file mode 100644 index 3ff14f5..0000000 --- a/src/plugins/mediaservices/qt7/qt7movievideowidget.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 QT7MOVIEVIDEOWIDGET_H -#define QT7MOVIEVIDEOWIDGET_H - -#include <QtCore/qobject.h> -#include <QtCore/qmutex.h> - -#include <qvideowindowcontrol.h> -#include <qmediaplayer.h> - -#include <QtGui/qmacdefines_mac.h> -#include "qt7videooutputcontrol.h" - -#include <QuartzCore/CVOpenGLTexture.h> -#include <QuickTime/QuickTime.h> - - -QT_BEGIN_HEADER - - -QT_BEGIN_NAMESPACE - -class GLVideoWidget; -class QCvDisplayLink; -class QT7PlayerSession; -class QT7PlayerService; - -class QT7MovieVideoWidget : public QT7VideoWidgetControl -{ -Q_OBJECT -public: - QT7MovieVideoWidget(QObject *parent = 0); - virtual ~QT7MovieVideoWidget(); - - void setMovie(void *movie); - void updateNaturalSize(const QSize &newSize); - - QWidget *videoWidget(); - - bool isFullScreen() const; - void setFullScreen(bool fullScreen); - - QSize nativeSize() const; - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - 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); - -private slots: - void updateVideoFrame(const CVTimeStamp &ts); - -private: - void setupVideoOutput(); - bool createVisualContext(); - - void updateColors(); - - void *m_movie; - GLVideoWidget *m_videoWidget; - - QCvDisplayLink *m_displayLink; - -#ifdef QUICKTIME_C_API_AVAILABLE - QTVisualContextRef m_visualContext; -#endif - - bool m_fullscreen; - QSize m_nativeSize; - Qt::AspectRatioMode m_aspectRatioMode; - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/qt7movievideowidget.mm b/src/plugins/mediaservices/qt7/qt7movievideowidget.mm deleted file mode 100644 index 648d6b4..0000000 --- a/src/plugins/mediaservices/qt7/qt7movievideowidget.mm +++ /dev/null @@ -1,425 +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$ -** -****************************************************************************/ - -#import <QTKit/QTKit.h> - -#include "qt7backend.h" - -#include "qt7playercontrol.h" -#include "qt7movievideowidget.h" -#include "qt7playersession.h" -#include "qcvdisplaylink.h" -#include <QtCore/qdebug.h> -#include <QtCore/qcoreapplication.h> - -#include <QGLWidget> - -#import <QuartzCore/QuartzCore.h> - -#include "math.h" - -QT_BEGIN_NAMESPACE - -class GLVideoWidget : public QGLWidget -{ -public: - - GLVideoWidget(QWidget *parent, const QGLFormat &format) - : QGLWidget(format, parent), - m_texRef(0), - m_nativeSize(640,480), - m_aspectRatioMode(Qt::KeepAspectRatio) - { - setAutoFillBackground(false); - } - - void initializeGL() - { - QColor bgColor = palette().color(QPalette::Background); - glClearColor(bgColor.redF(), bgColor.greenF(), bgColor.blueF(), bgColor.alphaF()); - } - - void resizeGL(int w, int h) - { - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glViewport(0, 0, GLsizei(w), GLsizei(h)); - gluOrtho2D(0, GLsizei(w), 0, GLsizei(h)); - updateGL(); - } - - void paintGL() - { - glClear(GL_COLOR_BUFFER_BIT); - if (!m_texRef) - return; - - glPushMatrix(); - glDisable(GL_CULL_FACE); - GLenum target = CVOpenGLTextureGetTarget(m_texRef); - glEnable(target); - - glBindTexture(target, CVOpenGLTextureGetName(m_texRef)); - glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - GLfloat lowerLeft[2], lowerRight[2], upperRight[2], upperLeft[2]; - CVOpenGLTextureGetCleanTexCoords(m_texRef, lowerLeft, lowerRight, upperRight, upperLeft); - - glBegin(GL_QUADS); - QRect rect = displayRect(); - glTexCoord2f(lowerLeft[0], lowerLeft[1]); - glVertex2i(rect.topLeft().x(), rect.topLeft().y()); - glTexCoord2f(lowerRight[0], lowerRight[1]); - glVertex2i(rect.topRight().x() + 1, rect.topRight().y()); - glTexCoord2f(upperRight[0], upperRight[1]); - glVertex2i(rect.bottomRight().x() + 1, rect.bottomRight().y() + 1); - glTexCoord2f(upperLeft[0], upperLeft[1]); - glVertex2i(rect.bottomLeft().x(), rect.bottomLeft().y() + 1); - glEnd(); - glPopMatrix(); - } - - void setCVTexture(CVOpenGLTextureRef texRef) - { - if (m_texRef) - CVOpenGLTextureRelease(m_texRef); - - m_texRef = texRef; - - if (m_texRef) - CVOpenGLTextureRetain(m_texRef); - - if (isVisible()) { - makeCurrent(); - paintGL(); - swapBuffers(); - } - } - - QSize sizeHint() const - { - return m_nativeSize; - } - - void setNativeSize(const QSize &size) - { - m_nativeSize = size; - } - - void setAspectRatioMode(Qt::AspectRatioMode mode) - { - if (m_aspectRatioMode != mode) { - m_aspectRatioMode = mode; - update(); - } - } - -private: - QRect displayRect() const - { - QRect displayRect = rect(); - - if (m_aspectRatioMode == Qt::KeepAspectRatio) { - QSize size = m_nativeSize; - size.scale(displayRect.size(), Qt::KeepAspectRatio); - - displayRect = QRect(QPoint(0, 0), size); - displayRect.moveCenter(rect().center()); - } - return displayRect; - } - - CVOpenGLTextureRef m_texRef; - QSize m_nativeSize; - Qt::AspectRatioMode m_aspectRatioMode; -}; - -QT7MovieVideoWidget::QT7MovieVideoWidget(QObject *parent) - :QT7VideoWidgetControl(parent), - m_movie(0), - m_videoWidget(0), - m_fullscreen(false), - m_aspectRatioMode(Qt::KeepAspectRatio), - m_brightness(0), - m_contrast(0), - m_hue(0), - m_saturation(0) -{ -// qDebug() << "QT7MovieVideoWidget"; - - QGLFormat format = QGLFormat::defaultFormat(); - format.setSwapInterval(1); // Vertical sync (avoid tearing) - m_videoWidget = new GLVideoWidget(0, format); - - m_displayLink = new QCvDisplayLink(this); - - connect(m_displayLink, SIGNAL(tick(CVTimeStamp)), SLOT(updateVideoFrame(CVTimeStamp))); - - if (!createVisualContext()) { - qWarning() << "QT7MovieVideoWidget: failed to create visual context"; - } -} - -bool QT7MovieVideoWidget::createVisualContext() -{ -#ifdef QUICKTIME_C_API_AVAILABLE - m_videoWidget->makeCurrent(); - - AutoReleasePool pool; - CGLContextObj cglContext = CGLGetCurrentContext(); - NSOpenGLPixelFormat *nsglPixelFormat = [NSOpenGLView defaultPixelFormat]; - CGLPixelFormatObj cglPixelFormat = static_cast<CGLPixelFormatObj>([nsglPixelFormat CGLPixelFormatObj]); - - CFTypeRef keys[] = { kQTVisualContextOutputColorSpaceKey }; - CGColorSpaceRef colorSpace = NULL; - CMProfileRef sysprof = NULL; - - // Get the Systems Profile for the main display - if (CMGetSystemProfile(&sysprof) == noErr) { - // Create a colorspace with the systems profile - colorSpace = CGColorSpaceCreateWithPlatformColorSpace(sysprof); - CMCloseProfile(sysprof); - } - - if (!colorSpace) - colorSpace = CGColorSpaceCreateDeviceRGB(); - - CFDictionaryRef textureContextAttributes = CFDictionaryCreate(kCFAllocatorDefault, - (const void **)keys, - (const void **)&colorSpace, 1, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - - OSStatus err = QTOpenGLTextureContextCreate(kCFAllocatorDefault, - cglContext, - cglPixelFormat, - textureContextAttributes, - &m_visualContext); - if (err != noErr) - qWarning() << "Could not create visual context (OpenGL)"; - - - return (err == noErr); -#endif // QUICKTIME_C_API_AVAILABLE - - return false; -} - -QT7MovieVideoWidget::~QT7MovieVideoWidget() -{ - m_displayLink->stop(); - [(QTMovie*)m_movie release]; - delete m_videoWidget; -} - -QWidget *QT7MovieVideoWidget::videoWidget() -{ - return m_videoWidget; -} - -void QT7MovieVideoWidget::setupVideoOutput() -{ - AutoReleasePool pool; - -// qDebug() << "QT7MovieVideoWidget::setupVideoOutput" << m_movie; - - if (m_movie == 0) { - m_displayLink->stop(); - return; - } - - NSSize size = [[(QTMovie*)m_movie attributeForKey:@"QTMovieNaturalSizeAttribute"] sizeValue]; - m_nativeSize = QSize(size.width, size.height); - m_videoWidget->setNativeSize(m_nativeSize); - -#ifdef QUICKTIME_C_API_AVAILABLE - // targets a Movie to render into a visual context - SetMovieVisualContext([(QTMovie*)m_movie quickTimeMovie], m_visualContext); -#endif - - m_displayLink->start(); -} - -void QT7MovieVideoWidget::setMovie(void *movie) -{ - if (m_movie == movie) - return; - - if (m_movie) { -#ifdef QUICKTIME_C_API_AVAILABLE - SetMovieVisualContext([(QTMovie*)m_movie quickTimeMovie], nil); -#endif - [(QTMovie*)m_movie release]; - } - - m_movie = movie; - [(QTMovie*)m_movie retain]; - - setupVideoOutput(); -} - -void QT7MovieVideoWidget::updateNaturalSize(const QSize &newSize) -{ - if (m_nativeSize != newSize) { - m_nativeSize = newSize; - setupVideoOutput(); - } -} - -bool QT7MovieVideoWidget::isFullScreen() const -{ - return m_fullscreen; -} - -void QT7MovieVideoWidget::setFullScreen(bool fullScreen) -{ - m_fullscreen = fullScreen; -} - -QSize QT7MovieVideoWidget::nativeSize() const -{ - return m_nativeSize; -} - -Qt::AspectRatioMode QT7MovieVideoWidget::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void QT7MovieVideoWidget::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_aspectRatioMode = mode; - m_videoWidget->setAspectRatioMode(mode); -} - -int QT7MovieVideoWidget::brightness() const -{ - return m_brightness; -} - -void QT7MovieVideoWidget::setBrightness(int brightness) -{ - m_brightness = brightness; - updateColors(); -} - -int QT7MovieVideoWidget::contrast() const -{ - return m_contrast; -} - -void QT7MovieVideoWidget::setContrast(int contrast) -{ - m_contrast = contrast; - updateColors(); -} - -int QT7MovieVideoWidget::hue() const -{ - return m_hue; -} - -void QT7MovieVideoWidget::setHue(int hue) -{ - m_hue = hue; - updateColors(); -} - -int QT7MovieVideoWidget::saturation() const -{ - return m_saturation; -} - -void QT7MovieVideoWidget::setSaturation(int saturation) -{ - m_saturation = saturation; - updateColors(); -} - -void QT7MovieVideoWidget::updateColors() -{ -#ifdef QUICKTIME_C_API_AVAILABLE - if (m_movie) { - QTMovie *movie = (QTMovie*)m_movie; - - Float32 value; - value = m_brightness/100.0; - SetMovieVisualBrightness([movie quickTimeMovie], value, 0); - value = pow(2, m_contrast/50.0); - SetMovieVisualContrast([movie quickTimeMovie], value, 0); - value = m_hue/100.0; - SetMovieVisualHue([movie quickTimeMovie], value, 0); - value = 1.0+m_saturation/100.0; - SetMovieVisualSaturation([movie quickTimeMovie], value, 0); - } -#endif -} - -void QT7MovieVideoWidget::updateVideoFrame(const CVTimeStamp &ts) -{ -#ifdef QUICKTIME_C_API_AVAILABLE - AutoReleasePool pool; - // check for new frame - if (m_visualContext && QTVisualContextIsNewImageAvailable(m_visualContext, &ts)) { - CVOpenGLTextureRef currentFrame = NULL; - - // get a "frame" (image buffer) from the Visual Context, indexed by the provided time - OSStatus status = QTVisualContextCopyImageForTime(m_visualContext, NULL, &ts, ¤tFrame); - - // the above call may produce a null frame so check for this first - // if we have a frame, then draw it - if (status == noErr && currentFrame) { - //qDebug() << "render video frame"; - m_videoWidget->setCVTexture(currentFrame); - CVOpenGLTextureRelease(currentFrame); - } - QTVisualContextTask(m_visualContext); - } -#else - Q_UNUSED(ts); -#endif -} - -#include "moc_qt7movievideowidget.cpp" - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/qt7movieviewoutput.h b/src/plugins/mediaservices/qt7/qt7movieviewoutput.h deleted file mode 100644 index d6bfd14..0000000 --- a/src/plugins/mediaservices/qt7/qt7movieviewoutput.h +++ /dev/null @@ -1,119 +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 QT7MOVIEVIEWOUTPUT_H -#define QT7MOVIEVIEWOUTPUT_H - -#include <QtCore/qobject.h> - -#include <QtMediaServices/qvideowindowcontrol.h> -#include <QtMediaServices/qmediaplayer.h> - -#include <QtGui/qmacdefines_mac.h> -#include "qt7videooutputcontrol.h" - - -QT_BEGIN_HEADER -QT_BEGIN_NAMESPACE - -class QT7PlayerSession; -class QT7PlayerService; - -class QT7MovieViewOutput : public QT7VideoWindowControl -{ -public: - QT7MovieViewOutput(QObject *parent = 0); - ~QT7MovieViewOutput(); - - void setMovie(void *movie); - void updateNaturalSize(const QSize &newSize); - - WId winId() const; - void setWinId(WId id); - - QRect displayRect() const; - void setDisplayRect(const QRect &rect); - - bool isFullScreen() const; - void setFullScreen(bool fullScreen); - - void repaint(); - - QSize nativeSize() const; - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - 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); - -private: - void setupVideoOutput(); - - void *m_movie; - void *m_movieView; - bool m_layouted; - - WId m_winId; - QRect m_displayRect; - bool m_fullscreen; - QSize m_nativeSize; - Qt::AspectRatioMode m_aspectRatioMode; - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm b/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm deleted file mode 100644 index 06299a3..0000000 --- a/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm +++ /dev/null @@ -1,335 +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$ -** -****************************************************************************/ - -#import <QTKit/QTKit.h> - -#include "qt7backend.h" - -#include "qt7playercontrol.h" -#include "qt7movieviewoutput.h" -#include "qt7playersession.h" -#include <QtCore/qdebug.h> - -#include <QuartzCore/CIFilter.h> -#include <QuartzCore/CIVector.h> - - -#define VIDEO_TRANSPARENT(m) -(void)m:(NSEvent *)e{[[self superview] m:e];} - -@interface TransparentQTMovieView : QTMovieView -{ -@private - QRect *m_drawRect; - qreal m_brightness, m_contrast, m_saturation, m_hue; -} - -- (TransparentQTMovieView *) init; -- (void) setDrawRect:(QRect &)rect; -- (CIImage *) view:(QTMovieView *)view willDisplayImage:(CIImage *)img; -- (void) setContrast:(qreal) contrast; -@end - -@implementation TransparentQTMovieView - -- (TransparentQTMovieView *) init -{ - self = [super initWithFrame:NSZeroRect]; - if (self) { - [self setControllerVisible:NO]; - [self setContrast:1.0]; - [self setDelegate:self]; - } - return self; -} - -- (void) dealloc -{ - [super dealloc]; -} - -- (void) setContrast:(qreal) contrast -{ - m_hue = 0.0; - m_brightness = 0.0; - m_contrast = contrast; - m_saturation = 1.0; -} - - -- (void) setDrawRect:(QRect &)rect -{ - *m_drawRect = rect; - - NSRect nsrect; - nsrect.origin.x = m_drawRect->x(); - nsrect.origin.y = m_drawRect->y(); - nsrect.size.width = m_drawRect->width(); - nsrect.size.height = m_drawRect->height(); - [self setFrame:nsrect]; -} - -- (CIImage *) view:(QTMovieView *)view willDisplayImage:(CIImage *)img -{ - // This method is called from QTMovieView just - // before the image will be drawn. - Q_UNUSED(view); - - if ( !qFuzzyCompare(m_brightness, 0.0) || - !qFuzzyCompare(m_contrast, 1.0) || - !qFuzzyCompare(m_saturation, 1.0)){ - CIFilter *colorFilter = [CIFilter filterWithName:@"CIColorControls"]; - [colorFilter setValue:[NSNumber numberWithFloat:m_brightness] forKey:@"inputBrightness"]; - [colorFilter setValue:[NSNumber numberWithFloat:(m_contrast < 1) ? m_contrast : 1 + ((m_contrast-1)*3)] forKey:@"inputContrast"]; - [colorFilter setValue:[NSNumber numberWithFloat:m_saturation] forKey:@"inputSaturation"]; - [colorFilter setValue:img forKey:@"inputImage"]; - img = [colorFilter valueForKey:@"outputImage"]; - } - - /*if (m_hue){ - CIFilter *colorFilter = [CIFilter filterWithName:@"CIHueAdjust"]; - [colorFilter setValue:[NSNumber numberWithFloat:(m_hue * 3.14)] forKey:@"inputAngle"]; - [colorFilter setValue:img forKey:@"inputImage"]; - img = [colorFilter valueForKey:@"outputImage"]; - }*/ - - return img; -} - - -VIDEO_TRANSPARENT(mouseDown); -VIDEO_TRANSPARENT(mouseDragged); -VIDEO_TRANSPARENT(mouseUp); -VIDEO_TRANSPARENT(mouseMoved); -VIDEO_TRANSPARENT(mouseEntered); -VIDEO_TRANSPARENT(mouseExited); -VIDEO_TRANSPARENT(rightMouseDown); -VIDEO_TRANSPARENT(rightMouseDragged); -VIDEO_TRANSPARENT(rightMouseUp); -VIDEO_TRANSPARENT(otherMouseDown); -VIDEO_TRANSPARENT(otherMouseDragged); -VIDEO_TRANSPARENT(otherMouseUp); -VIDEO_TRANSPARENT(keyDown); -VIDEO_TRANSPARENT(keyUp); -VIDEO_TRANSPARENT(scrollWheel) - -@end - - -QT7MovieViewOutput::QT7MovieViewOutput(QObject *parent) - :QT7VideoWindowControl(parent), - m_movie(0), - m_movieView(0), - m_layouted(false), - m_winId(0), - m_fullscreen(false), - m_aspectRatioMode(Qt::KeepAspectRatio), - m_brightness(0), - m_contrast(0), - m_hue(0), - m_saturation(0) -{ -} - -QT7MovieViewOutput::~QT7MovieViewOutput() -{ - [(QTMovieView*)m_movieView release]; - [(QTMovie*)m_movie release]; -} - -void QT7MovieViewOutput::setupVideoOutput() -{ - AutoReleasePool pool; - - //qDebug() << "QT7MovieViewOutput::setupVideoOutput" << m_movie << m_winId; - if (m_movie == 0 || m_winId <= 0) - return; - - NSSize size = [[(QTMovie*)m_movie attributeForKey:@"QTMovieNaturalSizeAttribute"] sizeValue]; - m_nativeSize = QSize(size.width, size.height); - - if (!m_movieView) - m_movieView = [[TransparentQTMovieView alloc] init]; - - [(QTMovieView*)m_movieView setControllerVisible:NO]; - [(QTMovieView*)m_movieView setMovie:(QTMovie*)m_movie]; - - [(NSView *)m_winId addSubview:(QTMovieView*)m_movieView]; - m_layouted = true; - - setDisplayRect(m_displayRect); -} - -void QT7MovieViewOutput::setMovie(void *movie) -{ - if (m_movie != movie) { - if (m_movie) { - if (m_movieView) - [(QTMovieView*)m_movieView setMovie:nil]; - - [(QTMovie*)m_movie release]; - } - - m_movie = movie; - - if (m_movie) - [(QTMovie*)m_movie retain]; - - setupVideoOutput(); - } -} - -void QT7MovieViewOutput::updateNaturalSize(const QSize &newSize) -{ - if (m_nativeSize != newSize) { - m_nativeSize = newSize; - emit nativeSizeChanged(); - } -} - -WId QT7MovieViewOutput::winId() const -{ - return m_winId; -} - -void QT7MovieViewOutput::setWinId(WId id) -{ - if (m_winId != id) { - if (m_movieView && m_layouted) { - [(QTMovieView*)m_movieView removeFromSuperview]; - m_layouted = false; - } - - m_winId = id; - setupVideoOutput(); - } -} - -QRect QT7MovieViewOutput::displayRect() const -{ - return m_displayRect; -} - -void QT7MovieViewOutput::setDisplayRect(const QRect &rect) -{ - m_displayRect = rect; - - if (m_movieView) { - AutoReleasePool pool; - [(QTMovieView*)m_movieView setPreservesAspectRatio:(m_aspectRatioMode == Qt::KeepAspectRatio ? YES : NO)]; - [(QTMovieView*)m_movieView setFrame:NSMakeRect(m_displayRect.x(), - m_displayRect.y(), - m_displayRect.width(), - m_displayRect.height())]; - } - -} - -bool QT7MovieViewOutput::isFullScreen() const -{ - return m_fullscreen; -} - -void QT7MovieViewOutput::setFullScreen(bool fullScreen) -{ - m_fullscreen = fullScreen; - setDisplayRect(m_displayRect); -} - -void QT7MovieViewOutput::repaint() -{ -} - -QSize QT7MovieViewOutput::nativeSize() const -{ - return m_nativeSize; -} - -Qt::AspectRatioMode QT7MovieViewOutput::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void QT7MovieViewOutput::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_aspectRatioMode = mode; - setDisplayRect(m_displayRect); -} - -int QT7MovieViewOutput::brightness() const -{ - return m_brightness; -} - -void QT7MovieViewOutput::setBrightness(int brightness) -{ - m_brightness = brightness; -} - -int QT7MovieViewOutput::contrast() const -{ - return m_contrast; -} - -void QT7MovieViewOutput::setContrast(int contrast) -{ - m_contrast = contrast; - [(TransparentQTMovieView*)m_movieView setContrast:(contrast/100.0+1.0)]; -} - -int QT7MovieViewOutput::hue() const -{ - return m_hue; -} - -void QT7MovieViewOutput::setHue(int hue) -{ - m_hue = hue; -} - -int QT7MovieViewOutput::saturation() const -{ - return m_saturation; -} - -void QT7MovieViewOutput::setSaturation(int saturation) -{ - m_saturation = saturation; -} diff --git a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.h b/src/plugins/mediaservices/qt7/qt7movieviewrenderer.h deleted file mode 100644 index fa4db4d..0000000 --- a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.h +++ /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$ -** -****************************************************************************/ - -#ifndef QT7MOVIEVIEWRENDERER_H -#define QT7MOVIEVIEWRENDERER_H - -#include <QtCore/qobject.h> -#include <QtCore/qmutex.h> - -#include <QtMediaServices/qvideowindowcontrol.h> -#include <QtMediaServices/qmediaplayer.h> - -#include <QtGui/qmacdefines_mac.h> -#include "qt7videooutputcontrol.h" -#include <QtMultimedia/qvideoframe.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QVideoFrame; -class QT7PlayerSession; -class QT7PlayerService; - -class QT7MovieViewRenderer : public QT7VideoRendererControl -{ -public: - QT7MovieViewRenderer(QObject *parent = 0); - ~QT7MovieViewRenderer(); - - void setMovie(void *movie); - void updateNaturalSize(const QSize &newSize); - - QAbstractVideoSurface *surface() const; - void setSurface(QAbstractVideoSurface *surface); - - void renderFrame(const QVideoFrame &); - -protected: - bool event(QEvent *event); - -private: - void setupVideoOutput(); - - void *m_movie; - void *m_movieView; - QSize m_nativeSize; - QAbstractVideoSurface *m_surface; - QVideoFrame m_currentFrame; - bool m_pendingRenderEvent; - QMutex m_mutex; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm b/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm deleted file mode 100644 index 5af9809..0000000 --- a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm +++ /dev/null @@ -1,366 +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$ -** -****************************************************************************/ - -#import <QTKit/QTKit.h> - -#include "qt7backend.h" - -#include "qt7playercontrol.h" -#include "qt7movieviewrenderer.h" -#include "qt7playersession.h" -#include "qt7ciimagevideobuffer.h" -#include <QtCore/qdebug.h> -#include <QtCore/qcoreevent.h> -#include <QtCore/qcoreapplication.h> - -#include <QtMultimedia/qabstractvideobuffer.h> -#include <QtMultimedia/qabstractvideosurface.h> -#include <QtMultimedia/qvideosurfaceformat.h> - -#include <QuartzCore/CIFilter.h> -#include <QuartzCore/CIVector.h> - - -QT_BEGIN_NAMESPACE - -class NSBitmapVideoBuffer : public QAbstractVideoBuffer -{ -public: - NSBitmapVideoBuffer(NSBitmapImageRep *buffer) - : QAbstractVideoBuffer(NoHandle) - , m_buffer(buffer) - , m_mode(NotMapped) - { - [m_buffer retain]; - } - - virtual ~NSBitmapVideoBuffer() - { - [m_buffer release]; - } - - MapMode mapMode() const { return m_mode; } - - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine) - { - if (mode != NotMapped && m_mode == NotMapped) { - if (numBytes) - *numBytes = [m_buffer bytesPerPlane]; - - if (bytesPerLine) - *bytesPerLine = [m_buffer bytesPerRow]; - - m_mode = mode; - - return [m_buffer bitmapData]; - } else { - return 0; - } - } - - void unmap() { m_mode = NotMapped; } - -private: - NSBitmapImageRep *m_buffer; - MapMode m_mode; -}; - -QT_END_NAMESPACE - -#define VIDEO_TRANSPARENT(m) -(void)m:(NSEvent *)e{[[self superview] m:e];} - -@interface HiddenQTMovieView : QTMovieView -{ -@private - QWidget *m_window; - QT7MovieViewRenderer *m_renderer; -} - -- (HiddenQTMovieView *) initWithRenderer:(QT7MovieViewRenderer *)renderer; -- (void) setRenderer:(QT7MovieViewRenderer *)renderer; -- (void) setDrawRect:(const QRect &)rect; -- (CIImage *) view:(QTMovieView *)view willDisplayImage:(CIImage *)img; -@end - -@implementation HiddenQTMovieView - -- (HiddenQTMovieView *) initWithRenderer:(QT7MovieViewRenderer *)renderer -{ - self = [super initWithFrame:NSZeroRect]; - if (self) { - [self setControllerVisible:NO]; - [self setDelegate:self]; - - self->m_renderer = renderer; - - self->m_window = new QWidget; - self->m_window->setWindowOpacity(0.0); - self->m_window->show(); - self->m_window->hide(); - - [(NSView *)(self->m_window->winId()) addSubview:self]; - [self setDrawRect:QRect(0,0,1,1)]; - } - return self; -} - -- (void) dealloc -{ - [super dealloc]; -} - -- (void) setRenderer:(QT7MovieViewRenderer *)renderer -{ - m_renderer = renderer; -} - -- (void) setDrawRect:(const QRect &)rect -{ - NSRect nsrect; - nsrect.origin.x = rect.x(); - nsrect.origin.y = rect.y(); - nsrect.size.width = rect.width(); - nsrect.size.height = rect.height(); - [self setFrame:nsrect]; -} - -- (CIImage *) view:(QTMovieView *)view willDisplayImage:(CIImage *)img -{ - // This method is called from QTMovieView just - // before the image will be drawn. - Q_UNUSED(view); - if (m_renderer) { - CGRect bounds = [img extent]; - int w = bounds.size.width; - int h = bounds.size.height; - - QVideoFrame frame; - - QAbstractVideoSurface *surface = m_renderer->surface(); - if (!surface || !surface->isActive()) - return img; - - if (surface->surfaceFormat().handleType() == QAbstractVideoBuffer::CoreImageHandle) { - //surface supports rendering of opengl based CIImage - frame = QVideoFrame(new QT7CIImageVideoBuffer(img), QSize(w,h), QVideoFrame::Format_RGB32 ); - } else { - //Swap R and B colors - CIFilter *colorSwapFilter = [CIFilter filterWithName: @"CIColorMatrix" keysAndValues: - @"inputImage", img, - @"inputRVector", [CIVector vectorWithX: 0 Y: 0 Z: 1 W: 0], - @"inputGVector", [CIVector vectorWithX: 0 Y: 1 Z: 0 W: 0], - @"inputBVector", [CIVector vectorWithX: 1 Y: 0 Z: 0 W: 0], - @"inputAVector", [CIVector vectorWithX: 0 Y: 0 Z: 0 W: 1], - @"inputBiasVector", [CIVector vectorWithX: 0 Y: 0 Z: 0 W: 0], - nil]; - CIImage *img = [colorSwapFilter valueForKey: @"outputImage"]; - NSBitmapImageRep *bitmap =[[NSBitmapImageRep alloc] initWithCIImage:img]; - //requesting the bitmap data is slow, - //but it's better to do it here to avoid blocking the main thread for a long. - [bitmap bitmapData]; - frame = QVideoFrame(new NSBitmapVideoBuffer(bitmap), QSize(w,h), QVideoFrame::Format_RGB32 ); - [bitmap release]; - } - - if (m_renderer) - m_renderer->renderFrame(frame); - } - - return img; -} - -// Override this method so that the movie doesn't stop if -// the window becomes invisible -- (void)viewWillMoveToWindow:(NSWindow *)newWindow -{ - Q_UNUSED(newWindow); -} - - -VIDEO_TRANSPARENT(mouseDown); -VIDEO_TRANSPARENT(mouseDragged); -VIDEO_TRANSPARENT(mouseUp); -VIDEO_TRANSPARENT(mouseMoved); -VIDEO_TRANSPARENT(mouseEntered); -VIDEO_TRANSPARENT(mouseExited); -VIDEO_TRANSPARENT(rightMouseDown); -VIDEO_TRANSPARENT(rightMouseDragged); -VIDEO_TRANSPARENT(rightMouseUp); -VIDEO_TRANSPARENT(otherMouseDown); -VIDEO_TRANSPARENT(otherMouseDragged); -VIDEO_TRANSPARENT(otherMouseUp); -VIDEO_TRANSPARENT(keyDown); -VIDEO_TRANSPARENT(keyUp); -VIDEO_TRANSPARENT(scrollWheel) - -@end - -QT_BEGIN_NAMESPACE - -QT7MovieViewRenderer::QT7MovieViewRenderer(QObject *parent) - :QT7VideoRendererControl(parent), - m_movie(0), - m_movieView(0), - m_surface(0), - m_pendingRenderEvent(false) -{ -} - -QT7MovieViewRenderer::~QT7MovieViewRenderer() -{ - [(HiddenQTMovieView*)m_movieView setRenderer:0]; - - QMutexLocker locker(&m_mutex); - m_currentFrame = QVideoFrame(); - [(HiddenQTMovieView*)m_movieView release]; -} - -void QT7MovieViewRenderer::setupVideoOutput() -{ - AutoReleasePool pool; - -// qDebug() << "QT7MovieViewRenderer::setupVideoOutput" << m_movie << m_surface; - - HiddenQTMovieView *movieView = (HiddenQTMovieView*)m_movieView; - - if (movieView && !m_movie) { - [movieView setMovie:nil]; - } - - if (m_movie) { - NSSize size = [[(QTMovie*)m_movie attributeForKey:@"QTMovieNaturalSizeAttribute"] sizeValue]; - - m_nativeSize = QSize(size.width, size.height); - - if (!movieView) { - movieView = [[HiddenQTMovieView alloc] initWithRenderer:this]; - m_movieView = movieView; - [movieView setControllerVisible:NO]; - } - - [movieView setMovie:(QTMovie*)m_movie]; - [movieView setDrawRect:QRect(QPoint(0,0), m_nativeSize)]; - } - - if (m_surface && !m_nativeSize.isEmpty()) { - bool coreImageFrameSupported = !m_surface->supportedPixelFormats(QAbstractVideoBuffer::CoreImageHandle).isEmpty() && - !m_surface->supportedPixelFormats(QAbstractVideoBuffer::GLTextureHandle).isEmpty(); - - QVideoSurfaceFormat format(m_nativeSize, QVideoFrame::Format_RGB32, - coreImageFrameSupported ? QAbstractVideoBuffer::CoreImageHandle : QAbstractVideoBuffer::NoHandle); - - if (m_surface->isActive() && m_surface->surfaceFormat() != format) { -// qDebug() << "Surface format was changed, stop the surface."; - m_surface->stop(); - } - - if (!m_surface->isActive()) { - //qDebug() << "Starting the surface with format" << format; - if (!m_surface->start(format)) { - qWarning() << "Failed to start video surface" << m_surface->error(); - qWarning() << "Surface format:" << format; - } - } - } -} - -void QT7MovieViewRenderer::setMovie(void *movie) -{ - if (movie == m_movie) - return; - - QMutexLocker locker(&m_mutex); - m_movie = movie; - setupVideoOutput(); -} - -void QT7MovieViewRenderer::updateNaturalSize(const QSize &newSize) -{ - if (m_nativeSize != newSize) { - m_nativeSize = newSize; - setupVideoOutput(); - } -} - -QAbstractVideoSurface *QT7MovieViewRenderer::surface() const -{ - return m_surface; -} - -void QT7MovieViewRenderer::setSurface(QAbstractVideoSurface *surface) -{ - if (surface == m_surface) - return; - - QMutexLocker locker(&m_mutex); - - if (m_surface && m_surface->isActive()) - m_surface->stop(); - - m_surface = surface; - setupVideoOutput(); -} - -void QT7MovieViewRenderer::renderFrame(const QVideoFrame &frame) -{ - - QMutexLocker locker(&m_mutex); - m_currentFrame = frame; - - if (!m_pendingRenderEvent) - qApp->postEvent(this, new QEvent(QEvent::User), Qt::HighEventPriority); - - m_pendingRenderEvent = true; -} - -bool QT7MovieViewRenderer::event(QEvent *event) -{ - if (event->type() == QEvent::User) { - QMutexLocker locker(&m_mutex); - m_pendingRenderEvent = false; - if (m_surface->isActive()) - m_surface->present(m_currentFrame); - } - - return QT7VideoRendererControl::event(event); -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/qt7serviceplugin.h b/src/plugins/mediaservices/qt7/qt7serviceplugin.h deleted file mode 100644 index 3871e10..0000000 --- a/src/plugins/mediaservices/qt7/qt7serviceplugin.h +++ /dev/null @@ -1,64 +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 QT7SERVICEPLUGIN_H -#define QT7SERVICEPLUGIN_H - -#include <QtMediaServices/qmediaserviceproviderplugin.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QT7ServicePlugin : public QMediaServiceProviderPlugin -{ -public: - QStringList keys() const; - QMediaService* create(QString const& key); - void release(QMediaService *service); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QGSTREAMERSERVICEPLUGIN_H diff --git a/src/plugins/mediaservices/qt7/qt7serviceplugin.mm b/src/plugins/mediaservices/qt7/qt7serviceplugin.mm deleted file mode 100644 index 92b472f..0000000 --- a/src/plugins/mediaservices/qt7/qt7serviceplugin.mm +++ /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$ -** -****************************************************************************/ - -#include <QtCore/qstring.h> -#include <QtCore/qdebug.h> - -#include "qt7serviceplugin.h" -#include "qt7playerservice.h" - -#include <QtMediaServices/qmediaserviceprovider.h> - -QT_BEGIN_NAMESPACE - -QStringList QT7ServicePlugin::keys() const -{ - return QStringList() -#ifdef QMEDIA_QT7_PLAYER - << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); -#endif -} - -QMediaService* QT7ServicePlugin::create(QString const& key) -{ -#ifdef QMEDIA_QT7_PLAYER - if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)) - return new QT7PlayerService; -#endif - - qWarning() << "Attempt to create unknown service with key" << key; - return 0; -} - -void QT7ServicePlugin::release(QMediaService *service) -{ - delete service; -} - -Q_EXPORT_PLUGIN2(qt7_serviceplugin, QT7ServicePlugin); - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/qt7videooutputcontrol.h b/src/plugins/mediaservices/qt7/qt7videooutputcontrol.h deleted file mode 100644 index 76066ba..0000000 --- a/src/plugins/mediaservices/qt7/qt7videooutputcontrol.h +++ /dev/null @@ -1,135 +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 QT7VIDEOOUTPUTCONTROL_H -#define QT7VIDEOOUTPUTCONTROL_H - -#include <QtCore/qobject.h> -#include <QtCore/qsize.h> - -#include <QtMediaServices/qvideooutputcontrol.h> -#include <QtMediaServices/qvideowindowcontrol.h> -#include <QtMediaServices/qvideowidgetcontrol.h> -#include <QtMediaServices/qvideorenderercontrol.h> -#include <QtMediaServices/qmediaplayer.h> - -#include <QtGui/qmacdefines_mac.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMediaPlaylist; -class QMediaPlaylistNavigator; -class QT7PlayerSession; -class QT7PlayerService; - - -class QT7VideoOutput { -public: - virtual ~QT7VideoOutput() {} - virtual void setMovie(void *movie) = 0; - virtual void updateNaturalSize(const QSize &newSize) = 0; -}; - -class QT7VideoWindowControl : public QVideoWindowControl, public QT7VideoOutput -{ -public: - virtual ~QT7VideoWindowControl() {} - -protected: - QT7VideoWindowControl(QObject *parent) - :QVideoWindowControl(parent) - {} -}; - -class QT7VideoRendererControl : public QVideoRendererControl, public QT7VideoOutput -{ -public: - virtual ~QT7VideoRendererControl() {} - -protected: - QT7VideoRendererControl(QObject *parent) - :QVideoRendererControl(parent) - {} -}; - -class QT7VideoWidgetControl : public QVideoWidgetControl, public QT7VideoOutput -{ -public: - virtual ~QT7VideoWidgetControl() {} - -protected: - QT7VideoWidgetControl(QObject *parent) - :QVideoWidgetControl(parent) - {} -}; - -class QT7VideoOutputControl : public QVideoOutputControl -{ -Q_OBJECT -public: - QT7VideoOutputControl(QObject *parent = 0); - ~QT7VideoOutputControl(); - - void setSession(QT7PlayerSession *session); - - QList<Output> availableOutputs() const; - void enableOutput(Output); - - Output output() const; - void setOutput(Output output); - -signals: - void videoOutputChanged(QVideoOutputControl::Output); - -private: - QT7PlayerSession *m_session; - Output m_output; - QList<Output> m_outputs; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/plugins/mediaservices/qt7/qt7videooutputcontrol.mm b/src/plugins/mediaservices/qt7/qt7videooutputcontrol.mm deleted file mode 100644 index a468431..0000000 --- a/src/plugins/mediaservices/qt7/qt7videooutputcontrol.mm +++ /dev/null @@ -1,93 +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 "qt7playercontrol.h" -#include "qt7videooutputcontrol.h" -#include "qt7playersession.h" -#include <QtCore/qdebug.h> - -QT_BEGIN_NAMESPACE - -QT7VideoOutputControl::QT7VideoOutputControl(QObject *parent) - :QVideoOutputControl(parent), - m_session(0), - m_output(QVideoOutputControl::NoOutput) -{ -} - -QT7VideoOutputControl::~QT7VideoOutputControl() -{ -} - -void QT7VideoOutputControl::setSession(QT7PlayerSession *session) -{ - m_session = session; -} - -QList<QVideoOutputControl::Output> QT7VideoOutputControl::availableOutputs() const -{ - return m_outputs; -} - -void QT7VideoOutputControl::enableOutput(QVideoOutputControl::Output output) -{ - if (!m_outputs.contains(output)) - m_outputs.append(output); -} - -QVideoOutputControl::Output QT7VideoOutputControl::output() const -{ - return m_output; -} - -void QT7VideoOutputControl::setOutput(Output output) -{ - if (m_output != output) { - m_output = output; - emit videoOutputChanged(m_output); - } - -} - -QT_END_NAMESPACE - -#include "moc_qt7videooutputcontrol.cpp" - diff --git a/src/plugins/mediaservices/symbian/mediaplayer/mediaplayer.pri b/src/plugins/mediaservices/symbian/mediaplayer/mediaplayer.pri deleted file mode 100644 index 205e014..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/mediaplayer.pri +++ /dev/null @@ -1,63 +0,0 @@ -INCLUDEPATH += $$PWD -LIBS += -lmediaclientvideo \ - -lmediaclientaudio \ - -lws32 \ - -lfbscli \ - -lcone \ - -lmmfcontrollerframework \ - -lefsrv \ - -lbitgdi \ - -lapgrfx \ - -lapmime - - -# We are building Symbian backend with media player support -DEFINES += QMEDIA_MMF_PLAYER - - -HEADERS += \ - $$PWD/s60mediaplayercontrol.h \ - $$PWD/s60mediaplayerservice.h \ - $$PWD/s60mediaplayersession.h \ - $$PWD/s60videoplayersession.h \ - $$PWD/s60mediametadataprovider.h \ - $$PWD/s60videosurface.h \ - $$PWD/s60videooverlay.h \ - $$PWD/s60videorenderer.h \ - $$PWD/s60mediarecognizer.h \ - $$PWD/s60audioplayersession.h \ - $$PWD/ms60mediaplayerresolver.h \ - $$PWD/s60videowidget.h \ - $$PWD/s60mediaplayeraudioendpointselector.h - -SOURCES += \ - $$PWD/s60mediaplayercontrol.cpp \ - $$PWD/s60mediaplayerservice.cpp \ - $$PWD/s60mediaplayersession.cpp \ - $$PWD/s60videoplayersession.cpp \ - $$PWD/s60mediametadataprovider.cpp \ - $$PWD/s60videosurface.cpp \ - $$PWD/s60videooverlay.cpp \ - $$PWD/s60videorenderer.cpp \ - $$PWD/s60mediarecognizer.cpp \ - $$PWD/s60audioplayersession.cpp \ - $$PWD/s60videowidget.cpp \ - $$PWD/s60mediaplayeraudioendpointselector.cpp - -contains(S60_VERSION, 3.1) { - - #3.1 doesn't provide audio routing in videoplayer - DEFINES += HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER - - !exists($${EPOCROOT}epoc32\release\winscw\udeb\audiooutputrouting.lib) { - MMP_RULES += "$${LITERAL_HASH}ifdef WINSCW" \ - "MACRO HAS_NO_AUDIOROUTING" \ - "$${LITERAL_HASH}else" \ - "LIBRARY audiooutputrouting.lib" \ - "$${LITERAL_HASH}endif" - } - -} else { - LIBS += -laudiooutputrouting -} - diff --git a/src/plugins/mediaservices/symbian/mediaplayer/ms60mediaplayerresolver.h b/src/plugins/mediaservices/symbian/mediaplayer/ms60mediaplayerresolver.h deleted file mode 100644 index b655a83..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/ms60mediaplayerresolver.h +++ /dev/null @@ -1,58 +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 MS60MEDIAPLAYERRESOLVER_H -#define MS60MEDIAPLAYERRESOLVER_H - -QT_BEGIN_NAMESPACE - -class S60MediaPlayerSession; - -class MS60MediaPlayerResolver -{ - public: - virtual S60MediaPlayerSession* PlayerSession() = 0; - virtual S60MediaPlayerSession* VideoPlayerSession() = 0; - virtual S60MediaPlayerSession* AudioPlayerSession() = 0; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.cpp deleted file mode 100644 index 1bebe0a..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.cpp +++ /dev/null @@ -1,275 +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 "s60audioplayersession.h" -#include <QtCore/qdebug.h> -#include <QtCore/qvariant.h> - -#include <AudioOutput.h> -#include <MAudioOutputObserver.h> - -QT_BEGIN_NAMESPACE - -S60AudioPlayerSession::S60AudioPlayerSession(QObject *parent) - : S60MediaPlayerSession(parent) - , m_player(0) - , m_audioEndpoint("Default") -{ -#ifndef HAS_NO_AUDIOROUTING - m_audioOutput = 0; -#endif - QT_TRAP_THROWING(m_player = CAudioPlayer::NewL(*this, 0, EMdaPriorityPreferenceNone)); - m_player->RegisterForAudioLoadingNotification(*this); -} - -S60AudioPlayerSession::~S60AudioPlayerSession() -{ -#if !defined(HAS_NO_AUDIOROUTING) - if (m_audioOutput) - m_audioOutput->UnregisterObserver(*this); - delete m_audioOutput; -#endif - m_player->Close(); - delete m_player; -} - -void S60AudioPlayerSession::doLoadL(const TDesC &path) -{ -#ifndef HAS_NO_AUDIOROUTING - // m_audioOutput needs to be reinitialized after MapcInitComplete - if (m_audioOutput) - m_audioOutput->UnregisterObserver(*this); - delete m_audioOutput; - m_audioOutput = NULL; -#endif - - m_player->OpenFileL(path); -} - -qint64 S60AudioPlayerSession::doGetDurationL() const -{ - return m_player->Duration().Int64() / qint64(1000); -} - -qint64 S60AudioPlayerSession::doGetPositionL() const -{ - TTimeIntervalMicroSeconds ms = 0; - m_player->GetPosition(ms); - return ms.Int64() / qint64(1000); -} - -bool S60AudioPlayerSession::isVideoAvailable() const -{ - return false; -} -bool S60AudioPlayerSession::isAudioAvailable() const -{ - return true; // this is a bit happy scenario, but we do emit error that we can't play -} - -void S60AudioPlayerSession::MaloLoadingStarted() -{ - buffering(); -} - -void S60AudioPlayerSession::MaloLoadingComplete() -{ - buffered(); -} - -void S60AudioPlayerSession::doPlay() -{ -// For some reason loading progress callbalck are not called on emulator -#ifdef __WINSCW__ - buffering(); -#endif - m_player->Play(); -#ifdef __WINSCW__ - buffered(); -#endif - -} - -void S60AudioPlayerSession::doPauseL() -{ - m_player->Pause(); -} - -void S60AudioPlayerSession::doStop() -{ - m_player->Stop(); -} - -void S60AudioPlayerSession::doSetVolumeL(int volume) -{ - m_player->SetVolume((volume / 100.0) * m_player->MaxVolume()); -} - -void S60AudioPlayerSession::doSetPositionL(qint64 microSeconds) -{ - m_player->SetPosition(TTimeIntervalMicroSeconds(microSeconds)); -} - -void S60AudioPlayerSession::updateMetaDataEntriesL() -{ - metaDataEntries().clear(); - int numberOfMetaDataEntries = 0; - - m_player->GetNumberOfMetaDataEntries(numberOfMetaDataEntries); - - for (int i = 0; i < numberOfMetaDataEntries; i++) { - CMMFMetaDataEntry *entry = NULL; - entry = m_player->GetMetaDataEntryL(i); - metaDataEntries().insert(QString::fromUtf16(entry->Name().Ptr(), entry->Name().Length()), QString::fromUtf16(entry->Value().Ptr(), entry->Value().Length())); - delete entry; - } - emit metaDataChanged(); -} - -int S60AudioPlayerSession::doGetBufferStatusL() const -{ - int progress = 0; - m_player->GetAudioLoadingProgressL(progress); - return progress; -} - -void S60AudioPlayerSession::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration) -{ - Q_UNUSED(aDuration); - setError(aError); -#ifndef HAS_NO_AUDIOROUTING - TRAPD(err, - m_audioOutput = CAudioOutput::NewL(*m_player); - m_audioOutput->RegisterObserverL(*this); - ); - setActiveEndpoint(m_audioEndpoint); - setError(err); -#endif - loaded(); -} - -void S60AudioPlayerSession::MapcPlayComplete(TInt aError) -{ - setError(aError); - endOfMedia(); -} - -void S60AudioPlayerSession::doSetAudioEndpoint(const QString& audioEndpoint) -{ - m_audioEndpoint = audioEndpoint; -} - -QString S60AudioPlayerSession::activeEndpoint() const -{ - QString outputName = QString("Default"); -#if !defined(HAS_NO_AUDIOROUTING) - if (m_audioOutput) { - CAudioOutput::TAudioOutputPreference output = m_audioOutput->AudioOutput(); - outputName = qStringFromTAudioOutputPreference(output); - } -#endif - return outputName; -} - -QString S60AudioPlayerSession::defaultEndpoint() const -{ - QString outputName = QString("Default"); -#if !defined(HAS_NO_AUDIOROUTING) - if (m_audioOutput) { - CAudioOutput::TAudioOutputPreference output = m_audioOutput->DefaultAudioOutput(); - outputName = qStringFromTAudioOutputPreference(output); - } -#endif - return outputName; -} - -void S60AudioPlayerSession::setActiveEndpoint(const QString& name) -{ -#if !defined(HAS_NO_AUDIOROUTING) - CAudioOutput::TAudioOutputPreference output = CAudioOutput::ENoPreference; - - if (name == QString("Default")) - output = CAudioOutput::ENoPreference; - else if (name == QString("All")) - output = CAudioOutput::EAll; - else if (name == QString("None")) - output = CAudioOutput::ENoOutput; - else if (name == QString("Earphone")) - output = CAudioOutput::EPrivate; - else if (name == QString("Speaker")) - output = CAudioOutput::EPublic; - if (m_audioOutput) { - TRAPD(err, m_audioOutput->SetAudioOutputL(output)); - setError(err); - - if (m_audioEndpoint != name) { - m_audioEndpoint = name; - emit activeEndpointChanged(name); - } - } -#endif -} - -#if !defined(HAS_NO_AUDIOROUTING) -void S60AudioPlayerSession::DefaultAudioOutputChanged(CAudioOutput& aAudioOutput, - CAudioOutput::TAudioOutputPreference aNewDefault) -{ - // Emit already implemented in setActiveEndpoint function - Q_UNUSED(aAudioOutput) - Q_UNUSED(aNewDefault) -} - -QString S60AudioPlayerSession::qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const -{ - if (output == CAudioOutput::ENoPreference) - return QString("Default"); - else if (output == CAudioOutput::EAll) - return QString("All"); - else if (output == CAudioOutput::ENoOutput) - return QString("None"); - else if (output == CAudioOutput::EPrivate) - return QString("Earphone"); - else if (output == CAudioOutput::EPublic) - return QString("Speaker"); - return QString("Default"); -} -#endif -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.h b/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.h deleted file mode 100644 index f25b722..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.h +++ /dev/null @@ -1,124 +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 S60AUDIOPLAYERSESSION_H -#define S60AUDIOPLAYERSESSION_H - -#include "s60mediaplayersession.h" - -#include <mdaaudiosampleplayer.h> -typedef CMdaAudioPlayerUtility CAudioPlayer; -typedef MMdaAudioPlayerCallback MAudioPlayerObserver; - -#ifndef HAS_NO_AUDIOROUTING -#include <phonon/audiooutput.h> -#include <MAudioOutputObserver.h> -#endif - -QT_BEGIN_NAMESPACE - -class S60AudioPlayerSession : public S60MediaPlayerSession - , public MAudioPlayerObserver - , public MAudioLoadingObserver -#ifndef HAS_NO_AUDIOROUTING - , public MAudioOutputObserver -#endif -{ - Q_OBJECT - -public: - S60AudioPlayerSession(QObject *parent); - ~S60AudioPlayerSession(); - - //From S60MediaPlayerSession - bool isVideoAvailable() const; - bool isAudioAvailable() const; - - // From MAudioLoadingObserver - void MaloLoadingStarted(); - void MaloLoadingComplete(); - -#ifndef HAS_NO_AUDIOROUTING - // From MAudioOutputObserver - void DefaultAudioOutputChanged( CAudioOutput& aAudioOutput, - CAudioOutput::TAudioOutputPreference aNewDefault ); -#endif -public: - // From S60MediaPlayerAudioEndpointSelector - QString activeEndpoint() const; - QString defaultEndpoint() const; -public Q_SLOTS: - void setActiveEndpoint(const QString& name); -Q_SIGNALS: - void activeEndpointChanged(const QString & name); - -protected: - //From S60MediaPlayerSession - void doLoadL(const TDesC &path); - void doLoadUrlL(const TDesC &path){Q_UNUSED(path)/*empty implementation*/} - void doPlay(); - void doStop(); - void doPauseL(); - void doSetVolumeL(int volume); - qint64 doGetPositionL() const; - void doSetPositionL(qint64 microSeconds); - void updateMetaDataEntriesL(); - int doGetBufferStatusL() const; - qint64 doGetDurationL() const; - void doSetAudioEndpoint(const QString& audioEndpoint); - -private: - void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration); - void MapcPlayComplete(TInt aError); -#ifndef HAS_NO_AUDIOROUTING - QString qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const; -#endif -private: - CAudioPlayer *m_player; -#ifndef HAS_NO_AUDIOROUTING - CAudioOutput *m_audioOutput; -#endif - QString m_audioEndpoint; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.cpp deleted file mode 100644 index e80c487..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.cpp +++ /dev/null @@ -1,185 +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 "s60mediametadataprovider.h" -#include "s60mediaplayersession.h" -#include <QtCore/qdebug.h> - -QT_BEGIN_NAMESPACE - -S60MediaMetaDataProvider::S60MediaMetaDataProvider(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent) - : QMetaDataControl(parent) - , m_mediaPlayerResolver(mediaPlayerResolver) - , m_session(NULL) -{ -} - -S60MediaMetaDataProvider::~S60MediaMetaDataProvider() -{ -} - -bool S60MediaMetaDataProvider::isMetaDataAvailable() const -{ - m_session = m_mediaPlayerResolver.PlayerSession(); - if (m_session) - return m_session->isMetadataAvailable(); - return false; -} - -bool S60MediaMetaDataProvider::isWritable() const -{ - return false; -} - -QVariant S60MediaMetaDataProvider::metaData(QtMediaServices::MetaData key) const -{ - m_session = m_mediaPlayerResolver.PlayerSession(); - if (m_session && m_session->isMetadataAvailable()) - return m_session->metaData(metaDataKeyAsString(key)); - return QVariant(); -} - -void S60MediaMetaDataProvider::setMetaData(QtMediaServices::MetaData key, QVariant const &value) -{ - Q_UNUSED(key); - Q_UNUSED(value); -} -QList<QtMediaServices::MetaData> S60MediaMetaDataProvider::availableMetaData() const -{ - m_session = m_mediaPlayerResolver.PlayerSession(); - QList<QtMediaServices::MetaData> metaDataTags; - if (m_session && m_session->isMetadataAvailable()) { - for (int i = QtMediaServices::Title; i <= QtMediaServices::DeviceSettingDescription; i++) { - QString metaData = metaDataKeyAsString((QtMediaServices::MetaData)i); - if (!metaData.isEmpty()) { - if (!m_session->metaData(metaData).toString().isEmpty()) { - metaDataTags.append((QtMediaServices::MetaData)i); - } - } - } - } - return metaDataTags; -} - -QVariant S60MediaMetaDataProvider::extendedMetaData(const QString &key) const -{ - m_session = m_mediaPlayerResolver.PlayerSession(); - if (m_session && m_session->isMetadataAvailable()) - return m_session->metaData(key); - return QVariant(); -} - -void S60MediaMetaDataProvider::setExtendedMetaData(const QString &key, QVariant const &value) -{ - Q_UNUSED(key); - Q_UNUSED(value); -} - -QStringList S60MediaMetaDataProvider::availableExtendedMetaData() const -{ - m_session = m_mediaPlayerResolver.PlayerSession(); - if (m_session && m_session->isMetadataAvailable()) - return m_session->availableMetaData().keys(); - return QStringList(); -} - -QString S60MediaMetaDataProvider::metaDataKeyAsString(QtMediaServices::MetaData key) const -{ - switch(key) { - case QtMediaServices::Title: return "title"; - case QtMediaServices::AlbumArtist: return "artist"; - case QtMediaServices::Comment: return "comment"; - case QtMediaServices::Genre: return "genre"; - case QtMediaServices::Year: return "year"; - case QtMediaServices::Copyright: return "copyright"; - case QtMediaServices::AlbumTitle: return "album"; - case QtMediaServices::Composer: return "composer"; - case QtMediaServices::TrackNumber: return "albumtrack"; - case QtMediaServices::AudioBitRate: return "audiobitrate"; - case QtMediaServices::VideoBitRate: return "videobitrate"; - case QtMediaServices::Duration: return "duration"; - case QtMediaServices::MediaType: return "contenttype"; - case QtMediaServices::SubTitle: // TODO: Find the matching metadata keys - case QtMediaServices::Description: - case QtMediaServices::Category: - case QtMediaServices::Date: - case QtMediaServices::UserRating: - case QtMediaServices::Keywords: - case QtMediaServices::Language: - case QtMediaServices::Publisher: - case QtMediaServices::ParentalRating: - case QtMediaServices::RatingOrganisation: - case QtMediaServices::Size: - case QtMediaServices::AudioCodec: - case QtMediaServices::AverageLevel: - case QtMediaServices::ChannelCount: - case QtMediaServices::PeakValue: - case QtMediaServices::SampleRate: - case QtMediaServices::Author: - case QtMediaServices::ContributingArtist: - case QtMediaServices::Conductor: - case QtMediaServices::Lyrics: - case QtMediaServices::Mood: - case QtMediaServices::TrackCount: - case QtMediaServices::CoverArtUrlSmall: - case QtMediaServices::CoverArtUrlLarge: - case QtMediaServices::Resolution: - case QtMediaServices::PixelAspectRatio: - case QtMediaServices::VideoFrameRate: - case QtMediaServices::VideoCodec: - case QtMediaServices::PosterUrl: - case QtMediaServices::ChapterNumber: - case QtMediaServices::Director: - case QtMediaServices::LeadPerformer: - case QtMediaServices::Writer: - case QtMediaServices::CameraManufacturer: - case QtMediaServices::CameraModel: - case QtMediaServices::Event: - case QtMediaServices::Subject: - default: - break; - } - - return QString(); -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.h deleted file mode 100644 index 07ae494..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.h +++ /dev/null @@ -1,81 +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 S60MEDIAMETADATAPROVIDER_H -#define S60MEDIAMETADATAPROVIDER_H - -#include <qmetadatacontrol.h> -#include "ms60mediaplayerresolver.h" - -QT_BEGIN_NAMESPACE - -class S60MediaPlayerSession; - -class S60MediaMetaDataProvider : public QMetaDataControl -{ - Q_OBJECT - -public: - S60MediaMetaDataProvider(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent = 0); - ~S60MediaMetaDataProvider(); - - 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: - QString metaDataKeyAsString(QtMediaServices::MetaData key) const; - -private: - MS60MediaPlayerResolver& m_mediaPlayerResolver; - mutable S60MediaPlayerSession *m_session; -}; - -QT_END_NAMESPACE - -#endif // S60VIDEOMETADATAPROVIDER_H diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.cpp deleted file mode 100644 index dbeed90..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.cpp +++ /dev/null @@ -1,127 +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 "s60mediaplayercontrol.h" -#include "s60mediaplayersession.h" -#include "s60mediaplayeraudioendpointselector.h" - -#include <QtGui/QIcon> -#include <QtCore/QDebug> - -QT_BEGIN_NAMESPACE - -S60MediaPlayerAudioEndpointSelector::S60MediaPlayerAudioEndpointSelector(QObject *control, QObject *parent) - :QMediaControl(parent) - , m_control(0) - , m_audioEndpointNames(0) -{ - m_control = qobject_cast<S60MediaPlayerControl*>(control); -} - -S60MediaPlayerAudioEndpointSelector::~S60MediaPlayerAudioEndpointSelector() -{ - delete m_audioEndpointNames; -} - -QList<QString> S60MediaPlayerAudioEndpointSelector::availableEndpoints() const -{ - if(m_audioEndpointNames->count() == 0) { - m_audioEndpointNames->append("Default"); - m_audioEndpointNames->append("All"); - m_audioEndpointNames->append("None"); - m_audioEndpointNames->append("Earphone"); - m_audioEndpointNames->append("Speaker"); - } - return *m_audioEndpointNames; -} - -QString S60MediaPlayerAudioEndpointSelector::endpointDescription(const QString& name) const -{ - if (name == QString("Default")) //ENoPreference - return QString("Used to indicate that the playing audio can be routed to" - "any speaker. This is the default value for audio."); - else if (name == QString("All")) //EAll - return QString("Used to indicate that the playing audio should be routed to all speakers."); - else if (name == QString("None")) //ENoOutput - return QString("Used to indicate that the playing audio should not be routed to any output."); - else if (name == QString("Earphone")) //EPrivate - return QString("Used to indicate that the playing audio should be routed to" - "the default private speaker. A private speaker is one that can only" - "be heard by one person."); - else if (name == QString("Speaker")) //EPublic - return QString("Used to indicate that the playing audio should be routed to" - "the default public speaker. A public speaker is one that can " - "be heard by multiple people."); - - return QString(); -} - -QString S60MediaPlayerAudioEndpointSelector::activeEndpoint() const -{ - if (m_control->session()) - return m_control->session()->activeEndpoint(); - else - return m_control->mediaControlSettings().audioEndpoint(); -} - -QString S60MediaPlayerAudioEndpointSelector::defaultEndpoint() const -{ - if (m_control->session()) - return m_control->session()->defaultEndpoint(); - else - return m_control->mediaControlSettings().audioEndpoint(); -} - -void S60MediaPlayerAudioEndpointSelector::setActiveEndpoint(const QString& name) -{ - QString oldEndpoint = m_control->mediaControlSettings().audioEndpoint(); - - if (name != oldEndpoint && (name == QString("Default") || name == QString("All") || - name == QString("None") || name == QString("Earphone") || name == QString("Speaker"))) { - - if (m_control->session()) { - m_control->session()->setActiveEndpoint(name); - } - m_control->setAudioEndpoint(name); - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.h deleted file mode 100644 index a110ae8..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.h +++ /dev/null @@ -1,81 +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 S60MEDIAPLAYERAUDIOENDPOINTSELECTOR_H -#define S60MEDIAPLAYERAUDIOENDPOINTSELECTOR_H - -#include <QStringList> - -#include <QtMediaServices/qmediacontrol.h> - -QT_BEGIN_NAMESPACE - -class S60MediaPlayerControl; -class S60MediaPlayerSession; - -class S60MediaPlayerAudioEndpointSelector : public QMediaControl -{ - -Q_OBJECT - -public: - S60MediaPlayerAudioEndpointSelector(QObject *control, QObject *parent = 0); - ~S60MediaPlayerAudioEndpointSelector(); - - QList<QString> availableEndpoints() const ; - QString endpointDescription(const QString& name) const; - QString defaultEndpoint() const; - QString activeEndpoint() const; - -public Q_SLOTS: - void setActiveEndpoint(const QString& name); - -private: - S60MediaPlayerControl* m_control; - QString m_audioInput; - QList<QString> *m_audioEndpointNames; -}; - -#define QAudioEndpointSelector_iid "com.nokia.Qt.QAudioEndpointSelector/1.0" - -QT_END_NAMESPACE - -#endif // S60MEDIAPLAYERAUDIOENDPOINTSELECTOR_H diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.cpp deleted file mode 100644 index 8e03afd..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.cpp +++ /dev/null @@ -1,274 +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 "s60mediaplayercontrol.h" -#include "s60mediaplayersession.h" - -#include <QtCore/qdir.h> -#include <QtCore/qurl.h> -#include <QtCore/qdebug.h> - -QT_BEGIN_NAMESPACE - -S60MediaPlayerControl::S60MediaPlayerControl(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent) - : QMediaPlayerControl(parent), - m_mediaPlayerResolver(mediaPlayerResolver), - m_session(NULL), - m_stream(NULL) -{ -} - -S60MediaPlayerControl::~S60MediaPlayerControl() -{ -} - -qint64 S60MediaPlayerControl::position() const -{ - if (m_session) - return m_session->position(); - return 0; -} - -qint64 S60MediaPlayerControl::duration() const -{ - if (m_session) - return m_session->duration(); - return -1; -} - -QMediaPlayer::State S60MediaPlayerControl::state() const -{ - if (m_session) - return m_session->state(); - return QMediaPlayer::StoppedState; -} - -QMediaPlayer::MediaStatus S60MediaPlayerControl::mediaStatus() const -{ - if (m_session) - return m_session->mediaStatus(); - return m_mediaSettings.mediaStatus(); -} - -int S60MediaPlayerControl::bufferStatus() const -{ - if (m_session) - return m_session->bufferStatus(); - return 0; -} - -int S60MediaPlayerControl::volume() const -{ - if (m_session) - return m_session->volume(); - return m_mediaSettings.volume(); -} - -bool S60MediaPlayerControl::isMuted() const -{ - if (m_session) - return m_session->isMuted(); - return m_mediaSettings.isMuted(); -} - -bool S60MediaPlayerControl::isSeekable() const -{ - if (m_session) - return m_session->isSeekable(); - return false; -} - -QMediaTimeRange S60MediaPlayerControl::availablePlaybackRanges() const -{ - QMediaTimeRange ranges; - - if(m_session && m_session->isSeekable()) - ranges.addInterval(0, m_session->duration()); - - return ranges; -} - -qreal S60MediaPlayerControl::playbackRate() const -{ - //None of symbian players supports this. - return m_mediaSettings.playbackRate(); -} - -void S60MediaPlayerControl::setPlaybackRate(qreal rate) -{ - //None of symbian players supports this. - m_mediaSettings.setPlaybackRate(rate); - emit playbackRateChanged(playbackRate()); - -} - -void S60MediaPlayerControl::setPosition(qint64 pos) -{ - if (m_session) - m_session->setPosition(pos); -} - -void S60MediaPlayerControl::play() -{ - if (m_session) - m_session->play(); -} - -void S60MediaPlayerControl::pause() -{ - if (m_session) - m_session->pause(); -} - -void S60MediaPlayerControl::stop() -{ - if (m_session) - m_session->stop(); -} - -void S60MediaPlayerControl::setVolume(int volume) -{ - int boundVolume = qBound(0, volume, 100); - if (boundVolume == m_mediaSettings.volume()) - return; - - m_mediaSettings.setVolume(boundVolume); - if (m_session) - m_session->setVolume(boundVolume); - - emit volumeChanged(boundVolume); -} - -void S60MediaPlayerControl::setMuted(bool muted) -{ - if (m_mediaSettings.isMuted() == muted) - return; - - m_mediaSettings.setMuted(muted); - if (m_session) - m_session->setMuted(muted); - - emit mutedChanged(muted); -} - -QMediaContent S60MediaPlayerControl::media() const -{ - return m_currentResource; -} - -const QIODevice *S60MediaPlayerControl::mediaStream() const -{ - return m_stream; -} - -void S60MediaPlayerControl::setMedia(const QMediaContent &source, QIODevice *stream) -{ - Q_UNUSED(stream) - // we don't want to set & load media again when it is already loaded - if (m_session && m_currentResource == source) - return; - - // store to variable as session is created based on the content type. - m_currentResource = source; - S60MediaPlayerSession *newSession = m_mediaPlayerResolver.PlayerSession(); - m_mediaSettings.setMediaStatus(QMediaPlayer::UnknownMediaStatus); - - if (m_session) - m_session->reset(); - else { - emit mediaStatusChanged(QMediaPlayer::UnknownMediaStatus); - emit error(QMediaPlayer::NoError, QString()); - } - - m_session = newSession; - - if (m_session) - m_session->load(source.canonicalUrl()); - else { - QMediaPlayer::MediaStatus status = (source.isNull()) ? QMediaPlayer::NoMedia : QMediaPlayer::InvalidMedia; - m_mediaSettings.setMediaStatus(status); - emit stateChanged(QMediaPlayer::StoppedState); - emit error((source.isNull()) ? QMediaPlayer::NoError : QMediaPlayer::ResourceError, - (source.isNull()) ? "" : tr("Media couldn't be resolved")); - emit mediaStatusChanged(status); - } - emit mediaChanged(m_currentResource); - } - -S60MediaPlayerSession* S60MediaPlayerControl::session() -{ - return m_session; -} - -void S60MediaPlayerControl::setVideoOutput(QObject *output) -{ - S60MediaPlayerSession *session = NULL; - session = m_mediaPlayerResolver.VideoPlayerSession(); - session->setVideoRenderer(output); -} - -bool S60MediaPlayerControl::isAudioAvailable() const -{ - if (m_session) - return m_session->isAudioAvailable(); - return false; -} - -bool S60MediaPlayerControl::isVideoAvailable() const -{ - if (m_session) - return m_session->isVideoAvailable(); - return false; -} - -const S60MediaSettings& S60MediaPlayerControl::mediaControlSettings() const -{ - return m_mediaSettings; -} - -void S60MediaPlayerControl::setAudioEndpoint(const QString& name) -{ - m_mediaSettings.setAudioEndpoint(name); -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.h deleted file mode 100644 index 3d26a5e..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.h +++ /dev/null @@ -1,143 +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 S60MEDIAPLAYERCONTROL_H -#define S60MEDIAPLAYERCONTROL_H - -#include <QtCore/qobject.h> - -#include <qmediaplayercontrol.h> - -#include "ms60mediaplayerresolver.h" -#include <QtCore/qdebug.h> - -QT_BEGIN_NAMESPACE - -class QMediaPlayer; -class QMediaTimeRange; -class QMediaContent; - - -class S60MediaPlayerSession; -class S60MediaPlayerService; - -class S60MediaSettings -{ - -public: - S60MediaSettings() - : m_volume(0) - , m_muted(false) - , m_playbackRate(0) - , m_mediaStatus(QMediaPlayer::UnknownMediaStatus) - , m_audioEndpoint(QString("Default")) - { - } - - void setVolume(int volume) { m_volume = volume; } - void setMuted(bool muted) { m_muted = muted; } - void setPlaybackRate(int rate) { m_playbackRate = rate; } - void setMediaStatus(QMediaPlayer::MediaStatus status) {m_mediaStatus=status;} - void setAudioEndpoint(const QString& audioEndpoint) { m_audioEndpoint = audioEndpoint; } - - int volume() const { return m_volume; } - bool isMuted() const { return m_muted; } - qreal playbackRate() const { return m_playbackRate; } - QMediaPlayer::MediaStatus mediaStatus() const {return m_mediaStatus;} - QString audioEndpoint() const { return m_audioEndpoint; } - -private: - int m_volume; - bool m_muted; - qreal m_playbackRate; - QMediaPlayer::MediaStatus m_mediaStatus; - QString m_audioEndpoint; -}; - -class S60MediaPlayerControl : public QMediaPlayerControl -{ - Q_OBJECT - -public: - S60MediaPlayerControl(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent = 0); - ~S60MediaPlayerControl(); - - // from QMediaPlayerControl - virtual QMediaPlayer::State state() const; - virtual QMediaPlayer::MediaStatus mediaStatus() const; - virtual qint64 duration() const; - virtual qint64 position() const; - virtual void setPosition(qint64 pos); - virtual int volume() const; - virtual void setVolume(int volume); - virtual bool isMuted() const; - virtual void setMuted(bool muted); - virtual int bufferStatus() const; - virtual bool isAudioAvailable() const; - virtual bool isVideoAvailable() const; - virtual bool isSeekable() const; - virtual QMediaTimeRange availablePlaybackRanges() const; - virtual qreal playbackRate() const; - virtual void setPlaybackRate(qreal rate); - virtual QMediaContent media() const; - virtual const QIODevice *mediaStream() const; - virtual void setMedia(const QMediaContent&, QIODevice *); - virtual void play(); - virtual void pause(); - virtual void stop(); - S60MediaPlayerSession* session(); - void setAudioEndpoint(const QString& name); - - // Own methods - void setVideoOutput(QObject *output); - const S60MediaSettings& mediaControlSettings() const; - -private: - MS60MediaPlayerResolver &m_mediaPlayerResolver; - S60MediaPlayerSession *m_session; - QMediaContent m_currentResource; - QIODevice *m_stream; - S60MediaSettings m_mediaSettings; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.cpp deleted file mode 100644 index 0b1c7d5..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.cpp +++ /dev/null @@ -1,259 +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 "s60mediaplayerservice.h" -#include "s60mediaplayercontrol.h" -#include "s60videoplayersession.h" -#include "s60audioplayersession.h" -#include "s60mediametadataprovider.h" -#include "s60videowidget.h" -#include "s60mediarecognizer.h" -//#include <qmediatimerange.h> -#include "s60videooverlay.h" -#include "s60videorenderer.h" -#include "s60mediaplayeraudioendpointselector.h" - -#include <qmediaplaylistnavigator.h> -#include <qmediaplaylist.h> - -QT_BEGIN_NAMESPACE - -S60MediaPlayerService::S60MediaPlayerService(QObject *parent) - : QMediaService(parent) - , m_control(NULL) - , m_videoOutput(NULL) - , m_videoPlayerSession(NULL) - , m_audioPlayerSession(NULL) - , m_metaData(NULL) - , m_videoWidget(NULL) - , m_videoWindow(NULL) - , m_videoRenderer(NULL) - , m_audioEndpointSelector(NULL) -{ - m_control = new S60MediaPlayerControl(*this, this); - m_metaData = new S60MediaMetaDataProvider(*this); - m_audioEndpointSelector = new S60MediaPlayerAudioEndpointSelector(m_control, this); -} - -S60MediaPlayerService::~S60MediaPlayerService() -{ - delete m_videoWidget; - delete m_videoRenderer; - delete m_videoWindow; - delete m_videoOutput; -} - -QMediaControl *S60MediaPlayerService::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, QVideoOutputControl_iid) == 0) { - if (!m_videoOutput) { - m_videoOutput = new S60VideoOutputControl; - connect(m_videoOutput, SIGNAL(outputChanged(QVideoOutputControl::Output)), - this, SLOT(videoOutputChanged(QVideoOutputControl::Output))); - m_videoOutput->setAvailableOutputs(QList<QVideoOutputControl::Output>() -// << QVideoOutputControl::RendererOutput -// << QVideoOutputControl::WindowOutput - << QVideoOutputControl::WidgetOutput); - - } - return m_videoOutput; - } - - if (qstrcmp(name, QVideoWidgetControl_iid) == 0) { - if (!m_videoWidget) - m_videoWidget = new S60VideoWidgetControl; - return m_videoWidget; - } - - if (qstrcmp(name, QVideoRendererControl_iid) == 0) { - if (m_videoRenderer) - m_videoRenderer = new S60VideoRenderer; - return m_videoRenderer; - } - - if (qstrcmp(name, QVideoWindowControl_iid) == 0) { - if (!m_videoWindow) - m_videoWindow = new S60VideoOverlay; - return m_videoWindow; - } - - if (qstrcmp(name, QAudioEndpointSelector_iid) == 0) { - return m_audioEndpointSelector; - } - - return 0; - -} - -void S60MediaPlayerService::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; - } -} - -S60MediaPlayerSession* S60MediaPlayerService::PlayerSession() -{ - QUrl url = m_control->media().canonicalUrl(); - - if (url.isEmpty() == true) { - return NULL; - } - - S60MediaRecognizer *m_mediaRecognizer = new S60MediaRecognizer(this); - S60MediaRecognizer::MediaType mediaType = m_mediaRecognizer->mediaType(url); - - switch (mediaType) { - case S60MediaRecognizer::Video: - case S60MediaRecognizer::Url: - return VideoPlayerSession(); - case S60MediaRecognizer::Audio: - return AudioPlayerSession(); - default: - break; - } - - return NULL; -} - -S60MediaPlayerSession* S60MediaPlayerService::VideoPlayerSession() -{ - if (!m_videoPlayerSession) { - m_videoPlayerSession = new S60VideoPlayerSession(this); - - connect(m_videoPlayerSession, SIGNAL(positionChanged(qint64)), - m_control, SIGNAL(positionChanged(qint64))); - connect(m_videoPlayerSession, SIGNAL(durationChanged(qint64)), - m_control, SIGNAL(durationChanged(qint64))); - connect(m_videoPlayerSession, SIGNAL(stateChanged(QMediaPlayer::State)), - m_control, SIGNAL(stateChanged(QMediaPlayer::State))); - connect(m_videoPlayerSession, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), - m_control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - connect(m_videoPlayerSession,SIGNAL(bufferStatusChanged(int)), - m_control, SIGNAL(bufferStatusChanged(int))); - connect(m_videoPlayerSession, SIGNAL(videoAvailableChanged(bool)), - m_control, SIGNAL(videoAvailableChanged(bool))); - connect(m_videoPlayerSession, SIGNAL(audioAvailableChanged(bool)), - m_control, SIGNAL(audioAvailableChanged(bool))); - connect(m_videoPlayerSession, SIGNAL(seekableChanged(bool)), - m_control, SIGNAL(seekableChanged(bool))); - connect(m_videoPlayerSession, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&)), - m_control, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&))); - connect(m_videoPlayerSession, SIGNAL(error(int, const QString &)), - m_control, SIGNAL(error(int, const QString &))); - connect(m_videoPlayerSession, SIGNAL(metaDataChanged()), - m_metaData, SIGNAL(metaDataChanged())); - connect(m_videoPlayerSession, SIGNAL(activeEndpointChanged(const QString&)), - m_audioEndpointSelector, SIGNAL(activeEndpointChanged(const QString&))); - } - - m_videoPlayerSession->setVolume(m_control->mediaControlSettings().volume()); - m_videoPlayerSession->setMuted(m_control->mediaControlSettings().isMuted()); - m_videoPlayerSession->setAudioEndpoint(m_control->mediaControlSettings().audioEndpoint()); - return m_videoPlayerSession; -} - -S60MediaPlayerSession* S60MediaPlayerService::AudioPlayerSession() -{ - if (!m_audioPlayerSession) { - m_audioPlayerSession = new S60AudioPlayerSession(this); - - connect(m_audioPlayerSession, SIGNAL(positionChanged(qint64)), - m_control, SIGNAL(positionChanged(qint64))); - connect(m_audioPlayerSession, SIGNAL(durationChanged(qint64)), - m_control, SIGNAL(durationChanged(qint64))); - connect(m_audioPlayerSession, SIGNAL(stateChanged(QMediaPlayer::State)), - m_control, SIGNAL(stateChanged(QMediaPlayer::State))); - connect(m_audioPlayerSession, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), - m_control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - connect(m_audioPlayerSession,SIGNAL(bufferStatusChanged(int)), - m_control, SIGNAL(bufferStatusChanged(int))); - connect(m_audioPlayerSession, SIGNAL(videoAvailableChanged(bool)), - m_control, SIGNAL(videoAvailableChanged(bool))); - connect(m_audioPlayerSession, SIGNAL(audioAvailableChanged(bool)), - m_control, SIGNAL(audioAvailableChanged(bool))); - connect(m_audioPlayerSession, SIGNAL(seekableChanged(bool)), - m_control, SIGNAL(seekableChanged(bool))); - connect(m_audioPlayerSession, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&)), - m_control, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&))); - connect(m_audioPlayerSession, SIGNAL(error(int, const QString &)), - m_control, SIGNAL(error(int, const QString &))); - connect(m_audioPlayerSession, SIGNAL(metaDataChanged()), - m_metaData, SIGNAL(metaDataChanged())); - connect(m_audioPlayerSession, SIGNAL(activeEndpointChanged(const QString&)), - m_audioEndpointSelector, SIGNAL(activeEndpointChanged(const QString&))); - } - - m_audioPlayerSession->setVolume(m_control->mediaControlSettings().volume()); - m_audioPlayerSession->setMuted(m_control->mediaControlSettings().isMuted()); - m_audioPlayerSession->setAudioEndpoint(m_control->mediaControlSettings().audioEndpoint()); - return m_audioPlayerSession; -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.h deleted file mode 100644 index 6c8155d..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.h +++ /dev/null @@ -1,105 +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 S60VIDEOPLAYERSERVICE_H -#define S60VIDEOPLAYERSERVICE_H - -#include <QtCore/qobject.h> - -#include <qmediaservice.h> -#include <qvideooutputcontrol.h> - -#include "s60videooutputcontrol.h" -#include "ms60mediaplayerresolver.h" - -#include "s60mediaplayeraudioendpointselector.h" - -QT_BEGIN_NAMESPACE - -class QMediaMetaData; -class QMediaPlayerControl; -class QMediaPlaylist; - - -class S60VideoPlayerSession; -class S60AudioPlayerSession; -class S60MediaPlayerControl; -class S60MediaMetaDataProvider; -class S60VideoWidgetControl; -class S60MediaRecognizer; -class S60VideoRenderer; -class S60VideoOverlay; - -class QMediaPlaylistNavigator; - -class S60MediaPlayerService : public QMediaService, public MS60MediaPlayerResolver -{ - Q_OBJECT - -public: - S60MediaPlayerService(QObject *parent = 0); - ~S60MediaPlayerService(); - - QMediaControl *control(const char *name) const; - -private slots: - void videoOutputChanged(QVideoOutputControl::Output output); - -protected: // From MS60MediaPlayerResolver - S60MediaPlayerSession* PlayerSession(); - S60MediaPlayerSession* VideoPlayerSession(); - S60MediaPlayerSession* AudioPlayerSession(); - -private: - S60MediaPlayerControl *m_control; - mutable S60VideoOutputControl *m_videoOutput; - S60VideoPlayerSession *m_videoPlayerSession; - S60AudioPlayerSession *m_audioPlayerSession; - mutable S60MediaMetaDataProvider *m_metaData; - mutable S60VideoWidgetControl *m_videoWidget; - mutable S60VideoOverlay *m_videoWindow; - mutable S60VideoRenderer *m_videoRenderer; - S60MediaPlayerAudioEndpointSelector *m_audioEndpointSelector; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.cpp deleted file mode 100644 index 693c103..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.cpp +++ /dev/null @@ -1,496 +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 "s60mediaplayersession.h" - -#include <QtCore/qdebug.h> -#include <QtCore/qdir.h> -#include <QtCore/qvariant.h> -#include <QtCore/qtimer.h> -#include <mmf/common/mmferrors.h> -#include <qmediatimerange.h> - -QT_BEGIN_NAMESPACE - -S60MediaPlayerSession::S60MediaPlayerSession(QObject *parent) - : QObject(parent) - , m_playbackRate(0) - , m_muted(false) - , m_volume(0) - , m_state(QMediaPlayer::StoppedState) - , m_mediaStatus(QMediaPlayer::UnknownMediaStatus) - , m_progressTimer(new QTimer(this)) - , m_stalledTimer(new QTimer(this)) - , m_error(KErrNone) - , m_play_requested(false) - , m_stream(false) -{ - connect(m_progressTimer, SIGNAL(timeout()), this, SLOT(tick())); - connect(m_stalledTimer, SIGNAL(timeout()), this, SLOT(stalled())); -} - -S60MediaPlayerSession::~S60MediaPlayerSession() -{ -} - -int S60MediaPlayerSession::volume() const -{ - return m_volume; -} - -void S60MediaPlayerSession::setVolume(int volume) -{ - if (m_volume == volume) - return; - - m_volume = volume; - // Dont set symbian players volume until media loaded. - // Leaves with KerrNotReady although documentation says otherwise. - if (!m_muted && - ( mediaStatus() == QMediaPlayer::LoadedMedia - || mediaStatus() == QMediaPlayer::StalledMedia - || mediaStatus() == QMediaPlayer::BufferingMedia - || mediaStatus() == QMediaPlayer::BufferedMedia - || mediaStatus() == QMediaPlayer::EndOfMedia)) { - TRAPD(err, doSetVolumeL(m_volume)); - setError(err); - } -} - -bool S60MediaPlayerSession::isMuted() const -{ - return m_muted; -} - -bool S60MediaPlayerSession::isSeekable() const -{ - return (m_stream)?false:true; -} - -void S60MediaPlayerSession::setMediaStatus(QMediaPlayer::MediaStatus status) -{ - if (m_mediaStatus == status) - return; - - m_mediaStatus = status; - - emit mediaStatusChanged(m_mediaStatus); - - if (m_play_requested) - play(); -} - -void S60MediaPlayerSession::setState(QMediaPlayer::State state) -{ - if (m_state == state) - return; - - m_state = state; - emit stateChanged(m_state); -} - -QMediaPlayer::State S60MediaPlayerSession::state() const -{ - return m_state; -} - -QMediaPlayer::MediaStatus S60MediaPlayerSession::mediaStatus() const -{ - return m_mediaStatus; -} - -void S60MediaPlayerSession::load(QUrl url) -{ - setMediaStatus(QMediaPlayer::LoadingMedia); - startStalledTimer(); - m_stream = (url.scheme() == "file")?false:true; - TRAPD(err, - if(m_stream) - doLoadUrlL(QString2TPtrC(url.toString())); - else - doLoadL(QString2TPtrC(QDir::toNativeSeparators(url.toLocalFile())))); - setError(err); -} - -void S60MediaPlayerSession::play() -{ - if (state() == QMediaPlayer::PlayingState - || mediaStatus() == QMediaPlayer::UnknownMediaStatus - || mediaStatus() == QMediaPlayer::NoMedia - || mediaStatus() == QMediaPlayer::InvalidMedia) - return; - - if (mediaStatus() == QMediaPlayer::LoadingMedia) { - m_play_requested = true; - return; - } - - m_play_requested = false; - setState(QMediaPlayer::PlayingState); - startProgressTimer(); - doPlay(); -} - -void S60MediaPlayerSession::pause() -{ - if (mediaStatus() == QMediaPlayer::NoMedia || - mediaStatus() == QMediaPlayer::InvalidMedia) - return; - - setState(QMediaPlayer::PausedState); - stopProgressTimer(); - TRAP_IGNORE(doPauseL()); -} - -void S60MediaPlayerSession::stop() -{ - m_play_requested = false; - setState(QMediaPlayer::StoppedState); - if (mediaStatus() == QMediaPlayer::BufferingMedia || - mediaStatus() == QMediaPlayer::BufferedMedia) - setMediaStatus(QMediaPlayer::LoadedMedia); - if (mediaStatus() == QMediaPlayer::LoadingMedia) - setMediaStatus(QMediaPlayer::UnknownMediaStatus); - stopProgressTimer(); - stopStalledTimer(); - doStop(); - emit positionChanged(0); -} -void S60MediaPlayerSession::reset() -{ - m_play_requested = false; - setError(KErrNone, QString(), true); - stopProgressTimer(); - stopStalledTimer(); - doStop(); - setState(QMediaPlayer::StoppedState); - setMediaStatus(QMediaPlayer::UnknownMediaStatus); -} - -void S60MediaPlayerSession::setVideoRenderer(QObject *renderer) -{ - Q_UNUSED(renderer); -} - -int S60MediaPlayerSession::bufferStatus() -{ - if( mediaStatus() == QMediaPlayer::LoadingMedia - || mediaStatus() == QMediaPlayer::UnknownMediaStatus - || mediaStatus() == QMediaPlayer::NoMedia - || mediaStatus() == QMediaPlayer::InvalidMedia) - return 0; - - int progress = 0; - TRAPD(err, progress = doGetBufferStatusL()); - - // If buffer status query not supported by codec return 100 - // do not set error - if(err == KErrNotSupported) - return 100; - - setError(err); - return progress; -} - -bool S60MediaPlayerSession::isMetadataAvailable() const -{ - return !m_metaDataMap.isEmpty(); -} - -QVariant S60MediaPlayerSession::metaData(const QString &key) const -{ - return m_metaDataMap.value(key); -} - -QMap<QString, QVariant> S60MediaPlayerSession::availableMetaData() const -{ - return m_metaDataMap; -} - -void S60MediaPlayerSession::setMuted(bool muted) -{ - m_muted = muted; - - if( m_mediaStatus == QMediaPlayer::LoadedMedia - || m_mediaStatus == QMediaPlayer::StalledMedia - || m_mediaStatus == QMediaPlayer::BufferingMedia - || m_mediaStatus == QMediaPlayer::BufferedMedia - || m_mediaStatus == QMediaPlayer::EndOfMedia) { - TRAPD(err, doSetVolumeL((m_muted)?0:m_volume)); - setError(err); - } -} - -qint64 S60MediaPlayerSession::duration() const -{ - if( mediaStatus() == QMediaPlayer::LoadingMedia - || mediaStatus() == QMediaPlayer::UnknownMediaStatus - || mediaStatus() == QMediaPlayer::NoMedia - || mediaStatus() == QMediaPlayer::InvalidMedia) - return -1; - - qint64 pos = 0; - TRAP_IGNORE(pos = doGetDurationL()); - return pos; -} - -qint64 S60MediaPlayerSession::position() const -{ - if( mediaStatus() == QMediaPlayer::LoadingMedia - || mediaStatus() == QMediaPlayer::UnknownMediaStatus - || mediaStatus() == QMediaPlayer::NoMedia - || mediaStatus() == QMediaPlayer::InvalidMedia) - return 0; - - qint64 pos = 0; - TRAP_IGNORE(pos = doGetPositionL()); - return pos; -} - -void S60MediaPlayerSession::setPosition(qint64 pos) -{ - if (position() == pos) - return; - - if (state() == QMediaPlayer::PlayingState) - pause(); - - TRAPD(err, doSetPositionL(pos * 1000)); - setError(err); - - if (state() == QMediaPlayer::PausedState) - play(); - - emit positionChanged(position()); -} - -void S60MediaPlayerSession::setAudioEndpoint(const QString& audioEndpoint) -{ - doSetAudioEndpoint(audioEndpoint); -} - -void S60MediaPlayerSession::loaded() -{ - stopStalledTimer(); - if (m_error == KErrNone || m_error == KErrMMPartialPlayback) { - setMediaStatus(QMediaPlayer::LoadedMedia); - TRAPD(err, updateMetaDataEntriesL()); - setError(err); - setVolume(m_volume); - setMuted(m_muted); - emit durationChanged(duration()); - emit videoAvailableChanged(isVideoAvailable()); - emit audioAvailableChanged(isAudioAvailable()); - } -} - -void S60MediaPlayerSession::endOfMedia() -{ - setMediaStatus(QMediaPlayer::EndOfMedia); - setState(QMediaPlayer::StoppedState); - emit positionChanged(0); -} - -void S60MediaPlayerSession::buffering() -{ - startStalledTimer(); - setMediaStatus(QMediaPlayer::BufferingMedia); -} - -void S60MediaPlayerSession::buffered() -{ - stopStalledTimer(); - setMediaStatus(QMediaPlayer::BufferedMedia); -} -void S60MediaPlayerSession::stalled() -{ - setMediaStatus(QMediaPlayer::StalledMedia); -} - -QMap<QString, QVariant>& S60MediaPlayerSession::metaDataEntries() -{ - return m_metaDataMap; -} - -QMediaPlayer::Error S60MediaPlayerSession::fromSymbianErrorToMultimediaError(int error) -{ - switch(error) { - case KErrNoMemory: - case KErrNotFound: - case KErrBadHandle: - case KErrAbort: - case KErrNotSupported: - case KErrCorrupt: - case KErrGeneral: - case KErrArgument: - case KErrPathNotFound: - case KErrDied: - case KErrServerTerminated: - case KErrServerBusy: - case KErrCompletion: - case KErrBadPower: - return QMediaPlayer::ResourceError; - - case KErrMMPartialPlayback: - return QMediaPlayer::FormatError; - - case KErrMMAudioDevice: - case KErrMMVideoDevice: - case KErrMMDecoder: - case KErrUnknown: - return QMediaPlayer::ServiceMissingError; - - case KErrMMNotEnoughBandwidth: - case KErrMMSocketServiceNotFound: - case KErrMMNetworkRead: - case KErrMMNetworkWrite: - case KErrMMServerSocket: - case KErrMMServerNotSupported: - case KErrMMUDPReceive: - case KErrMMInvalidProtocol: - case KErrMMInvalidURL: - case KErrMMMulticast: - case KErrMMProxyServer: - case KErrMMProxyServerNotSupported: - case KErrMMProxyServerConnect: - return QMediaPlayer::NetworkError; - - case KErrNotReady: - case KErrInUse: - case KErrAccessDenied: - case KErrLocked: - case KErrMMDRMNotAuthorized: - case KErrPermissionDenied: - case KErrCancel: - case KErrAlreadyExists: - return QMediaPlayer::AccessDeniedError; - - case KErrNone: - default: - return QMediaPlayer::NoError; - } -} - -void S60MediaPlayerSession::setError(int error, const QString &errorString, bool forceReset) -{ - if( forceReset ) { - m_error = KErrNone; - emit this->error(QMediaPlayer::NoError, QString()); - return; - } - - // If error does not change and m_error is reseted without forceReset flag - if (error == m_error || - (m_error != KErrNone && error == KErrNone)) - return; - - m_error = error; - QMediaPlayer::Error mediaError = fromSymbianErrorToMultimediaError(m_error); - QString symbianError = QString(errorString); - - if (mediaError != QMediaPlayer::NoError) { - // TODO: fix to user friendly string at some point - // These error string are only dev usable - symbianError.append("Symbian:"); - symbianError.append(QString::number(m_error)); - } - - emit this->error(mediaError, symbianError); - - switch(mediaError){ - case QMediaPlayer::ResourceError: - case QMediaPlayer::NetworkError: - case QMediaPlayer::AccessDeniedError: - case QMediaPlayer::ServiceMissingError: - m_play_requested = false; - setMediaStatus(QMediaPlayer::InvalidMedia); - stop(); - break; - } -} - -void S60MediaPlayerSession::tick() -{ - emit positionChanged(position()); - - if (bufferStatus() < 100) - emit bufferStatusChanged(bufferStatus()); -} - -void S60MediaPlayerSession::startProgressTimer() -{ - m_progressTimer->start(500); -} - -void S60MediaPlayerSession::stopProgressTimer() -{ - m_progressTimer->stop(); -} - -void S60MediaPlayerSession::startStalledTimer() -{ - m_stalledTimer->start(30000); -} - -void S60MediaPlayerSession::stopStalledTimer() -{ - m_stalledTimer->stop(); -} -QString S60MediaPlayerSession::TDesC2QString(const TDesC& aDescriptor) -{ - return QString::fromUtf16(aDescriptor.Ptr(), aDescriptor.Length()); -} -TPtrC S60MediaPlayerSession::QString2TPtrC( const QString& string ) -{ - // Returned TPtrC is valid as long as the given parameter is valid and unmodified - return TPtrC16(static_cast<const TUint16*>(string.utf16()), string.length()); -} -QRect S60MediaPlayerSession::TRect2QRect(const TRect& tr) -{ - return QRect(tr.iTl.iX, tr.iTl.iY, tr.Width(), tr.Height()); -} -TRect S60MediaPlayerSession::QRect2TRect(const QRect& qr) -{ - return TRect(TPoint(qr.left(), qr.top()), TSize(qr.width(), qr.height())); -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.h deleted file mode 100644 index bb9eddd..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.h +++ /dev/null @@ -1,167 +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 S60MEDIAPLAYERSESSION_H -#define S60MEDIAPLAYERSESSION_H - -#include <QtCore/qobject.h> -#include <QtCore/qurl.h> -#include <QtCore/qpair.h> -#include <qmediaplayer.h> -#include <e32cmn.h> // for TDesC -#include <QRect> -#include "s60mediaplayerservice.h" - -QT_BEGIN_NAMESPACE - -class QMediaTimeRange; - -class QTimer; - -class S60MediaPlayerSession : public QObject -{ - Q_OBJECT - -public: - S60MediaPlayerSession(QObject *parent); - virtual ~S60MediaPlayerSession(); - - // for player control interface to use - QMediaPlayer::State state() const; - QMediaPlayer::MediaStatus mediaStatus() const; - qint64 duration() const; - qint64 position() const; - void setPosition(qint64 pos); - int volume() const; - void setVolume(int volume); - bool isMuted() const; - void setMuted(bool muted); - virtual bool isVideoAvailable() const = 0; - virtual bool isAudioAvailable() const = 0; - bool isSeekable() const; - void play(); - void pause(); - void stop(); - void reset(); - bool isMetadataAvailable() const; - QVariant metaData(const QString &key) const; - QMap<QString, QVariant> availableMetaData() const; - void load(QUrl url); - int bufferStatus(); - virtual void setVideoRenderer(QObject *renderer); - void setMediaStatus(QMediaPlayer::MediaStatus); - void setState(QMediaPlayer::State state); - void setAudioEndpoint(const QString& audioEndpoint); - -protected: - virtual void doLoadL(const TDesC &path) = 0; - virtual void doLoadUrlL(const TDesC &path) = 0; - virtual void doPlay() = 0; - virtual void doStop() = 0; - virtual void doPauseL() = 0; - virtual void doSetVolumeL(int volume) = 0; - virtual void doSetPositionL(qint64 microSeconds) = 0; - virtual qint64 doGetPositionL() const = 0; - virtual void updateMetaDataEntriesL() = 0; - virtual int doGetBufferStatusL() const = 0; - virtual qint64 doGetDurationL() const = 0; - virtual void doSetAudioEndpoint(const QString& audioEndpoint) = 0; - -public: - // From S60MediaPlayerAudioEndpointSelector - virtual QString activeEndpoint() const = 0; - virtual QString defaultEndpoint() const = 0; -public Q_SLOTS: - virtual void setActiveEndpoint(const QString& name) = 0; - -protected: - void setError(int error, const QString &errorString = QString(), bool forceReset = false); - void loaded(); - void buffering(); - void buffered(); - void endOfMedia(); - QMap<QString, QVariant>& metaDataEntries(); - QMediaPlayer::Error fromSymbianErrorToMultimediaError(int error); - void startProgressTimer(); - void stopProgressTimer(); - void startStalledTimer(); - void stopStalledTimer(); - QString TDesC2QString(const TDesC& aDescriptor); - TPtrC QString2TPtrC( const QString& string ); - QRect TRect2QRect(const TRect& tr); - TRect QRect2TRect(const QRect& qr); - - -protected slots: - void tick(); - void stalled(); - -signals: - void durationChanged(qint64 duration); - void positionChanged(qint64 position); - void stateChanged(QMediaPlayer::State state); - void mediaStatusChanged(QMediaPlayer::MediaStatus mediaStatus); - void videoAvailableChanged(bool videoAvailable); - void audioAvailableChanged(bool audioAvailable); - void bufferStatusChanged(int percentFilled); - void seekableChanged(bool); - void availablePlaybackRangesChanged(const QMediaTimeRange&); - void metaDataChanged(); - void error(int error, const QString &errorString); - void activeEndpointChanged(const QString &name); - -private: - qreal m_playbackRate; - QMap<QString, QVariant> m_metaDataMap; - bool m_muted; - int m_volume; - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_mediaStatus; - QTimer *m_progressTimer; - QTimer *m_stalledTimer; - int m_error; - bool m_play_requested; - bool m_stream; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.cpp deleted file mode 100644 index b563dd9..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.cpp +++ /dev/null @@ -1,127 +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 "S60mediarecognizer.h" -#include <e32def.h> -#include <e32cmn.h> -#include <QtCore/qurl.h> -#include <QtCore/qdir.h> -#include <QtCore/qdebug.h> - -#include <apgcli.h> - -QT_BEGIN_NAMESPACE - -static const TInt KMimeTypePrefixLength = 6; // "audio/" or "video/" -_LIT(KMimeTypePrefixAudio, "audio/"); -_LIT(KMimeTypePrefixVideo, "video/"); - -S60MediaRecognizer::S60MediaRecognizer(QObject *parent) : QObject(parent) -{ -} - -S60MediaRecognizer::~S60MediaRecognizer() -{ - m_file.Close(); - m_fileServer.Close(); - m_recognizer.Close(); -} - -S60MediaRecognizer::MediaType S60MediaRecognizer::mediaType(const QUrl &url) -{ - bool isStream = (url.scheme() == "file")?false:true; - - if (isStream) - return Url; - else - return identifyMediaType(url.toLocalFile()); -} - -S60MediaRecognizer::MediaType S60MediaRecognizer::identifyMediaType(const QString& fileName) -{ - S60MediaRecognizer::MediaType result = NotSupported; - bool recognizerOpened = false; - - TInt err = m_recognizer.Connect(); - if (err == KErrNone) { - recognizerOpened = true; - } - - err = m_fileServer.Connect(); - if (err == KErrNone) { - recognizerOpened = true; - } - - // This is needed for sharing file handles for the recognizer - err = m_fileServer.ShareProtected(); - if (err == KErrNone) { - recognizerOpened = true; - } - - if (recognizerOpened) { - m_file.Close(); - err = m_file.Open(m_fileServer, QString2TPtrC(QDir::toNativeSeparators(fileName)), EFileRead | - EFileShareReadersOnly); - - if (err == KErrNone) { - TDataRecognitionResult recognizerResult; - err = m_recognizer.RecognizeData(m_file, recognizerResult); - if (err == KErrNone) { - const TPtrC mimeType = recognizerResult.iDataType.Des(); - - if (mimeType.Left(KMimeTypePrefixLength).Compare(KMimeTypePrefixAudio) == 0) { - result = Audio; - } else if (mimeType.Left(KMimeTypePrefixLength).Compare(KMimeTypePrefixVideo) == 0) { - result = Video; - } - } - } - } - return result; -} - -TPtrC S60MediaRecognizer::QString2TPtrC( const QString& string ) -{ - // Returned TPtrC is valid as long as the given parameter is valid and unmodified - return TPtrC16(static_cast<const TUint16*>(string.utf16()), string.length()); -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.h deleted file mode 100644 index 320c34c..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.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 S60MEDIARECOGNIZER_H_ -#define S60MEDIARECOGNIZER_H_ - -#include <QtCore/qobject.h> - -#include <apgcli.h> -#include <f32file.h> - -QT_BEGIN_NAMESPACE - -class QUrl; - -class S60MediaRecognizer : public QObject -{ - Q_OBJECT - -public: - enum MediaType { - Audio, - Video, - Url, - NotSupported = -1 - }; - - S60MediaRecognizer(QObject *parent = 0); - ~S60MediaRecognizer(); - - S60MediaRecognizer::MediaType mediaType(const QUrl &url); - S60MediaRecognizer::MediaType identifyMediaType(const QString& fileName); - -protected: - TPtrC QString2TPtrC( const QString& string ); - -private: - RApaLsSession m_recognizer; - RFile m_file; - RFs m_fileServer; -}; - -QT_END_NAMESPACE - -#endif /* S60MEDIARECOGNIZER_H_ */ diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.cpp deleted file mode 100644 index 489b2e3..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.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 <QtMultimedia/qvideosurfaceformat.h> -#include "s60videooverlay.h" -#include "s60videosurface.h" - -QT_BEGIN_NAMESPACE - -S60VideoOverlay::S60VideoOverlay(QObject *parent) - : QVideoWindowControl(parent) - , m_surface(new S60VideoSurface) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_fullScreen(false) -{ - connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), - this, SLOT(surfaceFormatChanged())); -} - -S60VideoOverlay::~S60VideoOverlay() -{ - delete m_surface; -} - -WId S60VideoOverlay::winId() const -{ - return m_surface->winId(); -} - -void S60VideoOverlay::setWinId(WId id) -{ - m_surface->setWinId(id); -} - -QRect S60VideoOverlay::displayRect() const -{ - return m_displayRect; -} - -void S60VideoOverlay::setDisplayRect(const QRect &rect) -{ - m_displayRect = rect; - - setScaledDisplayRect(); -} - -Qt::AspectRatioMode S60VideoOverlay::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void S60VideoOverlay::setAspectRatioMode(Qt::AspectRatioMode ratio) -{ - m_aspectRatioMode = ratio; - - setScaledDisplayRect(); -} - -QSize S60VideoOverlay::customAspectRatio() const -{ - return m_aspectRatio; -} - -void S60VideoOverlay::setCustomAspectRatio(const QSize &customRatio) -{ - m_aspectRatio = customRatio; - - setScaledDisplayRect(); -} - -void S60VideoOverlay::repaint() -{ -} - -int S60VideoOverlay::brightness() const -{ - return m_surface->brightness(); -} - -void S60VideoOverlay::setBrightness(int brightness) -{ - m_surface->setBrightness(brightness); - - emit brightnessChanged(m_surface->brightness()); -} - -int S60VideoOverlay::contrast() const -{ - return m_surface->contrast(); -} - -void S60VideoOverlay::setContrast(int contrast) -{ - m_surface->setContrast(contrast); - - emit contrastChanged(m_surface->contrast()); -} - -int S60VideoOverlay::hue() const -{ - return m_surface->hue(); -} - -void S60VideoOverlay::setHue(int hue) -{ - m_surface->setHue(hue); - - emit hueChanged(m_surface->hue()); -} - -int S60VideoOverlay::saturation() const -{ - return m_surface->saturation(); -} - -void S60VideoOverlay::setSaturation(int saturation) -{ - m_surface->setSaturation(saturation); - - emit saturationChanged(m_surface->saturation()); -} - -bool S60VideoOverlay::isFullScreen() const -{ - return m_fullScreen; -} - -void S60VideoOverlay::setFullScreen(bool fullScreen) -{ - emit fullScreenChanged(m_fullScreen = fullScreen); -} - -QSize S60VideoOverlay::nativeSize() const -{ - return m_surface->surfaceFormat().sizeHint(); -} - -QAbstractVideoSurface *S60VideoOverlay::surface() const -{ - return m_surface; -} - -void S60VideoOverlay::surfaceFormatChanged() -{ - setScaledDisplayRect(); - - emit nativeSizeChanged(); -} - -void S60VideoOverlay::setScaledDisplayRect() -{ - switch (m_aspectRatioMode) { - case Qt::KeepAspectRatio: - { - QSize size = m_surface->surfaceFormat().viewport().size(); - - size.scale(m_displayRect.size(), Qt::KeepAspectRatio); - - QRect rect(QPoint(0, 0), size); - rect.moveCenter(m_displayRect.center()); - - m_surface->setDisplayRect(rect); - } - break; - case Qt::IgnoreAspectRatio: - m_surface->setDisplayRect(m_displayRect); - break; - }; -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.h deleted file mode 100644 index d846f32..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.h +++ /dev/null @@ -1,109 +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 S60VIDEOOVERLAY_H -#define S60VIDEOOVERLAY_H - -#include <QtCore/qobject.h> -#include <qvideowindowcontrol.h> - -QT_BEGIN_NAMESPACE - -class QAbstractVideoSurface; -class S60VideoSurface; - -class S60VideoOverlay : public QVideoWindowControl -{ - Q_OBJECT - -public: - S60VideoOverlay(QObject *parent = 0); - ~S60VideoOverlay(); - - 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); - - QSize customAspectRatio() const; - void setCustomAspectRatio(const QSize &customRatio); - - 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; - -private slots: - void surfaceFormatChanged(); - -private: - void setScaledDisplayRect(); - - S60VideoSurface *m_surface; - Qt::AspectRatioMode m_aspectRatioMode; - QRect m_displayRect; - QSize m_aspectRatio; - bool m_fullScreen; -}; - -QT_END_NAMESPACE - -#endif // S60VIDEOOVERLAY_H diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.cpp deleted file mode 100644 index 134d5a0..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.cpp +++ /dev/null @@ -1,486 +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 "s60videoplayersession.h" -#include "s60videowidget.h" -#include "s60mediaplayerservice.h" -#include "s60videooverlay.h" - -#include <QtCore/qdebug.h> -#include <QtGui/qwidget.h> -#include <QtCore/qtimer.h> -#include <QApplication> - -#include <coecntrl.h> -#include <coemain.h> // For CCoeEnv -#include <w32std.h> -#include <mmf/common/mmfcontrollerframeworkbase.h> - -#include <AudioOutput.h> -#include <MAudioOutputObserver.h> - -QT_BEGIN_NAMESPACE - -S60VideoPlayerSession::S60VideoPlayerSession(QMediaService *service) - : S60MediaPlayerSession(service) - , m_player(0) - , m_rect(0, 0, 0, 0) - , m_output(QVideoOutputControl::NoOutput) - , m_windowId(0) - , m_dsaActive(false) - , m_dsaStopped(false) - , m_wsSession(CCoeEnv::Static()->WsSession()) - , m_screenDevice(*CCoeEnv::Static()->ScreenDevice()) - , m_window(0) - , m_service(*service) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_originalSize(1, 1) - , m_audioOutput(0) - , m_audioEndpoint("Default") -{ - resetNativeHandles(); - QT_TRAP_THROWING(m_player = CVideoPlayerUtility::NewL( - *this, - 0, - EMdaPriorityPreferenceNone, - m_wsSession, - m_screenDevice, - *m_window, - m_rect, - m_rect)); - m_dsaActive = true; - m_player->RegisterForVideoLoadingNotification(*this); -} - -S60VideoPlayerSession::~S60VideoPlayerSession() -{ -#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) - if (m_audioOutput) - m_audioOutput->UnregisterObserver(*this); - delete m_audioOutput; -#endif - m_player->Close(); - delete m_player; -} - -void S60VideoPlayerSession::doLoadL(const TDesC &path) -{ - // m_audioOutput needs to be reinitialized after MapcInitComplete - if (m_audioOutput) - m_audioOutput->UnregisterObserver(*this); - delete m_audioOutput; - m_audioOutput = NULL; - - m_player->OpenFileL(path); -} - -void S60VideoPlayerSession::doLoadUrlL(const TDesC &path) -{ - // m_audioOutput needs to be reinitialized after MapcInitComplete - if (m_audioOutput) - m_audioOutput->UnregisterObserver(*this); - delete m_audioOutput; - m_audioOutput = NULL; - - m_player->OpenUrlL(path); -} - -int S60VideoPlayerSession::doGetBufferStatusL() const -{ - int progress = 0; - m_player->GetVideoLoadingProgressL(progress); - return progress; -} - -qint64 S60VideoPlayerSession::doGetDurationL() const -{ - return m_player->DurationL().Int64() / qint64(1000); -} - -void S60VideoPlayerSession::setVideoRenderer(QObject *videoOutput) -{ - Q_UNUSED(videoOutput) - QVideoOutputControl *videoControl = qobject_cast<QVideoOutputControl *>(m_service.control(QVideoOutputControl_iid)); - - //Render changes - if (m_output != videoControl->output()) { - - if (m_output == QVideoOutputControl::WidgetOutput) { - S60VideoWidgetControl *widgetControl = qobject_cast<S60VideoWidgetControl *>(m_service.control(QVideoWidgetControl_iid)); - disconnect(widgetControl, SIGNAL(widgetUpdated()), this, SLOT(resetVideoDisplay())); - disconnect(widgetControl, SIGNAL(beginVideoWindowNativePaint()), this, SLOT(suspendDirectScreenAccess())); - disconnect(widgetControl, SIGNAL(endVideoWindowNativePaint()), this, SLOT(resumeDirectScreenAccess())); - disconnect(this, SIGNAL(stateChanged(QMediaPlayer::State)), widgetControl, SLOT(videoStateChanged(QMediaPlayer::State))); - } - - if (videoControl->output() == QVideoOutputControl::WidgetOutput) { - S60VideoWidgetControl *widgetControl = qobject_cast<S60VideoWidgetControl *>(m_service.control(QVideoWidgetControl_iid)); - connect(widgetControl, SIGNAL(widgetUpdated()), this, SLOT(resetVideoDisplay())); - connect(widgetControl, SIGNAL(beginVideoWindowNativePaint()), this, SLOT(suspendDirectScreenAccess())); - connect(widgetControl, SIGNAL(endVideoWindowNativePaint()), this, SLOT(resumeDirectScreenAccess())); - connect(this, SIGNAL(stateChanged(QMediaPlayer::State)), widgetControl, SLOT(videoStateChanged(QMediaPlayer::State))); - } - - m_output = videoControl->output(); - resetVideoDisplay(); - } -} - -bool S60VideoPlayerSession::resetNativeHandles() -{ - QVideoOutputControl* videoControl = qobject_cast<QVideoOutputControl *>(m_service.control(QVideoOutputControl_iid)); - WId newId = 0; - TRect newRect = TRect(0,0,0,0); - Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio; - - if (videoControl->output() == QVideoOutputControl::WidgetOutput) { - S60VideoWidgetControl* widgetControl = qobject_cast<S60VideoWidgetControl *>(m_service.control(QVideoWidgetControl_iid)); - QWidget *videoWidget = widgetControl->videoWidget(); - newId = widgetControl->videoWidgetWId(); - newRect = QRect2TRect(QRect(videoWidget->mapToGlobal(videoWidget->pos()), videoWidget->size())); - aspectRatioMode = widgetControl->aspectRatioMode(); - } else if (videoControl->output() == QVideoOutputControl::WindowOutput) { - S60VideoOverlay* windowControl = qobject_cast<S60VideoOverlay *>(m_service.control(QVideoWindowControl_iid)); - newId = windowControl->winId(); - newRect = TRect( newId->DrawableWindow()->AbsPosition(), newId->DrawableWindow()->Size()); - } else { - if (QApplication::activeWindow()) - newId = QApplication::activeWindow()->effectiveWinId(); - - if (!newId && QApplication::allWidgets().count()) - newId = QApplication::allWidgets().at(0)->effectiveWinId(); - - Q_ASSERT(newId != 0); - } - - if (newRect == m_rect && newId == m_windowId && aspectRatioMode == m_aspectRatioMode) - return false; - - if (newId) { - m_rect = newRect; - m_windowId = newId; - m_window = m_windowId->DrawableWindow(); - m_aspectRatioMode = aspectRatioMode; - return true; - } - return false; -} - -bool S60VideoPlayerSession::isVideoAvailable() const -{ -#ifdef PRE_S60_50_PLATFORM - return true; // this is not support in pre 5th platforms -#else - if (m_player) - return m_player->VideoEnabledL(); - else - return false; -#endif -} - -bool S60VideoPlayerSession::isAudioAvailable() const -{ - if (m_player) - return m_player->AudioEnabledL(); - else - return false; -} - -void S60VideoPlayerSession::doPlay() -{ - m_player->Play(); -} - -void S60VideoPlayerSession::doPauseL() -{ - m_player->PauseL(); -} - -void S60VideoPlayerSession::doStop() -{ - m_player->Stop(); -} - -qint64 S60VideoPlayerSession::doGetPositionL() const -{ - return m_player->PositionL().Int64() / qint64(1000); -} - -void S60VideoPlayerSession::doSetPositionL(qint64 microSeconds) -{ - m_player->SetPositionL(TTimeIntervalMicroSeconds(microSeconds)); -} - -void S60VideoPlayerSession::doSetVolumeL(int volume) -{ - m_player->SetVolumeL((volume / 100.0)* m_player->MaxVolume()); -} - -QPair<qreal, qreal> S60VideoPlayerSession::scaleFactor() -{ - QSize scaled = m_originalSize; - if (m_aspectRatioMode == Qt::IgnoreAspectRatio) - scaled.scale(TRect2QRect(m_rect).size(), Qt::IgnoreAspectRatio); - else if(m_aspectRatioMode == Qt::KeepAspectRatio) - scaled.scale(TRect2QRect(m_rect).size(), Qt::KeepAspectRatio); - - qreal width = qreal(scaled.width()) / qreal(m_originalSize.width()) * qreal(100); - qreal height = qreal(scaled.height()) / qreal(m_originalSize.height()) * qreal(100); - - return QPair<qreal, qreal>(width, height); -} - -void S60VideoPlayerSession::startDirectScreenAccess() -{ - if(m_dsaActive) - return; - - TRAPD(err, m_player->StartDirectScreenAccessL()); - if(err == KErrNone) - m_dsaActive = true; - setError(err); -} - -bool S60VideoPlayerSession::stopDirectScreenAccess() -{ - if(!m_dsaActive) - return false; - - TRAPD(err, m_player->StopDirectScreenAccessL()); - if(err == KErrNone) - m_dsaActive = false; - - setError(err); - return true; -} - -void S60VideoPlayerSession::MvpuoOpenComplete(TInt aError) -{ - setError(aError); - m_player->Prepare(); -} - -void S60VideoPlayerSession::MvpuoPrepareComplete(TInt aError) -{ - setError(aError); - TRAPD(err, - m_player->SetDisplayWindowL(m_wsSession, - m_screenDevice, - *m_window, - m_rect, - m_rect); - TSize originalSize; - m_player->VideoFrameSizeL(originalSize); - m_originalSize = QSize(originalSize.iWidth, originalSize.iHeight); - m_player->SetScaleFactorL(scaleFactor().first, scaleFactor().second, true)); - - setError(err); - m_dsaActive = true; -#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) - TRAP(err, - m_audioOutput = CAudioOutput::NewL(*m_player); - m_audioOutput->RegisterObserverL(*this); - ); - setActiveEndpoint(m_audioEndpoint); - setError(err); -#endif - loaded(); -} - -void S60VideoPlayerSession::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError) -{ - Q_UNUSED(aFrame); - Q_UNUSED(aError); -} - -void S60VideoPlayerSession::MvpuoPlayComplete(TInt aError) -{ - setError(aError); - endOfMedia(); -} - -void S60VideoPlayerSession::MvpuoEvent(const TMMFEvent &aEvent) -{ - Q_UNUSED(aEvent); -} - -void S60VideoPlayerSession::updateMetaDataEntriesL() -{ - metaDataEntries().clear(); - int numberOfMetaDataEntries = 0; - - numberOfMetaDataEntries = m_player->NumberOfMetaDataEntriesL(); - - for (int i = 0; i < numberOfMetaDataEntries; i++) { - CMMFMetaDataEntry *entry = NULL; - entry = m_player->MetaDataEntryL(i); - metaDataEntries().insert(TDesC2QString(entry->Name()), TDesC2QString(entry->Value())); - delete entry; - } - emit metaDataChanged(); -} - -void S60VideoPlayerSession::resetVideoDisplay() -{ - if (resetNativeHandles()) { - TRAPD(err, - m_player->SetDisplayWindowL(m_wsSession, - m_screenDevice, - *m_window, - m_rect, - m_rect)); - setError(err); - if( mediaStatus() == QMediaPlayer::LoadedMedia - || mediaStatus() == QMediaPlayer::StalledMedia - || mediaStatus() == QMediaPlayer::BufferingMedia - || mediaStatus() == QMediaPlayer::BufferedMedia - || mediaStatus() == QMediaPlayer::EndOfMedia) { - TRAPD(err, m_player->SetScaleFactorL(scaleFactor().first, scaleFactor().second, true)); - setError(err); - } - } -} - -void S60VideoPlayerSession::suspendDirectScreenAccess() -{ - m_dsaStopped = stopDirectScreenAccess(); -} - -void S60VideoPlayerSession::resumeDirectScreenAccess() -{ - if(!m_dsaStopped) - return; - - startDirectScreenAccess(); - m_dsaStopped = false; -} - -void S60VideoPlayerSession::MvloLoadingStarted() -{ - buffering(); -} - -void S60VideoPlayerSession::MvloLoadingComplete() -{ - buffered(); -} - -void S60VideoPlayerSession::doSetAudioEndpoint(const QString& audioEndpoint) -{ - m_audioEndpoint = audioEndpoint; -} - -QString S60VideoPlayerSession::activeEndpoint() const -{ - QString outputName = QString("Default"); -#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) - if (m_audioOutput) { - CAudioOutput::TAudioOutputPreference output = m_audioOutput->AudioOutput(); - outputName = qStringFromTAudioOutputPreference(output); - } -#endif - return outputName; -} - -QString S60VideoPlayerSession::defaultEndpoint() const -{ - QString outputName = QString("Default"); -#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) - if (m_audioOutput) { - CAudioOutput::TAudioOutputPreference output = m_audioOutput->DefaultAudioOutput(); - outputName = qStringFromTAudioOutputPreference(output); - } -#endif - return outputName; -} - -void S60VideoPlayerSession::setActiveEndpoint(const QString& name) -{ - CAudioOutput::TAudioOutputPreference output = CAudioOutput::ENoPreference; - - if (name == QString("Default")) - output = CAudioOutput::ENoPreference; - else if (name == QString("All")) - output = CAudioOutput::EAll; - else if (name == QString("None")) - output = CAudioOutput::ENoOutput; - else if (name == QString("Earphone")) - output = CAudioOutput::EPrivate; - else if (name == QString("Speaker")) - output = CAudioOutput::EPublic; -#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) - if (m_audioOutput) { - TRAPD(err, m_audioOutput->SetAudioOutputL(output)); - setError(err); - - if (m_audioEndpoint != name) { - m_audioEndpoint = name; - emit activeEndpointChanged(name); - } - } -#endif -} - -void S60VideoPlayerSession::DefaultAudioOutputChanged( CAudioOutput& aAudioOutput, - CAudioOutput::TAudioOutputPreference aNewDefault ) -{ - // Emit already implemented in setActiveEndpoint function - Q_UNUSED(aAudioOutput) - Q_UNUSED(aNewDefault) -} - -QString S60VideoPlayerSession::qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const -{ - if (output == CAudioOutput::ENoPreference) - return QString("Default"); - else if (output == CAudioOutput::EAll) - return QString("All"); - else if (output == CAudioOutput::ENoOutput) - return QString("None"); - else if (output == CAudioOutput::EPrivate) - return QString("Earphone"); - else if (output == CAudioOutput::EPublic) - return QString("Speaker"); - return QString("Default"); -} - -QT_END_NAMESPACE - diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.h deleted file mode 100644 index 9aece61..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.h +++ /dev/null @@ -1,147 +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 S60VIDEOPLAYERSESSION_H -#define S60VIDEOPLAYERSESSION_H - -#include "s60mediaplayersession.h" -#include "s60mediaplayeraudioendpointselector.h" -#include <videoplayer.h> -#include <QtGui/qwidget.h> -#include <qvideowidget.h> - -#include <phonon/audiooutput.h> - -QT_BEGIN_NAMESPACE - -class QTimer; - -class S60VideoPlayerSession : public S60MediaPlayerSession, - public MVideoPlayerUtilityObserver, - public MVideoLoadingObserver, - public MAudioOutputObserver -{ - Q_OBJECT - -public: - S60VideoPlayerSession(QMediaService *service); - ~S60VideoPlayerSession(); - - //From S60MediaPlayerSession - bool isVideoAvailable() const; - bool isAudioAvailable() const; - void setVideoRenderer(QObject *renderer); - - //From MVideoLoadingObserver - void MvloLoadingStarted(); - void MvloLoadingComplete(); - - // From MAudioOutputObserver - void DefaultAudioOutputChanged(CAudioOutput& aAudioOutput, - CAudioOutput::TAudioOutputPreference aNewDefault); - -public: - // From S60MediaPlayerAudioEndpointSelector - QString activeEndpoint() const; - QString defaultEndpoint() const; -public Q_SLOTS: - void setActiveEndpoint(const QString& name); -Q_SIGNALS: - void activeEndpointChanged(const QString &name); - -protected: - //From S60MediaPlayerSession - void doLoadL(const TDesC &path); - void doLoadUrlL(const TDesC &path); - void doPlay(); - void doStop(); - void doPauseL(); - void doSetVolumeL(int volume); - qint64 doGetPositionL() const; - void doSetPositionL(qint64 microSeconds); - void updateMetaDataEntriesL(); - int doGetBufferStatusL() const; - qint64 doGetDurationL() const; - void doSetAudioEndpoint(const QString& audioEndpoint); - -private slots: - void resetVideoDisplay(); - void suspendDirectScreenAccess(); - void resumeDirectScreenAccess(); - -private: - bool resetNativeHandles(); - QPair<qreal, qreal> scaleFactor(); - void startDirectScreenAccess(); - bool stopDirectScreenAccess(); - QString qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const; - - - // From MVideoPlayerUtilityObserver - void MvpuoOpenComplete(TInt aError); - void MvpuoPrepareComplete(TInt aError); - void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError); - void MvpuoPlayComplete(TInt aError); - void MvpuoEvent(const TMMFEvent &aEvent); - -private: - // Qwn - CVideoPlayerUtility *m_player; - TRect m_rect; - QVideoOutputControl::Output m_output; - WId m_windowId; - bool m_dsaActive; - bool m_dsaStopped; - - //Reference - RWsSession &m_wsSession; - CWsScreenDevice &m_screenDevice; - RWindowBase *m_window; - QMediaService &m_service; - Qt::AspectRatioMode m_aspectRatioMode; - QSize m_originalSize; - CAudioOutput *m_audioOutput; - QString m_audioEndpoint; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.cpp deleted file mode 100644 index 269dd43..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.cpp +++ /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$ -** -****************************************************************************/ - -#include "s60videorenderer.h" - -#include <QtCore/qcoreevent.h> -#include <QtGui/qapplication.h> - -QT_BEGIN_NAMESPACE - -S60VideoRenderer::S60VideoRenderer(QObject *parent) - : QVideoRendererControl(parent) -{ -} - -S60VideoRenderer::~S60VideoRenderer() -{ -} - - -QAbstractVideoSurface *S60VideoRenderer::surface() const -{ - return m_surface; -} - -void S60VideoRenderer::setSurface(QAbstractVideoSurface *surface) -{ - m_surface = surface; -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.h deleted file mode 100644 index 260dc8b..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.h +++ /dev/null @@ -1,68 +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 S60VIDEORENDERER_H -#define S60VIDEORENDERER_H - -#include <QtCore/qobject.h> -#include <qvideorenderercontrol.h> - -QT_BEGIN_NAMESPACE - -class S60VideoRenderer : public QVideoRendererControl -{ - Q_OBJECT - -public: - S60VideoRenderer(QObject *parent = 0); - virtual ~S60VideoRenderer(); - - QAbstractVideoSurface *surface() const; - void setSurface(QAbstractVideoSurface *surface); - -private: - - QAbstractVideoSurface *m_surface; -}; - -QT_END_NAMESPACE - -#endif // S60VIDEORENDERER_H diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.cpp deleted file mode 100644 index bfa7a13..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.cpp +++ /dev/null @@ -1,478 +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 <QtGui/qx11info_x11.h> - -#include "s60videosurface.h" - -QT_BEGIN_NAMESPACE - -/*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, "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" } -}; -*/ - -S60VideoSurface::S60VideoSurface(QObject *parent) - : QAbstractVideoSurface(parent) - , m_winId(0) - //, m_portId(0) - //, m_gc(0) - //, m_image(0) -{ -} - -S60VideoSurface::~S60VideoSurface() -{ - /*if (m_gc) - XFreeGC(QX11Info::display(), m_gc); - - if (m_portId != 0) - XvUngrabPort(QX11Info::display(), m_portId, 0); - */ -} - -WId S60VideoSurface::winId() const -{ - return m_winId; -} - -void S60VideoSurface::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(); - }*/ -} - -QRect S60VideoSurface::displayRect() const -{ - return m_displayRect; -} - -void S60VideoSurface::setDisplayRect(const QRect &rect) -{ - m_displayRect = rect; -} - -int S60VideoSurface::brightness() const -{ - //return getAttribute("XV_BRIGHTNESS", m_brightnessRange.first, m_brightnessRange.second); -} - -void S60VideoSurface::setBrightness(int brightness) -{ - //setAttribute("XV_BRIGHTNESS", brightness, m_brightnessRange.first, m_brightnessRange.second); -} - -int S60VideoSurface::contrast() const -{ - //return getAttribute("XV_CONTRAST", m_contrastRange.first, m_contrastRange.second); -} - -void S60VideoSurface::setContrast(int contrast) -{ - //setAttribute("XV_CONTRAST", contrast, m_contrastRange.first, m_contrastRange.second); -} - -int S60VideoSurface::hue() const -{ - //return getAttribute("XV_HUE", m_hueRange.first, m_hueRange.second); -} - -void S60VideoSurface::setHue(int hue) -{ - // setAttribute("XV_HUE", hue, m_hueRange.first, m_hueRange.second); -} - -int S60VideoSurface::saturation() const -{ - //return getAttribute("XV_SATURATION", m_saturationRange.first, m_saturationRange.second); -} - -void S60VideoSurface::setSaturation(int saturation) -{ - //setAttribute("XV_SATURATION", saturation, m_saturationRange.first, m_saturationRange.second); -} - -int S60VideoSurface::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 S60VideoSurface::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 S60VideoSurface::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> S60VideoSurface::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - /*return handleType == QAbstractVideoBuffer::NoHandle - ? m_supportedPixelFormats - : QList<QVideoFrame::PixelFormat>();*/ -} - -bool S60VideoSurface::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; - - return QAbstractVideoSurface::start(format); - } - } - - if (m_image) { - m_image = 0; - - QAbstractVideoSurface::stop(); - } -*/ - return false; -} - -void S60VideoSurface::stop() -{/* - if (m_image) { - XFree(m_image); - m_image = 0; - - QAbstractVideoSurface::stop(); - }*/ -} - -bool S60VideoSurface::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 (m_image->data_size > frame.numBytes()) { - qWarning("Insufficient frame buffer size"); - setError(IncorrectFormatError); - } else if (m_image->num_planes > 0 && m_image->pitches[0] != frame.bytesPerLine()) { - qWarning("Incompatible frame pitches"); - setError(IncorrectFormatError); - } else { - m_image->data = reinterpret_cast<char *>(frameCopy.bits()); - - 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; - - presented = true; - } - - frameCopy.unmap(); - - return presented; - } - }*/ -} - -bool S60VideoSurface::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 S60VideoSurface::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); - }*/ -} - -bool S60VideoSurface::isFormatSupported(const QVideoSurfaceFormat &format) const -{ -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.h deleted file mode 100644 index 836e52f..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.h +++ /dev/null @@ -1,112 +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 S60VIDEOSURFACE_H -#define S60VIDEOSURFACE_H - -#include <QtGui/qwidget.h> -#include <QtMultimedia/qabstractvideosurface.h> - -QT_BEGIN_NAMESPACE - -class QVideoSurfaceFormat; - -class S60VideoSurface : public QAbstractVideoSurface -{ - Q_OBJECT -public: - S60VideoSurface(QObject *parent = 0); - ~S60VideoSurface(); - - WId winId() const; - void setWinId(WId id); - - QRect displayRect() const; - void setDisplayRect(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 isFormatSupported(const QVideoSurfaceFormat &format) 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 - -#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.cpp deleted file mode 100644 index 84000d5..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.cpp +++ /dev/null @@ -1,208 +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 "s60videowidget.h" -#include <QtGui/private/qwidget_p.h> -#include <QEvent> -#include <coemain.h> // For CCoeEnv - -QT_BEGIN_NAMESPACE - -QBlackWidget::QBlackWidget(QWidget *parent) - : QWidget(parent) -{ - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - setAttribute(Qt::WA_OpaquePaintEvent, true); - setAttribute(Qt::WA_NoSystemBackground, true); - setAutoFillBackground(false); - setPalette(QPalette(Qt::black)); -#if QT_VERSION >= 0x040601 && !defined(__WINSCW__) - qt_widget_private(this)->extraData()->nativePaintMode = QWExtra::ZeroFill; - qt_widget_private(this)->extraData()->receiveNativePaintEvents = true; -#endif -} - -QBlackWidget::~QBlackWidget() -{ -} - -void QBlackWidget::beginNativePaintEvent(const QRect& /*controlRect*/) -{ - emit beginVideoWindowNativePaint(); -} - -void QBlackWidget::endNativePaintEvent(const QRect& /*controlRect*/) -{ - CCoeEnv::Static()->WsSession().Flush(); - emit endVideoWindowNativePaint(); -} - -void QBlackWidget::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - // Do nothing -} - -S60VideoWidgetControl::S60VideoWidgetControl(QObject *parent) - : QVideoWidgetControl(parent) - , m_widget(0) - , m_aspectRatioMode(Qt::KeepAspectRatio) -{ - m_widget = new QBlackWidget(); - connect(m_widget, SIGNAL(beginVideoWindowNativePaint()), this, SIGNAL(beginVideoWindowNativePaint())); - connect(m_widget, SIGNAL(endVideoWindowNativePaint()), this, SIGNAL(endVideoWindowNativePaint())); - m_widget->installEventFilter(this); - m_widget->winId(); -} - -S60VideoWidgetControl::~S60VideoWidgetControl() -{ - delete m_widget; -} - -QWidget *S60VideoWidgetControl::videoWidget() -{ - return m_widget; -} - -Qt::AspectRatioMode S60VideoWidgetControl::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void S60VideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode ratio) -{ - if (m_aspectRatioMode == ratio) - return; - - m_aspectRatioMode = ratio; - emit widgetUpdated(); -} - -bool S60VideoWidgetControl::isFullScreen() const -{ - return m_widget->isFullScreen(); -} - -void S60VideoWidgetControl::setFullScreen(bool fullScreen) -{ - emit fullScreenChanged(fullScreen); -} - -int S60VideoWidgetControl::brightness() const -{ - return 0; -} - -void S60VideoWidgetControl::setBrightness(int brightness) -{ - Q_UNUSED(brightness); -} - -int S60VideoWidgetControl::contrast() const -{ - return 0; -} - -void S60VideoWidgetControl::setContrast(int contrast) -{ - Q_UNUSED(contrast); -} - -int S60VideoWidgetControl::hue() const -{ - return 0; -} - -void S60VideoWidgetControl::setHue(int hue) -{ - Q_UNUSED(hue); -} - -int S60VideoWidgetControl::saturation() const -{ - return 0; -} - -void S60VideoWidgetControl::setSaturation(int saturation) -{ - Q_UNUSED(saturation); -} - -bool S60VideoWidgetControl::eventFilter(QObject *object, QEvent *e) -{ - if (object == m_widget) { - if ( e->type() == QEvent::Resize - || e->type() == QEvent::Move - || e->type() == QEvent::WinIdChange - || e->type() == QEvent::ParentChange - || e->type() == QEvent::Show) - emit widgetUpdated(); - } - return false; -} - -WId S60VideoWidgetControl::videoWidgetWId() -{ - if (m_widget->internalWinId()) - return m_widget->internalWinId(); - - if (m_widget->effectiveWinId()) - return m_widget->effectiveWinId(); - - return NULL; -} - -void S60VideoWidgetControl::videoStateChanged(QMediaPlayer::State state) -{ - if (state == QMediaPlayer::StoppedState) { -#if QT_VERSION <= 0x040600 && !defined(FF_QT) - qt_widget_private(m_widget)->extraData()->disableBlit = false; -#endif - m_widget->repaint(); - } else if (state == QMediaPlayer::PlayingState) { -#if QT_VERSION <= 0x040600 && !defined(FF_QT) - qt_widget_private(m_widget)->extraData()->disableBlit = true; -#endif - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.h deleted file mode 100644 index 28a1455..0000000 --- a/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.h +++ /dev/null @@ -1,115 +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 S60VIDEOWIDGET_H -#define S60VIDEOWIDGET_H - -#include <qvideowidgetcontrol.h> -#include <qmediaplayer.h> - -QT_BEGIN_NAMESPACE - -class QBlackWidget : public QWidget -{ - Q_OBJECT - -public: - QBlackWidget(QWidget *parent = 0); - virtual ~QBlackWidget(); - -signals: - void beginVideoWindowNativePaint(); - void endVideoWindowNativePaint(); - -public slots: - void beginNativePaintEvent(const QRect&); - void endNativePaintEvent(const QRect&); - -protected: - void paintEvent(QPaintEvent *event); -}; - -class S60VideoWidgetControl : public QVideoWidgetControl -{ - Q_OBJECT - -public: - S60VideoWidgetControl(QObject *parent = 0); - virtual ~S60VideoWidgetControl(); - - // from QVideoWidgetControl - QWidget *videoWidget(); - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode ratio); - 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); - - // from QObject - bool eventFilter(QObject *object, QEvent *event); - - //new methods - WId videoWidgetWId(); - -signals: - void widgetUpdated(); - void beginVideoWindowNativePaint(); - void endVideoWindowNativePaint(); - -private slots: - void videoStateChanged(QMediaPlayer::State state); - -private: - QBlackWidget *m_widget; - Qt::AspectRatioMode m_aspectRatioMode; -}; - -QT_END_NAMESPACE - - -#endif // S60VIDEOWIDGET_H diff --git a/src/plugins/mediaservices/symbian/s60mediaserviceplugin.cpp b/src/plugins/mediaservices/symbian/s60mediaserviceplugin.cpp deleted file mode 100644 index 1185583..0000000 --- a/src/plugins/mediaservices/symbian/s60mediaserviceplugin.cpp +++ /dev/null @@ -1,100 +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 "s60mediaserviceplugin.h" -#ifdef QMEDIA_MMF_RADIO -#include "s60radiotunerservice.h" -#endif -#ifdef QMEDIA_MMF_PLAYER -#include "s60mediaplayerservice.h" -#endif -#ifdef QMEDIA_MMF_CAPTURE -#include "s60audiocaptureservice.h" -#endif - -QT_BEGIN_NAMESPACE - -QStringList S60MediaServicePlugin::keys() const -{ - QStringList list; -#ifdef QMEDIA_MMF_RADIO - list << QLatin1String(Q_MEDIASERVICE_RADIO); -#endif - -#ifdef QMEDIA_MMF_PLAYER - list << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); -#endif -#ifdef QMEDIA_MMF_CAPTURE - list << QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE); -#endif - return list; -} - -QMediaService* S60MediaServicePlugin::create(QString const& key) -{ -#ifdef QMEDIA_MMF_PLAYER - if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)) - return new S60MediaPlayerService; -#endif -#ifdef QMEDIA_MMF_CAPTURE - if (key == QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE)) - return new S60AudioCaptureService; -#endif -#ifdef QMEDIA_MMF_RADIO - if (key == QLatin1String(Q_MEDIASERVICE_RADIO)) - return new S60RadioTunerService; -#endif - - return 0; -} - -void S60MediaServicePlugin::release(QMediaService *service) -{ - delete service; -} - -QT_END_NAMESPACE - -Q_EXPORT_PLUGIN2(qmmfengine, S60MediaServicePlugin); - diff --git a/src/plugins/mediaservices/symbian/s60mediaserviceplugin.h b/src/plugins/mediaservices/symbian/s60mediaserviceplugin.h deleted file mode 100644 index be2e05d..0000000 --- a/src/plugins/mediaservices/symbian/s60mediaserviceplugin.h +++ /dev/null @@ -1,64 +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 S60SERVICEPLUGIN_H -#define S60SERVICEPLUGIN_H - -#include <QtCore/qobject.h> -#include <qmediaservice.h> -#include <qmediaserviceproviderplugin.h> - -QT_BEGIN_NAMESPACE - -class S60MediaServicePlugin : public QMediaServiceProviderPlugin -{ - Q_OBJECT -public: - - QStringList keys() const; - QMediaService* create(QString const& key); - void release(QMediaService *service); -}; - -QT_END_NAMESPACE - -#endif // S60SERVICEPLUGIN_H diff --git a/src/plugins/mediaservices/symbian/s60videooutputcontrol.cpp b/src/plugins/mediaservices/symbian/s60videooutputcontrol.cpp deleted file mode 100644 index da07a7d..0000000 --- a/src/plugins/mediaservices/symbian/s60videooutputcontrol.cpp +++ /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$ -** -****************************************************************************/ - -#include "s60videooutputcontrol.h" - -QT_BEGIN_NAMESPACE - -S60VideoOutputControl::S60VideoOutputControl(QObject *parent) - : QVideoOutputControl(parent) - , m_output(NoOutput) -{ -} - -QList<QVideoOutputControl::Output> S60VideoOutputControl::availableOutputs() const -{ - return m_outputs; -} - -void S60VideoOutputControl::setAvailableOutputs(const QList<Output> &outputs) -{ - emit availableOutputsChanged(m_outputs = outputs); -} - -QVideoOutputControl::Output S60VideoOutputControl::output() const -{ - return m_output; -} - -void S60VideoOutputControl::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/symbian/s60videooutputcontrol.h b/src/plugins/mediaservices/symbian/s60videooutputcontrol.h deleted file mode 100644 index dbad889..0000000 --- a/src/plugins/mediaservices/symbian/s60videooutputcontrol.h +++ /dev/null @@ -1,72 +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 S60VIDEOOUTPUTCONTROL_H -#define S60VIDEOOUTPUTCONTROL_H - -#include <QObject> -#include <qvideooutputcontrol.h> - -QT_BEGIN_NAMESPACE - -class S60VideoOutputControl : public QVideoOutputControl -{ - Q_OBJECT -public: - S60VideoOutputControl(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 - -#endif diff --git a/src/plugins/mediaservices/symbian/symbian.pro b/src/plugins/mediaservices/symbian/symbian.pro deleted file mode 100644 index f76858f..0000000 --- a/src/plugins/mediaservices/symbian/symbian.pro +++ /dev/null @@ -1,27 +0,0 @@ -TARGET = qmmfengine -QT += multimedia mediaservices - -load(data_caging_paths) - -include (../../qpluginbase.pri) -include(mediaplayer/mediaplayer.pri) - -HEADERS += s60mediaserviceplugin.h \ - s60videooutputcontrol.h - -SOURCES += s60mediaserviceplugin.cpp \ - s60videooutputcontrol.cpp - -contains(S60_VERSION, 3.2)|contains(S60_VERSION, 3.1) { - DEFINES += PRE_S60_50_PLATFORM -} - -INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE -symbian-abld:INCLUDEPATH += $$QT_BUILD_TREE/include/QtWidget/private - -# This is needed for having the .qtplugin file properly created on Symbian. -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mediaservices -target.path += $$[QT_INSTALL_PLUGINS]/mediaservices -INSTALLS += target - -TARGET.UID3=0x20021318 diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 507654f..722979d 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -13,6 +13,6 @@ embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers !symbian:!contains(QT_CONFIG, no-gui):SUBDIRS += accessible symbian:SUBDIRS += s60 contains(QT_CONFIG, phonon): SUBDIRS *= phonon -contains(QT_CONFIG, multimedia): SUBDIRS *= audio mediaservices +contains(QT_CONFIG, multimedia): SUBDIRS *= audio diff --git a/src/s60installs/bwins/QtMediaServicesu.def b/src/s60installs/bwins/QtMediaServicesu.def deleted file mode 100644 index d674d12..0000000 --- a/src/s60installs/bwins/QtMediaServicesu.def +++ /dev/null @@ -1,673 +0,0 @@ -EXPORTS - ??0QGraphicsVideoItem@@QAE@PAVQGraphicsItem@@@Z @ 1 NONAME ; QGraphicsVideoItem::QGraphicsVideoItem(class QGraphicsItem *) - ??0QLocalMediaPlaylistProvider@@QAE@PAVQObject@@@Z @ 2 NONAME ; QLocalMediaPlaylistProvider::QLocalMediaPlaylistProvider(class QObject *) - ??0QMediaContent@@QAE@ABV0@@Z @ 3 NONAME ; QMediaContent::QMediaContent(class QMediaContent const &) - ??0QMediaContent@@QAE@ABV?$QList@VQMediaResource@@@@@Z @ 4 NONAME ; QMediaContent::QMediaContent(class QList<class QMediaResource> const &) - ??0QMediaContent@@QAE@ABVQMediaResource@@@Z @ 5 NONAME ; QMediaContent::QMediaContent(class QMediaResource const &) - ??0QMediaContent@@QAE@ABVQNetworkRequest@@@Z @ 6 NONAME ; QMediaContent::QMediaContent(class QNetworkRequest const &) - ??0QMediaContent@@QAE@ABVQUrl@@@Z @ 7 NONAME ; QMediaContent::QMediaContent(class QUrl const &) - ??0QMediaContent@@QAE@XZ @ 8 NONAME ; QMediaContent::QMediaContent(void) - ??0QMediaControl@@IAE@AAVQMediaControlPrivate@@PAVQObject@@@Z @ 9 NONAME ; QMediaControl::QMediaControl(class QMediaControlPrivate &, class QObject *) - ??0QMediaControl@@IAE@PAVQObject@@@Z @ 10 NONAME ; QMediaControl::QMediaControl(class QObject *) - ??0QMediaObject@@IAE@AAVQMediaObjectPrivate@@PAVQObject@@PAVQMediaService@@@Z @ 11 NONAME ; QMediaObject::QMediaObject(class QMediaObjectPrivate &, class QObject *, class QMediaService *) - ??0QMediaObject@@IAE@PAVQObject@@PAVQMediaService@@@Z @ 12 NONAME ; QMediaObject::QMediaObject(class QObject *, class QMediaService *) - ??0QMediaPlayer@@QAE@PAVQObject@@V?$QFlags@W4Flag@QMediaPlayer@@@@PAVQMediaServiceProvider@@@Z @ 13 NONAME ; QMediaPlayer::QMediaPlayer(class QObject *, class QFlags<enum QMediaPlayer::Flag>, class QMediaServiceProvider *) - ??0QMediaPlayerControl@@IAE@PAVQObject@@@Z @ 14 NONAME ; QMediaPlayerControl::QMediaPlayerControl(class QObject *) - ??0QMediaPlaylist@@QAE@PAVQObject@@@Z @ 15 NONAME ; QMediaPlaylist::QMediaPlaylist(class QObject *) - ??0QMediaPlaylistControl@@IAE@PAVQObject@@@Z @ 16 NONAME ; QMediaPlaylistControl::QMediaPlaylistControl(class QObject *) - ??0QMediaPlaylistIOPlugin@@QAE@PAVQObject@@@Z @ 17 NONAME ; QMediaPlaylistIOPlugin::QMediaPlaylistIOPlugin(class QObject *) - ??0QMediaPlaylistNavigator@@QAE@PAVQMediaPlaylistProvider@@PAVQObject@@@Z @ 18 NONAME ; QMediaPlaylistNavigator::QMediaPlaylistNavigator(class QMediaPlaylistProvider *, class QObject *) - ??0QMediaPlaylistProvider@@IAE@AAVQMediaPlaylistProviderPrivate@@PAVQObject@@@Z @ 19 NONAME ; QMediaPlaylistProvider::QMediaPlaylistProvider(class QMediaPlaylistProviderPrivate &, class QObject *) - ??0QMediaPlaylistProvider@@QAE@PAVQObject@@@Z @ 20 NONAME ; QMediaPlaylistProvider::QMediaPlaylistProvider(class QObject *) - ??0QMediaResource@@QAE@ABV0@@Z @ 21 NONAME ; QMediaResource::QMediaResource(class QMediaResource const &) - ??0QMediaResource@@QAE@ABVQNetworkRequest@@ABVQString@@@Z @ 22 NONAME ; QMediaResource::QMediaResource(class QNetworkRequest const &, class QString const &) - ??0QMediaResource@@QAE@ABVQUrl@@ABVQString@@@Z @ 23 NONAME ; QMediaResource::QMediaResource(class QUrl const &, class QString const &) - ??0QMediaResource@@QAE@XZ @ 24 NONAME ; QMediaResource::QMediaResource(void) - ??0QMediaService@@IAE@AAVQMediaServicePrivate@@PAVQObject@@@Z @ 25 NONAME ; QMediaService::QMediaService(class QMediaServicePrivate &, class QObject *) - ??0QMediaService@@IAE@PAVQObject@@@Z @ 26 NONAME ; QMediaService::QMediaService(class QObject *) - ??0QMediaServiceProviderHint@@QAE@ABV0@@Z @ 27 NONAME ; QMediaServiceProviderHint::QMediaServiceProviderHint(class QMediaServiceProviderHint const &) - ??0QMediaServiceProviderHint@@QAE@ABVQByteArray@@@Z @ 28 NONAME ; QMediaServiceProviderHint::QMediaServiceProviderHint(class QByteArray const &) - ??0QMediaServiceProviderHint@@QAE@ABVQString@@ABVQStringList@@@Z @ 29 NONAME ; QMediaServiceProviderHint::QMediaServiceProviderHint(class QString const &, class QStringList const &) - ??0QMediaServiceProviderHint@@QAE@V?$QFlags@W4Feature@QMediaServiceProviderHint@@@@@Z @ 30 NONAME ; QMediaServiceProviderHint::QMediaServiceProviderHint(class QFlags<enum QMediaServiceProviderHint::Feature>) - ??0QMediaServiceProviderHint@@QAE@XZ @ 31 NONAME ; QMediaServiceProviderHint::QMediaServiceProviderHint(void) - ??0QMediaTimeInterval@@QAE@ABV0@@Z @ 32 NONAME ; QMediaTimeInterval::QMediaTimeInterval(class QMediaTimeInterval const &) - ??0QMediaTimeInterval@@QAE@XZ @ 33 NONAME ; QMediaTimeInterval::QMediaTimeInterval(void) - ??0QMediaTimeInterval@@QAE@_J0@Z @ 34 NONAME ; QMediaTimeInterval::QMediaTimeInterval(long long, long long) - ??0QMediaTimeRange@@QAE@ABV0@@Z @ 35 NONAME ; QMediaTimeRange::QMediaTimeRange(class QMediaTimeRange const &) - ??0QMediaTimeRange@@QAE@ABVQMediaTimeInterval@@@Z @ 36 NONAME ; QMediaTimeRange::QMediaTimeRange(class QMediaTimeInterval const &) - ??0QMediaTimeRange@@QAE@XZ @ 37 NONAME ; QMediaTimeRange::QMediaTimeRange(void) - ??0QMediaTimeRange@@QAE@_J0@Z @ 38 NONAME ; QMediaTimeRange::QMediaTimeRange(long long, long long) - ??0QMetaDataControl@@IAE@PAVQObject@@@Z @ 39 NONAME ; QMetaDataControl::QMetaDataControl(class QObject *) - ??0QPainterVideoSurface@@QAE@PAVQObject@@@Z @ 40 NONAME ; QPainterVideoSurface::QPainterVideoSurface(class QObject *) - ??0QSoundEffect@@QAE@PAVQObject@@@Z @ 41 NONAME ; QSoundEffect::QSoundEffect(class QObject *) - ??0QVideoDeviceControl@@IAE@PAVQObject@@@Z @ 42 NONAME ; QVideoDeviceControl::QVideoDeviceControl(class QObject *) - ??0QVideoOutputControl@@IAE@PAVQObject@@@Z @ 43 NONAME ; QVideoOutputControl::QVideoOutputControl(class QObject *) - ??0QVideoRendererControl@@IAE@PAVQObject@@@Z @ 44 NONAME ; QVideoRendererControl::QVideoRendererControl(class QObject *) - ??0QVideoWidget@@QAE@PAVQWidget@@@Z @ 45 NONAME ; QVideoWidget::QVideoWidget(class QWidget *) - ??0QVideoWidgetControl@@IAE@PAVQObject@@@Z @ 46 NONAME ; QVideoWidgetControl::QVideoWidgetControl(class QObject *) - ??0QVideoWindowControl@@IAE@PAVQObject@@@Z @ 47 NONAME ; QVideoWindowControl::QVideoWindowControl(class QObject *) - ??1QGraphicsVideoItem@@UAE@XZ @ 48 NONAME ; QGraphicsVideoItem::~QGraphicsVideoItem(void) - ??1QLocalMediaPlaylistProvider@@UAE@XZ @ 49 NONAME ; QLocalMediaPlaylistProvider::~QLocalMediaPlaylistProvider(void) - ??1QMediaContent@@QAE@XZ @ 50 NONAME ; QMediaContent::~QMediaContent(void) - ??1QMediaControl@@UAE@XZ @ 51 NONAME ; QMediaControl::~QMediaControl(void) - ??1QMediaObject@@UAE@XZ @ 52 NONAME ; QMediaObject::~QMediaObject(void) - ??1QMediaPlayer@@UAE@XZ @ 53 NONAME ; QMediaPlayer::~QMediaPlayer(void) - ??1QMediaPlayerControl@@UAE@XZ @ 54 NONAME ; QMediaPlayerControl::~QMediaPlayerControl(void) - ??1QMediaPlaylist@@UAE@XZ @ 55 NONAME ; QMediaPlaylist::~QMediaPlaylist(void) - ??1QMediaPlaylistControl@@UAE@XZ @ 56 NONAME ; QMediaPlaylistControl::~QMediaPlaylistControl(void) - ??1QMediaPlaylistIOInterface@@UAE@XZ @ 57 NONAME ; QMediaPlaylistIOInterface::~QMediaPlaylistIOInterface(void) - ??1QMediaPlaylistIOPlugin@@UAE@XZ @ 58 NONAME ; QMediaPlaylistIOPlugin::~QMediaPlaylistIOPlugin(void) - ??1QMediaPlaylistNavigator@@UAE@XZ @ 59 NONAME ; QMediaPlaylistNavigator::~QMediaPlaylistNavigator(void) - ??1QMediaPlaylistProvider@@UAE@XZ @ 60 NONAME ; QMediaPlaylistProvider::~QMediaPlaylistProvider(void) - ??1QMediaPlaylistReader@@UAE@XZ @ 61 NONAME ; QMediaPlaylistReader::~QMediaPlaylistReader(void) - ??1QMediaPlaylistWriter@@UAE@XZ @ 62 NONAME ; QMediaPlaylistWriter::~QMediaPlaylistWriter(void) - ??1QMediaResource@@QAE@XZ @ 63 NONAME ; QMediaResource::~QMediaResource(void) - ??1QMediaService@@UAE@XZ @ 64 NONAME ; QMediaService::~QMediaService(void) - ??1QMediaServiceFeaturesInterface@@UAE@XZ @ 65 NONAME ; QMediaServiceFeaturesInterface::~QMediaServiceFeaturesInterface(void) - ??1QMediaServiceProvider@@UAE@XZ @ 66 NONAME ; QMediaServiceProvider::~QMediaServiceProvider(void) - ??1QMediaServiceProviderHint@@QAE@XZ @ 67 NONAME ; QMediaServiceProviderHint::~QMediaServiceProviderHint(void) - ??1QMediaServiceSupportedDevicesInterface@@UAE@XZ @ 68 NONAME ; QMediaServiceSupportedDevicesInterface::~QMediaServiceSupportedDevicesInterface(void) - ??1QMediaServiceSupportedFormatsInterface@@UAE@XZ @ 69 NONAME ; QMediaServiceSupportedFormatsInterface::~QMediaServiceSupportedFormatsInterface(void) - ??1QMediaTimeRange@@QAE@XZ @ 70 NONAME ; QMediaTimeRange::~QMediaTimeRange(void) - ??1QMetaDataControl@@UAE@XZ @ 71 NONAME ; QMetaDataControl::~QMetaDataControl(void) - ??1QPainterVideoSurface@@UAE@XZ @ 72 NONAME ; QPainterVideoSurface::~QPainterVideoSurface(void) - ??1QSoundEffect@@UAE@XZ @ 73 NONAME ; QSoundEffect::~QSoundEffect(void) - ??1QVideoDeviceControl@@UAE@XZ @ 74 NONAME ; QVideoDeviceControl::~QVideoDeviceControl(void) - ??1QVideoOutputControl@@UAE@XZ @ 75 NONAME ; QVideoOutputControl::~QVideoOutputControl(void) - ??1QVideoRendererControl@@UAE@XZ @ 76 NONAME ; QVideoRendererControl::~QVideoRendererControl(void) - ??1QVideoWidget@@UAE@XZ @ 77 NONAME ; QVideoWidget::~QVideoWidget(void) - ??1QVideoWidgetControl@@UAE@XZ @ 78 NONAME ; QVideoWidgetControl::~QVideoWidgetControl(void) - ??1QVideoWindowControl@@UAE@XZ @ 79 NONAME ; QVideoWindowControl::~QVideoWindowControl(void) - ??4QMediaContent@@QAEAAV0@ABV0@@Z @ 80 NONAME ; class QMediaContent & QMediaContent::operator=(class QMediaContent const &) - ??4QMediaResource@@QAEAAV0@ABV0@@Z @ 81 NONAME ; class QMediaResource & QMediaResource::operator=(class QMediaResource const &) - ??4QMediaServiceProviderHint@@QAEAAV0@ABV0@@Z @ 82 NONAME ; class QMediaServiceProviderHint & QMediaServiceProviderHint::operator=(class QMediaServiceProviderHint const &) - ??4QMediaTimeRange@@QAEAAV0@ABV0@@Z @ 83 NONAME ; class QMediaTimeRange & QMediaTimeRange::operator=(class QMediaTimeRange const &) - ??4QMediaTimeRange@@QAEAAV0@ABVQMediaTimeInterval@@@Z @ 84 NONAME ; class QMediaTimeRange & QMediaTimeRange::operator=(class QMediaTimeInterval const &) - ??8@YA_NABVQMediaTimeInterval@@0@Z @ 85 NONAME ; bool operator==(class QMediaTimeInterval const &, class QMediaTimeInterval const &) - ??8@YA_NABVQMediaTimeRange@@0@Z @ 86 NONAME ; bool operator==(class QMediaTimeRange const &, class QMediaTimeRange const &) - ??8QMediaContent@@QBE_NABV0@@Z @ 87 NONAME ; bool QMediaContent::operator==(class QMediaContent const &) const - ??8QMediaResource@@QBE_NABV0@@Z @ 88 NONAME ; bool QMediaResource::operator==(class QMediaResource const &) const - ??8QMediaServiceProviderHint@@QBE_NABV0@@Z @ 89 NONAME ; bool QMediaServiceProviderHint::operator==(class QMediaServiceProviderHint const &) const - ??9@YA_NABVQMediaTimeInterval@@0@Z @ 90 NONAME ; bool operator!=(class QMediaTimeInterval const &, class QMediaTimeInterval const &) - ??9@YA_NABVQMediaTimeRange@@0@Z @ 91 NONAME ; bool operator!=(class QMediaTimeRange const &, class QMediaTimeRange const &) - ??9QMediaContent@@QBE_NABV0@@Z @ 92 NONAME ; bool QMediaContent::operator!=(class QMediaContent const &) const - ??9QMediaResource@@QBE_NABV0@@Z @ 93 NONAME ; bool QMediaResource::operator!=(class QMediaResource const &) const - ??9QMediaServiceProviderHint@@QBE_NABV0@@Z @ 94 NONAME ; bool QMediaServiceProviderHint::operator!=(class QMediaServiceProviderHint const &) const - ??G@YA?AVQMediaTimeRange@@ABV0@0@Z @ 95 NONAME ; class QMediaTimeRange operator-(class QMediaTimeRange const &, class QMediaTimeRange const &) - ??H@YA?AVQMediaTimeRange@@ABV0@0@Z @ 96 NONAME ; class QMediaTimeRange operator+(class QMediaTimeRange const &, class QMediaTimeRange const &) - ??YQMediaTimeRange@@QAEAAV0@ABV0@@Z @ 97 NONAME ; class QMediaTimeRange & QMediaTimeRange::operator+=(class QMediaTimeRange const &) - ??YQMediaTimeRange@@QAEAAV0@ABVQMediaTimeInterval@@@Z @ 98 NONAME ; class QMediaTimeRange & QMediaTimeRange::operator+=(class QMediaTimeInterval const &) - ??ZQMediaTimeRange@@QAEAAV0@ABV0@@Z @ 99 NONAME ; class QMediaTimeRange & QMediaTimeRange::operator-=(class QMediaTimeRange const &) - ??ZQMediaTimeRange@@QAEAAV0@ABVQMediaTimeInterval@@@Z @ 100 NONAME ; class QMediaTimeRange & QMediaTimeRange::operator-=(class QMediaTimeInterval const &) - ??_EQGraphicsVideoItem@@UAE@I@Z @ 101 NONAME ; QGraphicsVideoItem::~QGraphicsVideoItem(unsigned int) - ??_EQLocalMediaPlaylistProvider@@UAE@I@Z @ 102 NONAME ; QLocalMediaPlaylistProvider::~QLocalMediaPlaylistProvider(unsigned int) - ??_EQMediaControl@@UAE@I@Z @ 103 NONAME ; QMediaControl::~QMediaControl(unsigned int) - ??_EQMediaObject@@UAE@I@Z @ 104 NONAME ; QMediaObject::~QMediaObject(unsigned int) - ??_EQMediaPlayer@@UAE@I@Z @ 105 NONAME ; QMediaPlayer::~QMediaPlayer(unsigned int) - ??_EQMediaPlayerControl@@UAE@I@Z @ 106 NONAME ; QMediaPlayerControl::~QMediaPlayerControl(unsigned int) - ??_EQMediaPlaylist@@UAE@I@Z @ 107 NONAME ; QMediaPlaylist::~QMediaPlaylist(unsigned int) - ??_EQMediaPlaylistControl@@UAE@I@Z @ 108 NONAME ; QMediaPlaylistControl::~QMediaPlaylistControl(unsigned int) - ??_EQMediaPlaylistIOInterface@@UAE@I@Z @ 109 NONAME ; QMediaPlaylistIOInterface::~QMediaPlaylistIOInterface(unsigned int) - ??_EQMediaPlaylistIOPlugin@@UAE@I@Z @ 110 NONAME ; QMediaPlaylistIOPlugin::~QMediaPlaylistIOPlugin(unsigned int) - ??_EQMediaPlaylistNavigator@@UAE@I@Z @ 111 NONAME ; QMediaPlaylistNavigator::~QMediaPlaylistNavigator(unsigned int) - ??_EQMediaPlaylistProvider@@UAE@I@Z @ 112 NONAME ; QMediaPlaylistProvider::~QMediaPlaylistProvider(unsigned int) - ??_EQMediaPlaylistReader@@UAE@I@Z @ 113 NONAME ; QMediaPlaylistReader::~QMediaPlaylistReader(unsigned int) - ??_EQMediaPlaylistWriter@@UAE@I@Z @ 114 NONAME ; QMediaPlaylistWriter::~QMediaPlaylistWriter(unsigned int) - ??_EQMediaService@@UAE@I@Z @ 115 NONAME ; QMediaService::~QMediaService(unsigned int) - ??_EQMediaServiceFeaturesInterface@@UAE@I@Z @ 116 NONAME ; QMediaServiceFeaturesInterface::~QMediaServiceFeaturesInterface(unsigned int) - ??_EQMediaServiceProvider@@UAE@I@Z @ 117 NONAME ; QMediaServiceProvider::~QMediaServiceProvider(unsigned int) - ??_EQMediaServiceSupportedDevicesInterface@@UAE@I@Z @ 118 NONAME ; QMediaServiceSupportedDevicesInterface::~QMediaServiceSupportedDevicesInterface(unsigned int) - ??_EQMediaServiceSupportedFormatsInterface@@UAE@I@Z @ 119 NONAME ; QMediaServiceSupportedFormatsInterface::~QMediaServiceSupportedFormatsInterface(unsigned int) - ??_EQMetaDataControl@@UAE@I@Z @ 120 NONAME ; QMetaDataControl::~QMetaDataControl(unsigned int) - ??_EQPainterVideoSurface@@UAE@I@Z @ 121 NONAME ; QPainterVideoSurface::~QPainterVideoSurface(unsigned int) - ??_EQSoundEffect@@UAE@I@Z @ 122 NONAME ; QSoundEffect::~QSoundEffect(unsigned int) - ??_EQVideoDeviceControl@@UAE@I@Z @ 123 NONAME ; QVideoDeviceControl::~QVideoDeviceControl(unsigned int) - ??_EQVideoOutputControl@@UAE@I@Z @ 124 NONAME ; QVideoOutputControl::~QVideoOutputControl(unsigned int) - ??_EQVideoRendererControl@@UAE@I@Z @ 125 NONAME ; QVideoRendererControl::~QVideoRendererControl(unsigned int) - ??_EQVideoWidget@@UAE@I@Z @ 126 NONAME ; QVideoWidget::~QVideoWidget(unsigned int) - ??_EQVideoWidgetControl@@UAE@I@Z @ 127 NONAME ; QVideoWidgetControl::~QVideoWidgetControl(unsigned int) - ??_EQVideoWindowControl@@UAE@I@Z @ 128 NONAME ; QVideoWindowControl::~QVideoWindowControl(unsigned int) - ?activated@QMediaPlaylistNavigator@@IAEXABVQMediaContent@@@Z @ 129 NONAME ; void QMediaPlaylistNavigator::activated(class QMediaContent const &) - ?addInterval@QMediaTimeRange@@QAEXABVQMediaTimeInterval@@@Z @ 130 NONAME ; void QMediaTimeRange::addInterval(class QMediaTimeInterval const &) - ?addInterval@QMediaTimeRange@@QAEX_J0@Z @ 131 NONAME ; void QMediaTimeRange::addInterval(long long, long long) - ?addMedia@QLocalMediaPlaylistProvider@@UAE_NABV?$QList@VQMediaContent@@@@@Z @ 132 NONAME ; bool QLocalMediaPlaylistProvider::addMedia(class QList<class QMediaContent> const &) - ?addMedia@QLocalMediaPlaylistProvider@@UAE_NABVQMediaContent@@@Z @ 133 NONAME ; bool QLocalMediaPlaylistProvider::addMedia(class QMediaContent const &) - ?addMedia@QMediaPlaylist@@QAE_NABV?$QList@VQMediaContent@@@@@Z @ 134 NONAME ; bool QMediaPlaylist::addMedia(class QList<class QMediaContent> const &) - ?addMedia@QMediaPlaylist@@QAE_NABVQMediaContent@@@Z @ 135 NONAME ; bool QMediaPlaylist::addMedia(class QMediaContent const &) - ?addMedia@QMediaPlaylistProvider@@UAE_NABV?$QList@VQMediaContent@@@@@Z @ 136 NONAME ; bool QMediaPlaylistProvider::addMedia(class QList<class QMediaContent> const &) - ?addMedia@QMediaPlaylistProvider@@UAE_NABVQMediaContent@@@Z @ 137 NONAME ; bool QMediaPlaylistProvider::addMedia(class QMediaContent const &) - ?addPropertyWatch@QMediaObject@@IAEXABVQByteArray@@@Z @ 138 NONAME ; void QMediaObject::addPropertyWatch(class QByteArray const &) - ?addTimeRange@QMediaTimeRange@@QAEXABV1@@Z @ 139 NONAME ; void QMediaTimeRange::addTimeRange(class QMediaTimeRange const &) - ?aspectRatioMode@QGraphicsVideoItem@@QBE?AW4AspectRatioMode@Qt@@XZ @ 140 NONAME ; enum Qt::AspectRatioMode QGraphicsVideoItem::aspectRatioMode(void) const - ?aspectRatioMode@QVideoWidget@@QBE?AW4AspectRatioMode@Qt@@XZ @ 141 NONAME ; enum Qt::AspectRatioMode QVideoWidget::aspectRatioMode(void) const - ?audioAvailableChanged@QMediaPlayer@@IAEX_N@Z @ 142 NONAME ; void QMediaPlayer::audioAvailableChanged(bool) - ?audioAvailableChanged@QMediaPlayerControl@@IAEX_N@Z @ 143 NONAME ; void QMediaPlayerControl::audioAvailableChanged(bool) - ?audioBitRate@QMediaResource@@QBEHXZ @ 144 NONAME ; int QMediaResource::audioBitRate(void) const - ?audioCodec@QMediaResource@@QBE?AVQString@@XZ @ 145 NONAME ; class QString QMediaResource::audioCodec(void) const - ?availabilityChanged@QMediaObject@@IAEX_N@Z @ 146 NONAME ; void QMediaObject::availabilityChanged(bool) - ?availabilityError@QMediaObject@@UBE?AW4AvailabilityError@QtMediaServices@@XZ @ 147 NONAME ; enum QtMediaServices::AvailabilityError QMediaObject::availabilityError(void) const - ?availableExtendedMetaData@QMediaObject@@QBE?AVQStringList@@XZ @ 148 NONAME ; class QStringList QMediaObject::availableExtendedMetaData(void) const - ?availableMetaData@QMediaObject@@QBE?AV?$QList@W4MetaData@QtMediaServices@@@@XZ @ 149 NONAME ; class QList<enum QtMediaServices::MetaData> QMediaObject::availableMetaData(void) const - ?availableOutputsChanged@QVideoOutputControl@@IAEXABV?$QList@W4Output@QVideoOutputControl@@@@@Z @ 150 NONAME ; void QVideoOutputControl::availableOutputsChanged(class QList<enum QVideoOutputControl::Output> const &) - ?availablePlaybackRangesChanged@QMediaPlayerControl@@IAEXABVQMediaTimeRange@@@Z @ 151 NONAME ; void QMediaPlayerControl::availablePlaybackRangesChanged(class QMediaTimeRange const &) - ?bind@QMediaObject@@UAEXPAVQObject@@@Z @ 152 NONAME ; void QMediaObject::bind(class QObject *) - ?bind@QMediaPlayer@@UAEXPAVQObject@@@Z @ 153 NONAME ; void QMediaPlayer::bind(class QObject *) - ?boundingRect@QGraphicsVideoItem@@UBE?AVQRectF@@XZ @ 154 NONAME ; class QRectF QGraphicsVideoItem::boundingRect(void) const - ?brightness@QPainterVideoSurface@@QBEHXZ @ 155 NONAME ; int QPainterVideoSurface::brightness(void) const - ?brightness@QVideoWidget@@QBEHXZ @ 156 NONAME ; int QVideoWidget::brightness(void) const - ?brightnessChanged@QVideoWidget@@IAEXH@Z @ 157 NONAME ; void QVideoWidget::brightnessChanged(int) - ?brightnessChanged@QVideoWidgetControl@@IAEXH@Z @ 158 NONAME ; void QVideoWidgetControl::brightnessChanged(int) - ?brightnessChanged@QVideoWindowControl@@IAEXH@Z @ 159 NONAME ; void QVideoWindowControl::brightnessChanged(int) - ?bufferStatus@QMediaPlayer@@QBEHXZ @ 160 NONAME ; int QMediaPlayer::bufferStatus(void) const - ?bufferStatusChanged@QMediaPlayer@@IAEXH@Z @ 161 NONAME ; void QMediaPlayer::bufferStatusChanged(int) - ?bufferStatusChanged@QMediaPlayerControl@@IAEXH@Z @ 162 NONAME ; void QMediaPlayerControl::bufferStatusChanged(int) - ?canonicalRequest@QMediaContent@@QBE?AVQNetworkRequest@@XZ @ 163 NONAME ; class QNetworkRequest QMediaContent::canonicalRequest(void) const - ?canonicalResource@QMediaContent@@QBE?AVQMediaResource@@XZ @ 164 NONAME ; class QMediaResource QMediaContent::canonicalResource(void) const - ?canonicalUrl@QMediaContent@@QBE?AVQUrl@@XZ @ 165 NONAME ; class QUrl QMediaContent::canonicalUrl(void) const - ?channelCount@QMediaResource@@QBEHXZ @ 166 NONAME ; int QMediaResource::channelCount(void) const - ?clear@QLocalMediaPlaylistProvider@@UAE_NXZ @ 167 NONAME ; bool QLocalMediaPlaylistProvider::clear(void) - ?clear@QMediaPlaylist@@QAE_NXZ @ 168 NONAME ; bool QMediaPlaylist::clear(void) - ?clear@QMediaPlaylistProvider@@UAE_NXZ @ 169 NONAME ; bool QMediaPlaylistProvider::clear(void) - ?clear@QMediaTimeRange@@QAEXXZ @ 170 NONAME ; void QMediaTimeRange::clear(void) - ?codecs@QMediaServiceProviderHint@@QBE?AVQStringList@@XZ @ 171 NONAME ; class QStringList QMediaServiceProviderHint::codecs(void) const - ?contains@QMediaTimeInterval@@QBE_N_J@Z @ 172 NONAME ; bool QMediaTimeInterval::contains(long long) const - ?contains@QMediaTimeRange@@QBE_N_J@Z @ 173 NONAME ; bool QMediaTimeRange::contains(long long) const - ?contrast@QPainterVideoSurface@@QBEHXZ @ 174 NONAME ; int QPainterVideoSurface::contrast(void) const - ?contrast@QVideoWidget@@QBEHXZ @ 175 NONAME ; int QVideoWidget::contrast(void) const - ?contrastChanged@QVideoWidget@@IAEXH@Z @ 176 NONAME ; void QVideoWidget::contrastChanged(int) - ?contrastChanged@QVideoWidgetControl@@IAEXH@Z @ 177 NONAME ; void QVideoWidgetControl::contrastChanged(int) - ?contrastChanged@QVideoWindowControl@@IAEXH@Z @ 178 NONAME ; void QVideoWindowControl::contrastChanged(int) - ?createPainter@QPainterVideoSurface@@AAEXXZ @ 179 NONAME ; void QPainterVideoSurface::createPainter(void) - ?currentIndex@QMediaPlaylist@@QBEHXZ @ 180 NONAME ; int QMediaPlaylist::currentIndex(void) const - ?currentIndex@QMediaPlaylistNavigator@@QBEHXZ @ 181 NONAME ; int QMediaPlaylistNavigator::currentIndex(void) const - ?currentIndexChanged@QMediaPlaylist@@IAEXH@Z @ 182 NONAME ; void QMediaPlaylist::currentIndexChanged(int) - ?currentIndexChanged@QMediaPlaylistControl@@IAEXH@Z @ 183 NONAME ; void QMediaPlaylistControl::currentIndexChanged(int) - ?currentIndexChanged@QMediaPlaylistNavigator@@IAEXH@Z @ 184 NONAME ; void QMediaPlaylistNavigator::currentIndexChanged(int) - ?currentItem@QMediaPlaylistNavigator@@QBE?AVQMediaContent@@XZ @ 185 NONAME ; class QMediaContent QMediaPlaylistNavigator::currentItem(void) const - ?currentMedia@QMediaPlaylist@@QBE?AVQMediaContent@@XZ @ 186 NONAME ; class QMediaContent QMediaPlaylist::currentMedia(void) const - ?currentMediaChanged@QMediaPlaylist@@IAEXABVQMediaContent@@@Z @ 187 NONAME ; void QMediaPlaylist::currentMediaChanged(class QMediaContent const &) - ?currentMediaChanged@QMediaPlaylistControl@@IAEXABVQMediaContent@@@Z @ 188 NONAME ; void QMediaPlaylistControl::currentMediaChanged(class QMediaContent const &) - ?d_func@QGraphicsVideoItem@@AAEPAVQGraphicsVideoItemPrivate@@XZ @ 189 NONAME ; class QGraphicsVideoItemPrivate * QGraphicsVideoItem::d_func(void) - ?d_func@QGraphicsVideoItem@@ABEPBVQGraphicsVideoItemPrivate@@XZ @ 190 NONAME ; class QGraphicsVideoItemPrivate const * QGraphicsVideoItem::d_func(void) const - ?d_func@QLocalMediaPlaylistProvider@@AAEPAVQLocalMediaPlaylistProviderPrivate@@XZ @ 191 NONAME ; class QLocalMediaPlaylistProviderPrivate * QLocalMediaPlaylistProvider::d_func(void) - ?d_func@QLocalMediaPlaylistProvider@@ABEPBVQLocalMediaPlaylistProviderPrivate@@XZ @ 192 NONAME ; class QLocalMediaPlaylistProviderPrivate const * QLocalMediaPlaylistProvider::d_func(void) const - ?d_func@QMediaControl@@AAEPAVQMediaControlPrivate@@XZ @ 193 NONAME ; class QMediaControlPrivate * QMediaControl::d_func(void) - ?d_func@QMediaControl@@ABEPBVQMediaControlPrivate@@XZ @ 194 NONAME ; class QMediaControlPrivate const * QMediaControl::d_func(void) const - ?d_func@QMediaObject@@AAEPAVQMediaObjectPrivate@@XZ @ 195 NONAME ; class QMediaObjectPrivate * QMediaObject::d_func(void) - ?d_func@QMediaObject@@ABEPBVQMediaObjectPrivate@@XZ @ 196 NONAME ; class QMediaObjectPrivate const * QMediaObject::d_func(void) const - ?d_func@QMediaPlayer@@AAEPAVQMediaPlayerPrivate@@XZ @ 197 NONAME ; class QMediaPlayerPrivate * QMediaPlayer::d_func(void) - ?d_func@QMediaPlayer@@ABEPBVQMediaPlayerPrivate@@XZ @ 198 NONAME ; class QMediaPlayerPrivate const * QMediaPlayer::d_func(void) const - ?d_func@QMediaPlaylist@@AAEPAVQMediaPlaylistPrivate@@XZ @ 199 NONAME ; class QMediaPlaylistPrivate * QMediaPlaylist::d_func(void) - ?d_func@QMediaPlaylist@@ABEPBVQMediaPlaylistPrivate@@XZ @ 200 NONAME ; class QMediaPlaylistPrivate const * QMediaPlaylist::d_func(void) const - ?d_func@QMediaPlaylistNavigator@@AAEPAVQMediaPlaylistNavigatorPrivate@@XZ @ 201 NONAME ; class QMediaPlaylistNavigatorPrivate * QMediaPlaylistNavigator::d_func(void) - ?d_func@QMediaPlaylistNavigator@@ABEPBVQMediaPlaylistNavigatorPrivate@@XZ @ 202 NONAME ; class QMediaPlaylistNavigatorPrivate const * QMediaPlaylistNavigator::d_func(void) const - ?d_func@QMediaPlaylistProvider@@AAEPAVQMediaPlaylistProviderPrivate@@XZ @ 203 NONAME ; class QMediaPlaylistProviderPrivate * QMediaPlaylistProvider::d_func(void) - ?d_func@QMediaPlaylistProvider@@ABEPBVQMediaPlaylistProviderPrivate@@XZ @ 204 NONAME ; class QMediaPlaylistProviderPrivate const * QMediaPlaylistProvider::d_func(void) const - ?d_func@QMediaService@@AAEPAVQMediaServicePrivate@@XZ @ 205 NONAME ; class QMediaServicePrivate * QMediaService::d_func(void) - ?d_func@QMediaService@@ABEPBVQMediaServicePrivate@@XZ @ 206 NONAME ; class QMediaServicePrivate const * QMediaService::d_func(void) const - ?d_func@QVideoWidget@@AAEPAVQVideoWidgetPrivate@@XZ @ 207 NONAME ; class QVideoWidgetPrivate * QVideoWidget::d_func(void) - ?d_func@QVideoWidget@@ABEPBVQVideoWidgetPrivate@@XZ @ 208 NONAME ; class QVideoWidgetPrivate const * QVideoWidget::d_func(void) const - ?dataSize@QMediaResource@@QBE_JXZ @ 209 NONAME ; long long QMediaResource::dataSize(void) const - ?defaultServiceProvider@QMediaServiceProvider@@SAPAV1@XZ @ 210 NONAME ; class QMediaServiceProvider * QMediaServiceProvider::defaultServiceProvider(void) - ?device@QMediaServiceProviderHint@@QBE?AVQByteArray@@XZ @ 211 NONAME ; class QByteArray QMediaServiceProviderHint::device(void) const - ?deviceDescription@QMediaServiceProvider@@UAE?AVQString@@ABVQByteArray@@0@Z @ 212 NONAME ; class QString QMediaServiceProvider::deviceDescription(class QByteArray const &, class QByteArray const &) - ?devices@QMediaServiceProvider@@UBE?AV?$QList@VQByteArray@@@@ABVQByteArray@@@Z @ 213 NONAME ; class QList<class QByteArray> QMediaServiceProvider::devices(class QByteArray const &) const - ?devicesChanged@QVideoDeviceControl@@IAEXXZ @ 214 NONAME ; void QVideoDeviceControl::devicesChanged(void) - ?duration@QMediaPlayer@@QBE_JXZ @ 215 NONAME ; long long QMediaPlayer::duration(void) const - ?durationChanged@QMediaPlayer@@IAEX_J@Z @ 216 NONAME ; void QMediaPlayer::durationChanged(long long) - ?durationChanged@QMediaPlayerControl@@IAEX_J@Z @ 217 NONAME ; void QMediaPlayerControl::durationChanged(long long) - ?earliestTime@QMediaTimeRange@@QBE_JXZ @ 218 NONAME ; long long QMediaTimeRange::earliestTime(void) const - ?end@QMediaTimeInterval@@QBE_JXZ @ 219 NONAME ; long long QMediaTimeInterval::end(void) const - ?error@QMediaPlayer@@IAEXW4Error@1@@Z @ 220 NONAME ; void QMediaPlayer::error(enum QMediaPlayer::Error) - ?error@QMediaPlayer@@QBE?AW4Error@1@XZ @ 221 NONAME ; enum QMediaPlayer::Error QMediaPlayer::error(void) const - ?error@QMediaPlayerControl@@IAEXHABVQString@@@Z @ 222 NONAME ; void QMediaPlayerControl::error(int, class QString const &) - ?error@QMediaPlaylist@@QBE?AW4Error@1@XZ @ 223 NONAME ; enum QMediaPlaylist::Error QMediaPlaylist::error(void) const - ?errorString@QMediaPlayer@@QBE?AVQString@@XZ @ 224 NONAME ; class QString QMediaPlayer::errorString(void) const - ?errorString@QMediaPlaylist@@QBE?AVQString@@XZ @ 225 NONAME ; class QString QMediaPlaylist::errorString(void) const - ?event@QGraphicsVideoItem@@MAE_NPAVQEvent@@@Z @ 226 NONAME ; bool QGraphicsVideoItem::event(class QEvent *) - ?event@QVideoWidget@@MAE_NPAVQEvent@@@Z @ 227 NONAME ; bool QVideoWidget::event(class QEvent *) - ?extendedMetaData@QMediaObject@@QBE?AVQVariant@@ABVQString@@@Z @ 228 NONAME ; class QVariant QMediaObject::extendedMetaData(class QString const &) const - ?features@QMediaServiceProviderHint@@QBE?AV?$QFlags@W4Feature@QMediaServiceProviderHint@@@@XZ @ 229 NONAME ; class QFlags<enum QMediaServiceProviderHint::Feature> QMediaServiceProviderHint::features(void) const - ?frameChanged@QPainterVideoSurface@@IAEXXZ @ 230 NONAME ; void QPainterVideoSurface::frameChanged(void) - ?fullScreenChanged@QVideoWidget@@IAEX_N@Z @ 231 NONAME ; void QVideoWidget::fullScreenChanged(bool) - ?fullScreenChanged@QVideoWidgetControl@@IAEX_N@Z @ 232 NONAME ; void QVideoWidgetControl::fullScreenChanged(bool) - ?fullScreenChanged@QVideoWindowControl@@IAEX_N@Z @ 233 NONAME ; void QVideoWindowControl::fullScreenChanged(bool) - ?getStaticMetaObject@QGraphicsVideoItem@@SAABUQMetaObject@@XZ @ 234 NONAME ; struct QMetaObject const & QGraphicsVideoItem::getStaticMetaObject(void) - ?getStaticMetaObject@QLocalMediaPlaylistProvider@@SAABUQMetaObject@@XZ @ 235 NONAME ; struct QMetaObject const & QLocalMediaPlaylistProvider::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaControl@@SAABUQMetaObject@@XZ @ 236 NONAME ; struct QMetaObject const & QMediaControl::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaObject@@SAABUQMetaObject@@XZ @ 237 NONAME ; struct QMetaObject const & QMediaObject::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaPlayer@@SAABUQMetaObject@@XZ @ 238 NONAME ; struct QMetaObject const & QMediaPlayer::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaPlayerControl@@SAABUQMetaObject@@XZ @ 239 NONAME ; struct QMetaObject const & QMediaPlayerControl::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaPlaylist@@SAABUQMetaObject@@XZ @ 240 NONAME ; struct QMetaObject const & QMediaPlaylist::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaPlaylistControl@@SAABUQMetaObject@@XZ @ 241 NONAME ; struct QMetaObject const & QMediaPlaylistControl::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaPlaylistIOPlugin@@SAABUQMetaObject@@XZ @ 242 NONAME ; struct QMetaObject const & QMediaPlaylistIOPlugin::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaPlaylistNavigator@@SAABUQMetaObject@@XZ @ 243 NONAME ; struct QMetaObject const & QMediaPlaylistNavigator::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaPlaylistProvider@@SAABUQMetaObject@@XZ @ 244 NONAME ; struct QMetaObject const & QMediaPlaylistProvider::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaService@@SAABUQMetaObject@@XZ @ 245 NONAME ; struct QMetaObject const & QMediaService::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaServiceProvider@@SAABUQMetaObject@@XZ @ 246 NONAME ; struct QMetaObject const & QMediaServiceProvider::getStaticMetaObject(void) - ?getStaticMetaObject@QMediaServiceProviderPlugin@@SAABUQMetaObject@@XZ @ 247 NONAME ; struct QMetaObject const & QMediaServiceProviderPlugin::getStaticMetaObject(void) - ?getStaticMetaObject@QMetaDataControl@@SAABUQMetaObject@@XZ @ 248 NONAME ; struct QMetaObject const & QMetaDataControl::getStaticMetaObject(void) - ?getStaticMetaObject@QPainterVideoSurface@@SAABUQMetaObject@@XZ @ 249 NONAME ; struct QMetaObject const & QPainterVideoSurface::getStaticMetaObject(void) - ?getStaticMetaObject@QSoundEffect@@SAABUQMetaObject@@XZ @ 250 NONAME ; struct QMetaObject const & QSoundEffect::getStaticMetaObject(void) - ?getStaticMetaObject@QVideoDeviceControl@@SAABUQMetaObject@@XZ @ 251 NONAME ; struct QMetaObject const & QVideoDeviceControl::getStaticMetaObject(void) - ?getStaticMetaObject@QVideoOutputControl@@SAABUQMetaObject@@XZ @ 252 NONAME ; struct QMetaObject const & QVideoOutputControl::getStaticMetaObject(void) - ?getStaticMetaObject@QVideoRendererControl@@SAABUQMetaObject@@XZ @ 253 NONAME ; struct QMetaObject const & QVideoRendererControl::getStaticMetaObject(void) - ?getStaticMetaObject@QVideoWidget@@SAABUQMetaObject@@XZ @ 254 NONAME ; struct QMetaObject const & QVideoWidget::getStaticMetaObject(void) - ?getStaticMetaObject@QVideoWidgetControl@@SAABUQMetaObject@@XZ @ 255 NONAME ; struct QMetaObject const & QVideoWidgetControl::getStaticMetaObject(void) - ?getStaticMetaObject@QVideoWindowControl@@SAABUQMetaObject@@XZ @ 256 NONAME ; struct QMetaObject const & QVideoWindowControl::getStaticMetaObject(void) - ?hasSupport@QMediaPlayer@@SA?AW4SupportEstimate@QtMediaServices@@ABVQString@@ABVQStringList@@V?$QFlags@W4Flag@QMediaPlayer@@@@@Z @ 257 NONAME ; enum QtMediaServices::SupportEstimate QMediaPlayer::hasSupport(class QString const &, class QStringList const &, class QFlags<enum QMediaPlayer::Flag>) - ?hasSupport@QMediaServiceProvider@@UBE?AW4SupportEstimate@QtMediaServices@@ABVQByteArray@@ABVQString@@ABVQStringList@@H@Z @ 258 NONAME ; enum QtMediaServices::SupportEstimate QMediaServiceProvider::hasSupport(class QByteArray const &, class QString const &, class QStringList const &, int) const - ?hideEvent@QVideoWidget@@MAEXPAVQHideEvent@@@Z @ 259 NONAME ; void QVideoWidget::hideEvent(class QHideEvent *) - ?hue@QPainterVideoSurface@@QBEHXZ @ 260 NONAME ; int QPainterVideoSurface::hue(void) const - ?hue@QVideoWidget@@QBEHXZ @ 261 NONAME ; int QVideoWidget::hue(void) const - ?hueChanged@QVideoWidget@@IAEXH@Z @ 262 NONAME ; void QVideoWidget::hueChanged(int) - ?hueChanged@QVideoWidgetControl@@IAEXH@Z @ 263 NONAME ; void QVideoWidgetControl::hueChanged(int) - ?hueChanged@QVideoWindowControl@@IAEXH@Z @ 264 NONAME ; void QVideoWindowControl::hueChanged(int) - ?insertMedia@QLocalMediaPlaylistProvider@@UAE_NHABV?$QList@VQMediaContent@@@@@Z @ 265 NONAME ; bool QLocalMediaPlaylistProvider::insertMedia(int, class QList<class QMediaContent> const &) - ?insertMedia@QLocalMediaPlaylistProvider@@UAE_NHABVQMediaContent@@@Z @ 266 NONAME ; bool QLocalMediaPlaylistProvider::insertMedia(int, class QMediaContent const &) - ?insertMedia@QMediaPlaylist@@QAE_NHABV?$QList@VQMediaContent@@@@@Z @ 267 NONAME ; bool QMediaPlaylist::insertMedia(int, class QList<class QMediaContent> const &) - ?insertMedia@QMediaPlaylist@@QAE_NHABVQMediaContent@@@Z @ 268 NONAME ; bool QMediaPlaylist::insertMedia(int, class QMediaContent const &) - ?insertMedia@QMediaPlaylistProvider@@UAE_NHABV?$QList@VQMediaContent@@@@@Z @ 269 NONAME ; bool QMediaPlaylistProvider::insertMedia(int, class QList<class QMediaContent> const &) - ?insertMedia@QMediaPlaylistProvider@@UAE_NHABVQMediaContent@@@Z @ 270 NONAME ; bool QMediaPlaylistProvider::insertMedia(int, class QMediaContent const &) - ?intervals@QMediaTimeRange@@QBE?AV?$QList@VQMediaTimeInterval@@@@XZ @ 271 NONAME ; class QList<class QMediaTimeInterval> QMediaTimeRange::intervals(void) const - ?isAudioAvailable@QMediaPlayer@@QBE_NXZ @ 272 NONAME ; bool QMediaPlayer::isAudioAvailable(void) const - ?isAvailable@QMediaObject@@UBE_NXZ @ 273 NONAME ; bool QMediaObject::isAvailable(void) const - ?isContinuous@QMediaTimeRange@@QBE_NXZ @ 274 NONAME ; bool QMediaTimeRange::isContinuous(void) const - ?isEmpty@QMediaPlaylist@@QBE_NXZ @ 275 NONAME ; bool QMediaPlaylist::isEmpty(void) const - ?isEmpty@QMediaTimeRange@@QBE_NXZ @ 276 NONAME ; bool QMediaTimeRange::isEmpty(void) const - ?isFormatSupported@QPainterVideoSurface@@QBE_NABVQVideoSurfaceFormat@@PAV2@@Z @ 277 NONAME ; bool QPainterVideoSurface::isFormatSupported(class QVideoSurfaceFormat const &, class QVideoSurfaceFormat *) const - ?isMetaDataAvailable@QMediaObject@@QBE_NXZ @ 278 NONAME ; bool QMediaObject::isMetaDataAvailable(void) const - ?isMetaDataWritable@QMediaObject@@QBE_NXZ @ 279 NONAME ; bool QMediaObject::isMetaDataWritable(void) const - ?isMuted@QMediaPlayer@@QBE_NXZ @ 280 NONAME ; bool QMediaPlayer::isMuted(void) const - ?isMuted@QSoundEffect@@QBE_NXZ @ 281 NONAME ; bool QSoundEffect::isMuted(void) const - ?isNormal@QMediaTimeInterval@@QBE_NXZ @ 282 NONAME ; bool QMediaTimeInterval::isNormal(void) const - ?isNull@QMediaContent@@QBE_NXZ @ 283 NONAME ; bool QMediaContent::isNull(void) const - ?isNull@QMediaResource@@QBE_NXZ @ 284 NONAME ; bool QMediaResource::isNull(void) const - ?isNull@QMediaServiceProviderHint@@QBE_NXZ @ 285 NONAME ; bool QMediaServiceProviderHint::isNull(void) const - ?isReadOnly@QLocalMediaPlaylistProvider@@UBE_NXZ @ 286 NONAME ; bool QLocalMediaPlaylistProvider::isReadOnly(void) const - ?isReadOnly@QMediaPlaylist@@QBE_NXZ @ 287 NONAME ; bool QMediaPlaylist::isReadOnly(void) const - ?isReadOnly@QMediaPlaylistProvider@@UBE_NXZ @ 288 NONAME ; bool QMediaPlaylistProvider::isReadOnly(void) const - ?isReady@QPainterVideoSurface@@QBE_NXZ @ 289 NONAME ; bool QPainterVideoSurface::isReady(void) const - ?isSeekable@QMediaPlayer@@QBE_NXZ @ 290 NONAME ; bool QMediaPlayer::isSeekable(void) const - ?isVideoAvailable@QMediaPlayer@@QBE_NXZ @ 291 NONAME ; bool QMediaPlayer::isVideoAvailable(void) const - ?itemAt@QMediaPlaylistNavigator@@QBE?AVQMediaContent@@H@Z @ 292 NONAME ; class QMediaContent QMediaPlaylistNavigator::itemAt(int) const - ?itemChange@QGraphicsVideoItem@@MAE?AVQVariant@@W4GraphicsItemChange@QGraphicsItem@@ABV2@@Z @ 293 NONAME ; class QVariant QGraphicsVideoItem::itemChange(enum QGraphicsItem::GraphicsItemChange, class QVariant const &) - ?jump@QMediaPlaylistNavigator@@QAEXH@Z @ 294 NONAME ; void QMediaPlaylistNavigator::jump(int) - ?language@QMediaResource@@QBE?AVQString@@XZ @ 295 NONAME ; class QString QMediaResource::language(void) const - ?latestTime@QMediaTimeRange@@QBE_JXZ @ 296 NONAME ; long long QMediaTimeRange::latestTime(void) const - ?load@QMediaPlaylist@@QAEXABVQUrl@@PBD@Z @ 297 NONAME ; void QMediaPlaylist::load(class QUrl const &, char const *) - ?load@QMediaPlaylist@@QAEXPAVQIODevice@@PBD@Z @ 298 NONAME ; void QMediaPlaylist::load(class QIODevice *, char const *) - ?load@QMediaPlaylistProvider@@UAE_NABVQUrl@@PBD@Z @ 299 NONAME ; bool QMediaPlaylistProvider::load(class QUrl const &, char const *) - ?load@QMediaPlaylistProvider@@UAE_NPAVQIODevice@@PBD@Z @ 300 NONAME ; bool QMediaPlaylistProvider::load(class QIODevice *, char const *) - ?loadFailed@QMediaPlaylist@@IAEXXZ @ 301 NONAME ; void QMediaPlaylist::loadFailed(void) - ?loadFailed@QMediaPlaylistProvider@@IAEXW4Error@QMediaPlaylist@@ABVQString@@@Z @ 302 NONAME ; void QMediaPlaylistProvider::loadFailed(enum QMediaPlaylist::Error, class QString const &) - ?loaded@QMediaPlaylist@@IAEXXZ @ 303 NONAME ; void QMediaPlaylist::loaded(void) - ?loaded@QMediaPlaylistProvider@@IAEXXZ @ 304 NONAME ; void QMediaPlaylistProvider::loaded(void) - ?loops@QSoundEffect@@QBEHXZ @ 305 NONAME ; int QSoundEffect::loops(void) const - ?loopsChanged@QSoundEffect@@IAEXXZ @ 306 NONAME ; void QSoundEffect::loopsChanged(void) - ?media@QLocalMediaPlaylistProvider@@UBE?AVQMediaContent@@H@Z @ 307 NONAME ; class QMediaContent QLocalMediaPlaylistProvider::media(int) const - ?media@QMediaPlayer@@QBE?AVQMediaContent@@XZ @ 308 NONAME ; class QMediaContent QMediaPlayer::media(void) const - ?media@QMediaPlaylist@@QBE?AVQMediaContent@@H@Z @ 309 NONAME ; class QMediaContent QMediaPlaylist::media(int) const - ?mediaAboutToBeInserted@QMediaPlaylist@@IAEXHH@Z @ 310 NONAME ; void QMediaPlaylist::mediaAboutToBeInserted(int, int) - ?mediaAboutToBeInserted@QMediaPlaylistProvider@@IAEXHH@Z @ 311 NONAME ; void QMediaPlaylistProvider::mediaAboutToBeInserted(int, int) - ?mediaAboutToBeRemoved@QMediaPlaylist@@IAEXHH@Z @ 312 NONAME ; void QMediaPlaylist::mediaAboutToBeRemoved(int, int) - ?mediaAboutToBeRemoved@QMediaPlaylistProvider@@IAEXHH@Z @ 313 NONAME ; void QMediaPlaylistProvider::mediaAboutToBeRemoved(int, int) - ?mediaChanged@QMediaPlayer@@IAEXABVQMediaContent@@@Z @ 314 NONAME ; void QMediaPlayer::mediaChanged(class QMediaContent const &) - ?mediaChanged@QMediaPlayerControl@@IAEXABVQMediaContent@@@Z @ 315 NONAME ; void QMediaPlayerControl::mediaChanged(class QMediaContent const &) - ?mediaChanged@QMediaPlaylist@@IAEXHH@Z @ 316 NONAME ; void QMediaPlaylist::mediaChanged(int, int) - ?mediaChanged@QMediaPlaylistProvider@@IAEXHH@Z @ 317 NONAME ; void QMediaPlaylistProvider::mediaChanged(int, int) - ?mediaCount@QLocalMediaPlaylistProvider@@UBEHXZ @ 318 NONAME ; int QLocalMediaPlaylistProvider::mediaCount(void) const - ?mediaCount@QMediaPlaylist@@QBEHXZ @ 319 NONAME ; int QMediaPlaylist::mediaCount(void) const - ?mediaInserted@QMediaPlaylist@@IAEXHH@Z @ 320 NONAME ; void QMediaPlaylist::mediaInserted(int, int) - ?mediaInserted@QMediaPlaylistProvider@@IAEXHH@Z @ 321 NONAME ; void QMediaPlaylistProvider::mediaInserted(int, int) - ?mediaObject@QGraphicsVideoItem@@QBEPAVQMediaObject@@XZ @ 322 NONAME ; class QMediaObject * QGraphicsVideoItem::mediaObject(void) const - ?mediaObject@QMediaPlaylist@@QBEPAVQMediaObject@@XZ @ 323 NONAME ; class QMediaObject * QMediaPlaylist::mediaObject(void) const - ?mediaObject@QVideoWidget@@QBEPAVQMediaObject@@XZ @ 324 NONAME ; class QMediaObject * QVideoWidget::mediaObject(void) const - ?mediaRemoved@QMediaPlaylist@@IAEXHH@Z @ 325 NONAME ; void QMediaPlaylist::mediaRemoved(int, int) - ?mediaRemoved@QMediaPlaylistProvider@@IAEXHH@Z @ 326 NONAME ; void QMediaPlaylistProvider::mediaRemoved(int, int) - ?mediaStatus@QMediaPlayer@@QBE?AW4MediaStatus@1@XZ @ 327 NONAME ; enum QMediaPlayer::MediaStatus QMediaPlayer::mediaStatus(void) const - ?mediaStatusChanged@QMediaPlayer@@IAEXW4MediaStatus@1@@Z @ 328 NONAME ; void QMediaPlayer::mediaStatusChanged(enum QMediaPlayer::MediaStatus) - ?mediaStatusChanged@QMediaPlayerControl@@IAEXW4MediaStatus@QMediaPlayer@@@Z @ 329 NONAME ; void QMediaPlayerControl::mediaStatusChanged(enum QMediaPlayer::MediaStatus) - ?mediaStream@QMediaPlayer@@QBEPBVQIODevice@@XZ @ 330 NONAME ; class QIODevice const * QMediaPlayer::mediaStream(void) const - ?metaData@QMediaObject@@QBE?AVQVariant@@W4MetaData@QtMediaServices@@@Z @ 331 NONAME ; class QVariant QMediaObject::metaData(enum QtMediaServices::MetaData) const - ?metaDataAvailableChanged@QMediaObject@@IAEX_N@Z @ 332 NONAME ; void QMediaObject::metaDataAvailableChanged(bool) - ?metaDataAvailableChanged@QMetaDataControl@@IAEX_N@Z @ 333 NONAME ; void QMetaDataControl::metaDataAvailableChanged(bool) - ?metaDataChanged@QMediaObject@@IAEXXZ @ 334 NONAME ; void QMediaObject::metaDataChanged(void) - ?metaDataChanged@QMetaDataControl@@IAEXXZ @ 335 NONAME ; void QMetaDataControl::metaDataChanged(void) - ?metaDataWritableChanged@QMediaObject@@IAEX_N@Z @ 336 NONAME ; void QMediaObject::metaDataWritableChanged(bool) - ?metaObject@QGraphicsVideoItem@@UBEPBUQMetaObject@@XZ @ 337 NONAME ; struct QMetaObject const * QGraphicsVideoItem::metaObject(void) const - ?metaObject@QLocalMediaPlaylistProvider@@UBEPBUQMetaObject@@XZ @ 338 NONAME ; struct QMetaObject const * QLocalMediaPlaylistProvider::metaObject(void) const - ?metaObject@QMediaControl@@UBEPBUQMetaObject@@XZ @ 339 NONAME ; struct QMetaObject const * QMediaControl::metaObject(void) const - ?metaObject@QMediaObject@@UBEPBUQMetaObject@@XZ @ 340 NONAME ; struct QMetaObject const * QMediaObject::metaObject(void) const - ?metaObject@QMediaPlayer@@UBEPBUQMetaObject@@XZ @ 341 NONAME ; struct QMetaObject const * QMediaPlayer::metaObject(void) const - ?metaObject@QMediaPlayerControl@@UBEPBUQMetaObject@@XZ @ 342 NONAME ; struct QMetaObject const * QMediaPlayerControl::metaObject(void) const - ?metaObject@QMediaPlaylist@@UBEPBUQMetaObject@@XZ @ 343 NONAME ; struct QMetaObject const * QMediaPlaylist::metaObject(void) const - ?metaObject@QMediaPlaylistControl@@UBEPBUQMetaObject@@XZ @ 344 NONAME ; struct QMetaObject const * QMediaPlaylistControl::metaObject(void) const - ?metaObject@QMediaPlaylistIOPlugin@@UBEPBUQMetaObject@@XZ @ 345 NONAME ; struct QMetaObject const * QMediaPlaylistIOPlugin::metaObject(void) const - ?metaObject@QMediaPlaylistNavigator@@UBEPBUQMetaObject@@XZ @ 346 NONAME ; struct QMetaObject const * QMediaPlaylistNavigator::metaObject(void) const - ?metaObject@QMediaPlaylistProvider@@UBEPBUQMetaObject@@XZ @ 347 NONAME ; struct QMetaObject const * QMediaPlaylistProvider::metaObject(void) const - ?metaObject@QMediaService@@UBEPBUQMetaObject@@XZ @ 348 NONAME ; struct QMetaObject const * QMediaService::metaObject(void) const - ?metaObject@QMediaServiceProvider@@UBEPBUQMetaObject@@XZ @ 349 NONAME ; struct QMetaObject const * QMediaServiceProvider::metaObject(void) const - ?metaObject@QMediaServiceProviderPlugin@@UBEPBUQMetaObject@@XZ @ 350 NONAME ; struct QMetaObject const * QMediaServiceProviderPlugin::metaObject(void) const - ?metaObject@QMetaDataControl@@UBEPBUQMetaObject@@XZ @ 351 NONAME ; struct QMetaObject const * QMetaDataControl::metaObject(void) const - ?metaObject@QPainterVideoSurface@@UBEPBUQMetaObject@@XZ @ 352 NONAME ; struct QMetaObject const * QPainterVideoSurface::metaObject(void) const - ?metaObject@QSoundEffect@@UBEPBUQMetaObject@@XZ @ 353 NONAME ; struct QMetaObject const * QSoundEffect::metaObject(void) const - ?metaObject@QVideoDeviceControl@@UBEPBUQMetaObject@@XZ @ 354 NONAME ; struct QMetaObject const * QVideoDeviceControl::metaObject(void) const - ?metaObject@QVideoOutputControl@@UBEPBUQMetaObject@@XZ @ 355 NONAME ; struct QMetaObject const * QVideoOutputControl::metaObject(void) const - ?metaObject@QVideoRendererControl@@UBEPBUQMetaObject@@XZ @ 356 NONAME ; struct QMetaObject const * QVideoRendererControl::metaObject(void) const - ?metaObject@QVideoWidget@@UBEPBUQMetaObject@@XZ @ 357 NONAME ; struct QMetaObject const * QVideoWidget::metaObject(void) const - ?metaObject@QVideoWidgetControl@@UBEPBUQMetaObject@@XZ @ 358 NONAME ; struct QMetaObject const * QVideoWidgetControl::metaObject(void) const - ?metaObject@QVideoWindowControl@@UBEPBUQMetaObject@@XZ @ 359 NONAME ; struct QMetaObject const * QVideoWindowControl::metaObject(void) const - ?mimeType@QMediaResource@@QBE?AVQString@@XZ @ 360 NONAME ; class QString QMediaResource::mimeType(void) const - ?mimeType@QMediaServiceProviderHint@@QBE?AVQString@@XZ @ 361 NONAME ; class QString QMediaServiceProviderHint::mimeType(void) const - ?moveEvent@QVideoWidget@@MAEXPAVQMoveEvent@@@Z @ 362 NONAME ; void QVideoWidget::moveEvent(class QMoveEvent *) - ?mutedChanged@QMediaPlayer@@IAEX_N@Z @ 363 NONAME ; void QMediaPlayer::mutedChanged(bool) - ?mutedChanged@QMediaPlayerControl@@IAEX_N@Z @ 364 NONAME ; void QMediaPlayerControl::mutedChanged(bool) - ?mutedChanged@QSoundEffect@@IAEXXZ @ 365 NONAME ; void QSoundEffect::mutedChanged(void) - ?nativeSize@QGraphicsVideoItem@@QBE?AVQSizeF@@XZ @ 366 NONAME ; class QSizeF QGraphicsVideoItem::nativeSize(void) const - ?nativeSizeChanged@QGraphicsVideoItem@@IAEXABVQSizeF@@@Z @ 367 NONAME ; void QGraphicsVideoItem::nativeSizeChanged(class QSizeF const &) - ?nativeSizeChanged@QVideoWindowControl@@IAEXXZ @ 368 NONAME ; void QVideoWindowControl::nativeSizeChanged(void) - ?next@QMediaPlaylist@@QAEXXZ @ 369 NONAME ; void QMediaPlaylist::next(void) - ?next@QMediaPlaylistNavigator@@QAEXXZ @ 370 NONAME ; void QMediaPlaylistNavigator::next(void) - ?nextIndex@QMediaPlaylist@@QBEHH@Z @ 371 NONAME ; int QMediaPlaylist::nextIndex(int) const - ?nextIndex@QMediaPlaylistNavigator@@QBEHH@Z @ 372 NONAME ; int QMediaPlaylistNavigator::nextIndex(int) const - ?nextItem@QMediaPlaylistNavigator@@QBE?AVQMediaContent@@H@Z @ 373 NONAME ; class QMediaContent QMediaPlaylistNavigator::nextItem(int) const - ?normalized@QMediaTimeInterval@@QBE?AV1@XZ @ 374 NONAME ; class QMediaTimeInterval QMediaTimeInterval::normalized(void) const - ?notifyInterval@QMediaObject@@QBEHXZ @ 375 NONAME ; int QMediaObject::notifyInterval(void) const - ?notifyIntervalChanged@QMediaObject@@IAEXH@Z @ 376 NONAME ; void QMediaObject::notifyIntervalChanged(int) - ?offset@QGraphicsVideoItem@@QBE?AVQPointF@@XZ @ 377 NONAME ; class QPointF QGraphicsVideoItem::offset(void) const - ?paint@QGraphicsVideoItem@@UAEXPAVQPainter@@PBVQStyleOptionGraphicsItem@@PAVQWidget@@@Z @ 378 NONAME ; void QGraphicsVideoItem::paint(class QPainter *, class QStyleOptionGraphicsItem const *, class QWidget *) - ?paint@QPainterVideoSurface@@QAEXPAVQPainter@@ABVQRectF@@1@Z @ 379 NONAME ; void QPainterVideoSurface::paint(class QPainter *, class QRectF const &, class QRectF const &) - ?paintEvent@QVideoWidget@@MAEXPAVQPaintEvent@@@Z @ 380 NONAME ; void QVideoWidget::paintEvent(class QPaintEvent *) - ?pause@QMediaPlayer@@QAEXXZ @ 381 NONAME ; void QMediaPlayer::pause(void) - ?play@QMediaPlayer@@QAEXXZ @ 382 NONAME ; void QMediaPlayer::play(void) - ?play@QSoundEffect@@QAEXXZ @ 383 NONAME ; void QSoundEffect::play(void) - ?playbackMode@QMediaPlaylist@@QBE?AW4PlaybackMode@1@XZ @ 384 NONAME ; enum QMediaPlaylist::PlaybackMode QMediaPlaylist::playbackMode(void) const - ?playbackMode@QMediaPlaylistNavigator@@QBE?AW4PlaybackMode@QMediaPlaylist@@XZ @ 385 NONAME ; enum QMediaPlaylist::PlaybackMode QMediaPlaylistNavigator::playbackMode(void) const - ?playbackModeChanged@QMediaPlaylist@@IAEXW4PlaybackMode@1@@Z @ 386 NONAME ; void QMediaPlaylist::playbackModeChanged(enum QMediaPlaylist::PlaybackMode) - ?playbackModeChanged@QMediaPlaylistControl@@IAEXW4PlaybackMode@QMediaPlaylist@@@Z @ 387 NONAME ; void QMediaPlaylistControl::playbackModeChanged(enum QMediaPlaylist::PlaybackMode) - ?playbackModeChanged@QMediaPlaylistNavigator@@IAEXW4PlaybackMode@QMediaPlaylist@@@Z @ 388 NONAME ; void QMediaPlaylistNavigator::playbackModeChanged(enum QMediaPlaylist::PlaybackMode) - ?playbackRate@QMediaPlayer@@QBEMXZ @ 389 NONAME ; float QMediaPlayer::playbackRate(void) const - ?playbackRateChanged@QMediaPlayer@@IAEXM@Z @ 390 NONAME ; void QMediaPlayer::playbackRateChanged(float) - ?playbackRateChanged@QMediaPlayerControl@@IAEXM@Z @ 391 NONAME ; void QMediaPlayerControl::playbackRateChanged(float) - ?playlist@QMediaPlaylistNavigator@@QBEPAVQMediaPlaylistProvider@@XZ @ 392 NONAME ; class QMediaPlaylistProvider * QMediaPlaylistNavigator::playlist(void) const - ?playlistProviderChanged@QMediaPlaylistControl@@IAEXXZ @ 393 NONAME ; void QMediaPlaylistControl::playlistProviderChanged(void) - ?position@QMediaPlayer@@QBE_JXZ @ 394 NONAME ; long long QMediaPlayer::position(void) const - ?positionChanged@QMediaPlayer@@IAEX_J@Z @ 395 NONAME ; void QMediaPlayer::positionChanged(long long) - ?positionChanged@QMediaPlayerControl@@IAEX_J@Z @ 396 NONAME ; void QMediaPlayerControl::positionChanged(long long) - ?present@QPainterVideoSurface@@UAE_NABVQVideoFrame@@@Z @ 397 NONAME ; bool QPainterVideoSurface::present(class QVideoFrame const &) - ?previous@QMediaPlaylist@@QAEXXZ @ 398 NONAME ; void QMediaPlaylist::previous(void) - ?previous@QMediaPlaylistNavigator@@QAEXXZ @ 399 NONAME ; void QMediaPlaylistNavigator::previous(void) - ?previousIndex@QMediaPlaylist@@QBEHH@Z @ 400 NONAME ; int QMediaPlaylist::previousIndex(int) const - ?previousIndex@QMediaPlaylistNavigator@@QBEHH@Z @ 401 NONAME ; int QMediaPlaylistNavigator::previousIndex(int) const - ?previousItem@QMediaPlaylistNavigator@@QBE?AVQMediaContent@@H@Z @ 402 NONAME ; class QMediaContent QMediaPlaylistNavigator::previousItem(int) const - ?qt_metacall@QGraphicsVideoItem@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 403 NONAME ; int QGraphicsVideoItem::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QLocalMediaPlaylistProvider@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 404 NONAME ; int QLocalMediaPlaylistProvider::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 405 NONAME ; int QMediaControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaObject@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 406 NONAME ; int QMediaObject::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaPlayer@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 407 NONAME ; int QMediaPlayer::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaPlayerControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 408 NONAME ; int QMediaPlayerControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaPlaylist@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 409 NONAME ; int QMediaPlaylist::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaPlaylistControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 410 NONAME ; int QMediaPlaylistControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaPlaylistIOPlugin@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 411 NONAME ; int QMediaPlaylistIOPlugin::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaPlaylistNavigator@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 412 NONAME ; int QMediaPlaylistNavigator::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaPlaylistProvider@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 413 NONAME ; int QMediaPlaylistProvider::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaService@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 414 NONAME ; int QMediaService::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaServiceProvider@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 415 NONAME ; int QMediaServiceProvider::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMediaServiceProviderPlugin@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 416 NONAME ; int QMediaServiceProviderPlugin::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QMetaDataControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 417 NONAME ; int QMetaDataControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QPainterVideoSurface@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 418 NONAME ; int QPainterVideoSurface::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QSoundEffect@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 419 NONAME ; int QSoundEffect::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QVideoDeviceControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 420 NONAME ; int QVideoDeviceControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QVideoOutputControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 421 NONAME ; int QVideoOutputControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QVideoRendererControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 422 NONAME ; int QVideoRendererControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QVideoWidget@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 423 NONAME ; int QVideoWidget::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QVideoWidgetControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 424 NONAME ; int QVideoWidgetControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@QVideoWindowControl@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 425 NONAME ; int QVideoWindowControl::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacast@QGraphicsVideoItem@@UAEPAXPBD@Z @ 426 NONAME ; void * QGraphicsVideoItem::qt_metacast(char const *) - ?qt_metacast@QLocalMediaPlaylistProvider@@UAEPAXPBD@Z @ 427 NONAME ; void * QLocalMediaPlaylistProvider::qt_metacast(char const *) - ?qt_metacast@QMediaControl@@UAEPAXPBD@Z @ 428 NONAME ; void * QMediaControl::qt_metacast(char const *) - ?qt_metacast@QMediaObject@@UAEPAXPBD@Z @ 429 NONAME ; void * QMediaObject::qt_metacast(char const *) - ?qt_metacast@QMediaPlayer@@UAEPAXPBD@Z @ 430 NONAME ; void * QMediaPlayer::qt_metacast(char const *) - ?qt_metacast@QMediaPlayerControl@@UAEPAXPBD@Z @ 431 NONAME ; void * QMediaPlayerControl::qt_metacast(char const *) - ?qt_metacast@QMediaPlaylist@@UAEPAXPBD@Z @ 432 NONAME ; void * QMediaPlaylist::qt_metacast(char const *) - ?qt_metacast@QMediaPlaylistControl@@UAEPAXPBD@Z @ 433 NONAME ; void * QMediaPlaylistControl::qt_metacast(char const *) - ?qt_metacast@QMediaPlaylistIOPlugin@@UAEPAXPBD@Z @ 434 NONAME ; void * QMediaPlaylistIOPlugin::qt_metacast(char const *) - ?qt_metacast@QMediaPlaylistNavigator@@UAEPAXPBD@Z @ 435 NONAME ; void * QMediaPlaylistNavigator::qt_metacast(char const *) - ?qt_metacast@QMediaPlaylistProvider@@UAEPAXPBD@Z @ 436 NONAME ; void * QMediaPlaylistProvider::qt_metacast(char const *) - ?qt_metacast@QMediaService@@UAEPAXPBD@Z @ 437 NONAME ; void * QMediaService::qt_metacast(char const *) - ?qt_metacast@QMediaServiceProvider@@UAEPAXPBD@Z @ 438 NONAME ; void * QMediaServiceProvider::qt_metacast(char const *) - ?qt_metacast@QMediaServiceProviderPlugin@@UAEPAXPBD@Z @ 439 NONAME ; void * QMediaServiceProviderPlugin::qt_metacast(char const *) - ?qt_metacast@QMetaDataControl@@UAEPAXPBD@Z @ 440 NONAME ; void * QMetaDataControl::qt_metacast(char const *) - ?qt_metacast@QPainterVideoSurface@@UAEPAXPBD@Z @ 441 NONAME ; void * QPainterVideoSurface::qt_metacast(char const *) - ?qt_metacast@QSoundEffect@@UAEPAXPBD@Z @ 442 NONAME ; void * QSoundEffect::qt_metacast(char const *) - ?qt_metacast@QVideoDeviceControl@@UAEPAXPBD@Z @ 443 NONAME ; void * QVideoDeviceControl::qt_metacast(char const *) - ?qt_metacast@QVideoOutputControl@@UAEPAXPBD@Z @ 444 NONAME ; void * QVideoOutputControl::qt_metacast(char const *) - ?qt_metacast@QVideoRendererControl@@UAEPAXPBD@Z @ 445 NONAME ; void * QVideoRendererControl::qt_metacast(char const *) - ?qt_metacast@QVideoWidget@@UAEPAXPBD@Z @ 446 NONAME ; void * QVideoWidget::qt_metacast(char const *) - ?qt_metacast@QVideoWidgetControl@@UAEPAXPBD@Z @ 447 NONAME ; void * QVideoWidgetControl::qt_metacast(char const *) - ?qt_metacast@QVideoWindowControl@@UAEPAXPBD@Z @ 448 NONAME ; void * QVideoWindowControl::qt_metacast(char const *) - ?removeInterval@QMediaTimeRange@@QAEXABVQMediaTimeInterval@@@Z @ 449 NONAME ; void QMediaTimeRange::removeInterval(class QMediaTimeInterval const &) - ?removeInterval@QMediaTimeRange@@QAEX_J0@Z @ 450 NONAME ; void QMediaTimeRange::removeInterval(long long, long long) - ?removeMedia@QLocalMediaPlaylistProvider@@UAE_NH@Z @ 451 NONAME ; bool QLocalMediaPlaylistProvider::removeMedia(int) - ?removeMedia@QLocalMediaPlaylistProvider@@UAE_NHH@Z @ 452 NONAME ; bool QLocalMediaPlaylistProvider::removeMedia(int, int) - ?removeMedia@QMediaPlaylist@@QAE_NH@Z @ 453 NONAME ; bool QMediaPlaylist::removeMedia(int) - ?removeMedia@QMediaPlaylist@@QAE_NHH@Z @ 454 NONAME ; bool QMediaPlaylist::removeMedia(int, int) - ?removeMedia@QMediaPlaylistProvider@@UAE_NH@Z @ 455 NONAME ; bool QMediaPlaylistProvider::removeMedia(int) - ?removeMedia@QMediaPlaylistProvider@@UAE_NHH@Z @ 456 NONAME ; bool QMediaPlaylistProvider::removeMedia(int, int) - ?removePropertyWatch@QMediaObject@@IAEXABVQByteArray@@@Z @ 457 NONAME ; void QMediaObject::removePropertyWatch(class QByteArray const &) - ?removeTimeRange@QMediaTimeRange@@QAEXABV1@@Z @ 458 NONAME ; void QMediaTimeRange::removeTimeRange(class QMediaTimeRange const &) - ?request@QMediaResource@@QBE?AVQNetworkRequest@@XZ @ 459 NONAME ; class QNetworkRequest QMediaResource::request(void) const - ?resizeEvent@QVideoWidget@@MAEXPAVQResizeEvent@@@Z @ 460 NONAME ; void QVideoWidget::resizeEvent(class QResizeEvent *) - ?resolution@QMediaResource@@QBE?AVQSize@@XZ @ 461 NONAME ; class QSize QMediaResource::resolution(void) const - ?resources@QMediaContent@@QBE?AV?$QList@VQMediaResource@@@@XZ @ 462 NONAME ; class QList<class QMediaResource> QMediaContent::resources(void) const - ?sampleRate@QMediaResource@@QBEHXZ @ 463 NONAME ; int QMediaResource::sampleRate(void) const - ?saturation@QPainterVideoSurface@@QBEHXZ @ 464 NONAME ; int QPainterVideoSurface::saturation(void) const - ?saturation@QVideoWidget@@QBEHXZ @ 465 NONAME ; int QVideoWidget::saturation(void) const - ?saturationChanged@QVideoWidget@@IAEXH@Z @ 466 NONAME ; void QVideoWidget::saturationChanged(int) - ?saturationChanged@QVideoWidgetControl@@IAEXH@Z @ 467 NONAME ; void QVideoWidgetControl::saturationChanged(int) - ?saturationChanged@QVideoWindowControl@@IAEXH@Z @ 468 NONAME ; void QVideoWindowControl::saturationChanged(int) - ?save@QMediaPlaylist@@QAE_NABVQUrl@@PBD@Z @ 469 NONAME ; bool QMediaPlaylist::save(class QUrl const &, char const *) - ?save@QMediaPlaylist@@QAE_NPAVQIODevice@@PBD@Z @ 470 NONAME ; bool QMediaPlaylist::save(class QIODevice *, char const *) - ?save@QMediaPlaylistProvider@@UAE_NABVQUrl@@PBD@Z @ 471 NONAME ; bool QMediaPlaylistProvider::save(class QUrl const &, char const *) - ?save@QMediaPlaylistProvider@@UAE_NPAVQIODevice@@PBD@Z @ 472 NONAME ; bool QMediaPlaylistProvider::save(class QIODevice *, char const *) - ?sceneEvent@QGraphicsVideoItem@@MAE_NPAVQEvent@@@Z @ 473 NONAME ; bool QGraphicsVideoItem::sceneEvent(class QEvent *) - ?seekableChanged@QMediaPlayer@@IAEX_N@Z @ 474 NONAME ; void QMediaPlayer::seekableChanged(bool) - ?seekableChanged@QMediaPlayerControl@@IAEX_N@Z @ 475 NONAME ; void QMediaPlayerControl::seekableChanged(bool) - ?selectedDeviceChanged@QVideoDeviceControl@@IAEXABVQString@@@Z @ 476 NONAME ; void QVideoDeviceControl::selectedDeviceChanged(class QString const &) - ?selectedDeviceChanged@QVideoDeviceControl@@IAEXH@Z @ 477 NONAME ; void QVideoDeviceControl::selectedDeviceChanged(int) - ?service@QMediaObject@@UBEPAVQMediaService@@XZ @ 478 NONAME ; class QMediaService * QMediaObject::service(void) const - ?setAspectRatioMode@QGraphicsVideoItem@@QAEXW4AspectRatioMode@Qt@@@Z @ 479 NONAME ; void QGraphicsVideoItem::setAspectRatioMode(enum Qt::AspectRatioMode) - ?setAspectRatioMode@QVideoWidget@@QAEXW4AspectRatioMode@Qt@@@Z @ 480 NONAME ; void QVideoWidget::setAspectRatioMode(enum Qt::AspectRatioMode) - ?setAudioBitRate@QMediaResource@@QAEXH@Z @ 481 NONAME ; void QMediaResource::setAudioBitRate(int) - ?setAudioCodec@QMediaResource@@QAEXABVQString@@@Z @ 482 NONAME ; void QMediaResource::setAudioCodec(class QString const &) - ?setBrightness@QPainterVideoSurface@@QAEXH@Z @ 483 NONAME ; void QPainterVideoSurface::setBrightness(int) - ?setBrightness@QVideoWidget@@QAEXH@Z @ 484 NONAME ; void QVideoWidget::setBrightness(int) - ?setChannelCount@QMediaResource@@QAEXH@Z @ 485 NONAME ; void QMediaResource::setChannelCount(int) - ?setContrast@QPainterVideoSurface@@QAEXH@Z @ 486 NONAME ; void QPainterVideoSurface::setContrast(int) - ?setContrast@QVideoWidget@@QAEXH@Z @ 487 NONAME ; void QVideoWidget::setContrast(int) - ?setCurrentIndex@QMediaPlaylist@@QAEXH@Z @ 488 NONAME ; void QMediaPlaylist::setCurrentIndex(int) - ?setDataSize@QMediaResource@@QAEX_J@Z @ 489 NONAME ; void QMediaResource::setDataSize(long long) - ?setExtendedMetaData@QMediaObject@@QAEXABVQString@@ABVQVariant@@@Z @ 490 NONAME ; void QMediaObject::setExtendedMetaData(class QString const &, class QVariant const &) - ?setFullScreen@QVideoWidget@@QAEX_N@Z @ 491 NONAME ; void QVideoWidget::setFullScreen(bool) - ?setHue@QPainterVideoSurface@@QAEXH@Z @ 492 NONAME ; void QPainterVideoSurface::setHue(int) - ?setHue@QVideoWidget@@QAEXH@Z @ 493 NONAME ; void QVideoWidget::setHue(int) - ?setLanguage@QMediaResource@@QAEXABVQString@@@Z @ 494 NONAME ; void QMediaResource::setLanguage(class QString const &) - ?setLoops@QSoundEffect@@QAEXH@Z @ 495 NONAME ; void QSoundEffect::setLoops(int) - ?setMedia@QMediaPlayer@@QAEXABVQMediaContent@@PAVQIODevice@@@Z @ 496 NONAME ; void QMediaPlayer::setMedia(class QMediaContent const &, class QIODevice *) - ?setMediaObject@QGraphicsVideoItem@@QAEXPAVQMediaObject@@@Z @ 497 NONAME ; void QGraphicsVideoItem::setMediaObject(class QMediaObject *) - ?setMediaObject@QMediaPlaylist@@QAEXPAVQMediaObject@@@Z @ 498 NONAME ; void QMediaPlaylist::setMediaObject(class QMediaObject *) - ?setMediaObject@QVideoWidget@@QAEXPAVQMediaObject@@@Z @ 499 NONAME ; void QVideoWidget::setMediaObject(class QMediaObject *) - ?setMetaData@QMediaObject@@QAEXW4MetaData@QtMediaServices@@ABVQVariant@@@Z @ 500 NONAME ; void QMediaObject::setMetaData(enum QtMediaServices::MetaData, class QVariant const &) - ?setMuted@QMediaPlayer@@QAEX_N@Z @ 501 NONAME ; void QMediaPlayer::setMuted(bool) - ?setMuted@QSoundEffect@@QAEX_N@Z @ 502 NONAME ; void QSoundEffect::setMuted(bool) - ?setNotifyInterval@QMediaObject@@QAEXH@Z @ 503 NONAME ; void QMediaObject::setNotifyInterval(int) - ?setOffset@QGraphicsVideoItem@@QAEXABVQPointF@@@Z @ 504 NONAME ; void QGraphicsVideoItem::setOffset(class QPointF const &) - ?setPlaybackMode@QMediaPlaylist@@QAEXW4PlaybackMode@1@@Z @ 505 NONAME ; void QMediaPlaylist::setPlaybackMode(enum QMediaPlaylist::PlaybackMode) - ?setPlaybackMode@QMediaPlaylistNavigator@@QAEXW4PlaybackMode@QMediaPlaylist@@@Z @ 506 NONAME ; void QMediaPlaylistNavigator::setPlaybackMode(enum QMediaPlaylist::PlaybackMode) - ?setPlaybackRate@QMediaPlayer@@QAEXM@Z @ 507 NONAME ; void QMediaPlayer::setPlaybackRate(float) - ?setPlaylist@QMediaPlaylistNavigator@@QAEXPAVQMediaPlaylistProvider@@@Z @ 508 NONAME ; void QMediaPlaylistNavigator::setPlaylist(class QMediaPlaylistProvider *) - ?setPosition@QMediaPlayer@@QAEX_J@Z @ 509 NONAME ; void QMediaPlayer::setPosition(long long) - ?setReady@QPainterVideoSurface@@QAEX_N@Z @ 510 NONAME ; void QPainterVideoSurface::setReady(bool) - ?setResolution@QMediaResource@@QAEXABVQSize@@@Z @ 511 NONAME ; void QMediaResource::setResolution(class QSize const &) - ?setResolution@QMediaResource@@QAEXHH@Z @ 512 NONAME ; void QMediaResource::setResolution(int, int) - ?setSampleRate@QMediaResource@@QAEXH@Z @ 513 NONAME ; void QMediaResource::setSampleRate(int) - ?setSaturation@QPainterVideoSurface@@QAEXH@Z @ 514 NONAME ; void QPainterVideoSurface::setSaturation(int) - ?setSaturation@QVideoWidget@@QAEXH@Z @ 515 NONAME ; void QVideoWidget::setSaturation(int) - ?setSize@QGraphicsVideoItem@@QAEXABVQSizeF@@@Z @ 516 NONAME ; void QGraphicsVideoItem::setSize(class QSizeF const &) - ?setSource@QSoundEffect@@QAEXABVQUrl@@@Z @ 517 NONAME ; void QSoundEffect::setSource(class QUrl const &) - ?setVideoBitRate@QMediaResource@@QAEXH@Z @ 518 NONAME ; void QMediaResource::setVideoBitRate(int) - ?setVideoCodec@QMediaResource@@QAEXABVQString@@@Z @ 519 NONAME ; void QMediaResource::setVideoCodec(class QString const &) - ?setVolume@QMediaPlayer@@QAEXH@Z @ 520 NONAME ; void QMediaPlayer::setVolume(int) - ?setVolume@QSoundEffect@@QAEXH@Z @ 521 NONAME ; void QSoundEffect::setVolume(int) - ?setupMetaData@QMediaObject@@AAEXXZ @ 522 NONAME ; void QMediaObject::setupMetaData(void) - ?showEvent@QVideoWidget@@MAEXPAVQShowEvent@@@Z @ 523 NONAME ; void QVideoWidget::showEvent(class QShowEvent *) - ?shuffle@QLocalMediaPlaylistProvider@@UAEXXZ @ 524 NONAME ; void QLocalMediaPlaylistProvider::shuffle(void) - ?shuffle@QMediaPlaylist@@QAEXXZ @ 525 NONAME ; void QMediaPlaylist::shuffle(void) - ?shuffle@QMediaPlaylistProvider@@UAEXXZ @ 526 NONAME ; void QMediaPlaylistProvider::shuffle(void) - ?size@QGraphicsVideoItem@@QBE?AVQSizeF@@XZ @ 527 NONAME ; class QSizeF QGraphicsVideoItem::size(void) const - ?sizeHint@QVideoWidget@@UBE?AVQSize@@XZ @ 528 NONAME ; class QSize QVideoWidget::sizeHint(void) const - ?source@QSoundEffect@@QBE?AVQUrl@@XZ @ 529 NONAME ; class QUrl QSoundEffect::source(void) const - ?sourceChanged@QSoundEffect@@IAEXXZ @ 530 NONAME ; void QSoundEffect::sourceChanged(void) - ?start@QMediaTimeInterval@@QBE_JXZ @ 531 NONAME ; long long QMediaTimeInterval::start(void) const - ?start@QPainterVideoSurface@@UAE_NABVQVideoSurfaceFormat@@@Z @ 532 NONAME ; bool QPainterVideoSurface::start(class QVideoSurfaceFormat const &) - ?state@QMediaPlayer@@QBE?AW4State@1@XZ @ 533 NONAME ; enum QMediaPlayer::State QMediaPlayer::state(void) const - ?stateChanged@QMediaPlayer@@IAEXW4State@1@@Z @ 534 NONAME ; void QMediaPlayer::stateChanged(enum QMediaPlayer::State) - ?stateChanged@QMediaPlayerControl@@IAEXW4State@QMediaPlayer@@@Z @ 535 NONAME ; void QMediaPlayerControl::stateChanged(enum QMediaPlayer::State) - ?stop@QMediaPlayer@@QAEXXZ @ 536 NONAME ; void QMediaPlayer::stop(void) - ?stop@QPainterVideoSurface@@UAEXXZ @ 537 NONAME ; void QPainterVideoSurface::stop(void) - ?supportedMimeTypes@QMediaPlayer@@SA?AVQStringList@@V?$QFlags@W4Flag@QMediaPlayer@@@@@Z @ 538 NONAME ; class QStringList QMediaPlayer::supportedMimeTypes(class QFlags<enum QMediaPlayer::Flag>) - ?supportedMimeTypes@QMediaServiceProvider@@UBE?AVQStringList@@ABVQByteArray@@H@Z @ 539 NONAME ; class QStringList QMediaServiceProvider::supportedMimeTypes(class QByteArray const &, int) const - ?supportedPixelFormats@QPainterVideoSurface@@UBE?AV?$QList@W4PixelFormat@QVideoFrame@@@@W4HandleType@QAbstractVideoBuffer@@@Z @ 540 NONAME ; class QList<enum QVideoFrame::PixelFormat> QPainterVideoSurface::supportedPixelFormats(enum QAbstractVideoBuffer::HandleType) const - ?surroundingItemsChanged@QMediaPlaylistNavigator@@IAEXXZ @ 541 NONAME ; void QMediaPlaylistNavigator::surroundingItemsChanged(void) - ?tr@QGraphicsVideoItem@@SA?AVQString@@PBD0@Z @ 542 NONAME ; class QString QGraphicsVideoItem::tr(char const *, char const *) - ?tr@QGraphicsVideoItem@@SA?AVQString@@PBD0H@Z @ 543 NONAME ; class QString QGraphicsVideoItem::tr(char const *, char const *, int) - ?tr@QLocalMediaPlaylistProvider@@SA?AVQString@@PBD0@Z @ 544 NONAME ; class QString QLocalMediaPlaylistProvider::tr(char const *, char const *) - ?tr@QLocalMediaPlaylistProvider@@SA?AVQString@@PBD0H@Z @ 545 NONAME ; class QString QLocalMediaPlaylistProvider::tr(char const *, char const *, int) - ?tr@QMediaControl@@SA?AVQString@@PBD0@Z @ 546 NONAME ; class QString QMediaControl::tr(char const *, char const *) - ?tr@QMediaControl@@SA?AVQString@@PBD0H@Z @ 547 NONAME ; class QString QMediaControl::tr(char const *, char const *, int) - ?tr@QMediaObject@@SA?AVQString@@PBD0@Z @ 548 NONAME ; class QString QMediaObject::tr(char const *, char const *) - ?tr@QMediaObject@@SA?AVQString@@PBD0H@Z @ 549 NONAME ; class QString QMediaObject::tr(char const *, char const *, int) - ?tr@QMediaPlayer@@SA?AVQString@@PBD0@Z @ 550 NONAME ; class QString QMediaPlayer::tr(char const *, char const *) - ?tr@QMediaPlayer@@SA?AVQString@@PBD0H@Z @ 551 NONAME ; class QString QMediaPlayer::tr(char const *, char const *, int) - ?tr@QMediaPlayerControl@@SA?AVQString@@PBD0@Z @ 552 NONAME ; class QString QMediaPlayerControl::tr(char const *, char const *) - ?tr@QMediaPlayerControl@@SA?AVQString@@PBD0H@Z @ 553 NONAME ; class QString QMediaPlayerControl::tr(char const *, char const *, int) - ?tr@QMediaPlaylist@@SA?AVQString@@PBD0@Z @ 554 NONAME ; class QString QMediaPlaylist::tr(char const *, char const *) - ?tr@QMediaPlaylist@@SA?AVQString@@PBD0H@Z @ 555 NONAME ; class QString QMediaPlaylist::tr(char const *, char const *, int) - ?tr@QMediaPlaylistControl@@SA?AVQString@@PBD0@Z @ 556 NONAME ; class QString QMediaPlaylistControl::tr(char const *, char const *) - ?tr@QMediaPlaylistControl@@SA?AVQString@@PBD0H@Z @ 557 NONAME ; class QString QMediaPlaylistControl::tr(char const *, char const *, int) - ?tr@QMediaPlaylistIOPlugin@@SA?AVQString@@PBD0@Z @ 558 NONAME ; class QString QMediaPlaylistIOPlugin::tr(char const *, char const *) - ?tr@QMediaPlaylistIOPlugin@@SA?AVQString@@PBD0H@Z @ 559 NONAME ; class QString QMediaPlaylistIOPlugin::tr(char const *, char const *, int) - ?tr@QMediaPlaylistNavigator@@SA?AVQString@@PBD0@Z @ 560 NONAME ; class QString QMediaPlaylistNavigator::tr(char const *, char const *) - ?tr@QMediaPlaylistNavigator@@SA?AVQString@@PBD0H@Z @ 561 NONAME ; class QString QMediaPlaylistNavigator::tr(char const *, char const *, int) - ?tr@QMediaPlaylistProvider@@SA?AVQString@@PBD0@Z @ 562 NONAME ; class QString QMediaPlaylistProvider::tr(char const *, char const *) - ?tr@QMediaPlaylistProvider@@SA?AVQString@@PBD0H@Z @ 563 NONAME ; class QString QMediaPlaylistProvider::tr(char const *, char const *, int) - ?tr@QMediaService@@SA?AVQString@@PBD0@Z @ 564 NONAME ; class QString QMediaService::tr(char const *, char const *) - ?tr@QMediaService@@SA?AVQString@@PBD0H@Z @ 565 NONAME ; class QString QMediaService::tr(char const *, char const *, int) - ?tr@QMediaServiceProvider@@SA?AVQString@@PBD0@Z @ 566 NONAME ; class QString QMediaServiceProvider::tr(char const *, char const *) - ?tr@QMediaServiceProvider@@SA?AVQString@@PBD0H@Z @ 567 NONAME ; class QString QMediaServiceProvider::tr(char const *, char const *, int) - ?tr@QMediaServiceProviderPlugin@@SA?AVQString@@PBD0@Z @ 568 NONAME ; class QString QMediaServiceProviderPlugin::tr(char const *, char const *) - ?tr@QMediaServiceProviderPlugin@@SA?AVQString@@PBD0H@Z @ 569 NONAME ; class QString QMediaServiceProviderPlugin::tr(char const *, char const *, int) - ?tr@QMetaDataControl@@SA?AVQString@@PBD0@Z @ 570 NONAME ; class QString QMetaDataControl::tr(char const *, char const *) - ?tr@QMetaDataControl@@SA?AVQString@@PBD0H@Z @ 571 NONAME ; class QString QMetaDataControl::tr(char const *, char const *, int) - ?tr@QPainterVideoSurface@@SA?AVQString@@PBD0@Z @ 572 NONAME ; class QString QPainterVideoSurface::tr(char const *, char const *) - ?tr@QPainterVideoSurface@@SA?AVQString@@PBD0H@Z @ 573 NONAME ; class QString QPainterVideoSurface::tr(char const *, char const *, int) - ?tr@QSoundEffect@@SA?AVQString@@PBD0@Z @ 574 NONAME ; class QString QSoundEffect::tr(char const *, char const *) - ?tr@QSoundEffect@@SA?AVQString@@PBD0H@Z @ 575 NONAME ; class QString QSoundEffect::tr(char const *, char const *, int) - ?tr@QVideoDeviceControl@@SA?AVQString@@PBD0@Z @ 576 NONAME ; class QString QVideoDeviceControl::tr(char const *, char const *) - ?tr@QVideoDeviceControl@@SA?AVQString@@PBD0H@Z @ 577 NONAME ; class QString QVideoDeviceControl::tr(char const *, char const *, int) - ?tr@QVideoOutputControl@@SA?AVQString@@PBD0@Z @ 578 NONAME ; class QString QVideoOutputControl::tr(char const *, char const *) - ?tr@QVideoOutputControl@@SA?AVQString@@PBD0H@Z @ 579 NONAME ; class QString QVideoOutputControl::tr(char const *, char const *, int) - ?tr@QVideoRendererControl@@SA?AVQString@@PBD0@Z @ 580 NONAME ; class QString QVideoRendererControl::tr(char const *, char const *) - ?tr@QVideoRendererControl@@SA?AVQString@@PBD0H@Z @ 581 NONAME ; class QString QVideoRendererControl::tr(char const *, char const *, int) - ?tr@QVideoWidget@@SA?AVQString@@PBD0@Z @ 582 NONAME ; class QString QVideoWidget::tr(char const *, char const *) - ?tr@QVideoWidget@@SA?AVQString@@PBD0H@Z @ 583 NONAME ; class QString QVideoWidget::tr(char const *, char const *, int) - ?tr@QVideoWidgetControl@@SA?AVQString@@PBD0@Z @ 584 NONAME ; class QString QVideoWidgetControl::tr(char const *, char const *) - ?tr@QVideoWidgetControl@@SA?AVQString@@PBD0H@Z @ 585 NONAME ; class QString QVideoWidgetControl::tr(char const *, char const *, int) - ?tr@QVideoWindowControl@@SA?AVQString@@PBD0@Z @ 586 NONAME ; class QString QVideoWindowControl::tr(char const *, char const *) - ?tr@QVideoWindowControl@@SA?AVQString@@PBD0H@Z @ 587 NONAME ; class QString QVideoWindowControl::tr(char const *, char const *, int) - ?trUtf8@QGraphicsVideoItem@@SA?AVQString@@PBD0@Z @ 588 NONAME ; class QString QGraphicsVideoItem::trUtf8(char const *, char const *) - ?trUtf8@QGraphicsVideoItem@@SA?AVQString@@PBD0H@Z @ 589 NONAME ; class QString QGraphicsVideoItem::trUtf8(char const *, char const *, int) - ?trUtf8@QLocalMediaPlaylistProvider@@SA?AVQString@@PBD0@Z @ 590 NONAME ; class QString QLocalMediaPlaylistProvider::trUtf8(char const *, char const *) - ?trUtf8@QLocalMediaPlaylistProvider@@SA?AVQString@@PBD0H@Z @ 591 NONAME ; class QString QLocalMediaPlaylistProvider::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaControl@@SA?AVQString@@PBD0@Z @ 592 NONAME ; class QString QMediaControl::trUtf8(char const *, char const *) - ?trUtf8@QMediaControl@@SA?AVQString@@PBD0H@Z @ 593 NONAME ; class QString QMediaControl::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaObject@@SA?AVQString@@PBD0@Z @ 594 NONAME ; class QString QMediaObject::trUtf8(char const *, char const *) - ?trUtf8@QMediaObject@@SA?AVQString@@PBD0H@Z @ 595 NONAME ; class QString QMediaObject::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaPlayer@@SA?AVQString@@PBD0@Z @ 596 NONAME ; class QString QMediaPlayer::trUtf8(char const *, char const *) - ?trUtf8@QMediaPlayer@@SA?AVQString@@PBD0H@Z @ 597 NONAME ; class QString QMediaPlayer::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaPlayerControl@@SA?AVQString@@PBD0@Z @ 598 NONAME ; class QString QMediaPlayerControl::trUtf8(char const *, char const *) - ?trUtf8@QMediaPlayerControl@@SA?AVQString@@PBD0H@Z @ 599 NONAME ; class QString QMediaPlayerControl::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaPlaylist@@SA?AVQString@@PBD0@Z @ 600 NONAME ; class QString QMediaPlaylist::trUtf8(char const *, char const *) - ?trUtf8@QMediaPlaylist@@SA?AVQString@@PBD0H@Z @ 601 NONAME ; class QString QMediaPlaylist::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaPlaylistControl@@SA?AVQString@@PBD0@Z @ 602 NONAME ; class QString QMediaPlaylistControl::trUtf8(char const *, char const *) - ?trUtf8@QMediaPlaylistControl@@SA?AVQString@@PBD0H@Z @ 603 NONAME ; class QString QMediaPlaylistControl::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaPlaylistIOPlugin@@SA?AVQString@@PBD0@Z @ 604 NONAME ; class QString QMediaPlaylistIOPlugin::trUtf8(char const *, char const *) - ?trUtf8@QMediaPlaylistIOPlugin@@SA?AVQString@@PBD0H@Z @ 605 NONAME ; class QString QMediaPlaylistIOPlugin::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaPlaylistNavigator@@SA?AVQString@@PBD0@Z @ 606 NONAME ; class QString QMediaPlaylistNavigator::trUtf8(char const *, char const *) - ?trUtf8@QMediaPlaylistNavigator@@SA?AVQString@@PBD0H@Z @ 607 NONAME ; class QString QMediaPlaylistNavigator::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaPlaylistProvider@@SA?AVQString@@PBD0@Z @ 608 NONAME ; class QString QMediaPlaylistProvider::trUtf8(char const *, char const *) - ?trUtf8@QMediaPlaylistProvider@@SA?AVQString@@PBD0H@Z @ 609 NONAME ; class QString QMediaPlaylistProvider::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaService@@SA?AVQString@@PBD0@Z @ 610 NONAME ; class QString QMediaService::trUtf8(char const *, char const *) - ?trUtf8@QMediaService@@SA?AVQString@@PBD0H@Z @ 611 NONAME ; class QString QMediaService::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaServiceProvider@@SA?AVQString@@PBD0@Z @ 612 NONAME ; class QString QMediaServiceProvider::trUtf8(char const *, char const *) - ?trUtf8@QMediaServiceProvider@@SA?AVQString@@PBD0H@Z @ 613 NONAME ; class QString QMediaServiceProvider::trUtf8(char const *, char const *, int) - ?trUtf8@QMediaServiceProviderPlugin@@SA?AVQString@@PBD0@Z @ 614 NONAME ; class QString QMediaServiceProviderPlugin::trUtf8(char const *, char const *) - ?trUtf8@QMediaServiceProviderPlugin@@SA?AVQString@@PBD0H@Z @ 615 NONAME ; class QString QMediaServiceProviderPlugin::trUtf8(char const *, char const *, int) - ?trUtf8@QMetaDataControl@@SA?AVQString@@PBD0@Z @ 616 NONAME ; class QString QMetaDataControl::trUtf8(char const *, char const *) - ?trUtf8@QMetaDataControl@@SA?AVQString@@PBD0H@Z @ 617 NONAME ; class QString QMetaDataControl::trUtf8(char const *, char const *, int) - ?trUtf8@QPainterVideoSurface@@SA?AVQString@@PBD0@Z @ 618 NONAME ; class QString QPainterVideoSurface::trUtf8(char const *, char const *) - ?trUtf8@QPainterVideoSurface@@SA?AVQString@@PBD0H@Z @ 619 NONAME ; class QString QPainterVideoSurface::trUtf8(char const *, char const *, int) - ?trUtf8@QSoundEffect@@SA?AVQString@@PBD0@Z @ 620 NONAME ; class QString QSoundEffect::trUtf8(char const *, char const *) - ?trUtf8@QSoundEffect@@SA?AVQString@@PBD0H@Z @ 621 NONAME ; class QString QSoundEffect::trUtf8(char const *, char const *, int) - ?trUtf8@QVideoDeviceControl@@SA?AVQString@@PBD0@Z @ 622 NONAME ; class QString QVideoDeviceControl::trUtf8(char const *, char const *) - ?trUtf8@QVideoDeviceControl@@SA?AVQString@@PBD0H@Z @ 623 NONAME ; class QString QVideoDeviceControl::trUtf8(char const *, char const *, int) - ?trUtf8@QVideoOutputControl@@SA?AVQString@@PBD0@Z @ 624 NONAME ; class QString QVideoOutputControl::trUtf8(char const *, char const *) - ?trUtf8@QVideoOutputControl@@SA?AVQString@@PBD0H@Z @ 625 NONAME ; class QString QVideoOutputControl::trUtf8(char const *, char const *, int) - ?trUtf8@QVideoRendererControl@@SA?AVQString@@PBD0@Z @ 626 NONAME ; class QString QVideoRendererControl::trUtf8(char const *, char const *) - ?trUtf8@QVideoRendererControl@@SA?AVQString@@PBD0H@Z @ 627 NONAME ; class QString QVideoRendererControl::trUtf8(char const *, char const *, int) - ?trUtf8@QVideoWidget@@SA?AVQString@@PBD0@Z @ 628 NONAME ; class QString QVideoWidget::trUtf8(char const *, char const *) - ?trUtf8@QVideoWidget@@SA?AVQString@@PBD0H@Z @ 629 NONAME ; class QString QVideoWidget::trUtf8(char const *, char const *, int) - ?trUtf8@QVideoWidgetControl@@SA?AVQString@@PBD0@Z @ 630 NONAME ; class QString QVideoWidgetControl::trUtf8(char const *, char const *) - ?trUtf8@QVideoWidgetControl@@SA?AVQString@@PBD0H@Z @ 631 NONAME ; class QString QVideoWidgetControl::trUtf8(char const *, char const *, int) - ?trUtf8@QVideoWindowControl@@SA?AVQString@@PBD0@Z @ 632 NONAME ; class QString QVideoWindowControl::trUtf8(char const *, char const *) - ?trUtf8@QVideoWindowControl@@SA?AVQString@@PBD0H@Z @ 633 NONAME ; class QString QVideoWindowControl::trUtf8(char const *, char const *, int) - ?translated@QMediaTimeInterval@@QBE?AV1@_J@Z @ 634 NONAME ; class QMediaTimeInterval QMediaTimeInterval::translated(long long) const - ?type@QMediaServiceProviderHint@@QBE?AW4Type@1@XZ @ 635 NONAME ; enum QMediaServiceProviderHint::Type QMediaServiceProviderHint::type(void) const - ?unbind@QMediaObject@@UAEXPAVQObject@@@Z @ 636 NONAME ; void QMediaObject::unbind(class QObject *) - ?unbind@QMediaPlayer@@UAEXPAVQObject@@@Z @ 637 NONAME ; void QMediaPlayer::unbind(class QObject *) - ?url@QMediaResource@@QBE?AVQUrl@@XZ @ 638 NONAME ; class QUrl QMediaResource::url(void) const - ?videoAvailableChanged@QMediaPlayer@@IAEX_N@Z @ 639 NONAME ; void QMediaPlayer::videoAvailableChanged(bool) - ?videoAvailableChanged@QMediaPlayerControl@@IAEX_N@Z @ 640 NONAME ; void QMediaPlayerControl::videoAvailableChanged(bool) - ?videoBitRate@QMediaResource@@QBEHXZ @ 641 NONAME ; int QMediaResource::videoBitRate(void) const - ?videoCodec@QMediaResource@@QBE?AVQString@@XZ @ 642 NONAME ; class QString QMediaResource::videoCodec(void) const - ?volume@QMediaPlayer@@QBEHXZ @ 643 NONAME ; int QMediaPlayer::volume(void) const - ?volume@QSoundEffect@@QBEHXZ @ 644 NONAME ; int QSoundEffect::volume(void) const - ?volumeChanged@QMediaPlayer@@IAEXH@Z @ 645 NONAME ; void QMediaPlayer::volumeChanged(int) - ?volumeChanged@QMediaPlayerControl@@IAEXH@Z @ 646 NONAME ; void QMediaPlayerControl::volumeChanged(int) - ?volumeChanged@QSoundEffect@@IAEXXZ @ 647 NONAME ; void QSoundEffect::volumeChanged(void) - ?writableChanged@QMetaDataControl@@IAEX_N@Z @ 648 NONAME ; void QMetaDataControl::writableChanged(bool) - ?staticMetaObject@QMediaPlaylistProvider@@2UQMetaObject@@B @ 649 NONAME ; struct QMetaObject const QMediaPlaylistProvider::staticMetaObject - ?staticMetaObject@QSoundEffect@@2UQMetaObject@@B @ 650 NONAME ; struct QMetaObject const QSoundEffect::staticMetaObject - ?staticMetaObject@QVideoWidget@@2UQMetaObject@@B @ 651 NONAME ; struct QMetaObject const QVideoWidget::staticMetaObject - ?staticMetaObject@QMediaPlaylistControl@@2UQMetaObject@@B @ 652 NONAME ; struct QMetaObject const QMediaPlaylistControl::staticMetaObject - ?staticMetaObject@QMediaControl@@2UQMetaObject@@B @ 653 NONAME ; struct QMetaObject const QMediaControl::staticMetaObject - ?staticMetaObject@QLocalMediaPlaylistProvider@@2UQMetaObject@@B @ 654 NONAME ; struct QMetaObject const QLocalMediaPlaylistProvider::staticMetaObject - ?staticMetaObject@QMediaServiceProviderPlugin@@2UQMetaObject@@B @ 655 NONAME ; struct QMetaObject const QMediaServiceProviderPlugin::staticMetaObject - ?staticMetaObject@QVideoOutputControl@@2UQMetaObject@@B @ 656 NONAME ; struct QMetaObject const QVideoOutputControl::staticMetaObject - ?staticMetaObject@QMetaDataControl@@2UQMetaObject@@B @ 657 NONAME ; struct QMetaObject const QMetaDataControl::staticMetaObject - ?staticMetaObject@QMediaPlayer@@2UQMetaObject@@B @ 658 NONAME ; struct QMetaObject const QMediaPlayer::staticMetaObject - ?staticMetaObject@QMediaService@@2UQMetaObject@@B @ 659 NONAME ; struct QMetaObject const QMediaService::staticMetaObject - ?staticMetaObject@QMediaObject@@2UQMetaObject@@B @ 660 NONAME ; struct QMetaObject const QMediaObject::staticMetaObject - ?staticMetaObject@QMediaPlaylist@@2UQMetaObject@@B @ 661 NONAME ; struct QMetaObject const QMediaPlaylist::staticMetaObject - ?staticMetaObject@QMediaServiceProvider@@2UQMetaObject@@B @ 662 NONAME ; struct QMetaObject const QMediaServiceProvider::staticMetaObject - ?staticMetaObject@QMediaPlayerControl@@2UQMetaObject@@B @ 663 NONAME ; struct QMetaObject const QMediaPlayerControl::staticMetaObject - ?staticMetaObject@QMediaPlaylistNavigator@@2UQMetaObject@@B @ 664 NONAME ; struct QMetaObject const QMediaPlaylistNavigator::staticMetaObject - ?staticMetaObject@QVideoWidgetControl@@2UQMetaObject@@B @ 665 NONAME ; struct QMetaObject const QVideoWidgetControl::staticMetaObject - ?staticMetaObject@QVideoWindowControl@@2UQMetaObject@@B @ 666 NONAME ; struct QMetaObject const QVideoWindowControl::staticMetaObject - ?staticMetaObject@QVideoDeviceControl@@2UQMetaObject@@B @ 667 NONAME ; struct QMetaObject const QVideoDeviceControl::staticMetaObject - ?staticMetaObject@QVideoRendererControl@@2UQMetaObject@@B @ 668 NONAME ; struct QMetaObject const QVideoRendererControl::staticMetaObject - ?staticMetaObject@QPainterVideoSurface@@2UQMetaObject@@B @ 669 NONAME ; struct QMetaObject const QPainterVideoSurface::staticMetaObject - ?staticMetaObject@QMediaPlaylistIOPlugin@@2UQMetaObject@@B @ 670 NONAME ; struct QMetaObject const QMediaPlaylistIOPlugin::staticMetaObject - ?staticMetaObject@QGraphicsVideoItem@@2UQMetaObject@@B @ 671 NONAME ; struct QMetaObject const QGraphicsVideoItem::staticMetaObject - diff --git a/src/s60installs/eabi/QtMediaServicesu.def b/src/s60installs/eabi/QtMediaServicesu.def deleted file mode 100644 index 0b4083d..0000000 --- a/src/s60installs/eabi/QtMediaServicesu.def +++ /dev/null @@ -1,674 +0,0 @@ -EXPORTS - _ZN12QMediaObject11qt_metacallEN11QMetaObject4CallEiPPv @ 1 NONAME - _ZN12QMediaObject11qt_metacastEPKc @ 2 NONAME - _ZN12QMediaObject11setMetaDataEN15QtMediaServices8MetaDataERK8QVariant @ 3 NONAME - _ZN12QMediaObject13setupMetaDataEv @ 4 NONAME - _ZN12QMediaObject15metaDataChangedEv @ 5 NONAME - _ZN12QMediaObject16addPropertyWatchERK10QByteArray @ 6 NONAME - _ZN12QMediaObject16staticMetaObjectE @ 7 NONAME DATA 16 - _ZN12QMediaObject17setNotifyIntervalEi @ 8 NONAME - _ZN12QMediaObject19availabilityChangedEb @ 9 NONAME - _ZN12QMediaObject19getStaticMetaObjectEv @ 10 NONAME - _ZN12QMediaObject19removePropertyWatchERK10QByteArray @ 11 NONAME - _ZN12QMediaObject19setExtendedMetaDataERK7QStringRK8QVariant @ 12 NONAME - _ZN12QMediaObject21notifyIntervalChangedEi @ 13 NONAME - _ZN12QMediaObject23metaDataWritableChangedEb @ 14 NONAME - _ZN12QMediaObject24metaDataAvailableChangedEb @ 15 NONAME - _ZN12QMediaObject4bindEP7QObject @ 16 NONAME - _ZN12QMediaObject6unbindEP7QObject @ 17 NONAME - _ZN12QMediaObjectC1EP7QObjectP13QMediaService @ 18 NONAME - _ZN12QMediaObjectC1ER19QMediaObjectPrivateP7QObjectP13QMediaService @ 19 NONAME - _ZN12QMediaObjectC2EP7QObjectP13QMediaService @ 20 NONAME - _ZN12QMediaObjectC2ER19QMediaObjectPrivateP7QObjectP13QMediaService @ 21 NONAME - _ZN12QMediaObjectD0Ev @ 22 NONAME - _ZN12QMediaObjectD1Ev @ 23 NONAME - _ZN12QMediaObjectD2Ev @ 24 NONAME - _ZN12QMediaPlayer10hasSupportERK7QStringRK11QStringList6QFlagsINS_4FlagEE @ 25 NONAME - _ZN12QMediaPlayer11qt_metacallEN11QMetaObject4CallEiPPv @ 26 NONAME - _ZN12QMediaPlayer11qt_metacastEPKc @ 27 NONAME - _ZN12QMediaPlayer11setPositionEx @ 28 NONAME - _ZN12QMediaPlayer12mediaChangedERK13QMediaContent @ 29 NONAME - _ZN12QMediaPlayer12mutedChangedEb @ 30 NONAME - _ZN12QMediaPlayer12stateChangedENS_5StateE @ 31 NONAME - _ZN12QMediaPlayer13volumeChangedEi @ 32 NONAME - _ZN12QMediaPlayer15durationChangedEx @ 33 NONAME - _ZN12QMediaPlayer15positionChangedEx @ 34 NONAME - _ZN12QMediaPlayer15seekableChangedEb @ 35 NONAME - _ZN12QMediaPlayer15setPlaybackRateEf @ 36 NONAME - _ZN12QMediaPlayer16staticMetaObjectE @ 37 NONAME DATA 16 - _ZN12QMediaPlayer18mediaStatusChangedENS_11MediaStatusE @ 38 NONAME - _ZN12QMediaPlayer18supportedMimeTypesE6QFlagsINS_4FlagEE @ 39 NONAME - _ZN12QMediaPlayer19bufferStatusChangedEi @ 40 NONAME - _ZN12QMediaPlayer19getStaticMetaObjectEv @ 41 NONAME - _ZN12QMediaPlayer19playbackRateChangedEf @ 42 NONAME - _ZN12QMediaPlayer21audioAvailableChangedEb @ 43 NONAME - _ZN12QMediaPlayer21videoAvailableChangedEb @ 44 NONAME - _ZN12QMediaPlayer4bindEP7QObject @ 45 NONAME - _ZN12QMediaPlayer4playEv @ 46 NONAME - _ZN12QMediaPlayer4stopEv @ 47 NONAME - _ZN12QMediaPlayer5errorENS_5ErrorE @ 48 NONAME - _ZN12QMediaPlayer5pauseEv @ 49 NONAME - _ZN12QMediaPlayer6unbindEP7QObject @ 50 NONAME - _ZN12QMediaPlayer8setMediaERK13QMediaContentP9QIODevice @ 51 NONAME - _ZN12QMediaPlayer8setMutedEb @ 52 NONAME - _ZN12QMediaPlayer9setVolumeEi @ 53 NONAME - _ZN12QMediaPlayerC1EP7QObject6QFlagsINS_4FlagEEP21QMediaServiceProvider @ 54 NONAME - _ZN12QMediaPlayerC2EP7QObject6QFlagsINS_4FlagEEP21QMediaServiceProvider @ 55 NONAME - _ZN12QMediaPlayerD0Ev @ 56 NONAME - _ZN12QMediaPlayerD1Ev @ 57 NONAME - _ZN12QMediaPlayerD2Ev @ 58 NONAME - _ZN12QSoundEffect11qt_metacallEN11QMetaObject4CallEiPPv @ 59 NONAME - _ZN12QSoundEffect11qt_metacastEPKc @ 60 NONAME - _ZN12QSoundEffect12loopsChangedEv @ 61 NONAME - _ZN12QSoundEffect12mutedChangedEv @ 62 NONAME - _ZN12QSoundEffect13sourceChangedEv @ 63 NONAME - _ZN12QSoundEffect13volumeChangedEv @ 64 NONAME - _ZN12QSoundEffect16staticMetaObjectE @ 65 NONAME DATA 16 - _ZN12QSoundEffect19getStaticMetaObjectEv @ 66 NONAME - _ZN12QSoundEffect4playEv @ 67 NONAME - _ZN12QSoundEffect8setLoopsEi @ 68 NONAME - _ZN12QSoundEffect8setMutedEb @ 69 NONAME - _ZN12QSoundEffect9setSourceERK4QUrl @ 70 NONAME - _ZN12QSoundEffect9setVolumeEi @ 71 NONAME - _ZN12QSoundEffectC1EP7QObject @ 72 NONAME - _ZN12QSoundEffectC2EP7QObject @ 73 NONAME - _ZN12QSoundEffectD0Ev @ 74 NONAME - _ZN12QSoundEffectD1Ev @ 75 NONAME - _ZN12QSoundEffectD2Ev @ 76 NONAME - _ZN12QVideoWidget10hueChangedEi @ 77 NONAME - _ZN12QVideoWidget10paintEventEP11QPaintEvent @ 78 NONAME - _ZN12QVideoWidget11qt_metacallEN11QMetaObject4CallEiPPv @ 79 NONAME - _ZN12QVideoWidget11qt_metacastEPKc @ 80 NONAME - _ZN12QVideoWidget11resizeEventEP12QResizeEvent @ 81 NONAME - _ZN12QVideoWidget11setContrastEi @ 82 NONAME - _ZN12QVideoWidget13setBrightnessEi @ 83 NONAME - _ZN12QVideoWidget13setFullScreenEb @ 84 NONAME - _ZN12QVideoWidget13setSaturationEi @ 85 NONAME - _ZN12QVideoWidget14setMediaObjectEP12QMediaObject @ 86 NONAME - _ZN12QVideoWidget15contrastChangedEi @ 87 NONAME - _ZN12QVideoWidget16staticMetaObjectE @ 88 NONAME DATA 16 - _ZN12QVideoWidget17brightnessChangedEi @ 89 NONAME - _ZN12QVideoWidget17fullScreenChangedEb @ 90 NONAME - _ZN12QVideoWidget17saturationChangedEi @ 91 NONAME - _ZN12QVideoWidget18setAspectRatioModeEN2Qt15AspectRatioModeE @ 92 NONAME - _ZN12QVideoWidget19getStaticMetaObjectEv @ 93 NONAME - _ZN12QVideoWidget5eventEP6QEvent @ 94 NONAME - _ZN12QVideoWidget6setHueEi @ 95 NONAME - _ZN12QVideoWidget9hideEventEP10QHideEvent @ 96 NONAME - _ZN12QVideoWidget9moveEventEP10QMoveEvent @ 97 NONAME - _ZN12QVideoWidget9showEventEP10QShowEvent @ 98 NONAME - _ZN12QVideoWidgetC1EP7QWidget @ 99 NONAME - _ZN12QVideoWidgetC2EP7QWidget @ 100 NONAME - _ZN12QVideoWidgetD0Ev @ 101 NONAME - _ZN12QVideoWidgetD1Ev @ 102 NONAME - _ZN12QVideoWidgetD2Ev @ 103 NONAME - _ZN13QMediaContentC1ERK14QMediaResource @ 104 NONAME - _ZN13QMediaContentC1ERK15QNetworkRequest @ 105 NONAME - _ZN13QMediaContentC1ERK4QUrl @ 106 NONAME - _ZN13QMediaContentC1ERK5QListI14QMediaResourceE @ 107 NONAME - _ZN13QMediaContentC1ERKS_ @ 108 NONAME - _ZN13QMediaContentC1Ev @ 109 NONAME - _ZN13QMediaContentC2ERK14QMediaResource @ 110 NONAME - _ZN13QMediaContentC2ERK15QNetworkRequest @ 111 NONAME - _ZN13QMediaContentC2ERK4QUrl @ 112 NONAME - _ZN13QMediaContentC2ERK5QListI14QMediaResourceE @ 113 NONAME - _ZN13QMediaContentC2ERKS_ @ 114 NONAME - _ZN13QMediaContentC2Ev @ 115 NONAME - _ZN13QMediaContentD1Ev @ 116 NONAME - _ZN13QMediaContentD2Ev @ 117 NONAME - _ZN13QMediaContentaSERKS_ @ 118 NONAME - _ZN13QMediaControl11qt_metacallEN11QMetaObject4CallEiPPv @ 119 NONAME - _ZN13QMediaControl11qt_metacastEPKc @ 120 NONAME - _ZN13QMediaControl16staticMetaObjectE @ 121 NONAME DATA 16 - _ZN13QMediaControl19getStaticMetaObjectEv @ 122 NONAME - _ZN13QMediaControlC1EP7QObject @ 123 NONAME - _ZN13QMediaControlC1ER20QMediaControlPrivateP7QObject @ 124 NONAME - _ZN13QMediaControlC2EP7QObject @ 125 NONAME - _ZN13QMediaControlC2ER20QMediaControlPrivateP7QObject @ 126 NONAME - _ZN13QMediaControlD0Ev @ 127 NONAME - _ZN13QMediaControlD1Ev @ 128 NONAME - _ZN13QMediaControlD2Ev @ 129 NONAME - _ZN13QMediaService11qt_metacallEN11QMetaObject4CallEiPPv @ 130 NONAME - _ZN13QMediaService11qt_metacastEPKc @ 131 NONAME - _ZN13QMediaService16staticMetaObjectE @ 132 NONAME DATA 16 - _ZN13QMediaService19getStaticMetaObjectEv @ 133 NONAME - _ZN13QMediaServiceC2EP7QObject @ 134 NONAME - _ZN13QMediaServiceC2ER20QMediaServicePrivateP7QObject @ 135 NONAME - _ZN13QMediaServiceD0Ev @ 136 NONAME - _ZN13QMediaServiceD1Ev @ 137 NONAME - _ZN13QMediaServiceD2Ev @ 138 NONAME - _ZN14QMediaPlaylist10loadFailedEv @ 139 NONAME - _ZN14QMediaPlaylist11insertMediaEiRK13QMediaContent @ 140 NONAME - _ZN14QMediaPlaylist11insertMediaEiRK5QListI13QMediaContentE @ 141 NONAME - _ZN14QMediaPlaylist11qt_metacallEN11QMetaObject4CallEiPPv @ 142 NONAME - _ZN14QMediaPlaylist11qt_metacastEPKc @ 143 NONAME - _ZN14QMediaPlaylist11removeMediaEi @ 144 NONAME - _ZN14QMediaPlaylist11removeMediaEii @ 145 NONAME - _ZN14QMediaPlaylist12mediaChangedEii @ 146 NONAME - _ZN14QMediaPlaylist12mediaRemovedEii @ 147 NONAME - _ZN14QMediaPlaylist13mediaInsertedEii @ 148 NONAME - _ZN14QMediaPlaylist14setMediaObjectEP12QMediaObject @ 149 NONAME - _ZN14QMediaPlaylist15setCurrentIndexEi @ 150 NONAME - _ZN14QMediaPlaylist15setPlaybackModeENS_12PlaybackModeE @ 151 NONAME - _ZN14QMediaPlaylist16staticMetaObjectE @ 152 NONAME DATA 16 - _ZN14QMediaPlaylist19currentIndexChangedEi @ 153 NONAME - _ZN14QMediaPlaylist19currentMediaChangedERK13QMediaContent @ 154 NONAME - _ZN14QMediaPlaylist19getStaticMetaObjectEv @ 155 NONAME - _ZN14QMediaPlaylist19playbackModeChangedENS_12PlaybackModeE @ 156 NONAME - _ZN14QMediaPlaylist21mediaAboutToBeRemovedEii @ 157 NONAME - _ZN14QMediaPlaylist22mediaAboutToBeInsertedEii @ 158 NONAME - _ZN14QMediaPlaylist4loadEP9QIODevicePKc @ 159 NONAME - _ZN14QMediaPlaylist4loadERK4QUrlPKc @ 160 NONAME - _ZN14QMediaPlaylist4nextEv @ 161 NONAME - _ZN14QMediaPlaylist4saveEP9QIODevicePKc @ 162 NONAME - _ZN14QMediaPlaylist4saveERK4QUrlPKc @ 163 NONAME - _ZN14QMediaPlaylist5clearEv @ 164 NONAME - _ZN14QMediaPlaylist6loadedEv @ 165 NONAME - _ZN14QMediaPlaylist7shuffleEv @ 166 NONAME - _ZN14QMediaPlaylist8addMediaERK13QMediaContent @ 167 NONAME - _ZN14QMediaPlaylist8addMediaERK5QListI13QMediaContentE @ 168 NONAME - _ZN14QMediaPlaylist8previousEv @ 169 NONAME - _ZN14QMediaPlaylistC1EP7QObject @ 170 NONAME - _ZN14QMediaPlaylistC2EP7QObject @ 171 NONAME - _ZN14QMediaPlaylistD0Ev @ 172 NONAME - _ZN14QMediaPlaylistD1Ev @ 173 NONAME - _ZN14QMediaPlaylistD2Ev @ 174 NONAME - _ZN14QMediaResource11setDataSizeEx @ 175 NONAME - _ZN14QMediaResource11setLanguageERK7QString @ 176 NONAME - _ZN14QMediaResource13setAudioCodecERK7QString @ 177 NONAME - _ZN14QMediaResource13setResolutionERK5QSize @ 178 NONAME - _ZN14QMediaResource13setResolutionEii @ 179 NONAME - _ZN14QMediaResource13setSampleRateEi @ 180 NONAME - _ZN14QMediaResource13setVideoCodecERK7QString @ 181 NONAME - _ZN14QMediaResource15setAudioBitRateEi @ 182 NONAME - _ZN14QMediaResource15setChannelCountEi @ 183 NONAME - _ZN14QMediaResource15setVideoBitRateEi @ 184 NONAME - _ZN14QMediaResourceC1ERK15QNetworkRequestRK7QString @ 185 NONAME - _ZN14QMediaResourceC1ERK4QUrlRK7QString @ 186 NONAME - _ZN14QMediaResourceC1ERKS_ @ 187 NONAME - _ZN14QMediaResourceC1Ev @ 188 NONAME - _ZN14QMediaResourceC2ERK15QNetworkRequestRK7QString @ 189 NONAME - _ZN14QMediaResourceC2ERK4QUrlRK7QString @ 190 NONAME - _ZN14QMediaResourceC2ERKS_ @ 191 NONAME - _ZN14QMediaResourceC2Ev @ 192 NONAME - _ZN14QMediaResourceD1Ev @ 193 NONAME - _ZN14QMediaResourceD2Ev @ 194 NONAME - _ZN14QMediaResourceaSERKS_ @ 195 NONAME - _ZN15QMediaTimeRange11addIntervalERK18QMediaTimeInterval @ 196 NONAME - _ZN15QMediaTimeRange11addIntervalExx @ 197 NONAME - _ZN15QMediaTimeRange12addTimeRangeERKS_ @ 198 NONAME - _ZN15QMediaTimeRange14removeIntervalERK18QMediaTimeInterval @ 199 NONAME - _ZN15QMediaTimeRange14removeIntervalExx @ 200 NONAME - _ZN15QMediaTimeRange15removeTimeRangeERKS_ @ 201 NONAME - _ZN15QMediaTimeRange5clearEv @ 202 NONAME - _ZN15QMediaTimeRangeC1ERK18QMediaTimeInterval @ 203 NONAME - _ZN15QMediaTimeRangeC1ERKS_ @ 204 NONAME - _ZN15QMediaTimeRangeC1Ev @ 205 NONAME - _ZN15QMediaTimeRangeC1Exx @ 206 NONAME - _ZN15QMediaTimeRangeC2ERK18QMediaTimeInterval @ 207 NONAME - _ZN15QMediaTimeRangeC2ERKS_ @ 208 NONAME - _ZN15QMediaTimeRangeC2Ev @ 209 NONAME - _ZN15QMediaTimeRangeC2Exx @ 210 NONAME - _ZN15QMediaTimeRangeD1Ev @ 211 NONAME - _ZN15QMediaTimeRangeD2Ev @ 212 NONAME - _ZN15QMediaTimeRangeaSERK18QMediaTimeInterval @ 213 NONAME - _ZN15QMediaTimeRangeaSERKS_ @ 214 NONAME - _ZN15QMediaTimeRangemIERK18QMediaTimeInterval @ 215 NONAME - _ZN15QMediaTimeRangemIERKS_ @ 216 NONAME - _ZN15QMediaTimeRangepLERK18QMediaTimeInterval @ 217 NONAME - _ZN15QMediaTimeRangepLERKS_ @ 218 NONAME - _ZN16QMetaDataControl11qt_metacallEN11QMetaObject4CallEiPPv @ 219 NONAME - _ZN16QMetaDataControl11qt_metacastEPKc @ 220 NONAME - _ZN16QMetaDataControl15metaDataChangedEv @ 221 NONAME - _ZN16QMetaDataControl15writableChangedEb @ 222 NONAME - _ZN16QMetaDataControl16staticMetaObjectE @ 223 NONAME DATA 16 - _ZN16QMetaDataControl19getStaticMetaObjectEv @ 224 NONAME - _ZN16QMetaDataControl24metaDataAvailableChangedEb @ 225 NONAME - _ZN16QMetaDataControlC2EP7QObject @ 226 NONAME - _ZN16QMetaDataControlD0Ev @ 227 NONAME - _ZN16QMetaDataControlD1Ev @ 228 NONAME - _ZN16QMetaDataControlD2Ev @ 229 NONAME - _ZN18QGraphicsVideoItem10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 230 NONAME - _ZN18QGraphicsVideoItem10sceneEventEP6QEvent @ 231 NONAME - _ZN18QGraphicsVideoItem11qt_metacallEN11QMetaObject4CallEiPPv @ 232 NONAME - _ZN18QGraphicsVideoItem11qt_metacastEPKc @ 233 NONAME - _ZN18QGraphicsVideoItem14setMediaObjectEP12QMediaObject @ 234 NONAME - _ZN18QGraphicsVideoItem16staticMetaObjectE @ 235 NONAME DATA 16 - _ZN18QGraphicsVideoItem17nativeSizeChangedERK6QSizeF @ 236 NONAME - _ZN18QGraphicsVideoItem18setAspectRatioModeEN2Qt15AspectRatioModeE @ 237 NONAME - _ZN18QGraphicsVideoItem19getStaticMetaObjectEv @ 238 NONAME - _ZN18QGraphicsVideoItem5eventEP6QEvent @ 239 NONAME - _ZN18QGraphicsVideoItem5paintEP8QPainterPK24QStyleOptionGraphicsItemP7QWidget @ 240 NONAME - _ZN18QGraphicsVideoItem7setSizeERK6QSizeF @ 241 NONAME - _ZN18QGraphicsVideoItem9setOffsetERK7QPointF @ 242 NONAME - _ZN18QGraphicsVideoItemC1EP13QGraphicsItem @ 243 NONAME - _ZN18QGraphicsVideoItemC2EP13QGraphicsItem @ 244 NONAME - _ZN18QGraphicsVideoItemD0Ev @ 245 NONAME - _ZN18QGraphicsVideoItemD1Ev @ 246 NONAME - _ZN18QGraphicsVideoItemD2Ev @ 247 NONAME - _ZN18QMediaTimeIntervalC1ERKS_ @ 248 NONAME - _ZN18QMediaTimeIntervalC1Ev @ 249 NONAME - _ZN18QMediaTimeIntervalC1Exx @ 250 NONAME - _ZN18QMediaTimeIntervalC2ERKS_ @ 251 NONAME - _ZN18QMediaTimeIntervalC2Ev @ 252 NONAME - _ZN18QMediaTimeIntervalC2Exx @ 253 NONAME - _ZN19QMediaPlayerControl11qt_metacallEN11QMetaObject4CallEiPPv @ 254 NONAME - _ZN19QMediaPlayerControl11qt_metacastEPKc @ 255 NONAME - _ZN19QMediaPlayerControl12mediaChangedERK13QMediaContent @ 256 NONAME - _ZN19QMediaPlayerControl12mutedChangedEb @ 257 NONAME - _ZN19QMediaPlayerControl12stateChangedEN12QMediaPlayer5StateE @ 258 NONAME - _ZN19QMediaPlayerControl13volumeChangedEi @ 259 NONAME - _ZN19QMediaPlayerControl15durationChangedEx @ 260 NONAME - _ZN19QMediaPlayerControl15positionChangedEx @ 261 NONAME - _ZN19QMediaPlayerControl15seekableChangedEb @ 262 NONAME - _ZN19QMediaPlayerControl16staticMetaObjectE @ 263 NONAME DATA 16 - _ZN19QMediaPlayerControl18mediaStatusChangedEN12QMediaPlayer11MediaStatusE @ 264 NONAME - _ZN19QMediaPlayerControl19bufferStatusChangedEi @ 265 NONAME - _ZN19QMediaPlayerControl19getStaticMetaObjectEv @ 266 NONAME - _ZN19QMediaPlayerControl19playbackRateChangedEf @ 267 NONAME - _ZN19QMediaPlayerControl21audioAvailableChangedEb @ 268 NONAME - _ZN19QMediaPlayerControl21videoAvailableChangedEb @ 269 NONAME - _ZN19QMediaPlayerControl30availablePlaybackRangesChangedERK15QMediaTimeRange @ 270 NONAME - _ZN19QMediaPlayerControl5errorEiRK7QString @ 271 NONAME - _ZN19QMediaPlayerControlC2EP7QObject @ 272 NONAME - _ZN19QMediaPlayerControlD0Ev @ 273 NONAME - _ZN19QMediaPlayerControlD1Ev @ 274 NONAME - _ZN19QMediaPlayerControlD2Ev @ 275 NONAME - _ZN19QVideoDeviceControl11qt_metacallEN11QMetaObject4CallEiPPv @ 276 NONAME - _ZN19QVideoDeviceControl11qt_metacastEPKc @ 277 NONAME - _ZN19QVideoDeviceControl14devicesChangedEv @ 278 NONAME - _ZN19QVideoDeviceControl16staticMetaObjectE @ 279 NONAME DATA 16 - _ZN19QVideoDeviceControl19getStaticMetaObjectEv @ 280 NONAME - _ZN19QVideoDeviceControl21selectedDeviceChangedERK7QString @ 281 NONAME - _ZN19QVideoDeviceControl21selectedDeviceChangedEi @ 282 NONAME - _ZN19QVideoDeviceControlC2EP7QObject @ 283 NONAME - _ZN19QVideoDeviceControlD0Ev @ 284 NONAME - _ZN19QVideoDeviceControlD1Ev @ 285 NONAME - _ZN19QVideoDeviceControlD2Ev @ 286 NONAME - _ZN19QVideoOutputControl11qt_metacallEN11QMetaObject4CallEiPPv @ 287 NONAME - _ZN19QVideoOutputControl11qt_metacastEPKc @ 288 NONAME - _ZN19QVideoOutputControl16staticMetaObjectE @ 289 NONAME DATA 16 - _ZN19QVideoOutputControl19getStaticMetaObjectEv @ 290 NONAME - _ZN19QVideoOutputControl23availableOutputsChangedERK5QListINS_6OutputEE @ 291 NONAME - _ZN19QVideoOutputControlC2EP7QObject @ 292 NONAME - _ZN19QVideoOutputControlD0Ev @ 293 NONAME - _ZN19QVideoOutputControlD1Ev @ 294 NONAME - _ZN19QVideoOutputControlD2Ev @ 295 NONAME - _ZN19QVideoWidgetControl10hueChangedEi @ 296 NONAME - _ZN19QVideoWidgetControl11qt_metacallEN11QMetaObject4CallEiPPv @ 297 NONAME - _ZN19QVideoWidgetControl11qt_metacastEPKc @ 298 NONAME - _ZN19QVideoWidgetControl15contrastChangedEi @ 299 NONAME - _ZN19QVideoWidgetControl16staticMetaObjectE @ 300 NONAME DATA 16 - _ZN19QVideoWidgetControl17brightnessChangedEi @ 301 NONAME - _ZN19QVideoWidgetControl17fullScreenChangedEb @ 302 NONAME - _ZN19QVideoWidgetControl17saturationChangedEi @ 303 NONAME - _ZN19QVideoWidgetControl19getStaticMetaObjectEv @ 304 NONAME - _ZN19QVideoWidgetControlC2EP7QObject @ 305 NONAME - _ZN19QVideoWidgetControlD0Ev @ 306 NONAME - _ZN19QVideoWidgetControlD1Ev @ 307 NONAME - _ZN19QVideoWidgetControlD2Ev @ 308 NONAME - _ZN19QVideoWindowControl10hueChangedEi @ 309 NONAME - _ZN19QVideoWindowControl11qt_metacallEN11QMetaObject4CallEiPPv @ 310 NONAME - _ZN19QVideoWindowControl11qt_metacastEPKc @ 311 NONAME - _ZN19QVideoWindowControl15contrastChangedEi @ 312 NONAME - _ZN19QVideoWindowControl16staticMetaObjectE @ 313 NONAME DATA 16 - _ZN19QVideoWindowControl17brightnessChangedEi @ 314 NONAME - _ZN19QVideoWindowControl17fullScreenChangedEb @ 315 NONAME - _ZN19QVideoWindowControl17nativeSizeChangedEv @ 316 NONAME - _ZN19QVideoWindowControl17saturationChangedEi @ 317 NONAME - _ZN19QVideoWindowControl19getStaticMetaObjectEv @ 318 NONAME - _ZN19QVideoWindowControlC2EP7QObject @ 319 NONAME - _ZN19QVideoWindowControlD0Ev @ 320 NONAME - _ZN19QVideoWindowControlD1Ev @ 321 NONAME - _ZN19QVideoWindowControlD2Ev @ 322 NONAME - _ZN20QMediaPlaylistReaderD0Ev @ 323 NONAME - _ZN20QMediaPlaylistReaderD1Ev @ 324 NONAME - _ZN20QMediaPlaylistReaderD2Ev @ 325 NONAME - _ZN20QMediaPlaylistWriterD0Ev @ 326 NONAME - _ZN20QMediaPlaylistWriterD1Ev @ 327 NONAME - _ZN20QMediaPlaylistWriterD2Ev @ 328 NONAME - _ZN20QPainterVideoSurface11qt_metacallEN11QMetaObject4CallEiPPv @ 329 NONAME - _ZN20QPainterVideoSurface11qt_metacastEPKc @ 330 NONAME - _ZN20QPainterVideoSurface11setContrastEi @ 331 NONAME - _ZN20QPainterVideoSurface12frameChangedEv @ 332 NONAME - _ZN20QPainterVideoSurface13createPainterEv @ 333 NONAME - _ZN20QPainterVideoSurface13setBrightnessEi @ 334 NONAME - _ZN20QPainterVideoSurface13setSaturationEi @ 335 NONAME - _ZN20QPainterVideoSurface16staticMetaObjectE @ 336 NONAME DATA 16 - _ZN20QPainterVideoSurface19getStaticMetaObjectEv @ 337 NONAME - _ZN20QPainterVideoSurface4stopEv @ 338 NONAME - _ZN20QPainterVideoSurface5paintEP8QPainterRK6QRectFS4_ @ 339 NONAME - _ZN20QPainterVideoSurface5startERK19QVideoSurfaceFormat @ 340 NONAME - _ZN20QPainterVideoSurface6setHueEi @ 341 NONAME - _ZN20QPainterVideoSurface7presentERK11QVideoFrame @ 342 NONAME - _ZN20QPainterVideoSurface8setReadyEb @ 343 NONAME - _ZN20QPainterVideoSurfaceC1EP7QObject @ 344 NONAME - _ZN20QPainterVideoSurfaceC2EP7QObject @ 345 NONAME - _ZN20QPainterVideoSurfaceD0Ev @ 346 NONAME - _ZN20QPainterVideoSurfaceD1Ev @ 347 NONAME - _ZN20QPainterVideoSurfaceD2Ev @ 348 NONAME - _ZN21QMediaPlaylistControl11qt_metacallEN11QMetaObject4CallEiPPv @ 349 NONAME - _ZN21QMediaPlaylistControl11qt_metacastEPKc @ 350 NONAME - _ZN21QMediaPlaylistControl16staticMetaObjectE @ 351 NONAME DATA 16 - _ZN21QMediaPlaylistControl19currentIndexChangedEi @ 352 NONAME - _ZN21QMediaPlaylistControl19currentMediaChangedERK13QMediaContent @ 353 NONAME - _ZN21QMediaPlaylistControl19getStaticMetaObjectEv @ 354 NONAME - _ZN21QMediaPlaylistControl19playbackModeChangedEN14QMediaPlaylist12PlaybackModeE @ 355 NONAME - _ZN21QMediaPlaylistControl23playlistProviderChangedEv @ 356 NONAME - _ZN21QMediaPlaylistControlC2EP7QObject @ 357 NONAME - _ZN21QMediaPlaylistControlD0Ev @ 358 NONAME - _ZN21QMediaPlaylistControlD1Ev @ 359 NONAME - _ZN21QMediaPlaylistControlD2Ev @ 360 NONAME - _ZN21QMediaServiceProvider11qt_metacallEN11QMetaObject4CallEiPPv @ 361 NONAME - _ZN21QMediaServiceProvider11qt_metacastEPKc @ 362 NONAME - _ZN21QMediaServiceProvider16staticMetaObjectE @ 363 NONAME DATA 16 - _ZN21QMediaServiceProvider17deviceDescriptionERK10QByteArrayS2_ @ 364 NONAME - _ZN21QMediaServiceProvider19getStaticMetaObjectEv @ 365 NONAME - _ZN21QMediaServiceProvider22defaultServiceProviderEv @ 366 NONAME - _ZN21QVideoRendererControl11qt_metacallEN11QMetaObject4CallEiPPv @ 367 NONAME - _ZN21QVideoRendererControl11qt_metacastEPKc @ 368 NONAME - _ZN21QVideoRendererControl16staticMetaObjectE @ 369 NONAME DATA 16 - _ZN21QVideoRendererControl19getStaticMetaObjectEv @ 370 NONAME - _ZN21QVideoRendererControlC2EP7QObject @ 371 NONAME - _ZN21QVideoRendererControlD0Ev @ 372 NONAME - _ZN21QVideoRendererControlD1Ev @ 373 NONAME - _ZN21QVideoRendererControlD2Ev @ 374 NONAME - _ZN22QMediaPlaylistIOPlugin11qt_metacallEN11QMetaObject4CallEiPPv @ 375 NONAME - _ZN22QMediaPlaylistIOPlugin11qt_metacastEPKc @ 376 NONAME - _ZN22QMediaPlaylistIOPlugin16staticMetaObjectE @ 377 NONAME DATA 16 - _ZN22QMediaPlaylistIOPlugin19getStaticMetaObjectEv @ 378 NONAME - _ZN22QMediaPlaylistIOPluginC2EP7QObject @ 379 NONAME - _ZN22QMediaPlaylistIOPluginD0Ev @ 380 NONAME - _ZN22QMediaPlaylistIOPluginD1Ev @ 381 NONAME - _ZN22QMediaPlaylistIOPluginD2Ev @ 382 NONAME - _ZN22QMediaPlaylistProvider10loadFailedEN14QMediaPlaylist5ErrorERK7QString @ 383 NONAME - _ZN22QMediaPlaylistProvider11insertMediaEiRK13QMediaContent @ 384 NONAME - _ZN22QMediaPlaylistProvider11insertMediaEiRK5QListI13QMediaContentE @ 385 NONAME - _ZN22QMediaPlaylistProvider11qt_metacallEN11QMetaObject4CallEiPPv @ 386 NONAME - _ZN22QMediaPlaylistProvider11qt_metacastEPKc @ 387 NONAME - _ZN22QMediaPlaylistProvider11removeMediaEi @ 388 NONAME - _ZN22QMediaPlaylistProvider11removeMediaEii @ 389 NONAME - _ZN22QMediaPlaylistProvider12mediaChangedEii @ 390 NONAME - _ZN22QMediaPlaylistProvider12mediaRemovedEii @ 391 NONAME - _ZN22QMediaPlaylistProvider13mediaInsertedEii @ 392 NONAME - _ZN22QMediaPlaylistProvider16staticMetaObjectE @ 393 NONAME DATA 16 - _ZN22QMediaPlaylistProvider19getStaticMetaObjectEv @ 394 NONAME - _ZN22QMediaPlaylistProvider21mediaAboutToBeRemovedEii @ 395 NONAME - _ZN22QMediaPlaylistProvider22mediaAboutToBeInsertedEii @ 396 NONAME - _ZN22QMediaPlaylistProvider4loadEP9QIODevicePKc @ 397 NONAME - _ZN22QMediaPlaylistProvider4loadERK4QUrlPKc @ 398 NONAME - _ZN22QMediaPlaylistProvider4saveEP9QIODevicePKc @ 399 NONAME - _ZN22QMediaPlaylistProvider4saveERK4QUrlPKc @ 400 NONAME - _ZN22QMediaPlaylistProvider5clearEv @ 401 NONAME - _ZN22QMediaPlaylistProvider6loadedEv @ 402 NONAME - _ZN22QMediaPlaylistProvider7shuffleEv @ 403 NONAME - _ZN22QMediaPlaylistProvider8addMediaERK13QMediaContent @ 404 NONAME - _ZN22QMediaPlaylistProvider8addMediaERK5QListI13QMediaContentE @ 405 NONAME - _ZN22QMediaPlaylistProviderC2EP7QObject @ 406 NONAME - _ZN22QMediaPlaylistProviderC2ER29QMediaPlaylistProviderPrivateP7QObject @ 407 NONAME - _ZN22QMediaPlaylistProviderD0Ev @ 408 NONAME - _ZN22QMediaPlaylistProviderD1Ev @ 409 NONAME - _ZN22QMediaPlaylistProviderD2Ev @ 410 NONAME - _ZN23QMediaPlaylistNavigator11qt_metacallEN11QMetaObject4CallEiPPv @ 411 NONAME - _ZN23QMediaPlaylistNavigator11qt_metacastEPKc @ 412 NONAME - _ZN23QMediaPlaylistNavigator11setPlaylistEP22QMediaPlaylistProvider @ 413 NONAME - _ZN23QMediaPlaylistNavigator15setPlaybackModeEN14QMediaPlaylist12PlaybackModeE @ 414 NONAME - _ZN23QMediaPlaylistNavigator16staticMetaObjectE @ 415 NONAME DATA 16 - _ZN23QMediaPlaylistNavigator19currentIndexChangedEi @ 416 NONAME - _ZN23QMediaPlaylistNavigator19getStaticMetaObjectEv @ 417 NONAME - _ZN23QMediaPlaylistNavigator19playbackModeChangedEN14QMediaPlaylist12PlaybackModeE @ 418 NONAME - _ZN23QMediaPlaylistNavigator23surroundingItemsChangedEv @ 419 NONAME - _ZN23QMediaPlaylistNavigator4jumpEi @ 420 NONAME - _ZN23QMediaPlaylistNavigator4nextEv @ 421 NONAME - _ZN23QMediaPlaylistNavigator8previousEv @ 422 NONAME - _ZN23QMediaPlaylistNavigator9activatedERK13QMediaContent @ 423 NONAME - _ZN23QMediaPlaylistNavigatorC1EP22QMediaPlaylistProviderP7QObject @ 424 NONAME - _ZN23QMediaPlaylistNavigatorC2EP22QMediaPlaylistProviderP7QObject @ 425 NONAME - _ZN23QMediaPlaylistNavigatorD0Ev @ 426 NONAME - _ZN23QMediaPlaylistNavigatorD1Ev @ 427 NONAME - _ZN23QMediaPlaylistNavigatorD2Ev @ 428 NONAME - _ZN25QMediaServiceProviderHintC1E6QFlagsINS_7FeatureEE @ 429 NONAME - _ZN25QMediaServiceProviderHintC1ERK10QByteArray @ 430 NONAME - _ZN25QMediaServiceProviderHintC1ERK7QStringRK11QStringList @ 431 NONAME - _ZN25QMediaServiceProviderHintC1ERKS_ @ 432 NONAME - _ZN25QMediaServiceProviderHintC1Ev @ 433 NONAME - _ZN25QMediaServiceProviderHintC2E6QFlagsINS_7FeatureEE @ 434 NONAME - _ZN25QMediaServiceProviderHintC2ERK10QByteArray @ 435 NONAME - _ZN25QMediaServiceProviderHintC2ERK7QStringRK11QStringList @ 436 NONAME - _ZN25QMediaServiceProviderHintC2ERKS_ @ 437 NONAME - _ZN25QMediaServiceProviderHintC2Ev @ 438 NONAME - _ZN25QMediaServiceProviderHintD1Ev @ 439 NONAME - _ZN25QMediaServiceProviderHintD2Ev @ 440 NONAME - _ZN25QMediaServiceProviderHintaSERKS_ @ 441 NONAME - _ZN27QLocalMediaPlaylistProvider11insertMediaEiRK13QMediaContent @ 442 NONAME - _ZN27QLocalMediaPlaylistProvider11insertMediaEiRK5QListI13QMediaContentE @ 443 NONAME - _ZN27QLocalMediaPlaylistProvider11qt_metacallEN11QMetaObject4CallEiPPv @ 444 NONAME - _ZN27QLocalMediaPlaylistProvider11qt_metacastEPKc @ 445 NONAME - _ZN27QLocalMediaPlaylistProvider11removeMediaEi @ 446 NONAME - _ZN27QLocalMediaPlaylistProvider11removeMediaEii @ 447 NONAME - _ZN27QLocalMediaPlaylistProvider16staticMetaObjectE @ 448 NONAME DATA 16 - _ZN27QLocalMediaPlaylistProvider19getStaticMetaObjectEv @ 449 NONAME - _ZN27QLocalMediaPlaylistProvider5clearEv @ 450 NONAME - _ZN27QLocalMediaPlaylistProvider7shuffleEv @ 451 NONAME - _ZN27QLocalMediaPlaylistProvider8addMediaERK13QMediaContent @ 452 NONAME - _ZN27QLocalMediaPlaylistProvider8addMediaERK5QListI13QMediaContentE @ 453 NONAME - _ZN27QLocalMediaPlaylistProviderC1EP7QObject @ 454 NONAME - _ZN27QLocalMediaPlaylistProviderC2EP7QObject @ 455 NONAME - _ZN27QLocalMediaPlaylistProviderD0Ev @ 456 NONAME - _ZN27QLocalMediaPlaylistProviderD1Ev @ 457 NONAME - _ZN27QLocalMediaPlaylistProviderD2Ev @ 458 NONAME - _ZN27QMediaServiceProviderPlugin11qt_metacallEN11QMetaObject4CallEiPPv @ 459 NONAME - _ZN27QMediaServiceProviderPlugin11qt_metacastEPKc @ 460 NONAME - _ZN27QMediaServiceProviderPlugin16staticMetaObjectE @ 461 NONAME DATA 16 - _ZN27QMediaServiceProviderPlugin19getStaticMetaObjectEv @ 462 NONAME - _ZNK12QMediaObject10metaObjectEv @ 463 NONAME - _ZNK12QMediaObject11isAvailableEv @ 464 NONAME - _ZNK12QMediaObject14notifyIntervalEv @ 465 NONAME - _ZNK12QMediaObject16extendedMetaDataERK7QString @ 466 NONAME - _ZNK12QMediaObject17availabilityErrorEv @ 467 NONAME - _ZNK12QMediaObject17availableMetaDataEv @ 468 NONAME - _ZNK12QMediaObject18isMetaDataWritableEv @ 469 NONAME - _ZNK12QMediaObject19isMetaDataAvailableEv @ 470 NONAME - _ZNK12QMediaObject25availableExtendedMetaDataEv @ 471 NONAME - _ZNK12QMediaObject7serviceEv @ 472 NONAME - _ZNK12QMediaObject8metaDataEN15QtMediaServices8MetaDataE @ 473 NONAME - _ZNK12QMediaPlayer10isSeekableEv @ 474 NONAME - _ZNK12QMediaPlayer10metaObjectEv @ 475 NONAME - _ZNK12QMediaPlayer11errorStringEv @ 476 NONAME - _ZNK12QMediaPlayer11mediaStatusEv @ 477 NONAME - _ZNK12QMediaPlayer11mediaStreamEv @ 478 NONAME - _ZNK12QMediaPlayer12bufferStatusEv @ 479 NONAME - _ZNK12QMediaPlayer12playbackRateEv @ 480 NONAME - _ZNK12QMediaPlayer16isAudioAvailableEv @ 481 NONAME - _ZNK12QMediaPlayer16isVideoAvailableEv @ 482 NONAME - _ZNK12QMediaPlayer5errorEv @ 483 NONAME - _ZNK12QMediaPlayer5mediaEv @ 484 NONAME - _ZNK12QMediaPlayer5stateEv @ 485 NONAME - _ZNK12QMediaPlayer6volumeEv @ 486 NONAME - _ZNK12QMediaPlayer7isMutedEv @ 487 NONAME - _ZNK12QMediaPlayer8durationEv @ 488 NONAME - _ZNK12QMediaPlayer8positionEv @ 489 NONAME - _ZNK12QSoundEffect10metaObjectEv @ 490 NONAME - _ZNK12QSoundEffect5loopsEv @ 491 NONAME - _ZNK12QSoundEffect6sourceEv @ 492 NONAME - _ZNK12QSoundEffect6volumeEv @ 493 NONAME - _ZNK12QSoundEffect7isMutedEv @ 494 NONAME - _ZNK12QVideoWidget10brightnessEv @ 495 NONAME - _ZNK12QVideoWidget10metaObjectEv @ 496 NONAME - _ZNK12QVideoWidget10saturationEv @ 497 NONAME - _ZNK12QVideoWidget11mediaObjectEv @ 498 NONAME - _ZNK12QVideoWidget15aspectRatioModeEv @ 499 NONAME - _ZNK12QVideoWidget3hueEv @ 500 NONAME - _ZNK12QVideoWidget8contrastEv @ 501 NONAME - _ZNK12QVideoWidget8sizeHintEv @ 502 NONAME - _ZNK13QMediaContent12canonicalUrlEv @ 503 NONAME - _ZNK13QMediaContent16canonicalRequestEv @ 504 NONAME - _ZNK13QMediaContent17canonicalResourceEv @ 505 NONAME - _ZNK13QMediaContent6isNullEv @ 506 NONAME - _ZNK13QMediaContent9resourcesEv @ 507 NONAME - _ZNK13QMediaContenteqERKS_ @ 508 NONAME - _ZNK13QMediaContentneERKS_ @ 509 NONAME - _ZNK13QMediaControl10metaObjectEv @ 510 NONAME - _ZNK13QMediaService10metaObjectEv @ 511 NONAME - _ZNK14QMediaPlaylist10isReadOnlyEv @ 512 NONAME - _ZNK14QMediaPlaylist10mediaCountEv @ 513 NONAME - _ZNK14QMediaPlaylist10metaObjectEv @ 514 NONAME - _ZNK14QMediaPlaylist11errorStringEv @ 515 NONAME - _ZNK14QMediaPlaylist11mediaObjectEv @ 516 NONAME - _ZNK14QMediaPlaylist12currentIndexEv @ 517 NONAME - _ZNK14QMediaPlaylist12currentMediaEv @ 518 NONAME - _ZNK14QMediaPlaylist12playbackModeEv @ 519 NONAME - _ZNK14QMediaPlaylist13previousIndexEi @ 520 NONAME - _ZNK14QMediaPlaylist5errorEv @ 521 NONAME - _ZNK14QMediaPlaylist5mediaEi @ 522 NONAME - _ZNK14QMediaPlaylist7isEmptyEv @ 523 NONAME - _ZNK14QMediaPlaylist9nextIndexEi @ 524 NONAME - _ZNK14QMediaResource10audioCodecEv @ 525 NONAME - _ZNK14QMediaResource10resolutionEv @ 526 NONAME - _ZNK14QMediaResource10sampleRateEv @ 527 NONAME - _ZNK14QMediaResource10videoCodecEv @ 528 NONAME - _ZNK14QMediaResource12audioBitRateEv @ 529 NONAME - _ZNK14QMediaResource12channelCountEv @ 530 NONAME - _ZNK14QMediaResource12videoBitRateEv @ 531 NONAME - _ZNK14QMediaResource3urlEv @ 532 NONAME - _ZNK14QMediaResource6isNullEv @ 533 NONAME - _ZNK14QMediaResource7requestEv @ 534 NONAME - _ZNK14QMediaResource8dataSizeEv @ 535 NONAME - _ZNK14QMediaResource8languageEv @ 536 NONAME - _ZNK14QMediaResource8mimeTypeEv @ 537 NONAME - _ZNK14QMediaResourceeqERKS_ @ 538 NONAME - _ZNK14QMediaResourceneERKS_ @ 539 NONAME - _ZNK15QMediaTimeRange10latestTimeEv @ 540 NONAME - _ZNK15QMediaTimeRange12earliestTimeEv @ 541 NONAME - _ZNK15QMediaTimeRange12isContinuousEv @ 542 NONAME - _ZNK15QMediaTimeRange7isEmptyEv @ 543 NONAME - _ZNK15QMediaTimeRange8containsEx @ 544 NONAME - _ZNK15QMediaTimeRange9intervalsEv @ 545 NONAME - _ZNK16QMetaDataControl10metaObjectEv @ 546 NONAME - _ZNK18QGraphicsVideoItem10metaObjectEv @ 547 NONAME - _ZNK18QGraphicsVideoItem10nativeSizeEv @ 548 NONAME - _ZNK18QGraphicsVideoItem11mediaObjectEv @ 549 NONAME - _ZNK18QGraphicsVideoItem12boundingRectEv @ 550 NONAME - _ZNK18QGraphicsVideoItem15aspectRatioModeEv @ 551 NONAME - _ZNK18QGraphicsVideoItem4sizeEv @ 552 NONAME - _ZNK18QGraphicsVideoItem6offsetEv @ 553 NONAME - _ZNK18QMediaTimeInterval10normalizedEv @ 554 NONAME - _ZNK18QMediaTimeInterval10translatedEx @ 555 NONAME - _ZNK18QMediaTimeInterval3endEv @ 556 NONAME - _ZNK18QMediaTimeInterval5startEv @ 557 NONAME - _ZNK18QMediaTimeInterval8containsEx @ 558 NONAME - _ZNK18QMediaTimeInterval8isNormalEv @ 559 NONAME - _ZNK19QMediaPlayerControl10metaObjectEv @ 560 NONAME - _ZNK19QVideoDeviceControl10metaObjectEv @ 561 NONAME - _ZNK19QVideoOutputControl10metaObjectEv @ 562 NONAME - _ZNK19QVideoWidgetControl10metaObjectEv @ 563 NONAME - _ZNK19QVideoWindowControl10metaObjectEv @ 564 NONAME - _ZNK20QPainterVideoSurface10brightnessEv @ 565 NONAME - _ZNK20QPainterVideoSurface10metaObjectEv @ 566 NONAME - _ZNK20QPainterVideoSurface10saturationEv @ 567 NONAME - _ZNK20QPainterVideoSurface17isFormatSupportedERK19QVideoSurfaceFormatPS0_ @ 568 NONAME - _ZNK20QPainterVideoSurface21supportedPixelFormatsEN20QAbstractVideoBuffer10HandleTypeE @ 569 NONAME - _ZNK20QPainterVideoSurface3hueEv @ 570 NONAME - _ZNK20QPainterVideoSurface7isReadyEv @ 571 NONAME - _ZNK20QPainterVideoSurface8contrastEv @ 572 NONAME - _ZNK21QMediaPlaylistControl10metaObjectEv @ 573 NONAME - _ZNK21QMediaServiceProvider10hasSupportERK10QByteArrayRK7QStringRK11QStringListi @ 574 NONAME - _ZNK21QMediaServiceProvider10metaObjectEv @ 575 NONAME - _ZNK21QMediaServiceProvider18supportedMimeTypesERK10QByteArrayi @ 576 NONAME - _ZNK21QMediaServiceProvider7devicesERK10QByteArray @ 577 NONAME - _ZNK21QVideoRendererControl10metaObjectEv @ 578 NONAME - _ZNK22QMediaPlaylistIOPlugin10metaObjectEv @ 579 NONAME - _ZNK22QMediaPlaylistProvider10isReadOnlyEv @ 580 NONAME - _ZNK22QMediaPlaylistProvider10metaObjectEv @ 581 NONAME - _ZNK23QMediaPlaylistNavigator10metaObjectEv @ 582 NONAME - _ZNK23QMediaPlaylistNavigator11currentItemEv @ 583 NONAME - _ZNK23QMediaPlaylistNavigator12currentIndexEv @ 584 NONAME - _ZNK23QMediaPlaylistNavigator12playbackModeEv @ 585 NONAME - _ZNK23QMediaPlaylistNavigator12previousItemEi @ 586 NONAME - _ZNK23QMediaPlaylistNavigator13previousIndexEi @ 587 NONAME - _ZNK23QMediaPlaylistNavigator6itemAtEi @ 588 NONAME - _ZNK23QMediaPlaylistNavigator8nextItemEi @ 589 NONAME - _ZNK23QMediaPlaylistNavigator8playlistEv @ 590 NONAME - _ZNK23QMediaPlaylistNavigator9nextIndexEi @ 591 NONAME - _ZNK25QMediaServiceProviderHint4typeEv @ 592 NONAME - _ZNK25QMediaServiceProviderHint6codecsEv @ 593 NONAME - _ZNK25QMediaServiceProviderHint6deviceEv @ 594 NONAME - _ZNK25QMediaServiceProviderHint6isNullEv @ 595 NONAME - _ZNK25QMediaServiceProviderHint8featuresEv @ 596 NONAME - _ZNK25QMediaServiceProviderHint8mimeTypeEv @ 597 NONAME - _ZNK25QMediaServiceProviderHinteqERKS_ @ 598 NONAME - _ZNK25QMediaServiceProviderHintneERKS_ @ 599 NONAME - _ZNK27QLocalMediaPlaylistProvider10isReadOnlyEv @ 600 NONAME - _ZNK27QLocalMediaPlaylistProvider10mediaCountEv @ 601 NONAME - _ZNK27QLocalMediaPlaylistProvider10metaObjectEv @ 602 NONAME - _ZNK27QLocalMediaPlaylistProvider5mediaEi @ 603 NONAME - _ZNK27QMediaServiceProviderPlugin10metaObjectEv @ 604 NONAME - _ZTI12QMediaObject @ 605 NONAME - _ZTI12QMediaPlayer @ 606 NONAME - _ZTI12QSoundEffect @ 607 NONAME - _ZTI12QVideoWidget @ 608 NONAME - _ZTI13QMediaControl @ 609 NONAME - _ZTI13QMediaService @ 610 NONAME - _ZTI14QMediaPlaylist @ 611 NONAME - _ZTI16QMetaDataControl @ 612 NONAME - _ZTI18QGraphicsVideoItem @ 613 NONAME - _ZTI19QMediaPlayerControl @ 614 NONAME - _ZTI19QVideoDeviceControl @ 615 NONAME - _ZTI19QVideoOutputControl @ 616 NONAME - _ZTI19QVideoWidgetControl @ 617 NONAME - _ZTI19QVideoWindowControl @ 618 NONAME - _ZTI20QMediaPlaylistReader @ 619 NONAME - _ZTI20QMediaPlaylistWriter @ 620 NONAME - _ZTI20QPainterVideoSurface @ 621 NONAME - _ZTI21QMediaPlaylistControl @ 622 NONAME - _ZTI21QMediaServiceProvider @ 623 NONAME - _ZTI21QVideoRendererControl @ 624 NONAME - _ZTI22QMediaPlaylistIOPlugin @ 625 NONAME - _ZTI22QMediaPlaylistProvider @ 626 NONAME - _ZTI23QMediaPlaylistNavigator @ 627 NONAME - _ZTI25QMediaPlaylistIOInterface @ 628 NONAME - _ZTI27QLocalMediaPlaylistProvider @ 629 NONAME - _ZTI27QMediaServiceProviderPlugin @ 630 NONAME - _ZTI37QMediaServiceProviderFactoryInterface @ 631 NONAME - _ZTV12QMediaObject @ 632 NONAME - _ZTV12QMediaPlayer @ 633 NONAME - _ZTV12QSoundEffect @ 634 NONAME - _ZTV12QVideoWidget @ 635 NONAME - _ZTV13QMediaControl @ 636 NONAME - _ZTV13QMediaService @ 637 NONAME - _ZTV14QMediaPlaylist @ 638 NONAME - _ZTV16QMetaDataControl @ 639 NONAME - _ZTV18QGraphicsVideoItem @ 640 NONAME - _ZTV19QMediaPlayerControl @ 641 NONAME - _ZTV19QVideoDeviceControl @ 642 NONAME - _ZTV19QVideoOutputControl @ 643 NONAME - _ZTV19QVideoWidgetControl @ 644 NONAME - _ZTV19QVideoWindowControl @ 645 NONAME - _ZTV20QMediaPlaylistReader @ 646 NONAME - _ZTV20QMediaPlaylistWriter @ 647 NONAME - _ZTV20QPainterVideoSurface @ 648 NONAME - _ZTV21QMediaPlaylistControl @ 649 NONAME - _ZTV21QMediaServiceProvider @ 650 NONAME - _ZTV21QVideoRendererControl @ 651 NONAME - _ZTV22QMediaPlaylistIOPlugin @ 652 NONAME - _ZTV22QMediaPlaylistProvider @ 653 NONAME - _ZTV23QMediaPlaylistNavigator @ 654 NONAME - _ZTV27QLocalMediaPlaylistProvider @ 655 NONAME - _ZTV27QMediaServiceProviderPlugin @ 656 NONAME - _ZThn8_N12QVideoWidgetD0Ev @ 657 NONAME - _ZThn8_N12QVideoWidgetD1Ev @ 658 NONAME - _ZThn8_N18QGraphicsVideoItem10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 659 NONAME - _ZThn8_N18QGraphicsVideoItem10sceneEventEP6QEvent @ 660 NONAME - _ZThn8_N18QGraphicsVideoItem5paintEP8QPainterPK24QStyleOptionGraphicsItemP7QWidget @ 661 NONAME - _ZThn8_N18QGraphicsVideoItemD0Ev @ 662 NONAME - _ZThn8_N18QGraphicsVideoItemD1Ev @ 663 NONAME - _ZThn8_N22QMediaPlaylistIOPluginD0Ev @ 664 NONAME - _ZThn8_N22QMediaPlaylistIOPluginD1Ev @ 665 NONAME - _ZThn8_NK18QGraphicsVideoItem12boundingRectEv @ 666 NONAME - _ZeqRK15QMediaTimeRangeS1_ @ 667 NONAME - _ZeqRK18QMediaTimeIntervalS1_ @ 668 NONAME - _ZmiRK15QMediaTimeRangeS1_ @ 669 NONAME - _ZneRK15QMediaTimeRangeS1_ @ 670 NONAME - _ZneRK18QMediaTimeIntervalS1_ @ 671 NONAME - _ZplRK15QMediaTimeRangeS1_ @ 672 NONAME - diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 97b2232..90c362b 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -151,21 +151,10 @@ symbian: { graphicssystems_plugins.sources += $$QT_BUILD_TREE/plugins/graphicssystems/qvggraphicssystem$${QT_LIBINFIX}.dll } - contains(QT_CONFIG, multimedia):contains(QT_CONFIG, mediaservices):contains(QT_CONFIG, media-backend) { + contains(QT_CONFIG, multimedia){ qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtMultimedia$${QT_LIBINFIX}.dll } - contains(QT_CONFIG, media-backend) { - qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtMediaServices$${QT_LIBINFIX}.dll - - contains(QT_CONFIG, audio-routing-available) { - mediaservices_plugins.path = c:$$QT_PLUGINS_BASE_DIR/mediaservices - mediaservices_plugins.sources += $$QT_BUILD_TREE/plugins/mediaservices/qmmfengine$${QT_LIBINFIX}.dll - } - - DEPLOYMENT += mediaservices_plugins - } - BLD_INF_RULES.prj_exports += "qt.iby $$CORE_MW_LAYER_IBY_EXPORT_PATH(qt.iby)" BLD_INF_RULES.prj_exports += "qtdemoapps.iby $$CUSTOMER_VARIANT_APP_LAYER_IBY_EXPORT_PATH(qtdemoapps.iby)" } diff --git a/src/src.pro b/src/src.pro index 3ceeb9c..7574796 100644 --- a/src/src.pro +++ b/src/src.pro @@ -17,7 +17,6 @@ contains(QT_CONFIG, openvg): SRC_SUBDIRS += src_openvg contains(QT_CONFIG, xmlpatterns): SRC_SUBDIRS += src_xmlpatterns contains(QT_CONFIG, phonon): SRC_SUBDIRS += src_phonon contains(QT_CONFIG, multimedia): SRC_SUBDIRS += src_multimedia -contains(QT_CONFIG, mediaservices): SRC_SUBDIRS += src_mediaservices contains(QT_CONFIG, svg): SRC_SUBDIRS += src_svg contains(QT_CONFIG, webkit) { exists($$QT_SOURCE_TREE/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro): SRC_SUBDIRS += src_javascriptcore @@ -67,10 +66,8 @@ src_qt3support.subdir = $$QT_SOURCE_TREE/src/qt3support src_qt3support.target = sub-qt3support src_phonon.subdir = $$QT_SOURCE_TREE/src/phonon src_phonon.target = sub-phonon -src_multimedia.subdir = $$QT_SOURCE_TREE/src/multimedia/multimedia +src_multimedia.subdir = $$QT_SOURCE_TREE/src/multimedia src_multimedia.target = sub-multimedia -src_mediaservices.subdir = $$QT_SOURCE_TREE/src/multimedia/mediaservices -src_mediaservices.target = sub-mediaservices src_activeqt.subdir = $$QT_SOURCE_TREE/src/activeqt src_activeqt.target = sub-activeqt src_plugins.subdir = $$QT_SOURCE_TREE/src/plugins @@ -108,7 +105,6 @@ src_declarative.target = sub-declarative src_phonon.depends = src_gui src_multimedia.depends = src_gui contains(QT_CONFIG, opengl):src_multimedia.depends += src_opengl - src_mediaservices.depends = src_multimedia src_tools_activeqt.depends = src_tools_idc src_gui src_declarative.depends = src_gui src_script src_network src_plugins.depends = src_gui src_sql src_svg src_multimedia @@ -116,7 +112,6 @@ src_declarative.target = sub-declarative src_imports.depends = src_gui src_declarative contains(QT_CONFIG, webkit) { src_webkit.depends = src_gui src_sql src_network - contains(QT_CONFIG, mediaservices):src_webkit.depends += src_mediaservices contains(QT_CONFIG, xmlpatterns): src_webkit.depends += src_xmlpatterns src_imports.depends += src_webkit exists($$QT_SOURCE_TREE/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro): src_webkit.depends += src_javascriptcore diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 12ebc75..c0004f7 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -16,7 +16,6 @@ unix:!embedded:contains(QT_CONFIG, dbus): SUBDIRS += dbus.pro contains(QT_CONFIG, script): SUBDIRS += script.pro contains(QT_CONFIG, webkit): SUBDIRS += webkit.pro contains(QT_CONFIG, multimedia): SUBDIRS += multimedia.pro -contains(QT_CONFIG, mediaservices): SUBDIRS += mediaservices.pro contains(QT_CONFIG, phonon): SUBDIRS += phonon.pro contains(QT_CONFIG, svg): SUBDIRS += svg.pro contains(QT_CONFIG, declarative): SUBDIRS += declarative.pro diff --git a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp index f910a18..82c327a 100644 --- a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp +++ b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp @@ -62,6 +62,9 @@ class tst_CompilerWarnings: public QObject private slots: void warnings_data(); void warnings(); + +private: + bool shouldIgnoreWarning(QString const&); }; #if 0 @@ -242,16 +245,37 @@ void tst_CompilerWarnings::warnings() if (!errs.isEmpty()) { errList = errs.split("\n"); qDebug() << "Arguments:" << args; - foreach (QString err, errList) { - qDebug() << err; + QStringList validErrors; + foreach (QString const& err, errList) { + bool ignore = shouldIgnoreWarning(err); + qDebug() << err << (ignore ? " [ignored]" : ""); + if (!ignore) { + validErrors << err; + } } + errList = validErrors; } QCOMPARE(errList.count(), 0); // verbose info how many lines of errors in output - QVERIFY(errs.isEmpty()); tmpQSourceFile.remove(); } +bool tst_CompilerWarnings::shouldIgnoreWarning(QString const& warning) +{ + if (warning.isEmpty()) { + return true; + } + + // icecc outputs warnings if some icecc node breaks + if (warning.startsWith("ICECC[")) { + return true; + } + + // Add more bogus warnings here + + return false; +} + QTEST_APPLESS_MAIN(tst_CompilerWarnings) #include "tst_compilerwarnings.moc" diff --git a/tests/auto/dbus.pro b/tests/auto/dbus.pro index 1c808df..e5f87e3 100644 --- a/tests/auto/dbus.pro +++ b/tests/auto/dbus.pro @@ -13,7 +13,6 @@ SUBDIRS=\ qdbuspendingreply \ qdbusperformance \ qdbusreply \ - qdbusserver \ qdbusservicewatcher \ qdbusthreading \ qdbusxmlparser \ diff --git a/tests/auto/mediaservices.pro b/tests/auto/mediaservices.pro deleted file mode 100644 index 1b50cd7..0000000 --- a/tests/auto/mediaservices.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE=subdirs -SUBDIRS=\ - qsoundeffect \ - qdeclarativeaudio \ - qdeclarativevideo \ - qgraphicsvideoitem \ - qmediacontent \ - qmediaobject \ - qmediaplayer \ - qmediaplaylist \ - qmediaplaylistnavigator \ - qmediapluginloader \ - qmediaresource \ - qmediaservice \ - qmediaserviceprovider \ - qmediatimerange \ - qvideowidget - - diff --git a/tests/auto/qdbusserver/.gitignore b/tests/auto/qdbusserver/.gitignore deleted file mode 100644 index 33a9be2..0000000 --- a/tests/auto/qdbusserver/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qdbusserver diff --git a/tests/auto/qdbusserver/qdbusserver.pro b/tests/auto/qdbusserver/qdbusserver.pro deleted file mode 100644 index 05a4eb8..0000000 --- a/tests/auto/qdbusserver/qdbusserver.pro +++ /dev/null @@ -1,11 +0,0 @@ -load(qttest_p4) -QT = core - -contains(QT_CONFIG,dbus): { - SOURCES += tst_qdbusserver.cpp - QT += dbus -} else { - SOURCES += ../qdbusmarshall/dummy.cpp -} - - diff --git a/tests/auto/qdbusserver/tst_qdbusserver.cpp b/tests/auto/qdbusserver/tst_qdbusserver.cpp deleted file mode 100644 index f0da02a..0000000 --- a/tests/auto/qdbusserver/tst_qdbusserver.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <qcoreapplication.h> -#include <qdebug.h> - -#include <QtTest/QtTest> -#include <QtDBus/QtDBus> - -static const QString bus = "unix:path=/tmp/qdbus-test"; -static const QString service = "com.trolltech.Qt.Autotests.QDBusServer"; -static const QString path = "/com/trolltech/test"; - -class tst_QDBusServer : public QObject -{ - Q_OBJECT - - void connectToServer(); - void callMethod(); -private slots: -}; - -void tst_QDBusServer::connectToServer() -{ - QDBusConnection connection = QDBusConnection::connectToBus(bus, "test-connection"); - QTest::qWait(100); - QVERIFY(connection.isConnected()); -} - -void tst_QDBusServer::callMethod() -{ - QDBusConnection connection = QDBusConnection::connectToBus(bus, "test-connection"); - QTest::qWait(100); - QVERIFY(connection.isConnected()); - //QDBusMessage msg = QDBusMessage::createMethodCall(bus, path, /*service*/"", "method"); - //QDBusMessage reply = connection.call(msg, QDBus::Block); -} - -QTEST_MAIN(tst_QDBusServer) - -#include "tst_qdbusserver.moc" diff --git a/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro b/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro deleted file mode 100644 index ecfe299..0000000 --- a/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro +++ /dev/null @@ -1,14 +0,0 @@ -load(qttest_p4) - -HEADERS += \ - $$PWD/../../../src/imports/multimedia/qdeclarativeaudio_p.h \ - $$PWD/../../../src/imports/multimedia/qdeclarativemediabase_p.h \ - $$PWD/../../../src/imports/multimedia/qmetadatacontrolmetaobject_p.h - -SOURCES += \ - tst_qdeclarativeaudio.cpp \ - $$PWD/../../../src/imports/multimedia/qdeclarativeaudio.cpp \ - $$PWD/../../../src/imports/multimedia/qdeclarativemediabase.cpp \ - $$PWD/../../../src/imports/multimedia/qmetadatacontrolmetaobject.cpp - -QT += mediaservices declarative diff --git a/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp b/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp deleted file mode 100644 index e393599..0000000 --- a/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp +++ /dev/null @@ -1,1252 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> - -#include "../../../src/imports/multimedia/qdeclarativeaudio_p.h" - -#include <QtGui/qapplication.h> -#include <QtMediaServices/qmediaplayercontrol.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmetadatacontrol.h> - - -class tst_QDeclarativeAudio : public QObject -{ - Q_OBJECT -public slots: - void initTestCase(); - -private slots: - void nullPlayerControl(); - void nullMetaDataControl(); - void nullService(); - - void source(); - void autoLoad(); - void playing(); - void paused(); - void duration(); - void position(); - void volume(); - void muted(); - void bufferProgress(); - void seekable(); - void playbackRate(); - void status(); - void metaData_data(); - void metaData(); - void error(); -}; - -Q_DECLARE_METATYPE(QtMediaServices::MetaData); -Q_DECLARE_METATYPE(QDeclarativeAudio::Error); - -class QtTestMediaPlayerControl : public QMediaPlayerControl -{ - Q_OBJECT -public: - QtTestMediaPlayerControl(QObject *parent = 0) - : QMediaPlayerControl(parent) - , m_state(QMediaPlayer::StoppedState) - , m_mediaStatus(QMediaPlayer::NoMedia) - , m_duration(0) - , m_position(0) - , m_playbackRate(1.0) - , m_volume(50) - , m_bufferStatus(0) - , m_muted(false) - , m_audioAvailable(false) - , m_videoAvailable(false) - , m_seekable(false) - { - } - - QMediaPlayer::State state() const { return m_state; } - void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); } - - QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; } - void updateMediaStatus(QMediaPlayer::MediaStatus status) { - emit mediaStatusChanged(m_mediaStatus = status); } - void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state) - { - m_mediaStatus = status; - m_state = state; - - emit mediaStatusChanged(m_mediaStatus); - emit stateChanged(m_state); - } - - qint64 duration() const { return m_duration; } - void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); } - - qint64 position() const { return m_position; } - void setPosition(qint64 position) { emit positionChanged(m_position = position); } - - int volume() const { return m_volume; } - void setVolume(int volume) { emit volumeChanged(m_volume = volume); } - - bool isMuted() const { return m_muted; } - void setMuted(bool muted) { emit mutedChanged(m_muted = muted); } - - int bufferStatus() const { return m_bufferStatus; } - void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); } - - bool isAudioAvailable() const { return m_audioAvailable; } - void setAudioAvailable(bool available) { - emit audioAvailableChanged(m_audioAvailable = available); } - bool isVideoAvailable() const { return m_videoAvailable; } - void setVideoAvailable(bool available) { - emit videoAvailableChanged(m_videoAvailable = available); } - - bool isSeekable() const { return m_seekable; } - void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); } - - QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); } - - qreal playbackRate() const { return m_playbackRate; } - void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); } - - QMediaContent media() const { return m_media; } - const QIODevice *mediaStream() const { return 0; } - void setMedia(const QMediaContent &media, QIODevice *) - { - m_media = media; - - m_mediaStatus = m_media.isNull() - ? QMediaPlayer::NoMedia - : QMediaPlayer::LoadingMedia; - - emit mediaChanged(m_media); - emit mediaStatusChanged(m_mediaStatus); - } - - void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); } - void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); } - void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); } - - void emitError(QMediaPlayer::Error err, const QString &errorString) { - emit error(err, errorString); } - -private: - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_mediaStatus; - qint64 m_duration; - qint64 m_position; - qreal m_playbackRate; - int m_volume; - int m_bufferStatus; - bool m_muted; - bool m_audioAvailable; - bool m_videoAvailable; - bool m_seekable; - QMediaContent m_media; -}; - -class QtTestMetaDataControl : public QMetaDataControl -{ - Q_OBJECT -public: - QtTestMetaDataControl(QObject *parent = 0) - : QMetaDataControl(parent) - { - } - - bool isWritable() const { return true; } - bool isMetaDataAvailable() const { return true; } - - QVariant metaData(QtMediaServices::MetaData key) const { return m_metaData.value(key); } - void setMetaData(QtMediaServices::MetaData key, const QVariant &value) { - m_metaData.insert(key, value); emit metaDataChanged(); } - void setMetaData(const QMap<QtMediaServices::MetaData, QVariant> &metaData) { - m_metaData = metaData; emit metaDataChanged(); } - - QList<QtMediaServices::MetaData> availableMetaData() const { return m_metaData.keys(); } - - QVariant extendedMetaData(const QString &) const { return QVariant(); } - void setExtendedMetaData(const QString &, const QVariant &) {} - QStringList availableExtendedMetaData() const { return QStringList(); } - -private: - QMap<QtMediaServices::MetaData, QVariant> m_metaData; -}; - -class QtTestMediaService : public QMediaService -{ - Q_OBJECT -public: - QtTestMediaService( - QtTestMediaPlayerControl *playerControl, - QtTestMetaDataControl *metaDataControl, - QObject *parent) - : QMediaService(parent) - , playerControl(playerControl) - , metaDataControl(metaDataControl) - { - } - - QMediaControl *control(const char *name) const - { - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) - return playerControl; - else if (qstrcmp(name, QMetaDataControl_iid) == 0) - return metaDataControl; - else - return 0; - } - - QtTestMediaPlayerControl *playerControl; - QtTestMetaDataControl *metaDataControl; -}; - -class QtTestMediaServiceProvider : public QMediaServiceProvider -{ - Q_OBJECT -public: - QtTestMediaServiceProvider() - : service(new QtTestMediaService( - new QtTestMediaPlayerControl(this), new QtTestMetaDataControl(this), this)) - { - setDefaultServiceProvider(this); - } - - QtTestMediaServiceProvider(QtTestMediaService *service) - : service(service) - { - setDefaultServiceProvider(this); - } - - QtTestMediaServiceProvider( - QtTestMediaPlayerControl *playerControl, QtTestMetaDataControl *metaDataControl) - : service(new QtTestMediaService(playerControl, metaDataControl, this)) - { - setDefaultServiceProvider(this); - } - - ~QtTestMediaServiceProvider() - { - setDefaultServiceProvider(0); - } - - QMediaService *requestService( - const QByteArray &type, - const QMediaServiceProviderHint & = QMediaServiceProviderHint()) - { - requestedService = type; - - return service; - } - - void releaseService(QMediaService *) {} - - inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; } - inline QtTestMetaDataControl *metaDataControl() { return service->metaDataControl; } - - QtTestMediaService *service; - QByteArray requestedService; -}; - - -void tst_QDeclarativeAudio::initTestCase() -{ - qRegisterMetaType<QDeclarativeAudio::Error>(); -} - -void tst_QDeclarativeAudio::nullPlayerControl() -{ - QtTestMetaDataControl metaDataControl; - QtTestMediaServiceProvider provider(0, &metaDataControl); - - QDeclarativeAudio audio; - - QCOMPARE(audio.source(), QUrl()); - audio.setSource(QUrl("http://example.com")); - QCOMPARE(audio.source(), QUrl("http://example.com")); - - QCOMPARE(audio.isPlaying(), false); - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - audio.setPlaying(false); - audio.play(); - QCOMPARE(audio.isPlaying(), false); - - QCOMPARE(audio.isPaused(), false); - audio.pause(); - QCOMPARE(audio.isPaused(), false); - audio.setPaused(true); - QCOMPARE(audio.isPaused(), true); - - QCOMPARE(audio.duration(), 0); - - QCOMPARE(audio.position(), 0); - audio.setPosition(10000); - QCOMPARE(audio.position(), 10000); - - QCOMPARE(audio.volume(), qreal(1.0)); - audio.setVolume(0.5); - QCOMPARE(audio.volume(), qreal(0.5)); - - QCOMPARE(audio.isMuted(), false); - audio.setMuted(true); - QCOMPARE(audio.isMuted(), true); - - QCOMPARE(audio.bufferProgress(), qreal(0)); - - QCOMPARE(audio.isSeekable(), false); - - QCOMPARE(audio.playbackRate(), qreal(1.0)); - - QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia); - - QCOMPARE(audio.error(), QDeclarativeAudio::ServiceMissing); -} - -void tst_QDeclarativeAudio::nullMetaDataControl() -{ - QtTestMediaPlayerControl playerControl; - QtTestMediaServiceProvider provider(&playerControl, 0); - - QDeclarativeAudio audio; - - QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1); - QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1); - QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1); -} - -void tst_QDeclarativeAudio::nullService() -{ - QtTestMediaServiceProvider provider(0); - - QDeclarativeAudio audio; - - QCOMPARE(audio.source(), QUrl()); - audio.setSource(QUrl("http://example.com")); - QCOMPARE(audio.source(), QUrl("http://example.com")); - - QCOMPARE(audio.isPlaying(), false); - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - audio.setPlaying(false); - audio.play(); - QCOMPARE(audio.isPlaying(), false); - - QCOMPARE(audio.isPaused(), false); - audio.pause(); - QCOMPARE(audio.isPaused(), false); - audio.setPaused(true); - QCOMPARE(audio.isPaused(), true); - - QCOMPARE(audio.duration(), 0); - - QCOMPARE(audio.position(), 0); - audio.setPosition(10000); - QCOMPARE(audio.position(), 10000); - - QCOMPARE(audio.volume(), qreal(1.0)); - audio.setVolume(0.5); - QCOMPARE(audio.volume(), qreal(0.5)); - - QCOMPARE(audio.isMuted(), false); - audio.setMuted(true); - QCOMPARE(audio.isMuted(), true); - - QCOMPARE(audio.bufferProgress(), qreal(0)); - - QCOMPARE(audio.isSeekable(), false); - - QCOMPARE(audio.playbackRate(), qreal(1.0)); - - QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia); - - QCOMPARE(audio.error(), QDeclarativeAudio::ServiceMissing); - - QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1); - QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1); - QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1); -} - -void tst_QDeclarativeAudio::source() -{ - const QUrl url1("http://example.com"); - const QUrl url2("file:///local/path"); - const QUrl url3; - - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(sourceChanged())); - - audio.setSource(url1); - QCOMPARE(audio.source(), url1); - QCOMPARE(provider.playerControl()->media().canonicalUrl(), url1); - QCOMPARE(spy.count(), 1); - - audio.setSource(url2); - QCOMPARE(audio.source(), url2); - QCOMPARE(provider.playerControl()->media().canonicalUrl(), url2); - QCOMPARE(spy.count(), 2); - - audio.setSource(url3); - QCOMPARE(audio.source(), url3); - QCOMPARE(provider.playerControl()->media().canonicalUrl(), url3); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeAudio::autoLoad() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(autoLoadChanged())); - - QCOMPARE(audio.isAutoLoad(), true); - - audio.setAutoLoad(false); - QCOMPARE(audio.isAutoLoad(), false); - QCOMPARE(spy.count(), 1); - - audio.setSource(QUrl("http://example.com")); - QCOMPARE(audio.source(), QUrl("http://example.com")); - audio.play(); - QCOMPARE(audio.isPlaying(), true); - audio.stop(); - - audio.setAutoLoad(true); - audio.setSource(QUrl("http://example.com")); - audio.setPaused(true); - QCOMPARE(spy.count(), 2); - QCOMPARE(audio.isPaused(), true); -} - -void tst_QDeclarativeAudio::playing() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - QSignalSpy playingChangedSpy(&audio, SIGNAL(playingChanged())); - QSignalSpy startedSpy(&audio, SIGNAL(started())); - QSignalSpy stoppedSpy(&audio, SIGNAL(stopped())); - - int playingChanged = 0; - int started = 0; - int stopped = 0; - - audio.componentComplete(); - - QCOMPARE(audio.isPlaying(), false); - - // setPlaying(true) when stopped. - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when playing. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // play() when stopped. - audio.play(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when playing. - audio.stop(); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // stop() when stopped. - audio.stop(); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when stopped. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(true) when playing. - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - // play() when playing. - audio.play(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); -} - -void tst_QDeclarativeAudio::paused() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - QSignalSpy playingChangedSpy(&audio, SIGNAL(playingChanged())); - QSignalSpy pausedChangedSpy(&audio, SIGNAL(pausedChanged())); - QSignalSpy startedSpy(&audio, SIGNAL(started())); - QSignalSpy pausedSpy(&audio, SIGNAL(paused())); - QSignalSpy resumedSpy(&audio, SIGNAL(resumed())); - QSignalSpy stoppedSpy(&audio, SIGNAL(stopped())); - - int playingChanged = 0; - int pausedChanged = 0; - int started = 0; - int paused = 0; - int resumed = 0; - int stopped = 0; - - audio.componentComplete(); - - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), false); - - // setPlaying(true) when stopped. - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when playing. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when paused. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when paused. - audio.pause(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when paused. - audio.setPaused(false); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), ++resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when playing. - audio.setPaused(false); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when playing. - audio.pause(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // setPaused(true) when stopped and paused. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when stopped and paused. - audio.setPaused(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when stopped. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(true) when stopped and paused. - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // play() when paused. - audio.play(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), ++resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when playing. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when paused. - audio.stop(); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // setPaused(true) when stopped. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when stopped and paused. - audio.stop(); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when stopped. - audio.pause(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // pause() when stopped and paused. - audio.pause(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // play() when stopped and paused. - audio.play(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); -} - -void tst_QDeclarativeAudio::duration() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(durationChanged())); - - QCOMPARE(audio.duration(), 0); - - provider.playerControl()->setDuration(4040); - QCOMPARE(audio.duration(), 4040); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setDuration(-129); - QCOMPARE(audio.duration(), -129); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setDuration(0); - QCOMPARE(audio.duration(), 0); - QCOMPARE(spy.count(), 3); - - // Unnecessary duration changed signals aren't filtered. - provider.playerControl()->setDuration(0); - QCOMPARE(audio.duration(), 0); - QCOMPARE(spy.count(), 4); -} - -void tst_QDeclarativeAudio::position() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(positionChanged())); - - QCOMPARE(audio.position(), 0); - - // QDeclarativeAudio won't bound set positions to the duration. A media service may though. - QCOMPARE(audio.duration(), 0); - - audio.setPosition(450); - QCOMPARE(audio.position(), 450); - QCOMPARE(provider.playerControl()->position(), qint64(450)); - QCOMPARE(spy.count(), 1); - - audio.setPosition(-5403); - QCOMPARE(audio.position(), -5403); - QCOMPARE(provider.playerControl()->position(), qint64(-5403)); - QCOMPARE(spy.count(), 2); - - audio.setPosition(-5403); - QCOMPARE(audio.position(), -5403); - QCOMPARE(provider.playerControl()->position(), qint64(-5403)); - QCOMPARE(spy.count(), 2); - - // Check the signal change signal is emitted if the change originates from the media service. - provider.playerControl()->setPosition(0); - QCOMPARE(audio.position(), 0); - QCOMPARE(spy.count(), 3); - - connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop())); - - provider.playerControl()->updateState(QMediaPlayer::PlayingState); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5 - - provider.playerControl()->updateState(QMediaPlayer::PausedState); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(spy.count() < 6); -} - -void tst_QDeclarativeAudio::volume() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(volumeChanged())); - - QCOMPARE(audio.volume(), qreal(1.0)); - - audio.setVolume(0.7); - QCOMPARE(audio.volume(), qreal(0.7)); - QCOMPARE(provider.playerControl()->volume(), 70); - QCOMPARE(spy.count(), 1); - - audio.setVolume(0.7); - QCOMPARE(audio.volume(), qreal(0.7)); - QCOMPARE(provider.playerControl()->volume(), 70); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setVolume(30); - QCOMPARE(audio.volume(), qreal(0.3)); - QCOMPARE(spy.count(), 2); -} - -void tst_QDeclarativeAudio::muted() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(mutedChanged())); - - QCOMPARE(audio.isMuted(), false); - - audio.setMuted(true); - QCOMPARE(audio.isMuted(), true); - QCOMPARE(provider.playerControl()->isMuted(), true); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setMuted(false); - QCOMPARE(audio.isMuted(), false); - QCOMPARE(spy.count(), 2); - - audio.setMuted(false); - QCOMPARE(audio.isMuted(), false); - QCOMPARE(provider.playerControl()->isMuted(), false); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeAudio::bufferProgress() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(bufferProgressChanged())); - - QCOMPARE(audio.bufferProgress(), qreal(0.0)); - - provider.playerControl()->setBufferStatus(20); - QCOMPARE(audio.bufferProgress(), qreal(0.2)); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setBufferStatus(20); - QCOMPARE(audio.bufferProgress(), qreal(0.2)); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setBufferStatus(40); - QCOMPARE(audio.bufferProgress(), qreal(0.4)); - QCOMPARE(spy.count(), 3); - - connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop())); - - provider.playerControl()->updateMediaStatus( - QMediaPlayer::BufferingMedia, QMediaPlayer::PlayingState); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5 - - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(spy.count() < 6); -} - -void tst_QDeclarativeAudio::seekable() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(seekableChanged())); - - QCOMPARE(audio.isSeekable(), false); - - provider.playerControl()->setSeekable(true); - QCOMPARE(audio.isSeekable(), true); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setSeekable(true); - QCOMPARE(audio.isSeekable(), true); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setSeekable(false); - QCOMPARE(audio.isSeekable(), false); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeAudio::playbackRate() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(playbackRateChanged())); - - QCOMPARE(audio.playbackRate(), qreal(1.0)); - - audio.setPlaybackRate(0.5); - QCOMPARE(audio.playbackRate(), qreal(0.5)); - QCOMPARE(provider.playerControl()->playbackRate(), qreal(0.5)); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setPlaybackRate(2.0); - QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0)); - QCOMPARE(spy.count(), 2); - - audio.setPlaybackRate(2.0); - QCOMPARE(audio.playbackRate(), qreal(2.0)); - QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0)); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeAudio::status() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy statusChangedSpy(&audio, SIGNAL(statusChanged())); - QSignalSpy loadedSpy(&audio, SIGNAL(loaded())); - QSignalSpy bufferingSpy(&audio, SIGNAL(buffering())); - QSignalSpy stalledSpy(&audio, SIGNAL(stalled())); - QSignalSpy bufferedSpy(&audio, SIGNAL(buffered())); - QSignalSpy endOfMediaSpy(&audio, SIGNAL(endOfMedia())); - - QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia); - - // Set media, start loading. - provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadingMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Loading); - QCOMPARE(statusChangedSpy.count(), 1); - QCOMPARE(loadedSpy.count(), 0); - QCOMPARE(bufferingSpy.count(), 0); - QCOMPARE(stalledSpy.count(), 0); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Finish loading. - provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadedMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Loaded); - QCOMPARE(statusChangedSpy.count(), 2); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 0); - QCOMPARE(stalledSpy.count(), 0); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Play, start buffering. - provider.playerControl()->updateMediaStatus( - QMediaPlayer::StalledMedia, QMediaPlayer::PlayingState); - QCOMPARE(audio.status(), QDeclarativeAudio::Stalled); - QCOMPARE(statusChangedSpy.count(), 3); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 0); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Enough data buffered to proceed. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffering); - QCOMPARE(statusChangedSpy.count(), 4); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 1); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Errant second buffering status changed. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffering); - QCOMPARE(statusChangedSpy.count(), 4); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 1); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Buffer full. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffered); - QCOMPARE(statusChangedSpy.count(), 5); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 1); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 1); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Buffer getting low. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffering); - QCOMPARE(statusChangedSpy.count(), 6); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 2); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 1); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Buffer full. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffered); - QCOMPARE(statusChangedSpy.count(), 7); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 2); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 2); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Finished. - provider.playerControl()->updateMediaStatus( - QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState); - QCOMPARE(audio.status(), QDeclarativeAudio::EndOfMedia); - QCOMPARE(statusChangedSpy.count(), 8); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 2); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 2); - QCOMPARE(endOfMediaSpy.count(), 1); -} - -void tst_QDeclarativeAudio::metaData_data() -{ - QTest::addColumn<QByteArray>("propertyName"); - QTest::addColumn<QtMediaServices::MetaData>("propertyKey"); - QTest::addColumn<QVariant>("value1"); - QTest::addColumn<QVariant>("value2"); - - QTest::newRow("title") - << QByteArray("title") - << QtMediaServices::Title - << QVariant(QString::fromLatin1("This is a title")) - << QVariant(QString::fromLatin1("This is another title")); - - QTest::newRow("genre") - << QByteArray("genre") - << QtMediaServices::Genre - << QVariant(QString::fromLatin1("rock")) - << QVariant(QString::fromLatin1("pop")); - - QTest::newRow("trackNumber") - << QByteArray("trackNumber") - << QtMediaServices::TrackNumber - << QVariant(8) - << QVariant(12); -} - -void tst_QDeclarativeAudio::metaData() -{ - QFETCH(QByteArray, propertyName); - QFETCH(QtMediaServices::MetaData, propertyKey); - QFETCH(QVariant, value1); - QFETCH(QVariant, value2); - - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(__metaDataChanged())); - - const int index = audio.metaObject()->indexOfProperty(propertyName.constData()); - QVERIFY(index != -1); - - QMetaProperty property = audio.metaObject()->property(index); - QCOMPARE(property.read(&audio), QVariant()); - - property.write(&audio, value1); - QCOMPARE(property.read(&audio), value1); - QCOMPARE(provider.metaDataControl()->metaData(propertyKey), value1); - QCOMPARE(spy.count(), 1); - - provider.metaDataControl()->setMetaData(propertyKey, value2); - QCOMPARE(property.read(&audio), value2); - QCOMPARE(spy.count(), 2); -} - -void tst_QDeclarativeAudio::error() -{ - const QString errorString = QLatin1String("Failed to open device."); - - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy errorSpy(&audio, SIGNAL(error(QDeclarativeAudio::Error,QString))); - QSignalSpy errorChangedSpy(&audio, SIGNAL(errorChanged())); - - QCOMPARE(audio.error(), QDeclarativeAudio::NoError); - QCOMPARE(audio.errorString(), QString()); - - provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString); - - QCOMPARE(audio.error(), QDeclarativeAudio::ResourceError); - QCOMPARE(audio.errorString(), errorString); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 1); - - // Changing the source resets the error properties. - audio.setSource(QUrl("http://example.com")); - QCOMPARE(audio.error(), QDeclarativeAudio::NoError); - QCOMPARE(audio.errorString(), QString()); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 2); - - // But isn't noisy. - audio.setSource(QUrl("file:///file/path")); - QCOMPARE(audio.error(), QDeclarativeAudio::NoError); - QCOMPARE(audio.errorString(), QString()); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 2); -} - - -QTEST_MAIN(tst_QDeclarativeAudio) - -#include "tst_qdeclarativeaudio.moc" diff --git a/tests/auto/qdeclarativevideo/qdeclarativevideo.pro b/tests/auto/qdeclarativevideo/qdeclarativevideo.pro deleted file mode 100644 index 64a20da..0000000 --- a/tests/auto/qdeclarativevideo/qdeclarativevideo.pro +++ /dev/null @@ -1,14 +0,0 @@ -load(qttest_p4) - -HEADERS += \ - $$PWD/../../../src/imports/multimedia/qdeclarativevideo_p.h \ - $$PWD/../../../src/imports/multimedia/qdeclarativemediabase_p.h \ - $$PWD/../../../src/imports/multimedia/qmetadatacontrolmetaobject_p.h - -SOURCES += \ - tst_qdeclarativevideo.cpp \ - $$PWD/../../../src/imports/multimedia/qdeclarativevideo.cpp \ - $$PWD/../../../src/imports/multimedia/qdeclarativemediabase.cpp \ - $$PWD/../../../src/imports/multimedia/qmetadatacontrolmetaobject.cpp - -QT += multimedia mediaservices declarative diff --git a/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp b/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp deleted file mode 100644 index 99b447a..0000000 --- a/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp +++ /dev/null @@ -1,921 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> - -#include "../../../src/imports/multimedia/qdeclarativevideo_p.h" - -#include <QtGui/qapplication.h> -#include <QtMultimedia/qabstractvideosurface.h> -#include <QtMediaServices/qgraphicsvideoitem.h> -#include <QtMediaServices/qmediaplayercontrol.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qvideooutputcontrol.h> -#include <QtMediaServices/qvideorenderercontrol.h> -#include <QtMultimedia/qvideosurfaceformat.h> - - -class tst_QDeclarativeVideo : public QObject -{ - Q_OBJECT -public slots: - void initTestCase(); - -private slots: - void nullPlayerControl(); - void nullService(); - - void playing(); - void paused(); - void error(); - - void hasAudio(); - void hasVideo(); - void fillMode(); - void geometry(); -}; - -Q_DECLARE_METATYPE(QtMediaServices::MetaData); -Q_DECLARE_METATYPE(QDeclarativeVideo::Error); - -class QtTestMediaPlayerControl : public QMediaPlayerControl -{ - Q_OBJECT -public: - QtTestMediaPlayerControl(QObject *parent = 0) - : QMediaPlayerControl(parent) - , m_state(QMediaPlayer::StoppedState) - , m_mediaStatus(QMediaPlayer::NoMedia) - , m_duration(0) - , m_position(0) - , m_playbackRate(1.0) - , m_volume(50) - , m_bufferStatus(0) - , m_muted(false) - , m_audioAvailable(false) - , m_videoAvailable(false) - , m_seekable(false) - { - } - - QMediaPlayer::State state() const { return m_state; } - void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); } - - QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; } - void updateMediaStatus(QMediaPlayer::MediaStatus status) { - emit mediaStatusChanged(m_mediaStatus = status); } - void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state) - { - m_mediaStatus = status; - m_state = state; - - emit mediaStatusChanged(m_mediaStatus); - emit stateChanged(m_state); - } - - qint64 duration() const { return m_duration; } - void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); } - - qint64 position() const { return m_position; } - void setPosition(qint64 position) { emit positionChanged(m_position = position); } - - int volume() const { return m_volume; } - void setVolume(int volume) { emit volumeChanged(m_volume = volume); } - - bool isMuted() const { return m_muted; } - void setMuted(bool muted) { emit mutedChanged(m_muted = muted); } - - int bufferStatus() const { return m_bufferStatus; } - void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); } - - bool isAudioAvailable() const { return m_audioAvailable; } - void setAudioAvailable(bool available) { - emit audioAvailableChanged(m_audioAvailable = available); } - bool isVideoAvailable() const { return m_videoAvailable; } - void setVideoAvailable(bool available) { - emit videoAvailableChanged(m_videoAvailable = available); } - - bool isSeekable() const { return m_seekable; } - void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); } - - QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); } - - qreal playbackRate() const { return m_playbackRate; } - void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); } - - QMediaContent media() const { return m_media; } - const QIODevice *mediaStream() const { return 0; } - void setMedia(const QMediaContent &media, QIODevice *) - { - m_media = media; - - m_mediaStatus = m_media.isNull() - ? QMediaPlayer::NoMedia - : QMediaPlayer::LoadingMedia; - - emit mediaChanged(m_media); - emit mediaStatusChanged(m_mediaStatus); - } - - void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); } - void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); } - void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); } - - void emitError(QMediaPlayer::Error err, const QString &errorString) { - emit error(err, errorString); } - -private: - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_mediaStatus; - qint64 m_duration; - qint64 m_position; - qreal m_playbackRate; - int m_volume; - int m_bufferStatus; - bool m_muted; - bool m_audioAvailable; - bool m_videoAvailable; - bool m_seekable; - QMediaContent m_media; -}; - -class QtTestOutputControl : public QVideoOutputControl -{ -public: - QtTestOutputControl(QObject *parent) : QVideoOutputControl(parent), m_output(NoOutput) {} - - QList<Output> availableOutputs() const { return m_outputs; } - void setAvailableOutputs(const QList<Output> outputs) { m_outputs = outputs; } - - Output output() const { return m_output; } - virtual void setOutput(Output output) { m_output = output; } - -private: - Output m_output; - QList<Output> m_outputs; -}; - -class QtTestRendererControl : public QVideoRendererControl -{ -public: - QtTestRendererControl(QObject *parent ) : QVideoRendererControl(parent), m_surface(0) {} - - QAbstractVideoSurface *surface() const { return m_surface; } - void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; } - -private: - QAbstractVideoSurface *m_surface; -}; - -class QtTestMediaService : public QMediaService -{ - Q_OBJECT -public: - QtTestMediaService( - QtTestMediaPlayerControl *playerControl, - QtTestOutputControl *outputControl, - QtTestRendererControl *rendererControl, - QObject *parent) - : QMediaService(parent) - , playerControl(playerControl) - , outputControl(outputControl) - , rendererControl(rendererControl) - { - } - - QMediaControl *control(const char *name) const - { - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) - return playerControl; - else if (qstrcmp(name, QVideoOutputControl_iid) == 0) - return outputControl; - else if (qstrcmp(name, QVideoRendererControl_iid) == 0) - return rendererControl; - else - return 0; - } - - QtTestMediaPlayerControl *playerControl; - QtTestOutputControl *outputControl; - QtTestRendererControl *rendererControl; -}; - -class QtTestMediaServiceProvider : public QMediaServiceProvider -{ - Q_OBJECT -public: - QtTestMediaServiceProvider() - : service(new QtTestMediaService( - new QtTestMediaPlayerControl(this), - new QtTestOutputControl(this), - new QtTestRendererControl(this), - this)) - { - setDefaultServiceProvider(this); - } - - QtTestMediaServiceProvider(QtTestMediaService *service) - : service(service) - { - setDefaultServiceProvider(this); - } - - QtTestMediaServiceProvider( - QtTestMediaPlayerControl *playerControl, - QtTestOutputControl *outputControl, - QtTestRendererControl *rendererControl) - : service(new QtTestMediaService(playerControl, outputControl, rendererControl, this)) - { - setDefaultServiceProvider(this); - } - - ~QtTestMediaServiceProvider() - { - setDefaultServiceProvider(0); - } - - QMediaService *requestService( - const QByteArray &type, - const QMediaServiceProviderHint & = QMediaServiceProviderHint()) - { - requestedService = type; - - return service; - } - - void releaseService(QMediaService *) {} - - inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; } - inline QtTestRendererControl *rendererControl() { return service->rendererControl; } - - QtTestMediaService *service; - QByteArray requestedService; -}; - - -void tst_QDeclarativeVideo::initTestCase() -{ - qRegisterMetaType<QDeclarativeVideo::Error>(); -} - -void tst_QDeclarativeVideo::nullPlayerControl() -{ - QtTestMediaServiceProvider provider(0, 0, 0); - - QDeclarativeVideo video; - - QCOMPARE(video.source(), QUrl()); - video.setSource(QUrl("http://example.com")); - QCOMPARE(video.source(), QUrl("http://example.com")); - - QCOMPARE(video.isPlaying(), false); - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - video.setPlaying(false); - video.play(); - QCOMPARE(video.isPlaying(), false); - - QCOMPARE(video.isPaused(), false); - video.pause(); - QCOMPARE(video.isPaused(), false); - video.setPaused(true); - QCOMPARE(video.isPaused(), true); - - QCOMPARE(video.duration(), 0); - - QCOMPARE(video.position(), 0); - video.setPosition(10000); - QCOMPARE(video.position(), 10000); - - QCOMPARE(video.volume(), qreal(1.0)); - video.setVolume(0.5); - QCOMPARE(video.volume(), qreal(0.5)); - - QCOMPARE(video.isMuted(), false); - video.setMuted(true); - QCOMPARE(video.isMuted(), true); - - QCOMPARE(video.bufferProgress(), qreal(0)); - - QCOMPARE(video.isSeekable(), false); - - QCOMPARE(video.playbackRate(), qreal(1.0)); - - QCOMPARE(video.hasAudio(), false); - QCOMPARE(video.hasVideo(), false); - - QCOMPARE(video.status(), QDeclarativeVideo::NoMedia); - - QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing); -} - -void tst_QDeclarativeVideo::nullService() -{ - QtTestMediaServiceProvider provider(0); - - QDeclarativeVideo video; - - QCOMPARE(video.source(), QUrl()); - video.setSource(QUrl("http://example.com")); - QCOMPARE(video.source(), QUrl("http://example.com")); - - QCOMPARE(video.isPlaying(), false); - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - video.setPlaying(false); - video.play(); - QCOMPARE(video.isPlaying(), false); - - QCOMPARE(video.isPaused(), false); - video.pause(); - QCOMPARE(video.isPaused(), false); - video.setPaused(true); - QCOMPARE(video.isPaused(), true); - - QCOMPARE(video.duration(), 0); - - QCOMPARE(video.position(), 0); - video.setPosition(10000); - QCOMPARE(video.position(), 10000); - - QCOMPARE(video.volume(), qreal(1.0)); - video.setVolume(0.5); - QCOMPARE(video.volume(), qreal(0.5)); - - QCOMPARE(video.isMuted(), false); - video.setMuted(true); - QCOMPARE(video.isMuted(), true); - - QCOMPARE(video.bufferProgress(), qreal(0)); - - QCOMPARE(video.isSeekable(), false); - - QCOMPARE(video.playbackRate(), qreal(1.0)); - - QCOMPARE(video.hasAudio(), false); - QCOMPARE(video.hasVideo(), false); - - QCOMPARE(video.status(), QDeclarativeVideo::NoMedia); - - QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing); - - QCOMPARE(video.metaObject()->indexOfProperty("title"), -1); - QCOMPARE(video.metaObject()->indexOfProperty("genre"), -1); - QCOMPARE(video.metaObject()->indexOfProperty("description"), -1); -} - -void tst_QDeclarativeVideo::playing() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged())); - QSignalSpy startedSpy(&video, SIGNAL(started())); - QSignalSpy stoppedSpy(&video, SIGNAL(stopped())); - - int playingChanged = 0; - int started = 0; - int stopped = 0; - - QCOMPARE(video.isPlaying(), false); - - // setPlaying(true) when stopped. - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when playing. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // play() when stopped. - video.play(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when playing. - video.stop(); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // stop() when stopped. - video.stop(); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when stopped. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(true) when playing. - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - // play() when playing. - video.play(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); -} - -void tst_QDeclarativeVideo::paused() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged())); - QSignalSpy pausedChangedSpy(&video, SIGNAL(pausedChanged())); - QSignalSpy startedSpy(&video, SIGNAL(started())); - QSignalSpy pausedSpy(&video, SIGNAL(paused())); - QSignalSpy resumedSpy(&video, SIGNAL(resumed())); - QSignalSpy stoppedSpy(&video, SIGNAL(stopped())); - - int playingChanged = 0; - int pausedChanged = 0; - int started = 0; - int paused = 0; - int resumed = 0; - int stopped = 0; - - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), false); - - // setPlaying(true) when stopped. - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when playing. - video.setPaused(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when paused. - video.setPaused(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when paused. - video.pause(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when paused. - video.setPaused(false); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), ++resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when playing. - video.setPaused(false); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when playing. - video.pause(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // setPaused(true) when stopped and paused. - video.setPaused(true); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when stopped and paused. - video.setPaused(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when stopped. - video.setPaused(true); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(true) when stopped and paused. - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // play() when paused. - video.play(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), ++resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when playing. - video.setPaused(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when paused. - video.stop(); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // setPaused(true) when stopped. - video.setPaused(true); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when stopped and paused. - video.stop(); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when stopped. - video.pause(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // pause() when stopped and paused. - video.pause(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // play() when stopped and paused. - video.play(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); -} - -void tst_QDeclarativeVideo::error() -{ - const QString errorString = QLatin1String("Failed to open device."); - - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QSignalSpy errorSpy(&video, SIGNAL(error(QDeclarativeVideo::Error,QString))); - QSignalSpy errorChangedSpy(&video, SIGNAL(errorChanged())); - - QCOMPARE(video.error(), QDeclarativeVideo::NoError); - QCOMPARE(video.errorString(), QString()); - - provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString); - - QCOMPARE(video.error(), QDeclarativeVideo::ResourceError); - QCOMPARE(video.errorString(), errorString); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 1); - - // Changing the source resets the error properties. - video.setSource(QUrl("http://example.com")); - QCOMPARE(video.error(), QDeclarativeVideo::NoError); - QCOMPARE(video.errorString(), QString()); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 2); - - // But isn't noisy. - video.setSource(QUrl("file:///file/path")); - QCOMPARE(video.error(), QDeclarativeVideo::NoError); - QCOMPARE(video.errorString(), QString()); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 2); -} - - -void tst_QDeclarativeVideo::hasAudio() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QSignalSpy spy(&video, SIGNAL(hasAudioChanged())); - - QCOMPARE(video.hasAudio(), false); - - provider.playerControl()->setAudioAvailable(true); - QCOMPARE(video.hasAudio(), true); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setAudioAvailable(true); - QCOMPARE(video.hasAudio(), true); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setAudioAvailable(false); - QCOMPARE(video.hasAudio(), false); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeVideo::hasVideo() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - - video.componentComplete(); - - QSignalSpy spy(&video, SIGNAL(hasVideoChanged())); - - QCOMPARE(video.hasVideo(), false); - - provider.playerControl()->setVideoAvailable(true); - QCOMPARE(video.hasVideo(), true); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setVideoAvailable(true); - QCOMPARE(video.hasVideo(), true); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setVideoAvailable(false); - QCOMPARE(video.hasVideo(), false); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeVideo::fillMode() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QList<QGraphicsItem *> children = video.childItems(); - QCOMPARE(children.count(), 1); - QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first()); - QVERIFY(videoItem != 0); - - QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectFit); - - video.setFillMode(QDeclarativeVideo::PreserveAspectCrop); - QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectCrop); - QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatioByExpanding); - - video.setFillMode(QDeclarativeVideo::Stretch); - QCOMPARE(video.fillMode(), QDeclarativeVideo::Stretch); - QCOMPARE(videoItem->aspectRatioMode(), Qt::IgnoreAspectRatio); - - video.setFillMode(QDeclarativeVideo::PreserveAspectFit); - QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectFit); - QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QDeclarativeVideo::geometry() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QAbstractVideoSurface *surface = provider.rendererControl()->surface(); - QVERIFY(surface != 0); - - QList<QGraphicsItem *> children = video.childItems(); - QCOMPARE(children.count(), 1); - QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first()); - QVERIFY(videoItem != 0); - - QVideoSurfaceFormat format(QSize(640, 480), QVideoFrame::Format_RGB32); - - QVERIFY(surface->start(format)); - - QCOMPARE(video.implicitWidth(), qreal(640)); - QCOMPARE(video.implicitHeight(), qreal(480)); - - video.setWidth(560); - video.setHeight(328); - - QCOMPARE(videoItem->size().width(), qreal(560)); - QCOMPARE(videoItem->size().height(), qreal(328)); -} - -QTEST_MAIN(tst_QDeclarativeVideo) - -#include "tst_qdeclarativevideo.moc" diff --git a/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro b/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro deleted file mode 100644 index b57e8e3..0000000 --- a/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro +++ /dev/null @@ -1,5 +0,0 @@ -load(qttest_p4) -SOURCES += tst_qgraphicsvideoitem.cpp - -QT += multimedia mediaservices -requires(contains(QT_CONFIG, mediaservices)) diff --git a/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp b/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp deleted file mode 100644 index 1815779..0000000 --- a/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp +++ /dev/null @@ -1,670 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> - -#include <QtMediaServices/qgraphicsvideoitem.h> - -#include <QtGui/qapplication.h> -#include <QtGui/qgraphicsscene.h> -#include <QtGui/qgraphicsview.h> -#include <QtMultimedia/qabstractvideosurface.h> -#include <QtMediaServices/qmediaobject.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qvideooutputcontrol.h> -#include <QtMediaServices/qvideorenderercontrol.h> -#include <QtMultimedia/qvideosurfaceformat.h> - -#include <QtMediaServices/private/qpaintervideosurface_p.h> - -class tst_QGraphicsVideoItem : public QObject -{ - Q_OBJECT -public slots: - void initTestCase(); - -private slots: - void nullObject(); - void nullService(); - void nullOutputControl(); - void noOutputs(); - void serviceDestroyed(); - void mediaObjectDestroyed(); - void setMediaObject(); - - void show(); - - void aspectRatioMode(); - void offset(); - void size(); - void nativeSize_data(); - void nativeSize(); - - void boundingRect_data(); - void boundingRect(); - - void paint(); -}; - -Q_DECLARE_METATYPE(const uchar *) -Q_DECLARE_METATYPE(Qt::AspectRatioMode) - -class QtTestOutputControl : public QVideoOutputControl -{ -public: - QtTestOutputControl() : m_output(NoOutput) {} - - QList<Output> availableOutputs() const { return m_outputs; } - void setAvailableOutputs(const QList<Output> outputs) { m_outputs = outputs; } - - Output output() const { return m_output; } - virtual void setOutput(Output output) { m_output = output; } - -private: - Output m_output; - QList<Output> m_outputs; -}; - -class QtTestRendererControl : public QVideoRendererControl -{ -public: - QtTestRendererControl() - : m_surface(0) - { - } - - QAbstractVideoSurface *surface() const { return m_surface; } - void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; } - -private: - QAbstractVideoSurface *m_surface; -}; - -class QtTestVideoService : public QMediaService -{ - Q_OBJECT -public: - QtTestVideoService( - QtTestOutputControl *output, - QtTestRendererControl *renderer) - : QMediaService(0) - , outputControl(output) - , rendererControl(renderer) - { - } - - ~QtTestVideoService() - { - delete outputControl; - delete rendererControl; - } - - QMediaControl *control(const char *name) const - { - if (qstrcmp(name, QVideoOutputControl_iid) == 0) - return outputControl; - else if (qstrcmp(name, QVideoRendererControl_iid) == 0) - return rendererControl; - else - return 0; - } - - QtTestOutputControl *outputControl; - QtTestRendererControl *rendererControl; -}; - -class QtTestVideoObject : public QMediaObject -{ - Q_OBJECT -public: - QtTestVideoObject(QtTestRendererControl *renderer): - QMediaObject(0, new QtTestVideoService(new QtTestOutputControl, renderer)) - { - testService = qobject_cast<QtTestVideoService*>(service()); - QList<QVideoOutputControl::Output> outputs; - - if (renderer) - outputs.append(QVideoOutputControl::RendererOutput); - - testService->outputControl->setAvailableOutputs(outputs); - } - - QtTestVideoObject(QtTestVideoService *service): - QMediaObject(0, service), - testService(service) - { - } - - ~QtTestVideoObject() - { - delete testService; - } - - QtTestVideoService *testService; -}; - -class QtTestGraphicsVideoItem : public QGraphicsVideoItem -{ -public: - QtTestGraphicsVideoItem(QGraphicsItem *parent = 0) - : QGraphicsVideoItem(parent) - , m_paintCount(0) - { - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) - { - ++m_paintCount; - - QTestEventLoop::instance().exitLoop(); - - QGraphicsVideoItem::paint(painter, option, widget); - } - - bool waitForPaint(int secs) - { - const int paintCount = m_paintCount; - - QTestEventLoop::instance().enterLoop(secs); - - return m_paintCount != paintCount; - } - - int paintCount() const - { - return m_paintCount; - } - -private: - int m_paintCount; -}; - -void tst_QGraphicsVideoItem::initTestCase() -{ - qRegisterMetaType<Qt::AspectRatioMode>(); -} - -void tst_QGraphicsVideoItem::nullObject() -{ - QGraphicsVideoItem item(0); - - QVERIFY(item.boundingRect().isEmpty()); -} - -void tst_QGraphicsVideoItem::nullService() -{ - QtTestVideoService *service = 0; - - QtTestVideoObject object(service); - - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - QVERIFY(item->boundingRect().isEmpty()); - - item->hide(); - item->show(); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); -} - -void tst_QGraphicsVideoItem::nullOutputControl() -{ - QtTestVideoObject object(new QtTestVideoService(0, 0)); - - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - QVERIFY(item->boundingRect().isEmpty()); - - item->hide(); - item->show(); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); -} - -void tst_QGraphicsVideoItem::noOutputs() -{ - QtTestRendererControl *control = 0; - QtTestVideoObject object(control); - - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - QVERIFY(item->boundingRect().isEmpty()); - - item->hide(); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - item->show(); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); -} - -void tst_QGraphicsVideoItem::serviceDestroyed() -{ - QtTestVideoObject object(new QtTestRendererControl); - - QGraphicsVideoItem item; - item.setMediaObject(&object); - - QtTestVideoService *service = object.testService; - object.testService = 0; - - delete service; - - QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(&object)); - QVERIFY(item.boundingRect().isEmpty()); -} - -void tst_QGraphicsVideoItem::mediaObjectDestroyed() -{ - QtTestVideoObject *object = new QtTestVideoObject(new QtTestRendererControl); - - QGraphicsVideoItem item; - item.setMediaObject(object); - - delete object; - object = 0; - - QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(object)); - QVERIFY(item.boundingRect().isEmpty()); -} - -void tst_QGraphicsVideoItem::setMediaObject() -{ - QMediaObject *nullObject = 0; - QtTestVideoObject object(new QtTestRendererControl); - - QGraphicsVideoItem item; - - QCOMPARE(item.mediaObject(), nullObject); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - item.setMediaObject(&object); - QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(&object)); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); - - item.setMediaObject(0); - QCOMPARE(item.mediaObject(), nullObject); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - item.setVisible(false); - - item.setMediaObject(&object); - QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(&object)); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); -} - -void tst_QGraphicsVideoItem::show() -{ - QtTestVideoObject object(new QtTestRendererControl); - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - // Graphics items are visible by default - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); - - item->hide(); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - - item->show(); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); - - QVERIFY(item->boundingRect().isEmpty()); - - QVideoSurfaceFormat format(QSize(320,240),QVideoFrame::Format_RGB32); - QVERIFY(object.testService->rendererControl->surface()->start(format)); - - QVERIFY(!item->boundingRect().isEmpty()); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); - - QVERIFY(item->paintCount() || item->waitForPaint(1)); -} - -void tst_QGraphicsVideoItem::aspectRatioMode() -{ - QGraphicsVideoItem item; - - QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatio); - - item.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(item.aspectRatioMode(), Qt::IgnoreAspectRatio); - - item.setAspectRatioMode(Qt::KeepAspectRatioByExpanding); - QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatioByExpanding); - - item.setAspectRatioMode(Qt::KeepAspectRatio); - QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QGraphicsVideoItem::offset() -{ - QGraphicsVideoItem item; - - QCOMPARE(item.offset(), QPointF(0, 0)); - - item.setOffset(QPointF(-32.4, 43.0)); - QCOMPARE(item.offset(), QPointF(-32.4, 43.0)); - - item.setOffset(QPointF(1, 1)); - QCOMPARE(item.offset(), QPointF(1, 1)); - - item.setOffset(QPointF(12, -30.4)); - QCOMPARE(item.offset(), QPointF(12, -30.4)); - - item.setOffset(QPointF(-90.4, -75)); - QCOMPARE(item.offset(), QPointF(-90.4, -75)); -} - -void tst_QGraphicsVideoItem::size() -{ - QGraphicsVideoItem item; - - QCOMPARE(item.size(), QSizeF(320, 240)); - - item.setSize(QSizeF(542.5, 436.3)); - QCOMPARE(item.size(), QSizeF(542.5, 436.3)); - - item.setSize(QSizeF(-43, 12)); - QCOMPARE(item.size(), QSizeF(0, 0)); - - item.setSize(QSizeF(54, -9)); - QCOMPARE(item.size(), QSizeF(0, 0)); - - item.setSize(QSizeF(-90, -65)); - QCOMPARE(item.size(), QSizeF(0, 0)); - - item.setSize(QSizeF(1000, 1000)); - QCOMPARE(item.size(), QSizeF(1000, 1000)); -} - -void tst_QGraphicsVideoItem::nativeSize_data() -{ - QTest::addColumn<QSize>("frameSize"); - QTest::addColumn<QRect>("viewport"); - QTest::addColumn<QSize>("pixelAspectRatio"); - QTest::addColumn<QSizeF>("nativeSize"); - - QTest::newRow("640x480") - << QSize(640, 480) - << QRect(0, 0, 640, 480) - << QSize(1, 1) - << QSizeF(640, 480); - - QTest::newRow("800x600, (80,60, 640x480) viewport") - << QSize(800, 600) - << QRect(80, 60, 640, 480) - << QSize(1, 1) - << QSizeF(640, 480); - - QTest::newRow("800x600, (80,60, 640x480) viewport, 4:3") - << QSize(800, 600) - << QRect(80, 60, 640, 480) - << QSize(4, 3) - << QSizeF(853, 480); -} - -void tst_QGraphicsVideoItem::nativeSize() -{ - QFETCH(QSize, frameSize); - QFETCH(QRect, viewport); - QFETCH(QSize, pixelAspectRatio); - QFETCH(QSizeF, nativeSize); - - QtTestVideoObject object(new QtTestRendererControl); - QGraphicsVideoItem item; - item.setMediaObject(&object); - - QCOMPARE(item.nativeSize(), QSizeF()); - - QSignalSpy spy(&item, SIGNAL(nativeSizeChanged(QSizeF))); - - QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); - format.setViewport(viewport); - format.setPixelAspectRatio(pixelAspectRatio); - - QVERIFY(object.testService->rendererControl->surface()->start(format)); - - QCOMPARE(item.nativeSize(), nativeSize); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.last().first().toSizeF(), nativeSize); - - object.testService->rendererControl->surface()->stop(); - - QCOMPARE(item.nativeSize(), QSizeF(0, 0)); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.last().first().toSizeF(), QSizeF(0, 0)); -} - -void tst_QGraphicsVideoItem::boundingRect_data() -{ - QTest::addColumn<QSize>("frameSize"); - QTest::addColumn<QPointF>("offset"); - QTest::addColumn<QSizeF>("size"); - QTest::addColumn<Qt::AspectRatioMode>("aspectRatioMode"); - QTest::addColumn<QRectF>("expectedRect"); - - - QTest::newRow("640x480: (0,0 640x480), Keep") - << QSize(640, 480) - << QPointF(0, 0) - << QSizeF(640, 480) - << Qt::KeepAspectRatio - << QRectF(0, 0, 640, 480); - - QTest::newRow("800x600, (0,0, 640x480), Keep") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(640, 480) - << Qt::KeepAspectRatio - << QRectF(0, 0, 640, 480); - - QTest::newRow("800x600, (0,0, 640x480), KeepByExpanding") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(640, 480) - << Qt::KeepAspectRatioByExpanding - << QRectF(0, 0, 640, 480); - - QTest::newRow("800x600, (0,0, 640x480), Ignore") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(640, 480) - << Qt::IgnoreAspectRatio - << QRectF(0, 0, 640, 480); - - QTest::newRow("800x600, (100,100, 640x480), Keep") - << QSize(800, 600) - << QPointF(100, 100) - << QSizeF(640, 480) - << Qt::KeepAspectRatio - << QRectF(100, 100, 640, 480); - - QTest::newRow("800x600, (100,-100, 640x480), KeepByExpanding") - << QSize(800, 600) - << QPointF(100, -100) - << QSizeF(640, 480) - << Qt::KeepAspectRatioByExpanding - << QRectF(100, -100, 640, 480); - - QTest::newRow("800x600, (-100,-100, 640x480), Ignore") - << QSize(800, 600) - << QPointF(-100, -100) - << QSizeF(640, 480) - << Qt::IgnoreAspectRatio - << QRectF(-100, -100, 640, 480); - - QTest::newRow("800x600, (0,0, 1920x1024), Keep") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(1920, 1024) - << Qt::KeepAspectRatio - << QRectF(832.0 / 3, 0, 4096.0 / 3, 1024); - - QTest::newRow("800x600, (0,0, 1920x1024), KeepByExpanding") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(1920, 1024) - << Qt::KeepAspectRatioByExpanding - << QRectF(0, 0, 1920, 1024); - - QTest::newRow("800x600, (0,0, 1920x1024), Ignore") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(1920, 1024) - << Qt::IgnoreAspectRatio - << QRectF(0, 0, 1920, 1024); - - QTest::newRow("800x600, (100,100, 1920x1024), Keep") - << QSize(800, 600) - << QPointF(100, 100) - << QSizeF(1920, 1024) - << Qt::KeepAspectRatio - << QRectF(100 + 832.0 / 3, 100, 4096.0 / 3, 1024); - - QTest::newRow("800x600, (100,-100, 1920x1024), KeepByExpanding") - << QSize(800, 600) - << QPointF(100, -100) - << QSizeF(1920, 1024) - << Qt::KeepAspectRatioByExpanding - << QRectF(100, -100, 1920, 1024); - - QTest::newRow("800x600, (-100,-100, 1920x1024), Ignore") - << QSize(800, 600) - << QPointF(-100, -100) - << QSizeF(1920, 1024) - << Qt::IgnoreAspectRatio - << QRectF(-100, -100, 1920, 1024); -} - -void tst_QGraphicsVideoItem::boundingRect() -{ - QFETCH(QSize, frameSize); - QFETCH(QPointF, offset); - QFETCH(QSizeF, size); - QFETCH(Qt::AspectRatioMode, aspectRatioMode); - QFETCH(QRectF, expectedRect); - - QtTestVideoObject object(new QtTestRendererControl); - QGraphicsVideoItem item; - item.setMediaObject(&object); - - item.setOffset(offset); - item.setSize(size); - item.setAspectRatioMode(aspectRatioMode); - - QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); - - QVERIFY(object.testService->rendererControl->surface()->start(format)); - - QCOMPARE(item.boundingRect(), expectedRect); -} - -static const uchar rgb32ImageData[] = -{ - 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, - 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00 -}; - -void tst_QGraphicsVideoItem::paint() -{ - QtTestVideoObject object(new QtTestRendererControl); - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); - - QPainterVideoSurface *surface = qobject_cast<QPainterVideoSurface *>( - object.testService->rendererControl->surface()); - - QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32); - - QVERIFY(surface->start(format)); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); - - QVERIFY(item->waitForPaint(1)); - - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); - - QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32); - - frame.map(QAbstractVideoBuffer::WriteOnly); - memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes()); - frame.unmap(); - - QVERIFY(surface->present(frame)); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), false); - - QVERIFY(item->waitForPaint(1)); - - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); -} - - -QTEST_MAIN(tst_QGraphicsVideoItem) - -#include "tst_qgraphicsvideoitem.moc" diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 5a1d20b..ed8ff04 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -169,6 +169,7 @@ private slots: void initialShow(); void initialShow2(); void itemChangeEvents(); + void itemSendGeometryPosChangesDeactivated(); // Task fixes void task236127_bspTreeIndexFails(); @@ -3030,6 +3031,34 @@ void tst_QGraphicsWidget::itemChangeEvents() QTRY_VERIFY(!item->valueDuringEvents.value(QEvent::EnabledChange).toBool()); } +void tst_QGraphicsWidget::itemSendGeometryPosChangesDeactivated() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + QGraphicsWidget *item = new QGraphicsWidget; + scene.addItem(item); + view.show(); + QTest::qWaitForWindowShown(&view); + item->setGeometry(QRectF(0, 0, 50, 50)); + QTRY_COMPARE(item->geometry(), QRectF(0, 0, 50, 50)); + + item->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); + item->setGeometry(QRectF(0, 0, 60, 60)); + QCOMPARE(item->geometry(), QRectF(0, 0, 60, 60)); + QCOMPARE(item->pos(), QPointF(0, 0)); + item->setPos(QPointF(10, 10)); + QCOMPARE(item->pos(), QPointF(10, 10)); + QCOMPARE(item->geometry(), QRectF(10, 10, 60, 60)); + + item->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false); + item->setGeometry(QRectF(0, 0, 60, 60)); + QCOMPARE(item->geometry(), QRectF(0, 0, 60, 60)); + QCOMPARE(item->pos(), QPointF(0, 0)); + item->setPos(QPointF(10, 10)); + QCOMPARE(item->pos(), QPointF(10, 10)); + QCOMPARE(item->geometry(), QRectF(10, 10, 60, 60)); +} + void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems() { QGraphicsScene scene; diff --git a/tests/auto/qhostinfo/qhostinfo.pro b/tests/auto/qhostinfo/qhostinfo.pro index 06a4b17..97197a9 100644 --- a/tests/auto/qhostinfo/qhostinfo.pro +++ b/tests/auto/qhostinfo/qhostinfo.pro @@ -2,7 +2,7 @@ load(qttest_p4) SOURCES += tst_qhostinfo.cpp -QT = core network core +QT = core network wince*: { LIBS += ws2.lib @@ -11,4 +11,6 @@ wince*: { } symbian: TARGET.CAPABILITY = NetworkServices - +symbian: { + INCLUDEPATH *= $$MW_LAYER_SYSTEMINCLUDE +} diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 21f228a..89f608e 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -109,6 +109,9 @@ private Q_SLOTS: void getMultipleWithPriorities(); void getEmptyWithPipelining(); + + void getAndThenDeleteObject(); + void getAndThenDeleteObject_data(); }; tst_QHttpNetworkConnection::tst_QHttpNetworkConnection() @@ -1033,6 +1036,47 @@ void tst_QHttpNetworkConnection::getEmptyWithPipelining() qDeleteAll(replies); } +void tst_QHttpNetworkConnection::getAndThenDeleteObject_data() +{ + QTest::addColumn<bool>("replyFirst"); + + QTest::newRow("delete-reply-first") << true; + QTest::newRow("delete-connection-first") << false; +} + +void tst_QHttpNetworkConnection::getAndThenDeleteObject() +{ + // yes, this will leak if the testcase fails. I don't care. It must not fail then :P + QHttpNetworkConnection *connection = new QHttpNetworkConnection(QtNetworkSettings::serverName()); + QHttpNetworkRequest request("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile"); + QHttpNetworkReply *reply = connection->sendRequest(request); + reply->setDownstreamLimited(true); + + QTime stopWatch; + stopWatch.start(); + forever { + QCoreApplication::instance()->processEvents(); + if (reply->bytesAvailable()) + break; + if (stopWatch.elapsed() >= 30000) + break; + } + + QVERIFY(reply->bytesAvailable()); + QCOMPARE(reply->statusCode() ,200); + QVERIFY(!reply->isFinished()); // must not be finished + + QFETCH(bool, replyFirst); + + if (replyFirst) { + delete reply; + delete connection; + } else { + delete connection; + delete reply; + } +} + QTEST_MAIN(tst_QHttpNetworkConnection) diff --git a/tests/auto/qmediacontent/qmediacontent.pro b/tests/auto/qmediacontent/qmediacontent.pro deleted file mode 100644 index e20b4db..0000000 --- a/tests/auto/qmediacontent/qmediacontent.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES += tst_qmediacontent.cpp - -QT = core network mediaservices - diff --git a/tests/auto/qmediacontent/tst_qmediacontent.cpp b/tests/auto/qmediacontent/tst_qmediacontent.cpp deleted file mode 100644 index e33149a..0000000 --- a/tests/auto/qmediacontent/tst_qmediacontent.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> - -#include <QtMediaServices/qmediacontent.h> - - -class tst_QMediaContent : public QObject -{ - Q_OBJECT - -private slots: - void testNull(); - void testUrlCtor(); - void testRequestCtor(); - void testResourceCtor(); - void testResourceListCtor(); - void testCopy(); - void testAssignment(); - void testEquality(); - void testResources(); -}; - -void tst_QMediaContent::testNull() -{ - QMediaContent media; - - QCOMPARE(media.isNull(), true); - QCOMPARE(media.canonicalUrl(), QUrl()); - QCOMPARE(media.canonicalResource(), QMediaResource()); - QCOMPARE(media.resources(), QMediaResourceList()); -} - -void tst_QMediaContent::testUrlCtor() -{ - QMediaContent media(QUrl("http://example.com/movie.mov")); - - QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov")); - QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov")); -} - -void tst_QMediaContent::testRequestCtor() -{ - QNetworkRequest request(QUrl("http://example.com/movie.mov")); - request.setAttribute(QNetworkRequest::User, QVariant(1234)); - - QMediaContent media(request); - - QCOMPARE(media.canonicalRequest(), request); - QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov")); - QCOMPARE(media.canonicalResource().request(), request); - QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov")); -} - -void tst_QMediaContent::testResourceCtor() -{ - QMediaContent media(QMediaResource(QUrl("http://example.com/movie.mov"))); - - QCOMPARE(media.canonicalResource(), QMediaResource(QUrl("http://example.com/movie.mov"))); -} - -void tst_QMediaContent::testResourceListCtor() -{ - QMediaResourceList resourceList; - resourceList << QMediaResource(QUrl("http://example.com/movie.mov")); - - QMediaContent media(resourceList); - - QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov")); - QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov")); -} - -void tst_QMediaContent::testCopy() -{ - QMediaContent media1(QMediaResource(QUrl("http://example.com/movie.mov"))); - QMediaContent media2(media1); - - QVERIFY(media1 == media2); -} - -void tst_QMediaContent::testAssignment() -{ - QMediaContent media1(QMediaResource(QUrl("http://example.com/movie.mov"))); - QMediaContent media2; - QMediaContent media3; - - media2 = media1; - QVERIFY(media2 == media1); - - media2 = media3; - QVERIFY(media2 == media3); -} - -void tst_QMediaContent::testEquality() -{ - QMediaContent media1; - QMediaContent media2; - QMediaContent media3(QMediaResource(QUrl("http://example.com/movie.mov"))); - QMediaContent media4(QMediaResource(QUrl("http://example.com/movie.mov"))); - QMediaContent media5(QMediaResource(QUrl("file:///some/where/over/the/rainbow.mp3"))); - - // null == null - QCOMPARE(media1 == media2, true); - QCOMPARE(media1 != media2, false); - - // null != something - QCOMPARE(media1 == media3, false); - QCOMPARE(media1 != media3, true); - - // equiv - QCOMPARE(media3 == media4, true); - QCOMPARE(media3 != media4, false); - - // not equiv - QCOMPARE(media4 == media5, false); - QCOMPARE(media4 != media5, true); -} - -void tst_QMediaContent::testResources() -{ - QMediaResourceList resourceList; - - resourceList << QMediaResource(QUrl("http://example.com/movie-main.mov")); - resourceList << QMediaResource(QUrl("http://example.com/movie-big.mov")); - QMediaContent media(resourceList); - - QMediaResourceList res = media.resources(); - QCOMPARE(res.size(), 2); - QCOMPARE(res[0], QMediaResource(QUrl("http://example.com/movie-main.mov"))); - QCOMPARE(res[1], QMediaResource(QUrl("http://example.com/movie-big.mov"))); -} - -QTEST_MAIN(tst_QMediaContent) - -#include "tst_qmediacontent.moc" diff --git a/tests/auto/qmediaobject/qmediaobject.pro b/tests/auto/qmediaobject/qmediaobject.pro deleted file mode 100644 index d6a0f7b..0000000 --- a/tests/auto/qmediaobject/qmediaobject.pro +++ /dev/null @@ -1,4 +0,0 @@ -load(qttest_p4) - -SOURCES += tst_qmediaobject.cpp -QT = core mediaservices diff --git a/tests/auto/qmediaobject/tst_qmediaobject.cpp b/tests/auto/qmediaobject/tst_qmediaobject.cpp deleted file mode 100644 index 5a2fdeb..0000000 --- a/tests/auto/qmediaobject/tst_qmediaobject.cpp +++ /dev/null @@ -1,549 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> - -#include <QtCore/qtimer.h> - -#include <QtMediaServices/qmediaobject.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmetadatacontrol.h> - - -class tst_QMediaObject : public QObject -{ - Q_OBJECT - -private slots: - void propertyWatch(); - void notifySignals_data(); - void notifySignals(); - void notifyInterval_data(); - void notifyInterval(); - - void nullMetaDataControl(); - void isMetaDataAvailable(); - void isWritable(); - void metaDataChanged(); - void metaData_data(); - void metaData(); - void setMetaData_data(); - void setMetaData(); - void extendedMetaData_data() { metaData_data(); } - void extendedMetaData(); - void setExtendedMetaData_data() { extendedMetaData_data(); } - void setExtendedMetaData(); - - -private: - void setupNotifyTests(); -}; - -class QtTestMetaDataProvider : public QMetaDataControl -{ - Q_OBJECT -public: - QtTestMetaDataProvider(QObject *parent = 0) - : QMetaDataControl(parent) - , m_available(false) - , m_writable(false) - { - } - - bool isMetaDataAvailable() const { return m_available; } - void setMetaDataAvailable(bool available) { - if (m_available != available) - emit metaDataAvailableChanged(m_available = available); - } - QList<QtMediaServices::MetaData> availableMetaData() const { return m_data.keys(); } - - bool isWritable() const { return m_writable; } - void setWritable(bool writable) { emit writableChanged(m_writable = writable); } - - QVariant metaData(QtMediaServices::MetaData key) const { return m_data.value(key); } - void setMetaData(QtMediaServices::MetaData key, const QVariant &value) { - m_data.insert(key, value); } - - QVariant extendedMetaData(const QString &key) const { return m_extendedData.value(key); } - void setExtendedMetaData(const QString &key, const QVariant &value) { - m_extendedData.insert(key, value); } - - QStringList availableExtendedMetaData() const { return m_extendedData.keys(); } - - using QMetaDataControl::metaDataChanged; - - void populateMetaData() - { - m_available = true; - } - - bool m_available; - bool m_writable; - QMap<QtMediaServices::MetaData, QVariant> m_data; - QMap<QString, QVariant> m_extendedData; -}; - -class QtTestMetaDataService : public QMediaService -{ - Q_OBJECT -public: - QtTestMetaDataService(QObject *parent = 0):QMediaService(parent), hasMetaData(true) - { - } - - QMediaControl *control(const char *iid) const - { - if (hasMetaData && qstrcmp(iid, QMetaDataControl_iid) == 0) - return const_cast<QtTestMetaDataProvider *>(&metaData); - else - return 0; - } - - QtTestMetaDataProvider metaData; - bool hasMetaData; -}; - - -class QtTestMediaObject : public QMediaObject -{ - Q_OBJECT - Q_PROPERTY(int a READ a WRITE setA NOTIFY aChanged) - Q_PROPERTY(int b READ b WRITE setB NOTIFY bChanged) - Q_PROPERTY(int c READ c WRITE setC NOTIFY cChanged) - Q_PROPERTY(int d READ d WRITE setD) -public: - QtTestMediaObject(QMediaService *service = 0): QMediaObject(0, service), m_a(0), m_b(0), m_c(0), m_d(0) {} - - using QMediaObject::addPropertyWatch; - using QMediaObject::removePropertyWatch; - - int a() const { return m_a; } - void setA(int a) { m_a = a; } - - int b() const { return m_b; } - void setB(int b) { m_b = b; } - - int c() const { return m_c; } - void setC(int c) { m_c = c; } - - int d() const { return m_d; } - void setD(int d) { m_d = d; } - -Q_SIGNALS: - void aChanged(int a); - void bChanged(int b); - void cChanged(int c); - -private: - int m_a; - int m_b; - int m_c; - int m_d; -}; - -void tst_QMediaObject::propertyWatch() -{ - QtTestMediaObject object; - object.setNotifyInterval(0); - - QEventLoop loop; - connect(&object, SIGNAL(aChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); - connect(&object, SIGNAL(bChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); - connect(&object, SIGNAL(cChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); - - QSignalSpy aSpy(&object, SIGNAL(aChanged(int))); - QSignalSpy bSpy(&object, SIGNAL(bChanged(int))); - QSignalSpy cSpy(&object, SIGNAL(cChanged(int))); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), 0); - QCOMPARE(bSpy.count(), 0); - QCOMPARE(cSpy.count(), 0); - - int aCount = 0; - int bCount = 0; - int cCount = 0; - - object.addPropertyWatch("a"); - - QTestEventLoop::instance().enterLoop(1); - - QVERIFY(aSpy.count() > aCount); - QCOMPARE(bSpy.count(), 0); - QCOMPARE(cSpy.count(), 0); - QCOMPARE(aSpy.last().value(0).toInt(), 0); - - aCount = aSpy.count(); - - object.setA(54); - object.setB(342); - object.setC(233); - - QTestEventLoop::instance().enterLoop(1); - - QVERIFY(aSpy.count() > aCount); - QCOMPARE(bSpy.count(), 0); - QCOMPARE(cSpy.count(), 0); - QCOMPARE(aSpy.last().value(0).toInt(), 54); - - aCount = aSpy.count(); - - object.addPropertyWatch("b"); - object.addPropertyWatch("d"); - object.removePropertyWatch("e"); - object.setA(43); - object.setB(235); - object.setC(90); - - QTestEventLoop::instance().enterLoop(1); - - QVERIFY(aSpy.count() > aCount); - QVERIFY(bSpy.count() > bCount); - QCOMPARE(cSpy.count(), 0); - QCOMPARE(aSpy.last().value(0).toInt(), 43); - QCOMPARE(bSpy.last().value(0).toInt(), 235); - - aCount = aSpy.count(); - bCount = bSpy.count(); - - object.removePropertyWatch("a"); - object.addPropertyWatch("c"); - object.addPropertyWatch("e"); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), aCount); - QVERIFY(bSpy.count() > bCount); - QVERIFY(cSpy.count() > cCount); - QCOMPARE(bSpy.last().value(0).toInt(), 235); - QCOMPARE(cSpy.last().value(0).toInt(), 90); - - bCount = bSpy.count(); - cCount = cSpy.count(); - - object.setA(435); - object.setC(9845); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), aCount); - QVERIFY(bSpy.count() > bCount); - QVERIFY(cSpy.count() > cCount); - QCOMPARE(bSpy.last().value(0).toInt(), 235); - QCOMPARE(cSpy.last().value(0).toInt(), 9845); - - bCount = bSpy.count(); - cCount = cSpy.count(); - - object.setA(8432); - object.setB(324); - object.setC(443); - object.removePropertyWatch("c"); - object.removePropertyWatch("d"); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), aCount); - QVERIFY(bSpy.count() > bCount); - QCOMPARE(cSpy.count(), cCount); - QCOMPARE(bSpy.last().value(0).toInt(), 324); - QCOMPARE(cSpy.last().value(0).toInt(), 9845); - - bCount = bSpy.count(); - - object.removePropertyWatch("b"); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), aCount); - QCOMPARE(bSpy.count(), bCount); - QCOMPARE(cSpy.count(), cCount); -} - -void tst_QMediaObject::setupNotifyTests() -{ - QTest::addColumn<int>("interval"); - QTest::addColumn<int>("count"); - - QTest::newRow("single 750ms") - << 750 - << 1; - QTest::newRow("single 600ms") - << 600 - << 1; - QTest::newRow("x3 300ms") - << 300 - << 3; - QTest::newRow("x5 180ms") - << 180 - << 5; -} - -void tst_QMediaObject::notifySignals_data() -{ - setupNotifyTests(); -} - -void tst_QMediaObject::notifySignals() -{ - QFETCH(int, interval); - QFETCH(int, count); - - QtTestMediaObject object; - object.setNotifyInterval(interval); - object.addPropertyWatch("a"); - - QSignalSpy spy(&object, SIGNAL(aChanged(int))); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(spy.count(), count); -} - -void tst_QMediaObject::notifyInterval_data() -{ - setupNotifyTests(); -} - -void tst_QMediaObject::notifyInterval() -{ - QFETCH(int, interval); - - QtTestMediaObject object; - QSignalSpy spy(&object, SIGNAL(notifyIntervalChanged(int))); - - object.setNotifyInterval(interval); - QCOMPARE(object.notifyInterval(), interval); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.last().value(0).toInt(), interval); - - object.setNotifyInterval(interval); - QCOMPARE(object.notifyInterval(), interval); - QCOMPARE(spy.count(), 1); -} - -void tst_QMediaObject::nullMetaDataControl() -{ - const QString titleKey(QLatin1String("Title")); - const QString title(QLatin1String("Host of Seraphim")); - - QtTestMetaDataService service; - service.hasMetaData = false; - - QtTestMediaObject object(&service); - - QSignalSpy spy(&object, SIGNAL(metaDataChanged())); - - QCOMPARE(object.isMetaDataAvailable(), false); - QCOMPARE(object.isMetaDataWritable(), false); - - object.setMetaData(QtMediaServices::Title, title); - object.setExtendedMetaData(titleKey, title); - - QCOMPARE(object.metaData(QtMediaServices::Title).toString(), QString()); - QCOMPARE(object.extendedMetaData(titleKey).toString(), QString()); - QCOMPARE(object.availableMetaData(), QList<QtMediaServices::MetaData>()); - QCOMPARE(object.availableExtendedMetaData(), QStringList()); - QCOMPARE(spy.count(), 0); -} - -void tst_QMediaObject::isMetaDataAvailable() -{ - QtTestMetaDataService service; - service.metaData.setMetaDataAvailable(false); - - QtTestMediaObject object(&service); - QCOMPARE(object.isMetaDataAvailable(), false); - - QSignalSpy spy(&object, SIGNAL(metaDataAvailableChanged(bool))); - service.metaData.setMetaDataAvailable(true); - - QCOMPARE(object.isMetaDataAvailable(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).at(0).toBool(), true); - - service.metaData.setMetaDataAvailable(false); - - QCOMPARE(object.isMetaDataAvailable(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.at(1).at(0).toBool(), false); -} - -void tst_QMediaObject::isWritable() -{ - QtTestMetaDataService service; - service.metaData.setWritable(false); - - QtTestMediaObject object(&service); - - QSignalSpy spy(&object, SIGNAL(metaDataWritableChanged(bool))); - - QCOMPARE(object.isMetaDataWritable(), false); - - service.metaData.setWritable(true); - - QCOMPARE(object.isMetaDataWritable(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).at(0).toBool(), true); - - service.metaData.setWritable(false); - - QCOMPARE(object.isMetaDataWritable(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.at(1).at(0).toBool(), false); -} - -void tst_QMediaObject::metaDataChanged() -{ - QtTestMetaDataService service; - QtTestMediaObject object(&service); - - QSignalSpy spy(&object, SIGNAL(metaDataChanged())); - - service.metaData.metaDataChanged(); - QCOMPARE(spy.count(), 1); - - service.metaData.metaDataChanged(); - QCOMPARE(spy.count(), 2); -} - -void tst_QMediaObject::metaData_data() -{ - QTest::addColumn<QString>("artist"); - QTest::addColumn<QString>("title"); - QTest::addColumn<QString>("genre"); - - QTest::newRow("") - << QString::fromLatin1("Dead Can Dance") - << QString::fromLatin1("Host of Seraphim") - << QString::fromLatin1("Awesome"); -} - -void tst_QMediaObject::metaData() -{ - QFETCH(QString, artist); - QFETCH(QString, title); - QFETCH(QString, genre); - - QtTestMetaDataService service; - service.metaData.populateMetaData(); - - QtTestMediaObject object(&service); - QVERIFY(object.availableMetaData().isEmpty()); - - service.metaData.m_data.insert(QtMediaServices::AlbumArtist, artist); - service.metaData.m_data.insert(QtMediaServices::Title, title); - service.metaData.m_data.insert(QtMediaServices::Genre, genre); - - QCOMPARE(object.metaData(QtMediaServices::AlbumArtist).toString(), artist); - QCOMPARE(object.metaData(QtMediaServices::Title).toString(), title); - - QList<QtMediaServices::MetaData> metaDataKeys = object.availableMetaData(); - QCOMPARE(metaDataKeys.size(), 3); - QVERIFY(metaDataKeys.contains(QtMediaServices::AlbumArtist)); - QVERIFY(metaDataKeys.contains(QtMediaServices::Title)); - QVERIFY(metaDataKeys.contains(QtMediaServices::Genre)); -} - -void tst_QMediaObject::setMetaData_data() -{ - QTest::addColumn<QString>("title"); - - QTest::newRow("") - << QString::fromLatin1("In the Kingdom of the Blind the One eyed are Kings"); -} - -void tst_QMediaObject::setMetaData() -{ - QFETCH(QString, title); - - QtTestMetaDataService service; - service.metaData.populateMetaData(); - - QtTestMediaObject object(&service); - - object.setMetaData(QtMediaServices::Title, title); - QCOMPARE(object.metaData(QtMediaServices::Title).toString(), title); - QCOMPARE(service.metaData.m_data.value(QtMediaServices::Title).toString(), title); -} - -void tst_QMediaObject::extendedMetaData() -{ - QFETCH(QString, artist); - QFETCH(QString, title); - QFETCH(QString, genre); - - QtTestMetaDataService service; - QtTestMediaObject object(&service); - QVERIFY(object.availableExtendedMetaData().isEmpty()); - - service.metaData.m_extendedData.insert(QLatin1String("Artist"), artist); - service.metaData.m_extendedData.insert(QLatin1String("Title"), title); - service.metaData.m_extendedData.insert(QLatin1String("Genre"), genre); - - QCOMPARE(object.extendedMetaData(QLatin1String("Artist")).toString(), artist); - QCOMPARE(object.extendedMetaData(QLatin1String("Title")).toString(), title); - - QStringList extendedKeys = object.availableExtendedMetaData(); - QCOMPARE(extendedKeys.size(), 3); - QVERIFY(extendedKeys.contains(QLatin1String("Artist"))); - QVERIFY(extendedKeys.contains(QLatin1String("Title"))); - QVERIFY(extendedKeys.contains(QLatin1String("Genre"))); -} - -void tst_QMediaObject::setExtendedMetaData() -{ - QtTestMetaDataService service; - service.metaData.populateMetaData(); - - QtTestMediaObject object(&service); - - QString title(QLatin1String("In the Kingdom of the Blind the One eyed are Kings")); - - object.setExtendedMetaData(QLatin1String("Title"), title); - QCOMPARE(object.extendedMetaData(QLatin1String("Title")).toString(), title); - QCOMPARE(service.metaData.m_extendedData.value(QLatin1String("Title")).toString(), title); -} - -QTEST_MAIN(tst_QMediaObject) - -#include "tst_qmediaobject.moc" diff --git a/tests/auto/qmediaplayer/qmediaplayer.pro b/tests/auto/qmediaplayer/qmediaplayer.pro deleted file mode 100644 index f355078..0000000 --- a/tests/auto/qmediaplayer/qmediaplayer.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES += tst_qmediaplayer.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediaplayer/tst_qmediaplayer.cpp b/tests/auto/qmediaplayer/tst_qmediaplayer.cpp deleted file mode 100644 index 9a597e2..0000000 --- a/tests/auto/qmediaplayer/tst_qmediaplayer.cpp +++ /dev/null @@ -1,986 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> -#include <QtCore/qdebug.h> -#include <QtCore/qbuffer.h> - -#include <QtMediaServices/qmediaplayer.h> -#include <QtMediaServices/qmediaplayercontrol.h> -#include <QtMediaServices/qmediaplaylist.h> -#include <QtMediaServices/qmediaservice.h> - - - -class AutoConnection -{ -public: - AutoConnection(QObject *sender, const char *signal, QObject *receiver, const char *method) - : sender(sender), signal(signal), receiver(receiver), method(method) - { - QObject::connect(sender, signal, receiver, method); - } - - ~AutoConnection() - { - QObject::disconnect(sender, signal, receiver, method); - } - -private: - QObject *sender; - const char *signal; - QObject *receiver; - const char *method; -}; - - -class MockPlayerControl : public QMediaPlayerControl -{ - friend class MockPlayerService; - -public: - MockPlayerControl():QMediaPlayerControl(0) {} - - QMediaPlayer::State state() const { return _state; } - QMediaPlayer::MediaStatus mediaStatus() const { return _mediaStatus; } - - qint64 duration() const { return _duration; } - - qint64 position() const { return _position; } - - void setPosition(qint64 position) { if (position != _position) emit positionChanged(_position = position); } - - int volume() const { return _volume; } - void setVolume(int volume) { emit volumeChanged(_volume = volume); } - - bool isMuted() const { return _muted; } - void setMuted(bool muted) { if (muted != _muted) emit mutedChanged(_muted = muted); } - - int bufferStatus() const { return _bufferStatus; } - - bool isAudioAvailable() const { return _audioAvailable; } - bool isVideoAvailable() const { return _videoAvailable; } - - bool isSeekable() const { return _isSeekable; } - QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(_seekRange.first, _seekRange.second); } - void setSeekRange(qint64 minimum, qint64 maximum) { _seekRange = qMakePair(minimum, maximum); } - - qreal playbackRate() const { return _playbackRate; } - void setPlaybackRate(qreal rate) { if (rate != _playbackRate) emit playbackRateChanged(_playbackRate = rate); } - - QMediaContent media() const { return _media; } - void setMedia(const QMediaContent &content, QIODevice *stream) - { - _stream = stream; - _media = content; - if (_state != QMediaPlayer::StoppedState) { - _mediaStatus = _media.isNull() ? QMediaPlayer::NoMedia : QMediaPlayer::LoadingMedia; - emit stateChanged(_state = QMediaPlayer::StoppedState); - emit mediaStatusChanged(_mediaStatus); - } - emit mediaChanged(_media = content); - } - QIODevice *mediaStream() const { return _stream; } - - void play() { if (_isValid && !_media.isNull() && _state != QMediaPlayer::PlayingState) emit stateChanged(_state = QMediaPlayer::PlayingState); } - void pause() { if (_isValid && !_media.isNull() && _state != QMediaPlayer::PausedState) emit stateChanged(_state = QMediaPlayer::PausedState); } - void stop() { if (_state != QMediaPlayer::StoppedState) emit stateChanged(_state = QMediaPlayer::StoppedState); } - - QMediaPlayer::State _state; - QMediaPlayer::MediaStatus _mediaStatus; - QMediaPlayer::Error _error; - qint64 _duration; - qint64 _position; - int _volume; - bool _muted; - int _bufferStatus; - bool _audioAvailable; - bool _videoAvailable; - bool _isSeekable; - QPair<qint64, qint64> _seekRange; - qreal _playbackRate; - QMediaContent _media; - QIODevice *_stream; - bool _isValid; - QString _errorString; -}; - - -class MockPlayerService : public QMediaService -{ - Q_OBJECT - -public: - MockPlayerService():QMediaService(0) - { - mockControl = new MockPlayerControl; - } - - ~MockPlayerService() - { - delete mockControl; - } - - QMediaControl* control(const char *iid) const - { - if (qstrcmp(iid, QMediaPlayerControl_iid) == 0) - return mockControl; - - return 0; - } - - void setState(QMediaPlayer::State state) { emit mockControl->stateChanged(mockControl->_state = state); } - void setState(QMediaPlayer::State state, QMediaPlayer::MediaStatus status) { - mockControl->_state = state; - mockControl->_mediaStatus = status; - emit mockControl->mediaStatusChanged(status); - emit mockControl->stateChanged(state); - } - void setMediaStatus(QMediaPlayer::MediaStatus status) { emit mockControl->mediaStatusChanged(mockControl->_mediaStatus = status); } - void setIsValid(bool isValid) { mockControl->_isValid = isValid; } - void setMedia(QMediaContent media) { mockControl->_media = media; } - void setDuration(qint64 duration) { mockControl->_duration = duration; } - void setPosition(qint64 position) { mockControl->_position = position; } - void setSeekable(bool seekable) { mockControl->_isSeekable = seekable; } - void setVolume(int volume) { mockControl->_volume = volume; } - void setMuted(bool muted) { mockControl->_muted = muted; } - void setVideoAvailable(bool videoAvailable) { mockControl->_videoAvailable = videoAvailable; } - void setBufferStatus(int bufferStatus) { mockControl->_bufferStatus = bufferStatus; } - void setPlaybackRate(qreal playbackRate) { mockControl->_playbackRate = playbackRate; } - void setError(QMediaPlayer::Error error) { mockControl->_error = error; emit mockControl->error(mockControl->_error, mockControl->_errorString); } - void setErrorString(QString errorString) { mockControl->_errorString = errorString; emit mockControl->error(mockControl->_error, mockControl->_errorString); } - - void reset() - { - mockControl->_state = QMediaPlayer::StoppedState; - mockControl->_mediaStatus = QMediaPlayer::UnknownMediaStatus; - mockControl->_error = QMediaPlayer::NoError; - mockControl->_duration = 0; - mockControl->_position = 0; - mockControl->_volume = 0; - mockControl->_muted = false; - mockControl->_bufferStatus = 0; - mockControl->_videoAvailable = false; - mockControl->_isSeekable = false; - mockControl->_playbackRate = 0.0; - mockControl->_media = QMediaContent(); - mockControl->_stream = 0; - mockControl->_isValid = false; - mockControl->_errorString = QString(); - } - - MockPlayerControl *mockControl; -}; - -class MockProvider : public QMediaServiceProvider -{ -public: - MockProvider(MockPlayerService *service):mockService(service) {} - QMediaService *requestService(const QByteArray &, const QMediaServiceProviderHint &) - { - return mockService; - } - - void releaseService(QMediaService *service) { delete service; } - - MockPlayerService *mockService; -}; - -class tst_QMediaPlayer: public QObject -{ - Q_OBJECT - -public slots: - void initTestCase_data(); - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void testNullService(); - void testValid(); - void testMedia(); - void testDuration(); - void testPosition(); - void testVolume(); - void testMuted(); - void testVideoAvailable(); - void testBufferStatus(); - void testSeekable(); - void testPlaybackRate(); - void testError(); - void testErrorString(); - void testService(); - void testPlay(); - void testPause(); - void testStop(); - void testMediaStatus(); - void testPlaylist(); - -private: - MockProvider *mockProvider; - MockPlayerService *mockService; - QMediaPlayer *player; -}; - -void tst_QMediaPlayer::initTestCase_data() -{ - QTest::addColumn<bool>("valid"); - QTest::addColumn<QMediaPlayer::State>("state"); - QTest::addColumn<QMediaPlayer::MediaStatus>("status"); - QTest::addColumn<QMediaContent>("mediaContent"); - QTest::addColumn<qint64>("duration"); - QTest::addColumn<qint64>("position"); - QTest::addColumn<bool>("seekable"); - QTest::addColumn<int>("volume"); - QTest::addColumn<bool>("muted"); - QTest::addColumn<bool>("videoAvailable"); - QTest::addColumn<int>("bufferStatus"); - QTest::addColumn<qreal>("playbackRate"); - QTest::addColumn<QMediaPlayer::Error>("error"); - QTest::addColumn<QString>("errorString"); - - QTest::newRow("invalid") << false << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus << - QMediaContent() << qint64(0) << qint64(0) << false << 0 << false << false << 0 << - qreal(0) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+null") << true << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus << - QMediaContent() << qint64(0) << qint64(0) << false << 0 << false << false << 50 << - qreal(0) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+content+stopped") << true << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus << - QMediaContent(QUrl("file:///some.mp3")) << qint64(0) << qint64(0) << false << 50 << false << false << 0 << - qreal(1) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+content+playing") << true << QMediaPlayer::PlayingState << QMediaPlayer::LoadedMedia << - QMediaContent(QUrl("file:///some.mp3")) << qint64(10000) << qint64(10) << true << 50 << true << false << 0 << - qreal(1) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+content+paused") << true << QMediaPlayer::PausedState << QMediaPlayer::LoadedMedia << - QMediaContent(QUrl("file:///some.mp3")) << qint64(10000) << qint64(10) << true << 50 << true << false << 0 << - qreal(1) << QMediaPlayer::NoError << QString(); - QTest::newRow("valud+streaming") << true << QMediaPlayer::PlayingState << QMediaPlayer::LoadedMedia << - QMediaContent(QUrl("http://example.com/stream")) << qint64(10000) << qint64(10000) << false << 50 << false << true << 0 << - qreal(1) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+error") << true << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus << - QMediaContent(QUrl("http://example.com/stream")) << qint64(0) << qint64(0) << false << 50 << false << false << 0 << - qreal(0) << QMediaPlayer::ResourceError << QString("Resource unavailable"); -} - -void tst_QMediaPlayer::initTestCase() -{ - qRegisterMetaType<QMediaContent>(); - - mockService = new MockPlayerService; - mockProvider = new MockProvider(mockService); - player = new QMediaPlayer(0, 0, mockProvider); -} - -void tst_QMediaPlayer::cleanupTestCase() -{ - delete player; -} - -void tst_QMediaPlayer::init() -{ - mockService->reset(); -} - -void tst_QMediaPlayer::cleanup() -{ -} - -void tst_QMediaPlayer::testNullService() -{ - MockProvider provider(0); - QMediaPlayer player(0, 0, &provider); - - const QIODevice *nullDevice = 0; - - QCOMPARE(player.media(), QMediaContent()); - QCOMPARE(player.mediaStream(), nullDevice); - QCOMPARE(player.state(), QMediaPlayer::StoppedState); - QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus); - QCOMPARE(player.duration(), qint64(-1)); - QCOMPARE(player.position(), qint64(0)); - QCOMPARE(player.volume(), 0); - QCOMPARE(player.isMuted(), false); - QCOMPARE(player.isVideoAvailable(), false); - QCOMPARE(player.bufferStatus(), 0); - QCOMPARE(player.isSeekable(), false); - QCOMPARE(player.playbackRate(), qreal(0)); - QCOMPARE(player.error(), QMediaPlayer::ServiceMissingError); - - { - QFETCH_GLOBAL(QMediaContent, mediaContent); - - QSignalSpy spy(&player, SIGNAL(mediaChanged(QMediaContent))); - QFile file; - - player.setMedia(mediaContent, &file); - QCOMPARE(player.media(), QMediaContent()); - QCOMPARE(player.mediaStream(), nullDevice); - QCOMPARE(spy.count(), 0); - } { - QSignalSpy stateSpy(&player, SIGNAL(stateChanged(QMediaPlayer::State))); - QSignalSpy statusSpy(&player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - - player.play(); - QCOMPARE(player.state(), QMediaPlayer::StoppedState); - QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - - player.pause(); - QCOMPARE(player.state(), QMediaPlayer::StoppedState); - QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - - player.stop(); - QCOMPARE(player.state(), QMediaPlayer::StoppedState); - QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - } { - QFETCH_GLOBAL(int, volume); - QFETCH_GLOBAL(bool, muted); - - QSignalSpy volumeSpy(&player, SIGNAL(volumeChanged(int))); - QSignalSpy mutingSpy(&player, SIGNAL(mutedChanged(bool))); - - player.setVolume(volume); - QCOMPARE(player.volume(), 0); - QCOMPARE(volumeSpy.count(), 0); - - player.setMuted(muted); - QCOMPARE(player.isMuted(), false); - QCOMPARE(mutingSpy.count(), 0); - } { - QFETCH_GLOBAL(qint64, position); - - QSignalSpy spy(&player, SIGNAL(positionChanged(qint64))); - - player.setPosition(position); - QCOMPARE(player.position(), qint64(0)); - QCOMPARE(spy.count(), 0); - } { - QFETCH_GLOBAL(qreal, playbackRate); - - QSignalSpy spy(&player, SIGNAL(playbackRateChanged(qreal))); - - player.setPlaybackRate(playbackRate); - QCOMPARE(player.playbackRate(), qreal(0)); - QCOMPARE(spy.count(), 0); - } { - QMediaPlaylist playlist; - playlist.setMediaObject(&player); - - QSignalSpy mediaSpy(&player, SIGNAL(mediaChanged(QMediaContent))); - QSignalSpy statusSpy(&player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - - playlist.addMedia(QUrl("http://example.com/stream")); - playlist.addMedia(QUrl("file:///some.mp3")); - - playlist.setCurrentIndex(0); - QCOMPARE(playlist.currentIndex(), 0); - QCOMPARE(player.media(), QMediaContent()); - QCOMPARE(mediaSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - - playlist.next(); - QCOMPARE(playlist.currentIndex(), 1); - QCOMPARE(player.media(), QMediaContent()); - QCOMPARE(mediaSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - } -} - -void tst_QMediaPlayer::testValid() -{ - /* - QFETCH_GLOBAL(bool, valid); - - mockService->setIsValid(valid); - QCOMPARE(player->isValid(), valid); - */ -} - -void tst_QMediaPlayer::testMedia() -{ - QFETCH_GLOBAL(QMediaContent, mediaContent); - - mockService->setMedia(mediaContent); - QCOMPARE(player->media(), mediaContent); - - QBuffer stream; - player->setMedia(mediaContent, &stream); - QCOMPARE(player->media(), mediaContent); - QCOMPARE((QBuffer*)player->mediaStream(), &stream); -} - -void tst_QMediaPlayer::testDuration() -{ - QFETCH_GLOBAL(qint64, duration); - - mockService->setDuration(duration); - QVERIFY(player->duration() == duration); -} - -void tst_QMediaPlayer::testPosition() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(bool, seekable); - QFETCH_GLOBAL(qint64, position); - QFETCH_GLOBAL(qint64, duration); - - mockService->setIsValid(valid); - mockService->setSeekable(seekable); - mockService->setPosition(position); - mockService->setDuration(duration); - QVERIFY(player->isSeekable() == seekable); - QVERIFY(player->position() == position); - QVERIFY(player->duration() == duration); - - if (seekable) { - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(position); - QCOMPARE(player->position(), position); - QCOMPARE(spy.count(), 0); } - - mockService->setPosition(position); - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(0); - QCOMPARE(player->position(), qint64(0)); - QCOMPARE(spy.count(), position == 0 ? 0 : 1); } - - mockService->setPosition(position); - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(duration); - QCOMPARE(player->position(), duration); - QCOMPARE(spy.count(), position == duration ? 0 : 1); } - - mockService->setPosition(position); - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(-1); - QCOMPARE(player->position(), qint64(0)); - QCOMPARE(spy.count(), position == 0 ? 0 : 1); } - - mockService->setPosition(position); - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(duration + 1); - QCOMPARE(player->position(), duration); - QCOMPARE(spy.count(), position == duration ? 0 : 1); } - } - else { - QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(position); - - QCOMPARE(player->position(), position); - QCOMPARE(spy.count(), 0); - } -} - -void tst_QMediaPlayer::testVolume() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(int, volume); - - mockService->setVolume(volume); - QVERIFY(player->volume() == volume); - - if (valid) { - { QSignalSpy spy(player, SIGNAL(volumeChanged(int))); - player->setVolume(10); - QCOMPARE(player->volume(), 10); - QCOMPARE(spy.count(), 1); } - - { QSignalSpy spy(player, SIGNAL(volumeChanged(int))); - player->setVolume(-1000); - QCOMPARE(player->volume(), 0); - QCOMPARE(spy.count(), 1); } - - { QSignalSpy spy(player, SIGNAL(volumeChanged(int))); - player->setVolume(100); - QCOMPARE(player->volume(), 100); - QCOMPARE(spy.count(), 1); } - - { QSignalSpy spy(player, SIGNAL(volumeChanged(int))); - player->setVolume(1000); - QCOMPARE(player->volume(), 100); - QCOMPARE(spy.count(), 0); } - } -} - -void tst_QMediaPlayer::testMuted() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(bool, muted); - QFETCH_GLOBAL(int, volume); - - if (valid) { - mockService->setMuted(muted); - mockService->setVolume(volume); - QVERIFY(player->isMuted() == muted); - - QSignalSpy spy(player, SIGNAL(mutedChanged(bool))); - player->setMuted(!muted); - QCOMPARE(player->isMuted(), !muted); - QCOMPARE(player->volume(), volume); - QCOMPARE(spy.count(), 1); - } -} - -void tst_QMediaPlayer::testVideoAvailable() -{ - QFETCH_GLOBAL(bool, videoAvailable); - - mockService->setVideoAvailable(videoAvailable); - QVERIFY(player->isVideoAvailable() == videoAvailable); -} - -void tst_QMediaPlayer::testBufferStatus() -{ - QFETCH_GLOBAL(int, bufferStatus); - - mockService->setBufferStatus(bufferStatus); - QVERIFY(player->bufferStatus() == bufferStatus); -} - -void tst_QMediaPlayer::testSeekable() -{ - QFETCH_GLOBAL(bool, seekable); - - mockService->setSeekable(seekable); - QVERIFY(player->isSeekable() == seekable); -} - -void tst_QMediaPlayer::testPlaybackRate() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(qreal, playbackRate); - - if (valid) { - mockService->setPlaybackRate(playbackRate); - QVERIFY(player->playbackRate() == playbackRate); - - QSignalSpy spy(player, SIGNAL(playbackRateChanged(qreal))); - player->setPlaybackRate(playbackRate + 0.5f); - QCOMPARE(player->playbackRate(), playbackRate + 0.5f); - QCOMPARE(spy.count(), 1); - } -} - -void tst_QMediaPlayer::testError() -{ - QFETCH_GLOBAL(QMediaPlayer::Error, error); - - mockService->setError(error); - QVERIFY(player->error() == error); -} - -void tst_QMediaPlayer::testErrorString() -{ - QFETCH_GLOBAL(QString, errorString); - - mockService->setErrorString(errorString); - QVERIFY(player->errorString() == errorString); -} - -void tst_QMediaPlayer::testService() -{ - /* - QFETCH_GLOBAL(bool, valid); - - mockService->setIsValid(valid); - - if (valid) - QVERIFY(player->service() != 0); - else - QVERIFY(player->service() == 0); - */ -} - -void tst_QMediaPlayer::testPlay() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(QMediaContent, mediaContent); - QFETCH_GLOBAL(QMediaPlayer::State, state); - - mockService->setIsValid(valid); - mockService->setState(state); - mockService->setMedia(mediaContent); - QVERIFY(player->state() == state); - QVERIFY(player->media() == mediaContent); - - QSignalSpy spy(player, SIGNAL(stateChanged(QMediaPlayer::State))); - - player->play(); - - if (!valid || mediaContent.isNull()) { - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(spy.count(), 0); - } - else { - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(spy.count(), state == QMediaPlayer::PlayingState ? 0 : 1); - } -} - -void tst_QMediaPlayer::testPause() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(QMediaContent, mediaContent); - QFETCH_GLOBAL(QMediaPlayer::State, state); - - mockService->setIsValid(valid); - mockService->setState(state); - mockService->setMedia(mediaContent); - QVERIFY(player->state() == state); - QVERIFY(player->media() == mediaContent); - - QSignalSpy spy(player, SIGNAL(stateChanged(QMediaPlayer::State))); - - player->pause(); - - if (!valid || mediaContent.isNull()) { - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(spy.count(), 0); - } - else { - QCOMPARE(player->state(), QMediaPlayer::PausedState); - QCOMPARE(spy.count(), state == QMediaPlayer::PausedState ? 0 : 1); - } -} - -void tst_QMediaPlayer::testStop() -{ - QFETCH_GLOBAL(QMediaContent, mediaContent); - QFETCH_GLOBAL(QMediaPlayer::State, state); - - mockService->setState(state); - mockService->setMedia(mediaContent); - QVERIFY(player->state() == state); - QVERIFY(player->media() == mediaContent); - - QSignalSpy spy(player, SIGNAL(stateChanged(QMediaPlayer::State))); - - player->stop(); - - if (mediaContent.isNull() || state == QMediaPlayer::StoppedState) { - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(spy.count(), 0); - } - else { - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(spy.count(), 1); - } -} - -void tst_QMediaPlayer::testMediaStatus() -{ - QFETCH_GLOBAL(int, bufferStatus); - int bufferSignals = 0; - - player->setNotifyInterval(10); - - mockService->setMediaStatus(QMediaPlayer::NoMedia); - mockService->setBufferStatus(bufferStatus); - - AutoConnection connection( - player, SIGNAL(bufferStatusChanged(int)), - &QTestEventLoop::instance(), SLOT(exitLoop())); - - QSignalSpy statusSpy(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - QSignalSpy bufferSpy(player, SIGNAL(bufferStatusChanged(int))); - - QCOMPARE(player->mediaStatus(), QMediaPlayer::NoMedia); - - mockService->setMediaStatus(QMediaPlayer::LoadingMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::LoadingMedia); - QCOMPARE(statusSpy.count(), 1); - - QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), - QMediaPlayer::LoadingMedia); - - mockService->setMediaStatus(QMediaPlayer::LoadedMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::LoadedMedia); - QCOMPARE(statusSpy.count(), 2); - - QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), - QMediaPlayer::LoadedMedia); - - // Verify the bufferStatusChanged() signal isn't being emitted. - QTestEventLoop::instance().enterLoop(1); - QCOMPARE(bufferSpy.count(), 0); - - mockService->setMediaStatus(QMediaPlayer::StalledMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::StalledMedia); - QCOMPARE(statusSpy.count(), 3); - - QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), - QMediaPlayer::StalledMedia); - - // Verify the bufferStatusChanged() signal is being emitted. - QTestEventLoop::instance().enterLoop(1); - QVERIFY(bufferSpy.count() > bufferSignals); - QCOMPARE(bufferSpy.last().value(0).toInt(), bufferStatus); - bufferSignals = bufferSpy.count(); - - mockService->setMediaStatus(QMediaPlayer::BufferingMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::BufferingMedia); - QCOMPARE(statusSpy.count(), 4); - - QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), - QMediaPlayer::BufferingMedia); - - // Verify the bufferStatusChanged() signal is being emitted. - QTestEventLoop::instance().enterLoop(1); - QVERIFY(bufferSpy.count() > bufferSignals); - QCOMPARE(bufferSpy.last().value(0).toInt(), bufferStatus); - bufferSignals = bufferSpy.count(); - - mockService->setMediaStatus(QMediaPlayer::BufferedMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::BufferedMedia); - QCOMPARE(statusSpy.count(), 5); - - QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), - QMediaPlayer::BufferedMedia); - - // Verify the bufferStatusChanged() signal isn't being emitted. - QTestEventLoop::instance().enterLoop(1); - QCOMPARE(bufferSpy.count(), bufferSignals); - - mockService->setMediaStatus(QMediaPlayer::EndOfMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::EndOfMedia); - QCOMPARE(statusSpy.count(), 6); - - QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), - QMediaPlayer::EndOfMedia); -} - -void tst_QMediaPlayer::testPlaylist() -{ - QMediaContent content0(QUrl(QLatin1String("test://audio/song1.mp3"))); - QMediaContent content1(QUrl(QLatin1String("test://audio/song2.mp3"))); - QMediaContent content2(QUrl(QLatin1String("test://video/movie1.mp4"))); - QMediaContent content3(QUrl(QLatin1String("test://video/movie2.mp4"))); - QMediaContent content4(QUrl(QLatin1String("test://image/photo.jpg"))); - - mockService->setIsValid(true); - mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::NoMedia); - - QMediaPlaylist *playlist = new QMediaPlaylist; - playlist->setMediaObject(player); - - QSignalSpy stateSpy(player, SIGNAL(stateChanged(QMediaPlayer::State))); - QSignalSpy mediaSpy(player, SIGNAL(mediaChanged(QMediaContent))); - - // Test the player does nothing with an empty playlist attached. - player->play(); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(mediaSpy.count(), 0); - - playlist->addMedia(content0); - playlist->addMedia(content1); - playlist->addMedia(content2); - playlist->addMedia(content3); - - // Test changing the playlist position, changes the current media, but not the playing state. - playlist->setCurrentIndex(1); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(mediaSpy.count(), 1); - - // Test playing starts with the current media. - player->play(); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 1); - QCOMPARE(mediaSpy.count(), 1); - - // Test pausing doesn't change the current media. - player->pause(); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::PausedState); - QCOMPARE(stateSpy.count(), 2); - QCOMPARE(mediaSpy.count(), 1); - - // Test stopping doesn't change the current media. - player->stop(); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 3); - QCOMPARE(mediaSpy.count(), 1); - - // Test when the player service reaches the end of the current media, the player moves onto - // the next item without stopping. - player->play(); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 4); - QCOMPARE(mediaSpy.count(), 1); - - mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::EndOfMedia); - QCOMPARE(player->media(), content2); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 4); - QCOMPARE(mediaSpy.count(), 2); - - // Test skipping the current media doesn't change the state. - playlist->next(); - QCOMPARE(player->media(), content3); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 4); - QCOMPARE(mediaSpy.count(), 3); - - // Test changing the current media while paused doesn't change the state. - player->pause(); - mockService->setMediaStatus(QMediaPlayer::BufferedMedia); - QCOMPARE(player->media(), content3); - QCOMPARE(player->state(), QMediaPlayer::PausedState); - QCOMPARE(stateSpy.count(), 5); - QCOMPARE(mediaSpy.count(), 3); - - playlist->previous(); - QCOMPARE(player->media(), content2); - QCOMPARE(player->state(), QMediaPlayer::PausedState); - QCOMPARE(stateSpy.count(), 5); - QCOMPARE(mediaSpy.count(), 4); - - // Test changing the current media while stopped doesn't change the state. - player->stop(); - mockService->setMediaStatus(QMediaPlayer::LoadedMedia); - QCOMPARE(player->media(), content2); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 6); - QCOMPARE(mediaSpy.count(), 4); - - playlist->next(); - QCOMPARE(player->media(), content3); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 6); - QCOMPARE(mediaSpy.count(), 5); - - // Test the player is stopped and the current media cleared when it reaches the end of the last - // item in the playlist. - player->play(); - QCOMPARE(player->media(), content3); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 7); - QCOMPARE(mediaSpy.count(), 5); - - // Double up the signals to ensure some noise doesn't destabalize things. - mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::EndOfMedia); - mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::EndOfMedia); - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 8); - QCOMPARE(mediaSpy.count(), 6); - - // Test starts playing from the start of the playlist if there is no current media selected. - player->play(); - QCOMPARE(player->media(), content0); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 9); - QCOMPARE(mediaSpy.count(), 7); - - // Test deleting the playlist stops the player and clears the media it set. - delete playlist; - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 10); - QCOMPARE(mediaSpy.count(), 8); - - // Test the player works as normal with the playlist removed. - player->play(); - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 10); - QCOMPARE(mediaSpy.count(), 8); - - player->setMedia(content1); - player->play(); - - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 11); - QCOMPARE(mediaSpy.count(), 9); - - // Test the player can bind to playlist again - playlist = new QMediaPlaylist; - playlist->setMediaObject(player); - QCOMPARE(playlist->mediaObject(), qobject_cast<QMediaObject*>(player)); - - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - - playlist->addMedia(content0); - playlist->addMedia(content1); - playlist->addMedia(content2); - playlist->addMedia(content3); - - playlist->setCurrentIndex(1); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - - // Test attaching the new playlist, - // player should detach the current one - QMediaPlaylist *playlist2 = new QMediaPlaylist; - playlist2->addMedia(content1); - playlist2->addMedia(content2); - playlist2->addMedia(content3); - playlist2->setCurrentIndex(2); - - player->play(); - playlist2->setMediaObject(player); - QCOMPARE(playlist2->mediaObject(), qobject_cast<QMediaObject*>(player)); - QVERIFY(playlist->mediaObject() == 0); - QCOMPARE(player->media(), playlist2->currentMedia()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - - playlist2->setCurrentIndex(1); - QCOMPARE(player->media(), playlist2->currentMedia()); -} - -QTEST_MAIN(tst_QMediaPlayer) - -#include "tst_qmediaplayer.moc" diff --git a/tests/auto/qmediaplaylist/qmediaplaylist.pro b/tests/auto/qmediaplaylist/qmediaplaylist.pro deleted file mode 100644 index 809473b..0000000 --- a/tests/auto/qmediaplaylist/qmediaplaylist.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaplaylist.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediaplaylist/tmp.unsupported_format b/tests/auto/qmediaplaylist/tmp.unsupported_format deleted file mode 100644 index e69de29..0000000 --- a/tests/auto/qmediaplaylist/tmp.unsupported_format +++ /dev/null diff --git a/tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp b/tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp deleted file mode 100644 index 1037f37..0000000 --- a/tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp +++ /dev/null @@ -1,593 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> -#include <QDebug> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmediaplaylist.h> -#include <QtMediaServices/qmediaplaylistcontrol.h> -#include <QtMediaServices/qmediaplaylistnavigator.h> -#include <QtMediaServices/private/qmediapluginloader_p.h> - - -class MockReadOnlyPlaylistProvider : public QMediaPlaylistProvider -{ - Q_OBJECT -public: - MockReadOnlyPlaylistProvider(QObject *parent) - :QMediaPlaylistProvider(parent) - { - m_items.append(QMediaContent(QUrl(QLatin1String("file:///1")))); - m_items.append(QMediaContent(QUrl(QLatin1String("file:///2")))); - m_items.append(QMediaContent(QUrl(QLatin1String("file:///3")))); - } - - int mediaCount() const { return m_items.size(); } - QMediaContent media(int index) const - { - return index >=0 && index < mediaCount() ? m_items.at(index) : QMediaContent(); - } - -private: - QList<QMediaContent> m_items; -}; - -class MockPlaylistControl : public QMediaPlaylistControl -{ - Q_OBJECT -public: - MockPlaylistControl(QObject *parent) : QMediaPlaylistControl(parent) - { - m_navigator = new QMediaPlaylistNavigator(new MockReadOnlyPlaylistProvider(this), this); - } - - ~MockPlaylistControl() - { - } - - QMediaPlaylistProvider* playlistProvider() const { return m_navigator->playlist(); } - bool setPlaylistProvider(QMediaPlaylistProvider *playlist) { m_navigator->setPlaylist(playlist); return true; } - - int currentIndex() const { return m_navigator->currentIndex(); } - void setCurrentIndex(int position) { m_navigator->jump(position); } - int nextIndex(int steps) const { return m_navigator->nextIndex(steps); } - int previousIndex(int steps) const { return m_navigator->previousIndex(steps); } - - void next() { m_navigator->next(); } - void previous() { m_navigator->previous(); } - - QMediaPlaylist::PlaybackMode playbackMode() const { return m_navigator->playbackMode(); } - void setPlaybackMode(QMediaPlaylist::PlaybackMode mode) { m_navigator->setPlaybackMode(mode); } - -private: - QMediaPlaylistNavigator *m_navigator; -}; - -class MockPlaylistService : public QMediaService -{ - Q_OBJECT - -public: - MockPlaylistService():QMediaService(0) - { - mockControl = new MockPlaylistControl(this); - } - - ~MockPlaylistService() - { - } - - QMediaControl* control(const char *iid) const - { - if (qstrcmp(iid, QMediaPlaylistControl_iid) == 0) - return mockControl; - return 0; - } - - MockPlaylistControl *mockControl; -}; - -class MockReadOnlyPlaylistObject : public QMediaObject -{ - Q_OBJECT -public: - MockReadOnlyPlaylistObject(QObject *parent = 0) - :QMediaObject(parent, new MockPlaylistService) - { - } -}; - - -class tst_QMediaPlaylist : public QObject -{ - Q_OBJECT -public slots: - void init(); - void cleanup(); - void initTestCase(); - -private slots: - void construction(); - void append(); - void insert(); - void clear(); - void removeMedia(); - void currentItem(); - void saveAndLoad(); - void playbackMode(); - void playbackMode_data(); - void shuffle(); - void readOnlyPlaylist(); - void setMediaObject(); - -private: - QMediaContent content1; - QMediaContent content2; - QMediaContent content3; -}; - -void tst_QMediaPlaylist::init() -{ -} - -void tst_QMediaPlaylist::initTestCase() -{ - content1 = QMediaContent(QUrl(QLatin1String("file:///1"))); - content2 = QMediaContent(QUrl(QLatin1String("file:///2"))); - content3 = QMediaContent(QUrl(QLatin1String("file:///3"))); -} - -void tst_QMediaPlaylist::cleanup() -{ -} - -void tst_QMediaPlaylist::construction() -{ - QMediaPlaylist playlist; - QCOMPARE(playlist.mediaCount(), 0); - QVERIFY(playlist.isEmpty()); -} - -void tst_QMediaPlaylist::append() -{ - QMediaPlaylist playlist; - QVERIFY(!playlist.isReadOnly()); - - playlist.addMedia(content1); - QCOMPARE(playlist.mediaCount(), 1); - QCOMPARE(playlist.media(0), content1); - - QSignalSpy aboutToBeInsertedSignalSpy(&playlist, SIGNAL(mediaAboutToBeInserted(int,int))); - QSignalSpy insertedSignalSpy(&playlist, SIGNAL(mediaInserted(int,int))); - playlist.addMedia(content2); - QCOMPARE(playlist.mediaCount(), 2); - QCOMPARE(playlist.media(1), content2); - - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy.first()[1].toInt(), 1); - - QCOMPARE(insertedSignalSpy.count(), 1); - QCOMPARE(insertedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(insertedSignalSpy.first()[1].toInt(), 1); - - aboutToBeInsertedSignalSpy.clear(); - insertedSignalSpy.clear(); - - QMediaContent content4(QUrl(QLatin1String("file:///4"))); - QMediaContent content5(QUrl(QLatin1String("file:///5"))); - playlist.addMedia(QList<QMediaContent>() << content3 << content4 << content5); - QCOMPARE(playlist.mediaCount(), 5); - QCOMPARE(playlist.media(2), content3); - QCOMPARE(playlist.media(3), content4); - QCOMPARE(playlist.media(4), content5); - - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy[0][0].toInt(), 2); - QCOMPARE(aboutToBeInsertedSignalSpy[0][1].toInt(), 4); - - QCOMPARE(insertedSignalSpy.count(), 1); - QCOMPARE(insertedSignalSpy[0][0].toInt(), 2); - QCOMPARE(insertedSignalSpy[0][1].toInt(), 4); - - aboutToBeInsertedSignalSpy.clear(); - insertedSignalSpy.clear(); - - playlist.addMedia(QList<QMediaContent>()); - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 0); - QCOMPARE(insertedSignalSpy.count(), 0); -} - -void tst_QMediaPlaylist::insert() -{ - QMediaPlaylist playlist; - QVERIFY(!playlist.isReadOnly()); - - playlist.addMedia(content1); - QCOMPARE(playlist.mediaCount(), 1); - QCOMPARE(playlist.media(0), content1); - - playlist.addMedia(content2); - QCOMPARE(playlist.mediaCount(), 2); - QCOMPARE(playlist.media(1), content2); - - QSignalSpy aboutToBeInsertedSignalSpy(&playlist, SIGNAL(mediaAboutToBeInserted(int,int))); - QSignalSpy insertedSignalSpy(&playlist, SIGNAL(mediaInserted(int,int))); - - playlist.insertMedia(1, content3); - QCOMPARE(playlist.mediaCount(), 3); - QCOMPARE(playlist.media(0), content1); - QCOMPARE(playlist.media(1), content3); - QCOMPARE(playlist.media(2), content2); - - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy.first()[1].toInt(), 1); - - QCOMPARE(insertedSignalSpy.count(), 1); - QCOMPARE(insertedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(insertedSignalSpy.first()[1].toInt(), 1); - - aboutToBeInsertedSignalSpy.clear(); - insertedSignalSpy.clear(); - - QMediaContent content4(QUrl(QLatin1String("file:///4"))); - QMediaContent content5(QUrl(QLatin1String("file:///5"))); - playlist.insertMedia(1, QList<QMediaContent>() << content4 << content5); - - QCOMPARE(playlist.media(0), content1); - QCOMPARE(playlist.media(1), content4); - QCOMPARE(playlist.media(2), content5); - QCOMPARE(playlist.media(3), content3); - QCOMPARE(playlist.media(4), content2); - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy[0][0].toInt(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy[0][1].toInt(), 2); - - QCOMPARE(insertedSignalSpy.count(), 1); - QCOMPARE(insertedSignalSpy[0][0].toInt(), 1); - QCOMPARE(insertedSignalSpy[0][1].toInt(), 2); - - aboutToBeInsertedSignalSpy.clear(); - insertedSignalSpy.clear(); - - playlist.insertMedia(1, QList<QMediaContent>()); - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 0); - QCOMPARE(insertedSignalSpy.count(), 0); -} - - -void tst_QMediaPlaylist::currentItem() -{ - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - - QCOMPARE(playlist.currentIndex(), -1); - QCOMPARE(playlist.currentMedia(), QMediaContent()); - - QCOMPARE(playlist.nextIndex(), 0); - QCOMPARE(playlist.nextIndex(2), 1); - QCOMPARE(playlist.previousIndex(), 1); - QCOMPARE(playlist.previousIndex(2), 0); - - playlist.setCurrentIndex(0); - QCOMPARE(playlist.currentIndex(), 0); - QCOMPARE(playlist.currentMedia(), content1); - - QCOMPARE(playlist.nextIndex(), 1); - QCOMPARE(playlist.nextIndex(2), -1); - QCOMPARE(playlist.previousIndex(), -1); - QCOMPARE(playlist.previousIndex(2), -1); - - playlist.setCurrentIndex(1); - QCOMPARE(playlist.currentIndex(), 1); - QCOMPARE(playlist.currentMedia(), content2); - - QCOMPARE(playlist.nextIndex(), -1); - QCOMPARE(playlist.nextIndex(2), -1); - QCOMPARE(playlist.previousIndex(), 0); - QCOMPARE(playlist.previousIndex(2), -1); - - QTest::ignoreMessage(QtWarningMsg, "QMediaPlaylistNavigator: Jump outside playlist range "); - playlist.setCurrentIndex(2); - - QCOMPARE(playlist.currentIndex(), -1); - QCOMPARE(playlist.currentMedia(), QMediaContent()); -} - -void tst_QMediaPlaylist::clear() -{ - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - - playlist.clear(); - QVERIFY(playlist.isEmpty()); - QCOMPARE(playlist.mediaCount(), 0); -} - -void tst_QMediaPlaylist::removeMedia() -{ - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - playlist.addMedia(content3); - - QSignalSpy aboutToBeRemovedSignalSpy(&playlist, SIGNAL(mediaAboutToBeRemoved(int,int))); - QSignalSpy removedSignalSpy(&playlist, SIGNAL(mediaRemoved(int,int))); - playlist.removeMedia(1); - QCOMPARE(playlist.mediaCount(), 2); - QCOMPARE(playlist.media(1), content3); - - QCOMPARE(aboutToBeRemovedSignalSpy.count(), 1); - QCOMPARE(aboutToBeRemovedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(aboutToBeRemovedSignalSpy.first()[1].toInt(), 1); - - QCOMPARE(removedSignalSpy.count(), 1); - QCOMPARE(removedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(removedSignalSpy.first()[1].toInt(), 1); - - aboutToBeRemovedSignalSpy.clear(); - removedSignalSpy.clear(); - - playlist.removeMedia(0,1); - QVERIFY(playlist.isEmpty()); - - QCOMPARE(aboutToBeRemovedSignalSpy.count(), 1); - QCOMPARE(aboutToBeRemovedSignalSpy.first()[0].toInt(), 0); - QCOMPARE(aboutToBeRemovedSignalSpy.first()[1].toInt(), 1); - - QCOMPARE(removedSignalSpy.count(), 1); - QCOMPARE(removedSignalSpy.first()[0].toInt(), 0); - QCOMPARE(removedSignalSpy.first()[1].toInt(), 1); - - - playlist.addMedia(content1); - playlist.addMedia(content2); - playlist.addMedia(content3); - - playlist.removeMedia(0,1); - QCOMPARE(playlist.mediaCount(), 1); - QCOMPARE(playlist.media(0), content3); -} - -void tst_QMediaPlaylist::saveAndLoad() -{ - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - playlist.addMedia(content3); - - QCOMPARE(playlist.error(), QMediaPlaylist::NoError); - QVERIFY(playlist.errorString().isEmpty()); - - QBuffer buffer; - buffer.open(QBuffer::ReadWrite); - - bool res = playlist.save(&buffer, "unsupported_format"); - QVERIFY(!res); - QVERIFY(playlist.error() != QMediaPlaylist::NoError); - QVERIFY(!playlist.errorString().isEmpty()); - - QSignalSpy errorSignal(&playlist, SIGNAL(loadFailed())); - playlist.load(&buffer, "unsupported_format"); - QCOMPARE(errorSignal.size(), 1); - QVERIFY(playlist.error() != QMediaPlaylist::NoError); - QVERIFY(!playlist.errorString().isEmpty()); - - res = playlist.save(QUrl(QLatin1String("tmp.unsupported_format")), "unsupported_format"); - QVERIFY(!res); - QVERIFY(playlist.error() != QMediaPlaylist::NoError); - QVERIFY(!playlist.errorString().isEmpty()); - - errorSignal.clear(); - playlist.load(QUrl(QLatin1String("tmp.unsupported_format")), "unsupported_format"); - QCOMPARE(errorSignal.size(), 1); - QVERIFY(playlist.error() != QMediaPlaylist::NoError); - QVERIFY(!playlist.errorString().isEmpty()); -} - -void tst_QMediaPlaylist::playbackMode_data() -{ - QTest::addColumn<QMediaPlaylist::PlaybackMode>("playbackMode"); - QTest::addColumn<int>("expectedPrevious"); - QTest::addColumn<int>("pos"); - QTest::addColumn<int>("expectedNext"); - - QTest::newRow("Linear, 0") << QMediaPlaylist::Linear << -1 << 0 << 1; - QTest::newRow("Linear, 1") << QMediaPlaylist::Linear << 0 << 1 << 2; - QTest::newRow("Linear, 2") << QMediaPlaylist::Linear << 1 << 2 << -1; - - QTest::newRow("Loop, 0") << QMediaPlaylist::Loop << 2 << 0 << 1; - QTest::newRow("Loop, 1") << QMediaPlaylist::Loop << 0 << 1 << 2; - QTest::newRow("Lopp, 2") << QMediaPlaylist::Loop << 1 << 2 << 0; - - QTest::newRow("ItemOnce, 1") << QMediaPlaylist::CurrentItemOnce << -1 << 1 << -1; - QTest::newRow("ItemInLoop, 1") << QMediaPlaylist::CurrentItemInLoop << 1 << 1 << 1; - -} - -void tst_QMediaPlaylist::playbackMode() -{ - QFETCH(QMediaPlaylist::PlaybackMode, playbackMode); - QFETCH(int, expectedPrevious); - QFETCH(int, pos); - QFETCH(int, expectedNext); - - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - playlist.addMedia(content3); - - QCOMPARE(playlist.playbackMode(), QMediaPlaylist::Linear); - QCOMPARE(playlist.currentIndex(), -1); - - playlist.setPlaybackMode(playbackMode); - QCOMPARE(playlist.playbackMode(), playbackMode); - - playlist.setCurrentIndex(pos); - QCOMPARE(playlist.currentIndex(), pos); - QCOMPARE(playlist.nextIndex(), expectedNext); - QCOMPARE(playlist.previousIndex(), expectedPrevious); - - playlist.next(); - QCOMPARE(playlist.currentIndex(), expectedNext); - - playlist.setCurrentIndex(pos); - playlist.previous(); - QCOMPARE(playlist.currentIndex(), expectedPrevious); -} - -void tst_QMediaPlaylist::shuffle() -{ - QMediaPlaylist playlist; - QList<QMediaContent> contentList; - - for (int i=0; i<100; i++) { - QMediaContent content(QUrl(QString::number(i))); - contentList.append(content); - playlist.addMedia(content); - } - - playlist.shuffle(); - - QList<QMediaContent> shuffledContentList; - for (int i=0; i<playlist.mediaCount(); i++) - shuffledContentList.append(playlist.media(i)); - - QVERIFY(contentList != shuffledContentList); - -} - -void tst_QMediaPlaylist::readOnlyPlaylist() -{ - MockReadOnlyPlaylistObject mediaObject; - QMediaPlaylist playlist; - playlist.setMediaObject(&mediaObject); - - QVERIFY(playlist.isReadOnly()); - QVERIFY(!playlist.isEmpty()); - QCOMPARE(playlist.mediaCount(), 3); - - QCOMPARE(playlist.media(0), content1); - QCOMPARE(playlist.media(1), content2); - QCOMPARE(playlist.media(2), content3); - QCOMPARE(playlist.media(3), QMediaContent()); - - //it's a read only playlist, so all the modification should fail - QVERIFY(!playlist.addMedia(content1)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.addMedia(QList<QMediaContent>() << content1 << content2)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.insertMedia(1, content1)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.insertMedia(1, QList<QMediaContent>() << content1 << content2)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.removeMedia(1)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.removeMedia(0,2)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.clear()); - QCOMPARE(playlist.mediaCount(), 3); - - //but it is still allowed to append/insert an empty list - QVERIFY(playlist.addMedia(QList<QMediaContent>())); - QVERIFY(playlist.insertMedia(1, QList<QMediaContent>())); - - playlist.shuffle(); - //it's still the same - QCOMPARE(playlist.media(0), content1); - QCOMPARE(playlist.media(1), content2); - QCOMPARE(playlist.media(2), content3); - QCOMPARE(playlist.media(3), QMediaContent()); - - - //load to read only playlist should fail, - //unless underlaying provider supports it - QBuffer buffer; - buffer.open(QBuffer::ReadWrite); - buffer.write(QByteArray("file:///1\nfile:///2")); - buffer.seek(0); - - QSignalSpy errorSignal(&playlist, SIGNAL(loadFailed())); - playlist.load(&buffer, "m3u"); - QCOMPARE(errorSignal.size(), 1); - QCOMPARE(playlist.error(), QMediaPlaylist::AccessDeniedError); - QVERIFY(!playlist.errorString().isEmpty()); - QCOMPARE(playlist.mediaCount(), 3); - - errorSignal.clear(); - playlist.load(QUrl(QLatin1String("tmp.m3u")), "m3u"); - - QCOMPARE(errorSignal.size(), 1); - QCOMPARE(playlist.error(), QMediaPlaylist::AccessDeniedError); - QVERIFY(!playlist.errorString().isEmpty()); - QCOMPARE(playlist.mediaCount(), 3); -} - -void tst_QMediaPlaylist::setMediaObject() -{ - MockReadOnlyPlaylistObject mediaObject; - - QMediaPlaylist playlist; - QVERIFY(playlist.mediaObject() == 0); - QVERIFY(!playlist.isReadOnly()); - - playlist.setMediaObject(&mediaObject); - QCOMPARE(playlist.mediaObject(), qobject_cast<QMediaObject*>(&mediaObject)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(playlist.isReadOnly()); - - playlist.setMediaObject(0); - QVERIFY(playlist.mediaObject() == 0); - QCOMPARE(playlist.mediaCount(), 0); - QVERIFY(!playlist.isReadOnly()); - - playlist.setMediaObject(&mediaObject); - QCOMPARE(playlist.mediaObject(), qobject_cast<QMediaObject*>(&mediaObject)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(playlist.isReadOnly()); -} - -QTEST_MAIN(tst_QMediaPlaylist) -#include "tst_qmediaplaylist.moc" - diff --git a/tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro b/tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro deleted file mode 100644 index 3265762..0000000 --- a/tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaplaylistnavigator.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp b/tests/auto/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp deleted file mode 100644 index 04f736c..0000000 --- a/tests/auto/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp +++ /dev/null @@ -1,316 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> -#include <QDebug> -#include <QtMediaServices/qlocalmediaplaylistprovider.h> -#include <QtMediaServices/qmediaplaylistnavigator.h> - - -class tst_QMediaPlaylistNavigator : public QObject -{ - Q_OBJECT -public slots: - void init(); - void cleanup(); - -private slots: - void construction(); - void setPlaylist(); - void linearPlayback(); - void loopPlayback(); - void currentItemOnce(); - void currentItemInLoop(); - void randomPlayback(); -}; - -void tst_QMediaPlaylistNavigator::init() -{ -} - -void tst_QMediaPlaylistNavigator::cleanup() -{ -} - -void tst_QMediaPlaylistNavigator::construction() -{ - QLocalMediaPlaylistProvider playlist; - QCOMPARE(playlist.mediaCount(), 0); - - QMediaPlaylistNavigator navigator(&playlist); - QVERIFY(navigator.currentItem().isNull()); - QCOMPARE(navigator.currentIndex(), -1); -} - -void tst_QMediaPlaylistNavigator::setPlaylist() -{ - QMediaPlaylistNavigator navigator(0); - QVERIFY(navigator.playlist() != 0); - QCOMPARE(navigator.playlist()->mediaCount(), 0); - QCOMPARE(navigator.playlist()->media(0), QMediaContent()); - QVERIFY(navigator.playlist()->isReadOnly() ); - - QLocalMediaPlaylistProvider playlist; - QCOMPARE(playlist.mediaCount(), 0); - - navigator.setPlaylist(&playlist); - QCOMPARE(navigator.playlist(), (QMediaPlaylistProvider*)&playlist); - QCOMPARE(navigator.playlist()->mediaCount(), 0); - QVERIFY(!navigator.playlist()->isReadOnly() ); -} - -void tst_QMediaPlaylistNavigator::linearPlayback() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::Linear); - QTest::ignoreMessage(QtWarningMsg, "QMediaPlaylistNavigator: Jump outside playlist range "); - navigator.jump(0);//it's ok to have warning here - QVERIFY(navigator.currentItem().isNull()); - QCOMPARE(navigator.currentIndex(), -1); - - QMediaContent content1(QUrl(QLatin1String("file:///1"))); - playlist.addMedia(content1); - navigator.jump(0); - QVERIFY(!navigator.currentItem().isNull()); - - QCOMPARE(navigator.currentIndex(), 0); - QCOMPARE(navigator.currentItem(), content1); - QCOMPARE(navigator.nextItem(), QMediaContent()); - QCOMPARE(navigator.nextItem(2), QMediaContent()); - QCOMPARE(navigator.previousItem(), QMediaContent()); - QCOMPARE(navigator.previousItem(2), QMediaContent()); - - QMediaContent content2(QUrl(QLatin1String("file:///2"))); - playlist.addMedia(content2); - QCOMPARE(navigator.currentIndex(), 0); - QCOMPARE(navigator.currentItem(), content1); - QCOMPARE(navigator.nextItem(), content2); - QCOMPARE(navigator.nextItem(2), QMediaContent()); - QCOMPARE(navigator.previousItem(), QMediaContent()); - QCOMPARE(navigator.previousItem(2), QMediaContent()); - - navigator.jump(1); - QCOMPARE(navigator.currentIndex(), 1); - QCOMPARE(navigator.currentItem(), content2); - QCOMPARE(navigator.nextItem(), QMediaContent()); - QCOMPARE(navigator.nextItem(2), QMediaContent()); - QCOMPARE(navigator.previousItem(), content1); - QCOMPARE(navigator.previousItem(2), QMediaContent()); - - navigator.jump(0); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.next();//jump to the first item - QCOMPARE(navigator.currentIndex(), 0); - - navigator.previous(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.previous();//jump to the last item - QCOMPARE(navigator.currentIndex(), 1); -} - -void tst_QMediaPlaylistNavigator::loopPlayback() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::Loop); - QTest::ignoreMessage(QtWarningMsg, "QMediaPlaylistNavigator: Jump outside playlist range "); - navigator.jump(0); - QVERIFY(navigator.currentItem().isNull()); - QCOMPARE(navigator.currentIndex(), -1); - - QMediaContent content1(QUrl(QLatin1String("file:///1"))); - playlist.addMedia(content1); - navigator.jump(0); - QVERIFY(!navigator.currentItem().isNull()); - - QCOMPARE(navigator.currentIndex(), 0); - QCOMPARE(navigator.currentItem(), content1); - QCOMPARE(navigator.nextItem(), content1); - QCOMPARE(navigator.nextItem(2), content1); - QCOMPARE(navigator.previousItem(), content1); - QCOMPARE(navigator.previousItem(2), content1); - - QMediaContent content2(QUrl(QLatin1String("file:///2"))); - playlist.addMedia(content2); - QCOMPARE(navigator.currentIndex(), 0); - QCOMPARE(navigator.currentItem(), content1); - QCOMPARE(navigator.nextItem(), content2); - QCOMPARE(navigator.nextItem(2), content1); //loop over end of the list - QCOMPARE(navigator.previousItem(), content2); - QCOMPARE(navigator.previousItem(2), content1); - - navigator.jump(1); - QCOMPARE(navigator.currentIndex(), 1); - QCOMPARE(navigator.currentItem(), content2); - QCOMPARE(navigator.nextItem(), content1); - QCOMPARE(navigator.nextItem(2), content2); - QCOMPARE(navigator.previousItem(), content1); - QCOMPARE(navigator.previousItem(2), content2); - - navigator.jump(0); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 0); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), 0); -} - -void tst_QMediaPlaylistNavigator::currentItemOnce() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::CurrentItemOnce); - - QCOMPARE(navigator.playbackMode(), QMediaPlaylist::CurrentItemOnce); - QCOMPARE(navigator.currentIndex(), -1); - - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3")))); - - QCOMPARE(navigator.currentIndex(), -1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - - navigator.jump(1); - QCOMPARE(navigator.currentIndex(), 1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.jump(1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), -1); -} - -void tst_QMediaPlaylistNavigator::currentItemInLoop() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::CurrentItemInLoop); - - QCOMPARE(navigator.playbackMode(), QMediaPlaylist::CurrentItemInLoop); - QCOMPARE(navigator.currentIndex(), -1); - - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3")))); - - QCOMPARE(navigator.currentIndex(), -1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.jump(1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), 1); -} - -void tst_QMediaPlaylistNavigator::randomPlayback() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::Random); - - QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random); - QCOMPARE(navigator.currentIndex(), -1); - - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3")))); - - playlist.shuffle(); - - QCOMPARE(navigator.currentIndex(), -1); - navigator.next(); - int pos1 = navigator.currentIndex(); - navigator.next(); - int pos2 = navigator.currentIndex(); - navigator.next(); - int pos3 = navigator.currentIndex(); - - QVERIFY(pos1 != -1); - QVERIFY(pos2 != -1); - QVERIFY(pos3 != -1); - - navigator.previous(); - QCOMPARE(navigator.currentIndex(), pos2); - navigator.next(); - QCOMPARE(navigator.currentIndex(), pos3); - navigator.next(); - int pos4 = navigator.currentIndex(); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), pos3); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), pos2); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), pos1); - navigator.previous(); - int pos0 = navigator.currentIndex(); - QVERIFY(pos0 != -1); - navigator.next(); - navigator.next(); - navigator.next(); - navigator.next(); - QCOMPARE(navigator.currentIndex(), pos4); - -} - -QTEST_MAIN(tst_QMediaPlaylistNavigator) -#include "tst_qmediaplaylistnavigator.moc" diff --git a/tests/auto/qmediapluginloader/qmediapluginloader.pro b/tests/auto/qmediapluginloader/qmediapluginloader.pro deleted file mode 100644 index a47cc57..0000000 --- a/tests/auto/qmediapluginloader/qmediapluginloader.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediapluginloader.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediapluginloader/tst_qmediapluginloader.cpp b/tests/auto/qmediapluginloader/tst_qmediapluginloader.cpp deleted file mode 100644 index 001e68a..0000000 --- a/tests/auto/qmediapluginloader/tst_qmediapluginloader.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> -#include <QDebug> - -#include <QtMediaServices/private/qmediapluginloader_p.h> -#include <QtMediaServices/qmediaserviceproviderplugin.h> - - - -class tst_QMediaPluginLoader : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - -private slots: - void testInstance(); - void testInstances(); - void testInvalidKey(); - -private: - QMediaPluginLoader *loader; -}; - -void tst_QMediaPluginLoader::initTestCase() -{ - loader = new QMediaPluginLoader(QMediaServiceProviderFactoryInterface_iid, - QLatin1String("/mediaservice"), - Qt::CaseInsensitive); -} - -void tst_QMediaPluginLoader::cleanupTestCase() -{ - delete loader; -} - -void tst_QMediaPluginLoader::testInstance() -{ - const QStringList keys = loader->keys(); - - if (keys.isEmpty()) // Test is invalidated, skip. - QSKIP("No plug-ins available", SkipAll); - - foreach (const QString &key, keys) - QVERIFY(loader->instance(key) != 0); -} - -void tst_QMediaPluginLoader::testInstances() -{ - const QStringList keys = loader->keys(); - - if (keys.isEmpty()) // Test is invalidated, skip. - QSKIP("No plug-ins available", SkipAll); - - foreach (const QString &key, keys) - QVERIFY(loader->instances(key).size() > 0); -} - -// Last so as to not interfere with the other tests if there is a failure. -void tst_QMediaPluginLoader::testInvalidKey() -{ - const QString key(QLatin1String("invalid-key")); - - // This test assumes there is no 'invalid-key' in the key list, verify that. - if (loader->keys().contains(key)) - QSKIP("a plug-in includes the invalid key", SkipAll); - - QVERIFY(loader->instance(key) == 0); - - // Test looking up the key hasn't inserted it into the list. See QMap::operator[]. - QVERIFY(!loader->keys().contains(key)); - - QVERIFY(loader->instances(key).isEmpty()); - QVERIFY(!loader->keys().contains(key)); -} - -QTEST_MAIN(tst_QMediaPluginLoader) - -#include "tst_qmediapluginloader.moc" diff --git a/tests/auto/qmediaresource/qmediaresource.pro b/tests/auto/qmediaresource/qmediaresource.pro deleted file mode 100644 index 64669a2..0000000 --- a/tests/auto/qmediaresource/qmediaresource.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaresource.cpp - -QT = core mediaservices network - diff --git a/tests/auto/qmediaresource/tst_qmediaresource.cpp b/tests/auto/qmediaresource/tst_qmediaresource.cpp deleted file mode 100644 index 984cfef..0000000 --- a/tests/auto/qmediaresource/tst_qmediaresource.cpp +++ /dev/null @@ -1,516 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> - -#include <QtMediaServices/qmediaresource.h> - - -class tst_QMediaResource : public QObject -{ - Q_OBJECT -private slots: - void constructNull(); - void construct_data(); - void construct(); - void setResolution(); - void equality(); - void copy(); - void assign(); -}; - -void tst_QMediaResource::constructNull() -{ - QMediaResource resource; - - QCOMPARE(resource.isNull(), true); - QCOMPARE(resource.url(), QUrl()); - QCOMPARE(resource.request(), QNetworkRequest()); - QCOMPARE(resource.mimeType(), QString()); - QCOMPARE(resource.language(), QString()); - QCOMPARE(resource.audioCodec(), QString()); - QCOMPARE(resource.videoCodec(), QString()); - QCOMPARE(resource.dataSize(), qint64(0)); - QCOMPARE(resource.audioBitRate(), 0); - QCOMPARE(resource.sampleRate(), 0); - QCOMPARE(resource.channelCount(), 0); - QCOMPARE(resource.videoBitRate(), 0); - QCOMPARE(resource.resolution(), QSize()); -} - -void tst_QMediaResource::construct_data() -{ - QTest::addColumn<QUrl>("url"); - QTest::addColumn<QNetworkRequest>("request"); - QTest::addColumn<QString>("mimeType"); - QTest::addColumn<QString>("language"); - QTest::addColumn<QString>("audioCodec"); - QTest::addColumn<QString>("videoCodec"); - QTest::addColumn<qint64>("dataSize"); - QTest::addColumn<int>("audioBitRate"); - QTest::addColumn<int>("sampleRate"); - QTest::addColumn<int>("channelCount"); - QTest::addColumn<int>("videoBitRate"); - QTest::addColumn<QSize>("resolution"); - - QTest::newRow("audio content") - << QUrl(QString::fromLatin1("http:://test.com/test.mp3")) - << QNetworkRequest(QUrl(QString::fromLatin1("http:://test.com/test.mp3"))) - << QString::fromLatin1("audio/mpeg") - << QString::fromLatin1("eng") - << QString::fromLatin1("mp3") - << QString() - << qint64(5465433) - << 128000 - << 44100 - << 2 - << 0 - << QSize(); - QTest::newRow("image content") - << QUrl(QString::fromLatin1("http:://test.com/test.jpg")) - << QNetworkRequest(QUrl(QString::fromLatin1("http:://test.com/test.jpg"))) - << QString::fromLatin1("image/jpeg") - << QString() - << QString() - << QString() - << qint64(23600) - << 0 - << 0 - << 0 - << 0 - << QSize(640, 480); - QTest::newRow("video content") - << QUrl(QString::fromLatin1("http:://test.com/test.mp4")) - << QNetworkRequest(QUrl(QString::fromLatin1("http:://test.com/test.mp4"))) - << QString::fromLatin1("video/mp4") - << QString() - << QString::fromLatin1("aac") - << QString::fromLatin1("h264") - << qint64(36245851) - << 96000 - << 44000 - << 5 - << 750000 - << QSize(720, 576); - QTest::newRow("thumbnail") - << QUrl(QString::fromLatin1("file::///thumbs/test.png")) - << QNetworkRequest(QUrl(QString::fromLatin1("file::///thumbs/test.png"))) - << QString::fromLatin1("image/png") - << QString() - << QString() - << QString() - << qint64(2360) - << 0 - << 0 - << 0 - << 0 - << QSize(128, 128); -} - -void tst_QMediaResource::construct() -{ - QFETCH(QUrl, url); - QFETCH(QNetworkRequest, request); - QFETCH(QString, mimeType); - QFETCH(QString, language); - QFETCH(QString, audioCodec); - QFETCH(QString, videoCodec); - QFETCH(qint64, dataSize); - QFETCH(int, audioBitRate); - QFETCH(int, sampleRate); - QFETCH(int, channelCount); - QFETCH(int, videoBitRate); - QFETCH(QSize, resolution); - - { - QMediaResource resource(url); - - QCOMPARE(resource.isNull(), false); - QCOMPARE(resource.url(), url); - QCOMPARE(resource.mimeType(), QString()); - QCOMPARE(resource.language(), QString()); - QCOMPARE(resource.audioCodec(), QString()); - QCOMPARE(resource.videoCodec(), QString()); - QCOMPARE(resource.dataSize(), qint64(0)); - QCOMPARE(resource.audioBitRate(), 0); - QCOMPARE(resource.sampleRate(), 0); - QCOMPARE(resource.channelCount(), 0); - QCOMPARE(resource.videoBitRate(), 0); - QCOMPARE(resource.resolution(), QSize()); - } - { - QMediaResource resource(url, mimeType); - - QCOMPARE(resource.isNull(), false); - QCOMPARE(resource.url(), url); - QCOMPARE(resource.request(), request); - QCOMPARE(resource.mimeType(), mimeType); - QCOMPARE(resource.language(), QString()); - QCOMPARE(resource.audioCodec(), QString()); - QCOMPARE(resource.videoCodec(), QString()); - QCOMPARE(resource.dataSize(), qint64(0)); - QCOMPARE(resource.audioBitRate(), 0); - QCOMPARE(resource.sampleRate(), 0); - QCOMPARE(resource.channelCount(), 0); - QCOMPARE(resource.videoBitRate(), 0); - QCOMPARE(resource.resolution(), QSize()); - - resource.setLanguage(language); - resource.setAudioCodec(audioCodec); - resource.setVideoCodec(videoCodec); - resource.setDataSize(dataSize); - resource.setAudioBitRate(audioBitRate); - resource.setSampleRate(sampleRate); - resource.setChannelCount(channelCount); - resource.setVideoBitRate(videoBitRate); - resource.setResolution(resolution); - - QCOMPARE(resource.language(), language); - QCOMPARE(resource.audioCodec(), audioCodec); - QCOMPARE(resource.videoCodec(), videoCodec); - QCOMPARE(resource.dataSize(), dataSize); - QCOMPARE(resource.audioBitRate(), audioBitRate); - QCOMPARE(resource.sampleRate(), sampleRate); - QCOMPARE(resource.channelCount(), channelCount); - QCOMPARE(resource.videoBitRate(), videoBitRate); - QCOMPARE(resource.resolution(), resolution); - } - { - QMediaResource resource(request, mimeType); - - QCOMPARE(resource.isNull(), false); - QCOMPARE(resource.url(), url); - QCOMPARE(resource.request(), request); - QCOMPARE(resource.mimeType(), mimeType); - QCOMPARE(resource.language(), QString()); - QCOMPARE(resource.audioCodec(), QString()); - QCOMPARE(resource.videoCodec(), QString()); - QCOMPARE(resource.dataSize(), qint64(0)); - QCOMPARE(resource.audioBitRate(), 0); - QCOMPARE(resource.sampleRate(), 0); - QCOMPARE(resource.channelCount(), 0); - QCOMPARE(resource.videoBitRate(), 0); - QCOMPARE(resource.resolution(), QSize()); - - resource.setLanguage(language); - resource.setAudioCodec(audioCodec); - resource.setVideoCodec(videoCodec); - resource.setDataSize(dataSize); - resource.setAudioBitRate(audioBitRate); - resource.setSampleRate(sampleRate); - resource.setChannelCount(channelCount); - resource.setVideoBitRate(videoBitRate); - resource.setResolution(resolution); - - QCOMPARE(resource.language(), language); - QCOMPARE(resource.audioCodec(), audioCodec); - QCOMPARE(resource.videoCodec(), videoCodec); - QCOMPARE(resource.dataSize(), dataSize); - QCOMPARE(resource.audioBitRate(), audioBitRate); - QCOMPARE(resource.sampleRate(), sampleRate); - QCOMPARE(resource.channelCount(), channelCount); - QCOMPARE(resource.videoBitRate(), videoBitRate); - QCOMPARE(resource.resolution(), resolution); - } -} - -void tst_QMediaResource::setResolution() -{ - QMediaResource resource( - QUrl(QString::fromLatin1("file::///thumbs/test.png")), - QString::fromLatin1("image/png")); - - QCOMPARE(resource.resolution(), QSize()); - - resource.setResolution(QSize(120, 80)); - QCOMPARE(resource.resolution(), QSize(120, 80)); - - resource.setResolution(QSize(-1, 23)); - QCOMPARE(resource.resolution(), QSize(-1, 23)); - - resource.setResolution(QSize(-43, 34)); - QCOMPARE(resource.resolution(), QSize(-43, 34)); - - resource.setResolution(QSize(64, -1)); - QCOMPARE(resource.resolution(), QSize(64, -1)); - - resource.setResolution(QSize(64, -83)); - QCOMPARE(resource.resolution(), QSize(64, -83)); - - resource.setResolution(QSize(-12, -83)); - QCOMPARE(resource.resolution(), QSize(-12, -83)); - - resource.setResolution(QSize()); - QCOMPARE(resource.resolution(), QSize(-1, -1)); - - resource.setResolution(120, 80); - QCOMPARE(resource.resolution(), QSize(120, 80)); - - resource.setResolution(-1, 23); - QCOMPARE(resource.resolution(), QSize(-1, 23)); - - resource.setResolution(-43, 34); - QCOMPARE(resource.resolution(), QSize(-43, 34)); - - resource.setResolution(64, -1); - QCOMPARE(resource.resolution(), QSize(64, -1)); - - resource.setResolution(64, -83); - QCOMPARE(resource.resolution(), QSize(64, -83)); - - resource.setResolution(-12, -83); - QCOMPARE(resource.resolution(), QSize(-12, -83)); - - resource.setResolution(-1, -1); - QCOMPARE(resource.resolution(), QSize()); -} - -void tst_QMediaResource::equality() -{ - QMediaResource resource1( - QUrl(QString::fromLatin1("http://test.com/test.mp4")), - QString::fromLatin1("video/mp4")); - QMediaResource resource2( - QUrl(QString::fromLatin1("http://test.com/test.mp4")), - QString::fromLatin1("video/mp4")); - QMediaResource resource3( - QUrl(QString::fromLatin1("file:///thumbs/test.jpg"))); - QMediaResource resource4( - QUrl(QString::fromLatin1("file:///thumbs/test.jpg"))); - QMediaResource resource5( - QUrl(QString::fromLatin1("http://test.com/test.mp3")), - QString::fromLatin1("audio/mpeg")); - - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - QCOMPARE(resource3 == resource4, true); - QCOMPARE(resource3 != resource4, false); - - QCOMPARE(resource1 == resource3, false); - QCOMPARE(resource1 != resource3, true); - - QCOMPARE(resource1 == resource5, false); - QCOMPARE(resource1 != resource5, true); - - resource1.setAudioCodec(QString::fromLatin1("mp3")); - resource2.setAudioCodec(QString::fromLatin1("aac")); - - // Not equal differing audio codecs. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource1.setAudioCodec(QString::fromLatin1("aac")); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setVideoCodec(QString()); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setVideoCodec(QString::fromLatin1("h264")); - - // Not equal differing video codecs. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource2.setVideoCodec(QString::fromLatin1("h264")); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource2.setDataSize(0); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setDataSize(546423); - - // Not equal differing video codecs. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource2.setDataSize(546423); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setAudioBitRate(96000); - resource1.setSampleRate(48000); - resource2.setSampleRate(44100); - resource1.setChannelCount(0); - resource1.setVideoBitRate(900000); - resource2.setLanguage(QString::fromLatin1("eng")); - - // Not equal, audio bit rate, sample rate, video bit rate, and - // language. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource2.setAudioBitRate(96000); - resource1.setSampleRate(44100); - - // Not equal, differing video bit rate, and language. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource2.setVideoBitRate(900000); - resource1.setLanguage(QString::fromLatin1("eng")); - - // Equal - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setResolution(QSize()); - - // Equal - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource2.setResolution(-1, -1); - - // Equal - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setResolution(QSize(-640, -480)); - - // Not equal, differing resolution. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - resource1.setResolution(QSize(640, 480)); - resource2.setResolution(QSize(800, 600)); - - // Not equal, differing resolution. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource1.setResolution(800, 600); - - // Equal - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); -} - -void tst_QMediaResource::copy() -{ - const QUrl url(QString::fromLatin1("http://test.com/test.mp4")); - const QString mimeType(QLatin1String("video/mp4")); - const QString amrCodec(QLatin1String("amr")); - const QString mp3Codec(QLatin1String("mp3")); - const QString aacCodec(QLatin1String("aac")); - const QString h264Codec(QLatin1String("h264")); - - QMediaResource original(url, mimeType); - original.setAudioCodec(amrCodec); - - QMediaResource copy(original); - - QCOMPARE(copy.url(), url); - QCOMPARE(copy.mimeType(), mimeType); - QCOMPARE(copy.audioCodec(), amrCodec); - - QCOMPARE(original == copy, true); - QCOMPARE(original != copy, false); - - original.setAudioCodec(mp3Codec); - - QCOMPARE(copy.audioCodec(), amrCodec); - QCOMPARE(original == copy, false); - QCOMPARE(original != copy, true); - - copy.setAudioCodec(aacCodec); - copy.setVideoCodec(h264Codec); - - QCOMPARE(copy.url(), url); - QCOMPARE(copy.mimeType(), mimeType); - - QCOMPARE(original.audioCodec(), mp3Codec); -} - -void tst_QMediaResource::assign() -{ - const QUrl url(QString::fromLatin1("http://test.com/test.mp4")); - const QString mimeType(QLatin1String("video/mp4")); - const QString amrCodec(QLatin1String("amr")); - const QString mp3Codec(QLatin1String("mp3")); - const QString aacCodec(QLatin1String("aac")); - const QString h264Codec(QLatin1String("h264")); - - QMediaResource copy(QUrl(QString::fromLatin1("file:///thumbs/test.jpg"))); - - QMediaResource original(url, mimeType); - original.setAudioCodec(amrCodec); - - copy = original; - - QCOMPARE(copy.url(), url); - QCOMPARE(copy.mimeType(), mimeType); - QCOMPARE(copy.audioCodec(), amrCodec); - - QCOMPARE(original == copy, true); - QCOMPARE(original != copy, false); - - original.setAudioCodec(mp3Codec); - - QCOMPARE(copy.audioCodec(), amrCodec); - QCOMPARE(original == copy, false); - QCOMPARE(original != copy, true); - - copy.setAudioCodec(aacCodec); - copy.setVideoCodec(h264Codec); - - QCOMPARE(copy.url(), url); - QCOMPARE(copy.mimeType(), mimeType); - - QCOMPARE(original.audioCodec(), mp3Codec); -} - -QTEST_MAIN(tst_QMediaResource) - -#include "tst_qmediaresource.moc" diff --git a/tests/auto/qmediaservice/qmediaservice.pro b/tests/auto/qmediaservice/qmediaservice.pro deleted file mode 100644 index 8acd03a..0000000 --- a/tests/auto/qmediaservice/qmediaservice.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaservice.cpp - -QT = core gui mediaservices - diff --git a/tests/auto/qmediaservice/tst_qmediaservice.cpp b/tests/auto/qmediaservice/tst_qmediaservice.cpp deleted file mode 100644 index a544e77..0000000 --- a/tests/auto/qmediaservice/tst_qmediaservice.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> - -#include <QtMediaServices/qvideodevicecontrol.h> -#include <QtMediaServices/qmediacontrol.h> -#include <QtMediaServices/qmediaservice.h> - -#include <QtGui/qapplication.h> -#include <QtGui/qstyle.h> - -class QtTestMediaService; - - -class tst_QMediaService : public QObject -{ - Q_OBJECT -private slots: - void initTestCase(); - - void control_iid(); - void control(); -}; - - -class QtTestMediaControlA : public QMediaControl -{ - Q_OBJECT -}; - - -#define QtTestMediaControlA_iid "com.nokia.QtTestMediaControlA" -QT_BEGIN_NAMESPACE -Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlA, QtTestMediaControlA_iid) -QT_END_NAMESPACE - - -class QtTestMediaControlB : public QMediaControl -{ - Q_OBJECT -}; - -#define QtTestMediaControlB_iid "com.nokia.QtTestMediaControlB" -QT_BEGIN_NAMESPACE -Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlB, QtTestMediaControlB_iid) -QT_END_NAMESPACE - - -class QtTestMediaControlC : public QMediaControl -{ - Q_OBJECT -}; - -#define QtTestMediaControlC_iid "com.nokia.QtTestMediaControlC" -QT_BEGIN_NAMESPACE -Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlC, QtTestMediaControlA_iid) // Yes A. -QT_END_NAMESPACE - -class QtTestMediaControlD : public QMediaControl -{ - Q_OBJECT -}; - -#define QtTestMediaControlD_iid "com.nokia.QtTestMediaControlD" -QT_BEGIN_NAMESPACE -Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlD, QtTestMediaControlD_iid) -QT_END_NAMESPACE - -class QtTestMediaControlE : public QMediaControl -{ - Q_OBJECT -}; - -struct QtTestDevice -{ - QtTestDevice() {} - QtTestDevice(const QString &name, const QString &description, const QIcon &icon) - : name(name), description(description), icon(icon) - { - } - - QString name; - QString description; - QIcon icon; -}; - -class QtTestVideoDeviceControl : public QVideoDeviceControl -{ -public: - QtTestVideoDeviceControl(QObject *parent = 0) - : QVideoDeviceControl(parent) - , m_selectedDevice(-1) - , m_defaultDevice(-1) - { - } - - int deviceCount() const { return devices.count(); } - - QString deviceName(int index) const { return devices.value(index).name; } - QString deviceDescription(int index) const { return devices.value(index).description; } - QIcon deviceIcon(int index) const { return devices.value(index).icon; } - - int defaultDevice() const { return m_defaultDevice; } - void setDefaultDevice(int index) { m_defaultDevice = index; } - - int selectedDevice() const { return m_selectedDevice; } - void setSelectedDevice(int index) - { - emit selectedDeviceChanged(m_selectedDevice = index); - emit selectedDeviceChanged(devices.value(index).name); - } - - QList<QtTestDevice> devices; - -private: - int m_selectedDevice; - int m_defaultDevice; -}; - -class QtTestMediaService : public QMediaService -{ - Q_OBJECT -public: - QtTestMediaService() - : QMediaService(0) - , hasDeviceControls(false) - { - } - - QMediaControl* control(const char *name) const - { - if (strcmp(name, QtTestMediaControlA_iid) == 0) - return const_cast<QtTestMediaControlA *>(&controlA); - else if (strcmp(name, QtTestMediaControlB_iid) == 0) - return const_cast<QtTestMediaControlB *>(&controlB); - else if (strcmp(name, QtTestMediaControlC_iid) == 0) - return const_cast<QtTestMediaControlC *>(&controlC); - else if (hasDeviceControls && strcmp(name, QVideoDeviceControl_iid) == 0) - return const_cast<QtTestVideoDeviceControl *>(&videoDeviceControl); - else - return 0; - } - - using QMediaService::control; - - QtTestMediaControlA controlA; - QtTestMediaControlB controlB; - QtTestMediaControlC controlC; - QtTestVideoDeviceControl videoDeviceControl; - bool hasDeviceControls; -}; - -void tst_QMediaService::initTestCase() -{ -} - -void tst_QMediaService::control_iid() -{ - const char *nullString = 0; - - // Default implementation. - QCOMPARE(qmediacontrol_iid<QtTestMediaControlE *>(), nullString); - - // Partial template. - QVERIFY(qstrcmp(qmediacontrol_iid<QtTestMediaControlA *>(), QtTestMediaControlA_iid) == 0); -} - -void tst_QMediaService::control() -{ - QtTestMediaService service; - - QCOMPARE(service.control<QtTestMediaControlA *>(), &service.controlA); - QCOMPARE(service.control<QtTestMediaControlB *>(), &service.controlB); - QVERIFY(!service.control<QtTestMediaControlC *>()); // Faulty implementation returns A. - QVERIFY(!service.control<QtTestMediaControlD *>()); // No control of that type. -} - -QTEST_MAIN(tst_QMediaService) - -#include "tst_qmediaservice.moc" diff --git a/tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro b/tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro deleted file mode 100644 index 69b3864..0000000 --- a/tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaserviceprovider.cpp - -QT = core gui mediaservices - diff --git a/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp b/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp deleted file mode 100644 index 64abedb..0000000 --- a/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp +++ /dev/null @@ -1,481 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> -#include <QDebug> -#include <QStringList> - -#include <QtMediaServices/qmediaserviceprovider.h> -#include <QtMediaServices/qmediaserviceproviderplugin.h> -#include <QtMediaServices/private/qmediapluginloader_p.h> -#include <QtMediaServices/qmediaobject.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmediaplayer.h> - -class MockMediaService : public QMediaService -{ - Q_OBJECT -public: - MockMediaService(const QString& name, QObject *parent = 0) : QMediaService(parent) - { setObjectName(name); } - ~MockMediaService() {} - - QMediaControl* control(const char *) const {return 0;} -}; - -class MockServicePlugin1 : public QMediaServiceProviderPlugin, - public QMediaServiceSupportedFormatsInterface, - public QMediaServiceSupportedDevicesInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceSupportedFormatsInterface) - Q_INTERFACES(QMediaServiceSupportedDevicesInterface) -public: - QStringList keys() const - { - return QStringList() << - QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); - } - - QMediaService* create(QString const& key) - { - if (keys().contains(key)) - return new MockMediaService("MockServicePlugin1"); - else - return 0; - } - - void release(QMediaService *service) - { - delete service; - } - - QtMediaServices::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const - { - if (codecs.contains(QLatin1String("mpeg4"))) - return QtMediaServices::NotSupported; - - if (mimeType == "audio/ogg") { - return QtMediaServices::ProbablySupported; - } - - return QtMediaServices::MaybeSupported; - } - - QStringList supportedMimeTypes() const - { - return QStringList("audio/ogg"); - } - - QList<QByteArray> devices(const QByteArray &service) const - { - Q_UNUSED(service); - QList<QByteArray> res; - return res; - } - - QString deviceDescription(const QByteArray &service, const QByteArray &device) - { - if (devices(service).contains(device)) - return QString(device)+" description"; - else - return QString(); - } -}; - -class MockServicePlugin2 : public QMediaServiceProviderPlugin, - public QMediaServiceSupportedFormatsInterface, - public QMediaServiceFeaturesInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceSupportedFormatsInterface) - Q_INTERFACES(QMediaServiceFeaturesInterface) -public: - QStringList keys() const - { - return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); - } - - QMediaService* create(QString const& key) - { - if (keys().contains(key)) - return new MockMediaService("MockServicePlugin2"); - else - return 0; - } - - void release(QMediaService *service) - { - delete service; - } - - QtMediaServices::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const - { - Q_UNUSED(codecs); - - if (mimeType == "audio/wav") - return QtMediaServices::PreferredService; - - return QtMediaServices::NotSupported; - } - - QStringList supportedMimeTypes() const - { - return QStringList("audio/wav"); - } - - QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const - { - if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)) - return QMediaServiceProviderHint::LowLatencyPlayback; - else - return 0; - } -}; - - -class MockServicePlugin3 : public QMediaServiceProviderPlugin, - public QMediaServiceSupportedDevicesInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceSupportedDevicesInterface) -public: - QStringList keys() const - { - return QStringList() << - QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); - } - - QMediaService* create(QString const& key) - { - if (keys().contains(key)) - return new MockMediaService("MockServicePlugin3"); - else - return 0; - } - - void release(QMediaService *service) - { - delete service; - } - - QList<QByteArray> devices(const QByteArray &service) const - { - Q_UNUSED(service); - QList<QByteArray> res; - return res; - } - - QString deviceDescription(const QByteArray &service, const QByteArray &device) - { - if (devices(service).contains(device)) - return QString(device)+" description"; - else - return QString(); - } -}; - -class MockServicePlugin4 : public QMediaServiceProviderPlugin, - public QMediaServiceSupportedFormatsInterface, - public QMediaServiceFeaturesInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceSupportedFormatsInterface) - Q_INTERFACES(QMediaServiceFeaturesInterface) -public: - QStringList keys() const - { - return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); - } - - QMediaService* create(QString const& key) - { - if (keys().contains(key)) - return new MockMediaService("MockServicePlugin4"); - else - return 0; - } - - void release(QMediaService *service) - { - delete service; - } - - QtMediaServices::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const - { - if (codecs.contains(QLatin1String("jpeg2000"))) - return QtMediaServices::NotSupported; - - if (supportedMimeTypes().contains(mimeType)) - return QtMediaServices::ProbablySupported; - - return QtMediaServices::MaybeSupported; - } - - QStringList supportedMimeTypes() const - { - return QStringList() << "video/mp4" << "video/quicktime"; - } - - QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const - { - if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)) - return QMediaServiceProviderHint::StreamPlayback; - else - return 0; - } -}; - - - -class MockMediaServiceProvider : public QMediaServiceProvider -{ - QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &) - { - Q_UNUSED(type); - return 0; - } - - void releaseService(QMediaService *service) - { - Q_UNUSED(service); - } -}; - - -class tst_QMediaServiceProvider : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - -private slots: - void testDefaultProviderAvailable(); - void testObtainService(); - void testHasSupport(); - void testSupportedMimeTypes(); - void testProviderHints(); - -private: - QObjectList plugins; -}; - -void tst_QMediaServiceProvider::initTestCase() -{ - plugins << new MockServicePlugin1; - plugins << new MockServicePlugin2; - plugins << new MockServicePlugin3; - plugins << new MockServicePlugin4; - - QMediaPluginLoader::setStaticPlugins(QLatin1String("/mediaservices"), plugins); -} - -void tst_QMediaServiceProvider::testDefaultProviderAvailable() -{ - // Must always be a default provider available - QVERIFY(QMediaServiceProvider::defaultServiceProvider() != 0); -} - -void tst_QMediaServiceProvider::testObtainService() -{ - QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); - - if (provider == 0) - QSKIP("No default provider", SkipSingle); - - QMediaService *service = 0; - - // Player - service = provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER); - QVERIFY(service != 0); - provider->releaseService(service); -} - -void tst_QMediaServiceProvider::testHasSupport() -{ - MockMediaServiceProvider mockProvider; - QCOMPARE(mockProvider.hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), - QtMediaServices::MaybeSupported); - - QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); - - if (provider == 0) - QSKIP("No default provider", SkipSingle); - - QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), - QtMediaServices::MaybeSupported); - - QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/ogg", QStringList()), - QtMediaServices::ProbablySupported); - - //while the service returns PreferredService, provider should return ProbablySupported - QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/wav", QStringList()), - QtMediaServices::ProbablySupported); - - //even while all the plugins with "hasSupport" returned NotSupported, - //MockServicePlugin3 has no "hasSupport" interface, so MaybeSupported - QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/avi", - QStringList() << "mpeg4"), - QtMediaServices::MaybeSupported); - - QCOMPARE(provider->hasSupport(QByteArray("non existing service"), "video/ogv", QStringList()), - QtMediaServices::NotSupported); - - QCOMPARE(QMediaPlayer::hasSupport("video/ogv"), QtMediaServices::MaybeSupported); - QCOMPARE(QMediaPlayer::hasSupport("audio/ogg"), QtMediaServices::ProbablySupported); - QCOMPARE(QMediaPlayer::hasSupport("audio/wav"), QtMediaServices::ProbablySupported); - - //test low latency flag support - QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::LowLatency), - QtMediaServices::ProbablySupported); - //plugin1 probably supports audio/ogg, it checked because it doesn't provide features iface - QCOMPARE(QMediaPlayer::hasSupport("audio/ogg", QStringList(), QMediaPlayer::LowLatency), - QtMediaServices::ProbablySupported); - //Plugin4 is not checked here, sine it's known not support low latency - QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::LowLatency), - QtMediaServices::MaybeSupported); - - //test streaming flag support - QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::StreamPlayback), - QtMediaServices::ProbablySupported); - //Plugin2 is not checked here, sine it's known not support streaming - QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::StreamPlayback), - QtMediaServices::MaybeSupported); - - //ensure the correct media player plugin is choosen for mime type - QMediaPlayer simplePlayer(0, QMediaPlayer::LowLatency); - QCOMPARE(simplePlayer.service()->objectName(), QLatin1String("MockServicePlugin2")); - - QMediaPlayer mediaPlayer; - QVERIFY(mediaPlayer.service()->objectName() != QLatin1String("MockServicePlugin2")); - - QMediaPlayer streamPlayer(0, QMediaPlayer::StreamPlayback); - QCOMPARE(streamPlayer.service()->objectName(), QLatin1String("MockServicePlugin4")); -} - -void tst_QMediaServiceProvider::testSupportedMimeTypes() -{ - QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); - - if (provider == 0) - QSKIP("No default provider", SkipSingle); - - QVERIFY(provider->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)).contains("audio/ogg")); - QVERIFY(!provider->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)).contains("audio/mp3")); -} - -void tst_QMediaServiceProvider::testProviderHints() -{ - { - QMediaServiceProviderHint hint; - QVERIFY(hint.isNull()); - QCOMPARE(hint.type(), QMediaServiceProviderHint::Null); - QVERIFY(hint.device().isEmpty()); - QVERIFY(hint.mimeType().isEmpty()); - QVERIFY(hint.codecs().isEmpty()); - QCOMPARE(hint.features(), 0); - } - - { - QByteArray deviceName(QByteArray("testDevice")); - QMediaServiceProviderHint hint(deviceName); - QVERIFY(!hint.isNull()); - QCOMPARE(hint.type(), QMediaServiceProviderHint::Device); - QCOMPARE(hint.device(), deviceName); - QVERIFY(hint.mimeType().isEmpty()); - QVERIFY(hint.codecs().isEmpty()); - QCOMPARE(hint.features(), 0); - } - - { - QMediaServiceProviderHint hint(QMediaServiceProviderHint::LowLatencyPlayback); - QVERIFY(!hint.isNull()); - QCOMPARE(hint.type(), QMediaServiceProviderHint::SupportedFeatures); - QVERIFY(hint.device().isEmpty()); - QVERIFY(hint.mimeType().isEmpty()); - QVERIFY(hint.codecs().isEmpty()); - QCOMPARE(hint.features(), QMediaServiceProviderHint::LowLatencyPlayback); - } - - { - QString mimeType(QLatin1String("video/ogg")); - QStringList codecs; - codecs << "theora" << "vorbis"; - - QMediaServiceProviderHint hint(mimeType,codecs); - QVERIFY(!hint.isNull()); - QCOMPARE(hint.type(), QMediaServiceProviderHint::ContentType); - QVERIFY(hint.device().isEmpty()); - QCOMPARE(hint.mimeType(), mimeType); - QCOMPARE(hint.codecs(), codecs); - - QMediaServiceProviderHint hint2(hint); - - QVERIFY(!hint2.isNull()); - QCOMPARE(hint2.type(), QMediaServiceProviderHint::ContentType); - QVERIFY(hint2.device().isEmpty()); - QCOMPARE(hint2.mimeType(), mimeType); - QCOMPARE(hint2.codecs(), codecs); - - QMediaServiceProviderHint hint3; - QVERIFY(hint3.isNull()); - hint3 = hint; - QVERIFY(!hint3.isNull()); - QCOMPARE(hint3.type(), QMediaServiceProviderHint::ContentType); - QVERIFY(hint3.device().isEmpty()); - QCOMPARE(hint3.mimeType(), mimeType); - QCOMPARE(hint3.codecs(), codecs); - - QCOMPARE(hint, hint2); - QCOMPARE(hint3, hint2); - - QMediaServiceProviderHint hint4(mimeType,codecs); - QCOMPARE(hint, hint4); - - QMediaServiceProviderHint hint5(mimeType,QStringList()); - QVERIFY(hint != hint5); - } -} - -QTEST_MAIN(tst_QMediaServiceProvider) - -#include "tst_qmediaserviceprovider.moc" diff --git a/tests/auto/qmediatimerange/qmediatimerange.pro b/tests/auto/qmediatimerange/qmediatimerange.pro deleted file mode 100644 index c5e74ce..0000000 --- a/tests/auto/qmediatimerange/qmediatimerange.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediatimerange.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediatimerange/tst_qmediatimerange.cpp b/tests/auto/qmediatimerange/tst_qmediatimerange.cpp deleted file mode 100644 index a21abe2..0000000 --- a/tests/auto/qmediatimerange/tst_qmediatimerange.cpp +++ /dev/null @@ -1,735 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> -#include <QtCore/qdebug.h> - -#include <QtMediaServices/qmediatimerange.h> - -class tst_QMediaTimeRange: public QObject -{ - Q_OBJECT - -public slots: - -private slots: - void testCtor(); - void testGetters(); - void testAssignment(); - void testNormalize(); - void testTranslated(); - void testEarliestLatest(); - void testContains(); - void testAddInterval(); - void testAddTimeRange(); - void testRemoveInterval(); - void testRemoveTimeRange(); - void testClear(); - void testComparisons(); - void testArithmetic(); -}; - -void tst_QMediaTimeRange::testCtor() -{ - // Default Ctor - QMediaTimeRange a; - QVERIFY(a.isEmpty()); - - // (qint, qint) Ctor - QMediaTimeRange b(10, 20); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 20); - - // Interval Ctor - QMediaTimeRange c(QMediaTimeInterval(30, 40)); - - QVERIFY(!c.isEmpty()); - QVERIFY(c.isContinuous()); - QVERIFY(c.earliestTime() == 30); - QVERIFY(c.latestTime() == 40); - - // Abnormal Interval Ctor - QMediaTimeRange d(QMediaTimeInterval(20, 10)); - - QVERIFY(d.isEmpty()); - - // Copy Ctor - QMediaTimeRange e(b); - - QVERIFY(!e.isEmpty()); - QVERIFY(e.isContinuous()); - QVERIFY(e.earliestTime() == 10); - QVERIFY(e.latestTime() == 20); -} - -void tst_QMediaTimeRange::testGetters() -{ - QMediaTimeRange x; - - // isEmpty - QVERIFY(x.isEmpty()); - - x.addInterval(10, 20); - - // isEmpty + isContinuous - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - - x.addInterval(30, 40); - - // isEmpty + isContinuous + intervals + start + end - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 20); - QVERIFY(x.intervals()[1].start() == 30); - QVERIFY(x.intervals()[1].end() == 40); -} - -void tst_QMediaTimeRange::testAssignment() -{ - QMediaTimeRange x; - - // Range Assignment - x = QMediaTimeRange(10, 20); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 20); - - // Interval Assignment - x = QMediaTimeInterval(30, 40); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 30); - QVERIFY(x.latestTime() == 40); - - // Shared Data Check - QMediaTimeRange y; - - y = x; - y.addInterval(10, 20); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 30); - QVERIFY(x.latestTime() == 40); -} - -void tst_QMediaTimeRange::testNormalize() -{ - QMediaTimeInterval x(20, 10); - - QVERIFY(!x.isNormal()); - - x = x.normalized(); - - QVERIFY(x.isNormal()); - QVERIFY(x.start() == 10); - QVERIFY(x.end() == 20); -} - -void tst_QMediaTimeRange::testTranslated() -{ - QMediaTimeInterval x(10, 20); - x = x.translated(10); - - QVERIFY(x.start() == 20); - QVERIFY(x.end() == 30); -} - -void tst_QMediaTimeRange::testEarliestLatest() -{ - // Test over a single interval - QMediaTimeRange x(30, 40); - - QVERIFY(x.earliestTime() == 30); - QVERIFY(x.latestTime() == 40); - - // Test over multiple intervals - x.addInterval(50, 60); - - QVERIFY(x.earliestTime() == 30); - QVERIFY(x.latestTime() == 60); -} - -void tst_QMediaTimeRange::testContains() -{ - // Test over a single interval - QMediaTimeRange x(10, 20); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.contains(15)); - QVERIFY(x.contains(10)); - QVERIFY(x.contains(20)); - QVERIFY(!x.contains(25)); - - // Test over multiple intervals - x.addInterval(40, 50); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.contains(15)); - QVERIFY(x.contains(45)); - QVERIFY(!x.contains(30)); - - // Test over a concrete interval - QMediaTimeInterval y(10, 20); - QVERIFY(y.contains(15)); - QVERIFY(y.contains(10)); - QVERIFY(y.contains(20)); - QVERIFY(!y.contains(25)); -} - -void tst_QMediaTimeRange::testAddInterval() -{ - // All intervals Overlap - QMediaTimeRange x; - x.addInterval(10, 40); - x.addInterval(30, 50); - x.addInterval(20, 60); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 60); - - // 1 adjacent interval, 1 encompassed interval - x = QMediaTimeRange(); - x.addInterval(10, 40); - x.addInterval(20, 30); - x.addInterval(41, 50); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 50); - - // 1 overlapping interval, 1 disjoint interval - x = QMediaTimeRange(); - x.addInterval(10, 30); - x.addInterval(20, 40); - x.addInterval(50, 60); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 40); - QVERIFY(x.intervals()[1].start() == 50); - QVERIFY(x.intervals()[1].end() == 60); - - // Identical Add - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(10, 20); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 20); - - // Multi-Merge - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(30, 40); - x.addInterval(50, 60); - x.addInterval(15, 55); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 60); - - // Interval Parameter - All intervals Overlap - x = QMediaTimeRange(); - x.addInterval(QMediaTimeInterval(10, 40)); - x.addInterval(QMediaTimeInterval(30, 50)); - x.addInterval(QMediaTimeInterval(20, 60)); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 60); - - // Interval Parameter - Abnormal Interval - x = QMediaTimeRange(); - x.addInterval(QMediaTimeInterval(20, 10)); - - QVERIFY(x.isEmpty()); -} - -void tst_QMediaTimeRange::testAddTimeRange() -{ - // Add Time Range uses Add Interval internally, - // so in this test the focus is on combinations of number - // of intervals added, rather than the different types of - // merges which can occur. - QMediaTimeRange a, b; - - // Add Single into Single - a = QMediaTimeRange(10, 30); - b = QMediaTimeRange(20, 40); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 40); - - // Add Multiple into Single - a = QMediaTimeRange(); - a.addInterval(10, 30); - a.addInterval(40, 60); - - b = QMediaTimeRange(20, 50); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 60); - - // Add Single into Multiple - a = QMediaTimeRange(20, 50); - - b = QMediaTimeRange(); - b.addInterval(10, 30); - b.addInterval(40, 60); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 60); - - // Add Multiple into Multiple - a = QMediaTimeRange(); - a.addInterval(10, 30); - a.addInterval(40, 70); - a.addInterval(80, 100); - - b = QMediaTimeRange(); - b.addInterval(20, 50); - b.addInterval(60, 90); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 100); - - // Add Nothing to Single - a = QMediaTimeRange(); - b = QMediaTimeRange(10, 20); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 20); - - // Add Single to Nothing - a = QMediaTimeRange(10, 20); - b = QMediaTimeRange(); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 20); - - // Add Nothing to Nothing - a = QMediaTimeRange(); - b = QMediaTimeRange(); - - b.addTimeRange(a); - - QVERIFY(b.isEmpty()); -} - -void tst_QMediaTimeRange::testRemoveInterval() -{ - // Removing an interval, causing a split - QMediaTimeRange x; - x.addInterval(10, 50); - x.removeInterval(20, 40); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 19); - QVERIFY(x.intervals()[1].start() == 41); - QVERIFY(x.intervals()[1].end() == 50); - - // Removing an interval, causing a deletion - x = QMediaTimeRange(); - x.addInterval(20, 30); - x.removeInterval(10, 40); - - QVERIFY(x.isEmpty()); - - // Removing an interval, causing a tail trim - x = QMediaTimeRange(); - x.addInterval(20, 40); - x.removeInterval(30, 50); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 20); - QVERIFY(x.latestTime() == 29); - - // Removing an interval, causing a head trim - x = QMediaTimeRange(); - x.addInterval(20, 40); - x.removeInterval(10, 30); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 31); - QVERIFY(x.latestTime() == 40); - - // Identical Remove - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.removeInterval(10, 20); - - QVERIFY(x.isEmpty()); - - // Multi-Trim - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(30, 40); - x.removeInterval(15, 35); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 14); - QVERIFY(x.intervals()[1].start() == 36); - QVERIFY(x.intervals()[1].end() == 40); - - // Multi-Delete - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(30, 40); - x.addInterval(50, 60); - x.removeInterval(10, 60); - - QVERIFY(x.isEmpty()); - - // Interval Parameter - Removing an interval, causing a split - x = QMediaTimeRange(); - x.addInterval(10, 50); - x.removeInterval(QMediaTimeInterval(20, 40)); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 19); - QVERIFY(x.intervals()[1].start() == 41); - QVERIFY(x.intervals()[1].end() == 50); - - // Interval Parameter - Abnormal Interval - x = QMediaTimeRange(); - x.addInterval(10, 40); - x.removeInterval(QMediaTimeInterval(30, 20)); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 40); -} - -void tst_QMediaTimeRange::testRemoveTimeRange() -{ - // Remove Time Range uses Remove Interval internally, - // so in this test the focus is on combinations of number - // of intervals removed, rather than the different types of - // deletions which can occur. - QMediaTimeRange a, b; - - // Remove Single from Single - a = QMediaTimeRange(10, 30); - b = QMediaTimeRange(20, 40); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 31); - QVERIFY(b.latestTime() == 40); - - // Remove Multiple from Single - a = QMediaTimeRange(); - a.addInterval(10, 30); - a.addInterval(40, 60); - - b = QMediaTimeRange(20, 50); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 31); - QVERIFY(b.latestTime() == 39); - - // Remove Single from Multiple - a = QMediaTimeRange(20, 50); - - b = QMediaTimeRange(); - b.addInterval(10, 30); - b.addInterval(40, 60); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(!b.isContinuous()); - QVERIFY(b.intervals().count() == 2); - QVERIFY(b.intervals()[0].start() == 10); - QVERIFY(b.intervals()[0].end() == 19); - QVERIFY(b.intervals()[1].start() == 51); - QVERIFY(b.intervals()[1].end() == 60); - - // Remove Multiple from Multiple - a = QMediaTimeRange(); - a.addInterval(20, 50); - a.addInterval(50, 90); - - - b = QMediaTimeRange(); - b.addInterval(10, 30); - b.addInterval(40, 70); - b.addInterval(80, 100); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(!b.isContinuous()); - QVERIFY(b.intervals().count() == 2); - QVERIFY(b.intervals()[0].start() == 10); - QVERIFY(b.intervals()[0].end() == 19); - QVERIFY(b.intervals()[1].start() == 91); - QVERIFY(b.intervals()[1].end() == 100); - - // Remove Nothing from Single - a = QMediaTimeRange(); - b = QMediaTimeRange(10, 20); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 20); - - // Remove Single from Nothing - a = QMediaTimeRange(10, 20); - b = QMediaTimeRange(); - - b.removeTimeRange(a); - - QVERIFY(b.isEmpty()); - - // Remove Nothing from Nothing - a = QMediaTimeRange(); - b = QMediaTimeRange(); - - b.removeTimeRange(a); - - QVERIFY(b.isEmpty()); -} - -void tst_QMediaTimeRange::testClear() -{ - QMediaTimeRange x; - - // Clear Nothing - x.clear(); - - QVERIFY(x.isEmpty()); - - // Clear Single - x = QMediaTimeRange(10, 20); - x.clear(); - - QVERIFY(x.isEmpty()); - - // Clear Multiple - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(30, 40); - x.clear(); - - QVERIFY(x.isEmpty()); -} - -void tst_QMediaTimeRange::testComparisons() -{ - // Interval equality - QVERIFY(QMediaTimeInterval(10, 20) == QMediaTimeInterval(10, 20)); - QVERIFY(QMediaTimeInterval(10, 20) != QMediaTimeInterval(10, 30)); - QVERIFY(!(QMediaTimeInterval(10, 20) != QMediaTimeInterval(10, 20))); - QVERIFY(!(QMediaTimeInterval(10, 20) == QMediaTimeInterval(10, 30))); - - // Time range equality - Single Interval - QMediaTimeRange a(10, 20), b(20, 30), c(10, 20); - - QVERIFY(a == c); - QVERIFY(!(a == b)); - QVERIFY(a != b); - QVERIFY(!(a != c)); - - // Time Range Equality - Multiple Intervals - QMediaTimeRange x, y, z; - - x.addInterval(10, 20); - x.addInterval(30, 40); - x.addInterval(50, 60); - - y.addInterval(10, 20); - y.addInterval(35, 45); - y.addInterval(50, 60); - - z.addInterval(10, 20); - z.addInterval(30, 40); - z.addInterval(50, 60); - - QVERIFY(x == z); - QVERIFY(!(x == y)); - QVERIFY(x != y); - QVERIFY(!(x != z)); -} - -void tst_QMediaTimeRange::testArithmetic() -{ - QMediaTimeRange a(10, 20), b(20, 30); - - // Test += - a += b; - - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 30); - - // Test -= - a -= b; - - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 19); - - // Test += and -= on intervals - a -= QMediaTimeInterval(10, 20); - a += QMediaTimeInterval(40, 50); - - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 40); - QVERIFY(a.latestTime() == 50); - - // Test Interval + Interval - a = QMediaTimeInterval(10, 20) + QMediaTimeInterval(20, 30); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 30); - - // Test Range + Interval - a = a + QMediaTimeInterval(30, 40); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 40); - - // Test Interval + Range - a = QMediaTimeInterval(40, 50) + a; - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 50); - - // Test Range + Range - a = a + QMediaTimeRange(50, 60); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 60); - - // Test Range - Interval - a = a - QMediaTimeInterval(50, 60); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 49); - - // Test Range - Range - a = a - QMediaTimeRange(40, 50); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 39); - - // Test Interval - Range - b = QMediaTimeInterval(0, 20) - a; - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 0); - QVERIFY(b.latestTime() == 9); - - // Test Interval - Interval - a = QMediaTimeInterval(10, 20) - QMediaTimeInterval(15, 30); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 14); -} - -QTEST_MAIN(tst_QMediaTimeRange) - -#include "tst_qmediatimerange.moc" diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 9d942bf..01d7783 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -284,6 +284,11 @@ private Q_SLOTS: void ignoreSslErrorsListWithSlot(); #endif + void getAndThenDeleteObject_data(); + void getAndThenDeleteObject(); + + void symbianOpenCDataUrlCrash(); + // NOTE: This test must be last! void parentingRepliesToTheApp(); }; @@ -4211,6 +4216,66 @@ void tst_QNetworkReply::ignoreSslErrorsListWithSlot() #endif // QT_NO_OPENSSL +void tst_QNetworkReply::getAndThenDeleteObject_data() +{ + QTest::addColumn<bool>("replyFirst"); + + QTest::newRow("delete-reply-first") << true; + QTest::newRow("delete-qnam-first") << false; +} + +void tst_QNetworkReply::getAndThenDeleteObject() +{ + // yes, this will leak if the testcase fails. I don't care. It must not fail then :P + QNetworkAccessManager *manager = new QNetworkAccessManager(); + QNetworkRequest request("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile"); + QNetworkReply *reply = manager->get(request); + reply->setReadBufferSize(1); + reply->setParent((QObject*)0); // must be 0 because else it is the manager + + QTime stopWatch; + stopWatch.start(); + forever { + QCoreApplication::instance()->processEvents(); + if (reply->bytesAvailable()) + break; + if (stopWatch.elapsed() >= 30000) + break; + } + + QVERIFY(reply->bytesAvailable()); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); + QVERIFY(!reply->isFinished()); // must not be finished + + QFETCH(bool, replyFirst); + + if (replyFirst) { + delete reply; + delete manager; + } else { + delete manager; + delete reply; + } +} + +// see https://bugs.webkit.org/show_bug.cgi?id=38935 +void tst_QNetworkReply::symbianOpenCDataUrlCrash() +{ + QString requestUrl("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAWCAYAAAA1vze2AAAAB3RJTUUH2AUSEgolrgBvVQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAARnQU1BAACxjwv8YQUAAAHlSURBVHja5VbNShxBEK6ZaXtnHTebQPA1gngNmfaeq+QNPIlIXkC9iQdJxJNvEHLN3VkxhxxE8gTmEhAVddXZ6Z3f9Ndriz89/sHmkBQUVVT1fB9d9c3uOERUKTunIdn3HzstxGpYBDS4wZk7TAJj/wlJ90J+jnuygqs8svSj+/rGHBos3rE18XBvfU3no7NzlJfUaY/5whAwl8Lr/WDUv4ODxTMb+P5xLExe5LmO559WqTX/MQR4WZYEAtSePS4pE0qSnuhnRUcBU5Gm2k9XljU4Z26I3NRxBrd80rj2fh+KNE0FY4xevRgTjREvPFpasAK8Xli6MUbbuKw3afAGgSBXozo5u4hkmncAlkl5wx8iMGbdyQjnCFEiEwGiosj1UQA/x2rVddiVoi+l4IxE0PTDnx+mrQBvvnx9cFz3krhVvuhzFn579/aq/n5rW8fbtTqiWhIQZEo17YBvbkxOXNVndnYpTvod7AtiuN2re0+siwcB9oH8VxxrNwQQAhzyRs30n7wTI2HIN2g2QtQwjjhJIQatOq7E8bIVCLwzpl83Lvtvl+NohWWlE8UZTWEMAGCcR77fHKhPnZF5tYie6dfdxCphACmLPM+j8bYfmTryg64kV9Vh3mV8jP0b/4wO/YUPiT/8i0MLf55lSQAAAABJRU5ErkJggg=="); + QUrl url = QUrl::fromEncoded(requestUrl.toLatin1()); + QNetworkRequest req(url); + QNetworkReplyPtr reply; + + RUN_REQUEST(runSimpleRequest(QNetworkAccessManager::GetOperation, req, reply)); + + QCOMPARE(reply->url(), url); + QCOMPARE(reply->error(), QNetworkReply::NoError); + + QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), qint64(598)); +} + + + // NOTE: This test must be last testcase in tst_qnetworkreply! void tst_QNetworkReply::parentingRepliesToTheApp() { diff --git a/tests/auto/qsoundeffect/qsoundeffect.pro b/tests/auto/qsoundeffect/qsoundeffect.pro deleted file mode 100644 index 5344a16..0000000 --- a/tests/auto/qsoundeffect/qsoundeffect.pro +++ /dev/null @@ -1,20 +0,0 @@ -load(qttest_p4) - -SOURCES += tst_qsoundeffect.cpp - -QT = core multimedia mediaservices - -wince* { - deploy.sources += 4.wav - DEPLOYMENT = deploy - DEFINES += SRCDIR=\\\"\\\" - QT += gui -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} - -unix:!mac { - !contains(QT_CONFIG, pulseaudio) { - DEFINES += QT_MULTIMEDIA_QMEDIAPLAYER - } -} diff --git a/tests/auto/qsoundeffect/test.wav b/tests/auto/qsoundeffect/test.wav Binary files differdeleted file mode 100644 index e4088a9..0000000 --- a/tests/auto/qsoundeffect/test.wav +++ /dev/null diff --git a/tests/auto/qsoundeffect/tst_qsoundeffect.cpp b/tests/auto/qsoundeffect/tst_qsoundeffect.cpp deleted file mode 100644 index e76a4c5..0000000 --- a/tests/auto/qsoundeffect/tst_qsoundeffect.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> -#include <QtCore/qlocale.h> -#include <qaudiooutput.h> -#include <qaudiodeviceinfo.h> -#include <qaudio.h> -#include <private/qsoundeffect_p.h> - - -class tst_QSoundEffect : public QObject -{ - Q_OBJECT -public: - tst_QSoundEffect(QObject* parent=0) : QObject(parent) {} - -private slots: - void initTestCase(); - void testSource(); - void testLooping(); - void testVolume(); - void testMuting(); - -private: - QSoundEffect* sound; -}; - -void tst_QSoundEffect::initTestCase() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - sound = new QSoundEffect; - - QVERIFY(sound->source().isEmpty()); - QVERIFY(sound->loops() == 1); - QVERIFY(sound->volume() == 100); - QVERIFY(sound->isMuted() == false); -#endif -} - -void tst_QSoundEffect::testSource() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - QSignalSpy readSignal(sound, SIGNAL(sourceChanged())); - - QUrl url = QUrl::fromLocalFile(QString("%1%2").arg(SRCDIR).arg("test.wav")); - sound->setSource(url); - - QCOMPARE(sound->source(),url); - QCOMPARE(readSignal.count(),1); - - QTestEventLoop::instance().enterLoop(1); - sound->play(); - - QTest::qWait(3000); -#endif -} - -void tst_QSoundEffect::testLooping() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - QSignalSpy readSignal(sound, SIGNAL(loopsChanged())); - - sound->setLoops(5); - QCOMPARE(sound->loops(),5); - - sound->play(); - - // test.wav is about 200ms, wait until it has finished playing 5 times - QTest::qWait(3000); -#endif -} - -void tst_QSoundEffect::testVolume() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - QSignalSpy readSignal(sound, SIGNAL(volumeChanged())); - - sound->setVolume(50); - QCOMPARE(sound->volume(),50); - - QTest::qWait(20); - QCOMPARE(readSignal.count(),1); -#endif -} - -void tst_QSoundEffect::testMuting() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - QSignalSpy readSignal(sound, SIGNAL(mutedChanged())); - - sound->setMuted(true); - QCOMPARE(sound->isMuted(),true); - - QTest::qWait(20); - QCOMPARE(readSignal.count(),1); - - delete sound; -#endif -} - -QTEST_MAIN(tst_QSoundEffect) - -#include "tst_qsoundeffect.moc" diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index fa42adc..820e32d 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -1410,7 +1410,7 @@ void tst_QUrl::setUrl() void tst_QUrl::i18n_data() { QTest::addColumn<QString>("input"); - QTest::addColumn<QByteArray>("punyOutput"); + QTest::addColumn<QByteArray>("punyOutput"); QTest::newRow("øl") << QString::fromLatin1("http://ole:passord@www.øl.no/index.html?ole=æsemann&ilder gud=hei#top") << QByteArray("http://ole:passord@www.xn--l-4ga.no/index.html?ole=%C3%A6semann&ilder%20gud=hei#top"); @@ -2165,25 +2165,25 @@ void tst_QUrl::toPercentEncoding_data() QTest::addColumn<QByteArray>("includeInEncoding"); QTest::newRow("test_01") << QString::fromLatin1("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~") - << QByteArray("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~") + << QByteArray("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~") << QByteArray("") << QByteArray(""); QTest::newRow("test_02") << QString::fromLatin1("{\t\n\r^\"abc}") - << QByteArray("%7B%09%0A%0D%5E%22abc%7D") + << QByteArray("%7B%09%0A%0D%5E%22abc%7D") << QByteArray("") << QByteArray(""); QTest::newRow("test_03") << QString::fromLatin1("://?#[]@!$&'()*+,;=") - << QByteArray("%3A%2F%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D") + << QByteArray("%3A%2F%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D") << QByteArray("") << QByteArray(""); QTest::newRow("test_04") << QString::fromLatin1("://?#[]@!$&'()*+,;=") - << QByteArray("%3A%2F%2F%3F%23%5B%5D%40!$&'()*+,;=") + << QByteArray("%3A%2F%2F%3F%23%5B%5D%40!$&'()*+,;=") << QByteArray("!$&'()*+,;=") << QByteArray(""); QTest::newRow("test_05") << QString::fromLatin1("abcd") << QByteArray("a%62%63d") << QByteArray("") - << QByteArray("bc"); + << QByteArray("bc"); } void tst_QUrl::toPercentEncoding() @@ -2193,7 +2193,7 @@ void tst_QUrl::toPercentEncoding() QFETCH(QByteArray, excludeInEncoding); QFETCH(QByteArray, includeInEncoding); - QByteArray encodedUrl = QUrl::toPercentEncoding(original, excludeInEncoding, includeInEncoding); + QByteArray encodedUrl = QUrl::toPercentEncoding(original, excludeInEncoding, includeInEncoding); QCOMPARE(encodedUrl.constData(), encoded.constData()); QCOMPARE(original, QUrl::fromPercentEncoding(encodedUrl)); } @@ -2461,6 +2461,8 @@ void tst_QUrl::isValid() QUrl url = QUrl::fromEncoded("http://strange<username>@ok-hostname/", QUrl::StrictMode); QVERIFY(!url.isValid()); // < and > are not allowed in userinfo in strict mode + url.setUserName("normal_username"); + QVERIFY(url.isValid()); } { QUrl url = QUrl::fromEncoded("http://strange<username>@ok-hostname/"); @@ -2471,7 +2473,18 @@ void tst_QUrl::isValid() QUrl url = QUrl::fromEncoded("http://strange;hostname/here"); QVERIFY(!url.isValid()); QCOMPARE(url.path(), QString("/here")); + url.setAuthority("foobar@bar"); + QVERIFY(url.isValid()); } + + { + QUrl url = QUrl::fromEncoded("foo://stuff;1/g"); + QVERIFY(!url.isValid()); + QCOMPARE(url.path(), QString("/g")); + url.setHost("stuff-1"); + QVERIFY(url.isValid()); + } + } void tst_QUrl::schemeValidator_data() @@ -3194,6 +3207,32 @@ void tst_QUrl::ace_testsuite_data() QTest::newRow("separator-3002") << QString::fromUtf8("example\343\200\202com") << "example.com" << "." << "example.com"; + + QString egyptianIDN = + QString::fromUtf8("\331\210\330\262\330\247\330\261\330\251\055\330\247\331\204\330" + "\243\330\252\330\265\330\247\331\204\330\247\330\252.\331\205" + "\330\265\330\261"); + QTest::newRow("egyptian-tld-ace") + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "." + << egyptianIDN; + QTest::newRow("egyptian-tld-unicode") + << egyptianIDN + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "." + << egyptianIDN; + QTest::newRow("egyptian-tld-mix1") + << QString::fromUtf8("\331\210\330\262\330\247\330\261\330\251\055\330\247\331\204\330" + "\243\330\252\330\265\330\247\331\204\330\247\330\252.xn--wgbh1c") + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "." + << egyptianIDN; + QTest::newRow("egyptian-tld-mix2") + << QString::fromUtf8("xn----rmckbbajlc6dj7bxne2c.\331\205\330\265\330\261") + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "." + << egyptianIDN; } void tst_QUrl::ace_testsuite() diff --git a/tests/auto/qvideowidget/qvideowidget.pro b/tests/auto/qvideowidget/qvideowidget.pro deleted file mode 100644 index 12686f3..0000000 --- a/tests/auto/qvideowidget/qvideowidget.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qvideowidget.cpp - -QT = core gui multimedia mediaservices - diff --git a/tests/auto/qvideowidget/tst_qvideowidget.cpp b/tests/auto/qvideowidget/tst_qvideowidget.cpp deleted file mode 100644 index 8a54789..0000000 --- a/tests/auto/qvideowidget/tst_qvideowidget.cpp +++ /dev/null @@ -1,1602 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite 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 <QtTest/QtTest> - -#include <QtMediaServices/qvideowidget.h> - -#include <QtMediaServices/qmediaobject.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/private/qpaintervideosurface_p.h> -#include <QtMediaServices/qvideooutputcontrol.h> -#include <QtMediaServices/qvideowindowcontrol.h> -#include <QtMediaServices/qvideowidgetcontrol.h> -#include <QtMediaServices/qvideorenderercontrol.h> -#include <QtMultimedia/qabstractvideosurface.h> -#include <QtMultimedia/qvideosurfaceformat.h> - -#include <QtGui/qapplication.h> - - -class tst_QVideoWidget : public QObject -{ - Q_OBJECT -private slots: - void nullObject(); - void nullService(); - void nullOutputControl(); - void noOutputs(); - void serviceDestroyed(); - void objectDestroyed(); - void setMediaObject(); - - void showWindowControl(); - void aspectRatioWindowControl(); - void sizeHintWindowControl_data() { sizeHint_data(); } - void sizeHintWindowControl(); - void brightnessWindowControl_data() { color_data(); } - void brightnessWindowControl(); - void contrastWindowControl_data() { color_data(); } - void contrastWindowControl(); - void hueWindowControl_data() { color_data(); } - void hueWindowControl(); - void saturationWindowControl_data() { color_data(); } - void saturationWindowControl(); - - void showWidgetControl(); - void aspectRatioWidgetControl(); - void sizeHintWidgetControl_data() { sizeHint_data(); } - void sizeHintWidgetControl(); - void brightnessWidgetControl_data() { color_data(); } - void brightnessWidgetControl(); - void contrastWidgetControl_data() { color_data(); } - void contrastWidgetControl(); - void hueWidgetControl_data() { color_data(); } - void hueWidgetControl(); - void saturationWidgetControl_data() { color_data(); } - void saturationWidgetControl(); - - void showRendererControl(); - void aspectRatioRendererControl(); - void sizeHintRendererControl_data(); - void sizeHintRendererControl(); - void brightnessRendererControl_data() { color_data(); } - void brightnessRendererControl(); - void contrastRendererControl_data() { color_data(); } - void contrastRendererControl(); - void hueRendererControl_data() { color_data(); } - void hueRendererControl(); - void saturationRendererControl_data() { color_data(); } - void saturationRendererControl(); - - void paintRendererControl(); - -#ifndef Q_WS_X11 - void fullScreenWindowControl(); - void fullScreenWidgetControl(); - void fullScreenRendererControl(); -#endif - -private: - void sizeHint_data(); - void color_data(); -}; - -Q_DECLARE_METATYPE(Qt::AspectRatioMode) -Q_DECLARE_METATYPE(const uchar *) - -class QtTestOutputControl : public QVideoOutputControl -{ -public: - QtTestOutputControl() : m_output(NoOutput) {} - - QList<Output> availableOutputs() const { return m_outputs; } - void setAvailableOutputs(const QList<Output> outputs) { m_outputs = outputs; } - - Output output() const { return m_output; } - virtual void setOutput(Output output) { m_output = output; } - -private: - Output m_output; - QList<Output> m_outputs; -}; - -class QtTestWindowControl : public QVideoWindowControl -{ -public: - QtTestWindowControl() - : m_winId(0) - , m_repaintCount(0) - , m_brightness(0) - , m_contrast(0) - , m_saturation(0) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_fullScreen(0) - { - } - - WId winId() const { return m_winId; } - void setWinId(WId id) { m_winId = id; } - - QRect displayRect() const { return m_displayRect; } - void setDisplayRect(const QRect &rect) { m_displayRect = rect; } - - bool isFullScreen() const { return m_fullScreen; } - void setFullScreen(bool fullScreen) { emit fullScreenChanged(m_fullScreen = fullScreen); } - - int repaintCount() const { return m_repaintCount; } - void setRepaintCount(int count) { m_repaintCount = count; } - void repaint() { ++m_repaintCount; } - - QSize nativeSize() const { return m_nativeSize; } - void setNativeSize(const QSize &size) { m_nativeSize = size; emit nativeSizeChanged(); } - - Qt::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; } - void setAspectRatioMode(Qt::AspectRatioMode mode) { m_aspectRatioMode = mode; } - - int brightness() const { return m_brightness; } - void setBrightness(int brightness) { emit brightnessChanged(m_brightness = brightness); } - - int contrast() const { return m_contrast; } - void setContrast(int contrast) { emit contrastChanged(m_contrast = contrast); } - - int hue() const { return m_hue; } - void setHue(int hue) { emit hueChanged(m_hue = hue); } - - int saturation() const { return m_saturation; } - void setSaturation(int saturation) { emit saturationChanged(m_saturation = saturation); } - -private: - WId m_winId; - int m_repaintCount; - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; - Qt::AspectRatioMode m_aspectRatioMode; - QRect m_displayRect; - QSize m_nativeSize; - bool m_fullScreen; -}; - -class QtTestWidgetControl : public QVideoWidgetControl -{ -public: - QtTestWidgetControl() - : m_brightness(1.0) - , m_contrast(1.0) - , m_hue(1.0) - , m_saturation(1.0) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_fullScreen(false) - { - } - - bool isFullScreen() const { return m_fullScreen; } - void setFullScreen(bool fullScreen) { emit fullScreenChanged(m_fullScreen = fullScreen); } - - Qt::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; } - void setAspectRatioMode(Qt::AspectRatioMode mode) { m_aspectRatioMode = mode; } - - int brightness() const { return m_brightness; } - void setBrightness(int brightness) { emit brightnessChanged(m_brightness = brightness); } - - int contrast() const { return m_contrast; } - void setContrast(int contrast) { emit contrastChanged(m_contrast = contrast); } - - int hue() const { return m_hue; } - void setHue(int hue) { emit hueChanged(m_hue = hue); } - - int saturation() const { return m_saturation; } - void setSaturation(int saturation) { emit saturationChanged(m_saturation = saturation); } - - void setSizeHint(const QSize &size) { m_widget.setSizeHint(size); } - - QWidget *videoWidget() { return &m_widget; } - -private: - class Widget : public QWidget - { - public: - QSize sizeHint() const { return m_sizeHint; } - void setSizeHint(const QSize &size) { m_sizeHint = size; updateGeometry(); } - private: - QSize m_sizeHint; - } m_widget; - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; - Qt::AspectRatioMode m_aspectRatioMode; - QSize m_sizeHint; - bool m_fullScreen; -}; - -class QtTestRendererControl : public QVideoRendererControl -{ -public: - QtTestRendererControl() - : m_surface(0) - { - } - - QAbstractVideoSurface *surface() const { return m_surface; } - void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; } - -private: - QAbstractVideoSurface *m_surface; -}; - -class QtTestVideoService : public QMediaService -{ - Q_OBJECT -public: - QtTestVideoService( - QtTestOutputControl *output, - QtTestWindowControl *window, - QtTestWidgetControl *widget, - QtTestRendererControl *renderer) - : QMediaService(0) - , outputControl(output) - , windowControl(window) - , widgetControl(widget) - , rendererControl(renderer) - { - } - - ~QtTestVideoService() - { - delete outputControl; - delete windowControl; - delete widgetControl; - delete rendererControl; - } - - QMediaControl *control(const char *name) const - { - if (qstrcmp(name, QVideoOutputControl_iid) == 0) - return outputControl; - else if (qstrcmp(name, QVideoWindowControl_iid) == 0) - return windowControl; - else if (qstrcmp(name, QVideoWidgetControl_iid) == 0) - return widgetControl; - else if (qstrcmp(name, QVideoRendererControl_iid) == 0) - return rendererControl; - else - return 0; - } - - QtTestOutputControl *outputControl; - QtTestWindowControl *windowControl; - QtTestWidgetControl *widgetControl; - QtTestRendererControl *rendererControl; -}; - -class QtTestVideoObject : public QMediaObject -{ - Q_OBJECT -public: - QtTestVideoObject( - QtTestWindowControl *window, - QtTestWidgetControl *widget, - QtTestRendererControl *renderer): - QMediaObject(0, new QtTestVideoService(new QtTestOutputControl, window, widget, renderer)) - { - testService = qobject_cast<QtTestVideoService*>(service()); - QList<QVideoOutputControl::Output> outputs; - - if (window) - outputs.append(QVideoOutputControl::WindowOutput); - if (widget) - outputs.append(QVideoOutputControl::WidgetOutput); - if (renderer) - outputs.append(QVideoOutputControl::RendererOutput); - - testService->outputControl->setAvailableOutputs(outputs); - } - - QtTestVideoObject(QtTestVideoService *service): - QMediaObject(0, service), - testService(service) - { - } - - ~QtTestVideoObject() - { - delete testService; - } - - QtTestVideoService *testService; -}; - -void tst_QVideoWidget::nullObject() -{ - QVideoWidget widget; - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QVERIFY(widget.sizeHint().isEmpty()); - - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - - { - QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int))); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), 100); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - QCOMPARE(spy.count(), 1); - - widget.setBrightness(-120); - QCOMPARE(widget.brightness(), -100); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), -100); - } { - QSignalSpy spy(&widget, SIGNAL(contrastChanged(int))); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), 100); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - QCOMPARE(spy.count(), 1); - - widget.setContrast(-120); - QCOMPARE(widget.contrast(), -100); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), -100); - } { - QSignalSpy spy(&widget, SIGNAL(hueChanged(int))); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), 100); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - QCOMPARE(spy.count(), 1); - - widget.setHue(-120); - QCOMPARE(widget.hue(), -100); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), -100); - } { - QSignalSpy spy(&widget, SIGNAL(saturationChanged(int))); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), 100); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); - QCOMPARE(spy.count(), 1); - - widget.setSaturation(-120); - QCOMPARE(widget.saturation(), -100); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), -100); - } -} - -void tst_QVideoWidget::nullService() -{ - QtTestVideoObject object(0); - - QVideoWidget widget; - widget.setMediaObject(&object); - - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QVERIFY(widget.sizeHint().isEmpty()); - - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); -} - -void tst_QVideoWidget::nullOutputControl() -{ - QtTestVideoObject object(new QtTestVideoService(0, 0, 0, 0)); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QVERIFY(widget.sizeHint().isEmpty()); - - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); -} - -void tst_QVideoWidget::noOutputs() -{ - QtTestVideoObject object(0, 0, 0); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QVERIFY(widget.sizeHint().isEmpty()); - - widget.setFullScreen(true); - QCOMPARE(widget.isFullScreen(), true); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); -} - -void tst_QVideoWidget::serviceDestroyed() -{ - QtTestVideoObject object(new QtTestWindowControl, new QtTestWidgetControl, 0); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - widget.setBrightness(100); - widget.setContrast(100); - widget.setHue(100); - widget.setSaturation(100); - - delete object.testService; - object.testService = 0; - - QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(&object)); - - QCOMPARE(widget.brightness(), 100); - QCOMPARE(widget.contrast(), 100); - QCOMPARE(widget.hue(), 100); - QCOMPARE(widget.saturation(), 100); - - widget.setFullScreen(true); - QCOMPARE(widget.isFullScreen(), true); -} - -void tst_QVideoWidget::objectDestroyed() -{ - QtTestVideoObject *object = new QtTestVideoObject( - new QtTestWindowControl, - new QtTestWidgetControl, - 0); - - QVideoWidget widget; - widget.setMediaObject(object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - widget.setBrightness(100); - widget.setContrast(100); - widget.setHue(100); - widget.setSaturation(100); - - // Delete the media object without deleting the service. - QtTestVideoService *service = object->testService; - object->testService = 0; - - delete object; - object = 0; - - QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(object)); - - QCOMPARE(service->outputControl->output(), QVideoOutputControl::NoOutput); - - QCOMPARE(widget.brightness(), 100); - QCOMPARE(widget.contrast(), 100); - QCOMPARE(widget.hue(), 100); - QCOMPARE(widget.saturation(), 100); - - widget.setFullScreen(true); - QCOMPARE(widget.isFullScreen(), true); - - delete service; -} - -void tst_QVideoWidget::setMediaObject() -{ - QMediaObject *nullObject = 0; - QtTestVideoObject windowObject(new QtTestWindowControl, 0, 0); - QtTestVideoObject widgetObject(0, new QtTestWidgetControl, 0); - QtTestVideoObject rendererObject(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QCOMPARE(widget.mediaObject(), nullObject); - QCOMPARE(windowObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - QCOMPARE(widgetObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - QCOMPARE(rendererObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.setMediaObject(&windowObject); - QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(&windowObject)); - QCOMPARE(windowObject.testService->outputControl->output(), QVideoOutputControl::WindowOutput); - QVERIFY(windowObject.testService->windowControl->winId() != 0); - - - widget.setMediaObject(&widgetObject); - QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(&widgetObject)); - QCOMPARE(widgetObject.testService->outputControl->output(), QVideoOutputControl::WidgetOutput); - - QCoreApplication::processEvents(QEventLoop::AllEvents); - QCOMPARE(widgetObject.testService->widgetControl->videoWidget()->isVisible(), true); - - QCOMPARE(windowObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.setMediaObject(&rendererObject); - QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(&rendererObject)); - QCOMPARE(rendererObject.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(rendererObject.testService->rendererControl->surface() != 0); - - QCOMPARE(widgetObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.setMediaObject(0); - QCOMPARE(widget.mediaObject(), nullObject); - - QCOMPARE(rendererObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); -} - -void tst_QVideoWidget::showWindowControl() -{ - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setNativeSize(QSize(240, 180)); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::WindowOutput); - QVERIFY(object.testService->windowControl->winId() != 0); - - QVERIFY(object.testService->windowControl->repaintCount() > 0); - - widget.resize(640, 480); - QCOMPARE(object.testService->windowControl->displayRect(), QRect(0, 0, 640, 480)); - - widget.move(10, 10); - QCOMPARE(object.testService->windowControl->displayRect(), QRect(0, 0, 640, 480)); - - widget.hide(); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::WindowOutput); -} - -void tst_QVideoWidget::showWidgetControl() -{ - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::WidgetOutput); - QCOMPARE(object.testService->widgetControl->videoWidget()->isVisible(), true); - - widget.resize(640, 480); - - widget.move(10, 10); - - widget.hide(); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::WidgetOutput); - QCOMPARE(object.testService->widgetControl->videoWidget()->isVisible(), false); -} - -void tst_QVideoWidget::showRendererControl() -{ - QtTestVideoObject object(0, 0, new QtTestRendererControl); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); - - widget.resize(640, 480); - - widget.move(10, 10); - - widget.hide(); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); -} - -void tst_QVideoWidget::aspectRatioWindowControl() -{ - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setAspectRatioMode(Qt::IgnoreAspectRatio); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - // Test the aspect ratio defaults to keeping the aspect ratio. - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - - // Test the control has been informed of the aspect ratio change, post show. - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::KeepAspectRatio); - - // Test an aspect ratio change is enforced immediately while visible. - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::IgnoreAspectRatio); - - // Test an aspect ratio set while not visible is respected. - widget.hide(); - widget.setAspectRatioMode(Qt::KeepAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - widget.show(); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QVideoWidget::aspectRatioWidgetControl() -{ - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setAspectRatioMode(Qt::IgnoreAspectRatio); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - // Test the aspect ratio defaults to keeping the aspect ratio. - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - - // Test the control has been informed of the aspect ratio change, post show. - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::KeepAspectRatio); - - // Test an aspect ratio change is enforced immediately while visible. - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::IgnoreAspectRatio); - - // Test an aspect ratio set while not visible is respected. - widget.hide(); - widget.setAspectRatioMode(Qt::KeepAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - widget.show(); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QVideoWidget::aspectRatioRendererControl() -{ - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - // Test the aspect ratio defaults to keeping the aspect ratio. - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - - // Test the control has been informed of the aspect ratio change, post show. - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - - // Test an aspect ratio change is enforced immediately while visible. - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - - // Test an aspect ratio set while not visible is respected. - widget.hide(); - widget.setAspectRatioMode(Qt::KeepAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - widget.show(); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QVideoWidget::sizeHint_data() -{ - QTest::addColumn<QSize>("size"); - - QTest::newRow("720x576") - << QSize(720, 576); -} - -void tst_QVideoWidget::sizeHintWindowControl() -{ - QFETCH(QSize, size); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QVERIFY(widget.sizeHint().isEmpty()); - - object.testService->windowControl->setNativeSize(size); - QCOMPARE(widget.sizeHint(), size); -} - -void tst_QVideoWidget::sizeHintWidgetControl() -{ - QFETCH(QSize, size); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QVERIFY(widget.sizeHint().isEmpty()); - - object.testService->widgetControl->setSizeHint(size); - QCOMPARE(widget.sizeHint(), size); -} - -void tst_QVideoWidget::sizeHintRendererControl_data() -{ - QTest::addColumn<QSize>("frameSize"); - QTest::addColumn<QRect>("viewport"); - QTest::addColumn<QSize>("pixelAspectRatio"); - QTest::addColumn<QSize>("expectedSize"); - - QTest::newRow("640x480") - << QSize(640, 480) - << QRect(0, 0, 640, 480) - << QSize(1, 1) - << QSize(640, 480); - - QTest::newRow("800x600, (80,60, 640x480) viewport") - << QSize(800, 600) - << QRect(80, 60, 640, 480) - << QSize(1, 1) - << QSize(640, 480); - - QTest::newRow("800x600, (80,60, 640x480) viewport, 4:3") - << QSize(800, 600) - << QRect(80, 60, 640, 480) - << QSize(4, 3) - << QSize(853, 480); - -} - -void tst_QVideoWidget::sizeHintRendererControl() -{ - QFETCH(QSize, frameSize); - QFETCH(QRect, viewport); - QFETCH(QSize, pixelAspectRatio); - QFETCH(QSize, expectedSize); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); - format.setViewport(viewport); - format.setPixelAspectRatio(pixelAspectRatio); - - QVERIFY(object.testService->rendererControl->surface()->start(format)); - - QCOMPARE(widget.sizeHint(), expectedSize); -} - -#ifndef Q_WS_X11 - -void tst_QVideoWidget::fullScreenWindowControl() -{ - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - Qt::WindowFlags windowFlags = widget.windowFlags(); - - QSignalSpy spy(&widget, SIGNAL(fullScreenChanged(bool))); - - // Test showing full screen with setFullScreen(true). - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toBool(), true); - - // Test returning to normal with setFullScreen(false). - widget.setFullScreen(false); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test showing full screen with showFullScreen(). - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 3); - QCOMPARE(spy.value(2).value(0).toBool(), true); - - // Test returning to normal with showNormal(). - widget.showNormal(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - QCOMPARE(spy.value(3).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test setFullScreen(false) and showNormal() do nothing when isFullScreen() == false. - widget.setFullScreen(false); - QCOMPARE(object.testService->windowControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - widget.showNormal(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - - // Test setFullScreen(true) and showFullScreen() do nothing when isFullScreen() == true. - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - widget.setFullScreen(true); - QCOMPARE(object.testService->windowControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - widget.showFullScreen(); - QCOMPARE(object.testService->windowControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - - // Test if the window control exits full screen mode, the widget follows suit. - object.testService->windowControl->setFullScreen(false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 6); - QCOMPARE(spy.value(5).value(0).toBool(), false); - - // Test if the window control enters full screen mode, the widget does nothing. - object.testService->windowControl->setFullScreen(false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 6); -} - -void tst_QVideoWidget::fullScreenWidgetControl() -{ - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - Qt::WindowFlags windowFlags = widget.windowFlags(); - - QSignalSpy spy(&widget, SIGNAL(fullScreenChanged(bool))); - - // Test showing full screen with setFullScreen(true). - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->widgetControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toBool(), true); - - // Test returning to normal with setFullScreen(false). - widget.setFullScreen(false); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->widgetControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test showing full screen with showFullScreen(). - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->widgetControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 3); - QCOMPARE(spy.value(2).value(0).toBool(), true); - - // Test returning to normal with showNormal(). - widget.showNormal(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->widgetControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - QCOMPARE(spy.value(3).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test setFullScreen(false) and showNormal() do nothing when isFullScreen() == false. - widget.setFullScreen(false); - QCOMPARE(object.testService->widgetControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - widget.showNormal(); - QCOMPARE(object.testService->widgetControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - - // Test setFullScreen(true) and showFullScreen() do nothing when isFullScreen() == true. - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - widget.setFullScreen(true); - QCOMPARE(object.testService->widgetControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - widget.showFullScreen(); - QCOMPARE(object.testService->widgetControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - - // Test if the window control exits full screen mode, the widget follows suit. - object.testService->widgetControl->setFullScreen(false); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 6); - QCOMPARE(spy.value(5).value(0).toBool(), false); - - // Test if the window control enters full screen mode, the widget does nothing. - object.testService->widgetControl->setFullScreen(false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 6); -} - - -void tst_QVideoWidget::fullScreenRendererControl() -{ - QtTestVideoObject object(0, 0, new QtTestRendererControl); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - Qt::WindowFlags windowFlags = widget.windowFlags(); - - QSignalSpy spy(&widget, SIGNAL(fullScreenChanged(bool))); - - // Test showing full screen with setFullScreen(true). - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toBool(), true); - - // Test returning to normal with setFullScreen(false). - widget.setFullScreen(false); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test showing full screen with showFullScreen(). - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 3); - QCOMPARE(spy.value(2).value(0).toBool(), true); - - // Test returning to normal with showNormal(). - widget.showNormal(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - QCOMPARE(spy.value(3).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test setFullScreen(false) and showNormal() do nothing when isFullScreen() == false. - widget.setFullScreen(false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - widget.showNormal(); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - - // Test setFullScreen(true) and showFullScreen() do nothing when isFullScreen() == true. - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - widget.setFullScreen(true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - widget.showFullScreen(); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); -} - -#endif - -void tst_QVideoWidget::color_data() -{ - QTest::addColumn<int>("controlValue"); - QTest::addColumn<int>("value"); - QTest::addColumn<int>("expectedValue"); - - QTest::newRow("12") - << 0 - << 12 - << 12; - QTest::newRow("-56") - << 87 - << -56 - << -56; - QTest::newRow("100") - << 32 - << 100 - << 100; - QTest::newRow("1294") - << 0 - << 1294 - << 100; - QTest::newRow("-102") - << 34 - << -102 - << -100; -} - -void tst_QVideoWidget::brightnessWindowControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setBrightness(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - // Test the video widget resets the controls starting brightness to the default. - QCOMPARE(widget.brightness(), 0); - - QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int))); - - // Test the video widget sets the brightness value, bounded if necessary and emits a changed - // signal. - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(object.testService->windowControl->brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - // Test the changed signal isn't emitted if the value is unchanged. - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(object.testService->windowControl->brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - - // Test the changed signal is emitted if the brightness is changed internally. - object.testService->windowControl->setBrightness(controlValue); - QCOMPARE(widget.brightness(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::brightnessWidgetControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setBrightness(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(widget.brightness(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int))); - - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(object.testService->widgetControl->brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(object.testService->widgetControl->brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->widgetControl->setBrightness(controlValue); - QCOMPARE(widget.brightness(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::brightnessRendererControl() -{ - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int))); - - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(spy.count(), 1); -} - -void tst_QVideoWidget::contrastWindowControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setContrast(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(widget.contrast(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.contrast(), 0); - - QSignalSpy spy(&widget, SIGNAL(contrastChanged(int))); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(object.testService->windowControl->contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(object.testService->windowControl->contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->windowControl->setContrast(controlValue); - QCOMPARE(widget.contrast(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::contrastWidgetControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setContrast(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - QCOMPARE(widget.contrast(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.contrast(), 0); - - QSignalSpy spy(&widget, SIGNAL(contrastChanged(int))); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(object.testService->widgetControl->contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(object.testService->widgetControl->contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->widgetControl->setContrast(controlValue); - QCOMPARE(widget.contrast(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::contrastRendererControl() -{ - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QSignalSpy spy(&widget, SIGNAL(contrastChanged(int))); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(spy.count(), 1); -} - -void tst_QVideoWidget::hueWindowControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setHue(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - QCOMPARE(widget.hue(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.hue(), 0); - - QSignalSpy spy(&widget, SIGNAL(hueChanged(int))); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(object.testService->windowControl->hue(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(object.testService->windowControl->hue(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->windowControl->setHue(controlValue); - QCOMPARE(widget.hue(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::hueWidgetControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setHue(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - QCOMPARE(widget.hue(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.hue(), 0); - - QSignalSpy spy(&widget, SIGNAL(hueChanged(int))); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(object.testService->widgetControl->hue(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(object.testService->widgetControl->hue(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->widgetControl->setHue(controlValue); - QCOMPARE(widget.hue(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::hueRendererControl() -{ - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QSignalSpy spy(&widget, SIGNAL(hueChanged(int))); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(spy.count(), 1); -} - -void tst_QVideoWidget::saturationWindowControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setSaturation(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - QCOMPARE(widget.saturation(), 0); - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.saturation(), 0); - - QSignalSpy spy(&widget, SIGNAL(saturationChanged(int))); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(object.testService->windowControl->saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(object.testService->windowControl->saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->windowControl->setSaturation(controlValue); - QCOMPARE(widget.saturation(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::saturationWidgetControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setSaturation(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(widget.saturation(), 0); - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.saturation(), 0); - - QSignalSpy spy(&widget, SIGNAL(saturationChanged(int))); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(object.testService->widgetControl->saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(object.testService->widgetControl->saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->widgetControl->setSaturation(controlValue); - QCOMPARE(widget.saturation(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); - -} - -void tst_QVideoWidget::saturationRendererControl() -{ - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - QSignalSpy spy(&widget, SIGNAL(saturationChanged(int))); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(spy.count(), 1); -} - -static const uchar rgb32ImageData[] = -{ - 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, - 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00 -}; - -void tst_QVideoWidget::paintRendererControl() -{ - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QPainterVideoSurface *surface = qobject_cast<QPainterVideoSurface *>( - object.testService->rendererControl->surface()); - - QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32); - - QVERIFY(surface->start(format)); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); - - QCoreApplication::processEvents(QEventLoop::AllEvents); - - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); - - QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32); - - frame.map(QAbstractVideoBuffer::WriteOnly); - memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes()); - frame.unmap(); - - QVERIFY(surface->present(frame)); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), false); - - //wait up to 2 seconds for the frame to be presented - for (int i=0; i<200 && !surface->isReady(); i++) - QTest::qWait(10); - - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); -} - -QTEST_MAIN(tst_QVideoWidget) - -#include "tst_qvideowidget.moc" diff --git a/tests/auto/xmlpatterns.pro b/tests/auto/xmlpatterns.pro index 923f2c4..b9244d6 100644 --- a/tests/auto/xmlpatterns.pro +++ b/tests/auto/xmlpatterns.pro @@ -36,6 +36,7 @@ SUBDIRS=\ xmlpatternsdiagnosticsts.depends = xmlpatternssdk xmlpatternsview.depends = xmlpatternssdk xmlpatternsxslts.depends = xmlpatternssdk +xmlpatternsxqts.depends = xmlpatternssdk xmlpatternsschemats.depends = xmlpatternssdk xmlpatternsxqts.depends = xmlpatternssdk diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index beaf9bd..ee49bbf 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -274,9 +274,7 @@ Configure::Configure( int& argc, char** argv ) dictionary[ "PHONON" ] = "auto"; dictionary[ "PHONON_BACKEND" ] = "yes"; dictionary[ "MULTIMEDIA" ] = "yes"; - dictionary[ "MEDIASERVICES" ] = "yes"; dictionary[ "AUDIO_BACKEND" ] = "auto"; - dictionary[ "MEDIA_BACKEND"] = "auto"; dictionary[ "WMSDK" ] = "auto"; dictionary[ "DIRECTSHOW" ] = "no"; dictionary[ "WEBKIT" ] = "auto"; @@ -933,18 +931,10 @@ void Configure::parseCmdLine() dictionary[ "MULTIMEDIA" ] = "no"; } else if( configCmdLine.at(i) == "-multimedia" ) { dictionary[ "MULTIMEDIA" ] = "yes"; - } else if( configCmdLine.at(i) == "-no-mediaservices" ) { - dictionary[ "MEDIASERVICES" ] = "no"; - } else if( configCmdLine.at(i) == "-mediaservices" ) { - dictionary[ "MEDIASERVICES" ] = "yes"; } else if( configCmdLine.at(i) == "-audio-backend" ) { dictionary[ "AUDIO_BACKEND" ] = "yes"; } else if( configCmdLine.at(i) == "-no-audio-backend" ) { dictionary[ "AUDIO_BACKEND" ] = "no"; - } else if( configCmdLine.at(i) == "-media-backend") { - dictionary[ "MEDIA_BACKEND" ] = "yes"; - } else if (configCmdLine.at(i) == "-no-media-backend") { - dictionary[ "MEDIA_BACKEND" ] = "no"; } else if( configCmdLine.at(i) == "-no-phonon" ) { dictionary[ "PHONON" ] = "no"; } else if( configCmdLine.at(i) == "-phonon" ) { @@ -1630,7 +1620,6 @@ bool Configure::displayHelp() "[-qtnamespace <namespace>] [-qtlibinfix <infix>] [-no-phonon]\n" "[-phonon] [-no-phonon-backend] [-phonon-backend]\n" "[-no-multimedia] [-multimedia] [-no-audio-backend] [-audio-backend]\n" - "[-no-mediaservices] [-mediaservices] [-no-media-backend] [-media-backend]\n" "[-no-script] [-script] [-no-scripttools] [-scripttools]\n" "[-no-webkit] [-webkit] [-graphicssystem raster|opengl|openvg]\n\n", 0, 7); @@ -1815,10 +1804,6 @@ bool Configure::displayHelp() desc("MULTIMEDIA", "yes","-multimedia", "Compile in multimedia module"); desc("AUDIO_BACKEND", "no","-no-audio-backend", "Do not compile in the platform audio backend into QtMultimedia"); desc("AUDIO_BACKEND", "yes","-audio-backend", "Compile in the platform audio backend into QtMultimedia"); - desc("MEDIASERVICES", "no", "-no-mediaservices","Do not compile the QtMediaServices module"); - desc("MEDIASERVICES", "yes","-mediaservices", "Compile in QtMediaServices module"); - desc("MEDIA_BACKEND", "no","-no-media-backend", "Do not compile in the platform-specific QtMediaServices media service."); - desc("MEDIA_BACKEND", "yes","-media-backend", "Compile in the platform-specific QtMediaServices media service."); desc("WEBKIT", "no", "-no-webkit", "Do not compile in the WebKit module"); desc("WEBKIT", "yes", "-webkit", "Compile in the WebKit module (WebKit is built if a decent C++ compiler is used.)"); desc("SCRIPT", "no", "-no-script", "Do not build the QtScript module."); @@ -2100,7 +2085,7 @@ bool Configure::checkAvailability(const QString &part) && dictionary.value("QMAKESPEC") != "win32-msvc.net" // Leave for now, since we can't be sure if they are using 2002 or 2003 with this spec && dictionary.value("QMAKESPEC") != "win32-msvc2002" && dictionary.value("EXCEPTIONS") == "yes"; - } else if (part == "PHONON" || part == "MEDIA_BACKEND") { + } else if (part == "PHONON") { if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) { available = true; } else { @@ -2264,8 +2249,6 @@ void Configure::autoDetection() dictionary["DECLARATIVE"] = dictionary["SCRIPT"] == "yes" ? "yes" : "no"; if (dictionary["AUDIO_BACKEND"] == "auto") dictionary["AUDIO_BACKEND"] = checkAvailability("AUDIO_BACKEND") ? "yes" : "no"; - if (dictionary["MEDIA_BACKEND"] == "auto") - dictionary["MEDIA_BACKEND"] = checkAvailability("MEDIA_BACKEND") ? "yes" : "no"; if (dictionary["WMSDK"] == "auto") dictionary["WMSDK"] = checkAvailability("WMSDK") ? "yes" : "no"; @@ -2666,14 +2649,6 @@ void Configure::generateOutputVars() qtConfig += "multimedia"; if (dictionary["AUDIO_BACKEND"] == "yes") qtConfig += "audio-backend"; - if (dictionary["MEDIASERVICES"] == "yes") { - qtConfig += "mediaservices"; - if (dictionary["MEDIA_BACKEND"] == "yes") { - qtConfig += "media-backend"; - if (dictionary["WMSDK"] == "yes") - qtConfig += "wmsdk"; - } - } } if (dictionary["WEBKIT"] == "yes") @@ -3075,7 +3050,6 @@ void Configure::generateConfigfiles() if(dictionary["DECLARATIVE"] == "no") qconfigList += "QT_NO_DECLARATIVE"; if(dictionary["PHONON"] == "no") qconfigList += "QT_NO_PHONON"; if(dictionary["MULTIMEDIA"] == "no") qconfigList += "QT_NO_MULTIMEDIA"; - if(dictionary["MEDIASERVICES"] == "no") qconfigList += "QT_NO_MEDIASERVICES"; if(dictionary["XMLPATTERNS"] == "no") qconfigList += "QT_NO_XMLPATTERNS"; if(dictionary["SCRIPT"] == "no") qconfigList += "QT_NO_SCRIPT"; if(dictionary["SCRIPTTOOLS"] == "no") qconfigList += "QT_NO_SCRIPTTOOLS"; @@ -3378,7 +3352,6 @@ void Configure::displayConfig() cout << "QtXmlPatterns support......." << dictionary[ "XMLPATTERNS" ] << endl; cout << "Phonon support.............." << dictionary[ "PHONON" ] << endl; cout << "QtMultimedia support........" << dictionary[ "MULTIMEDIA" ] << endl; - cout << "QtMediaServices support....." << dictionary[ "MEDIASERVICES" ] << endl; cout << "WebKit support.............." << dictionary[ "WEBKIT" ] << endl; cout << "Declarative support........." << dictionary[ "DECLARATIVE" ] << endl; cout << "QtScript support............" << dictionary[ "SCRIPT" ] << endl; diff --git a/translations/qt_de.ts b/translations/qt_de.ts index 86d5edb..226b7da 100644 --- a/translations/qt_de.ts +++ b/translations/qt_de.ts @@ -3683,15 +3683,6 @@ Möchten Sie die Datei trotzdem löschen?</translation> </message> </context> <context> - <name>QGstreamerPlayerSession</name> - <message> - <location filename="../src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp" line="+423"/> - <location line="+16"/> - <source>Unable to play %1</source> - <translation>%1 kann nicht abgespielt werden</translation> - </message> -</context> -<context> <name>QHostInfo</name> <message> <location filename="../src/network/kernel/qhostinfo_p.h" line="+103"/> diff --git a/translations/qt_pl.ts b/translations/qt_pl.ts index a089cb6..1f5ceb0 100644 --- a/translations/qt_pl.ts +++ b/translations/qt_pl.ts @@ -3757,15 +3757,6 @@ ProszÄ™ o sprawdzenie podanej nazwy pliku.</translation> </message> </context> <context> - <name>QGstreamerPlayerSession</name> - <message> - <location filename="../src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp" line="+423"/> - <location line="+16"/> - <source>Unable to play %1</source> - <translation>Nie można odtworzyć %1</translation> - </message> -</context> -<context> <name>QHostInfo</name> <message> <location filename="../src/network/kernel/qhostinfo_p.h" line="+103"/> @@ -4592,39 +4583,6 @@ ProszÄ™ o sprawdzenie podanej nazwy pliku.</translation> </message> </context> <context> - <name>QMediaPlayer</name> - <message> - <location filename="../src/multimedia/mediaservices/playback/qmediaplayer.cpp" line="+496"/> - <source>The QMediaPlayer object does not have a valid service</source> - <translation type="unfinished"></translation> - </message> -</context> -<context> - <name>QMediaPlaylist</name> - <message> - <location filename="../src/multimedia/mediaservices/base/qmediaplaylist.cpp" line="+455"/> - <location line="+46"/> - <source>Could not add items to read only playlist.</source> - <translation>Nie można dodać elementów do listy odtwarzania (tylko do odczytu).</translation> - </message> - <message> - <location line="-27"/> - <location line="+46"/> - <source>Playlist format is not supported</source> - <translation>Format listy odtwarzania nie jest obsÅ‚ugiwany</translation> - </message> - <message> - <location line="+26"/> - <source>The file could not be accessed.</source> - <translation>Brak dostÄ™pu do pliku.</translation> - </message> - <message> - <location line="+35"/> - <source>Playlist format is not supported.</source> - <translation>Format listy odtwarzania nie jest obsÅ‚ugiwany.</translation> - </message> -</context> -<context> <name>QMenu</name> <message> <location filename="../src/plugins/accessible/widgets/qaccessiblemenu.cpp" line="+157"/> diff --git a/translations/translations.pri b/translations/translations.pri index 3c4bdd1..2edc89a 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -8,11 +8,7 @@ defineReplace(prependAll) { return ($$result) } -LUPDATE = $$QT_BUILD_TREE/bin/lupdate -win32 { - LUPDATE ~= s,/,$$QMAKE_DIR_SEP, - LUPDATE = $${LUPDATE}.exe -} +qtPrepareTool(LUPDATE, lupdate) LUPDATE += -locations relative -no-ui-lines ###### Qt Libraries diff --git a/translations/translations.pro b/translations/translations.pro index ca83d07..cdaf04a 100644 --- a/translations/translations.pro +++ b/translations/translations.pro @@ -1,10 +1,6 @@ TRANSLATIONS = $$files(*.ts) -LRELEASE = $$QT_BUILD_TREE/bin/lrelease -win32 { - LRELEASE ~= s,/,$$QMAKE_DIR_SEP, - LRELEASE = $${LRELEASE}.exe -} +qtPrepareTool(LRELEASE, lrelease) contains(TEMPLATE_PREFIX, vc):vcproj = 1 diff --git a/util/s60pixelmetrics/pixel_metrics.cpp b/util/s60pixelmetrics/pixel_metrics.cpp index 0fd650e..42ae850 100644 --- a/util/s60pixelmetrics/pixel_metrics.cpp +++ b/util/s60pixelmetrics/pixel_metrics.cpp @@ -50,7 +50,7 @@ // so that we can keep dynamic and static values inline. // Please adjust version data if correcting dynamic PM calculations. const TInt KPMMajorVersion = 1; -const TInt KPMMinorVersion = 18; +const TInt KPMMinorVersion = 19; TPixelMetricsVersion PixelMetrics::Version() { @@ -468,7 +468,7 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) TAknLayoutRect sliderSettingRect; sliderSettingRect.LayoutRect( sliderRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_cp() ); TAknLayoutRect sliderGraph2Rect; - sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g2() ); + sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g6() ); value = sliderGraph2Rect.Rect().Width(); } break; @@ -483,7 +483,8 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) TAknLayoutRect sliderSettingRect; sliderSettingRect.LayoutRect( sliderRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_cp() ); TAknLayoutRect sliderGraph2Rect; - sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g2() ); + sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g6() ); + //todo: make a proper calculation for tick marks value = (TInt)(sliderGraph2Rect.Rect().Height()*1.5); // add assumed tickmark height } break; @@ -498,7 +499,8 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) TAknLayoutRect sliderSettingRect; sliderSettingRect.LayoutRect( sliderRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_cp() ); TAknLayoutRect sliderGraph2Rect; - sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g2() ); + sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g6() ); + //todo: make a proper calculation for tick marks value = (TInt)(sliderGraph2Rect.Rect().Height()*0.5); // no tickmarks in S60, lets assume they are half the size of slider indicator } break; @@ -513,7 +515,7 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) TAknLayoutRect sliderSettingRect; sliderSettingRect.LayoutRect( sliderRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_cp() ); TAknLayoutRect sliderGraph2Rect; - sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g2() ); + sliderGraph2Rect.LayoutRect( sliderSettingRect.Rect(), AknLayoutScalable_Avkon::slider_set_pane_g6() ); value = sliderGraph2Rect.Rect().Height(); } break; |