phoneapp/phoneringingtoneplayer/inc/cphonetoneserverplaybackcontroller.h
changeset 78 baacf668fe89
equal deleted inserted replaced
76:cfea66083b62 78:baacf668fe89
       
     1 /*
       
     2 * Copyright (c) 2010-2010 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:  Playback controller class for phone ringingtone server.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CPHONETONESERVERPLAYBACKCONTROLLER_H
       
    19 #define CPHONETONESERVERPLAYBACKCONTROLLER_H
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <mdaaudiosampleplayer.h>
       
    23 #include <mdaaudiotoneplayer.h>
       
    24 
       
    25 
       
    26 class MPhoneToneServer;
       
    27 
       
    28 
       
    29 NONSHARABLE_CLASS( CPhoneToneServerPlaybackController ) : public CTimer,
       
    30     private MMdaAudioPlayerCallback,
       
    31     private MMdaAudioToneObserver
       
    32     {
       
    33 
       
    34 public:
       
    35 
       
    36     static CPhoneToneServerPlaybackController* NewL();
       
    37 
       
    38     ~CPhoneToneServerPlaybackController();
       
    39 
       
    40     /**
       
    41     * Plays tone set by control panel.
       
    42     *
       
    43     * @param aName file path of ringingtone
       
    44     * @param aVolume volume of ringingtone
       
    45     * @param aType type of ringtone e.g. ringing or silent    
       
    46     */     
       
    47     void PlayNormalToneL( const TFileName& aName, 
       
    48                           TInt aVolume, 
       
    49                           TProfileRingingType aType );
       
    50     
       
    51     /**
       
    52     * Plays silent tone.
       
    53     */     
       
    54     void PlaySilentTone();
       
    55         
       
    56     /**
       
    57     * Stops playing.
       
    58     */     
       
    59     void StopTone();
       
    60 
       
    61 private:    
       
    62     
       
    63     /**
       
    64     * Plays profile based tone.
       
    65     *    
       
    66     */     
       
    67     void PlayProfileTone();
       
    68     
       
    69     /**
       
    70     * Plays default tone
       
    71     *    
       
    72     */      
       
    73     void PlayDefaultTone();
       
    74     
       
    75     /**
       
    76     * Converts volume level  
       
    77     *
       
    78     * @param aMaxVolume player's maximum volume
       
    79     * @param aVolume requested volume level.
       
    80     */     
       
    81     TInt ConvertVolume( TInt aMaxVolume, TInt aVolume );
       
    82     
       
    83     /**
       
    84     * Stops and deletes last used player.
       
    85     *    
       
    86     */     
       
    87     void StopAndDeleteProfilePlayer();
       
    88     
       
    89 
       
    90     /**
       
    91     * Checks that file uses rng file type
       
    92     *
       
    93     * @param aFile ringingtone file name
       
    94     * @return TBool true when file uses rng file type.
       
    95     */     
       
    96     TBool IsRngL( const TDesC& aFile );   
       
    97     
       
    98 private:
       
    99 
       
   100     CPhoneToneServerPlaybackController();
       
   101 
       
   102     void ConstructL();
       
   103     
       
   104 private:
       
   105 
       
   106     /**
       
   107      * @see MMdaAudioPlayerCallback
       
   108      */
       
   109     void MapcInitComplete(
       
   110         TInt aError, 
       
   111         const TTimeIntervalMicroSeconds& aDuration );
       
   112 
       
   113     /**
       
   114      * @see MMdaAudioPlayerCallback
       
   115      */
       
   116     void MapcPlayComplete( TInt aError );
       
   117 
       
   118     /**
       
   119      * @see MMdaAudioToneObserver
       
   120      */
       
   121     void MatoPrepareComplete(TInt aError );
       
   122 
       
   123     /**
       
   124      * @see MMdaAudioToneObserver
       
   125      */
       
   126     void MatoPlayComplete(TInt aError);
       
   127 
       
   128 
       
   129 private: 
       
   130 
       
   131     /**
       
   132      * @see CActive
       
   133      */
       
   134     virtual void RunL();
       
   135     
       
   136     
       
   137 private:   
       
   138 
       
   139     // Owned
       
   140     CMdaAudioPlayerUtility* iDefaultPlayer;
       
   141         
       
   142     // Owned
       
   143     CMdaAudioPlayerUtility* iProfileSamplePlayer;
       
   144         
       
   145     // Owned
       
   146     CMdaAudioToneUtility* iProfileTonePlayer;
       
   147     
       
   148     // Owned
       
   149     CMdaAudioToneUtility* iSilentPlayer;
       
   150     
       
   151     TProfileRingingType iRingingType;
       
   152         
       
   153     TBool iDefaultPlayerInitialized;
       
   154     
       
   155     TInt iVolume;
       
   156   
       
   157     };
       
   158 
       
   159 #endif // CPHONETONESERVERPLAYBACKCONTROLLER_H
       
   160 
       
   161 // End of file