profilesservices/RingingTone3DPlugin/inc/CRingingTone3DPlugin.h
changeset 68 13e71d907dc3
equal deleted inserted replaced
40:6465d5bb863a 68:13e71d907dc3
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Plug-In that implements C3DRingingToneInterface.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CRINGINGTONE3DPLUGIN_H
       
    20 #define CRINGINGTONE3DPLUGIN_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include    <DrmAudioSamplePlayer.h>
       
    24 #include    <mdaaudiotoneplayer.h>
       
    25 #include    <videoplayer.h>
       
    26 
       
    27 #include <c3dringingtoneinterface.h>
       
    28 #include "C3DAudioTimeOutTimer.h"
       
    29 #include "C3DAudioPattern.h"
       
    30 #include "C3DAudioXMLParser.h"
       
    31 
       
    32 #include <centralrepository.h>
       
    33 #include <MProfile.h>
       
    34 
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class C3DAudioTimeOutTimer;
       
    38 class CEnvironmentalReverbUtility;
       
    39 class CSourceDoppler;
       
    40 class CSourceLocation;
       
    41 class CListenerLocation;
       
    42 
       
    43 class C3DPatternParser;
       
    44 
       
    45 #ifdef __STEREO_WIDENING_EFFECT_UI 
       
    46 class CStereoWidening;
       
    47 #endif
       
    48 
       
    49 
       
    50 // CONSTANTS
       
    51 const TInt32 KRingingTone3DAudioEComPluginUID = 0x10208ADF;
       
    52 const TInt KBufSize256 = 256;
       
    53 
       
    54 
       
    55 
       
    56 // CLASS DECLARATION
       
    57 
       
    58 
       
    59 /**
       
    60 * Plug-In implementing C3DRingingToneInterface.
       
    61 *
       
    62 * Used for playing 3D ringing tones. For playing, plugin uses player utility
       
    63 * (eg CDrmPlayerUtility) from calling application. 3D effect is achieved by
       
    64 * adding 3D data into normal ringing tone. C3DAudioXMLParser reads this
       
    65 * data from .xml files (one file per 3D effect).
       
    66 *  
       
    67 * @lib RingingTone3DPlugin.dll
       
    68 * @since 5.0
       
    69 */
       
    70 NONSHARABLE_CLASS (CRingingTone3DPlugin): public C3DRingingToneInterface,
       
    71 							              public M3DAudioTimeOutNotifier
       
    72     {
       
    73     private:
       
    74     
       
    75     enum TRingingTonePlayerType
       
    76         {
       
    77         EMdaAudioPlayerUtility,
       
    78         EMdaAudioToneUtility,
       
    79         EDrmPlayerUtility,
       
    80         EVideoPlayerUtility
       
    81         };
       
    82         
       
    83 
       
    84     public:
       
    85         
       
    86         /**
       
    87         * Two-phased constructor.
       
    88         */
       
    89         static CRingingTone3DPlugin* NewL( TAny* aParameter );
       
    90         
       
    91         /**
       
    92         * Destructor.
       
    93         */
       
    94         virtual ~CRingingTone3DPlugin();
       
    95         
       
    96     private:
       
    97 
       
    98        /**
       
    99         * C++ default constructor.
       
   100         */
       
   101         CRingingTone3DPlugin();
       
   102 
       
   103        /**
       
   104         * By default Symbian 2nd phase constructor is private.
       
   105         */
       
   106         void ConstructL( TAny* aParameter );
       
   107         
       
   108 
       
   109     public: // Functions from C3DRingingToneInterface
       
   110 
       
   111        /**
       
   112         * Set 3D plugin attribute.
       
   113         * @param aAttributeKey
       
   114         * @param aValue
       
   115         * @return System-wide error code.
       
   116         */
       
   117         TInt SetAttr( T3DRingingToneInterfaceAttr aAttributeKey, TInt aValue );
       
   118 
       
   119        /**
       
   120         * Set 3D plugin attribute.
       
   121         * @param aAttributeKey
       
   122         * @param aValue
       
   123         * @return System-wide error code.
       
   124         */
       
   125         TInt SetAttr( T3DRingingToneInterfaceAttr aAttributeKey, const TDesC& aValue );
       
   126 
       
   127        /**
       
   128         * Set 3D plugin attribute.
       
   129         * @param aAttributeKey
       
   130         * @param aValue
       
   131         * @return System-wide error code.
       
   132         */
       
   133         TInt SetAttr( TInt aAttributeKey, TAny* aValue );
       
   134 
       
   135        /**
       
   136         * Plays 3D ringing tone.
       
   137         */
       
   138     	void PlayL();
       
   139 
       
   140        /**
       
   141         * Stops playing 3D ringing tone.
       
   142         */
       
   143     	void Stop();
       
   144 
       
   145     
       
   146     private:  // from M3DAudioTimeOutNotifier
       
   147 
       
   148        /**
       
   149         * Callback initiated from C3DAudioTimeOutTimer.
       
   150         */
       
   151 		void TimerExpiredL();
       
   152 
       
   153 	private:
       
   154 		
       
   155        /**
       
   156         * Initializes player utility.
       
   157         * @param aSamplePlayer Player utility.
       
   158         */
       
   159         void Init( CMdaAudioPlayerUtility* aSamplePlayer );
       
   160 
       
   161        /**
       
   162         * Initializes player utility.
       
   163         * @param aSamplePlayer Player utility.
       
   164         */
       
   165         void Init( CMdaAudioToneUtility* aSamplePlayer );
       
   166 
       
   167        /**
       
   168         * Initializes player utility.
       
   169         * @param aSamplePlayer Player utility.
       
   170         */
       
   171         void Init( CDrmPlayerUtility* aSamplePlayer );
       
   172 
       
   173 #ifdef RD_VIDEO_AS_RINGING_TONE
       
   174        /**
       
   175         * Initializes player utility.
       
   176         * @param aSamplePlayer Player utility.
       
   177         */
       
   178         void Init( CVideoPlayerUtility* aSamplePlayer  );
       
   179 #endif
       
   180         
       
   181        /**
       
   182         * Plays 3D ringing tone.
       
   183         */        
       
   184         void DoPlayL();
       
   185         
       
   186        /**
       
   187         * Add 3D pattern (effect) data into normal ringing tone.
       
   188         */
       
   189         void SetNext3DPatternPositionL();
       
   190 
       
   191 	   /**
       
   192         * Plays 3D ringing tone.
       
   193         */		        
       
   194         void PlayRingingTone();
       
   195 
       
   196 	   /**
       
   197         * Stops playing 3D ringing tone.
       
   198         */		        
       
   199         void StopRingingTone();
       
   200   
       
   201     private:
       
   202     
       
   203 	   /**
       
   204         * Calculates the correct dTime according to velocity-value in cenrep.
       
   205         * @param aTime Time from the script to be calculated.
       
   206         */		        
       
   207         void CalculateDTime( TInt& aTime );
       
   208         
       
   209        /**
       
   210         * Plugin initialization.
       
   211         */		        
       
   212         void InitializeL();
       
   213         
       
   214        /**
       
   215         * Plugin uninitialization. Needed in error case when normal ringing 
       
   216         * tone is played.
       
   217         */		        
       
   218         void UnInitialize();
       
   219         
       
   220 
       
   221     private:
       
   222     
       
   223 	   /**
       
   224         * Gets CEnvironmentalReverbUtility object.
       
   225         * @return CEnvironmentalReverbUtility.
       
   226         */		        
       
   227         CEnvironmentalReverbUtility* EnvironmentalReverbUtilityL();
       
   228 
       
   229 	   /**
       
   230         * Gets CSourceLocation object.
       
   231         * @return CSourceLocation.
       
   232         */		        
       
   233         CSourceLocation* SourceLocationL();
       
   234         
       
   235 	   /**
       
   236         * Gets CListenerLocation object.
       
   237         * @return CListenerLocation.
       
   238         */		        
       
   239         CListenerLocation* ListenerLocationL();
       
   240         
       
   241 	   /**
       
   242         * Gets CSourceDoppler object.
       
   243         * @return CSourceDoppler.
       
   244         */		        
       
   245         CSourceDoppler* SourceDopplerL();
       
   246       
       
   247 #ifdef __STEREO_WIDENING_EFFECT_UI
       
   248         CStereoWidening* StereoWideningL();
       
   249 #endif        
       
   250 
       
   251 
       
   252     private:
       
   253 
       
   254        /**
       
   255         * Read active profile setting from profile engine. Needed in case calling
       
   256         * app does not set 3D effect and echo attributes.
       
   257         */
       
   258         void ReadActiveProfileL();
       
   259         
       
   260        /**
       
   261         * Checks that tone can be used as 3D ringing tone. This check is only
       
   262         * done if calling app explicitly sets ringing tone attribute.
       
   263         */
       
   264         TBool CheckRingingTone();
       
   265 
       
   266 	   /**
       
   267         * Panics plugin dll.
       
   268         * @param aReason Panic code.
       
   269         */		        
       
   270         void Panic(TInt aReason);
       
   271         
       
   272         
       
   273 #ifdef _DEBUG
       
   274     public:
       
   275         void FlogRepositoryL(CRepository* aRepository, TInt aEcho);
       
   276         //void FlogPatternsL(TInt aOldPattern, TInt aNewPattern);
       
   277         void FlogProfileL(MProfile* aProfile);
       
   278         void FlogPlayer(TInt aPlayer);
       
   279         void Check3DEchoL(TInt aEcho);
       
   280         void Check3DPatternL(TInt aPattern);
       
   281         void FlogPositionL(T3DPosition& aPosition, TInt aIndex);
       
   282         void FlogVelocityL(T3DVelocity& aVelocity, TInt aIndex);
       
   283         void FlogTimeL(TInt aTime, TInt aIndex);
       
   284         void FlogPubSubL(TInt aEcho);
       
   285 #endif        
       
   286 
       
   287 
       
   288     private:    // Data
       
   289    	
       
   290     	// 3D Ringing tone velocity
       
   291     	TInt iVelocity;		
       
   292     	
       
   293     	// Doppler status
       
   294     	TBool iDoppler;		
       
   295     	
       
   296     	// 3D effect (pattern)
       
   297     	TInt iProfile3DToneEffect;
       
   298     	
       
   299     	// 3D echo
       
   300     	TInt iProfile3DToneEcho;
       
   301     	
       
   302     	// ringing tone, used only for validity check
       
   303     	TFileName iRingingTone;
       
   304     	
       
   305     	// profile id, currently not used
       
   306     	TInt iProfileId;
       
   307     	
       
   308     	// ringing tone player type
       
   309     	TInt iPlayerType;
       
   310     	
       
   311     	// is ringing tone playing
       
   312     	TInt iPlaying;
       
   313 		
       
   314 		// 3D pattern parser
       
   315 		C3DAudioXMLParser* iParser;
       
   316                 
       
   317     	// current position in pattern script
       
   318     	TInt iCurrentUpdate;
       
   319     	
       
   320     	// player utility used for playback
       
   321     	CMdaAudioPlayerUtility* iAudioPlayerUtility;
       
   322 
       
   323     	// player utility
       
   324     	CMdaAudioToneUtility* iAudioToneUtility;
       
   325     	
       
   326     	// player utility
       
   327     	CDrmPlayerUtility* iDrmPlayerUtility;
       
   328     	
       
   329 #ifdef RD_VIDEO_AS_RINGING_TONE
       
   330     	// player utility
       
   331     	CVideoPlayerUtility* iVideoPlayerUtility; 
       
   332 #endif
       
   333   
       
   334     	// timer for updating 3D pattern position
       
   335     	C3DAudioTimeOutTimer* iTimer;
       
   336     
       
   337     	// reverberation utility used to set reverb presets
       
   338     	CEnvironmentalReverbUtility* iReverbEffect;
       
   339        	
       
   340        	// doppler-effect
       
   341        	CSourceDoppler* iDopplerEffect;
       
   342     	
       
   343     	// source location-effect
       
   344     	CSourceLocation* iSource;
       
   345     	
       
   346     	// listener location-effect
       
   347     	CListenerLocation* iListener;
       
   348      	
       
   349 #ifdef __STEREO_WIDENING_EFFECT_UI    	
       
   350     	// stereo widening-effect
       
   351     	CStereoWidening* iStereoWidening;
       
   352 #endif
       
   353     };
       
   354 
       
   355 
       
   356 
       
   357 
       
   358 #endif      // CRINGINGTONE3DPLUGIN_H
       
   359             
       
   360 // End of File