profilesservices/MediaFileList/Inc/mediafilepreview.h
changeset 68 13e71d907dc3
parent 0 8c5d936e5675
equal deleted inserted replaced
40:6465d5bb863a 68:13e71d907dc3
       
     1 /*
       
     2 * Copyright (c) 2007 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:   Class for preview audio and video
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef MEDIAFILEPREVIEW_H
       
    21 #define MEDIAFILEPREVIEW_H
       
    22 
       
    23 #include "mediafiledialogutils.h"
       
    24 
       
    25 //  INCLUDES
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <DrmAudioSamplePlayer.h>
       
    29 #include <mdaaudiotoneplayer.h>
       
    30 #include <videoplayer.h>
       
    31 #include <centralrepository.h>
       
    32 #include <apgcli.h>  // for RApaLsSession
       
    33 #include <e32property.h>
       
    34 
       
    35 
       
    36 
       
    37 // CONSTANTS
       
    38 
       
    39 
       
    40 //	FORWARD DECLARATIONS
       
    41 class C3DRingingToneInterface;
       
    42 class RWindow;
       
    43 
       
    44 
       
    45 
       
    46 
       
    47 /**
       
    48 * MPreviewHandlerObserver
       
    49 * 
       
    50 * For observing media file preview events.
       
    51 *
       
    52 */
       
    53 NONSHARABLE_CLASS (MPreviewHandlerObserver)
       
    54 	{
       
    55     public:
       
    56     enum TPreviewHandler
       
    57         {
       
    58         EVideoPreviewComplete,
       
    59         EAudioPreviewComplete,
       
    60         EPreviewError
       
    61         };
       
    62 	
       
    63 	public:
       
    64 		virtual void HandlePreviewEventL( TInt aEvent, TInt aError ) = 0;
       
    65 	};
       
    66 
       
    67 
       
    68 
       
    69 
       
    70 /**
       
    71 * CMFPreviewHandlerBase
       
    72 *
       
    73 * Base class for CMFAudioPreviewHandler and CMFVideoPreviewHandler.
       
    74 */
       
    75 NONSHARABLE_CLASS (CMFPreviewHandlerBase) : public CBase
       
    76     {
       
    77     public:
       
    78         enum TPlayerStatus
       
    79             {
       
    80             EPlayerNotCreated,
       
    81             EPlayerInitializing,
       
    82             EPlayerReady,
       
    83             EPlayerPlaying,
       
    84 			EPlayerInitialized,
       
    85 			EPlayerPlayingWith3DEffect
       
    86             };
       
    87 
       
    88         // these must match with the ones in Profile Engine
       
    89         enum TRingingTypes
       
    90             {
       
    91             ERingingTypeRinging = 0,
       
    92             ERingingTypeAscending,
       
    93             ERingingTypeRingOnce,
       
    94             ERingingTypeBeepOnce,
       
    95             ERingingTypeSilent
       
    96             };
       
    97 
       
    98 		enum TFLAllowScreenSaver
       
    99 			{
       
   100 			EFLScreenSaverAllowed = 0,
       
   101 			EFLScreenSaverNotAllowed
       
   102 			};
       
   103     
       
   104     protected:// Constructors and destructor
       
   105 
       
   106         /**
       
   107         * Destructor.
       
   108         */
       
   109         virtual ~CMFPreviewHandlerBase();
       
   110     
       
   111     protected:
       
   112 
       
   113         /**
       
   114         * C++ default constructor.
       
   115         */
       
   116         CMFPreviewHandlerBase();
       
   117 	
       
   118         /**
       
   119         * By default Symbian OS constructor is private.
       
   120         */
       
   121         void ConstructL();
       
   122 
       
   123 	public:
       
   124 		void SetAttrL( TInt aAttr, TInt aValue );
       
   125 		void SetAttrL( TInt aAttr, const TDesC& aValue );
       
   126 		void SetAttrL( TInt aAttr, TAny* aValue );
       
   127 		TInt Attr( TInt aAttr );
       
   128 		void SetObserver( MPreviewHandlerObserver* aObserver );
       
   129         virtual void PlayL() = 0;
       
   130         virtual void Stop() = 0;
       
   131         virtual TBool IsPlaying() = 0;
       
   132 
       
   133     protected:
       
   134         TInt ConvertVolume( TInt aVolume );
       
   135         void ReadActiveProfileL();
       
   136         TInt GetDataType( const TDesC& aFileName, TDataType& aDataType );
       
   137         void ReadDefaultToneL();
       
   138         void Panic( TInt aReason );
       
   139         void EnableScreenSaver( TBool aEnable );
       
   140         
       
   141         void DisableBackLight();
       
   142         		
       
   143         static TInt DoResetInactivityTimer( TAny* aObject );
       
   144     protected:
       
   145         TInt RingingVolume();
       
   146         TInt RingingType();
       
   147         TInt Vibra();
       
   148         TInt Echo3D();
       
   149         TInt Effect3D();
       
   150         
       
   151     protected:
       
   152         static TInt ConvertVolume( TInt aVolume, TInt aMaxVolume );
       
   153         static TBool IsCallOngoing();
       
   154         
       
   155     protected:
       
   156         TInt iRingingVolume;
       
   157         TInt iRingingType;
       
   158         TInt iVibra;
       
   159         TInt i3DEffect;
       
   160         TInt i3DEcho;
       
   161         TInt iMediaType;
       
   162         TInt iFileSize;
       
   163         HBufC* iFullName;
       
   164         
       
   165         TBool iActiveProfileRead;
       
   166         TInt iActiveProfileRingingVolume;
       
   167         TInt iActiveProfileRingingType;
       
   168         TInt iActiveProfileVibra;
       
   169         TInt iActiveProfile3DEffect;
       
   170         TInt iActiveProfile3DEcho;
       
   171 
       
   172 
       
   173         MPreviewHandlerObserver* iObserver;
       
   174         
       
   175         TInt iPlayerStatus;
       
   176         
       
   177         // handle to window
       
   178         RWindow* iWindow;  // does not own
       
   179         
       
   180         // for getting file MIME types
       
   181         RApaLsSession iApaSession;
       
   182         
       
   183         // for setting screensaver on/off
       
   184         RProperty iProperty;
       
   185         
       
   186         // default ringing tone
       
   187         TFileName iDefaultTone;
       
   188         
       
   189         // file server session
       
   190         //RFs iFsSession;
       
   191         
       
   192         /**
       
   193 		* Timer for resetting the user inactivity timeout
       
   194 		*/
       
   195 		CPeriodic* iBacklightTimer;
       
   196     };
       
   197 
       
   198 
       
   199 
       
   200 /**
       
   201 * CMFVideoPreviewHandler
       
   202 * 
       
   203 * For previewing video files.
       
   204 */
       
   205 NONSHARABLE_CLASS (CMFVideoPreviewHandler) : public CMFPreviewHandlerBase,
       
   206                                              public MVideoPlayerUtilityObserver
       
   207     {
       
   208 
       
   209     public:// Constructors and destructor
       
   210 
       
   211         /**
       
   212         * Two-phased constructor.
       
   213         */
       
   214 		static CMFVideoPreviewHandler* NewL();
       
   215         
       
   216         /**
       
   217         * Destructor.
       
   218         */
       
   219         virtual ~CMFVideoPreviewHandler();
       
   220     
       
   221     private:
       
   222 
       
   223         /**
       
   224         * C++ default constructor.
       
   225         */
       
   226         CMFVideoPreviewHandler();
       
   227 	
       
   228         /**
       
   229         * By default Symbian OS constructor is private.
       
   230         */
       
   231         void ConstructL();
       
   232 
       
   233 	public:
       
   234         void PlayL();
       
   235         void Stop();
       
   236         TBool IsPlaying();
       
   237         void SetDisplayWindowL();
       
   238 
       
   239     
       
   240     private:
       
   241         TInt VolumeRamp();
       
   242         void SetRingingType( TInt aRingingType );
       
   243         TInt ConvertVolume( TInt aVolume );
       
   244         void Cancel();
       
   245         void GetRectData( TRect aRect, TDes& aText );
       
   246         
       
   247 
       
   248         
       
   249     private:
       
   250         static TInt VolumeRampTimerCallback( TAny* aObj );
       
   251         
       
   252 	private:	// from MVidePlayerUtilityObserver
       
   253 		void MvpuoOpenComplete( TInt aError );
       
   254 		void MvpuoFrameReady( CFbsBitmap& aFrame, TInt aError );
       
   255 		void MvpuoPlayComplete( TInt aError );
       
   256 		void MvpuoEvent( const TMMFEvent& aEvent );
       
   257 		void MvpuoPrepareComplete( TInt aError );
       
   258         
       
   259         
       
   260     private:
       
   261         
       
   262     	//  video player
       
   263     	CVideoPlayerUtility* iVideoPlayer;
       
   264         
       
   265         // ascending volume timer
       
   266         CPeriodic* iVolumeRampTimer;
       
   267         
       
   268         // Ascending volume
       
   269         TInt iRampedVolume;
       
   270     };
       
   271     
       
   272 
       
   273 
       
   274 /**
       
   275 * CMFAudioPreviewHandler
       
   276 * 
       
   277 * For previewing audio files (tones, music and recordings).
       
   278 *
       
   279 */
       
   280 NONSHARABLE_CLASS (CMFAudioPreviewHandler) : public CMFPreviewHandlerBase,
       
   281                                         public MDrmAudioPlayerCallback,
       
   282                                         public MMdaAudioToneObserver
       
   283 
       
   284     {
       
   285     public:// Constructors and destructor
       
   286 
       
   287         /**
       
   288         * Two-phased constructor.
       
   289         */
       
   290 		static CMFAudioPreviewHandler* NewL();
       
   291         
       
   292         /**
       
   293         * Destructor.
       
   294         */
       
   295         virtual ~CMFAudioPreviewHandler();
       
   296     
       
   297     private:
       
   298 
       
   299         /**
       
   300         * C++ default constructor.
       
   301         */
       
   302         CMFAudioPreviewHandler();
       
   303 	
       
   304         /**
       
   305         * By default Symbian OS constructor is private.
       
   306         */
       
   307         void ConstructL();
       
   308 
       
   309 	public:
       
   310         void PlayL();
       
   311         void Stop();
       
   312         TBool IsPlaying();
       
   313 
       
   314     private:
       
   315         void Cancel();
       
   316         void SetAudioRingingType( TInt aRingingType );
       
   317         void SetToneRingingType( TInt aRingingType );
       
   318         TInt ConvertVolume( TInt aVolume );
       
   319         
       
   320         
       
   321     private:  // from MMdaAudioToneObserver
       
   322 	    virtual void MatoPrepareComplete( TInt aError );
       
   323 	    virtual void MatoPlayComplete( TInt aError );
       
   324 
       
   325     private:  // from MDrmAudioPlayerCallback
       
   326         void MdapcInitComplete( TInt aError, const TTimeIntervalMicroSeconds& aDuration );
       
   327         void MdapcPlayComplete( TInt aError );
       
   328 
       
   329     private:
       
   330         // audio player
       
   331         CDrmPlayerUtility* iAudioPlayer;
       
   332 
       
   333 		/// Audioplayer status
       
   334         TPlayerStatus iAudioPlayerStatus;
       
   335 
       
   336 		/// toneplayer
       
   337         CMdaAudioToneUtility* iTonePlayer;
       
   338 
       
   339 		/// Toneplayer status
       
   340         TPlayerStatus iTonePlayerStatus;
       
   341         
       
   342         // plugin for playing 3D effects
       
   343         C3DRingingToneInterface* i3dRingingTonePlugin;
       
   344         
       
   345     };
       
   346     
       
   347 
       
   348     
       
   349 
       
   350 
       
   351 #endif  // MEDIAFILEPREVIEW_H
       
   352 
       
   353 // End of File