khronosfws/openmax_al/src/mmf_adaptation/cmmfradiobackendengine.h
changeset 31 8dfd592727cb
child 32 94fc26b6e006
equal deleted inserted replaced
22:128eb6a32b84 31:8dfd592727cb
       
     1 /*
       
     2 * Copyright (c) 2009 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CMMFRADIOBACKENDENGINE_H
       
    19 #define CMMFRADIOBACKENDENGINE_H
       
    20 
       
    21 #ifdef __cplusplus
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <RadioUtility.h>
       
    25 #include <RadioFmTunerUtility.h>
       
    26 #include <RadioPlayerUtility.h>
       
    27 #include <RadioPresetUtility.h>
       
    28 #include <RadioFmPresetUtility.h>
       
    29 #include <FMRadioTunerControl.h>
       
    30 #include "xaadaptationmmf.h"
       
    31 
       
    32 NONSHARABLE_CLASS(CMMFRadioBackendEngine) : public CBase,
       
    33                      public MRadioPlayerObserver,
       
    34                      public MRadioFmTunerObserver,
       
    35                      public MRadioPresetObserver          
       
    36     {
       
    37 public:
       
    38 
       
    39     static CMMFRadioBackendEngine* Instance();
       
    40     void DeleteInstance();
       
    41     ~CMMFRadioBackendEngine();
       
    42     
       
    43 		void SetFrequency(TInt aFreq);		   
       
    44 		TInt GetFrequency(TInt& aFreq);
       
    45 		TInt GetSignalStrength(TInt& aFreq);		
       
    46 		void StationSeek(XAboolean aUpwards);
       
    47 		void CancelSetFrequency();	
       
    48 		void CancelStationSeek();	
       
    49 		void SetFreqRange(TFmRadioFrequencyRange aRange);	
       
    50 		TInt GetFreqRange(TFmRadioFrequencyRange& aRange);
       
    51 		TInt GetFreqRangeProperties(TFmRadioFrequencyRange& aRange, TInt& aMinFreq, TInt& aMaxFreq);			
       
    52 		TInt GetMaxVolume(TInt& aMaxVol);									
       
    53 		TInt SetVolume(TInt aVol);		
       
    54 		TInt GetVolume(TInt& aVol);
       
    55 		TInt SetMute(XAboolean aMute);	
       
    56 		TInt GetForcedMonoReception(XAuint32& aForcedMono);
       
    57 		TInt ForceMonoReception(XAuint32 aForcedMono);
       
    58 		void PlayRadio();		
       
    59 		void StopRadio();		
       
    60     XAresult SetRadioAdaptContext(void * adaptcontext);  	
       
    61 		XAresult SetPlayerAdaptContext(void * adaptcontext);    					
       
    62 						
       
    63     /**
       
    64      * From MRadioPlayerObserver.
       
    65      * Called when Radio state changed.
       
    66      *
       
    67      * @since S60 3.2
       
    68      * @param aState Radio player state
       
    69      * @param aError A standard system error code, only used when aState is ERadioPlayerIdle
       
    70      */
       
    71     void MrpoStateChange( TPlayerState aState, TInt aError );
       
    72 
       
    73     /**
       
    74      * From MRadioPlayerObserver.
       
    75      * Called when volume changes. This may be caused by other applications.
       
    76      *
       
    77      * @since S60 3.2
       
    78      * @param aVolume Current volume.
       
    79      */
       
    80     void MrpoVolumeChange( TInt aVolume );
       
    81 
       
    82     /**
       
    83      * From MRadioPlayerObserver.
       
    84      * Called when mute setting changes. This may be caused by other applications.
       
    85      *
       
    86      * @since S60 3.2
       
    87      * @param aMute ETrue indicates audio is muted.
       
    88      */
       
    89     void MrpoMuteChange( TBool aMute );
       
    90 
       
    91     /**
       
    92      * From MRadioPlayerObserver.
       
    93      * Called when mute setting changes. This may be caused by other applications.
       
    94      *
       
    95      * Called when balance setting changes. This may be caused by other applications.
       
    96      *
       
    97      * @since S60 3.2
       
    98      * @param aLeftPercentage
       
    99      *        Left speaker volume percentage. This can be any value from zero to 100.
       
   100      *        Zero value means left speaker is muted.
       
   101      * @param aRightPercentage
       
   102      *        Right speaker volume percentage. This can be any value from zero to 100.
       
   103      *        Zero value means right speaker is muted.
       
   104      */
       
   105     void MrpoBalanceChange( TInt aLeftPercentage, TInt aRightPercentage );
       
   106         
       
   107     /**
       
   108      * From MRadioFmTunerObserver.
       
   109      * Called when Request for tuner control completes.
       
   110      *
       
   111      * @since S60 3.2
       
   112      * @param aError A standard system error code or FM tuner error (TFmRadioTunerError).
       
   113      */
       
   114     void MrftoRequestTunerControlComplete( TInt aError );
       
   115 
       
   116     /**
       
   117      * From MRadioFmTunerObserver.
       
   118      * Set frequency range complete event. This event is asynchronous and is received after
       
   119      * a call to CRadioFmTunerUtility::SetFrequencyRange.
       
   120      *
       
   121      * @since S60 3.2
       
   122      * @param aError A standard system error code or FM tuner error (TFmRadioTunerError).
       
   123      */
       
   124     void MrftoSetFrequencyRangeComplete( TInt aError );
       
   125 
       
   126     /**
       
   127      * From MRadioFmTunerObserver.
       
   128      * Set frequency complete event. This event is asynchronous and is received after a call to
       
   129      * CRadioFmTunerUtility::SetFrequency.
       
   130      *
       
   131      * @since S60 3.2
       
   132      * @param aError A standard system error code or FM tuner error (TFmRadioTunerError).
       
   133      */
       
   134     void MrftoSetFrequencyComplete( TInt aError );
       
   135 
       
   136     /**
       
   137      * From MRadioFmTunerObserver.
       
   138      * Station seek complete event. This event is asynchronous and is received after a call to
       
   139      * CRadioFmTunerUtility::StationSeek.
       
   140      *
       
   141      * @since S60 3.2
       
   142      * @param aError A standard system error code or FM tuner error (TFmRadioTunerError).
       
   143      * @param aFrequency The frequency(Hz) of the radio station that was found.
       
   144      */
       
   145     void MrftoStationSeekComplete( TInt aError, TInt aFrequency );
       
   146 
       
   147     /**
       
   148      * From MRadioFmTunerObserver.
       
   149      * Called when FM Transmitter status changes (if one is present in the device). Tuner receiver
       
   150      * is forced to be turned off due to hardware conflicts when FM transmitter is activated.
       
   151      *
       
   152      * @since S60 3.2
       
   153      * @param aActive ETrue if FM transmitter is active; EFalse otherwise.
       
   154      */
       
   155     void MrftoFmTransmitterStatusChange( TBool aActive );
       
   156 
       
   157     /**
       
   158      * From MRadioFmTunerObserver.
       
   159      * Called when antenna status changes.
       
   160      *
       
   161      * @since S60 3.2
       
   162      * @param aAttached ETrue if antenna is attached; EFalse otherwise.
       
   163      */
       
   164     void MrftoAntennaStatusChange(TBool aAttached );
       
   165 
       
   166     /**
       
   167      * From MRadioFmTunerObserver.
       
   168      * Called when offline mode status changes.
       
   169      * @since S60 3.2
       
   170      *
       
   171      * @param aOfflineMode ETrue if offline mode is enabled; EFalse otherwise.
       
   172      */
       
   173     void MrftoOfflineModeStatusChange(TBool aOfflineMode );
       
   174 
       
   175     /**
       
   176      * From MRadioFmTunerObserver.
       
   177      * Called when the frequency range changes. This may be caused by other applications.
       
   178      *
       
   179      * @since S60 3.2
       
   180      * @param aBand New frequency range.
       
   181      */
       
   182     void MrftoFrequencyRangeChange(TFmRadioFrequencyRange aBand );
       
   183 
       
   184     /**
       
   185      * From MRadioFmTunerObserver.
       
   186      * Called when the tuned frequency changes. This may be caused by other
       
   187      * applications or RDS if AF/TA is enabled.
       
   188      *
       
   189      * @since S60 3.2
       
   190      * @param aNewFrequency The new tuned frequency(Hz).
       
   191      */
       
   192     void MrftoFrequencyChange( TInt aNewFrequency );
       
   193 
       
   194     /**
       
   195      * From MRadioFmTunerObserver.
       
   196      * Called when the forced mono status change. This may be caused by other applications.
       
   197      *
       
   198      * @since S60 3.2
       
   199      * @param aForcedMono ETrue if forced mono mode is enabled; EFalse otherwise.
       
   200      */
       
   201     void MrftoForcedMonoChange( TBool aForcedMono );
       
   202 
       
   203     /**
       
   204      * From MRadioFmTunerObserver.
       
   205      * Called when the squelch (muting the frequencies without broadcast) status change.
       
   206      * This may be caused by other applications.
       
   207      *
       
   208      * @since S60 3.2
       
   209      * @param aSquelch ETrue if squelch is enabled; EFalse otherwise.
       
   210      */
       
   211     void MrftoSquelchChange( TBool aSquelch );
       
   212 
       
   213     /**
       
   214      * From MRadioPresetObserver.
       
   215      * Called when a preset changes.
       
   216      *
       
   217      * NOTE: EPresetDeleted with aIndex == 0, indicates that all presets have been deleted.
       
   218      *
       
   219      * @since S60 3.2
       
   220      * @param aChange Change event type
       
   221      * @param aIndex Index to the preset that has changed. Zero means all presets.
       
   222      */
       
   223     void MrpeoPresetChanged( TPresetChangeEvent aChange, TInt aIndex ); 
       
   224        
       
   225 private:
       
   226 		static CMMFRadioBackendEngine* s_instance;
       
   227     CMMFRadioBackendEngine();
       
   228     void ConstructL();
       
   229 
       
   230 private:      
       
   231     CRadioUtility* 					iRadioUtility; 
       
   232     CRadioFmTunerUtility* 	iFmTunerUtility;
       
   233     CRadioPlayerUtility* 		iPlayerUtility;
       
   234     TBool										iAutoFlag;
       
   235     void* 									iRadioAdaptContext;
       
   236     void* 									iPlayerAdaptContext;    
       
   237        
       
   238     };
       
   239     
       
   240 #else  /* __cplusplus */
       
   241 
       
   242 extern void*     	cmmfradiobackendengine_init(void);
       
   243 extern void      	cmmfradiobackendengine_delete(void* context);
       
   244 extern void      	set_frequency(void* context, XAuint32 freq);
       
   245 extern void  			cancel_set_frequency(void* context);
       
   246 extern void 			station_seek(void* context, XAboolean upwards);    
       
   247 extern void 			cancel_station_seek(void* context);        
       
   248 extern XAresult  	get_frequency(void* context, XAuint32* freq);
       
   249 extern XAresult 	get_signal_strength(void* context, XAuint32* signalStrength);
       
   250 extern void 		 	set_freq_range(void* context, XAuint8 range);
       
   251 extern XAresult  	get_freq_range(void* context, XAuint8* range);   
       
   252 extern XAresult  	get_freq_range_properties(void* context, XAuint8 range, XAuint32* aMinFreq, XAuint32* aMaxFreq);
       
   253 extern XAresult  	set_stereo_mode(void* context, XAuint32 mode);
       
   254 extern XAresult  	get_stereo_mode(void* context, XAuint32* mode);
       
   255 extern XAresult  	mmf_set_radio_adapt_context(void * context, void * adaptcontext);
       
   256 extern XAresult  	mmf_set_player_adapt_context(void * context, void * adaptcontext);
       
   257 extern void         stop_radio(void * context);
       
   258 extern void         play_radio(void* context);
       
   259 extern XAresult     set_volume(void* context, XAuint32 vol);
       
   260 extern XAresult     mmf_set_player_adapt_context(void * context, void * adaptcontext);
       
   261 extern XAresult     set_mute(void* context, XAboolean mute);
       
   262 #endif /* __cplusplus */
       
   263 
       
   264 #endif /* CMMFRADIOBACKENDENGINE_H */