messagingappbase/msgeditor/mediacontrolinc/MsgVideoControl.h
changeset 79 2981cb3aa489
parent 0 72b543305e3a
equal deleted inserted replaced
25:84d9eb65b26f 79:2981cb3aa489
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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 *       MsgEditor video media control - a Message Editor Base control.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef MSGVIDEOCONTROL_H
       
    22 #define MSGVIDEOCONTROL_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <msgmediacontrol.h>
       
    26 #include <videoplayer.h>
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // MACROS
       
    31 
       
    32 // DATA TYPES
       
    33 
       
    34 // FUNCTION PROTOTYPES
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 
       
    38 class CVideoPlayerUtility;
       
    39 class CPeriodic;
       
    40 class CMsgVideoAreaControl;
       
    41 
       
    42 // CLASS DECLARATION
       
    43 
       
    44 // ==========================================================
       
    45 
       
    46 /**
       
    47 * Message Editor Base control handling images in MMS
       
    48 */
       
    49 class CMsgVideoControl : public CMsgMediaControl,
       
    50                          public MVideoPlayerUtilityObserver,
       
    51                          public MVideoLoadingObserver,                         
       
    52                          public MCoeControlHitTest
       
    53     {
       
    54     public:  // Constructor and destructor
       
    55         
       
    56         
       
    57         enum TVideoFlags
       
    58             {
       
    59             ENoPlayback = 0x1 // Video control is not used for video playback
       
    60             };
       
    61         
       
    62         /**
       
    63         * Two-phased constructor.
       
    64         * @param aParent parent control
       
    65         * @param aFlags display flags - by default editor state
       
    66         * @param aPlaybackSupported Indicates whether control 
       
    67         * @return new object
       
    68         */
       
    69         IMPORT_C static CMsgVideoControl* NewL( CMsgEditorView& aParent,
       
    70                                                 MMsgAsyncControlObserver* aObserver,
       
    71                                                 TMdaPriority aPriority,
       
    72                                                 TMdaPriorityPreference  aPreference,
       
    73                                                 TInt aFlags = 0 );
       
    74 
       
    75         /**
       
    76         * Destructor.
       
    77         */
       
    78         virtual ~CMsgVideoControl();
       
    79 
       
    80     public:
       
    81 
       
    82         /**
       
    83         * From MMsgAsyncControl
       
    84         *
       
    85         * Loads the video
       
    86         *
       
    87         * @param aFileHandle image file handle - expected to be valid videoclip
       
    88         */
       
    89         void LoadL( RFile& aFileHandle );
       
    90         
       
    91         /**
       
    92         * From MMsgAsyncControl
       
    93         *
       
    94         * Cancels the asyncronous operation if it is pending.
       
    95         */         
       
    96         void Cancel();
       
    97         
       
    98         /**
       
    99         * From MMsgAsyncControl
       
   100         *
       
   101         * Close video.
       
   102         */
       
   103         void Close();
       
   104         
       
   105         /**
       
   106         * From CMsgMediaControl    
       
   107         *
       
   108         * Start video.
       
   109         * Video must be loaded AND prepared before calling this!
       
   110         */
       
   111         void PlayL();
       
   112 
       
   113         /**
       
   114         * From CMsgMediaControl    
       
   115         *
       
   116         * Stop video.
       
   117         */
       
   118         void Stop();
       
   119 
       
   120         /**
       
   121         * From CMsgMediaControl    
       
   122         *
       
   123         * Pause video.
       
   124         */
       
   125         void PauseL();
       
   126         
       
   127         /**
       
   128         * Gives the resolution of the video in display
       
   129         * @return scaled resolution
       
   130         */
       
   131         IMPORT_C TSize VideoResolutionL() const;
       
   132         
       
   133         /**
       
   134         * Returns ETrue if control is off screen.
       
   135         */
       
   136         IMPORT_C TBool IsOffScreen() const;
       
   137 
       
   138         /**
       
   139         * Check if video clip has audio in.
       
   140         * @return ETrue if there is audio.
       
   141         */
       
   142         IMPORT_C TBool HasAudioL() const;
       
   143 
       
   144         /**
       
   145         * Set volume level
       
   146         * @param aVolume    Volume level wanted range 0..10.
       
   147         * @return           Volume level after adjustment.
       
   148         */
       
   149         IMPORT_C void SetVolumeL( TInt aVolume );
       
   150 
       
   151         /**
       
   152         * Get current volume level
       
   153         * @return   Current volume level
       
   154         */
       
   155         inline TInt Volume() const;
       
   156 
       
   157         /**
       
   158         * Get maximum volume level
       
   159         * @return   Maximum volume level
       
   160         */
       
   161         inline TInt MaxVolume() const;
       
   162 
       
   163         /**
       
   164         * Set continuation property for focus movement.
       
   165         * @param aContinue  Boolean value to decide whether playing
       
   166         *                   is continued when focus comes back to region.
       
   167         */
       
   168         inline void ContinueOnFocus( TBool aContinue );
       
   169         
       
   170         /**
       
   171         * Returns ETrue if video file contains video stream.
       
   172         * @return ETrue if video stream is present on video file.
       
   173         */
       
   174         inline TBool HasVideoStream() const;
       
   175 
       
   176     public: // From CCoeControl
       
   177 
       
   178         /**
       
   179         * Draw Control
       
   180         * From CCoeControl
       
   181         */
       
   182         void Draw( const TRect& aRect ) const;
       
   183         
       
   184         /**
       
   185         * Handles resource change events.
       
   186         * From CCoeControl
       
   187         */
       
   188         void HandleResourceChange( TInt aType );
       
   189 
       
   190     public: // Functions from MVideoPlayerUtilityObserver
       
   191     
       
   192         /** 
       
   193         * From MVideoPlayerUtilityObserver 
       
   194         */
       
   195         void MvpuoOpenComplete( TInt aError );
       
   196 
       
   197         /** 
       
   198         * From MVideoPlayerUtilityObserver 
       
   199         */
       
   200         void MvpuoPrepareComplete( TInt aError );
       
   201 
       
   202         /** 
       
   203         * From MVideoPlayerUtilityObserver 
       
   204         */
       
   205         void MvpuoFrameReady( CFbsBitmap& aFrame ,TInt aError );
       
   206 
       
   207         /** 
       
   208         * From MVideoPlayerUtilityObserver 
       
   209         */
       
   210         void MvpuoPlayComplete( TInt aError );
       
   211         
       
   212         /** 
       
   213         * From MVideoPlayerUtilityObserver 
       
   214         */
       
   215         void MvpuoEvent( const TMMFEvent& aEvent );
       
   216     
       
   217         /** 
       
   218         * From MVideoPlayerUtilityObserver 
       
   219         */
       
   220         void MvloLoadingStarted();
       
   221     
       
   222         /** 
       
   223         * From MVideoPlayerUtilityObserver 
       
   224         */
       
   225         void MvloLoadingComplete();
       
   226 
       
   227     public: // from CMsgBaseControl
       
   228 
       
   229         /**
       
   230         * Calculates and sets the size of the control and returns new size as
       
   231         * reference aSize.
       
   232         * From CMsgBaseControl
       
   233         */
       
   234         void SetAndGetSizeL( TSize& aSize );
       
   235 
       
   236         /**
       
   237         * Resets (= clears) contents of the control.
       
   238         * From CMsgBaseControl
       
   239         */
       
   240         void Reset();
       
   241 
       
   242         /**
       
   243         * Called when size is changed.
       
   244         * From CMsgBaseControl
       
   245         */
       
   246         void SizeChanged();
       
   247     
       
   248     public: // from MCoeControlHitTest
       
   249     
       
   250         /**
       
   251         * Evaluates whether control is "hit" by touch event.
       
   252         */
       
   253         TBool HitRegionContains( const TPoint& aPoint, const CCoeControl& aControl ) const;
       
   254         
       
   255     public:
       
   256 
       
   257         /**
       
   258         * Callback for CIdle
       
   259         */
       
   260         static TInt DelayedPlay( TAny* aThis );
       
   261 
       
   262     protected: // from CCoeControl
       
   263 
       
   264         /**
       
   265         * Called when focus is changing
       
   266         * From CCoeControl
       
   267         */
       
   268         void FocusChanged( TDrawNow aDrawNow );
       
   269 
       
   270     private:
       
   271         
       
   272         /**
       
   273         * C++ default constructor.
       
   274         */
       
   275         CMsgVideoControl();
       
   276         
       
   277         /**
       
   278         * constructor
       
   279         * @param aFlags
       
   280         */
       
   281         CMsgVideoControl( MMsgBaseControlObserver& aBaseControlObserver,
       
   282                           TMdaPriority aPriority,
       
   283                           TMdaPriorityPreference  aPreference,
       
   284                           TInt aFlags );
       
   285             
       
   286         /**
       
   287         * By default Symbian constructor is private.
       
   288         */
       
   289         void ConstructL( CMsgEditorView& aParent, MMsgAsyncControlObserver* aObserver );
       
   290 
       
   291         /**
       
   292         * Sets the correct size for video frame.
       
   293         */
       
   294         void SetVideoFrameSizeL();
       
   295 
       
   296         /**
       
   297         * Handles callback or other completion of an operation.
       
   298         * Calls DoHandleCallbackL
       
   299         * @param aError     error code
       
   300         * @param aNewState  new state assigned to iState, if aError is KErrNone:
       
   301         *                   if aError indicates real error, state is not assigned
       
   302         */
       
   303         void HandleCallback( TInt aError, 
       
   304                              TMsgAsyncControlState aNewState = EMsgAsyncControlStateReady);
       
   305         
       
   306         /**
       
   307         * Callback function to do inactivity timer resetting.
       
   308         */
       
   309         static TInt DoResetInactivityTimer( TAny* aObject );
       
   310         
       
   311         /**
       
   312         * Updates scaling factor
       
   313         */
       
   314         void UpdateScaleFactorL();
       
   315         
       
   316     private: //Data
       
   317 
       
   318         CVideoPlayerUtility*    iVideoPlayer;
       
   319         TRect                   iMaxVideoArea;
       
   320         TBool                   iContinueOnFocus;
       
   321         TInt                    iVolume;
       
   322         TInt                    iMaxVolume;
       
   323         
       
   324         CIdle*                  iIdle;
       
   325         
       
   326         RFile                   iVideoFile;
       
   327         TSize                   iOriginalSize;
       
   328         
       
   329         TInt                    iFlags;
       
   330         
       
   331         CPeriodic*              iTimer;        
       
   332         TBool                   iHasVideo;
       
   333         
       
   334         TRect                   iVideoFrameArea;
       
   335         
       
   336         TMdaPriority            iPriority;
       
   337         TMdaPriorityPreference  iPreference;
       
   338         
       
   339         TReal                   iScaleFactor;
       
   340         CMsgVideoAreaControl*	iVideoAreaControl;
       
   341     };
       
   342 
       
   343 
       
   344 #include <msgvideocontrol.inl>
       
   345 
       
   346 #endif // MSGVIDEOCONTROL_H