videoplayback/hbvideoplaybackview/inc/mpxvideoplaybackcontrolscontroller.h
changeset 44 518105d52e45
parent 42 17f382c040b1
child 49 824471cb468a
equal deleted inserted replaced
42:17f382c040b1 44:518105d52e45
     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:  Implementation of MPXVideoPlaybackControlsController
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: da1mmcf#19 %
       
    19 
       
    20 
       
    21 
       
    22 #ifndef MPXVIDEOPLAYBACKCONTROLSCONTROLLER_H_
       
    23 #define MPXVIDEOPLAYBACKCONTROLSCONTROLLER_H_
       
    24 
       
    25 // INCLUDES
       
    26 #include <QObject>
       
    27 #include <QPixmap>
       
    28 
       
    29 #include <mpxplaybackframeworkdefs.h>
       
    30 
       
    31 #include "mpxvideo_debug.h"
       
    32 #include "mpxvideoplaybackcontrol.hrh"
       
    33 #include "mpxcommonvideoplaybackview.hrh"
       
    34 #include "mpxvideoplaybackviewfiledetails.h"
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class QTimer;
       
    38 class QString;
       
    39 class HbAction;
       
    40 class ThumbnailManager;
       
    41 class HbVolumeSliderPopup ;
       
    42 class CMPXVideoViewWrapper;
       
    43 class HbVideoBasePlaybackView;
       
    44 class QMPXVideoPlaybackControlPolicy;
       
    45 class QMPXVideoPlaybackDocumentLoader;
       
    46 class QMPXVideoPlaybackFullScreenControl;
       
    47 class QMPXVideoPlaybackControlsController;
       
    48 class QMPXVideoPlaybackControlConfiguration;
       
    49 class VideoServices;
       
    50 
       
    51 
       
    52 // DATA TYPES
       
    53 
       
    54 enum TMPXTimerAction
       
    55 {
       
    56     EMPXTimerCancel,
       
    57     EMPXTimerReset
       
    58 };
       
    59 
       
    60 enum TThumbNailState
       
    61 {
       
    62     EThumbNailEmpty,
       
    63     EThumbNailNotAvailable,
       
    64     EThumbNailRequsted,
       
    65     EThumbNailSet
       
    66 };
       
    67 
       
    68 enum TPlaybackViewMode
       
    69 {
       
    70     EFullScreenView,
       
    71     EDetailsView,
       
    72     EAudioOnlyView
       
    73 };
       
    74 
       
    75 const int KMPXControlsTimeOut = 4000;
       
    76 const int KMPXRNLogoTimeOut = 600;
       
    77 
       
    78 const QString KMPXPLAYBACKVIEW_XML = ":/hbvideoplaybackview/hbvideoplaybackview.docml";
       
    79 
       
    80 
       
    81 // CLASS DECLARATION
       
    82 
       
    83 class QMPXVideoPlaybackControlsController : public QObject
       
    84 {
       
    85     Q_OBJECT
       
    86 
       
    87     public:
       
    88 
       
    89         /**
       
    90         * constructor.
       
    91         */
       
    92         QMPXVideoPlaybackControlsController(
       
    93                 HbVideoBasePlaybackView *view,
       
    94                 CMPXVideoViewWrapper *viewWrapper,
       
    95                 QMPXVideoPlaybackViewFileDetails *details );
       
    96 
       
    97         /**
       
    98         * Destructor.
       
    99         */
       
   100         virtual ~QMPXVideoPlaybackControlsController();
       
   101 
       
   102     public:
       
   103 
       
   104         /**
       
   105         * Handle event from container
       
   106         */
       
   107         void handleEvent( TMPXVideoPlaybackControlCommandIds event, int value = 0 );
       
   108 
       
   109         /**
       
   110         * Command handling function.
       
   111         * Call HandleCommandL() of container
       
   112         */
       
   113         void handleCommand( TMPXVideoPlaybackViewCommandIds command, int value = 0 );
       
   114 
       
   115         /*
       
   116         * Return ETrue if TV-out cable gets connected
       
   117         */
       
   118         inline bool isTvOutConnected();
       
   119 
       
   120         /**
       
   121         * Reset or cancel timers for the controls
       
   122         */
       
   123         void resetDisappearingTimers( TMPXTimerAction timerAction );
       
   124 
       
   125         /**
       
   126         * Return state
       
   127         */
       
   128         inline TMPXPlaybackState state();
       
   129 
       
   130         /**
       
   131         * Return file details
       
   132         */
       
   133         inline QMPXVideoPlaybackViewFileDetails* fileDetails();
       
   134 
       
   135         //
       
   136         //  Add the file details to the controls controller when available
       
   137         //
       
   138         void addFileDetails( QMPXVideoPlaybackViewFileDetails* details );
       
   139 
       
   140         inline QMPXVideoPlaybackDocumentLoader* layoutLoader();
       
   141 
       
   142         inline HbVideoBasePlaybackView* view();
       
   143 
       
   144         void updateVideoRectDone();
       
   145 
       
   146         TPlaybackViewMode viewMode();
       
   147 
       
   148         void changeViewMode( TPlaybackViewMode viewMode, bool transitionEffect = true );
       
   149 
       
   150         inline bool isAttachOperation();
       
   151 
       
   152         bool isRNLogoBitmapInControlList();
       
   153 
       
   154     private:
       
   155         /**
       
   156         * Initialize controller
       
   157         */
       
   158         void initializeController();
       
   159 
       
   160         /**
       
   161         * Update controls
       
   162         */
       
   163         void handleStateChange( TMPXPlaybackState newState );
       
   164 
       
   165         /**
       
   166         * Show Controls and reset the timers
       
   167         */
       
   168         void showControls();
       
   169 
       
   170         /**
       
   171         * Return ETrue if any control is visible
       
   172         */
       
   173         bool isVisible();
       
   174 
       
   175         /**
       
   176         * Append a control based on control index
       
   177         */
       
   178         void appendControl( TMPXVideoPlaybackControls controlIndex );
       
   179 
       
   180         /**
       
   181         * Set changed volume
       
   182         */
       
   183         void volumeChanged( int volume );
       
   184 
       
   185         /**
       
   186         * Set changed duration
       
   187         */
       
   188         void durationChanged( int duration);
       
   189 
       
   190         /**
       
   191         * Set changed position
       
   192         */
       
   193         void positionChanged( int position );
       
   194 
       
   195         /**
       
   196         * Set changed position
       
   197         */
       
   198         void aspectRatioChanged( int aspectRatio );
       
   199 
       
   200         /*
       
   201          *  Sets the download size on the progress bar
       
   202          */
       
   203         void setDownloadSize( int size );
       
   204 
       
   205         /*
       
   206          *  Updates the download ratio on the progress bar
       
   207          */
       
   208         void updateDownloadPosition( int newSize );
       
   209 
       
   210         /**
       
   211         * Set changed state on the controls
       
   212         */
       
   213         void updateState();
       
   214 
       
   215         /**
       
   216         * Check whether this clip is real format or not
       
   217         */
       
   218         bool realFormat( QString filename );
       
   219 
       
   220         /**
       
   221         * Check whether this clip is real format or not for streaming/live streaming
       
   222         */
       
   223         bool realFormatForStreaming( const TDesC& des );
       
   224 
       
   225         /**
       
   226         * Check whether this clip is real format or not for local/progressive donwload
       
   227         */
       
   228         bool realFormatForLocal();
       
   229         
       
   230         /**
       
   231         * Handle errors
       
   232         */
       
   233         void handleErrors(); 
       
   234         
       
   235         /**
       
   236 		* Return true if control is visible
       
   237 		*/
       
   238 		bool isSoftKeyVisible();
       
   239 
       
   240         /**
       
   241         * Handle tvout connected/disconnected event
       
   242         */
       
   243 		void handleTvOutEvent( bool connected, 
       
   244 		                       TMPXVideoPlaybackControlCommandIds event );
       
   245 
       
   246 		void updateVideoRect(  bool transitionEffect = true );
       
   247 
       
   248 		void showVolumeControls();
       
   249 
       
   250 		void setDefaultBitmap();
       
   251 
       
   252 		void generateThumbNail();
       
   253 
       
   254     signals:
       
   255 
       
   256         /**
       
   257         * Signals the file path of the current video to VideoServices
       
   258         *
       
   259         * @param filePath of the video
       
   260         */
       
   261         void attachVideoPath( const QString& );
       
   262 
       
   263     private slots:
       
   264         void hideAllControls();
       
   265         void skipToNextVideoItem();
       
   266         void skipToPreviousVideoItem();
       
   267         void handleTappedOnScreen();
       
   268         void handleThumbnailReady( QPixmap tnData, void *internal , int id, int error );
       
   269         void controlsListUpdated();
       
   270         void attachVideo();
       
   271         void sendVideo();
       
   272         void handleRNLogoVisibleChanged();
       
   273         void handleRNLogoTimeout();
       
   274         void handleOrientationChanged( Qt::Orientation orientation );
       
   275 
       
   276     private:
       
   277         HbVideoBasePlaybackView                   *mView;
       
   278         CMPXVideoViewWrapper                      *mViewWrapper;
       
   279         QMPXVideoPlaybackViewFileDetails          *mFileDetails;
       
   280 
       
   281         QList<QMPXVideoPlaybackFullScreenControl*> mControls;
       
   282 
       
   283         QMPXVideoPlaybackControlPolicy            *mControlsPolicy;
       
   284         QMPXVideoPlaybackControlConfiguration     *mControlsConfig;
       
   285 
       
   286         QTimer                                    *mControlsTimer;
       
   287         QTimer                                    *mRNLogoTimer;
       
   288 
       
   289         QMPXVideoPlaybackDocumentLoader           *mLoader;
       
   290         HbVolumeSliderPopup                       *mVolumeControl;
       
   291 
       
   292         ThumbnailManager                          *mThumbnailManager;
       
   293         VideoServices                             *mVideoServices;
       
   294 
       
   295         bool                                       mViewTransitionIsGoingOn;
       
   296         bool                                       mIsAttachOperation;
       
   297         
       
   298         TThumbNailState                            mThumbNailState;
       
   299 
       
   300         TMPXPlaybackState                          mState;
       
   301         TPlaybackViewMode                          mViewMode;
       
   302         Qt::Orientation                            mOrientation;
       
   303 };
       
   304 
       
   305 // INLINE METHODS
       
   306 // -------------------------------------------------------------------------------------------------
       
   307 //   QMPXVideoPlaybackControlsController::state
       
   308 // -------------------------------------------------------------------------------------------------
       
   309 //
       
   310 inline
       
   311 TMPXPlaybackState QMPXVideoPlaybackControlsController::state()
       
   312 {
       
   313     return mState;
       
   314 }
       
   315 
       
   316 // -------------------------------------------------------------------------------------------------
       
   317 //   QMPXVideoPlaybackControlsController::fileDetails
       
   318 // -------------------------------------------------------------------------------------------------
       
   319 //
       
   320 inline
       
   321 QMPXVideoPlaybackViewFileDetails* QMPXVideoPlaybackControlsController::fileDetails()
       
   322 {
       
   323     return mFileDetails;
       
   324 }
       
   325 
       
   326 // -------------------------------------------------------------------------------------------------
       
   327 //   QMPXVideoPlaybackControlsController::isTvOutConnected
       
   328 // -------------------------------------------------------------------------------------------------
       
   329 //
       
   330 inline
       
   331 bool QMPXVideoPlaybackControlsController::isTvOutConnected()
       
   332 {
       
   333     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::isTvOutConnected(%d)"),
       
   334             mFileDetails->mTvOutConnected);
       
   335 
       
   336     return mFileDetails->mTvOutConnected;
       
   337 }
       
   338 
       
   339 // -------------------------------------------------------------------------------------------------
       
   340 //   QMPXVideoPlaybackControlsController::layoutLoader
       
   341 // -------------------------------------------------------------------------------------------------
       
   342 //
       
   343 inline
       
   344 QMPXVideoPlaybackDocumentLoader* QMPXVideoPlaybackControlsController::layoutLoader()
       
   345 {
       
   346     return mLoader;
       
   347 }
       
   348 
       
   349 // -------------------------------------------------------------------------------------------------
       
   350 //   QMPXVideoPlaybackControlsController::view
       
   351 // -------------------------------------------------------------------------------------------------
       
   352 //
       
   353 inline
       
   354 HbVideoBasePlaybackView* QMPXVideoPlaybackControlsController::view()
       
   355 {
       
   356     return mView;
       
   357 }
       
   358 
       
   359 // -------------------------------------------------------------------------------------------------
       
   360 //   QMPXVideoPlaybackControlsController::viewMode
       
   361 // -------------------------------------------------------------------------------------------------
       
   362 //
       
   363 inline
       
   364 TPlaybackViewMode QMPXVideoPlaybackControlsController::viewMode()
       
   365 {
       
   366     return mViewMode;
       
   367 }
       
   368 
       
   369 // -------------------------------------------------------------------------------------------------
       
   370 // QMPXVideoPlaybackControlsController::isAttachOperation
       
   371 // -------------------------------------------------------------------------------------------------
       
   372 //
       
   373 inline
       
   374 bool QMPXVideoPlaybackControlsController::isAttachOperation()
       
   375 {        
       
   376     MPX_DEBUG(_L("QMPXVideoPlaybackControlsController::isAttachOperation() ret %d"), 
       
   377         mIsAttachOperation );
       
   378     
       
   379     return mIsAttachOperation;
       
   380 }
       
   381 
       
   382 #endif /*MPXVIDEOPLAYBACKCONTROLSCONTROLLER_P_H_*/
       
   383 
       
   384 // End of File