diff options
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/multimedia/multimedia.cpp | 4 | ||||
-rw-r--r-- | src/imports/multimedia/multimedia.pro | 5 | ||||
-rw-r--r-- | src/imports/multimedia/qdeclarativebackgroundaudio.cpp | 137 | ||||
-rw-r--r-- | src/imports/multimedia/qdeclarativebackgroundaudio_p.h | 97 | ||||
-rw-r--r-- | src/imports/multimedia/qdeclarativemediabase.cpp | 14 | ||||
-rw-r--r-- | src/imports/multimedia/qdeclarativemediabase_p.h | 2 | ||||
-rw-r--r-- | src/imports/multimedia/qdeclarativeradio.cpp | 212 | ||||
-rw-r--r-- | src/imports/multimedia/qdeclarativeradio_p.h | 175 | ||||
-rw-r--r-- | src/imports/multimedia/qsgvideonode_i420.cpp | 7 | ||||
-rw-r--r-- | src/imports/multimedia/qsgvideonode_rgb32.cpp | 5 |
10 files changed, 647 insertions, 11 deletions
diff --git a/src/imports/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp index 753fc431f..2de7401c9 100644 --- a/src/imports/multimedia/multimedia.cpp +++ b/src/imports/multimedia/multimedia.cpp @@ -48,6 +48,8 @@ #include "qdeclarativemediametadata_p.h" #include "qdeclarativeaudio_p.h" #include "qdeclarativevideooutput_p.h" +#include "qdeclarativeradio_p.h" +#include "qdeclarativebackgroundaudio_p.h" #include "qdeclarativecamera_p.h" #include "qdeclarativecamerapreviewprovider_p.h" #include "qdeclarativecameraexposure_p.h" @@ -72,6 +74,8 @@ public: qmlRegisterType<QDeclarativeAudio>(uri, 4, 0, "Audio"); qmlRegisterType<QDeclarativeAudio>(uri, 4, 0, "MediaPlayer"); qmlRegisterType<QDeclarativeVideoOutput>(uri, 4, 0, "VideoOutput"); + qmlRegisterType<QDeclarativeRadio>(uri, 4, 0, "Radio"); + qmlRegisterType<QDeclarativeBackgroundAudio>(uri, 4, 0, "BackgroundAudio"); qmlRegisterType<QDeclarativeCamera>(uri, 4, 0, "Camera"); qmlRegisterUncreatableType<QDeclarativeCameraCapture>(uri, 4, 0, "CameraCapture", trUtf8("CameraCapture is only provided by Camera element")); diff --git a/src/imports/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro index c300e9846..4574d0247 100644 --- a/src/imports/multimedia/multimedia.pro +++ b/src/imports/multimedia/multimedia.pro @@ -16,6 +16,8 @@ HEADERS += \ qsgvideonode_p.h \ qsgvideonode_i420.h \ qsgvideonode_rgb32.h \ + qdeclarativeradio_p.h \ + qdeclarativebackgroundaudio_p.h \ qdeclarativecamera_p.h \ qdeclarativecameracapture_p.h \ qdeclarativecamerarecorder_p.h \ @@ -25,7 +27,6 @@ HEADERS += \ qdeclarativecameraimageprocessing_p.h \ qdeclarativecamerapreviewprovider_p.h - SOURCES += \ multimedia.cpp \ qdeclarativeaudio.cpp \ @@ -34,6 +35,8 @@ SOURCES += \ qsgvideonode.cpp \ qsgvideonode_i420.cpp \ qsgvideonode_rgb32.cpp \ + qdeclarativeradio.cpp \ + qdeclarativebackgroundaudio.cpp \ qdeclarativecamera.cpp \ qdeclarativecameracapture.cpp \ qdeclarativecamerarecorder.cpp \ diff --git a/src/imports/multimedia/qdeclarativebackgroundaudio.cpp b/src/imports/multimedia/qdeclarativebackgroundaudio.cpp new file mode 100644 index 000000000..d56e9992f --- /dev/null +++ b/src/imports/multimedia/qdeclarativebackgroundaudio.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qdeclarativebackgroundaudio_p.h" +#include <qmediabackgroundplaybackcontrol.h> +#include <qmediaservice.h> + +void QDeclarativeBackgroundAudio::classBegin() +{ +} + +void QDeclarativeBackgroundAudio::componentComplete() +{ + setObject(this, QMediaServiceProviderHint(QMediaServiceProviderHint::BackgroundPlayback)); + if (m_mediaService) { + m_backgroundPlaybackControl = + static_cast<QMediaBackgroundPlaybackControl*>( + m_mediaService->requestControl(QMediaBackgroundPlaybackControl_iid)); + if (m_backgroundPlaybackControl) { + connect(m_backgroundPlaybackControl, SIGNAL(acquired()), this, SIGNAL(acquiredChanged())); + connect(m_backgroundPlaybackControl, SIGNAL(lost()), this, SIGNAL(acquiredChanged())); + if (!m_contextId.isEmpty()) + m_backgroundPlaybackControl->setContextId(m_contextId); + } else { + qWarning("can not get QMediaBackgroundPlaybackControl!"); + } + } + QDeclarativeMediaBase::componentComplete(); +} + +QDeclarativeBackgroundAudio::QDeclarativeBackgroundAudio(QObject *parent) + : QDeclarativeAudio(parent) + , m_backgroundPlaybackControl(0) +{ + +} + +QDeclarativeBackgroundAudio::~QDeclarativeBackgroundAudio() +{ + if (m_backgroundPlaybackControl) + m_mediaService->releaseControl(m_backgroundPlaybackControl); +} + +/*! + \qmlproperty string BackgroundAudio::contextId + + This property holds the unique contextId for the application + + When a new contextId is set, the previously set contextId will be released automatically. +*/ +QString QDeclarativeBackgroundAudio::contextId() const +{ + return m_contextId; +} + +void QDeclarativeBackgroundAudio::setContextId(QString contextId) +{ + if (m_contextId == contextId) + return; + m_contextId = contextId; + if (m_backgroundPlaybackControl) + m_backgroundPlaybackControl->setContextId(m_contextId); + emit contextIdChanged(); +} + +/*! + \qmlproperty bool BackgroundAudio::acquired + + This property indicates whether the application holds the playback resource in music daemon +*/ +bool QDeclarativeBackgroundAudio::isAcquired() const +{ + if (!m_backgroundPlaybackControl) + return false; + return m_backgroundPlaybackControl->isAcquired(); +} + +/*! + \qmlmethod BackgroundAudio::acquire() + + try to acquire the playback resource in music daemon +*/ +void QDeclarativeBackgroundAudio::acquire() +{ + if (isAcquired() || !m_backgroundPlaybackControl) + return; + m_backgroundPlaybackControl->acquire(); +} + +/*! + \qmlmethod BackgroundAudio::acquire() + + try to release the playback resource in music daemon +*/ +void QDeclarativeBackgroundAudio::release() +{ + if (!isAcquired() || !m_backgroundPlaybackControl) + return; + m_backgroundPlaybackControl->release(); +} diff --git a/src/imports/multimedia/qdeclarativebackgroundaudio_p.h b/src/imports/multimedia/qdeclarativebackgroundaudio_p.h new file mode 100644 index 000000000..f7f6778f9 --- /dev/null +++ b/src/imports/multimedia/qdeclarativebackgroundaudio_p.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QDECLARATIVEBACKGROUNDAUDIO_P_H +#define QDECLARATIVEBACKGROUNDAUDIO_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 "qdeclarativeaudio_p.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QMediaBackgroundPlaybackControl; +class QDeclarativeBackgroundAudio : public QDeclarativeAudio +{ + Q_OBJECT + Q_PROPERTY(QString contextId READ contextId WRITE setContextId NOTIFY contextIdChanged) + Q_PROPERTY(bool acquired READ isAcquired NOTIFY acquiredChanged) +public: + QDeclarativeBackgroundAudio(QObject *parent = 0); + ~QDeclarativeBackgroundAudio(); + + void classBegin(); + void componentComplete(); + + QString contextId() const; + void setContextId(QString contextId); + bool isAcquired() const; + +public Q_SLOTS: + void acquire(); + void release(); + +Q_SIGNALS: + void contextIdChanged(); + void acquiredChanged(); + +private: + Q_DISABLE_COPY(QDeclarativeBackgroundAudio) + QString m_contextId; + QMediaBackgroundPlaybackControl *m_backgroundPlaybackControl; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeBackgroundAudio)) + +QT_END_HEADER + +#endif // QDECLARATIVEBACKGROUNDAUDIO_P_H diff --git a/src/imports/multimedia/qdeclarativemediabase.cpp b/src/imports/multimedia/qdeclarativemediabase.cpp index 82e127407..a7435029b 100644 --- a/src/imports/multimedia/qdeclarativemediabase.cpp +++ b/src/imports/multimedia/qdeclarativemediabase.cpp @@ -260,12 +260,13 @@ void QDeclarativeMediaBase::shutdown() } -void QDeclarativeMediaBase::setObject(QObject *object) +void QDeclarativeMediaBase::setObject(QObject *object, const QMediaServiceProviderHint& hint) { m_qmlObject = object; if ((m_mediaProvider = QMediaServiceProvider::defaultServiceProvider()) != 0) { - if ((m_mediaService = m_mediaProvider->requestService(Q_MEDIASERVICE_MEDIAPLAYER)) != 0) { + m_mediaService = m_mediaProvider->requestService(Q_MEDIASERVICE_MEDIAPLAYER, hint); + if (m_mediaService != 0) { m_playerControl = qobject_cast<QMediaPlayerControl *>( m_mediaService->requestControl(QMediaPlayerControl_iid)); m_metaDataControl = qobject_cast<QMetaDataReaderControl *>( @@ -315,9 +316,12 @@ void QDeclarativeMediaBase::setObject(QObject *object) void QDeclarativeMediaBase::componentComplete() { - m_playerControl->setVolume(m_vol * 100); - m_playerControl->setMuted(m_muted); - m_playerControl->setPlaybackRate(m_playbackRate); + if (!qFuzzyCompare(m_vol, qreal(1.0))) + m_playerControl->setVolume(m_vol * 100); + if (m_muted) + m_playerControl->setMuted(m_muted); + if (!qFuzzyCompare(m_playbackRate, qreal(1.0))) + m_playerControl->setPlaybackRate(m_playbackRate); if (!m_source.isEmpty() && (m_autoLoad || m_playing)) // Override autoLoad if playing set m_playerControl->setMedia(m_source, 0); diff --git a/src/imports/multimedia/qdeclarativemediabase_p.h b/src/imports/multimedia/qdeclarativemediabase_p.h index cfbe0c554..70e349c97 100644 --- a/src/imports/multimedia/qdeclarativemediabase_p.h +++ b/src/imports/multimedia/qdeclarativemediabase_p.h @@ -123,7 +123,7 @@ public: protected: void shutdown(); - void setObject(QObject *object); + void setObject(QObject *object, const QMediaServiceProviderHint& hint = QMediaServiceProviderHint()); virtual void sourceChanged() = 0; virtual void autoLoadChanged() = 0; diff --git a/src/imports/multimedia/qdeclarativeradio.cpp b/src/imports/multimedia/qdeclarativeradio.cpp new file mode 100644 index 000000000..5cac32e6f --- /dev/null +++ b/src/imports/multimedia/qdeclarativeradio.cpp @@ -0,0 +1,212 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qdeclarativeradio_p.h" + +QT_BEGIN_NAMESPACE + +QDeclarativeRadio::QDeclarativeRadio(QObject *parent) : + QObject(parent), + m_radioTuner(0) +{ + m_radioTuner = new QRadioTuner(this); + + connect(m_radioTuner, SIGNAL(stateChanged(QRadioTuner::State)), this, SLOT(_q_stateChanged(QRadioTuner::State))); + connect(m_radioTuner, SIGNAL(bandChanged(QRadioTuner::Band)), this, SLOT(_q_bandChanged(QRadioTuner::Band))); + + connect(m_radioTuner, SIGNAL(frequencyChanged(int)), this, SIGNAL(frequencyChanged(int))); + connect(m_radioTuner, SIGNAL(stereoStatusChanged(bool)), this, SIGNAL(stereoStatusChanged(bool))); + connect(m_radioTuner, SIGNAL(searchingChanged(bool)), this, SIGNAL(searchingChanged(bool))); + connect(m_radioTuner, SIGNAL(signalStrengthChanged(int)), this, SIGNAL(signalStrengthChanged(int))); + connect(m_radioTuner, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int))); + connect(m_radioTuner, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool))); + + connect(m_radioTuner, SIGNAL(error(QRadioTuner::Error)), this, SLOT(_q_error(QRadioTuner::Error))); +} + +QDeclarativeRadio::~QDeclarativeRadio() +{ +} + +QDeclarativeRadio::State QDeclarativeRadio::state() const +{ + return static_cast<QDeclarativeRadio::State>(m_radioTuner->state()); +} + +QDeclarativeRadio::Band QDeclarativeRadio::band() const +{ + return static_cast<QDeclarativeRadio::Band>(m_radioTuner->band()); +} + +int QDeclarativeRadio::frequency() const +{ + return m_radioTuner->frequency(); +} + +QDeclarativeRadio::StereoMode QDeclarativeRadio::stereoMode() const +{ + return static_cast<QDeclarativeRadio::StereoMode>(m_radioTuner->stereoMode()); +} + +int QDeclarativeRadio::volume() const +{ + return m_radioTuner->volume(); +} + +bool QDeclarativeRadio::muted() const +{ + return m_radioTuner->isMuted(); +} + +bool QDeclarativeRadio::stereo() const +{ + return m_radioTuner->isStereo(); +} + +int QDeclarativeRadio::signalStrength() const +{ + return m_radioTuner->signalStrength(); +} + +bool QDeclarativeRadio::searching() const +{ + return m_radioTuner->isSearching(); +} + +int QDeclarativeRadio::frequencyStep() const +{ + return m_radioTuner->frequencyStep(m_radioTuner->band()); +} + +int QDeclarativeRadio::minimumFrequency() const +{ + return m_radioTuner->frequencyRange(m_radioTuner->band()).first; +} + +int QDeclarativeRadio::maximumFrequency() const +{ + return m_radioTuner->frequencyRange(m_radioTuner->band()).second; +} + +bool QDeclarativeRadio::isAvailable() const +{ + return m_radioTuner->isAvailable(); +} + +void QDeclarativeRadio::setBand(QDeclarativeRadio::Band band) +{ + m_radioTuner->setBand(static_cast<QRadioTuner::Band>(band)); +} + +void QDeclarativeRadio::setFrequency(int frequency) +{ + m_radioTuner->setFrequency(frequency); +} + +void QDeclarativeRadio::setStereoMode(QDeclarativeRadio::StereoMode stereoMode) +{ + m_radioTuner->setStereoMode(static_cast<QRadioTuner::StereoMode>(stereoMode)); +} + +void QDeclarativeRadio::setVolume(int volume) +{ + m_radioTuner->setVolume(volume); +} + +void QDeclarativeRadio::setMuted(bool muted) +{ + m_radioTuner->setMuted(muted); +} + +void QDeclarativeRadio::cancelScan() +{ + m_radioTuner->cancelSearch(); +} + +void QDeclarativeRadio::scanDown() +{ + m_radioTuner->searchBackward(); +} + +void QDeclarativeRadio::scanUp() +{ + m_radioTuner->searchForward(); +} + +void QDeclarativeRadio::tuneDown() +{ + int f = frequency(); + f = f - frequencyStep(); + setFrequency(f); +} + +void QDeclarativeRadio::tuneUp() +{ + int f = frequency(); + f = f + frequencyStep(); + setFrequency(f); +} + +void QDeclarativeRadio::start() +{ + m_radioTuner->start(); +} + +void QDeclarativeRadio::stop() +{ + m_radioTuner->stop(); +} + +void QDeclarativeRadio::_q_stateChanged(QRadioTuner::State state) +{ + emit stateChanged(static_cast<QDeclarativeRadio::State>(state)); +} + +void QDeclarativeRadio::_q_bandChanged(QRadioTuner::Band band) +{ + emit bandChanged(static_cast<QDeclarativeRadio::Band>(band)); +} + +void QDeclarativeRadio::_q_error(QRadioTuner::Error errorCode) +{ + emit error(static_cast<QDeclarativeRadio::Error>(errorCode)); + emit errorChanged(); +} diff --git a/src/imports/multimedia/qdeclarativeradio_p.h b/src/imports/multimedia/qdeclarativeradio_p.h new file mode 100644 index 000000000..eddf93bfc --- /dev/null +++ b/src/imports/multimedia/qdeclarativeradio_p.h @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVERADIO_P_H +#define QDECLARATIVERADIO_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 <QtDeclarative/qdeclarative.h> +#include <qradiotuner.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QDeclarativeRadio : public QObject +{ + Q_OBJECT + Q_PROPERTY(State state READ state NOTIFY stateChanged) + Q_PROPERTY(Band band READ band WRITE setBand NOTIFY bandChanged) + Q_PROPERTY(int frequency READ frequency WRITE setFrequency NOTIFY frequencyChanged) + Q_PROPERTY(bool stereo READ stereo NOTIFY stereoStatusChanged) + Q_PROPERTY(StereoMode stereoMode READ stereoMode WRITE setStereoMode) + Q_PROPERTY(int signalStrength READ signalStrength NOTIFY signalStrengthChanged) + Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged) + Q_PROPERTY(bool muted READ muted WRITE setMuted NOTIFY mutedChanged) + Q_PROPERTY(bool searching READ searching NOTIFY searchingChanged) + Q_PROPERTY(int frequencyStep READ frequencyStep NOTIFY bandChanged) + Q_PROPERTY(int minimumFrequency READ minimumFrequency NOTIFY bandChanged) + Q_PROPERTY(int maximumFrequency READ maximumFrequency NOTIFY bandChanged) + Q_ENUMS(State) + Q_ENUMS(Band) + Q_ENUMS(Error) + Q_ENUMS(StereoMode) + +public: + enum State { + ActiveState = QRadioTuner::ActiveState, + StoppedState = QRadioTuner::StoppedState + }; + + enum Band { + AM = QRadioTuner::AM, + FM = QRadioTuner::FM, + SW = QRadioTuner::SW, + LW = QRadioTuner::LW, + FM2 = QRadioTuner::FM2 + }; + + enum Error { + NoError = QRadioTuner::NoError, + ResourceError = QRadioTuner::ResourceError, + OpenError = QRadioTuner::OpenError, + OutOfRangeError = QRadioTuner::OutOfRangeError + }; + + enum StereoMode { + ForceStereo = QRadioTuner::ForceStereo, + ForceMono = QRadioTuner::ForceMono, + Auto = QRadioTuner::Auto + }; + + QDeclarativeRadio(QObject *parent = 0); + ~QDeclarativeRadio(); + + QDeclarativeRadio::State state() const; + QDeclarativeRadio::Band band() const; + int frequency() const; + QDeclarativeRadio::StereoMode stereoMode() const; + int volume() const; + bool muted() const; + + bool stereo() const; + int signalStrength() const; + bool searching() const; + + int frequencyStep() const; + int minimumFrequency() const; + int maximumFrequency() const; + + Q_INVOKABLE bool isAvailable() const; + +public Q_SLOTS: + void setBand(QDeclarativeRadio::Band band); + void setFrequency(int frequency); + void setStereoMode(QDeclarativeRadio::StereoMode stereoMode); + void setVolume(int volume); + void setMuted(bool muted); + + void cancelScan(); + void scanDown(); + void scanUp(); + void tuneUp(); + void tuneDown(); + void start(); + void stop(); + +Q_SIGNALS: + void stateChanged(QDeclarativeRadio::State state); + void bandChanged(QDeclarativeRadio::Band band); + void frequencyChanged(int frequency); + void stereoStatusChanged(bool stereo); + void searchingChanged(bool searching); + void signalStrengthChanged(int signalStrength); + void volumeChanged(int volume); + void mutedChanged(bool muted); + + void errorChanged(); + void error(QDeclarativeRadio::Error errorCode); + +private Q_SLOTS: + void _q_stateChanged(QRadioTuner::State state); + void _q_bandChanged(QRadioTuner::Band band); + void _q_error(QRadioTuner::Error errorCode); + +private: + Q_DISABLE_COPY(QDeclarativeRadio) + + QRadioTuner *m_radioTuner; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeRadio)) + +QT_END_HEADER + +#endif // QDECLARATIVERADIO_P_H diff --git a/src/imports/multimedia/qsgvideonode_i420.cpp b/src/imports/multimedia/qsgvideonode_i420.cpp index 0342de565..11135c14b 100644 --- a/src/imports/multimedia/qsgvideonode_i420.cpp +++ b/src/imports/multimedia/qsgvideonode_i420.cpp @@ -41,7 +41,8 @@ #include "qsgvideonode_i420.h" #include <QtDeclarative/qsgtexturematerial.h> #include <QtDeclarative/qsgmaterial.h> - +#include <QtGui/QOpenGLContext> +#include <QtGui/QOpenGLFunctions> #include <QtOpenGL/qglshaderprogram.h> QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_I420::supportedPixelFormats( @@ -254,7 +255,7 @@ void QSGVideoNode_I420::setCurrentFrame(const QVideoFrame &frame) void QSGVideoNode_I420::bindTexture(int id, int unit, int w, int h, const uchar *bits) { - QGLFunctions *functions = QGLContext::currentContext()->functions(); + QOpenGLFunctions *functions = QOpenGLContext::currentContext()->functions(); functions->glActiveTexture(unit); glBindTexture(GL_TEXTURE_2D, id); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, w, h, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, bits); @@ -271,7 +272,7 @@ void QSGVideoMaterialShader_YUV420::updateState(const RenderState &state, { Q_UNUSED(oldMaterial); - QGLFunctions *functions = state.context()->functions(); + QOpenGLFunctions *functions = state.context()->functions(); QSGVideoMaterial_YUV420 *mat = static_cast<QSGVideoMaterial_YUV420 *>(newMaterial); program()->setUniformValue(m_id_yTexture, 0); program()->setUniformValue(m_id_uTexture, 1); diff --git a/src/imports/multimedia/qsgvideonode_rgb32.cpp b/src/imports/multimedia/qsgvideonode_rgb32.cpp index 1c6738d28..dbb2e8b50 100644 --- a/src/imports/multimedia/qsgvideonode_rgb32.cpp +++ b/src/imports/multimedia/qsgvideonode_rgb32.cpp @@ -42,6 +42,9 @@ #include <QtDeclarative/qsgtexture.h> +#include <QtGui/QOpenGLContext> +#include <QtGui/QOpenGLFunctions> + QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_RGB32::supportedPixelFormats( QAbstractVideoBuffer::HandleType handleType) const { @@ -101,7 +104,7 @@ void QSGVideoTexture_RGB32::bind() } if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { - QGLFunctions *functions = QGLContext::currentContext()->functions(); + QOpenGLFunctions *functions = QOpenGLContext::currentContext()->functions(); const uchar *bits = m_frame.bits(); functions->glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_textureId); |