summaryrefslogtreecommitdiffstats
path: root/src/plugins/symbian/mmf/radio/s60radiotunercontrol_since32.h
blob: 7081e5718ba34c61910bd96da854aad964f21ec0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Mobility Components.
**
** $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 S60RADIOTUNERCONTROL_H
#define S60RADIOTUNERCONTROL_H

#include <QtCore/qobject.h>
#include <QtCore/qtimer.h>
#include <qradiotunercontrol.h>
#include <qradiotuner.h>

#include <RadioUtility.h>
#include <RadioFmTunerUtility.h>
#include <RadioPlayerUtility.h>

class S60RadioTunerService;
class CFMRadioEngineCallObserver;

QT_USE_NAMESPACE

class S60RadioTunerControl 
    : public QRadioTunerControl
    , public MRadioPlayerObserver
    , public MRadioFmTunerObserver
{
    Q_OBJECT
public:
    S60RadioTunerControl(QObject *parent = 0);
    ~S60RadioTunerControl();
    
    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 searchForward();
    void searchBackward();
    void cancelSearch();

    bool isValid() const;

    bool isAvailable() const;
    QtMultimediaKit::AvailabilityError availabilityError() const;
    
    void start();
    void stop();

    QRadioTuner::Error error() const;
    QString errorString() const;
    
    /**
	 * From MRadioPlayerObserver.
	 * Called when Radio state changed.
	 *
	 * @since S60 3.2
	 * @param aState Radio player state
	 * @param aError A standard system error code, only used when aState is ERadioPlayerIdle
	 */
	void MrpoStateChange(TPlayerState aState, TInt aError);

	/**
	 * From MRadioPlayerObserver.
	 * Called when volume changes. This may be caused by other applications.
	 *
	 * @since S60 3.2
	 * @param aVolume Current volume.
	 */
	void MrpoVolumeChange(TInt aVolume);

	/**
	 * From MRadioPlayerObserver.
	 * Called when mute setting changes. This may be caused by other applications.
	 *
	 * @since S60 3.2
	 * @param aMute ETrue indicates audio is muted.
	 */
	void MrpoMuteChange(TBool aMute);

	/**
	 * From MRadioPlayerObserver.
	 * Called when mute setting changes. This may be caused by other applications.
	 *
	 * Called when balance setting changes. This may be caused by other applications.
	 *
	 * @since S60 3.2
	 *        Left speaker volume percentage. This can be any value from zero to 100.
	 *        Zero value means left speaker is muted.
	 * @param aRightPercentage
	 *        Right speaker volume percentage. This can be any value from zero to 100.
	 *        Zero value means right speaker is muted.
	 */
	void MrpoBalanceChange(TInt aLeftPercentage, TInt aRightPercentage);

	
	/**
	 * From MRadioFmTunerObserver.
	 * Called when Request for tuner control completes.
	 *
	 * @since S60 3.2
	 * @param aError A standard system error code or FM tuner error (TFmRadioTunerError).
	 */
	void MrftoRequestTunerControlComplete(TInt aError);

	/**
	 * From MRadioFmTunerObserver.
	 * Set frequency range complete event. This event is asynchronous and is received after
	 * a call to CRadioFmTunerUtility::SetFrequencyRange.
	 *
	 * @since S60 3.2
	 * @param aError A standard system error code or FM tuner error (TFmRadioTunerError).
	 */
	void MrftoSetFrequencyRangeComplete(TInt aError);

	/**
	 * From MRadioFmTunerObserver.
	 * Set frequency complete event. This event is asynchronous and is received after a call to
	 * CRadioFmTunerUtility::SetFrequency.
	 *
	 * @since S60 3.2
	 * @param aError A standard system error code or FM tuner error (TFmRadioTunerError).
	 */
	void MrftoSetFrequencyComplete(TInt aError);

	/**
	 * From MRadioFmTunerObserver.
	 * Station seek complete event. This event is asynchronous and is received after a call to
	 * CRadioFmTunerUtility::StationSeek.
	 *
	 * @since S60 3.2
	 * @param aError A standard system error code or FM tuner error (TFmRadioTunerError).
	 * @param aFrequency The frequency(Hz) of the radio station that was found.
	 */
	void MrftoStationSeekComplete(TInt aError, TInt aFrequency);

	/**
	 * From MRadioFmTunerObserver.
	 * Called when FM Transmitter status changes (if one is present in the device). Tuner receiver
	 * is forced to be turned off due to hardware conflicts when FM transmitter is activated.
	 *
	 * @since S60 3.2
	 * @param aActive ETrue if FM transmitter is active; EFalse otherwise.
	 */
	void MrftoFmTransmitterStatusChange(TBool aActive);

	/**
	 * From MRadioFmTunerObserver.
	 * Called when antenna status changes.
	 *
	 * @since S60 3.2
	 * @param aAttached ETrue if antenna is attached; EFalse otherwise.
	 */
	void MrftoAntennaStatusChange(TBool aAttached);

	/**
	 * From MRadioFmTunerObserver.
	 * Called when offline mode status changes.
	 * @since S60 3.2
	 *
	 ** @param aAttached ETrue if offline mode is enabled; EFalse otherwise.
	 */
	void MrftoOfflineModeStatusChange(TBool aOfflineMode);

	/**
	 * From MRadioFmTunerObserver.
	 * Called when the frequency range changes. This may be caused by other applications.
	 *
	 * @since S60 3.2
	 * @param aNewRange New frequency range.
	 */
	void MrftoFrequencyRangeChange(TFmRadioFrequencyRange aBand /*, TInt aMinFreq, TInt aMaxFreq*/);

	/**
	 * From MRadioFmTunerObserver.
	 * Called when the tuned frequency changes. This may be caused by other
	 * applications or RDS if AF/TA is enabled.
	 *
	 * @since S60 3.2
	 * @param aNewFrequency The new tuned frequency(Hz).
	 */
	void MrftoFrequencyChange(TInt aNewFrequency);

	/**
	 * From MRadioFmTunerObserver.
	 * Called when the forced mono status change. This may be caused by other applications.
	 *
	 * @since S60 3.2
	 * @param aForcedMono ETrue if forced mono mode is enabled; EFalse otherwise.
	 */
	void MrftoForcedMonoChange(TBool aForcedMono);

	/**
	 * From MRadioFmTunerObserver.
	 * Called when the squelch (muting the frequencies without broadcast) status change.
	 * This may be caused by other applications.
	 *
	 * @since S60 3.2
	 * @param aSquelch ETrue if squelch is enabled; EFalse otherwise.
	 */
	void MrftoSquelchChange(TBool aSquelch);

private:
    bool initRadio();

    mutable int m_error;

    CRadioUtility* m_radioUtility;   
    CRadioFmTunerUtility* m_fmTunerUtility;
    CRadioPlayerUtility* m_playerUtility;
    TInt m_maxVolume;
    TReal m_volMultiplier;

	bool m_tunerControl;
    bool m_audioInitializationComplete;
    bool m_muted;
    bool m_isStereo;
    bool m_available;
    int  m_vol;
    bool m_volChangeRequired;
    mutable int m_signal;
    int m_previousSignal;
    bool m_scanning;
    QRadioTuner::Band m_currentBand;
    qint64 m_currentFreq;
    
    QRadioTuner::Error m_radioError;
    QRadioTuner::StereoMode m_stereoMode;
    QString m_errorString;
    QRadioTuner::State m_apiTunerState;
    QTimer *m_signalStrengthTimer;
    
Q_SIGNALS:
     void error(QRadioTuner::Error) const;
     
protected slots:
    void changeSignalStrength();
};

#endif