phoneapp/phoneuiview/inc/cphoneringingtoneplayerao.h
branchRCL_3
changeset 62 5266b1f337bd
equal deleted inserted replaced
61:41a7f70b3818 62:5266b1f337bd
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Active object which implements ringing tone functionality
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPHONERINGINGTONEPLAYERAO_H
       
    20 #define CPHONERINGINGTONEPLAYERAO_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <Profile.hrh>
       
    25 #include "mphonevideoplayerobserver.h"
       
    26 #include "mphonecenrepobserver.h"
       
    27 #include "mphonetimer.h"
       
    28 #include "mphonevideoplayer.h"
       
    29 #include "phoneringingtoneclient.h"
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 //class MPhoneRingingToneObserver;
       
    33 class CPhoneAudioPlayer;
       
    34 class CPhoneTimer;
       
    35 class CMdaServer;
       
    36 class MPhoneDisplayProvider;
       
    37 class CPhoneRingingTone;
       
    38 class TPhoneCommandParam;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 * It implements ringing tone functionality. 
       
    44 * Note that when issuing Play-command to audio side, ALWAYS set the tone type
       
    45 * before the Play() is called. This is to ensure that correct tone is tried to
       
    46 * be played. 
       
    47 *
       
    48 * @since 1.0
       
    49 */
       
    50 class CPhoneRingingTonePlayerAO :
       
    51     public CActive,
       
    52     public MPhoneCenRepObserver,
       
    53     private MPhoneTimer,
       
    54     private MPhoneVideoPlayerObserver
       
    55     {
       
    56     public:
       
    57         // States for this active object
       
    58         enum TState
       
    59             {
       
    60             EIdleState,  
       
    61             EDeletingVideoPlayer,
       
    62             EPlayingDefaultVideo
       
    63             };
       
    64 
       
    65     public:
       
    66 
       
    67         /**
       
    68         * Two-phased constructor.
       
    69         * @return new instance.
       
    70         */
       
    71         static CPhoneRingingTonePlayerAO* NewL();
       
    72 
       
    73         /**
       
    74         * Destructor.
       
    75         */
       
    76         ~CPhoneRingingTonePlayerAO();
       
    77 
       
    78         /**
       
    79         * Play ring tone
       
    80         * @param aCommandParam a command param
       
    81         */
       
    82         void PlayRingToneL( TPhoneCommandParam *aCommandParam );
       
    83 
       
    84         /**
       
    85         * Play audio ring tone 
       
    86         * @param aVolume Volume used to play the ringing tone.
       
    87         * @param aRingingType Ringing type.
       
    88         */
       
    89         void PlayAudioRingTone( 
       
    90             TInt aVolume, 
       
    91             TProfileRingingType aRingingType );
       
    92 
       
    93         /**
       
    94         * Playing the Beep once.
       
    95         * @param aVolume volume used to play the ringing tone.
       
    96         */
       
    97         void BeepOnce( TInt aVolume );
       
    98 
       
    99         /**
       
   100         * Play silent tone. No_sound.wav will be played. If vibration alert
       
   101         * is ON, it will vibrate.
       
   102         */
       
   103         void PlaySilentTone();
       
   104 
       
   105         /**
       
   106         * Play unsecure VoIP tone.
       
   107         * Play tone if secure call fails and call is changed to unsecure call
       
   108         * @since    S60 5.0
       
   109         */
       
   110         void PlayUnsecureVoIPTone();
       
   111 
       
   112         /**
       
   113         * Stops playing the ringing tone.
       
   114         * Method does not do anything if ringing tone is not playing.
       
   115         */
       
   116         void StopPlaying();
       
   117 
       
   118         /**
       
   119         * Continues video playback ( and ringing tone ) with volume 0
       
   120         * Stream not closed ( If music player was ongoing ) 
       
   121         */
       
   122         void MuteRingingToneOnAnswer();
       
   123 
       
   124         /**
       
   125         * Continues video playback with muted audio.
       
   126         * Ringing tone is stopped.
       
   127         */
       
   128         void MuteRingingTone();
       
   129 
       
   130         /**
       
   131         * Sets video player.
       
   132         * @since Series 60 v3.2
       
   133         * @param aVideoPlayer Video player reference.
       
   134         */
       
   135         void SetVideoPlayer( MPhoneVideoPlayer* aVideoPlayer );
       
   136 
       
   137         /**
       
   138         * Play TTS tone simultaneously with Personal or Default tones.
       
   139         * This method does not command phone to play TTS immediately. Instead 
       
   140         * it registers a request to play TTS, when Personal or default tones 
       
   141         * are played.
       
   142         *
       
   143         * @since Series 60 3.0
       
   144         * @param aTextToSay Text, that should be pronounced by the 
       
   145         * Text-To-Speech engine. This is normal descriptor, no UTF-8 
       
   146         * and no "(tts)" prefix
       
   147         * @param aVolume Volume for the TTS-tone, Does not effect the volume 
       
   148         * of the normal tone, that will be played simulteneously with the TTS
       
   149         * @param aRingingType ringing type.
       
   150         */
       
   151         void PlayTtsTone(
       
   152             const TDesC& aTextToSay,
       
   153             TInt aVolume,
       
   154             TProfileRingingType aRingingType );
       
   155 
       
   156         /**
       
   157         * Play video ring tone.
       
   158         * @since Series 60 3.1
       
   159         * @param aRingingTone Ringing tone to be played.
       
   160         * @param aVolume Volume used to play the ringing tone.
       
   161         * @param aRingingType Ringing type.
       
   162         */
       
   163         void PlayVideoRingingTone( 
       
   164             const CPhoneRingingTone& aRingingTone, 
       
   165             TInt aVolume, 
       
   166             TProfileRingingType aRingingType,
       
   167             TBool aPersonalTone = EFalse );
       
   168 
       
   169         /**
       
   170         * Checks if extended security required.
       
   171         * @since Series 60 3.1
       
   172         * @return ETrue if extended security is required.
       
   173         */
       
   174         TBool ExtendedSecurity() const;
       
   175 
       
   176     public: // From MPhoneCenRepObserver
       
   177 
       
   178         /**
       
   179         * Handle the change of the setting from Central Repository
       
   180         * @param aUid identifing the central repository UID.
       
   181         * @param aId central repository ID.
       
   182         */
       
   183         virtual void HandleCenRepChangeL( 
       
   184             const TUid& aUid,
       
   185             const TUint aId );
       
   186 
       
   187 
       
   188     private:
       
   189 
       
   190         /**
       
   191         * @see MPhoneTimer
       
   192         */
       
   193         virtual void HandleTimeOutL();
       
   194 
       
   195         /**
       
   196         * This function is called for video player errors.
       
   197         * @param aEvent The error event happend in initializing or playing.
       
   198         * @param aError The error code return by MMF video player. 
       
   199         */
       
   200         virtual void HandleVideoPlayerError( 
       
   201             TPhoneVideoPlayerErrorEvent aEvent,
       
   202             TInt aError );
       
   203 
       
   204         /**
       
   205         * This function is called when video player initialization complete
       
   206         */
       
   207         virtual void HandleVideoPlayerInitComplete();
       
   208 
       
   209         /**
       
   210         * This function is called after the playing completes successfully
       
   211         */
       
   212         virtual void HandleVideoPlayerPlayingComplete();
       
   213 
       
   214         /**
       
   215         * C++ default constructor.
       
   216         */
       
   217         CPhoneRingingTonePlayerAO();
       
   218 
       
   219         /**
       
   220         * Symbian 2nd phase constructor.
       
   221         */
       
   222         void ConstructL();
       
   223 
       
   224         /**
       
   225         * Play default tone.
       
   226         * @param aVolume volume used for the playing.
       
   227         * @param aRingingType ringing type.
       
   228         */
       
   229         void PlayDefaultTone( 
       
   230             TInt aVolume, 
       
   231             TProfileRingingType aRingingType );
       
   232 
       
   233         /**
       
   234         * Play backup tone.
       
   235         * @param aVolume volume used for the playing.
       
   236         * @param aRingingType ringing type.
       
   237         */
       
   238         void PlayBackupTone( 
       
   239             TInt aVolume, 
       
   240             TProfileRingingType aRingingType );
       
   241 
       
   242         /**
       
   243         * Convert ringing type from PhoneAppEnging to the ringing type in 
       
   244         * MPhoneVideoPlayer.
       
   245         * @since Series 60 3.1
       
   246         * @param aRingingType the ringing type form PhoneAppEngine.
       
   247         * @return ringing type of MPhoneVideoPlayer.
       
   248         */
       
   249         MPhoneVideoPlayer::TPlayMode ConvertVideoRingingType(
       
   250             TProfileRingingType aRingingType );
       
   251 
       
   252        /**
       
   253         * Plays default L1 or L2 video ring tone asynchronously.
       
   254         * @since Series 60 3.1
       
   255         */
       
   256         void PlayDefaultVideoAsync();
       
   257 
       
   258         /**
       
   259         * Deletes video player and plays default L1 or L2
       
   260         * tone asynchronously.
       
   261         * @since Series 60 3.1
       
   262         */
       
   263         void DeleteVideoPlayerAndPlayDefaultAsync();
       
   264 
       
   265         /**
       
   266         * @see CActive::RunL.
       
   267         */
       
   268         void RunL();
       
   269 
       
   270         /**
       
   271         * @see CActive::DoCancel.
       
   272         */
       
   273         void DoCancel();
       
   274 
       
   275          /**
       
   276          * Checks if ringing tone file's size is larger than the size limit.
       
   277          * If size limit is exceeded, default tone is played instead.
       
   278          * @since 3.1
       
   279          * @param aRingingTone  Tone to check.
       
   280          * @return EFalse if the limit was exceeded and thus default tone played.
       
   281          *         ETrue  if tone file's size was valid and the checked tone 
       
   282          *                can be played.
       
   283          */
       
   284         TBool CheckAndHandleToneSizeLimit( CPhoneRingingTone* aRingingTone );
       
   285 
       
   286          /**
       
   287          * Checks if ringing tone file's size is larger than the size limit.
       
   288          * @since 3.1
       
   289          * @param aFile   File to check.
       
   290          * @param aSizeLimitKB  the size limit in kB is set to this variable.
       
   291          * @return KErrNone        if the file can be used as a ringing tone.
       
   292          *         KErrTooBig        if the file size limit is exceeded.
       
   293          *         Other error value if error happened during size checking.
       
   294          */
       
   295         TInt CheckToneFileSize( const TDesC& aFile, TInt aSizeLimitKB );
       
   296 
       
   297          /**
       
   298          * Reads from central repository the file size limit of following tones:
       
   299          * -contact's personal ringing tone
       
   300          * -voice call line1
       
   301          * -voice call line2
       
   302          * Value 0 means all sizes are allowed.
       
   303          * @since 3.1
       
   304          * @param aSizeLimitKB  the size limit in kB is read to this variable.
       
   305          * @return leaves on error.
       
   306          */
       
   307         void GetMaxToneFileSizeL( TInt& aSizeLimitKB ) const;
       
   308 
       
   309     private:    // Data
       
   310 
       
   311         // Indicate which tone is playing or need to be played:
       
   312         // EIdle - idle,
       
   313         // EVideoTonePlaying - playing video ringing tone
       
   314         // ESilentVideoTonePlaying  - silent playing video ringing tone
       
   315         // EPersonalVideoTonePlaying - personal playing video ringing tone
       
   316         enum TTonePlayingStatus
       
   317             {
       
   318             EIdle,
       
   319             EVideoTonePlaying,
       
   320             ESilentVideoTonePlaying,
       
   321             EPersonalVideoTonePlaying
       
   322             };
       
   323 
       
   324         // Current playing status.
       
   325         TTonePlayingStatus iTonePlayingStatus;
       
   326 
       
   327         // Audio/Video tone, not owned
       
   328         CPhoneRingingTone* iAudioVideoRingingTone;
       
   329 
       
   330         // Volume for backup tone playing.
       
   331         TInt iVolume;
       
   332 
       
   333         // Ringing type for backup tone playing.
       
   334         TProfileRingingType iRingingType;
       
   335 
       
   336         // Timer.
       
   337         CPhoneTimer* iTimer;
       
   338 
       
   339         // DRM extend security
       
   340         TBool iExtSecNeeded;
       
   341 
       
   342         // Video ringing tone player
       
   343         MPhoneVideoPlayer* iVideoPlayer;
       
   344 
       
   345         // State of this active object
       
   346         TState iState;
       
   347 
       
   348         // Voice call ringing tone file size max value.
       
   349         TInt iToneFileSizeLimitKB;
       
   350 
       
   351         // Flag. Indicates video scaling capability of the device.
       
   352         TBool iArbitraryVideoScaling;
       
   353 
       
   354         // Ringing tone server.
       
   355         RPhoneRingingTonePlayer iToneServer;
       
   356 
       
   357     };
       
   358 
       
   359 #endif      // CPHONERINGINGTONEPLAYERAO_H
       
   360 
       
   361 // End of File