|
1 /* |
|
2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This class implements an interface to FM tuner control. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef RADIOSERVERFMTUNER_H |
|
21 #define RADIOSERVERFMTUNER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <FMRadioTunerControl.h> |
|
26 #include <RadioRdsControl.h> |
|
27 #include "RadioServerData.h" |
|
28 |
|
29 // DATA TYPES |
|
30 enum TTunerEvent |
|
31 { |
|
32 ETunerEventTunerOn = 1, |
|
33 ETunerEventTunerOff, |
|
34 ETunerEventSetFrequencyRange, |
|
35 ETunerEventSetFrequency, |
|
36 ETunerEventStationSeek, // 5 |
|
37 ETunerEventAudioMode, |
|
38 ETunerEventSetAudioMode, |
|
39 ETunerEventMaxSignalStrength, |
|
40 ETunerEventSignalStrength, |
|
41 ETunerEventSquelch, // 10 |
|
42 ETunerEventSetSquelch, |
|
43 ETunerEventAntennaStatusChange, |
|
44 ETunerEventTunerControlChange, |
|
45 ETunerEventStationSeekByPTY, |
|
46 ETunerEventStationSeekByTA, // 15 |
|
47 ETunerEventStationSeekByTP, |
|
48 }; |
|
49 |
|
50 struct TRadioFmTunerData |
|
51 { |
|
52 TSglQueLink iLink; |
|
53 TTunerEvent iEvent; |
|
54 TFMRadioTunerError iError; |
|
55 }; |
|
56 |
|
57 // CLASS DECLARATION |
|
58 |
|
59 /** |
|
60 * This class provides the interface class to be implemented by object receiving events |
|
61 * from CRadioServerFMTuner. |
|
62 * |
|
63 * @lib RadioServer.exe |
|
64 * @since 3.2 |
|
65 */ |
|
66 class MRadioServerFMTunerObserver |
|
67 { |
|
68 public: |
|
69 |
|
70 /** |
|
71 * Completion message for TunerOn request. |
|
72 * |
|
73 * @since S60 3.0 |
|
74 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
75 */ |
|
76 virtual void TunerOnComplete( TRadioServerError aError ) = 0; |
|
77 |
|
78 /** |
|
79 * Completion message for TunerOff request. |
|
80 * |
|
81 * @since S60 3.0 |
|
82 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
83 */ |
|
84 virtual void TunerOffComplete( TRadioServerError aError ) = 0; |
|
85 |
|
86 /** |
|
87 * Completion message for SetFrequencyRange request. |
|
88 * |
|
89 * @since S60 3.0 |
|
90 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
91 */ |
|
92 virtual void SetFrequencyRangeComplete( TRadioServerError aError ) = 0; |
|
93 |
|
94 /** |
|
95 * Completion message for SetFrequency request. |
|
96 * |
|
97 * @since S60 3.0 |
|
98 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
99 */ |
|
100 virtual void SetFrequencyComplete( TRadioServerError aError ) = 0; |
|
101 |
|
102 /** |
|
103 * Completion message for StationSeek request. |
|
104 * |
|
105 * @since S60 3.0 |
|
106 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
107 * @param aFrequency Valid only if aError is KErrNone. Contains the new frequency in Hz. |
|
108 */ |
|
109 virtual void StationSeekComplete( TRadioServerError aError, TInt aFrequency ) = 0; |
|
110 |
|
111 /** |
|
112 * Completion message for AudioMode request. |
|
113 * |
|
114 * @since S60 3.2 |
|
115 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
116 * @param aStereo ETrue if signal is stereo. |
|
117 */ |
|
118 virtual void AudioModeComplete( TRadioServerError aError, TBool aStereo ) = 0; |
|
119 |
|
120 /** |
|
121 * Completion message for SetAudioMode request. |
|
122 * |
|
123 * @since S60 3.2 |
|
124 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
125 */ |
|
126 virtual void SetAudioModeComplete( TRadioServerError aError ) = 0; |
|
127 |
|
128 /** |
|
129 * Completion message for GetSignalStrength request. |
|
130 * |
|
131 * @since S60 3.0 |
|
132 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
133 * @param aStrength Valid only if aError is KErrNone. Contains the signal strength |
|
134 * of the currently tuned frequency. |
|
135 */ |
|
136 virtual void SignalStrengthComplete( TRadioServerError aError, TInt aStrength ) = 0; |
|
137 |
|
138 /** |
|
139 * Completion message for GetMaxSignalStrength request. |
|
140 * |
|
141 * @since S60 3.0 |
|
142 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
143 * @param aMaxStrength Valid only if aError is KErrNone. Contains the maximum |
|
144 * signal strength supported. |
|
145 */ |
|
146 virtual void MaxSignalStrengthComplete( TRadioServerError aError, TInt aMaxStrength ) = 0; |
|
147 |
|
148 /** |
|
149 * Completion message for Squelch request. |
|
150 * |
|
151 * @since S60 3.0 |
|
152 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
153 * @param aEnabled ETrue if squelching is enabled, EFalse if disabled. |
|
154 */ |
|
155 virtual void SquelchComplete( TRadioServerError aError, TBool aEnabled ) = 0; |
|
156 |
|
157 /** |
|
158 * Completion message for SetSquelch request. |
|
159 * |
|
160 * @since S60 3.0 |
|
161 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
162 */ |
|
163 virtual void SetSquelchComplete( TRadioServerError aError ) = 0; |
|
164 |
|
165 /** |
|
166 * Notification mechanism provided to inform client that BufferToBeFilled request has completed. |
|
167 * |
|
168 * @since S60 3.0 |
|
169 * @param aBuffer Buffer with data to be played. |
|
170 */ |
|
171 virtual void BufferFilled( TDes8& aBuffer ) = 0; |
|
172 |
|
173 /** |
|
174 * Notification mechanism provided to inform that the antenna status has changed. |
|
175 * |
|
176 * @since S60 3.0 |
|
177 * @param aAttached ETrue if antenna is attached. |
|
178 */ |
|
179 virtual void RadioEventAntennaStatusChange( TBool aAttached ) = 0; |
|
180 |
|
181 /** |
|
182 * Notification mechanism indicating tuner control change. When tuner receiver is |
|
183 * forced to be turned off due to hardware conflict such as a FM transmitter, this |
|
184 * event is sent with an error code. |
|
185 * NOTE: Once the tuner control is restored, this event is sent again with KErrNone |
|
186 * and the client can re-issue TunerOn. |
|
187 * |
|
188 * @since S60 3.2 |
|
189 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
190 */ |
|
191 virtual void RadioEventTunerControlChange( TRadioServerError aError ) = 0; |
|
192 |
|
193 /** |
|
194 * Completion message for StationSeekByPTY request. |
|
195 * |
|
196 * @since S60 3.2 |
|
197 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
198 * @param aFrequency The frequency(Hz) of the radio station that was found. |
|
199 */ |
|
200 virtual void StationSeekByPTYComplete( TRadioServerError aError, TInt aFrequency ) = 0; |
|
201 |
|
202 /** |
|
203 * Completion message for StationSeekByTA request. |
|
204 * |
|
205 * @since S60 3.2 |
|
206 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
207 * @param aFrequency The frequency(Hz) of the radio station that was found. |
|
208 */ |
|
209 virtual void StationSeekByTAComplete( TRadioServerError aError, TInt aFrequency ) = 0; |
|
210 |
|
211 /** |
|
212 * Completion message for StationSeekByTP request. |
|
213 * |
|
214 * @since S60 3.2 |
|
215 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
216 * @param aFrequency The frequency(Hz) of the radio station that was found. |
|
217 */ |
|
218 virtual void StationSeekByTPComplete( TRadioServerError aError, TInt aFrequency ) = 0; |
|
219 |
|
220 /** |
|
221 * Notification mechanism indicating New Programme Identification(PI) is available. |
|
222 * |
|
223 * @since S60 3.2 |
|
224 * @param aPi Programme identification |
|
225 */ |
|
226 virtual void RdsDataPI( TInt aPi ) = 0; |
|
227 |
|
228 /** |
|
229 * Notification mechanism indicating New Programme Type (PTY) is available. |
|
230 * |
|
231 * @since S60 3.2 |
|
232 * @param aPty Programme type |
|
233 */ |
|
234 virtual void RdsDataPTY( TRdsProgrammeType aPty ) = 0; |
|
235 |
|
236 /** |
|
237 * Notification mechanism indicating New Programme Service name (PS) is available. |
|
238 * |
|
239 * @since S60 3.2 |
|
240 * @param aPs Programme service |
|
241 */ |
|
242 virtual void RdsDataPS( TRdsPSName& aPs ) = 0; |
|
243 |
|
244 /** |
|
245 * Notification mechanism indicating New Radio Text (RT) is available. |
|
246 * |
|
247 * @since S60 3.2 |
|
248 * @param aRt Radio text |
|
249 * @param aRTplusTags RTplus tags |
|
250 */ |
|
251 virtual void RdsDataRT( TRdsRadioText& aRt, RArray<TRdsRTplusTag>& aRTplusTags ) = 0; |
|
252 |
|
253 /** |
|
254 * Notification mechanism indicating Clock Time (CT) is available. |
|
255 * |
|
256 * @since S60 3.2 |
|
257 * @param aCt Clock time |
|
258 */ |
|
259 virtual void RdsDataCT( TDateTime& aCt ) = 0; |
|
260 |
|
261 /** |
|
262 * Notification mechanism indicating Traffice Announcement (TA) status changes. |
|
263 * |
|
264 * @since S60 3.2 |
|
265 * @param aTaOn ETrue indicates that Traffic Announcement is on. |
|
266 */ |
|
267 virtual void RdsDataTA( TBool aTaOn ) = 0; |
|
268 |
|
269 /** |
|
270 * Notification mechanism indicating that tuner started to search for an Alternate Frequency (AF). |
|
271 * |
|
272 * @since S60 3.2 |
|
273 */ |
|
274 virtual void RdsSearchBeginAF() = 0; |
|
275 |
|
276 /** |
|
277 * Notification mechanism indicating end of search for an Alternate Frequency. |
|
278 * |
|
279 * @since S60 3.2 |
|
280 * @param aError KErrNone if successful, otherwise one of the system/RadioServer errors. |
|
281 * @param aFrequency The frequency (Hz) of the radio station that was found. |
|
282 */ |
|
283 virtual void RdsSearchEndAF( TRadioServerError aError, TInt aFrequency ) = 0; |
|
284 |
|
285 /** |
|
286 * Notification mechanism indicating RDS signal status change (i.e. signal is lost/restored). |
|
287 * |
|
288 * @since S60 3.2 |
|
289 * @param aSignal ETrue indicates that RDS signal is available in the tuned frequency. |
|
290 */ |
|
291 virtual void RdsEventSignalChange( TBool aSignal ) = 0; |
|
292 }; |
|
293 |
|
294 /** |
|
295 * This class is the FM tuner adaptation observer. This is pretty much a pass through. |
|
296 * The only purpose of this class is to guarantee asynchronous replies. In addition, it |
|
297 * also provides type conversion such as adaptation error code to RadioServer error code, etc. |
|
298 * |
|
299 * @lib RadioServer.exe |
|
300 * @since S60 3.0 |
|
301 */ |
|
302 class CRadioServerFMTuner : public CActive, |
|
303 public MFMRadioTunerControlObserver |
|
304 #ifdef RD_FM_RADIO_ENHANCEMENTS |
|
305 ,public MRdsControlObserver |
|
306 #endif |
|
307 { |
|
308 public: // Constructors and destructor |
|
309 |
|
310 /** |
|
311 * Two-phased constructor. |
|
312 */ |
|
313 static CRadioServerFMTuner* NewL( MRadioServerFMTunerObserver& aObserver ); |
|
314 |
|
315 /** |
|
316 * Destructor. |
|
317 */ |
|
318 virtual ~CRadioServerFMTuner(); |
|
319 |
|
320 public: // Functions from base classes |
|
321 |
|
322 /** |
|
323 * From MFMRadioTunerControlObserver |
|
324 * See FMRadioTunerControl.h for detailed description. |
|
325 * @since S60 3.0 |
|
326 */ |
|
327 void TunerOnComplete( TFMRadioTunerError aError ); |
|
328 void TunerOffComplete( TFMRadioTunerError aError ); |
|
329 void SetFrequencyRangeComplete( TFMRadioTunerError aError ); |
|
330 void SetFrequencyComplete( TFMRadioTunerError aError ); |
|
331 void StationSeekComplete( TFMRadioTunerError aError, TInt aFrequency ); |
|
332 void AudioModeComplete( TFMRadioTunerError aError, TFMRadioAudioMode aMode ); |
|
333 void SetAudioModeComplete( TFMRadioTunerError aError ); |
|
334 void MaxSignalStrengthComplete( TFMRadioTunerError aError, TInt aStrength ); |
|
335 void SignalStrengthComplete( TFMRadioTunerError aError, TInt aStrength ); |
|
336 void SquelchComplete( TFMRadioTunerError aError, TBool aEnabled ); |
|
337 void SetSquelchComplete( TFMRadioTunerError aError ); |
|
338 void BufferFilled( TDes8& aBuffer ); |
|
339 void RadioEventAntennaStatusChange( TBool aAttached ); |
|
340 |
|
341 #ifdef RD_FM_RADIO_ENHANCEMENTS |
|
342 void RadioEventTunerControlChange( TInt aError ); |
|
343 |
|
344 /** |
|
345 * From MRdsControlObserver |
|
346 * See RadioRdsControl.h for detailed description. |
|
347 * @since S60 3.2 |
|
348 */ |
|
349 void StationSeekByPTYComplete( TInt aError, TInt aFrequency ); |
|
350 void StationSeekByTAComplete( TInt aError, TInt aFrequency ); |
|
351 void StationSeekByTPComplete( TInt aError, TInt aFrequency ); |
|
352 void GetFreqByPTYComplete( TInt aError, RArray<TInt>& aFreqList ); |
|
353 void GetFreqByTAComplete( TInt aError, RArray<TInt>& aFreqList ); |
|
354 void GetPSByPTYComplete( TInt aError, RArray<TRdsPSName>& aPsList ); |
|
355 void GetPSByTAComplete( TInt aError, RArray<TRdsPSName>& aPsList ); |
|
356 void RdsDataPI( TInt aPi ); |
|
357 void RdsDataPTY( TRdsProgrammeType aPty ); |
|
358 void RdsDataPS( TRdsPSName& aPs ); |
|
359 void RdsDataRT( TRdsRadioText& aRt, RArray<TRdsRTplusTag>& aRTplusTags ); |
|
360 void RdsDataCT( TDateTime& aCt ); |
|
361 void RdsDataTA( TBool aTaOn ); |
|
362 void RdsSearchBeginAF(); |
|
363 void RdsSearchEndAF( TInt aError, TInt aFrequency ); |
|
364 void RdsStationChangeTA( TInt aFrequency ); |
|
365 void RdsEventSignalChange( TBool aSignal ); |
|
366 #endif |
|
367 |
|
368 private: // Functions from base classes |
|
369 |
|
370 /** |
|
371 * From CActive |
|
372 * Cancel outstanding request. |
|
373 */ |
|
374 void DoCancel(); |
|
375 |
|
376 /** |
|
377 * From CActive |
|
378 * Implementation of CActive::RunL. Called when server request has completed. |
|
379 **/ |
|
380 void RunL(); |
|
381 |
|
382 private: |
|
383 |
|
384 /** |
|
385 * C++ default constructor. |
|
386 */ |
|
387 CRadioServerFMTuner( MRadioServerFMTunerObserver& aObserver ); |
|
388 |
|
389 /** |
|
390 * By default Symbian 2nd phase constructor is private. |
|
391 */ |
|
392 void ConstructL(); |
|
393 |
|
394 /** |
|
395 * Used internally to ensure asynchronous behaviour of a request completion message. |
|
396 * @since S60 3.2 |
|
397 * @param aEvent Tuner event |
|
398 * @param aError Tuner error |
|
399 */ |
|
400 void CompleteNotification( TTunerEvent aEvent, TFMRadioTunerError aError=KErrNone ); |
|
401 |
|
402 /** |
|
403 * Check if another request exists in the queue. If so, process the request. |
|
404 * @since S60 3.2 |
|
405 */ |
|
406 void ProcessNextItemInQueue(); |
|
407 |
|
408 /** |
|
409 * Map tuner error to a standard system error code. |
|
410 */ |
|
411 TInt MapTunerError( TFMRadioTunerError aError ); |
|
412 |
|
413 private: // Data |
|
414 |
|
415 // FM Tuner Observer |
|
416 MRadioServerFMTunerObserver& iObserver; |
|
417 |
|
418 // Queue for asynchronous requests |
|
419 TSglQue<TRadioFmTunerData> iFmTunerQue; |
|
420 TRadioFmTunerData* iFmTunerData; |
|
421 |
|
422 // Temporary variables |
|
423 TInt iFrequency; |
|
424 TFMRadioAudioMode iMode; |
|
425 TInt iStrength; |
|
426 TBool iAttached; |
|
427 TBool iEnabled; |
|
428 }; |
|
429 |
|
430 #endif // RADIOSERVERFMTUNER_H |
|
431 |
|
432 // End of File |