We already have a mock backend.
Change-Id: Ic4f9277c4c4bff225ac6cd70d28b495a42435e35 Reviewed-by: Sergey Dubitskiy <sergey.dubitskiy@nokia.com> Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
89b6bcbd96
commit
ab52443dc5
@@ -1,24 +0,0 @@
|
|||||||
load(qt_module)
|
|
||||||
|
|
||||||
TARGET = qtmedia_fakeradio
|
|
||||||
QT += multimedia-private
|
|
||||||
PLUGIN_TYPE = mediaservice
|
|
||||||
|
|
||||||
load(qt_plugin)
|
|
||||||
DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE}
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
fakeradioserviceplugin.h \
|
|
||||||
fakeradioservice.h \
|
|
||||||
fakeradiotunercontrol.h \
|
|
||||||
fakeradiodatacontrol.h
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
fakeradioserviceplugin.cpp \
|
|
||||||
fakeradioservice.cpp \
|
|
||||||
fakeradiotunercontrol.cpp \
|
|
||||||
fakeradiodatacontrol.cpp
|
|
||||||
|
|
||||||
target.path += $$[QT_INSTALL_PLUGINS]/$${PLUGIN_TYPE}
|
|
||||||
INSTALLS += target
|
|
||||||
|
|
||||||
@@ -1,226 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** 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);
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** 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
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** 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 <QtCore/qvariant.h>
|
|
||||||
#include <QtCore/qdebug.h>
|
|
||||||
#include <QtCore/qfile.h>
|
|
||||||
#include <QtWidgets/qwidget.h>
|
|
||||||
|
|
||||||
#include "fakeradioservice.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):
|
|
||||||
QMediaService(parent)
|
|
||||||
{
|
|
||||||
m_tunerControl = new FakeRadioTunerControl(this);
|
|
||||||
m_dataControl = new FakeRadioDataControl(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
if (qstrcmp(name,QRadioTunerControl_iid) == 0)
|
|
||||||
return m_tunerControl;
|
|
||||||
if (qstrcmp(name,QRadioDataControl_iid) == 0)
|
|
||||||
return m_dataControl;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void FakeRadioService::releaseControl(QMediaControl *)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** 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 FAKERADIOSERVICE_H
|
|
||||||
#define FAKERADIOSERVICE_H
|
|
||||||
|
|
||||||
#include <QtCore/qobject.h>
|
|
||||||
#include <QMutex>
|
|
||||||
|
|
||||||
#include <qmediaservice.h>
|
|
||||||
QT_USE_NAMESPACE
|
|
||||||
|
|
||||||
class FakeRadioTunerControl;
|
|
||||||
class FakeRadioDataControl;
|
|
||||||
|
|
||||||
class FakeRadioService : public QMediaService
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
private:
|
|
||||||
FakeRadioService(QObject *parent = 0);
|
|
||||||
~FakeRadioService();
|
|
||||||
|
|
||||||
public:
|
|
||||||
static FakeRadioService* instance();
|
|
||||||
void release();
|
|
||||||
|
|
||||||
QMediaControl *requestControl(const char* name);
|
|
||||||
void releaseControl(QMediaControl *);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static FakeRadioService* m_instance;
|
|
||||||
static int m_referenceCount;
|
|
||||||
|
|
||||||
FakeRadioTunerControl *m_tunerControl;
|
|
||||||
FakeRadioDataControl *m_dataControl;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // FAKERADIOSERVICE_H
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** 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 <QtCore/qstring.h>
|
|
||||||
#include <QtCore/qfile.h>
|
|
||||||
#include <QtCore/qdebug.h>
|
|
||||||
#include <QtCore/qdir.h>
|
|
||||||
|
|
||||||
#include "fakeradioserviceplugin.h"
|
|
||||||
#include "fakeradioservice.h"
|
|
||||||
|
|
||||||
#include <qmediaserviceprovider.h>
|
|
||||||
|
|
||||||
|
|
||||||
QStringList FakeRadioServicePlugin::keys() const
|
|
||||||
{
|
|
||||||
return QStringList() <<
|
|
||||||
QLatin1String(Q_MEDIASERVICE_RADIO);
|
|
||||||
}
|
|
||||||
|
|
||||||
QMediaService* FakeRadioServicePlugin::create(QString const& key)
|
|
||||||
{
|
|
||||||
if (key == QLatin1String(Q_MEDIASERVICE_RADIO))
|
|
||||||
return FakeRadioService::instance();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeRadioServicePlugin::release(QMediaService *service)
|
|
||||||
{
|
|
||||||
FakeRadioService* fakeRadio = qobject_cast<FakeRadioService*>(service);
|
|
||||||
if (fakeRadio)
|
|
||||||
fakeRadio->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QByteArray> FakeRadioServicePlugin::devices(const QByteArray &service) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(service);
|
|
||||||
return QList<QByteArray>();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString FakeRadioServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device)
|
|
||||||
{
|
|
||||||
Q_UNUSED(service);
|
|
||||||
Q_UNUSED(device);
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN2(qtmedia_fakeradio, FakeRadioServicePlugin);
|
|
||||||
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** 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 FAKERADIOSERVICEPLUGIN_H
|
|
||||||
#define FAKERADIOSERVICEPLUGIN_H
|
|
||||||
|
|
||||||
#include <qmediaserviceproviderplugin.h>
|
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
|
||||||
|
|
||||||
class FakeRadioServicePlugin : public QMediaServiceProviderPlugin, public QMediaServiceSupportedDevicesInterface
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
|
|
||||||
public:
|
|
||||||
QStringList keys() const;
|
|
||||||
QMediaService* create(QString const& key);
|
|
||||||
void release(QMediaService *service);
|
|
||||||
|
|
||||||
QList<QByteArray> devices(const QByteArray &service) const;
|
|
||||||
QString deviceDescription(const QByteArray &service, const QByteArray &device);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // FAKERADIOSERVICEPLUGIN_H
|
|
||||||
@@ -1,380 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** 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 "fakeradiotunercontrol.h"
|
|
||||||
#include "fakeradioservice.h"
|
|
||||||
|
|
||||||
#include <QtCore/qdebug.h>
|
|
||||||
|
|
||||||
FakeRadioTunerControl::FakeRadioTunerControl(QObject *parent)
|
|
||||||
:QRadioTunerControl(parent)
|
|
||||||
{
|
|
||||||
m_state = QRadioTuner::StoppedState;
|
|
||||||
m_freqMin = 520000;
|
|
||||||
m_freqMax = 108000000;
|
|
||||||
m_currentBand = QRadioTuner::FM;
|
|
||||||
m_currentFreq = 0;
|
|
||||||
m_stereo = true;
|
|
||||||
m_stereoMode = QRadioTuner::Auto;
|
|
||||||
m_signalStrength = 0;
|
|
||||||
m_volume = 50;
|
|
||||||
m_muted = false;
|
|
||||||
|
|
||||||
m_searching = false;
|
|
||||||
m_forward = true;
|
|
||||||
m_searchMode = QRadioTuner::SearchFast;
|
|
||||||
m_piCounter = 0;
|
|
||||||
m_searchTimer = new QTimer(this);
|
|
||||||
m_searchTimer->setSingleShot(true);
|
|
||||||
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()));
|
|
||||||
|
|
||||||
qsrand(QTime::currentTime().msec());
|
|
||||||
}
|
|
||||||
|
|
||||||
FakeRadioTunerControl::~FakeRadioTunerControl()
|
|
||||||
{
|
|
||||||
m_searchTimer->stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FakeRadioTunerControl::isAvailable() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QtMultimedia::AvailabilityError FakeRadioTunerControl::availabilityError() const
|
|
||||||
{
|
|
||||||
return QtMultimedia::NoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRadioTuner::State FakeRadioTunerControl::state() const
|
|
||||||
{
|
|
||||||
return m_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRadioTuner::Band FakeRadioTunerControl::band() const
|
|
||||||
{
|
|
||||||
return m_currentBand;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FakeRadioTunerControl::isBandSupported(QRadioTuner::Band b) const
|
|
||||||
{
|
|
||||||
switch (b) {
|
|
||||||
case QRadioTuner::FM:
|
|
||||||
if (m_freqMin <= 87500000 && m_freqMax >= 108000000)
|
|
||||||
return true;
|
|
||||||
break;
|
|
||||||
case QRadioTuner::LW:
|
|
||||||
if (m_freqMin <= 148500 && m_freqMax >= 283500)
|
|
||||||
return true;
|
|
||||||
case QRadioTuner::AM:
|
|
||||||
if (m_freqMin <= 520000 && m_freqMax >= 1610000)
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
if (m_freqMin <= 1711000 && m_freqMax >= 30000000)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeRadioTunerControl::setBand(QRadioTuner::Band b)
|
|
||||||
{
|
|
||||||
if (isBandSupported(b)) {
|
|
||||||
m_currentBand = b;
|
|
||||||
emit bandChanged(m_currentBand);
|
|
||||||
|
|
||||||
int f = m_currentFreq;
|
|
||||||
QPair<int, int> fRange = frequencyRange(m_currentBand);
|
|
||||||
|
|
||||||
if (f < fRange.first)
|
|
||||||
f = fRange.first;
|
|
||||||
if (f > fRange.second)
|
|
||||||
f = fRange.second;
|
|
||||||
|
|
||||||
if (f != m_currentFreq) {
|
|
||||||
m_currentFreq = f;
|
|
||||||
emit frequencyChanged(m_currentFreq);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int FakeRadioTunerControl::frequency() const
|
|
||||||
{
|
|
||||||
return m_currentFreq;
|
|
||||||
}
|
|
||||||
|
|
||||||
int FakeRadioTunerControl::frequencyStep(QRadioTuner::Band b) const
|
|
||||||
{
|
|
||||||
int step = 0;
|
|
||||||
|
|
||||||
if (b == QRadioTuner::FM)
|
|
||||||
step = 100000; // 100kHz steps
|
|
||||||
else if (b == QRadioTuner::LW)
|
|
||||||
step = 1000; // 1kHz steps
|
|
||||||
else if (b == QRadioTuner::AM)
|
|
||||||
step = 1000; // 1kHz steps
|
|
||||||
else if (b == QRadioTuner::SW)
|
|
||||||
step = 500; // 500Hz steps
|
|
||||||
|
|
||||||
return step;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPair<int,int> FakeRadioTunerControl::frequencyRange(QRadioTuner::Band b) const
|
|
||||||
{
|
|
||||||
if (b == QRadioTuner::FM)
|
|
||||||
return qMakePair<int,int>(87500000,108000000);
|
|
||||||
else if (b == QRadioTuner::LW)
|
|
||||||
return qMakePair<int,int>(148500,283500);
|
|
||||||
else if (b == QRadioTuner::AM)
|
|
||||||
return qMakePair<int,int>(520000,1710000);
|
|
||||||
else if (b == QRadioTuner::SW)
|
|
||||||
return qMakePair<int,int>(1711111,30000000);
|
|
||||||
|
|
||||||
return qMakePair<int,int>(0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeRadioTunerControl::setFrequency(int frequency)
|
|
||||||
{
|
|
||||||
qint64 f = frequency;
|
|
||||||
QPair<int, int> fRange = frequencyRange(m_currentBand);
|
|
||||||
|
|
||||||
if (frequency < fRange.first)
|
|
||||||
f = fRange.first;
|
|
||||||
if (frequency > fRange.second)
|
|
||||||
f = fRange.second;
|
|
||||||
|
|
||||||
m_currentFreq = f;
|
|
||||||
emit frequencyChanged(m_currentFreq);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FakeRadioTunerControl::isStereo() const
|
|
||||||
{
|
|
||||||
return m_stereo;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRadioTuner::StereoMode FakeRadioTunerControl::stereoMode() const
|
|
||||||
{
|
|
||||||
return m_stereoMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeRadioTunerControl::setStereoMode(QRadioTuner::StereoMode mode)
|
|
||||||
{
|
|
||||||
bool stereo = true;
|
|
||||||
|
|
||||||
if (mode == QRadioTuner::ForceMono)
|
|
||||||
stereo = false;
|
|
||||||
else
|
|
||||||
stereo = true;
|
|
||||||
|
|
||||||
m_stereo = stereo;
|
|
||||||
m_stereoMode = mode;
|
|
||||||
|
|
||||||
emit stereoStatusChanged(stereo);
|
|
||||||
}
|
|
||||||
|
|
||||||
int FakeRadioTunerControl::signalStrength() const
|
|
||||||
{
|
|
||||||
return m_signalStrength;
|
|
||||||
}
|
|
||||||
|
|
||||||
int FakeRadioTunerControl::volume() const
|
|
||||||
{
|
|
||||||
return m_volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeRadioTunerControl::setVolume(int volume)
|
|
||||||
{
|
|
||||||
int v = volume;
|
|
||||||
|
|
||||||
if (v < 0)
|
|
||||||
v = 0;
|
|
||||||
if (100 > v)
|
|
||||||
v = 100;
|
|
||||||
|
|
||||||
m_volume = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FakeRadioTunerControl::isMuted() const
|
|
||||||
{
|
|
||||||
return m_muted;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeRadioTunerControl::setMuted(bool muted)
|
|
||||||
{
|
|
||||||
if (muted != m_muted) {
|
|
||||||
m_muted = muted;
|
|
||||||
emit mutedChanged(m_muted);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FakeRadioTunerControl::isSearching() const
|
|
||||||
{
|
|
||||||
return m_searching;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeRadioTunerControl::cancelSearch()
|
|
||||||
{
|
|
||||||
m_searching = false;
|
|
||||||
m_searchTimer->stop();
|
|
||||||
emit searchingChanged(m_searching);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeRadioTunerControl::searchForward()
|
|
||||||
{
|
|
||||||
m_forward = true;
|
|
||||||
performSearch();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeRadioTunerControl::searchBackward()
|
|
||||||
{
|
|
||||||
m_forward = false;
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
if (isAvailable() && m_state != QRadioTuner::ActiveState) {
|
|
||||||
m_state = QRadioTuner::ActiveState;
|
|
||||||
emit stateChanged(m_state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeRadioTunerControl::stop()
|
|
||||||
{
|
|
||||||
if (m_state != QRadioTuner::StoppedState) {
|
|
||||||
m_state = QRadioTuner::StoppedState;
|
|
||||||
emit stateChanged(m_state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QRadioTuner::Error FakeRadioTunerControl::error() const
|
|
||||||
{
|
|
||||||
return QRadioTuner::NoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString FakeRadioTunerControl::errorString() const
|
|
||||||
{
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeRadioTunerControl::delayedInit()
|
|
||||||
{
|
|
||||||
m_signalStrength = 50;
|
|
||||||
emit signalStrengthChanged(m_signalStrength);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeRadioTunerControl::performSearch()
|
|
||||||
{
|
|
||||||
m_searching = true;
|
|
||||||
m_searchTimer->start(qrand() % 1000);
|
|
||||||
emit searchingChanged(m_searching);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeRadioTunerControl::searchEnded()
|
|
||||||
{
|
|
||||||
int minFreq, maxFreq, newFreq;
|
|
||||||
QPair<int, int> fRange = frequencyRange(m_currentBand);
|
|
||||||
|
|
||||||
if (m_forward) {
|
|
||||||
minFreq = m_currentFreq;
|
|
||||||
maxFreq = fRange.second;
|
|
||||||
} else {
|
|
||||||
minFreq = fRange.first;
|
|
||||||
maxFreq = m_currentFreq;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((qreal)(maxFreq - minFreq) / (qreal)(fRange.second - fRange.first) < 0.02) {
|
|
||||||
// don't change frequency if we have less than 2% of the range to scan
|
|
||||||
m_searching = false;
|
|
||||||
emit searchingChanged(m_searching);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
newFreq = (qrand() % (maxFreq - minFreq)) + minFreq;
|
|
||||||
newFreq -= newFreq % frequencyStep(m_currentBand);
|
|
||||||
|
|
||||||
m_searching = false;
|
|
||||||
m_currentFreq = newFreq;
|
|
||||||
emit searchingChanged(m_searching);
|
|
||||||
emit frequencyChanged(m_currentFreq);
|
|
||||||
}
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** 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 FAKERADIOTUNERCONTROL_H
|
|
||||||
#define FAKERADIOTUNERCONTROL_H
|
|
||||||
|
|
||||||
#include <QtCore/qobject.h>
|
|
||||||
#include <QtCore/qtimer.h>
|
|
||||||
#include <QtCore/qdatetime.h>
|
|
||||||
|
|
||||||
#include <qradiotunercontrol.h>
|
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
|
||||||
|
|
||||||
class FakeRadioService;
|
|
||||||
|
|
||||||
class FakeRadioTunerControl : public QRadioTunerControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
FakeRadioTunerControl(QObject *parent = 0);
|
|
||||||
~FakeRadioTunerControl();
|
|
||||||
|
|
||||||
bool isAvailable() const;
|
|
||||||
QtMultimedia::AvailabilityError availabilityError() const;
|
|
||||||
|
|
||||||
QRadioTuner::State state() const;
|
|
||||||
|
|
||||||
QRadioTuner::Band band() const;
|
|
||||||
void setBand(QRadioTuner::Band b);
|
|
||||||
bool isBandSupported(QRadioTuner::Band b) const;
|
|
||||||
|
|
||||||
int frequency() const;
|
|
||||||
int frequencyStep(QRadioTuner::Band b) const;
|
|
||||||
QPair<int,int> frequencyRange(QRadioTuner::Band b) const;
|
|
||||||
void setFrequency(int frequency);
|
|
||||||
|
|
||||||
bool isStereo() const;
|
|
||||||
QRadioTuner::StereoMode stereoMode() const;
|
|
||||||
void setStereoMode(QRadioTuner::StereoMode mode);
|
|
||||||
|
|
||||||
int signalStrength() const;
|
|
||||||
|
|
||||||
int volume() const;
|
|
||||||
void setVolume(int volume);
|
|
||||||
|
|
||||||
bool isMuted() const;
|
|
||||||
void setMuted(bool muted);
|
|
||||||
|
|
||||||
bool isSearching() const;
|
|
||||||
void cancelSearch();
|
|
||||||
|
|
||||||
void searchForward();
|
|
||||||
void searchBackward();
|
|
||||||
void searchAllStations(QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast);
|
|
||||||
|
|
||||||
void start();
|
|
||||||
void stop();
|
|
||||||
|
|
||||||
QRadioTuner::Error error() const;
|
|
||||||
QString errorString() const;
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void delayedInit();
|
|
||||||
void performSearch();
|
|
||||||
void searchEnded();
|
|
||||||
void newStationFound();
|
|
||||||
|
|
||||||
private: //data
|
|
||||||
QRadioTuner::State m_state;
|
|
||||||
QRadioTuner::Band m_currentBand;
|
|
||||||
qint64 m_freqMin;
|
|
||||||
qint64 m_freqMax;
|
|
||||||
qint64 m_currentFreq;
|
|
||||||
qint64 m_seekingStartFreq;
|
|
||||||
bool m_stereo;
|
|
||||||
QRadioTuner::StereoMode m_stereoMode;
|
|
||||||
int m_signalStrength;
|
|
||||||
int m_volume;
|
|
||||||
bool m_muted;
|
|
||||||
|
|
||||||
// searching
|
|
||||||
bool m_searching;
|
|
||||||
bool m_forward;
|
|
||||||
QRadioTuner::SearchMode m_searchMode;
|
|
||||||
int m_piCounter;
|
|
||||||
QTimer *m_searchTimer;
|
|
||||||
QTimer *m_allStationSeekTimer;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // FAKERADIOTUNERCONTROL_H
|
|
||||||
@@ -39,6 +39,3 @@ mac:!simulator {
|
|||||||
SUBDIRS += qt7
|
SUBDIRS += qt7
|
||||||
}
|
}
|
||||||
|
|
||||||
# fake radio to test the radio APIs
|
|
||||||
SUBDIRS += fakeradio
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user