profilesservices/RingingTone3DPlugin/inc/CRingingTone3DPlugin.h
changeset 0 8c5d936e5675
child 11 23553eb4e470
equal deleted inserted replaced
-1:000000000000 0:8c5d936e5675
       
     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        /**
       
   174         * Initializes player utility.
       
   175         * @param aSamplePlayer Player utility.
       
   176         */
       
   177         void Init( CVideoPlayerUtility* aSamplePlayer  );
       
   178         
       
   179        /**
       
   180         * Plays 3D ringing tone.
       
   181         */        
       
   182         void DoPlayL();
       
   183         
       
   184        /**
       
   185         * Add 3D pattern (effect) data into normal ringing tone.
       
   186         */
       
   187         void SetNext3DPatternPositionL();
       
   188 
       
   189 	   /**
       
   190         * Plays 3D ringing tone.
       
   191         */		        
       
   192         void PlayRingingTone();
       
   193 
       
   194 	   /**
       
   195         * Stops playing 3D ringing tone.
       
   196         */		        
       
   197         void StopRingingTone();
       
   198   
       
   199     private:
       
   200     
       
   201 	   /**
       
   202         * Calculates the correct dTime according to velocity-value in cenrep.
       
   203         * @param aTime Time from the script to be calculated.
       
   204         */		        
       
   205         void CalculateDTime( TInt& aTime );
       
   206         
       
   207        /**
       
   208         * Plugin initialization.
       
   209         */		        
       
   210         void InitializeL();
       
   211         
       
   212        /**
       
   213         * Plugin uninitialization. Needed in error case when normal ringing 
       
   214         * tone is played.
       
   215         */		        
       
   216         void UnInitialize();
       
   217         
       
   218 
       
   219     private:
       
   220     
       
   221 	   /**
       
   222         * Gets CEnvironmentalReverbUtility object.
       
   223         * @return CEnvironmentalReverbUtility.
       
   224         */		        
       
   225         CEnvironmentalReverbUtility* EnvironmentalReverbUtilityL();
       
   226 
       
   227 	   /**
       
   228         * Gets CSourceLocation object.
       
   229         * @return CSourceLocation.
       
   230         */		        
       
   231         CSourceLocation* SourceLocationL();
       
   232         
       
   233 	   /**
       
   234         * Gets CListenerLocation object.
       
   235         * @return CListenerLocation.
       
   236         */		        
       
   237         CListenerLocation* ListenerLocationL();
       
   238         
       
   239 	   /**
       
   240         * Gets CSourceDoppler object.
       
   241         * @return CSourceDoppler.
       
   242         */		        
       
   243         CSourceDoppler* SourceDopplerL();
       
   244       
       
   245 #ifdef __STEREO_WIDENING_EFFECT_UI
       
   246         CStereoWidening* StereoWideningL();
       
   247 #endif        
       
   248 
       
   249 
       
   250     private:
       
   251 
       
   252        /**
       
   253         * Read active profile setting from profile engine. Needed in case calling
       
   254         * app does not set 3D effect and echo attributes.
       
   255         */
       
   256         void ReadActiveProfileL();
       
   257         
       
   258        /**
       
   259         * Checks that tone can be used as 3D ringing tone. This check is only
       
   260         * done if calling app explicitly sets ringing tone attribute.
       
   261         */
       
   262         TBool CheckRingingTone();
       
   263 
       
   264 	   /**
       
   265         * Panics plugin dll.
       
   266         * @param aReason Panic code.
       
   267         */		        
       
   268         void Panic(TInt aReason);
       
   269         
       
   270         
       
   271 #ifdef _DEBUG
       
   272     public:
       
   273         void FlogRepositoryL(CRepository* aRepository, TInt aEcho);
       
   274         //void FlogPatternsL(TInt aOldPattern, TInt aNewPattern);
       
   275         void FlogProfileL(MProfile* aProfile);
       
   276         void FlogPlayer(TInt aPlayer);
       
   277         void Check3DEchoL(TInt aEcho);
       
   278         void Check3DPatternL(TInt aPattern);
       
   279         void FlogPositionL(T3DPosition& aPosition, TInt aIndex);
       
   280         void FlogVelocityL(T3DVelocity& aVelocity, TInt aIndex);
       
   281         void FlogTimeL(TInt aTime, TInt aIndex);
       
   282         void FlogPubSubL(TInt aEcho);
       
   283 #endif        
       
   284 
       
   285 
       
   286     private:    // Data
       
   287    	
       
   288     	// 3D Ringing tone velocity
       
   289     	TInt iVelocity;		
       
   290     	
       
   291     	// Doppler status
       
   292     	TBool iDoppler;		
       
   293     	
       
   294     	// 3D effect (pattern)
       
   295     	TInt iProfile3DToneEffect;
       
   296     	
       
   297     	// 3D echo
       
   298     	TInt iProfile3DToneEcho;
       
   299     	
       
   300     	// ringing tone, used only for validity check
       
   301     	TFileName iRingingTone;
       
   302     	
       
   303     	// profile id, currently not used
       
   304     	TInt iProfileId;
       
   305     	
       
   306     	// ringing tone player type
       
   307     	TInt iPlayerType;
       
   308     	
       
   309     	// is ringing tone playing
       
   310     	TInt iPlaying;
       
   311 		
       
   312 		// 3D pattern parser
       
   313 		C3DAudioXMLParser* iParser;
       
   314                 
       
   315     	// current position in pattern script
       
   316     	TInt iCurrentUpdate;
       
   317     	
       
   318     	// player utility used for playback
       
   319     	CMdaAudioPlayerUtility* iAudioPlayerUtility;
       
   320 
       
   321     	// player utility
       
   322     	CMdaAudioToneUtility* iAudioToneUtility;
       
   323     	
       
   324     	// player utility
       
   325     	CDrmPlayerUtility* iDrmPlayerUtility;
       
   326     	
       
   327     	// player utility
       
   328     	CVideoPlayerUtility* iVideoPlayerUtility; 
       
   329   
       
   330     	// timer for updating 3D pattern position
       
   331     	C3DAudioTimeOutTimer* iTimer;
       
   332     
       
   333     	// reverberation utility used to set reverb presets
       
   334     	CEnvironmentalReverbUtility* iReverbEffect;
       
   335        	
       
   336        	// doppler-effect
       
   337        	CSourceDoppler* iDopplerEffect;
       
   338     	
       
   339     	// source location-effect
       
   340     	CSourceLocation* iSource;
       
   341     	
       
   342     	// listener location-effect
       
   343     	CListenerLocation* iListener;
       
   344      	
       
   345 #ifdef __STEREO_WIDENING_EFFECT_UI    	
       
   346     	// stereo widening-effect
       
   347     	CStereoWidening* iStereoWidening;
       
   348 #endif
       
   349     };
       
   350 
       
   351 
       
   352 
       
   353 
       
   354 #endif      // CRINGINGTONE3DPLUGIN_H
       
   355             
       
   356 // End of File