browserplugins/browseraudiovideoplugin/inc/BavpController.h
branchRCL_3
changeset 65 8e6fa1719340
equal deleted inserted replaced
64:6385c4c93049 65:8e6fa1719340
       
     1 /*
       
     2 * Copyright (c) 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 the License "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:  Base Controller class for handling browser requests to play
       
    15 *                audio or video.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef BAVPCONTROLLER_H
       
    21 #define BAVPCONTROLLER_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <coecntrl.h>
       
    26 #include <e32property.h>                // RProperty class
       
    27 #include "FeatMgr.h"
       
    28 
       
    29 #include "BrowserAudioVideoPlugin.hrh"
       
    30 #include "BavpVolumeObserver.h"         // Volume Observer class
       
    31 #include "BavpVolumeHandler.h"
       
    32 #include "BavpHwKeyEvents.h"            // Hardware Key Events
       
    33 #include "BavpClipInfo.h"               // Clip info
       
    34 #include <rt_gesturehelper.h>
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class RFs;
       
    38 class CBavpPlugin;
       
    39 class MBavpView;
       
    40 
       
    41 // CONSTANTS
       
    42 // Does this build include Side Volume Keys support
       
    43 #define HAS_HW_VOLUME_KEYS ( FeatureManager::FeatureSupported( KFeatureIdSideVolumeKeys ) )
       
    44 
       
    45 // Used to walk the content's meta data
       
    46 _LIT(KBavpTrue, "1");
       
    47 _LIT(KBavpFalse, "0");
       
    48 _LIT(KBavpLiveStream, "LiveStream");
       
    49 _LIT(KBavpSeekable, "Seekable");
       
    50 
       
    51 // ROP controller UID, ?? Helix UID ??
       
    52 const TUid KRopControllerUid =
       
    53     {
       
    54     0x101F8514
       
    55     };
       
    56 
       
    57 // The Audio or Video player state
       
    58 enum TAudioVideoState
       
    59     {
       
    60     EBavpNone,                  // Player is idle or not created yet
       
    61     EBavpBuffering,             // Loading the content
       
    62     EBavpPlaying,               // Playing the content
       
    63     EBavpPlayComplete,          // Done playing the content (end)
       
    64     EBavpStopped,               // User stopped the content
       
    65     EBavpPaused,                // User paused the content
       
    66     EBavpBadContent,            // Bad content or network error encountered
       
    67     EBavpFastForwarding,        // Fast Forwarding the content
       
    68     EBavpFastForwardComplete,   // Fast Forward reached end of content
       
    69     EBavpRewinding,             // Rewinding the content
       
    70     EBavpRewindComplete         // Rewind reached beginning of content
       
    71     };
       
    72 
       
    73 // Use these values for fast-forwarding and rewinding
       
    74 const TInt KSkipToPosition = 2*1000*1000;   // 2 seconds
       
    75 const TInt KUpdateFrequency = 400*1000;     // 400 milliseconds
       
    76 const TInt KInitialDelay = 600*1000;        // 600 milliseconds
       
    77 
       
    78 // CLASS DECLARATIONS
       
    79 
       
    80 /**
       
    81 *  CBavpController.
       
    82 *  Controller class for handling browser requests to play audio or video.
       
    83 *  @lib npBrowserAudioVideoPlugin.lib
       
    84 *  @since 3.2
       
    85 */
       
    86 class CBavpController : public CActive,
       
    87                         public MBavpVolumeObserver,
       
    88                         public MBavpHwKeyEventsObserver,
       
    89                         public MCenRepNotifyHandlerCallback
       
    90     {
       
    91     public:    // Constructors and destructor
       
    92 
       
    93         /**
       
    94         * C++ default constructor.
       
    95         */
       
    96         CBavpController( MBavpView* aView, TUint aAccessPtId );
       
    97 
       
    98         /**
       
    99         * Destructor.
       
   100         */
       
   101         virtual ~CBavpController();
       
   102 
       
   103     public: // New pure virtual methods
       
   104 
       
   105         /**
       
   106         * Handles request to play the audio or video content
       
   107         * @since 3.2
       
   108         * @param none
       
   109         * @return void
       
   110         */
       
   111         virtual void PlayAudioVideoL() = 0;
       
   112 
       
   113         /**
       
   114         * Handles request to stop playing the content
       
   115         * @param none
       
   116         * @return void
       
   117         */
       
   118         virtual void Stop() = 0;
       
   119 
       
   120         /**
       
   121         * Handles request to play content
       
   122         * @param none
       
   123         * @return void
       
   124         */
       
   125         virtual void PlayL() = 0;
       
   126 
       
   127         /**
       
   128         * Handles request to pause playing content
       
   129         * @param none
       
   130         * @return void
       
   131         */
       
   132         virtual void PauseL() = 0;
       
   133 
       
   134         /**
       
   135         * Handles request to fast forward content
       
   136         * @param none
       
   137         * @return void
       
   138         */
       
   139         virtual void FastForwardL() = 0;
       
   140 
       
   141         /**
       
   142         * Handles request to rewind content
       
   143         * @param none
       
   144         * @return void
       
   145         */
       
   146         virtual void RewindL() = 0;
       
   147 
       
   148         /**
       
   149         * Set the volume in the player, we send volume value 0-10, this method
       
   150         * will scale before calling Player::SetVolume()
       
   151         * @param aVolume the new volume: 0(mute) - 10(max)
       
   152         * @return void
       
   153         */
       
   154         virtual void SetPlayerVolume( TInt aVolume ) = 0;
       
   155 
       
   156         /**
       
   157         * Get the current volume of the player
       
   158         * This needs to be scaled to 0-10 (CR value) before returning
       
   159         * @param none
       
   160         * @return player volume scaled: 0(mute) - 10(max)
       
   161         */
       
   162         virtual TInt GetPlayerVolume() = 0;
       
   163 
       
   164         /**
       
   165         * To get the current position of the clip
       
   166         * @since 3.2
       
   167         * @param none
       
   168         * @return TTimeIntervalMicroSeconds
       
   169         */
       
   170         virtual TTimeIntervalMicroSeconds getPositionL() = 0;
       
   171 
       
   172         /**
       
   173         * To set the position of the clip
       
   174         * @since 3.2
       
   175         * @param TTimeIntervalMicroSeconds
       
   176         * @return void
       
   177         */
       
   178         virtual void setPositionL(TTimeIntervalMicroSeconds) = 0;
       
   179         
       
   180         /**
       
   181         * Handles the incoming call
       
   182         * @param none
       
   183         * @return void
       
   184         */
       
   185         virtual void HandleInComingCallL() = 0;
       
   186 
       
   187     public: // New virtual methods
       
   188 
       
   189         /**
       
   190         * Handles Notifications from Browser
       
   191         * @since 3.2
       
   192         * @param TBool: Tell bavp plugin if Browser is in or out of focus
       
   193         * @return void
       
   194         */
       
   195         virtual void HandleBrowserNotification( TBool aBrowserFocus );
       
   196 
       
   197         /**
       
   198         * Handles the error
       
   199         * @param TInt aError: error to be handled
       
   200         * @return void
       
   201         */
       
   202         virtual void HandleError( TInt aError );
       
   203 
       
   204         /**
       
   205         * Handles the keys offered by the CCoeControl
       
   206         * @since 3.2
       
   207         * @param TInt aKeyEvent: Which key pressed
       
   208         * @param TInt aEventCode: Key down, key up...
       
   209         * @return TKeyResponse: Was the key consumed
       
   210         */
       
   211         virtual TKeyResponse HandleKeysL( const TKeyEvent& aKeyEvent,
       
   212                                           TEventCode aType );
       
   213 
       
   214         /**
       
   215         * Handles commands from Option Menu, defined in resource files
       
   216         * @since 3.2
       
   217         * @param TBavpCommandIds aCommand:  a Command Id
       
   218         * @return void
       
   219         */
       
   220         virtual void HandleCommandL( TBavpCommandIds aCommand );
       
   221 
       
   222         /**
       
   223         * Called by CBavpView to CBavpPlugin whenever Bavp focus changes
       
   224         * @since 3.2
       
   225         * @param aFocus True if plugin has focus
       
   226         * @return none
       
   227         */
       
   228         virtual void BavpFocusChanged( TBool aFocus );
       
   229         
       
   230         virtual TBool HandleGesture(RT_GestureHelper::TGestureEvent *gesture); 
       
   231 
       
   232     public: // New methods
       
   233 
       
   234         /**
       
   235         * Sets volume using the value from <object> attribute
       
   236         * @since 3.2
       
   237         * @param aVolume
       
   238         * @return void
       
   239         */
       
   240         void SetVolumeFromAttribute( TInt aVolume );
       
   241 
       
   242         /**
       
   243         * Sets loop using the value from <object> attribute
       
   244         * @since 3.2
       
   245         * @param aLoopValue: The number of times to play file
       
   246         * @param aInfiniteFlag: Set to ETrue if play infinitely, we use a loop
       
   247         *        countValue = 50 for infinite and always set this to EFalse
       
   248         * @return void
       
   249         */
       
   250         void SetLoopFromAttribute( TInt aLoopValue, TBool aInfiniteFlag );
       
   251 
       
   252         /**
       
   253         * Refresh the coordinates of the rectangle to be drawn
       
   254         * @since 3.2
       
   255         * @param none
       
   256         * @return void
       
   257         */
       
   258         virtual void RefreshRectCoordinatesL();
       
   259 
       
   260         /**
       
   261         * Sets original file name (used for scripting functionality)
       
   262         * @since 3.2
       
   263         * @param originalFilename
       
   264         * @return void
       
   265         */
       
   266         void SetOriginalFileName( const TDesC* originalFileName );
       
   267 
       
   268 
       
   269         /**
       
   270         * Sets the mime type(used for scripting functionality)
       
   271         * @since 3.2
       
   272         * @param mime type
       
   273         * @return void
       
   274         */
       
   275         void SetMimeType( const TDesC8* mimetype );
       
   276 
       
   277     public: // New inline methods
       
   278 
       
   279         /**
       
   280         * Bavp has focus
       
   281         * @since 3.2
       
   282         * @param void
       
   283         * @return : TBool 0 or 1 indicating the focus
       
   284         */
       
   285         inline TBool BavpHasFocus()
       
   286             {
       
   287             return iBavpHasFocus;
       
   288             }
       
   289 
       
   290         /**
       
   291         * Returns the video player plugin current state
       
   292         * @since 3.2
       
   293         * @param none
       
   294         * @return TVideoState
       
   295         */
       
   296         inline TAudioVideoState State()
       
   297             {
       
   298             return iCurrentState;
       
   299             }
       
   300 
       
   301         /**
       
   302         * returns ETrue is the volume is muted
       
   303         * @param none
       
   304         * @return TBool
       
   305         */
       
   306         inline TBool IsVolumeMuted()
       
   307             {
       
   308             return ( iCurrentVolume == KCRVolumeMute );
       
   309             }
       
   310 
       
   311         /**
       
   312         * Returns ETrue is this is a video clip
       
   313         * @since 3.2
       
   314         * @param none
       
   315         * @return TBool
       
   316         */
       
   317         inline TBool IsClipVideo()
       
   318             {
       
   319             return iClipInfo->iVideoTrack;
       
   320             }
       
   321 
       
   322         /**
       
   323         * Returns ETrue is the clip is seekable.
       
   324         * @param none
       
   325         * @return TBool
       
   326         */
       
   327         inline TBool IsClipSeekable()
       
   328            {
       
   329            return iClipInfo->iSeekable;
       
   330            }
       
   331 
       
   332         /**
       
   333         * returns ETrue is the content is local media file.
       
   334         * Local files can be FF and Rewind
       
   335         * @param none
       
   336         * @return TBool
       
   337         */
       
   338         inline TBool IsClipLocalMedia()
       
   339             {
       
   340             return ( iClipInfo->iMediaType == ELocalVideoFile ||
       
   341                      iClipInfo->iMediaType == ELocalAudioFile );
       
   342             }
       
   343 
       
   344         /**
       
   345         * Returns TRUE if the display is on full screen, otherwise FALSE
       
   346         * @since 3.2
       
   347         * @param none
       
   348         * @return TBool
       
   349         */
       
   350         inline TBool IsClipFullScreen()
       
   351             {
       
   352             return iClipInfo->iInFullScreenMode;
       
   353             }
       
   354 
       
   355         /**
       
   356         * Returns TRUE if the content is being fast-forwarded,
       
   357         * otherwise FALSE
       
   358         * @since 3.2
       
   359         * @param none
       
   360         * @return TBool
       
   361         */
       
   362         inline TBool IsClipFastForwarding()
       
   363             {
       
   364             return ( iCurrentState == EBavpFastForwarding );
       
   365             }
       
   366 
       
   367         /**
       
   368         * Returns TRUE if the content is being rewound,
       
   369         * otherwise FALSE
       
   370         * @since 3.2
       
   371         * @param none
       
   372         * @return TBool
       
   373         */
       
   374         inline TBool IsClipRewinding()
       
   375             {
       
   376             return ( iCurrentState == EBavpRewinding );
       
   377             }
       
   378 
       
   379         /**
       
   380         * Returns ETrue is the clip is onDemand stream.
       
   381         * @param none
       
   382         * @return TBool
       
   383         */
       
   384         inline TBool IsClipOnDemand()
       
   385             {
       
   386             return ( iClipInfo->iMediaType != ELocalVideoFile && iClipInfo->iSeekable );
       
   387             }
       
   388 
       
   389         /**
       
   390         * Returns ETrue is the clip is live stream.
       
   391         * @param none
       
   392         * @return TBool
       
   393         */
       
   394         inline TBool IsClipLive()
       
   395             {
       
   396             return ( iClipInfo->iLiveStream );
       
   397             }
       
   398 
       
   399 
       
   400         /** Returns the original filename of the clip
       
   401         * @param none
       
   402         * @return HBufC*
       
   403         */
       
   404         inline const HBufC& ClipName()
       
   405             {
       
   406             return *iOriginalFileName;
       
   407             }
       
   408 
       
   409         /** Returns the duration of the clip
       
   410         * @param none
       
   411         * @return TTimeIntervalMicroSeconds
       
   412         */
       
   413         inline TTimeIntervalMicroSeconds Duration()
       
   414             {
       
   415             return ( iClipInfo->iDurationInSeconds );
       
   416             }
       
   417 
       
   418         /** Returns the mime type of the clip
       
   419         * @param none
       
   420         * @return HBufC*
       
   421         */
       
   422         inline const HBufC8& MimeType()
       
   423             {
       
   424             return *iMimeType;
       
   425             }
       
   426 
       
   427 
       
   428 
       
   429     protected:  // New methods
       
   430 
       
   431         /**
       
   432         * By default Symbian 2nd phase constructor is private.
       
   433         * @param none
       
   434         * @return void
       
   435         */
       
   436         void BaseConstructL( TBavpMediaType aMediaType,
       
   437                              const TDesC& aFileName );
       
   438 
       
   439         /**
       
   440         * Parse the ram file
       
   441         * @param none
       
   442         * @return void
       
   443         */
       
   444         void ParseRamFileL();
       
   445 #if defined(BRDO_ASX_FF) 
       
   446     /**
       
   447 	* Parse the asx file
       
   448 	* @param none
       
   449 	* @return void
       
   450 	*/
       
   451         void ParseAsxFileL();
       
   452 #endif //BRDO_ASX_FF
       
   453         /**
       
   454         * Set the rectangle to prepare the display
       
   455         * @param TRect
       
   456         * @return TRect aRect
       
   457         */
       
   458         TRect GetClipRect( TRect aRect );
       
   459 
       
   460         /**
       
   461         * Create a query dialog for the volume setting list
       
   462         * @param none
       
   463         * @return void
       
   464         */
       
   465         void CreateVolumeListDlgL();
       
   466 
       
   467         /**
       
   468         * Check if an incoming call comes
       
   469         * @param none
       
   470         * @return TBool
       
   471         */
       
   472         TBool IsVideoOrAudioCall();
       
   473 
       
   474         /**
       
   475         * Check if other audio or video controllers are playing
       
   476         * @param none
       
   477         * @return TBool
       
   478         */
       
   479         TBool IsAnotherControllerPlaying();
       
   480 
       
   481         /**
       
   482         * Pause or Stop the other audio or video controllers from playing
       
   483         * @param none
       
   484         * @return void
       
   485         */
       
   486         void PauseOtherControllersPlaying();
       
   487 
       
   488         /**
       
   489         * Handle the error from MMF for multiple media object case
       
   490         * @param aError error code from MMF
       
   491         * @return void
       
   492         */
       
   493         void HandleMultiInstanceError();
       
   494 
       
   495     protected:  // Methods from CActive
       
   496 
       
   497         /**
       
   498         * Implements cancellation of an outstanding request.
       
   499         * @param none
       
   500         * @return void
       
   501         */
       
   502         void DoCancel() { /* Not implemented */ }
       
   503 
       
   504         /**
       
   505         * Handles an active object’s request completion event.
       
   506         * @param none
       
   507         * @return void
       
   508         */
       
   509         void RunL();
       
   510 
       
   511     public: // Methods from MBavpVolumeObserver
       
   512 
       
   513         /**
       
   514         * Updates the volume
       
   515         * From MBavpVolumeObserver
       
   516         * @since 3.2
       
   517         * @param TInt aVolume: volume value
       
   518         * @return void
       
   519         */
       
   520         void UpdateVolume( TInt aVolume );
       
   521 
       
   522     private:       // From MHwKeyEventsObserver
       
   523 
       
   524         /**
       
   525         * Called when volume level should be changed.
       
   526         * Set volume control visible into navi pane.
       
   527         * @param aVolumeChange: +1 change volume up
       
   528         *                       -1 change volume down
       
   529         */
       
   530         void BavpHwKeyVolumeChange( TInt aVolumeChange );
       
   531 
       
   532         /**
       
   533         * Called when a media hardware key (play, pause...) was presed.
       
   534         * @since 3.2
       
   535         * @param aCommand: Command ID representing Play, Pause, ...
       
   536         * @return void
       
   537         */
       
   538         // void BavpHwKeyCommand( TBavpCommandIds aCommand );
       
   539 
       
   540     public:         // Data, public
       
   541 
       
   542         // Is Bavp Plugin in focus
       
   543         TBool iBavpHasFocus;
       
   544 
       
   545         // Audio Video plugin current state
       
   546         TAudioVideoState iCurrentState;
       
   547 
       
   548         // ClipInfo contains our metadata from the MMF/Helix and content file
       
   549         CBavpClipInfo* iClipInfo;
       
   550 
       
   551         // Array of pointers of CBavpController (this) instances
       
   552         static RPointerArray<CBavpController> iBavpControllerArray;
       
   553 
       
   554     protected:      // Data
       
   555 
       
   556         // The player is initialized and ready to be used
       
   557         TBool iPlayerInitialized;
       
   558 
       
   559         // Bavp plugin previous state - used when handling interrupted
       
   560         // media, because of a phone call
       
   561         TAudioVideoState iPreCallState;
       
   562 
       
   563         // Last command
       
   564         TBavpCommandIds iLastCommand;
       
   565 
       
   566         // The number of times the audio or video file will play (loop)
       
   567         TInt iLoopCount;
       
   568 
       
   569         // Hold the initial value of loop
       
   570         TInt iInitLoopCount;
       
   571 
       
   572         // The infinite loop flag, we currently set to EFalse and use loop=50
       
   573         // if a web site requests infinite looping
       
   574         TBool iInfiniteLoopFlag;
       
   575 
       
   576         // Access pt id
       
   577         TUint iAccessPtId;
       
   578 
       
   579         // Bavp View
       
   580         MBavpView* iBavpView;
       
   581 
       
   582         // Events from Hardware Keys
       
   583         CBavpHwKeyEvents* iHwKeyEvents;
       
   584 
       
   585         // System state
       
   586         RProperty iIncomingCalls;
       
   587 
       
   588         // Volume hander
       
   589         CBavpVolumeHandler* iBavpVolumeHandler;
       
   590 
       
   591         // Current volume level
       
   592         TInt iCurrentVolume;
       
   593 
       
   594         // Audio or Video player max volume
       
   595         TInt iPlayerMaxVolume;
       
   596 
       
   597         // Timer to jump to a new position, used for Fast Forward, Rewind
       
   598         CPeriodic* iPositionUpdater;
       
   599 
       
   600         // original file name. added for scripting functionality
       
   601         HBufC* iOriginalFileName;
       
   602 
       
   603         // mime type. added for scripting functionality
       
   604         HBufC8* iMimeType;
       
   605 
       
   606         //Normal display mode screen rect
       
   607         TRect iNormalScreenRect;
       
   608     };
       
   609 
       
   610 #endif      // CBAVPCONTROLLER_H
       
   611 
       
   612 // End of File