diff options
18 files changed, 455 insertions, 700 deletions
diff --git a/.qmake.conf b/.qmake.conf index ef45a002d..17a3a5783 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,4 +1,4 @@ load(qt_build_config) CONFIG += qt_example_installs -MODULE_VERSION = 5.3.1 +MODULE_VERSION = 5.4.0 diff --git a/examples/multimedia/audiorecorder/audiorecorder.cpp b/examples/multimedia/audiorecorder/audiorecorder.cpp index c77396b0f..2291fed52 100644 --- a/examples/multimedia/audiorecorder/audiorecorder.cpp +++ b/examples/multimedia/audiorecorder/audiorecorder.cpp @@ -47,11 +47,7 @@ #include "audiorecorder.h" #include "qaudiolevel.h" -#if defined(Q_WS_MAEMO_6) -#include "ui_audiorecorder_small.h" -#else #include "ui_audiorecorder.h" -#endif static qreal getPeakValue(const QAudioFormat &format); static QVector<qreal> getBufferLevels(const QAudioBuffer &buffer); diff --git a/examples/multimedia/audiorecorder/audiorecorder.pro b/examples/multimedia/audiorecorder/audiorecorder.pro index 7ea4c6fe2..79d6caf23 100644 --- a/examples/multimedia/audiorecorder/audiorecorder.pro +++ b/examples/multimedia/audiorecorder/audiorecorder.pro @@ -14,11 +14,7 @@ SOURCES = \ audiorecorder.cpp \ qaudiolevel.cpp -maemo*: { - FORMS += audiorecorder_small.ui -}else { - FORMS += audiorecorder.ui -} +FORMS += audiorecorder.ui target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audiorecorder INSTALLS += target diff --git a/examples/multimedia/audiorecorder/audiorecorder_small.ui b/examples/multimedia/audiorecorder/audiorecorder_small.ui deleted file mode 100644 index 2030ab963..000000000 --- a/examples/multimedia/audiorecorder/audiorecorder_small.ui +++ /dev/null @@ -1,286 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>AudioRecorder</class> - <widget class="QMainWindow" name="AudioRecorder"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>420</width> - <height>346</height> - </rect> - </property> - <property name="windowTitle"> - <string>MainWindow</string> - </property> - <widget class="QWidget" name="centralwidget"> - <layout class="QGridLayout" name="gridLayout_5"> - <item row="0" column="0" colspan="3"> - <widget class="QScrollArea" name="scrollArea"> - <property name="focusPolicy"> - <enum>Qt::ClickFocus</enum> - </property> - <property name="widgetResizable"> - <bool>true</bool> - </property> - <widget class="QWidget" name="scrollAreaWidgetContents"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>277</height> - </rect> - </property> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="0"> - <widget class="QWidget" name="widget" native="true"> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="3" column="0"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>Audio Level:</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>29</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0"> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QRadioButton" name="constantQualityRadioButton"> - <property name="text"> - <string>Quality:</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QRadioButton" name="constantBitrateRadioButton"> - <property name="text"> - <string>Bitrate:</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QSlider" name="qualitySlider"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>1</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QComboBox" name="bitrateBox"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>1</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </item> - <item row="0" column="0"> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="3" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Sample rate:</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Audio Codec:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QComboBox" name="containerBox"/> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="audioDeviceBox"/> - </item> - <item row="3" column="1"> - <widget class="QComboBox" name="sampleRateBox"/> - </item> - <item row="1" column="1"> - <widget class="QComboBox" name="audioCodecBox"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>File Container:</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Input Device:</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Channels:</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QComboBox" name="channelsBox"/> - </item> - </layout> - </item> - <item row="4" column="0"> - <layout class="QVBoxLayout" name="levelsLayout"/> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </widget> - </item> - <item row="1" column="0"> - <widget class="QPushButton" name="outputButton"> - <property name="text"> - <string>Output...</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QPushButton" name="recordButton"> - <property name="text"> - <string>Record</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QPushButton" name="pauseButton"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Pause</string> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QStatusBar" name="statusbar"/> - </widget> - <resources/> - <connections> - <connection> - <sender>constantQualityRadioButton</sender> - <signal>toggled(bool)</signal> - <receiver>qualitySlider</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>113</x> - <y>197</y> - </hint> - <hint type="destinationlabel"> - <x>115</x> - <y>223</y> - </hint> - </hints> - </connection> - <connection> - <sender>constantBitrateRadioButton</sender> - <signal>toggled(bool)</signal> - <receiver>bitrateBox</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>173</x> - <y>259</y> - </hint> - <hint type="destinationlabel"> - <x>190</x> - <y>291</y> - </hint> - </hints> - </connection> - <connection> - <sender>outputButton</sender> - <signal>clicked()</signal> - <receiver>AudioRecorder</receiver> - <slot>setOutputLocation()</slot> - <hints> - <hint type="sourcelabel"> - <x>46</x> - <y>340</y> - </hint> - <hint type="destinationlabel"> - <x>6</x> - <y>302</y> - </hint> - </hints> - </connection> - <connection> - <sender>recordButton</sender> - <signal>clicked()</signal> - <receiver>AudioRecorder</receiver> - <slot>toggleRecord()</slot> - <hints> - <hint type="sourcelabel"> - <x>191</x> - <y>340</y> - </hint> - <hint type="destinationlabel"> - <x>113</x> - <y>317</y> - </hint> - </hints> - </connection> - <connection> - <sender>pauseButton</sender> - <signal>clicked()</signal> - <receiver>AudioRecorder</receiver> - <slot>togglePause()</slot> - <hints> - <hint type="sourcelabel"> - <x>252</x> - <y>334</y> - </hint> - <hint type="destinationlabel"> - <x>258</x> - <y>346</y> - </hint> - </hints> - </connection> - </connections> - <slots> - <slot>setOutputLocation()</slot> - <slot>toggleRecord()</slot> - <slot>togglePause()</slot> - </slots> -</ui> diff --git a/examples/multimediawidgets/camera/camera.cpp b/examples/multimediawidgets/camera/camera.cpp index abbbf8333..3afe59324 100644 --- a/examples/multimediawidgets/camera/camera.cpp +++ b/examples/multimediawidgets/camera/camera.cpp @@ -53,10 +53,6 @@ #include <QtWidgets> -#if (defined(Q_WS_MAEMO_6)) && QT_VERSION >= 0x040700 -#define HAVE_CAMERA_BUTTONS -#endif - Camera::Camera(QWidget *parent) : QMainWindow(parent), ui(new Ui::Camera), @@ -88,10 +84,6 @@ Camera::Camera(QWidget *parent) : connect(videoDevicesGroup, SIGNAL(triggered(QAction*)), SLOT(updateCameraDevice(QAction*))); connect(ui->captureWidget, SIGNAL(currentChanged(int)), SLOT(updateCaptureMode())); -#ifdef HAVE_CAMERA_BUTTONS - ui->lockButton->hide(); -#endif - setCamera(cameraDevice); } diff --git a/examples/multimediawidgets/player/main.cpp b/examples/multimediawidgets/player/main.cpp index 3009d29e2..60867ce82 100644 --- a/examples/multimediawidgets/player/main.cpp +++ b/examples/multimediawidgets/player/main.cpp @@ -44,10 +44,6 @@ int main(int argc, char *argv[]) { -#ifdef Q_WS_MAEMO_6 - //Meego graphics system conflicts with xvideo during fullscreen transition - QApplication::setGraphicsSystem("raster"); -#endif QApplication app(argc, argv); Player player; diff --git a/src/multimedia/doc/qtmultimedia.qdocconf b/src/multimedia/doc/qtmultimedia.qdocconf index d6ff6822e..79acb2d54 100644 --- a/src/multimedia/doc/qtmultimedia.qdocconf +++ b/src/multimedia/doc/qtmultimedia.qdocconf @@ -26,7 +26,7 @@ qhp.QtMultimedia.subprojects.classes.selectors = class fake:headerfile qhp.QtMultimedia.subprojects.classes.sortPages = true qhp.QtMultimedia.subprojects.qmltypes.title = QML Types qhp.QtMultimedia.subprojects.qmltypes.indexTitle = Qt Multimedia QML Types -qhp.QtMultimedia.subprojects.qmltypes.selectors = fake:qmlclass +qhp.QtMultimedia.subprojects.qmltypes.selectors = qmlclass qhp.QtMultimedia.subprojects.qmltypes.sortPages = true exampledirs += ../../../examples/multimedia \ diff --git a/src/multimedia/video/qvideoframe.cpp b/src/multimedia/video/qvideoframe.cpp index ad81c80e7..4a32bc557 100644 --- a/src/multimedia/video/qvideoframe.cpp +++ b/src/multimedia/video/qvideoframe.cpp @@ -1017,7 +1017,7 @@ static QString qFormatTimeStamps(qint64 start, qint64 end) QDebug operator<<(QDebug dbg, const QVideoFrame& f) { - dbg.nospace() << "QVideoFrame(" << f.size() << "," + dbg.nospace() << "QVideoFrame(" << f.size() << ", " << f.pixelFormat() << ", " << f.handleType() << ", " << f.mapMode() << ", " diff --git a/src/plugins/resourcepolicy/resourcepolicy.pro b/src/plugins/resourcepolicy/resourcepolicy.pro index 7aa1ced9f..4805c5250 100644 --- a/src/plugins/resourcepolicy/resourcepolicy.pro +++ b/src/plugins/resourcepolicy/resourcepolicy.pro @@ -13,9 +13,11 @@ INCLUDEPATH += $$PWD \ HEADERS += \ $$PWD/resourcepolicyplugin.h \ - $$PWD/resourcepolicyimpl.h + $$PWD/resourcepolicyimpl.h \ + $$PWD/resourcepolicyint.h SOURCES += \ $$PWD/resourcepolicyplugin.cpp \ - $$PWD/resourcepolicyimpl.cpp + $$PWD/resourcepolicyimpl.cpp \ + $$PWD/resourcepolicyint.cpp diff --git a/src/plugins/resourcepolicy/resourcepolicyimpl.cpp b/src/plugins/resourcepolicy/resourcepolicyimpl.cpp index 0acabc001..3ad92fa1f 100644 --- a/src/plugins/resourcepolicy/resourcepolicyimpl.cpp +++ b/src/plugins/resourcepolicy/resourcepolicyimpl.cpp @@ -40,99 +40,62 @@ ** ****************************************************************************/ +#include <QGlobalStatic> + #include <policy/resource.h> #include <policy/resources.h> #include <policy/resource-set.h> #include "resourcepolicyimpl.h" +#include "resourcepolicyint.h" + +Q_GLOBAL_STATIC(ResourcePolicyInt, globalResourcePolicyInt); ResourcePolicyImpl::ResourcePolicyImpl(QObject *parent) : QMediaPlayerResourceSetInterface(parent) - , m_status(Initial) - , m_videoEnabled(false) { - m_resourceSet = new ResourcePolicy::ResourceSet("player", this); - m_resourceSet->setAlwaysReply(); - - ResourcePolicy::AudioResource *audioResource = new ResourcePolicy::AudioResource("player"); - audioResource->setProcessID(QCoreApplication::applicationPid()); - audioResource->setStreamTag("media.name", "*"); - m_resourceSet->addResourceObject(audioResource); - - m_resourceSet->update(); + ResourcePolicyInt *set = globalResourcePolicyInt; + set->addClient(this); +} - connect(m_resourceSet, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)), - this, SLOT(handleResourcesGranted())); - connect(m_resourceSet, SIGNAL(resourcesDenied()), - this, SLOT(handleResourcesDenied())); - connect(m_resourceSet, SIGNAL(lostResources()), - this, SLOT(handleResourcesLost())); - connect(m_resourceSet, SIGNAL(resourcesReleasedByManager()), - this, SLOT(handleResourcesLost())); +ResourcePolicyImpl::~ResourcePolicyImpl() +{ + ResourcePolicyInt *set = globalResourcePolicyInt; + set->removeClient(this); } bool ResourcePolicyImpl::isVideoEnabled() const { - return m_videoEnabled; + ResourcePolicyInt *set = globalResourcePolicyInt; + return set->isVideoEnabled(this); } void ResourcePolicyImpl::setVideoEnabled(bool videoEnabled) { - if (m_videoEnabled != videoEnabled) { - m_videoEnabled = videoEnabled; - - if (videoEnabled) - m_resourceSet->addResource(ResourcePolicy::VideoPlaybackType); - else - m_resourceSet->deleteResource(ResourcePolicy::VideoPlaybackType); - - m_resourceSet->update(); - } + ResourcePolicyInt *set = globalResourcePolicyInt; + set->setVideoEnabled(this, videoEnabled); } void ResourcePolicyImpl::acquire() { - m_status = RequestedResource; - m_resourceSet->acquire(); + ResourcePolicyInt *set = globalResourcePolicyInt; + set->acquire(this); } void ResourcePolicyImpl::release() { - m_resourceSet->release(); - m_status = Initial; + ResourcePolicyInt *set = globalResourcePolicyInt; + set->release(this); } bool ResourcePolicyImpl::isGranted() const { - return m_status == GrantedResource; + ResourcePolicyInt *set = globalResourcePolicyInt; + return set->isGranted(this); } bool ResourcePolicyImpl::isAvailable() const { - // TODO: is this used? what is it for? - qWarning() << Q_FUNC_INFO << "Stub"; - return true; + ResourcePolicyInt *set = globalResourcePolicyInt; + return set->isAvailable(); } - -void ResourcePolicyImpl::handleResourcesGranted() -{ - m_status = GrantedResource; - emit resourcesGranted(); -} - -void ResourcePolicyImpl::handleResourcesDenied() -{ - m_status = Initial; - emit resourcesDenied(); -} - -void ResourcePolicyImpl::handleResourcesLost() -{ - if (m_status != Initial) { - m_status = Initial; - emit resourcesLost(); - } - - m_resourceSet->release(); -} - diff --git a/src/plugins/resourcepolicy/resourcepolicyimpl.h b/src/plugins/resourcepolicy/resourcepolicyimpl.h index 8680df86a..28393b789 100644 --- a/src/plugins/resourcepolicy/resourcepolicyimpl.h +++ b/src/plugins/resourcepolicy/resourcepolicyimpl.h @@ -56,6 +56,7 @@ class ResourcePolicyImpl : public QMediaPlayerResourceSetInterface Q_OBJECT public: ResourcePolicyImpl(QObject *parent = 0); + ~ResourcePolicyImpl(); bool isVideoEnabled() const; void setVideoEnabled(bool videoEnabled); @@ -63,22 +64,6 @@ public: void release(); bool isGranted() const; bool isAvailable() const; - -private slots: - void handleResourcesGranted(); - void handleResourcesDenied(); - void handleResourcesLost(); - -private: - enum ResourceStatus { - Initial = 0, - RequestedResource, - GrantedResource - }; - - bool m_videoEnabled; - ResourcePolicy::ResourceSet *m_resourceSet; - ResourceStatus m_status; }; #endif // RESOURCEPOLICYIMPL_H diff --git a/src/plugins/resourcepolicy/resourcepolicyint.cpp b/src/plugins/resourcepolicy/resourcepolicyint.cpp new file mode 100644 index 000000000..2fff64bfb --- /dev/null +++ b/src/plugins/resourcepolicy/resourcepolicyint.cpp @@ -0,0 +1,311 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Jolla Ltd, author: <robin.burchell@jollamobile.com> +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <policy/resource.h> +#include <policy/resources.h> +#include <policy/resource-set.h> + +#include "resourcepolicyint.h" +#include "resourcepolicyimpl.h" + +#include <QMap> + +static int clientid = 0; + +ResourcePolicyInt::ResourcePolicyInt(QObject *parent) + : QObject(parent) + , m_acquired(0) + , m_status(Initial) + , m_video(0) + , m_resourceSet(0) +{ + m_resourceSet = new ResourcePolicy::ResourceSet("player", this); + m_resourceSet->setAlwaysReply(); + + ResourcePolicy::AudioResource *audioResource = new ResourcePolicy::AudioResource("player"); + audioResource->setProcessID(QCoreApplication::applicationPid()); + audioResource->setStreamTag("media.name", "*"); + m_resourceSet->addResourceObject(audioResource); + + m_resourceSet->update(); + + connect(m_resourceSet, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)), + this, SLOT(handleResourcesGranted())); + connect(m_resourceSet, SIGNAL(resourcesDenied()), + this, SLOT(handleResourcesDenied())); + connect(m_resourceSet, SIGNAL(lostResources()), + this, SLOT(handleResourcesLost())); + connect(m_resourceSet, SIGNAL(resourcesReleasedByManager()), + this, SLOT(handleResourcesLost())); +} + +ResourcePolicyInt::~ResourcePolicyInt() +{ + delete m_resourceSet; + m_resourceSet = 0; +#ifdef RESOURCE_DEBUG + qDebug() << "##### Tearing down singleton."; +#endif +} + +void ResourcePolicyInt::addClient(ResourcePolicyImpl *client) +{ + clientEntry entry; + entry.id = clientid++; + entry.client = client; + entry.status = Initial; + entry.videoEnabled = false; + m_clients.insert(entry.client, entry); +#ifdef RESOURCE_DEBUG + qDebug() << "##### Add client " << client << " : " << entry.id; +#endif +} + +void ResourcePolicyInt::removeClient(ResourcePolicyImpl *client) +{ + QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.find(client); + if (i != m_clients.end()) { +#ifdef RESOURCE_DEBUG + qDebug() << "##### Remove client " << client << " : " << i.value().id; +#endif + if (i.value().status == GrantedResource) + --m_acquired; + m_clients.erase(i); + } + + if (m_acquired == 0) { +#ifdef RESOURCE_DEBUG + qDebug() << "##### Remove client, acquired = 0, release"; +#endif + m_resourceSet->release(); + m_status = Initial; + } +} + +bool ResourcePolicyInt::isVideoEnabled(const ResourcePolicyImpl *client) const +{ + QMap<const ResourcePolicyImpl*, clientEntry>::const_iterator i = m_clients.find(client); + if (i != m_clients.constEnd()) + return i.value().videoEnabled; + + return false; +} + +void ResourcePolicyInt::setVideoEnabled(const ResourcePolicyImpl *client, bool videoEnabled) +{ + bool update = false; + + QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.find(client); + if (i != m_clients.end()) { + if (videoEnabled == i.value().videoEnabled) + return; + + if (videoEnabled) { + if (m_video > 0) { + i.value().videoEnabled = true; + } else { + m_resourceSet->addResource(ResourcePolicy::VideoPlaybackType); + update = true; + } + ++m_video; + } else { + --m_video; + i.value().videoEnabled = false; + if (m_video == 0) { + m_resourceSet->deleteResource(ResourcePolicy::VideoPlaybackType); + update = true; + } + } + } + + if (update) + m_resourceSet->update(); +} + +void ResourcePolicyInt::acquire(const ResourcePolicyImpl *client) +{ + QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.find(client); + if (i != m_clients.end()) { +#ifdef RESOURCE_DEBUG + qDebug() << "##### " << i.value().id << ": ACQUIRE"; +#endif + if (i.value().status == Initial) { + + if (m_status == RequestedResource) { + i.value().status = RequestedResource; +#ifdef RESOURCE_DEBUG + qDebug() << "##### " << i.value().id << ": Already requesting, set client as RequestResource and return"; +#endif + return; + } + + if (m_status == GrantedResource) { + ++m_acquired; +#ifdef RESOURCE_DEBUG + qDebug() << "##### " << i.value().id << ": Already granted, set as GrantedResource and return"; +#endif + i.value().status = GrantedResource; + emit i.value().client->resourcesGranted(); + return; + } + } else if (i.value().status == RequestedResource) { +#ifdef RESOURCE_DEBUG + qDebug() << "##### " << i.value().id << ": Already requesting, return"; +#endif + return; + } else { +#ifdef RESOURCE_DEBUG + qDebug() << "##### " << i.value().id << ": Already granted, return "; +#endif + return; + } + i.value().status = RequestedResource; + m_status = RequestedResource; + +#ifdef RESOURCE_DEBUG + qDebug() << "##### " << i.value().id << ": ACQUIRE call resourceSet->acquire()"; +#endif + // If m_status was Initial this is the first time resources are requested, + // so let's actually do the acquiring + m_resourceSet->acquire(); + } +} + +void ResourcePolicyInt::release(const ResourcePolicyImpl *client) +{ + QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.find(client); + if (i != m_clients.end()) { + if (i.value().status == GrantedResource) { + i.value().status = Initial; + --m_acquired; +#ifdef RESOURCE_DEBUG + qDebug() << "##### " << i.value().id << ": RELEASE, acquired (" << m_acquired << ")"; +#endif + } + } + + if (m_acquired == 0) { +#ifdef RESOURCE_DEBUG + qDebug() << "##### " << i.value().id << ": RELEASE call resourceSet->release()"; +#endif + m_resourceSet->release(); + m_status = Initial; + } +} + +bool ResourcePolicyInt::isGranted(const ResourcePolicyImpl *client) const +{ + QMap<const ResourcePolicyImpl*, clientEntry>::const_iterator i = m_clients.find(client); + if (i != m_clients.constEnd()) { +#ifdef RESOURCE_DEBUG + qDebug() << "##### " << i.value().id << ": IS GRANTED, status: " << i.value().status; +#endif + return i.value().status == GrantedResource; + } + + return false; +} + +bool ResourcePolicyInt::isAvailable() const +{ + // TODO: is this used? what is it for? + qWarning() << Q_FUNC_INFO << "Stub"; + return true; +} + +void ResourcePolicyInt::handleResourcesGranted() +{ + m_status = GrantedResource; + QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.begin(); + while (i != m_clients.end()) { + if (i.value().status == RequestedResource) { + ++m_acquired; +#ifdef RESOURCE_DEBUG + qDebug() << "##### " << i.value().id << ": HANDLE GRANTED, acquired (" << m_acquired << ") emitting resourcesGranted()"; +#endif + i.value().status = GrantedResource; + emit i.value().client->resourcesGranted(); + } + ++i; + } +} + +void ResourcePolicyInt::handleResourcesDenied() +{ + m_status = Initial; + m_acquired = 0; + QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.begin(); + while (i != m_clients.end()) { + if (i.value().status == RequestedResource) { +#ifdef RESOURCE_DEBUG + qDebug() << "##### " << i.value().id << ": HANDLE DENIED, acquired (" << m_acquired << ") emitting resourcesDenied()"; +#endif + i.value().status = Initial; + emit i.value().client->resourcesDenied(); + } + // Do we need to act for clients that are in granted state? + ++i; + } +} + +void ResourcePolicyInt::handleResourcesLost() +{ + if (m_status != Initial) { + m_status = Initial; + } + + m_acquired = 0; + m_resourceSet->release(); + + QMap<const ResourcePolicyImpl*, clientEntry>::iterator i = m_clients.begin(); + while (i != m_clients.end()) { + if (i.value().status != Initial) { +#ifdef RESOURCE_DEBUG + qDebug() << "##### " << i.value().id << ": HANDLE LOST, acquired (" << m_acquired << ") emitting resourcesLost()"; +#endif + i.value().status = Initial; + emit i.value().client->resourcesLost(); + } + ++i; + } +} diff --git a/src/plugins/resourcepolicy/resourcepolicyint.h b/src/plugins/resourcepolicy/resourcepolicyint.h new file mode 100644 index 000000000..39882b527 --- /dev/null +++ b/src/plugins/resourcepolicy/resourcepolicyint.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Jolla Ltd, author: <robin.burchell@jollamobile.com> +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef RESOURCEPOLICYINT_H +#define RESOURCEPOLICYINT_H + +#include <QObject> +#include <QMap> + +#include <private/qmediaresourceset_p.h> +#include "resourcepolicyimpl.h" + +namespace ResourcePolicy { + class ResourceSet; +}; + +enum ResourceStatus { + Initial = 0, + RequestedResource, + GrantedResource +}; + +struct clientEntry { + int id; + ResourcePolicyImpl *client; + ResourceStatus status; + bool videoEnabled; +}; + +class ResourcePolicyInt : public QObject +{ + Q_OBJECT +public: + ResourcePolicyInt(QObject *parent = 0); + ~ResourcePolicyInt(); + + bool isVideoEnabled(const ResourcePolicyImpl *client) const; + void setVideoEnabled(const ResourcePolicyImpl *client, bool videoEnabled); + void acquire(const ResourcePolicyImpl *client); + void release(const ResourcePolicyImpl *client); + bool isGranted(const ResourcePolicyImpl *client) const; + bool isAvailable() const; + + void addClient(ResourcePolicyImpl *client); + void removeClient(ResourcePolicyImpl *client); + +private slots: + void handleResourcesGranted(); + void handleResourcesDenied(); + void handleResourcesLost(); + +private: + QMap<const ResourcePolicyImpl*, clientEntry> m_clients; + + int m_acquired; + ResourceStatus m_status; + int m_video; + ResourcePolicy::ResourceSet *m_resourceSet; +}; + +#endif // RESOURCEPOLICYINT_H diff --git a/tests/auto/unit/qaudioformat/tst_qaudioformat.cpp b/tests/auto/unit/qaudioformat/tst_qaudioformat.cpp index 22a5dc135..b52cdebb9 100644 --- a/tests/auto/unit/qaudioformat/tst_qaudioformat.cpp +++ b/tests/auto/unit/qaudioformat/tst_qaudioformat.cpp @@ -69,9 +69,6 @@ private slots: void checkSizes(); void checkSizes_data(); - - void debugOperator(); - void debugOperator_data(); }; void tst_QAudioFormat::checkNull() @@ -316,42 +313,6 @@ void tst_QAudioFormat::checkSizes_data() QTest::newRow("2ch_16b_8k_signed_8000_duration4") << f << 4 << 8000 << qrtr << 2000 << 8000 << qrtr + 126 << 8004 << 2001; } -void tst_QAudioFormat::debugOperator_data() -{ - QTest::addColumn<QAudioFormat>("format"); - QTest::addColumn<QString>("stringized"); - - // A small sampling - QAudioFormat f; - f.setByteOrder(QAudioFormat::LittleEndian); - QTest::newRow("plain") << f << QString::fromLatin1("QAudioFormat(-1Hz, -1bit, channelCount=-1, sampleType=Unknown, byteOrder=LittleEndian, codec=\"\") "); - - f.setSampleRate(22050); - f.setChannelCount(4); - f.setCodec("audio/pcm"); - f.setSampleType(QAudioFormat::Float); - - QTest::newRow("float") << f << QString::fromLatin1("QAudioFormat(22050Hz, -1bit, channelCount=4, sampleType=Float, byteOrder=LittleEndian, codec=\"audio/pcm\") "); - - f.setSampleType(QAudioFormat::UnSignedInt); - QTest::newRow("unsigned") << f << QString::fromLatin1("QAudioFormat(22050Hz, -1bit, channelCount=4, sampleType=UnSignedInt, byteOrder=LittleEndian, codec=\"audio/pcm\") "); - - f.setSampleRate(44100); - QTest::newRow("44.1 unsigned") << f << QString::fromLatin1("QAudioFormat(44100Hz, -1bit, channelCount=4, sampleType=UnSignedInt, byteOrder=LittleEndian, codec=\"audio/pcm\") "); - - f.setByteOrder(QAudioFormat::BigEndian); - QTest::newRow("44.1 big unsigned") << f << QString::fromLatin1("QAudioFormat(44100Hz, -1bit, channelCount=4, sampleType=UnSignedInt, byteOrder=BigEndian, codec=\"audio/pcm\") "); -} - -void tst_QAudioFormat::debugOperator() -{ - QFETCH(QAudioFormat, format); - QFETCH(QString, stringized); - - QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData()); - qDebug() << format; -} - QTEST_MAIN(tst_QAudioFormat) #include "tst_qaudioformat.moc" diff --git a/tests/auto/unit/qcamera/tst_qcamera.cpp b/tests/auto/unit/qcamera/tst_qcamera.cpp index 3bbbc3650..61dd05b09 100644 --- a/tests/auto/unit/qcamera/tst_qcamera.cpp +++ b/tests/auto/unit/qcamera/tst_qcamera.cpp @@ -1126,21 +1126,21 @@ void tst_QCamera::testSetVideoOutputDestruction() void tst_QCamera::testEnumDebug() { - QTest::ignoreMessage(QtDebugMsg, "QCamera::ActiveState "); + QTest::ignoreMessage(QtDebugMsg, "QCamera::ActiveState"); qDebug() << QCamera::ActiveState; - QTest::ignoreMessage(QtDebugMsg, "QCamera::ActiveStatus "); + QTest::ignoreMessage(QtDebugMsg, "QCamera::ActiveStatus"); qDebug() << QCamera::ActiveStatus; - QTest::ignoreMessage(QtDebugMsg, "QCamera::CaptureVideo "); + QTest::ignoreMessage(QtDebugMsg, "QCamera::CaptureVideo"); qDebug() << QCamera::CaptureVideo; - QTest::ignoreMessage(QtDebugMsg, "QCamera::CameraError "); + QTest::ignoreMessage(QtDebugMsg, "QCamera::CameraError"); qDebug() << QCamera::CameraError; - QTest::ignoreMessage(QtDebugMsg, "QCamera::Unlocked "); + QTest::ignoreMessage(QtDebugMsg, "QCamera::Unlocked"); qDebug() << QCamera::Unlocked; - QTest::ignoreMessage(QtDebugMsg, "QCamera::LockAcquired "); + QTest::ignoreMessage(QtDebugMsg, "QCamera::LockAcquired"); qDebug() << QCamera::LockAcquired; - QTest::ignoreMessage(QtDebugMsg, "QCamera::NoLock "); + QTest::ignoreMessage(QtDebugMsg, "QCamera::NoLock"); qDebug() << QCamera::NoLock; - QTest::ignoreMessage(QtDebugMsg, "QCamera::LockExposure "); + QTest::ignoreMessage(QtDebugMsg, "QCamera::LockExposure"); qDebug() << QCamera::LockExposure; QTest::ignoreMessage(QtDebugMsg, "QCamera::FrontFace "); qDebug() << QCamera::FrontFace; diff --git a/tests/auto/unit/qmediaplayer/tst_qmediaplayer.cpp b/tests/auto/unit/qmediaplayer/tst_qmediaplayer.cpp index eed523aba..ff8933ff0 100644 --- a/tests/auto/unit/qmediaplayer/tst_qmediaplayer.cpp +++ b/tests/auto/unit/qmediaplayer/tst_qmediaplayer.cpp @@ -1106,11 +1106,11 @@ void tst_QMediaPlayer::testPositionPropertyWatch() void tst_QMediaPlayer::debugEnums() { - QTest::ignoreMessage(QtDebugMsg, "QMediaPlayer::PlayingState "); + QTest::ignoreMessage(QtDebugMsg, "QMediaPlayer::PlayingState"); qDebug() << QMediaPlayer::PlayingState; - QTest::ignoreMessage(QtDebugMsg, "QMediaPlayer::NoMedia "); + QTest::ignoreMessage(QtDebugMsg, "QMediaPlayer::NoMedia"); qDebug() << QMediaPlayer::NoMedia; - QTest::ignoreMessage(QtDebugMsg, "QMediaPlayer::NetworkError "); + QTest::ignoreMessage(QtDebugMsg, "QMediaPlayer::NetworkError"); qDebug() << QMediaPlayer::NetworkError; } diff --git a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp index c7dbfbe55..403320e59 100644 --- a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp +++ b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp @@ -93,15 +93,6 @@ private slots: void metadata(); - void debugType_data(); - void debugType(); - - void debug_data(); - void debug(); - - void debugFormat_data(); - void debugFormat(); - void isMapped(); void isReadable(); void isWritable(); @@ -1028,154 +1019,6 @@ void tst_QVideoFrame::isWritable() frame.unmap(); } -void tst_QVideoFrame::debugType_data() -{ - QTest::addColumn<QVideoFrame::FieldType>("fieldType"); - QTest::addColumn<QString>("stringized"); - - ADD_ENUM_TEST(ProgressiveFrame); - ADD_ENUM_TEST(InterlacedFrame); - ADD_ENUM_TEST(TopField); - ADD_ENUM_TEST(BottomField); -} - -void tst_QVideoFrame::debugType() -{ - QFETCH(QVideoFrame::FieldType, fieldType); - QFETCH(QString, stringized); - - QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData()); - qDebug() << fieldType; -} - -void tst_QVideoFrame::debug_data() -{ - QTest::addColumn<QVideoFrame>("frame"); - QTest::addColumn<QString>("stringized"); - - QVideoFrame f; - QTest::newRow("default") << f << QString::fromLatin1("QVideoFrame(QSize(-1, -1) , Format_Invalid, NoHandle, NotMapped, [no timestamp])"); - - QVideoFrame f2; - f2.setStartTime(12345); - f2.setEndTime(8000000000LL); - QTest::newRow("times") << f2 << QString::fromLatin1("QVideoFrame(QSize(-1, -1) , Format_Invalid, NoHandle, NotMapped, 0:00:00.12345 - 2:13:20.00)"); - - QVideoFrame f3; - f3.setFieldType(QVideoFrame::ProgressiveFrame); - QTest::newRow("times prog") << f3 << QString::fromLatin1("QVideoFrame(QSize(-1, -1) , Format_Invalid, NoHandle, NotMapped, [no timestamp])"); - - QVideoFrame f4; - f4.setFieldType(QVideoFrame::TopField); - QTest::newRow("times top") << f4 << QString::fromLatin1("QVideoFrame(QSize(-1, -1) , Format_Invalid, NoHandle, NotMapped, [no timestamp])"); - - QVideoFrame f5; - f5.setFieldType(QVideoFrame::TopField); - f5.setEndTime(90000000000LL); - QTest::newRow("end but no start") << f5 << QString::fromLatin1("QVideoFrame(QSize(-1, -1) , Format_Invalid, NoHandle, NotMapped, [no timestamp])"); - - QVideoFrame f6; - f6.setStartTime(12345000000LL); - f6.setEndTime(80000000000LL); - QTest::newRow("times big") << f6 << QString::fromLatin1("QVideoFrame(QSize(-1, -1) , Format_Invalid, NoHandle, NotMapped, 3:25:45.00 - 22:13:20.00)"); - - QVideoFrame g(0, QSize(320,240), 640, QVideoFrame::Format_ARGB32); - QTest::newRow("more valid") << g << QString::fromLatin1("QVideoFrame(QSize(320, 240) , Format_ARGB32, NoHandle, NotMapped, [no timestamp])"); - - QVideoFrame g2(0, QSize(320,240), 640, QVideoFrame::Format_ARGB32); - g2.setStartTime(9000000000LL); - g2.setEndTime(9000000000LL); - QTest::newRow("more valid") << g2 << QString::fromLatin1("QVideoFrame(QSize(320, 240) , Format_ARGB32, NoHandle, NotMapped, @2:30:00.00)"); - - QVideoFrame g3(0, QSize(320,240), 640, QVideoFrame::Format_ARGB32); - g3.setStartTime(900000LL); - g3.setEndTime(900000LL); - QTest::newRow("more valid single timestamp") << g3 << QString::fromLatin1("QVideoFrame(QSize(320, 240) , Format_ARGB32, NoHandle, NotMapped, @00:00.900000)"); - - QVideoFrame g4(0, QSize(320,240), 640, QVideoFrame::Format_ARGB32); - g4.setStartTime(200000000LL); - g4.setEndTime(300000000LL); - QTest::newRow("more valid") << g4 << QString::fromLatin1("QVideoFrame(QSize(320, 240) , Format_ARGB32, NoHandle, NotMapped, 03:20.00 - 05:00.00)"); - - QVideoFrame g5(0, QSize(320,240), 640, QVideoFrame::Format_ARGB32); - g5.setStartTime(200000000LL); - QTest::newRow("more valid until forever") << g5 << QString::fromLatin1("QVideoFrame(QSize(320, 240) , Format_ARGB32, NoHandle, NotMapped, 03:20.00 - forever)"); - - QVideoFrame g6(0, QSize(320,240), 640, QVideoFrame::Format_ARGB32); - g6.setStartTime(9000000000LL); - QTest::newRow("more valid for long forever") << g6 << QString::fromLatin1("QVideoFrame(QSize(320, 240) , Format_ARGB32, NoHandle, NotMapped, 2:30:00.00 - forever)"); - - QVideoFrame g7(0, QSize(320,240), 640, QVideoFrame::Format_ARGB32); - g7.setStartTime(9000000000LL); - g7.setMetaData("bar", 42); - QTest::newRow("more valid for long forever + metadata") << g7 << QString::fromLatin1("QVideoFrame(QSize(320, 240) , Format_ARGB32, NoHandle, NotMapped, 2:30:00.00 - forever, metaData: QMap((\"bar\", QVariant(int, 42) ) ) )"); -} - -void tst_QVideoFrame::debug() -{ - QFETCH(QVideoFrame, frame); - QFETCH(QString, stringized); - - QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData()); - qDebug() << frame; -} - -void tst_QVideoFrame::debugFormat_data() -{ - QTest::addColumn<QVideoFrame::PixelFormat>("format"); - QTest::addColumn<QString>("stringized"); - - ADD_ENUM_TEST(Format_Invalid); - ADD_ENUM_TEST(Format_ARGB32); - ADD_ENUM_TEST(Format_ARGB32_Premultiplied); - ADD_ENUM_TEST(Format_RGB32); - ADD_ENUM_TEST(Format_RGB24); - ADD_ENUM_TEST(Format_RGB565); - ADD_ENUM_TEST(Format_RGB555); - ADD_ENUM_TEST(Format_ARGB8565_Premultiplied); - ADD_ENUM_TEST(Format_BGRA32); - ADD_ENUM_TEST(Format_BGRA32_Premultiplied); - ADD_ENUM_TEST(Format_BGR32); - ADD_ENUM_TEST(Format_BGR24); - ADD_ENUM_TEST(Format_BGR565); - ADD_ENUM_TEST(Format_BGR555); - ADD_ENUM_TEST(Format_BGRA5658_Premultiplied); - - ADD_ENUM_TEST(Format_AYUV444); - ADD_ENUM_TEST(Format_AYUV444_Premultiplied); - ADD_ENUM_TEST(Format_YUV444); - ADD_ENUM_TEST(Format_YUV420P); - ADD_ENUM_TEST(Format_YV12); - ADD_ENUM_TEST(Format_UYVY); - ADD_ENUM_TEST(Format_YUYV); - ADD_ENUM_TEST(Format_NV12); - ADD_ENUM_TEST(Format_NV21); - ADD_ENUM_TEST(Format_IMC1); - ADD_ENUM_TEST(Format_IMC2); - ADD_ENUM_TEST(Format_IMC3); - ADD_ENUM_TEST(Format_IMC4); - ADD_ENUM_TEST(Format_Y8); - ADD_ENUM_TEST(Format_Y16); - - ADD_ENUM_TEST(Format_Jpeg); - - ADD_ENUM_TEST(Format_CameraRaw); - ADD_ENUM_TEST(Format_AdobeDng); - - // User enums are formatted differently - QTest::newRow("user 1000") << QVideoFrame::Format_User << QString::fromLatin1("UserType(1000)"); - QTest::newRow("user 1005") << QVideoFrame::PixelFormat(QVideoFrame::Format_User + 5) << QString::fromLatin1("UserType(1005)"); -} - -void tst_QVideoFrame::debugFormat() -{ - QFETCH(QVideoFrame::PixelFormat, format); - QFETCH(QString, stringized); - - QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData()); - qDebug() << format; -} - QTEST_MAIN(tst_QVideoFrame) #include "tst_qvideoframe.moc" diff --git a/tests/auto/unit/qvideosurfaceformat/tst_qvideosurfaceformat.cpp b/tests/auto/unit/qvideosurfaceformat/tst_qvideosurfaceformat.cpp index 0a78e1ba0..35e76b7e8 100644 --- a/tests/auto/unit/qvideosurfaceformat/tst_qvideosurfaceformat.cpp +++ b/tests/auto/unit/qvideosurfaceformat/tst_qvideosurfaceformat.cpp @@ -93,8 +93,6 @@ private slots: void assignAllParameters (); void propertyEdgeCases(); - void debugOperator(); - void debugOperator_data(); }; tst_QVideoSurfaceFormat::tst_QVideoSurfaceFormat() @@ -918,108 +916,6 @@ void tst_QVideoSurfaceFormat::propertyEdgeCases() QCOMPARE(original.pixelAspectRatio(), QSize(53, 45)); } -#define ADDDEBUGTEST(format, w, h, r) \ - QTest::newRow(#format "-" #w "x" #h "@" #r) \ - << QVideoFrame::Format_ ##format \ - << "Format_" #format \ - << QSize(w, h) \ - << r; - -void tst_QVideoSurfaceFormat::debugOperator_data() -{ - // This is not too exhaustive - QTest::addColumn<QVideoFrame::PixelFormat>("format"); - QTest::addColumn<QString>("formatString"); - QTest::addColumn<QSize>("frameSize"); - QTest::addColumn<int>("frameRate"); // could be double, but formatting is unstable - - ADDDEBUGTEST(Invalid, 100, 200, 3); - ADDDEBUGTEST(ARGB32,101, 201, 4); - ADDDEBUGTEST(ARGB32_Premultiplied, 100, 202, 5); - ADDDEBUGTEST(RGB32, 8, 16, 30); - ADDDEBUGTEST(RGB24, 8, 16, 30); - ADDDEBUGTEST(RGB565, 8, 16, 30); - ADDDEBUGTEST(RGB555, 8, 16, 30); - ADDDEBUGTEST(ARGB8565_Premultiplied, 8, 16, 30); - ADDDEBUGTEST(BGRA32, 8, 16, 30); - ADDDEBUGTEST(BGRA32_Premultiplied, 8, 16, 30); - ADDDEBUGTEST(BGR32, 8, 16, 30); - ADDDEBUGTEST(BGR24, 8, 16, 30); - ADDDEBUGTEST(BGR565, 8, 16, 30); - ADDDEBUGTEST(BGR555, 8, 16, 30); - ADDDEBUGTEST(BGRA5658_Premultiplied, 8, 16, 30); - - ADDDEBUGTEST(AYUV444, 8, 16, 30); - ADDDEBUGTEST(AYUV444, 8, 16, 31); - ADDDEBUGTEST(AYUV444_Premultiplied, 8, 16, 30); - ADDDEBUGTEST(YUV444, 8, 16, 30); - ADDDEBUGTEST(YUV420P, 8, 16, 30); - ADDDEBUGTEST(YV12, 8, 16, 30); - ADDDEBUGTEST(UYVY, 8, 16, 30); - ADDDEBUGTEST(YUYV, 8, 16, 30); - ADDDEBUGTEST(NV12, 8, 16, 30); - ADDDEBUGTEST(NV12, 80, 16, 30); - ADDDEBUGTEST(NV21, 8, 16, 30); - ADDDEBUGTEST(IMC1, 8, 16, 30); - ADDDEBUGTEST(IMC2, 8, 16, 30); - ADDDEBUGTEST(IMC3, 8, 16, 30); - ADDDEBUGTEST(IMC3, 8, 160, 30); - ADDDEBUGTEST(IMC4, 8, 16, 30); - ADDDEBUGTEST(Y8, 8, 16, 30); - ADDDEBUGTEST(Y16, 8, 16, 30); - - ADDDEBUGTEST(Jpeg, 8, 16, 30); - - ADDDEBUGTEST(CameraRaw, 8, 16, 30); - ADDDEBUGTEST(AdobeDng, 8, 16, 30); - - // User is special - QTest::newRow("User-0x0@0)") - << QVideoFrame::Format_User - << "UserType(1000)" - << QSize() - << 0; -} - -void tst_QVideoSurfaceFormat::debugOperator() -{ - QFETCH(QVideoFrame::PixelFormat, format); - QFETCH(QString, formatString); - QFETCH(QSize, frameSize); - QFETCH(int, frameRate); - - QString templateOutput = QString("QVideoSurfaceFormat(%1, QSize(%2, %3) , viewport=QRect(0,1 800x600) , pixelAspectRatio=QSize(320, 200) " - ", handleType=GLTextureHandle, yCbCrColorSpace=YCbCr_BT709)\n" - " handleType = QVariant(QAbstractVideoBuffer::HandleType, ) \n" - " pixelFormat = QVariant(QVideoFrame::PixelFormat, ) \n" - " frameSize = QVariant(QSize, QSize(%4, %5) ) \n" - " frameWidth = QVariant(int, %6) \n" - " viewport = QVariant(QRect, QRect(0,1 800x600) ) \n" - " scanLineDirection = QVariant(QVideoSurfaceFormat::Direction, ) \n" - " frameRate = QVariant(%7, %8) \n" - " pixelAspectRatio = QVariant(QSize, QSize(320, 200) ) \n" - " sizeHint = QVariant(QSize, QSize(1280, 600) ) \n" - " yCbCrColorSpace = QVariant(QVideoSurfaceFormat::YCbCrColorSpace, ) ") - .arg(formatString) - .arg(frameSize.width()) - .arg(frameSize.height()) - .arg(frameSize.width()) - .arg(frameSize.height()) - .arg(frameSize.width()) - .arg(sizeof(qreal) == sizeof(double) ? "double" : "float") - .arg(frameRate); - - QVideoSurfaceFormat vsf(frameSize, format, QAbstractVideoBuffer::GLTextureHandle); - vsf.setViewport(QRect(0,1, 800, 600)); - vsf.setPixelAspectRatio(QSize(320, 200)); - vsf.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709); - vsf.setFrameRate(frameRate); - - QTest::ignoreMessage(QtDebugMsg, templateOutput.toLatin1().constData()); - qDebug() << vsf; -} - - QTEST_MAIN(tst_QVideoSurfaceFormat) |