Added RDS functionality to the QRadioTuner/QDeclarativeRadio
Change-Id: I865e3caba82977002cf1f01f1d64ee0a42de77c6 Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com> Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
cbb21e30d5
commit
6aea1a22ee
@@ -49,6 +49,7 @@
|
|||||||
#include "qdeclarativeaudio_p.h"
|
#include "qdeclarativeaudio_p.h"
|
||||||
#include "qdeclarativevideooutput_p.h"
|
#include "qdeclarativevideooutput_p.h"
|
||||||
#include "qdeclarativeradio_p.h"
|
#include "qdeclarativeradio_p.h"
|
||||||
|
#include "qdeclarativeradiodata_p.h"
|
||||||
#include "qdeclarativebackgroundaudio_p.h"
|
#include "qdeclarativebackgroundaudio_p.h"
|
||||||
#include "qdeclarativecamera_p.h"
|
#include "qdeclarativecamera_p.h"
|
||||||
#include "qdeclarativecamerapreviewprovider_p.h"
|
#include "qdeclarativecamerapreviewprovider_p.h"
|
||||||
@@ -76,6 +77,7 @@ public:
|
|||||||
qmlRegisterType<QDeclarativeAudio>(uri, 4, 0, "MediaPlayer");
|
qmlRegisterType<QDeclarativeAudio>(uri, 4, 0, "MediaPlayer");
|
||||||
qmlRegisterType<QDeclarativeVideoOutput>(uri, 4, 0, "VideoOutput");
|
qmlRegisterType<QDeclarativeVideoOutput>(uri, 4, 0, "VideoOutput");
|
||||||
qmlRegisterType<QDeclarativeRadio>(uri, 4, 0, "Radio");
|
qmlRegisterType<QDeclarativeRadio>(uri, 4, 0, "Radio");
|
||||||
|
qmlRegisterType<QDeclarativeRadioData>(uri, 4, 0, "RadioData");
|
||||||
qmlRegisterType<QDeclarativeBackgroundAudio>(uri, 4, 0, "BackgroundAudio");
|
qmlRegisterType<QDeclarativeBackgroundAudio>(uri, 4, 0, "BackgroundAudio");
|
||||||
qmlRegisterType<QDeclarativeCamera>(uri, 4, 0, "Camera");
|
qmlRegisterType<QDeclarativeCamera>(uri, 4, 0, "Camera");
|
||||||
qmlRegisterUncreatableType<QDeclarativeCameraCapture>(uri, 4, 0, "CameraCapture",
|
qmlRegisterUncreatableType<QDeclarativeCameraCapture>(uri, 4, 0, "CameraCapture",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ HEADERS += \
|
|||||||
qsgvideonode_i420.h \
|
qsgvideonode_i420.h \
|
||||||
qsgvideonode_rgb.h \
|
qsgvideonode_rgb.h \
|
||||||
qdeclarativeradio_p.h \
|
qdeclarativeradio_p.h \
|
||||||
|
qdeclarativeradiodata_p.h \
|
||||||
qdeclarativebackgroundaudio_p.h \
|
qdeclarativebackgroundaudio_p.h \
|
||||||
qdeclarativecamera_p.h \
|
qdeclarativecamera_p.h \
|
||||||
qdeclarativecameracapture_p.h \
|
qdeclarativecameracapture_p.h \
|
||||||
@@ -36,6 +37,7 @@ SOURCES += \
|
|||||||
qsgvideonode_i420.cpp \
|
qsgvideonode_i420.cpp \
|
||||||
qsgvideonode_rgb.cpp \
|
qsgvideonode_rgb.cpp \
|
||||||
qdeclarativeradio.cpp \
|
qdeclarativeradio.cpp \
|
||||||
|
qdeclarativeradiodata.cpp \
|
||||||
qdeclarativebackgroundaudio.cpp \
|
qdeclarativebackgroundaudio.cpp \
|
||||||
qdeclarativecamera.cpp \
|
qdeclarativecamera.cpp \
|
||||||
qdeclarativecameracapture.cpp \
|
qdeclarativecameracapture.cpp \
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ QDeclarativeRadio::QDeclarativeRadio(QObject *parent) :
|
|||||||
connect(m_radioTuner, SIGNAL(signalStrengthChanged(int)), this, SIGNAL(signalStrengthChanged(int)));
|
connect(m_radioTuner, SIGNAL(signalStrengthChanged(int)), this, SIGNAL(signalStrengthChanged(int)));
|
||||||
connect(m_radioTuner, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(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(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool)));
|
||||||
|
connect(m_radioTuner, SIGNAL(stationFound(int, QString)), this, SIGNAL(stationFound(int, QString)));
|
||||||
|
|
||||||
connect(m_radioTuner, SIGNAL(error(QRadioTuner::Error)), this, SLOT(_q_error(QRadioTuner::Error)));
|
connect(m_radioTuner, SIGNAL(error(QRadioTuner::Error)), this, SLOT(_q_error(QRadioTuner::Error)));
|
||||||
}
|
}
|
||||||
@@ -171,6 +172,11 @@ void QDeclarativeRadio::scanUp()
|
|||||||
m_radioTuner->searchForward();
|
m_radioTuner->searchForward();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QDeclarativeRadio::searchAllStations(QDeclarativeRadio::SearchMode searchMode)
|
||||||
|
{
|
||||||
|
m_radioTuner->searchAllStations(static_cast<QRadioTuner::SearchMode>(searchMode));
|
||||||
|
}
|
||||||
|
|
||||||
void QDeclarativeRadio::tuneDown()
|
void QDeclarativeRadio::tuneDown()
|
||||||
{
|
{
|
||||||
int f = frequency();
|
int f = frequency();
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ class QDeclarativeRadio : public QObject
|
|||||||
Q_ENUMS(Band)
|
Q_ENUMS(Band)
|
||||||
Q_ENUMS(Error)
|
Q_ENUMS(Error)
|
||||||
Q_ENUMS(StereoMode)
|
Q_ENUMS(StereoMode)
|
||||||
|
Q_ENUMS(SearchMode)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum State {
|
enum State {
|
||||||
@@ -107,6 +108,11 @@ public:
|
|||||||
Auto = QRadioTuner::Auto
|
Auto = QRadioTuner::Auto
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum SearchMode {
|
||||||
|
SearchFast = QRadioTuner::SearchFast,
|
||||||
|
SearchGetStationId = QRadioTuner::SearchGetStationId
|
||||||
|
};
|
||||||
|
|
||||||
QDeclarativeRadio(QObject *parent = 0);
|
QDeclarativeRadio(QObject *parent = 0);
|
||||||
~QDeclarativeRadio();
|
~QDeclarativeRadio();
|
||||||
|
|
||||||
@@ -139,6 +145,8 @@ public Q_SLOTS:
|
|||||||
void scanUp();
|
void scanUp();
|
||||||
void tuneUp();
|
void tuneUp();
|
||||||
void tuneDown();
|
void tuneDown();
|
||||||
|
void searchAllStations(QDeclarativeRadio::SearchMode searchMode = QDeclarativeRadio::SearchFast );
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
@@ -151,6 +159,7 @@ Q_SIGNALS:
|
|||||||
void signalStrengthChanged(int signalStrength);
|
void signalStrengthChanged(int signalStrength);
|
||||||
void volumeChanged(int volume);
|
void volumeChanged(int volume);
|
||||||
void mutedChanged(bool muted);
|
void mutedChanged(bool muted);
|
||||||
|
void stationFound(int frequency, QString stationId);
|
||||||
|
|
||||||
void errorChanged();
|
void errorChanged();
|
||||||
void error(QDeclarativeRadio::Error errorCode);
|
void error(QDeclarativeRadio::Error errorCode);
|
||||||
|
|||||||
118
src/imports/multimedia/qdeclarativeradiodata.cpp
Normal file
118
src/imports/multimedia/qdeclarativeradiodata.cpp
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 "qdeclarativeradiodata_p.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
QDeclarativeRadioData::QDeclarativeRadioData(QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
|
m_radioData(0)
|
||||||
|
{
|
||||||
|
m_radioData = new QRadioData(this);
|
||||||
|
|
||||||
|
connect(m_radioData, SIGNAL(programTypeChanged(QRadioData::ProgramType)), this,
|
||||||
|
SLOT(_q_programTypeChanged(QRadioData::ProgramType)));
|
||||||
|
|
||||||
|
connect(m_radioData, SIGNAL(stationIdChanged(QString)), this, SIGNAL(stationIdChanged(QString)));
|
||||||
|
connect(m_radioData, SIGNAL(programTypeNameChanged(QString)), this, SIGNAL(programTypeNameChanged(QString)));
|
||||||
|
connect(m_radioData, SIGNAL(stationNameChanged(QString)), this, SIGNAL(stationNameChanged(QString)));
|
||||||
|
connect(m_radioData, SIGNAL(radioTextChanged(QString)), this, SIGNAL(radioTextChanged(QString)));
|
||||||
|
connect(m_radioData, SIGNAL(alternativeFrequenciesEnabledChanged(bool)), this,
|
||||||
|
SIGNAL(alternativeFrequenciesEnabledChanged(bool)));
|
||||||
|
|
||||||
|
connect(m_radioData, SIGNAL(error(QRadioData::Error)), this, SLOT(_q_error(QRadioData::Error)));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDeclarativeRadioData::~QDeclarativeRadioData()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QDeclarativeRadioData::isAvailable() const
|
||||||
|
{
|
||||||
|
return m_radioData->isAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QDeclarativeRadioData::stationId() const
|
||||||
|
{
|
||||||
|
return m_radioData->stationId();
|
||||||
|
}
|
||||||
|
|
||||||
|
QDeclarativeRadioData::ProgramType QDeclarativeRadioData::programType() const
|
||||||
|
{
|
||||||
|
return static_cast<QDeclarativeRadioData::ProgramType>(m_radioData->programType());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QDeclarativeRadioData::programTypeName() const
|
||||||
|
{
|
||||||
|
return m_radioData->programTypeName();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QDeclarativeRadioData::stationName() const
|
||||||
|
{
|
||||||
|
return m_radioData->stationName();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QDeclarativeRadioData::radioText() const
|
||||||
|
{
|
||||||
|
return m_radioData->radioText();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QDeclarativeRadioData::alternativeFrequenciesEnabled() const
|
||||||
|
{
|
||||||
|
return m_radioData->isAlternativeFrequenciesEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QDeclarativeRadioData::setAlternativeFrequenciesEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
m_radioData->setAlternativeFrequenciesEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QDeclarativeRadioData::_q_programTypeChanged(QRadioData::ProgramType programType)
|
||||||
|
{
|
||||||
|
emit programTypeChanged(static_cast<QDeclarativeRadioData::ProgramType>(programType));
|
||||||
|
}
|
||||||
|
|
||||||
|
void QDeclarativeRadioData::_q_error(QRadioData::Error errorCode)
|
||||||
|
{
|
||||||
|
emit error(static_cast<QDeclarativeRadioData::Error>(errorCode));
|
||||||
|
emit errorChanged();
|
||||||
|
}
|
||||||
178
src/imports/multimedia/qdeclarativeradiodata_p.h
Normal file
178
src/imports/multimedia/qdeclarativeradiodata_p.h
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 QDECLARATIVERADIODATA_P_H
|
||||||
|
#define QDECLARATIVERADIODATA_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 <qradiodata.h>
|
||||||
|
|
||||||
|
QT_BEGIN_HEADER
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QDeclarativeRadioData : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString stationId READ stationId NOTIFY stationIdChanged)
|
||||||
|
Q_PROPERTY(QDeclarativeRadioData::ProgramType programType READ programType NOTIFY programTypeChanged)
|
||||||
|
Q_PROPERTY(QString programTypeName READ programTypeName NOTIFY programTypeNameChanged)
|
||||||
|
Q_PROPERTY(QString stationName READ stationName NOTIFY stationNameChanged)
|
||||||
|
Q_PROPERTY(QString radioText READ radioText NOTIFY radioTextChanged)
|
||||||
|
Q_PROPERTY(bool alternativeFrequenciesEnabled READ alternativeFrequenciesEnabled
|
||||||
|
WRITE setAlternativeFrequenciesEnabled NOTIFY alternativeFrequenciesEnabledChanged)
|
||||||
|
Q_ENUMS(Error)
|
||||||
|
Q_ENUMS(ProgramType)
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum Error {
|
||||||
|
NoError = QRadioData::NoError,
|
||||||
|
ResourceError = QRadioData::ResourceError,
|
||||||
|
OpenError = QRadioData::OpenError,
|
||||||
|
OutOfRangeError = QRadioData::OutOfRangeError
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ProgramType {
|
||||||
|
Undefined = QRadioData::Undefined,
|
||||||
|
News = QRadioData::News,
|
||||||
|
CurrentAffairs = QRadioData::CurrentAffairs,
|
||||||
|
Information = QRadioData::Information,
|
||||||
|
Sport = QRadioData::Sport,
|
||||||
|
Education = QRadioData::Education,
|
||||||
|
Drama = QRadioData::Drama,
|
||||||
|
Culture = QRadioData::Culture,
|
||||||
|
Science = QRadioData::Science,
|
||||||
|
Varied = QRadioData::Varied,
|
||||||
|
PopMusic = QRadioData::PopMusic,
|
||||||
|
RockMusic = QRadioData::RockMusic,
|
||||||
|
EasyListening = QRadioData::EasyListening,
|
||||||
|
LightClassical = QRadioData::LightClassical,
|
||||||
|
SeriousClassical = QRadioData::SeriousClassical,
|
||||||
|
OtherMusic = QRadioData::OtherMusic,
|
||||||
|
Weather = QRadioData::Weather,
|
||||||
|
Finance = QRadioData::Finance,
|
||||||
|
ChildrensProgrammes = QRadioData::ChildrensProgrammes,
|
||||||
|
SocialAffairs = QRadioData::SocialAffairs,
|
||||||
|
Religion = QRadioData::Religion,
|
||||||
|
PhoneIn = QRadioData::PhoneIn,
|
||||||
|
Travel = QRadioData::Travel,
|
||||||
|
Leisure = QRadioData::Leisure,
|
||||||
|
JazzMusic = QRadioData::JazzMusic,
|
||||||
|
CountryMusic = QRadioData::CountryMusic,
|
||||||
|
NationalMusic = QRadioData::NationalMusic,
|
||||||
|
OldiesMusic = QRadioData::OldiesMusic,
|
||||||
|
FolkMusic = QRadioData::FolkMusic,
|
||||||
|
Documentary = QRadioData::Documentary,
|
||||||
|
AlarmTest = QRadioData::AlarmTest,
|
||||||
|
Alarm = QRadioData::Alarm,
|
||||||
|
Talk = QRadioData::Talk,
|
||||||
|
ClassicRock = QRadioData::ClassicRock,
|
||||||
|
AdultHits = QRadioData::AdultHits,
|
||||||
|
SoftRock = QRadioData::SoftRock,
|
||||||
|
Top40 = QRadioData::Top40,
|
||||||
|
Soft = QRadioData::Soft,
|
||||||
|
Nostalgia = QRadioData::Nostalgia,
|
||||||
|
Classical = QRadioData::Classical,
|
||||||
|
RhythmAndBlues = QRadioData::RhythmAndBlues,
|
||||||
|
SoftRhythmAndBlues = QRadioData::SoftRhythmAndBlues,
|
||||||
|
Language = QRadioData::Language,
|
||||||
|
ReligiousMusic = QRadioData::ReligiousMusic,
|
||||||
|
ReligiousTalk = QRadioData::ReligiousTalk,
|
||||||
|
Personality = QRadioData::Personality,
|
||||||
|
Public = QRadioData::Public,
|
||||||
|
College = QRadioData::College,
|
||||||
|
};
|
||||||
|
|
||||||
|
QDeclarativeRadioData(QObject *parent = 0);
|
||||||
|
~QDeclarativeRadioData();
|
||||||
|
|
||||||
|
Q_INVOKABLE bool isAvailable() const;
|
||||||
|
|
||||||
|
QString stationId() const;
|
||||||
|
QDeclarativeRadioData::ProgramType programType() const;
|
||||||
|
QString programTypeName() const;
|
||||||
|
QString stationName() const;
|
||||||
|
QString radioText() const;
|
||||||
|
bool alternativeFrequenciesEnabled() const;
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void setAlternativeFrequenciesEnabled(bool enabled);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void stationIdChanged(QString stationId);
|
||||||
|
void programTypeChanged(QDeclarativeRadioData::ProgramType programType);
|
||||||
|
void programTypeNameChanged(QString programTypeName);
|
||||||
|
void stationNameChanged(QString stationName);
|
||||||
|
void radioTextChanged(QString radioText);
|
||||||
|
void alternativeFrequenciesEnabledChanged(bool enabled);
|
||||||
|
|
||||||
|
void errorChanged();
|
||||||
|
void error(QDeclarativeRadioData::Error errorCode);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void _q_programTypeChanged(QRadioData::ProgramType programType);
|
||||||
|
void _q_error(QRadioData::Error errorCode);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(QDeclarativeRadioData)
|
||||||
|
|
||||||
|
QRadioData *m_radioData;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeRadioData))
|
||||||
|
|
||||||
|
QT_END_HEADER
|
||||||
|
|
||||||
|
#endif // QDECLARATIVERADIODATA_P_H
|
||||||
@@ -55,7 +55,9 @@ PUBLIC_HEADERS += \
|
|||||||
qmetadatawritercontrol.h \
|
qmetadatawritercontrol.h \
|
||||||
qmediastreamscontrol.h \
|
qmediastreamscontrol.h \
|
||||||
qradiotuner.h \
|
qradiotuner.h \
|
||||||
|
qradiodata.h \
|
||||||
qradiotunercontrol.h \
|
qradiotunercontrol.h \
|
||||||
|
qradiodatacontrol.h \
|
||||||
qtmedianamespace.h \
|
qtmedianamespace.h \
|
||||||
qaudioencodercontrol.h \
|
qaudioencodercontrol.h \
|
||||||
qvideoencodercontrol.h \
|
qvideoencodercontrol.h \
|
||||||
@@ -95,7 +97,9 @@ SOURCES += qmediacontrol.cpp \
|
|||||||
qmetadatawritercontrol.cpp \
|
qmetadatawritercontrol.cpp \
|
||||||
qmediastreamscontrol.cpp \
|
qmediastreamscontrol.cpp \
|
||||||
qradiotuner.cpp \
|
qradiotuner.cpp \
|
||||||
|
qradiodata.cpp \
|
||||||
qradiotunercontrol.cpp \
|
qradiotunercontrol.cpp \
|
||||||
|
qradiodatacontrol.cpp \
|
||||||
qaudioencodercontrol.cpp \
|
qaudioencodercontrol.cpp \
|
||||||
qvideoencodercontrol.cpp \
|
qvideoencodercontrol.cpp \
|
||||||
qimageencodercontrol.cpp \
|
qimageencodercontrol.cpp \
|
||||||
|
|||||||
341
src/multimedia/qradiodata.cpp
Normal file
341
src/multimedia/qradiodata.cpp
Normal file
@@ -0,0 +1,341 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 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 "qradiodata.h"
|
||||||
|
#include "qmediaservice.h"
|
||||||
|
#include "qmediaobject_p.h"
|
||||||
|
#include "qradiodatacontrol.h"
|
||||||
|
|
||||||
|
#include <QPair>
|
||||||
|
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class QRadioData
|
||||||
|
\brief The QRadioData class provides interfaces to the RDS functionality of the system radio.
|
||||||
|
|
||||||
|
\inmodule QtMultimedia
|
||||||
|
\ingroup multimedia
|
||||||
|
\since 5.0
|
||||||
|
|
||||||
|
The radio data object will emit signals for any changes in radio data. You can enable or disable
|
||||||
|
alternative frequency with setAlternativeFrequenciesEnabled().
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class QRadioDataPrivate : public QMediaObjectPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QRadioDataPrivate():provider(0), control(0) {}
|
||||||
|
QMediaServiceProvider *provider;
|
||||||
|
QRadioDataControl* control;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructs a radio data based on a media service allocated by a media service \a provider.
|
||||||
|
|
||||||
|
The \a parent is passed to QMediaObject.
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
QRadioData::QRadioData(QObject *parent, QMediaServiceProvider* provider):
|
||||||
|
QMediaObject(*new QRadioDataPrivate, parent, provider->requestService(Q_MEDIASERVICE_RADIO))
|
||||||
|
{
|
||||||
|
Q_D(QRadioData);
|
||||||
|
|
||||||
|
d->provider = provider;
|
||||||
|
|
||||||
|
if (d->service != 0) {
|
||||||
|
d->control = qobject_cast<QRadioDataControl*>(d->service->requestControl(QRadioDataControl_iid));
|
||||||
|
if (d->control != 0) {
|
||||||
|
connect(d->control, SIGNAL(stationIdChanged(QString)), SIGNAL(stationIdChanged(QString)));
|
||||||
|
connect(d->control, SIGNAL(programTypeChanged(QRadioData::ProgramType)),
|
||||||
|
SIGNAL(programTypeChanged(QRadioData::ProgramType)));
|
||||||
|
connect(d->control, SIGNAL(programTypeNameChanged(QString)), SIGNAL(programTypeNameChanged(QString)));
|
||||||
|
connect(d->control, SIGNAL(stationNameChanged(QString)), SIGNAL(stationNameChanged(QString)));
|
||||||
|
connect(d->control, SIGNAL(radioTextChanged(QString)), SIGNAL(radioTextChanged(QString)));
|
||||||
|
connect(d->control, SIGNAL(alternativeFrequenciesEnabledChanged(bool)), SIGNAL(alternativeFrequenciesEnabledChanged(bool)));
|
||||||
|
connect(d->control, SIGNAL(error(QRadioData::Error)), SIGNAL(error(QRadioData::Error)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Destroys a radio data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
QRadioData::~QRadioData()
|
||||||
|
{
|
||||||
|
Q_D(QRadioData);
|
||||||
|
|
||||||
|
if (d->service && d->control)
|
||||||
|
d->service->releaseControl(d->control);
|
||||||
|
|
||||||
|
d->provider->releaseService(d->service);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns true if the radio data service is ready to use.
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
bool QRadioData::isAvailable() const
|
||||||
|
{
|
||||||
|
Q_D(const QRadioData);
|
||||||
|
|
||||||
|
if (d->control != 0)
|
||||||
|
return d_func()->control->isAvailable();
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the availability error state.
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
QtMultimedia::AvailabilityError QRadioData::availabilityError() const
|
||||||
|
{
|
||||||
|
Q_D(const QRadioData);
|
||||||
|
|
||||||
|
if (d->control != 0)
|
||||||
|
return d_func()->control->availabilityError();
|
||||||
|
else
|
||||||
|
return QtMultimedia::ServiceMissingError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\property QRadioData::stationId
|
||||||
|
\brief Current Program Identification
|
||||||
|
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
QString QRadioData::stationId() const
|
||||||
|
{
|
||||||
|
Q_D(const QRadioData);
|
||||||
|
|
||||||
|
if (d->control != 0)
|
||||||
|
return d->control->stationId();
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\property QRadioData::programType
|
||||||
|
\brief Current Program Type
|
||||||
|
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
QRadioData::ProgramType QRadioData::programType() const
|
||||||
|
{
|
||||||
|
Q_D(const QRadioData);
|
||||||
|
|
||||||
|
if (d->control != 0)
|
||||||
|
return d->control->programType();
|
||||||
|
|
||||||
|
return QRadioData::Undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\property QRadioData::programTypeName
|
||||||
|
\brief Current Program Type Name
|
||||||
|
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
QString QRadioData::programTypeName() const
|
||||||
|
{
|
||||||
|
Q_D(const QRadioData);
|
||||||
|
|
||||||
|
if (d->control != 0)
|
||||||
|
return d->control->programTypeName();
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\property QRadioData::stationName
|
||||||
|
\brief Current Program Service
|
||||||
|
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
QString QRadioData::stationName() const
|
||||||
|
{
|
||||||
|
Q_D(const QRadioData);
|
||||||
|
|
||||||
|
if (d->control != 0)
|
||||||
|
return d->control->stationName();
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\property QRadioData::radioText
|
||||||
|
\brief Current Radio Text
|
||||||
|
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
QString QRadioData::radioText() const
|
||||||
|
{
|
||||||
|
Q_D(const QRadioData);
|
||||||
|
|
||||||
|
if (d->control != 0)
|
||||||
|
return d->control->radioText();
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\property QRadioData::alternativeFrequenciesEnabled
|
||||||
|
\brief Is Alternative Frequency currently enabled
|
||||||
|
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool QRadioData::isAlternativeFrequenciesEnabled() const
|
||||||
|
{
|
||||||
|
Q_D(const QRadioData);
|
||||||
|
|
||||||
|
if (d->control != 0)
|
||||||
|
return d->control->isAlternativeFrequenciesEnabled();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QRadioData::setAlternativeFrequenciesEnabled( bool enabled )
|
||||||
|
{
|
||||||
|
Q_D(const QRadioData);
|
||||||
|
|
||||||
|
if (d->control != 0)
|
||||||
|
return d->control->setAlternativeFrequenciesEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the error state of a radio data.
|
||||||
|
|
||||||
|
\since 5.0
|
||||||
|
\sa errorString()
|
||||||
|
*/
|
||||||
|
|
||||||
|
QRadioData::Error QRadioData::error() const
|
||||||
|
{
|
||||||
|
Q_D(const QRadioData);
|
||||||
|
|
||||||
|
if (d->control != 0)
|
||||||
|
return d->control->error();
|
||||||
|
return QRadioData::ResourceError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns a description of a radio data's error state.
|
||||||
|
|
||||||
|
\since 5.0
|
||||||
|
\sa error()
|
||||||
|
*/
|
||||||
|
QString QRadioData::errorString() const
|
||||||
|
{
|
||||||
|
Q_D(const QRadioData);
|
||||||
|
|
||||||
|
if (d->control != 0)
|
||||||
|
return d->control->errorString();
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioData::stationIdChanged(QString stationId)
|
||||||
|
|
||||||
|
Signals that the Program Identification code has changed to \a stationId
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioData::programTypeChanged(QRadioData::ProgramType programType)
|
||||||
|
|
||||||
|
Signals that the Program Type code has changed to \a programType
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioData::programTypeNameChanged(QString programTypeName)
|
||||||
|
|
||||||
|
Signals that the Program Type Name has changed to \a programTypeName
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioData::stationNameChanged(int stationName)
|
||||||
|
|
||||||
|
Signals that the Program Service has changed to \a stationName
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioData::alternativeFrequenciesEnabledChanged(bool enabled)
|
||||||
|
|
||||||
|
Signals that the AF has been enabled or disabled
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioData::error(QRadioData::Error error)
|
||||||
|
|
||||||
|
Signals that an \a error occurred.
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\enum QRadioData::Error
|
||||||
|
|
||||||
|
Enumerates radio data error conditions.
|
||||||
|
|
||||||
|
\value NoError No errors have occurred.
|
||||||
|
\value ResourceError There is no radio service available.
|
||||||
|
\value OpenError Unable to open radio device.
|
||||||
|
\value OutOfRangeError An attempt to set a frequency or band that is not supported by radio device.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \fn void QRadioData::stateChanged(QRadioData::State state)
|
||||||
|
This signal is emitted when the state changes to \a state.
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "moc_qradiodata.cpp"
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
136
src/multimedia/qradiodata.h
Normal file
136
src/multimedia/qradiodata.h
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 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 QRADIODATA_H
|
||||||
|
#define QRADIODATA_H
|
||||||
|
|
||||||
|
#include <QtCore/qobject.h>
|
||||||
|
|
||||||
|
#include "qmediaobject.h"
|
||||||
|
#include "qmediaserviceprovider.h"
|
||||||
|
#include <qmediaenumdebug.h>
|
||||||
|
|
||||||
|
#include <QPair>
|
||||||
|
|
||||||
|
QT_BEGIN_HEADER
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
QT_MODULE(Multimedia)
|
||||||
|
|
||||||
|
|
||||||
|
class QRadioDataPrivate;
|
||||||
|
class Q_MULTIMEDIA_EXPORT QRadioData : public QMediaObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString stationId READ stationId NOTIFY stationIdChanged)
|
||||||
|
Q_PROPERTY(ProgramType programType READ programType NOTIFY programTypeChanged)
|
||||||
|
Q_PROPERTY(QString programTypeName READ programTypeName NOTIFY programTypeNameChanged)
|
||||||
|
Q_PROPERTY(QString stationName READ stationName NOTIFY stationNameChanged)
|
||||||
|
Q_PROPERTY(QString radioText READ radioText NOTIFY radioTextChanged)
|
||||||
|
Q_PROPERTY(bool alternativeFrequenciesEnabled READ isAlternativeFrequenciesEnabled
|
||||||
|
WRITE setAlternativeFrequenciesEnabled NOTIFY alternativeFrequenciesEnabledChanged)
|
||||||
|
Q_ENUMS(Error)
|
||||||
|
Q_ENUMS(ProgramType)
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum Error { NoError, ResourceError, OpenError, OutOfRangeError };
|
||||||
|
|
||||||
|
enum ProgramType { Undefined = 0, News, CurrentAffairs, Information,
|
||||||
|
Sport, Education, Drama, Culture, Science, Varied,
|
||||||
|
PopMusic, RockMusic, EasyListening, LightClassical,
|
||||||
|
SeriousClassical, OtherMusic, Weather, Finance,
|
||||||
|
ChildrensProgrammes, SocialAffairs, Religion,
|
||||||
|
PhoneIn, Travel, Leisure, JazzMusic, CountryMusic,
|
||||||
|
NationalMusic, OldiesMusic, FolkMusic, Documentary,
|
||||||
|
AlarmTest, Alarm, Talk, ClassicRock, AdultHits,
|
||||||
|
SoftRock, Top40, Soft, Nostalgia, Classical,
|
||||||
|
RhythmAndBlues, SoftRhythmAndBlues, Language,
|
||||||
|
ReligiousMusic, ReligiousTalk, Personality, Public,
|
||||||
|
College
|
||||||
|
};
|
||||||
|
|
||||||
|
QRadioData(QObject *parent = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider());
|
||||||
|
~QRadioData();
|
||||||
|
|
||||||
|
bool isAvailable() const;
|
||||||
|
QtMultimedia::AvailabilityError availabilityError() const;
|
||||||
|
|
||||||
|
QString stationId() const;
|
||||||
|
ProgramType programType() const;
|
||||||
|
QString programTypeName() const;
|
||||||
|
QString stationName() const;
|
||||||
|
QString radioText() const;
|
||||||
|
bool isAlternativeFrequenciesEnabled() const;
|
||||||
|
|
||||||
|
Error error() const;
|
||||||
|
QString errorString() const;
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void setAlternativeFrequenciesEnabled(bool enabled);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void stationIdChanged(QString stationId);
|
||||||
|
void programTypeChanged(QRadioData::ProgramType programType);
|
||||||
|
void programTypeNameChanged(QString programTypeName);
|
||||||
|
void stationNameChanged(QString stationName);
|
||||||
|
void radioTextChanged(QString radioText);
|
||||||
|
void alternativeFrequenciesEnabledChanged(bool enabled);
|
||||||
|
|
||||||
|
void error(QRadioData::Error error);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
Q_DISABLE_COPY(QRadioData)
|
||||||
|
Q_DECLARE_PRIVATE(QRadioData)
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(QRadioData::Error)
|
||||||
|
Q_DECLARE_METATYPE(QRadioData::ProgramType)
|
||||||
|
|
||||||
|
Q_MEDIA_ENUM_DEBUG(QRadioData, Error)
|
||||||
|
Q_MEDIA_ENUM_DEBUG(QRadioData, ProgramType)
|
||||||
|
|
||||||
|
QT_END_HEADER
|
||||||
|
|
||||||
|
#endif // QRADIOPLAYER_H
|
||||||
216
src/multimedia/qradiodatacontrol.cpp
Normal file
216
src/multimedia/qradiodatacontrol.cpp
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 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 <qtmultimediadefs.h>
|
||||||
|
#include "qradiodatacontrol.h"
|
||||||
|
#include "qmediacontrol_p.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class QRadioDataControl
|
||||||
|
\inmodule QtMultimedia
|
||||||
|
\ingroup multimedia-serv
|
||||||
|
\since 5.0
|
||||||
|
|
||||||
|
|
||||||
|
\brief The QRadioDataControl class provides access to the RDS functionality of the
|
||||||
|
radio in the QMediaService.
|
||||||
|
|
||||||
|
The functionality provided by this control is exposed to application code
|
||||||
|
through the QRadioData class.
|
||||||
|
|
||||||
|
The interface name of QRadioDataControl is \c com.nokia.Qt.QRadioDataControl/5.0 as
|
||||||
|
defined in QRadioDataControl_iid.
|
||||||
|
|
||||||
|
\sa QMediaService::requestControl(), QRadioData
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\macro QRadioDataControl_iid
|
||||||
|
|
||||||
|
\c com.nokia.Qt.QRadioDataControl/5.0
|
||||||
|
|
||||||
|
Defines the interface name of the QRadioDataControl class.
|
||||||
|
|
||||||
|
\relates QRadioDataControl
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructs a radio data control with the given \a parent.
|
||||||
|
*/
|
||||||
|
|
||||||
|
QRadioDataControl::QRadioDataControl(QObject *parent):
|
||||||
|
QMediaControl(*new QMediaControlPrivate, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Destroys a radio data control.
|
||||||
|
*/
|
||||||
|
|
||||||
|
QRadioDataControl::~QRadioDataControl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn bool QRadioDataControl::isAvailable() const
|
||||||
|
|
||||||
|
Returns true if the radio service is ready to use.
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QtMultimedia::AvailabilityError QRadioDataControl::availabilityError() const
|
||||||
|
|
||||||
|
Returns the error state of the radio service.
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QRadioData::Error QRadioDataControl::error() const
|
||||||
|
|
||||||
|
Returns the error state of a radio data.
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QString QRadioDataControl::errorString() const
|
||||||
|
|
||||||
|
Returns a string describing a radio data's error state.
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioDataControl::error(QRadioData::Error error)
|
||||||
|
|
||||||
|
Signals that an \a error has occurred.
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn int QRadioDataControl::stationId()
|
||||||
|
|
||||||
|
Returns the current Program Identification
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QRadioData::ProgramType QRadioDataControl::programType()
|
||||||
|
|
||||||
|
Returns the current Program Type
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QString QRadioDataControl::programTypeName()
|
||||||
|
|
||||||
|
Returns the current Program Type Name
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QString QRadioDataControl::stationName()
|
||||||
|
|
||||||
|
Returns the current Program Service
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QString QRadioDataControl::radioText()
|
||||||
|
|
||||||
|
Returns the current Radio Text
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioDataControl::setAlternativeFrequenciesEnabled(bool enabled)
|
||||||
|
|
||||||
|
Sets the Alternative Frequency to \a enabled
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn bool QRadioDataControl::isAlternativeFrequenciesEnabled()
|
||||||
|
|
||||||
|
Returns true if Alternative Frequency is currently enabled
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioDataControl::stationIdChanged(QString stationId)
|
||||||
|
|
||||||
|
Signals that the Program Identification \a stationId has changed
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioDataControl::programTypeChanged(QRadioData::ProgramType programType)
|
||||||
|
|
||||||
|
Signals that the Program Type \a programType has changed
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioDataControl::programTypeNameChanged(QString programTypeName)
|
||||||
|
|
||||||
|
Signals that the Program Type Name \a programTypeName has changed
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioDataControl::stationNameChanged(QString stationName)
|
||||||
|
|
||||||
|
Signals that the Program Service \a stationName has changed
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioDataControl::radioTextChanged(QString radioText)
|
||||||
|
|
||||||
|
Signals that the Radio Text \a radioText has changed
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "moc_qradiodatacontrol.cpp"
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
97
src/multimedia/qradiodatacontrol.h
Normal file
97
src/multimedia/qradiodatacontrol.h
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 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 QRADIODATACONTROL_H
|
||||||
|
#define QRADIODATACONTROL_H
|
||||||
|
|
||||||
|
#include "qmediacontrol.h"
|
||||||
|
#include "qradiodata.h"
|
||||||
|
|
||||||
|
QT_BEGIN_HEADER
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
QT_MODULE(Multimedia)
|
||||||
|
|
||||||
|
|
||||||
|
class Q_MULTIMEDIA_EXPORT QRadioDataControl : public QMediaControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
~QRadioDataControl();
|
||||||
|
|
||||||
|
virtual bool isAvailable() const = 0;
|
||||||
|
virtual QtMultimedia::AvailabilityError availabilityError() const = 0;
|
||||||
|
|
||||||
|
virtual QString stationId() const = 0;
|
||||||
|
virtual QRadioData::ProgramType programType() const = 0;
|
||||||
|
virtual QString programTypeName() const = 0;
|
||||||
|
virtual QString stationName() const = 0;
|
||||||
|
virtual QString radioText() const = 0;
|
||||||
|
virtual void setAlternativeFrequenciesEnabled(bool enabled) = 0;
|
||||||
|
virtual bool isAlternativeFrequenciesEnabled() const = 0;
|
||||||
|
|
||||||
|
virtual QRadioData::Error error() const = 0;
|
||||||
|
virtual QString errorString() const = 0;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void stationIdChanged(QString stationId);
|
||||||
|
void programTypeChanged(QRadioData::ProgramType programType);
|
||||||
|
void programTypeNameChanged(QString programTypeName);
|
||||||
|
void stationNameChanged(QString stationName);
|
||||||
|
void radioTextChanged(QString radioText);
|
||||||
|
void alternativeFrequenciesEnabledChanged(bool enabled);
|
||||||
|
void error(QRadioData::Error err);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QRadioDataControl(QObject *parent = 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
#define QRadioDataControl_iid "com.nokia.Qt.QRadioDataControl/5.0"
|
||||||
|
Q_MEDIA_DECLARE_CONTROL(QRadioDataControl, QRadioDataControl_iid)
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
QT_END_HEADER
|
||||||
|
|
||||||
|
|
||||||
|
#endif // QRADIODATACONTROL_H
|
||||||
@@ -106,6 +106,7 @@ QRadioTuner::QRadioTuner(QObject *parent, QMediaServiceProvider* provider):
|
|||||||
connect(d->control, SIGNAL(signalStrengthChanged(int)), SIGNAL(signalStrengthChanged(int)));
|
connect(d->control, SIGNAL(signalStrengthChanged(int)), SIGNAL(signalStrengthChanged(int)));
|
||||||
connect(d->control, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged(int)));
|
connect(d->control, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged(int)));
|
||||||
connect(d->control, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool)));
|
connect(d->control, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool)));
|
||||||
|
connect(d->control, SIGNAL(stationFound(int,QString)), SIGNAL(stationFound(int,QString)));
|
||||||
connect(d->control, SIGNAL(error(QRadioTuner::Error)), SIGNAL(error(QRadioTuner::Error)));
|
connect(d->control, SIGNAL(error(QRadioTuner::Error)), SIGNAL(error(QRadioTuner::Error)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -456,6 +457,26 @@ void QRadioTuner::searchBackward()
|
|||||||
d->control->searchBackward();
|
d->control->searchBackward();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Search all stations in current band
|
||||||
|
|
||||||
|
Emits QRadioTuner::stationFound(int, QString) for every found station.
|
||||||
|
After searching is completed, QRadioTuner::searchingChanged(bool) is
|
||||||
|
emitted (false). If \a searchMode is set to SearchGetStationId, searching
|
||||||
|
waits for station id (PI) on each frequency.
|
||||||
|
|
||||||
|
\since 5.0
|
||||||
|
\sa searchForward(), searchBackward(), searching
|
||||||
|
*/
|
||||||
|
|
||||||
|
void QRadioTuner::searchAllStations(QRadioTuner::SearchMode searchMode)
|
||||||
|
{
|
||||||
|
Q_D(const QRadioTuner);
|
||||||
|
|
||||||
|
if (d->control != 0)
|
||||||
|
d->control->searchAllStations(searchMode);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Stops scanning for a signal.
|
Stops scanning for a signal.
|
||||||
|
|
||||||
@@ -554,6 +575,14 @@ QString QRadioTuner::errorString() const
|
|||||||
\since 1.0
|
\since 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioTuner::stationFound(int frequency, QString stationId)
|
||||||
|
|
||||||
|
Signals that a station was found in \a frequency with \a stationId Program
|
||||||
|
Identification code.
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn void QRadioTuner::error(QRadioTuner::Error error)
|
\fn void QRadioTuner::error(QRadioTuner::Error error)
|
||||||
|
|
||||||
|
|||||||
@@ -74,12 +74,14 @@ class Q_MULTIMEDIA_EXPORT QRadioTuner : public QMediaObject
|
|||||||
Q_ENUMS(Band)
|
Q_ENUMS(Band)
|
||||||
Q_ENUMS(Error)
|
Q_ENUMS(Error)
|
||||||
Q_ENUMS(StereoMode)
|
Q_ENUMS(StereoMode)
|
||||||
|
Q_ENUMS(SearchMode)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum State { ActiveState, StoppedState };
|
enum State { ActiveState, StoppedState };
|
||||||
enum Band { AM, FM, SW, LW, FM2 };
|
enum Band { AM, FM, SW, LW, FM2 };
|
||||||
enum Error { NoError, ResourceError, OpenError, OutOfRangeError };
|
enum Error { NoError, ResourceError, OpenError, OutOfRangeError };
|
||||||
enum StereoMode { ForceStereo, ForceMono, Auto };
|
enum StereoMode { ForceStereo, ForceMono, Auto };
|
||||||
|
enum SearchMode { SearchFast, SearchGetStationId };
|
||||||
|
|
||||||
QRadioTuner(QObject *parent = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider());
|
QRadioTuner(QObject *parent = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider());
|
||||||
~QRadioTuner();
|
~QRadioTuner();
|
||||||
@@ -114,6 +116,7 @@ public:
|
|||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void searchForward();
|
void searchForward();
|
||||||
void searchBackward();
|
void searchBackward();
|
||||||
|
void searchAllStations(QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast);
|
||||||
void cancelSearch();
|
void cancelSearch();
|
||||||
|
|
||||||
void setBand(Band band);
|
void setBand(Band band);
|
||||||
@@ -134,6 +137,8 @@ Q_SIGNALS:
|
|||||||
void signalStrengthChanged(int signalStrength);
|
void signalStrengthChanged(int signalStrength);
|
||||||
void volumeChanged(int volume);
|
void volumeChanged(int volume);
|
||||||
void mutedChanged(bool muted);
|
void mutedChanged(bool muted);
|
||||||
|
void stationFound(int frequency, QString stationId);
|
||||||
|
|
||||||
void error(QRadioTuner::Error error);
|
void error(QRadioTuner::Error error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -147,11 +152,13 @@ Q_DECLARE_METATYPE(QRadioTuner::State)
|
|||||||
Q_DECLARE_METATYPE(QRadioTuner::Band)
|
Q_DECLARE_METATYPE(QRadioTuner::Band)
|
||||||
Q_DECLARE_METATYPE(QRadioTuner::Error)
|
Q_DECLARE_METATYPE(QRadioTuner::Error)
|
||||||
Q_DECLARE_METATYPE(QRadioTuner::StereoMode)
|
Q_DECLARE_METATYPE(QRadioTuner::StereoMode)
|
||||||
|
Q_DECLARE_METATYPE(QRadioTuner::SearchMode)
|
||||||
|
|
||||||
Q_MEDIA_ENUM_DEBUG(QRadioTuner, State)
|
Q_MEDIA_ENUM_DEBUG(QRadioTuner, State)
|
||||||
Q_MEDIA_ENUM_DEBUG(QRadioTuner, Band)
|
Q_MEDIA_ENUM_DEBUG(QRadioTuner, Band)
|
||||||
Q_MEDIA_ENUM_DEBUG(QRadioTuner, Error)
|
Q_MEDIA_ENUM_DEBUG(QRadioTuner, Error)
|
||||||
Q_MEDIA_ENUM_DEBUG(QRadioTuner, StereoMode)
|
Q_MEDIA_ENUM_DEBUG(QRadioTuner, StereoMode)
|
||||||
|
Q_MEDIA_ENUM_DEBUG(QRadioTuner, SearchMode)
|
||||||
|
|
||||||
QT_END_HEADER
|
QT_END_HEADER
|
||||||
|
|
||||||
|
|||||||
@@ -267,6 +267,13 @@ QRadioTunerControl::~QRadioTunerControl()
|
|||||||
\since 1.0
|
\since 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioTunerControl::searchAllStations()
|
||||||
|
|
||||||
|
Starts a scan through the whole frequency band searching all stations
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn void QRadioTunerControl::cancelSearch()
|
\fn void QRadioTunerControl::cancelSearch()
|
||||||
|
|
||||||
@@ -359,6 +366,13 @@ QRadioTunerControl::~QRadioTunerControl()
|
|||||||
\since 1.0
|
\since 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QRadioTunerControl::stationFound(int frequency)
|
||||||
|
|
||||||
|
Signals that new station with \a frequency was found when scanning
|
||||||
|
\since 5.0
|
||||||
|
*/
|
||||||
|
|
||||||
#include "moc_qradiotunercontrol.cpp"
|
#include "moc_qradiotunercontrol.cpp"
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ public:
|
|||||||
|
|
||||||
virtual void searchForward() = 0;
|
virtual void searchForward() = 0;
|
||||||
virtual void searchBackward() = 0;
|
virtual void searchBackward() = 0;
|
||||||
|
virtual void searchAllStations(QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast) = 0;
|
||||||
virtual void cancelSearch() = 0;
|
virtual void cancelSearch() = 0;
|
||||||
|
|
||||||
virtual void start() = 0;
|
virtual void start() = 0;
|
||||||
@@ -107,6 +108,7 @@ Q_SIGNALS:
|
|||||||
void volumeChanged(int volume);
|
void volumeChanged(int volume);
|
||||||
void mutedChanged(bool muted);
|
void mutedChanged(bool muted);
|
||||||
void error(QRadioTuner::Error err);
|
void error(QRadioTuner::Error err);
|
||||||
|
void stationFound(int frequency, QString stationId);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QRadioTunerControl(QObject *parent = 0);
|
QRadioTunerControl(QObject *parent = 0);
|
||||||
|
|||||||
@@ -10,13 +10,14 @@ DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE}
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
fakeradioserviceplugin.h \
|
fakeradioserviceplugin.h \
|
||||||
fakeradioservice.h \
|
fakeradioservice.h \
|
||||||
fakeradiotunercontrol.h
|
fakeradiotunercontrol.h \
|
||||||
|
fakeradiodatacontrol.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
fakeradioserviceplugin.cpp \
|
fakeradioserviceplugin.cpp \
|
||||||
fakeradioservice.cpp \
|
fakeradioservice.cpp \
|
||||||
fakeradiotunercontrol.cpp
|
fakeradiotunercontrol.cpp \
|
||||||
|
fakeradiodatacontrol.cpp
|
||||||
|
|
||||||
target.path += $$[QT_INSTALL_PLUGINS]/$${PLUGIN_TYPE}
|
target.path += $$[QT_INSTALL_PLUGINS]/$${PLUGIN_TYPE}
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
|
|||||||
226
src/plugins/fakeradio/fakeradiodatacontrol.cpp
Normal file
226
src/plugins/fakeradio/fakeradiodatacontrol.cpp
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 "fakeradiodatacontrol.h"
|
||||||
|
#include "fakeradioservice.h"
|
||||||
|
|
||||||
|
#include <QtCore/qdebug.h>
|
||||||
|
|
||||||
|
FakeRadioDataControl::FakeRadioDataControl(QObject *parent)
|
||||||
|
:QRadioDataControl(parent)
|
||||||
|
{
|
||||||
|
initializeProgramTypeMapping();
|
||||||
|
|
||||||
|
m_rdsTimer = new QTimer(this);
|
||||||
|
connect(m_rdsTimer,SIGNAL(timeout()),this,SLOT(rdsUpdate()));
|
||||||
|
m_rdsTimer->start(5000);
|
||||||
|
rdsUpdate();
|
||||||
|
|
||||||
|
qsrand(QTime::currentTime().msec());
|
||||||
|
}
|
||||||
|
|
||||||
|
FakeRadioDataControl::~FakeRadioDataControl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FakeRadioDataControl::isAvailable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QtMultimedia::AvailabilityError FakeRadioDataControl::availabilityError() const
|
||||||
|
{
|
||||||
|
return QtMultimedia::NoError;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FakeRadioDataControl::stationId() const
|
||||||
|
{
|
||||||
|
return "12345678";
|
||||||
|
}
|
||||||
|
|
||||||
|
QRadioData::ProgramType FakeRadioDataControl::programType() const
|
||||||
|
{
|
||||||
|
return QRadioData::Drama;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FakeRadioDataControl::programTypeName() const
|
||||||
|
{
|
||||||
|
return "Cycling";
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FakeRadioDataControl::stationName() const
|
||||||
|
{
|
||||||
|
return "Fake FM";
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeRadioDataControl::rdsUpdate()
|
||||||
|
{
|
||||||
|
static int index = 0;
|
||||||
|
QString rdsStrings[] = {
|
||||||
|
"This is radio Fake FM",
|
||||||
|
"There is nothing to listen to here",
|
||||||
|
"Please remain calm" };
|
||||||
|
setradioText(rdsStrings[index%3]);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeRadioDataControl::setradioText(QString text)
|
||||||
|
{
|
||||||
|
m_radioText = text;
|
||||||
|
emit radioTextChanged(m_radioText);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FakeRadioDataControl::radioText() const
|
||||||
|
{
|
||||||
|
return m_radioText;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeRadioDataControl::setAlternativeFrequenciesEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
m_alternativeFrequenciesEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FakeRadioDataControl::isAlternativeFrequenciesEnabled() const
|
||||||
|
{
|
||||||
|
return m_alternativeFrequenciesEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRadioData::Error FakeRadioDataControl::error() const
|
||||||
|
{
|
||||||
|
return QRadioData::NoError;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FakeRadioDataControl::errorString() const
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeRadioDataControl::initializeProgramTypeMapping()
|
||||||
|
{
|
||||||
|
m_programTypeMapRDS[0] = QRadioData::Undefined;
|
||||||
|
m_programTypeMapRDS[1] = QRadioData::News;
|
||||||
|
m_programTypeMapRDS[2] = QRadioData::CurrentAffairs;
|
||||||
|
m_programTypeMapRDS[3] = QRadioData::Information;
|
||||||
|
m_programTypeMapRDS[4] = QRadioData::Sport;
|
||||||
|
m_programTypeMapRDS[5] = QRadioData::Education;
|
||||||
|
m_programTypeMapRDS[6] = QRadioData::Drama;
|
||||||
|
m_programTypeMapRDS[7] = QRadioData::Culture;
|
||||||
|
m_programTypeMapRDS[8] = QRadioData::Science;
|
||||||
|
m_programTypeMapRDS[9] = QRadioData::Varied;
|
||||||
|
m_programTypeMapRDS[10] = QRadioData::PopMusic;
|
||||||
|
m_programTypeMapRDS[11] = QRadioData::RockMusic;
|
||||||
|
m_programTypeMapRDS[12] = QRadioData::EasyListening;
|
||||||
|
m_programTypeMapRDS[13] = QRadioData::LightClassical;
|
||||||
|
m_programTypeMapRDS[14] = QRadioData::SeriousClassical;
|
||||||
|
m_programTypeMapRDS[15] = QRadioData::OtherMusic;
|
||||||
|
m_programTypeMapRDS[16] = QRadioData::Weather;
|
||||||
|
m_programTypeMapRDS[17] = QRadioData::Finance;
|
||||||
|
m_programTypeMapRDS[18] = QRadioData::ChildrensProgrammes;
|
||||||
|
m_programTypeMapRDS[19] = QRadioData::SocialAffairs;
|
||||||
|
m_programTypeMapRDS[20] = QRadioData::Religion;
|
||||||
|
m_programTypeMapRDS[21] = QRadioData::PhoneIn;
|
||||||
|
m_programTypeMapRDS[22] = QRadioData::Travel;
|
||||||
|
m_programTypeMapRDS[23] = QRadioData::Leisure;
|
||||||
|
m_programTypeMapRDS[24] = QRadioData::JazzMusic;
|
||||||
|
m_programTypeMapRDS[25] = QRadioData::CountryMusic;
|
||||||
|
m_programTypeMapRDS[26] = QRadioData::NationalMusic;
|
||||||
|
m_programTypeMapRDS[27] = QRadioData::OldiesMusic;
|
||||||
|
m_programTypeMapRDS[28] = QRadioData::FolkMusic;
|
||||||
|
m_programTypeMapRDS[29] = QRadioData::Documentary;
|
||||||
|
m_programTypeMapRDS[30] = QRadioData::AlarmTest;
|
||||||
|
m_programTypeMapRDS[31] = QRadioData::Alarm;
|
||||||
|
|
||||||
|
m_programTypeMapRBDS[0] = QRadioData::Undefined,
|
||||||
|
m_programTypeMapRBDS[1] = QRadioData::News;
|
||||||
|
m_programTypeMapRBDS[2] = QRadioData::Information;
|
||||||
|
m_programTypeMapRBDS[3] = QRadioData::Sport;
|
||||||
|
m_programTypeMapRBDS[4] = QRadioData::Talk;
|
||||||
|
m_programTypeMapRBDS[5] = QRadioData::RockMusic;
|
||||||
|
m_programTypeMapRBDS[6] = QRadioData::ClassicRock;
|
||||||
|
m_programTypeMapRBDS[7] = QRadioData::AdultHits;
|
||||||
|
m_programTypeMapRBDS[8] = QRadioData::SoftRock;
|
||||||
|
m_programTypeMapRBDS[9] = QRadioData::Top40;
|
||||||
|
m_programTypeMapRBDS[10] = QRadioData::CountryMusic;
|
||||||
|
m_programTypeMapRBDS[11] = QRadioData::OldiesMusic;
|
||||||
|
m_programTypeMapRBDS[12] = QRadioData::Soft;
|
||||||
|
m_programTypeMapRBDS[13] = QRadioData::Nostalgia;
|
||||||
|
m_programTypeMapRBDS[14] = QRadioData::JazzMusic;
|
||||||
|
m_programTypeMapRBDS[15] = QRadioData::Classical;
|
||||||
|
m_programTypeMapRBDS[16] = QRadioData::RhythmAndBlues;
|
||||||
|
m_programTypeMapRBDS[17] = QRadioData::SoftRhythmAndBlues;
|
||||||
|
m_programTypeMapRBDS[18] = QRadioData::Language;
|
||||||
|
m_programTypeMapRBDS[19] = QRadioData::ReligiousMusic;
|
||||||
|
m_programTypeMapRBDS[20] = QRadioData::ReligiousTalk;
|
||||||
|
m_programTypeMapRBDS[21] = QRadioData::Personality;
|
||||||
|
m_programTypeMapRBDS[22] = QRadioData::Public;
|
||||||
|
m_programTypeMapRBDS[23] = QRadioData::College;
|
||||||
|
m_programTypeMapRBDS[24] = QRadioData::Undefined;
|
||||||
|
m_programTypeMapRBDS[25] = QRadioData::Undefined;
|
||||||
|
m_programTypeMapRBDS[26] = QRadioData::Undefined;
|
||||||
|
m_programTypeMapRBDS[27] = QRadioData::Undefined;
|
||||||
|
m_programTypeMapRBDS[28] = QRadioData::Undefined;
|
||||||
|
m_programTypeMapRBDS[29] = QRadioData::Weather;
|
||||||
|
m_programTypeMapRBDS[30] = QRadioData::AlarmTest;
|
||||||
|
m_programTypeMapRBDS[31] = QRadioData::Alarm;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FakeRadioDataControl::usingRBDS()
|
||||||
|
{
|
||||||
|
switch ( QLocale::system().country() )
|
||||||
|
{
|
||||||
|
case QLocale::Canada:
|
||||||
|
case QLocale::Mexico:
|
||||||
|
case QLocale::UnitedStates:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRadioData::ProgramType FakeRadioDataControl::fromRawProgramType(int rawProgramType)
|
||||||
|
{
|
||||||
|
if ( usingRBDS() )
|
||||||
|
return m_programTypeMapRBDS.value(rawProgramType, QRadioData::Undefined);
|
||||||
|
|
||||||
|
return m_programTypeMapRDS.value(rawProgramType, QRadioData::Undefined);
|
||||||
|
}
|
||||||
96
src/plugins/fakeradio/fakeradiodatacontrol.h
Normal file
96
src/plugins/fakeradio/fakeradiodatacontrol.h
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 FAKERADIODATACONTROL_H
|
||||||
|
#define FAKERADIODATACONTROL_H
|
||||||
|
|
||||||
|
#include <QtCore/qobject.h>
|
||||||
|
#include <QtCore/qtimer.h>
|
||||||
|
#include <QtCore/qdatetime.h>
|
||||||
|
|
||||||
|
#include <qradiodatacontrol.h>
|
||||||
|
|
||||||
|
QT_USE_NAMESPACE
|
||||||
|
|
||||||
|
class FakeRadioService;
|
||||||
|
|
||||||
|
class FakeRadioDataControl : public QRadioDataControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
FakeRadioDataControl(QObject *parent = 0);
|
||||||
|
~FakeRadioDataControl();
|
||||||
|
|
||||||
|
bool isAvailable() const;
|
||||||
|
QtMultimedia::AvailabilityError availabilityError() const;
|
||||||
|
|
||||||
|
QString stationId() const;
|
||||||
|
QRadioData::ProgramType programType() const;
|
||||||
|
QString programTypeName() const;
|
||||||
|
QString stationName() const;
|
||||||
|
QString radioText() const;
|
||||||
|
void setAlternativeFrequenciesEnabled(bool enabled);
|
||||||
|
bool isAlternativeFrequenciesEnabled() const;
|
||||||
|
|
||||||
|
QRadioData::Error error() const;
|
||||||
|
QString errorString() const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void rdsUpdate();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setradioText(QString);
|
||||||
|
void initializeProgramTypeMapping();
|
||||||
|
bool usingRBDS();
|
||||||
|
QRadioData::ProgramType fromRawProgramType(int rawProgramType);
|
||||||
|
|
||||||
|
private: //data
|
||||||
|
bool m_alternativeFrequenciesEnabled;
|
||||||
|
QString m_radioText;
|
||||||
|
QTimer *m_rdsTimer;
|
||||||
|
|
||||||
|
QMap<int, QRadioData::ProgramType> m_programTypeMapRDS;
|
||||||
|
QMap<int, QRadioData::ProgramType> m_programTypeMapRBDS;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FAKERADIODATACONTROL_H
|
||||||
@@ -46,21 +46,46 @@
|
|||||||
|
|
||||||
#include "fakeradioservice.h"
|
#include "fakeradioservice.h"
|
||||||
#include "fakeradiotunercontrol.h"
|
#include "fakeradiotunercontrol.h"
|
||||||
|
#include "fakeradiodatacontrol.h"
|
||||||
|
|
||||||
|
Q_GLOBAL_STATIC( QMutex, fakeRadioServiceMutex );
|
||||||
|
FakeRadioService* FakeRadioService::m_instance = 0;
|
||||||
|
int FakeRadioService::m_referenceCount = 0;
|
||||||
|
|
||||||
FakeRadioService::FakeRadioService(QObject *parent):
|
FakeRadioService::FakeRadioService(QObject *parent):
|
||||||
QMediaService(parent)
|
QMediaService(parent)
|
||||||
{
|
{
|
||||||
m_control = new FakeRadioTunerControl(this);
|
m_tunerControl = new FakeRadioTunerControl(this);
|
||||||
|
m_dataControl = new FakeRadioDataControl(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
FakeRadioService::~FakeRadioService()
|
FakeRadioService::~FakeRadioService()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FakeRadioService* FakeRadioService::instance()
|
||||||
|
{
|
||||||
|
QMutexLocker lock(fakeRadioServiceMutex());
|
||||||
|
if (!m_instance)
|
||||||
|
m_instance = new FakeRadioService;
|
||||||
|
m_referenceCount++;
|
||||||
|
return m_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeRadioService::release()
|
||||||
|
{
|
||||||
|
QMutexLocker lock(fakeRadioServiceMutex());
|
||||||
|
m_referenceCount--;
|
||||||
|
if (m_referenceCount == 0)
|
||||||
|
delete m_instance;
|
||||||
|
}
|
||||||
|
|
||||||
QMediaControl *FakeRadioService::requestControl(const char* name)
|
QMediaControl *FakeRadioService::requestControl(const char* name)
|
||||||
{
|
{
|
||||||
if (qstrcmp(name,QRadioTunerControl_iid) == 0)
|
if (qstrcmp(name,QRadioTunerControl_iid) == 0)
|
||||||
return m_control;
|
return m_tunerControl;
|
||||||
|
if (qstrcmp(name,QRadioDataControl_iid) == 0)
|
||||||
|
return m_dataControl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,25 +43,36 @@
|
|||||||
#define FAKERADIOSERVICE_H
|
#define FAKERADIOSERVICE_H
|
||||||
|
|
||||||
#include <QtCore/qobject.h>
|
#include <QtCore/qobject.h>
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
#include <qmediaservice.h>
|
#include <qmediaservice.h>
|
||||||
QT_USE_NAMESPACE
|
QT_USE_NAMESPACE
|
||||||
|
|
||||||
class FakeRadioTunerControl;
|
class FakeRadioTunerControl;
|
||||||
|
class FakeRadioDataControl;
|
||||||
|
|
||||||
class FakeRadioService : public QMediaService
|
class FakeRadioService : public QMediaService
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
private:
|
||||||
FakeRadioService(QObject *parent = 0);
|
FakeRadioService(QObject *parent = 0);
|
||||||
~FakeRadioService();
|
~FakeRadioService();
|
||||||
|
|
||||||
|
public:
|
||||||
|
static FakeRadioService* instance();
|
||||||
|
void release();
|
||||||
|
|
||||||
QMediaControl *requestControl(const char* name);
|
QMediaControl *requestControl(const char* name);
|
||||||
void releaseControl(QMediaControl *);
|
void releaseControl(QMediaControl *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FakeRadioTunerControl *m_control;
|
static FakeRadioService* m_instance;
|
||||||
|
static int m_referenceCount;
|
||||||
|
|
||||||
|
FakeRadioTunerControl *m_tunerControl;
|
||||||
|
FakeRadioDataControl *m_dataControl;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FAKERADIOSERVICE_H
|
#endif // FAKERADIOSERVICE_H
|
||||||
|
|||||||
@@ -59,14 +59,16 @@ QStringList FakeRadioServicePlugin::keys() const
|
|||||||
QMediaService* FakeRadioServicePlugin::create(QString const& key)
|
QMediaService* FakeRadioServicePlugin::create(QString const& key)
|
||||||
{
|
{
|
||||||
if (key == QLatin1String(Q_MEDIASERVICE_RADIO))
|
if (key == QLatin1String(Q_MEDIASERVICE_RADIO))
|
||||||
return new FakeRadioService;
|
return FakeRadioService::instance();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeRadioServicePlugin::release(QMediaService *service)
|
void FakeRadioServicePlugin::release(QMediaService *service)
|
||||||
{
|
{
|
||||||
delete service;
|
FakeRadioService* fakeRadio = qobject_cast<FakeRadioService*>(service);
|
||||||
|
if (fakeRadio)
|
||||||
|
fakeRadio->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QByteArray> FakeRadioServicePlugin::devices(const QByteArray &service) const
|
QList<QByteArray> FakeRadioServicePlugin::devices(const QByteArray &service) const
|
||||||
|
|||||||
@@ -60,10 +60,16 @@ FakeRadioTunerControl::FakeRadioTunerControl(QObject *parent)
|
|||||||
|
|
||||||
m_searching = false;
|
m_searching = false;
|
||||||
m_forward = true;
|
m_forward = true;
|
||||||
|
m_searchMode = QRadioTuner::SearchFast;
|
||||||
|
m_piCounter = 0;
|
||||||
m_searchTimer = new QTimer(this);
|
m_searchTimer = new QTimer(this);
|
||||||
m_searchTimer->setSingleShot(true);
|
m_searchTimer->setSingleShot(true);
|
||||||
connect(m_searchTimer, SIGNAL(timeout()), this, SLOT(searchEnded()));
|
connect(m_searchTimer, SIGNAL(timeout()), this, SLOT(searchEnded()));
|
||||||
|
|
||||||
|
m_allStationSeekTimer = new QTimer(this);
|
||||||
|
m_allStationSeekTimer->setSingleShot(true);
|
||||||
|
connect(m_allStationSeekTimer,SIGNAL(timeout()),this,SLOT(newStationFound()));
|
||||||
|
|
||||||
QTimer::singleShot(300, this, SLOT(delayedInit()));
|
QTimer::singleShot(300, this, SLOT(delayedInit()));
|
||||||
|
|
||||||
qsrand(QTime::currentTime().msec());
|
qsrand(QTime::currentTime().msec());
|
||||||
@@ -269,6 +275,42 @@ void FakeRadioTunerControl::searchBackward()
|
|||||||
performSearch();
|
performSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FakeRadioTunerControl::searchAllStations(QRadioTuner::SearchMode searchMode)
|
||||||
|
{
|
||||||
|
m_searchMode = searchMode;
|
||||||
|
m_seekingStartFreq = m_currentFreq;
|
||||||
|
m_searching = true;
|
||||||
|
m_allStationSeekTimer->start(10);
|
||||||
|
emit searchingChanged(m_searching);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeRadioTunerControl::newStationFound()
|
||||||
|
{
|
||||||
|
QPair<int, int> fRange = frequencyRange(m_currentBand);
|
||||||
|
if (m_currentFreq == fRange.second)
|
||||||
|
m_currentFreq = fRange.first;
|
||||||
|
else
|
||||||
|
m_currentFreq += 100000;
|
||||||
|
emit frequencyChanged(m_currentFreq);
|
||||||
|
|
||||||
|
// There are 200 ticks, we want to find average of 5 stations per scan
|
||||||
|
if (qrand() < (RAND_MAX/40)) {
|
||||||
|
QString programmeId;
|
||||||
|
|
||||||
|
if (m_searchMode == QRadioTuner::SearchGetStationId)
|
||||||
|
programmeId = QString("FakeProgrammeID") + QString::number(m_piCounter++);
|
||||||
|
|
||||||
|
emit stationFound(m_currentFreq, programmeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_currentFreq == m_seekingStartFreq) {
|
||||||
|
m_searching = false;
|
||||||
|
emit searchingChanged(m_searching);
|
||||||
|
}else {
|
||||||
|
m_allStationSeekTimer->start(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FakeRadioTunerControl::start()
|
void FakeRadioTunerControl::start()
|
||||||
{
|
{
|
||||||
if (isAvailable() && m_state != QRadioTuner::ActiveState) {
|
if (isAvailable() && m_state != QRadioTuner::ActiveState) {
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ public:
|
|||||||
|
|
||||||
void searchForward();
|
void searchForward();
|
||||||
void searchBackward();
|
void searchBackward();
|
||||||
|
void searchAllStations(QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast);
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
@@ -101,6 +102,7 @@ private slots:
|
|||||||
void delayedInit();
|
void delayedInit();
|
||||||
void performSearch();
|
void performSearch();
|
||||||
void searchEnded();
|
void searchEnded();
|
||||||
|
void newStationFound();
|
||||||
|
|
||||||
private: //data
|
private: //data
|
||||||
QRadioTuner::State m_state;
|
QRadioTuner::State m_state;
|
||||||
@@ -108,6 +110,7 @@ private: //data
|
|||||||
qint64 m_freqMin;
|
qint64 m_freqMin;
|
||||||
qint64 m_freqMax;
|
qint64 m_freqMax;
|
||||||
qint64 m_currentFreq;
|
qint64 m_currentFreq;
|
||||||
|
qint64 m_seekingStartFreq;
|
||||||
bool m_stereo;
|
bool m_stereo;
|
||||||
QRadioTuner::StereoMode m_stereoMode;
|
QRadioTuner::StereoMode m_stereoMode;
|
||||||
int m_signalStrength;
|
int m_signalStrength;
|
||||||
@@ -117,7 +120,11 @@ private: //data
|
|||||||
// searching
|
// searching
|
||||||
bool m_searching;
|
bool m_searching;
|
||||||
bool m_forward;
|
bool m_forward;
|
||||||
|
QRadioTuner::SearchMode m_searchMode;
|
||||||
|
int m_piCounter;
|
||||||
QTimer *m_searchTimer;
|
QTimer *m_searchTimer;
|
||||||
|
QTimer *m_allStationSeekTimer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FAKERADIOTUNERCONTROL_H
|
#endif // FAKERADIOTUNERCONTROL_H
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ SUBDIRS += \
|
|||||||
qmediaservice \
|
qmediaservice \
|
||||||
qmediatimerange \
|
qmediatimerange \
|
||||||
qradiotuner \
|
qradiotuner \
|
||||||
|
qradiodata \
|
||||||
qvideoframe \
|
qvideoframe \
|
||||||
qvideosurfaceformat \
|
qvideosurfaceformat \
|
||||||
qmetadatareadercontrol \
|
qmetadatareadercontrol \
|
||||||
|
|||||||
@@ -4,4 +4,5 @@
|
|||||||
INCLUDEPATH += .
|
INCLUDEPATH += .
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
../qmultimedia_common/mockradiotunercontrol.h
|
../qmultimedia_common/mockradiotunercontrol.h \
|
||||||
|
../qmultimedia_common/mockradiodatacontrol.h
|
||||||
|
|||||||
157
tests/auto/qmultimedia_common/mockradiodatacontrol.h
Normal file
157
tests/auto/qmultimedia_common/mockradiodatacontrol.h
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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$
|
||||||
|
** 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 MOCKRADIODATACONTROL_H
|
||||||
|
#define MOCKRADIODATACONTROL_H
|
||||||
|
|
||||||
|
#include "qradiodatacontrol.h"
|
||||||
|
|
||||||
|
class MockRadioDataControl : public QRadioDataControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MockRadioDataControl(QObject *parent):
|
||||||
|
QRadioDataControl(parent), m_err(QRadioData::NoError),
|
||||||
|
m_errstr("")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
using QRadioDataControl::error;
|
||||||
|
|
||||||
|
bool isAvailable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
QtMultimedia::AvailabilityError availabilityError() const
|
||||||
|
{
|
||||||
|
return QtMultimedia::NoError;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRadioData::Error error() const
|
||||||
|
{
|
||||||
|
return m_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString errorString() const
|
||||||
|
{
|
||||||
|
return m_errstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString stationId() const
|
||||||
|
{
|
||||||
|
return m_stationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRadioData::ProgramType programType() const
|
||||||
|
{
|
||||||
|
return m_programType;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString programTypeName() const
|
||||||
|
{
|
||||||
|
return m_programTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString stationName() const
|
||||||
|
{
|
||||||
|
return m_stationName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString radioText() const
|
||||||
|
{
|
||||||
|
return m_radioText;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAlternativeFrequenciesEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
m_alternativeFrequenciesEnabled = enabled;
|
||||||
|
emit alternativeFrequenciesEnabledChanged(m_alternativeFrequenciesEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isAlternativeFrequenciesEnabled() const
|
||||||
|
{
|
||||||
|
return m_alternativeFrequenciesEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void forceRT( QString text )
|
||||||
|
{
|
||||||
|
m_radioText = text;
|
||||||
|
emit radioTextChanged(m_radioText);
|
||||||
|
}
|
||||||
|
|
||||||
|
void forceProgramType( int pty )
|
||||||
|
{
|
||||||
|
m_programType = static_cast<QRadioData::ProgramType>(pty);
|
||||||
|
emit programTypeChanged(m_programType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void forcePTYN( QString ptyn )
|
||||||
|
{
|
||||||
|
m_programTypeName = ptyn;
|
||||||
|
emit programTypeNameChanged(m_programTypeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void forcePI( QString pi )
|
||||||
|
{
|
||||||
|
m_stationId = pi;
|
||||||
|
emit stationIdChanged(m_stationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void forcePS( QString ps )
|
||||||
|
{
|
||||||
|
m_stationName = ps;
|
||||||
|
emit stationNameChanged(m_stationName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
QString m_radioText;
|
||||||
|
QRadioData::ProgramType m_programType;
|
||||||
|
QString m_programTypeName;
|
||||||
|
QString m_stationId;
|
||||||
|
QString m_stationName;
|
||||||
|
bool m_alternativeFrequenciesEnabled;
|
||||||
|
|
||||||
|
QRadioData::Error m_err;
|
||||||
|
QString m_errstr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKRADIODATACONTROL_H
|
||||||
@@ -216,6 +216,32 @@ public:
|
|||||||
emit searchingChanged(m_searching);
|
emit searchingChanged(m_searching);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void findNewStation( int frequency, QString stationId )
|
||||||
|
{
|
||||||
|
setFrequency(frequency);
|
||||||
|
emit stationFound( frequency, stationId );
|
||||||
|
}
|
||||||
|
|
||||||
|
void searchAllStations(QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast)
|
||||||
|
{
|
||||||
|
QString programmeIdentifiers[3] = { "", "", "" };
|
||||||
|
|
||||||
|
if ( searchMode == QRadioTuner::SearchGetStationId ) {
|
||||||
|
programmeIdentifiers[0] = QString("MockProgramPI1");
|
||||||
|
programmeIdentifiers[1] = QString("MockProgramPI2");
|
||||||
|
programmeIdentifiers[2] = QString("MockProgramPI3");
|
||||||
|
}
|
||||||
|
m_searching = true;
|
||||||
|
emit searchingChanged(m_searching);
|
||||||
|
|
||||||
|
findNewStation(88300000, programmeIdentifiers[0]);
|
||||||
|
findNewStation(95100000, programmeIdentifiers[1]);
|
||||||
|
findNewStation(103100000, programmeIdentifiers[2]);
|
||||||
|
|
||||||
|
m_searching = false;
|
||||||
|
emit searchingChanged(m_searching);
|
||||||
|
}
|
||||||
|
|
||||||
void start()
|
void start()
|
||||||
{
|
{
|
||||||
if (!m_active) {
|
if (!m_active) {
|
||||||
|
|||||||
53
tests/auto/qradiodata/main.cpp
Executable file
53
tests/auto/qradiodata/main.cpp
Executable file
@@ -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 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 <QtCore/qcoreapplication.h>
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
#include "tst_qradiodata.h"
|
||||||
|
|
||||||
|
int main(int argc, char**argv)
|
||||||
|
{
|
||||||
|
QCoreApplication app(argc,argv);
|
||||||
|
int ret;
|
||||||
|
tst_QRadioData test_api;
|
||||||
|
ret = QTest::qExec(&test_api, argc, argv);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
11
tests/auto/qradiodata/qradiodata.pro
Normal file
11
tests/auto/qradiodata/qradiodata.pro
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
CONFIG += testcase
|
||||||
|
TARGET = tst_qradiodata
|
||||||
|
|
||||||
|
QT += multimedia-private testlib
|
||||||
|
CONFIG += no_private_qt_headers_warning
|
||||||
|
|
||||||
|
HEADERS += tst_qradiodata.h
|
||||||
|
SOURCES += main.cpp tst_qradiodata.cpp
|
||||||
|
|
||||||
|
include (../qmultimedia_common/mock.pri)
|
||||||
|
include (../qmultimedia_common/mockradio.pri)
|
||||||
148
tests/auto/qradiodata/tst_qradiodata.cpp
Normal file
148
tests/auto/qradiodata/tst_qradiodata.cpp
Normal file
@@ -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 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$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
//TESTED_COMPONENT=src/multimedia
|
||||||
|
|
||||||
|
#include "tst_qradiodata.h"
|
||||||
|
|
||||||
|
QT_USE_NAMESPACE
|
||||||
|
|
||||||
|
void tst_QRadioData::initTestCase()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<QRadioData::ProgramType>("QRadioData::ProgramType");
|
||||||
|
|
||||||
|
mock = new MockRadioDataControl(this);
|
||||||
|
service = new MockMediaService(this, mock);
|
||||||
|
provider = new MockMediaServiceProvider(service);
|
||||||
|
radio = new QRadioData(0,provider);
|
||||||
|
QVERIFY(radio->service() != 0);
|
||||||
|
QVERIFY(radio->isAvailable());
|
||||||
|
QVERIFY(radio->availabilityError() == QtMultimedia::NoError);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QRadioData::cleanupTestCase()
|
||||||
|
{
|
||||||
|
QVERIFY(radio->error() == QRadioData::NoError);
|
||||||
|
QVERIFY(radio->errorString().isEmpty());
|
||||||
|
|
||||||
|
delete radio;
|
||||||
|
delete service;
|
||||||
|
delete provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QRadioData::testNullService()
|
||||||
|
{
|
||||||
|
const QPair<int, int> nullRange(0, 0);
|
||||||
|
|
||||||
|
MockMediaServiceProvider provider(0);
|
||||||
|
QRadioData radio(0, &provider);
|
||||||
|
QVERIFY(!radio.isAvailable());
|
||||||
|
QCOMPARE(radio.error(), QRadioData::ResourceError);
|
||||||
|
QCOMPARE(radio.errorString(), QString());
|
||||||
|
QCOMPARE(radio.stationId(), QString());
|
||||||
|
QCOMPARE(radio.programType(), QRadioData::Undefined);
|
||||||
|
QCOMPARE(radio.programTypeName(), QString());
|
||||||
|
QCOMPARE(radio.stationName(), QString());
|
||||||
|
QCOMPARE(radio.radioText(), QString());
|
||||||
|
QCOMPARE(radio.isAlternativeFrequenciesEnabled(), false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QRadioData::testNullControl()
|
||||||
|
{
|
||||||
|
const QPair<int, int> nullRange(0, 0);
|
||||||
|
|
||||||
|
MockMediaService service(0, 0);
|
||||||
|
MockMediaServiceProvider provider(&service);
|
||||||
|
QRadioData radio(0, &provider);
|
||||||
|
QVERIFY(!radio.isAvailable());
|
||||||
|
QCOMPARE(radio.error(), QRadioData::ResourceError);
|
||||||
|
QCOMPARE(radio.errorString(), QString());
|
||||||
|
|
||||||
|
QCOMPARE(radio.stationId(), QString());
|
||||||
|
QCOMPARE(radio.programType(), QRadioData::Undefined);
|
||||||
|
QCOMPARE(radio.programTypeName(), QString());
|
||||||
|
QCOMPARE(radio.stationName(), QString());
|
||||||
|
QCOMPARE(radio.radioText(), QString());
|
||||||
|
QCOMPARE(radio.isAlternativeFrequenciesEnabled(), false);
|
||||||
|
{
|
||||||
|
QSignalSpy spy(&radio, SIGNAL(alternativeFrequenciesEnabledChanged(bool)));
|
||||||
|
|
||||||
|
radio.setAlternativeFrequenciesEnabled(true);
|
||||||
|
QCOMPARE(radio.isAlternativeFrequenciesEnabled(), false);
|
||||||
|
QCOMPARE(spy.count(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QRadioData::testAlternativeFrequencies()
|
||||||
|
{
|
||||||
|
QSignalSpy readSignal(radio, SIGNAL(alternativeFrequenciesEnabledChanged(bool)));
|
||||||
|
radio->setAlternativeFrequenciesEnabled(true);
|
||||||
|
QTestEventLoop::instance().enterLoop(1);
|
||||||
|
QVERIFY(radio->isAlternativeFrequenciesEnabled() == true);
|
||||||
|
QVERIFY(readSignal.count() == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QRadioData::testRadioDataUpdates()
|
||||||
|
{
|
||||||
|
QSignalSpy rtSpy(radio, SIGNAL(radioTextChanged(QString)));
|
||||||
|
QSignalSpy ptyPTYSpy(radio, SIGNAL(programTypeChanged(QRadioData::ProgramType)));
|
||||||
|
QSignalSpy ptynSpy(radio, SIGNAL(programTypeNameChanged(QString)));
|
||||||
|
QSignalSpy piSpy(radio, SIGNAL(stationIdChanged(QString)));
|
||||||
|
QSignalSpy psSpy(radio, SIGNAL(stationNameChanged(QString)));
|
||||||
|
mock->forceRT("Mock Radio Text");
|
||||||
|
mock->forceProgramType(static_cast<int>(QRadioData::Sport));
|
||||||
|
mock->forcePTYN("Mock Programme Type Name");
|
||||||
|
mock->forcePI("Mock Programme Identification");
|
||||||
|
mock->forcePS("Mock Programme Service");
|
||||||
|
QTestEventLoop::instance().enterLoop(1);
|
||||||
|
QVERIFY(rtSpy.count() == 1);
|
||||||
|
QVERIFY(ptyPTYSpy.count() == 1);
|
||||||
|
QVERIFY(ptynSpy.count() == 1);
|
||||||
|
QVERIFY(piSpy.count() == 1);
|
||||||
|
QVERIFY(psSpy.count() == 1);
|
||||||
|
qDebug()<<radio->radioText();
|
||||||
|
QCOMPARE(radio->radioText(), QString("Mock Radio Text"));
|
||||||
|
QCOMPARE(radio->programType(), QRadioData::Sport);
|
||||||
|
QCOMPARE(radio->programTypeName(), QString("Mock Programme Type Name"));
|
||||||
|
QCOMPARE(radio->stationId(), QString("Mock Programme Identification"));
|
||||||
|
QCOMPARE(radio->stationName(), QString("Mock Programme Service"));
|
||||||
|
}
|
||||||
80
tests/auto/qradiodata/tst_qradiodata.h
Normal file
80
tests/auto/qradiodata/tst_qradiodata.h
Normal file
@@ -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 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 TST_QRADIODATA_H
|
||||||
|
#define TST_QRADIODATA_H
|
||||||
|
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <qmediaobject.h>
|
||||||
|
#include <qmediacontrol.h>
|
||||||
|
#include <qmediaservice.h>
|
||||||
|
#include <qradiodatacontrol.h>
|
||||||
|
#include <qradiodata.h>
|
||||||
|
|
||||||
|
#include "mockmediaserviceprovider.h"
|
||||||
|
#include "mockmediaservice.h"
|
||||||
|
#include "mockradiodatacontrol.h"
|
||||||
|
|
||||||
|
QT_USE_NAMESPACE
|
||||||
|
|
||||||
|
class tst_QRadioData: public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void initTestCase();
|
||||||
|
void cleanupTestCase();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void testNullService();
|
||||||
|
void testNullControl();
|
||||||
|
void testAlternativeFrequencies();
|
||||||
|
void testRadioDataUpdates();
|
||||||
|
|
||||||
|
private:
|
||||||
|
MockRadioDataControl *mock;
|
||||||
|
MockMediaService *service;
|
||||||
|
MockMediaServiceProvider *provider;
|
||||||
|
QRadioData *radio;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@@ -186,6 +186,10 @@ void tst_QRadioTuner::testNullControl()
|
|||||||
QCOMPARE(radio.isSearching(), false);
|
QCOMPARE(radio.isSearching(), false);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
|
|
||||||
|
radio.searchAllStations();
|
||||||
|
QCOMPARE(radio.isSearching(), false);
|
||||||
|
QCOMPARE(spy.count(), 0);
|
||||||
|
|
||||||
radio.cancelSearch();
|
radio.cancelSearch();
|
||||||
QCOMPARE(radio.isSearching(), false);
|
QCOMPARE(radio.isSearching(), false);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
@@ -281,6 +285,19 @@ void tst_QRadioTuner::testStereo()
|
|||||||
QVERIFY(radio->stereoMode() == QRadioTuner::ForceMono);
|
QVERIFY(radio->stereoMode() == QRadioTuner::ForceMono);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QRadioTuner::testSearchAllStations()
|
||||||
|
{
|
||||||
|
QSignalSpy foundSpy(radio, SIGNAL(stationFound(int,QString)));
|
||||||
|
QSignalSpy completeSpy(radio, SIGNAL(searchingChanged(bool)));
|
||||||
|
radio->searchAllStations(QRadioTuner::SearchGetStationId);
|
||||||
|
QTestEventLoop::instance().enterLoop(1);
|
||||||
|
QCOMPARE(radio->frequency(), 103100000 );
|
||||||
|
QCOMPARE(foundSpy.count(), 3);
|
||||||
|
QVERIFY(qvariant_cast<int>(foundSpy.at(2).at(0)) == 103100000 );
|
||||||
|
QVERIFY(qvariant_cast<QString>(foundSpy.at(2).at(1)) == QString("MockProgramPI3") );
|
||||||
|
QCOMPARE(completeSpy.count(), 2);
|
||||||
|
}
|
||||||
|
|
||||||
// QRadioTuner's errorsignal
|
// QRadioTuner's errorsignal
|
||||||
void tst_QRadioTuner::errorSignal()
|
void tst_QRadioTuner::errorSignal()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ private slots:
|
|||||||
void testVolume();
|
void testVolume();
|
||||||
void testSignal();
|
void testSignal();
|
||||||
void testStereo();
|
void testStereo();
|
||||||
|
void testSearchAllStations();
|
||||||
void errorSignal();
|
void errorSignal();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user