controlpanelui/src/tonefetcher/tonefetcherengine/private/CTonePlayer.h
branchRCL_3
changeset 35 5f281e37a2f5
parent 34 90fe62538f66
child 46 ed95320285d0
equal deleted inserted replaced
34:90fe62538f66 35:5f281e37a2f5
     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  *     The header file for tone playing.
       
    16  *     
       
    17  */
       
    18 
       
    19 #ifndef CTONEPLAYER_H
       
    20 #define CTONEPLAYER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <coemain.h>
       
    24 #include <DrmAudioSamplePlayer.h>
       
    25 #include <mdaaudiotoneplayer.h>
       
    26 #include <videoplayer.h>
       
    27 #include <centralrepository.h>
       
    28 #include <apgcli.h>  // for RApaLsSession
       
    29 #include <e32property.h>
       
    30 
       
    31 class C3DRingingToneInterface;
       
    32 class RWindow;
       
    33 class MTonePlayingWatcher;
       
    34 /**
       
    35 * CMFPreviewHandlerBase
       
    36 *
       
    37 * Base class for CMFAudioPreviewHandler.
       
    38  */
       
    39 class CMFPreviewHandlerBase : public CBase
       
    40                         
       
    41     {
       
    42     public:     
       
    43        enum TMediaFileType
       
    44            {
       
    45            EMediaFileTypeAudio = 0,
       
    46            EMediaFileTypeVideo
       
    47            };
       
    48         enum TPlayerStatus
       
    49             {
       
    50             EPlayerNotCreated,
       
    51             EPlayerInitializing,
       
    52             EPlayerReady,
       
    53             EPlayerPlaying,
       
    54             EPlayerInitialized,
       
    55             EPlayerPlayingWith3DEffect
       
    56             };
       
    57     
       
    58         // these must match with the ones in Profile Engine
       
    59         enum TRingingTypes
       
    60             {
       
    61             ERingingTypeRinging = 0,
       
    62             ERingingTypeAscending,
       
    63             ERingingTypeRingOnce,
       
    64             ERingingTypeBeepOnce,
       
    65             ERingingTypeSilent
       
    66             };
       
    67     
       
    68         enum TFLAllowScreenSaver
       
    69             {
       
    70             EFLScreenSaverAllowed = 0, EFLScreenSaverNotAllowed
       
    71             };
       
    72     public:    
       
    73         void SetAttrL(const TDesC& aFileName);    
       
    74         TInt Attr(TInt aAttr);    
       
    75         virtual void PlayL() = 0;
       
    76         virtual void Stop() = 0;
       
    77         virtual TBool IsPlaying() = 0;
       
    78            
       
    79     protected:    
       
    80         virtual ~CMFPreviewHandlerBase();
       
    81     
       
    82     protected:    
       
    83         /**
       
    84          * C++ default constructor.
       
    85          */
       
    86         CMFPreviewHandlerBase( );    
       
    87         /**
       
    88          * By default Symbian OS constructor is private.
       
    89          */
       
    90         void ConstructL();
       
    91      
       
    92     protected:
       
    93         TInt ConvertVolume(TInt aVolume);
       
    94         void ReadActiveProfileL();
       
    95         TInt GetDataType(const TDesC& aFileName, TDataType& aDataType);
       
    96         void ReadDefaultToneL();   
       
    97         void DisableBackLight();    
       
    98         static TInt DoResetInactivityTimer(TAny* aObject);
       
    99         TInt RingingVolume();
       
   100         TInt RingingType();
       
   101         TInt Vibra();
       
   102         TInt Echo3D();
       
   103         TInt Effect3D();
       
   104         static TInt ConvertVolume(TInt aVolume, TInt aMaxVolume);    
       
   105     
       
   106     protected:
       
   107         TInt iRingingVolume;
       
   108         TInt iRingingType;
       
   109         TInt iVibra;
       
   110         TInt i3DEffect;
       
   111         TInt i3DEcho;
       
   112         TInt iMediaType;
       
   113         TInt iFileSize;
       
   114         HBufC* iFullName;    
       
   115         TBool iActiveProfileRead;
       
   116         TInt iActiveProfileRingingVolume;
       
   117         TInt iActiveProfileRingingType;
       
   118         TInt iActiveProfileVibra;
       
   119         TInt iActiveProfile3DEffect;
       
   120         TInt iActiveProfile3DEcho;    
       
   121         TInt iPlayerStatus;    
       
   122         // handle to window
       
   123         RWindow* iWindow; // does not own    
       
   124         // for getting file MIME types
       
   125         RApaLsSession iApaSession;    
       
   126         // for setting screensaver on/off
       
   127         RProperty iProperty;    
       
   128         // default ringing tone
       
   129         TFileName iDefaultTone;        
       
   130         /**
       
   131          * Timer for resetting the user inactivity timeout
       
   132          */
       
   133         CPeriodic* iBacklightTimer;
       
   134     };
       
   135 
       
   136 // CLASS DECLARATION
       
   137 /**
       
   138  *  This class is used for playing the tones.
       
   139  *
       
   140  */
       
   141 
       
   142 class CTonePlayer : public CMFPreviewHandlerBase,
       
   143                     public MDrmAudioPlayerCallback,
       
   144                     public MMdaAudioToneObserver,
       
   145                     public MCoeForegroundObserver
       
   146     {
       
   147     public:
       
   148         static CTonePlayer* NewL( MTonePlayingWatcher *aWatcher );
       
   149         static CTonePlayer* NewLC( MTonePlayingWatcher *aWatcher );
       
   150         virtual ~CTonePlayer();   
       
   151     
       
   152         
       
   153     public:
       
   154         void PlayL();
       
   155         void Stop();
       
   156         TBool IsPlaying();
       
   157     
       
   158     private:
       
   159         CTonePlayer( MTonePlayingWatcher *aWatcher );
       
   160         void ConstructL();
       
   161         void Cancel();
       
   162         void SetAudioRingingType( TInt aRingingType );
       
   163         void SetToneRingingType( TInt aRingingType );
       
   164         TInt ConvertVolume( TInt aVolume );        
       
   165             
       
   166     private:
       
   167         // from MMdaAudioToneObserver
       
   168         virtual void MatoPrepareComplete( TInt aError );
       
   169         virtual void MatoPlayComplete(TInt aError);
       
   170     
       
   171     private:
       
   172         // from MDrmAudioPlayerCallback
       
   173         void MdapcInitComplete(TInt aError,
       
   174                 const TTimeIntervalMicroSeconds& aDuration);
       
   175         void MdapcPlayComplete(TInt aError);
       
   176         
       
   177         // from MCoeForegroundObserver
       
   178         void HandleLosingForeground();
       
   179         void HandleGainingForeground();
       
   180     
       
   181     private:
       
   182         //wacher of the playing process
       
   183         MTonePlayingWatcher* iTonePlayWatcher;
       
   184         
       
   185         // audio player
       
   186         CDrmPlayerUtility* iAudioPlayer;
       
   187     
       
   188         /// Audioplayer status
       
   189         TPlayerStatus iAudioPlayerStatus;
       
   190     
       
   191         /// toneplayer
       
   192         CMdaAudioToneUtility* iTonePlayer;
       
   193     
       
   194         /// Toneplayer status
       
   195         TPlayerStatus iTonePlayerStatus;
       
   196         
       
   197         // plugin for playing 3D effects
       
   198         C3DRingingToneInterface* i3dRingingTonePlugin;
       
   199     
       
   200     };
       
   201     
       
   202 #endif /* CTONEPLAYER_H */