browserplugins/browseraudiovideoplugin/inc/BavpController.h
changeset 0 84ad3b177aa3
child 5 e45c3f40ea5f
equal deleted inserted replaced
-1:000000000000 0:84ad3b177aa3
       
     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 
       
    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     public: // New methods
       
   231 
       
   232         /**
       
   233         * Sets volume using the value from <object> attribute
       
   234         * @since 3.2
       
   235         * @param aVolume
       
   236         * @return void
       
   237         */
       
   238         void SetVolumeFromAttribute( TInt aVolume );
       
   239 
       
   240         /**
       
   241         * Sets loop using the value from <object> attribute
       
   242         * @since 3.2
       
   243         * @param aLoopValue: The number of times to play file
       
   244         * @param aInfiniteFlag: Set to ETrue if play infinitely, we use a loop
       
   245         *        countValue = 50 for infinite and always set this to EFalse
       
   246         * @return void
       
   247         */
       
   248         void SetLoopFromAttribute( TInt aLoopValue, TBool aInfiniteFlag );
       
   249 
       
   250         /**
       
   251         * Refresh the coordinates of the rectangle to be drawn
       
   252         * @since 3.2
       
   253         * @param none
       
   254         * @return void
       
   255         */
       
   256         virtual void RefreshRectCoordinates();
       
   257 
       
   258         /**
       
   259         * Sets original file name (used for scripting functionality)
       
   260         * @since 3.2
       
   261         * @param originalFilename
       
   262         * @return void
       
   263         */
       
   264         void SetOriginalFileName( const TDesC* originalFileName );
       
   265 
       
   266 
       
   267         /**
       
   268         * Sets the mime type(used for scripting functionality)
       
   269         * @since 3.2
       
   270         * @param mime type
       
   271         * @return void
       
   272         */
       
   273         void SetMimeType( const TDesC8* mimetype );
       
   274 
       
   275     public: // New inline methods
       
   276 
       
   277         /**
       
   278         * Bavp has focus
       
   279         * @since 3.2
       
   280         * @param void
       
   281         * @return : TBool 0 or 1 indicating the focus
       
   282         */
       
   283         inline TBool BavpHasFocus()
       
   284             {
       
   285             return iBavpHasFocus;
       
   286             }
       
   287 
       
   288         /**
       
   289         * Returns the video player plugin current state
       
   290         * @since 3.2
       
   291         * @param none
       
   292         * @return TVideoState
       
   293         */
       
   294         inline TAudioVideoState State()
       
   295             {
       
   296             return iCurrentState;
       
   297             }
       
   298 
       
   299         /**
       
   300         * returns ETrue is the volume is muted
       
   301         * @param none
       
   302         * @return TBool
       
   303         */
       
   304         inline TBool IsVolumeMuted()
       
   305             {
       
   306             return ( iCurrentVolume == KCRVolumeMute );
       
   307             }
       
   308 
       
   309         /**
       
   310         * Returns ETrue is this is a video clip
       
   311         * @since 3.2
       
   312         * @param none
       
   313         * @return TBool
       
   314         */
       
   315         inline TBool IsClipVideo()
       
   316             {
       
   317             return iClipInfo->iVideoTrack;
       
   318             }
       
   319 
       
   320         /**
       
   321         * Returns ETrue is the clip is seekable.
       
   322         * @param none
       
   323         * @return TBool
       
   324         */
       
   325         inline TBool IsClipSeekable()
       
   326            {
       
   327            return iClipInfo->iSeekable;
       
   328            }
       
   329 
       
   330         /**
       
   331         * returns ETrue is the content is local media file.
       
   332         * Local files can be FF and Rewind
       
   333         * @param none
       
   334         * @return TBool
       
   335         */
       
   336         inline TBool IsClipLocalMedia()
       
   337             {
       
   338             return ( iClipInfo->iMediaType == ELocalVideoFile ||
       
   339                      iClipInfo->iMediaType == ELocalAudioFile );
       
   340             }
       
   341 
       
   342         /**
       
   343         * Returns TRUE if the display is on full screen, otherwise FALSE
       
   344         * @since 3.2
       
   345         * @param none
       
   346         * @return TBool
       
   347         */
       
   348         inline TBool IsClipFullScreen()
       
   349             {
       
   350             return iClipInfo->iInFullScreenMode;
       
   351             }
       
   352 
       
   353         /**
       
   354         * Returns TRUE if the content is being fast-forwarded,
       
   355         * otherwise FALSE
       
   356         * @since 3.2
       
   357         * @param none
       
   358         * @return TBool
       
   359         */
       
   360         inline TBool IsClipFastForwarding()
       
   361             {
       
   362             return ( iCurrentState == EBavpFastForwarding );
       
   363             }
       
   364 
       
   365         /**
       
   366         * Returns TRUE if the content is being rewound,
       
   367         * otherwise FALSE
       
   368         * @since 3.2
       
   369         * @param none
       
   370         * @return TBool
       
   371         */
       
   372         inline TBool IsClipRewinding()
       
   373             {
       
   374             return ( iCurrentState == EBavpRewinding );
       
   375             }
       
   376 
       
   377         /**
       
   378         * Returns ETrue is the clip is onDemand stream.
       
   379         * @param none
       
   380         * @return TBool
       
   381         */
       
   382         inline TBool IsClipOnDemand()
       
   383             {
       
   384             return ( iClipInfo->iMediaType != ELocalVideoFile && iClipInfo->iSeekable );
       
   385             }
       
   386 
       
   387         /**
       
   388         * Returns ETrue is the clip is live stream.
       
   389         * @param none
       
   390         * @return TBool
       
   391         */
       
   392         inline TBool IsClipLive()
       
   393             {
       
   394             return ( iClipInfo->iLiveStream );
       
   395             }
       
   396 
       
   397 
       
   398         /** Returns the original filename of the clip
       
   399         * @param none
       
   400         * @return HBufC*
       
   401         */
       
   402         inline const HBufC& ClipName()
       
   403             {
       
   404             return *iOriginalFileName;
       
   405             }
       
   406 
       
   407         /** Returns the duration of the clip
       
   408         * @param none
       
   409         * @return TTimeIntervalMicroSeconds
       
   410         */
       
   411         inline TTimeIntervalMicroSeconds Duration()
       
   412             {
       
   413             return ( iClipInfo->iDurationInSeconds );
       
   414             }
       
   415 
       
   416         /** Returns the mime type of the clip
       
   417         * @param none
       
   418         * @return HBufC*
       
   419         */
       
   420         inline const HBufC8& MimeType()
       
   421             {
       
   422             return *iMimeType;
       
   423             }
       
   424 
       
   425 
       
   426 
       
   427     protected:  // New methods
       
   428 
       
   429         /**
       
   430         * By default Symbian 2nd phase constructor is private.
       
   431         * @param none
       
   432         * @return void
       
   433         */
       
   434         void BaseConstructL( TBavpMediaType aMediaType,
       
   435                              const TDesC& aFileName );
       
   436 
       
   437         /**
       
   438         * Parse the ram file
       
   439         * @param none
       
   440         * @return void
       
   441         */
       
   442         void ParseRamFileL();
       
   443 #if defined(BRDO_ASX_FF) 
       
   444     /**
       
   445 	* Parse the asx file
       
   446 	* @param none
       
   447 	* @return void
       
   448 	*/
       
   449         void ParseAsxFileL();
       
   450 #endif //BRDO_ASX_FF
       
   451         /**
       
   452         * Set the rectangle to prepare the display
       
   453         * @param TRect
       
   454         * @return TRect aRect
       
   455         */
       
   456         TRect GetClipRect( TRect aRect );
       
   457 
       
   458         /**
       
   459         * Create a query dialog for the volume setting list
       
   460         * @param none
       
   461         * @return void
       
   462         */
       
   463         void CreateVolumeListDlgL();
       
   464 
       
   465         /**
       
   466         * Check if an incoming call comes
       
   467         * @param none
       
   468         * @return TBool
       
   469         */
       
   470         TBool IsVideoOrAudioCall();
       
   471 
       
   472         /**
       
   473         * Check if other audio or video controllers are playing
       
   474         * @param none
       
   475         * @return TBool
       
   476         */
       
   477         TBool IsAnotherControllerPlaying();
       
   478 
       
   479         /**
       
   480         * Pause or Stop the other audio or video controllers from playing
       
   481         * @param none
       
   482         * @return void
       
   483         */
       
   484         void PauseOtherControllersPlaying();
       
   485 
       
   486         /**
       
   487         * Handle the error from MMF for multiple media object case
       
   488         * @param aError error code from MMF
       
   489         * @return void
       
   490         */
       
   491         void HandleMultiInstanceError();
       
   492 
       
   493     protected:  // Methods from CActive
       
   494 
       
   495         /**
       
   496         * Implements cancellation of an outstanding request.
       
   497         * @param none
       
   498         * @return void
       
   499         */
       
   500         void DoCancel() { /* Not implemented */ }
       
   501 
       
   502         /**
       
   503         * Handles an active object’s request completion event.
       
   504         * @param none
       
   505         * @return void
       
   506         */
       
   507         void RunL();
       
   508 
       
   509     public: // Methods from MBavpVolumeObserver
       
   510 
       
   511         /**
       
   512         * Updates the volume
       
   513         * From MBavpVolumeObserver
       
   514         * @since 3.2
       
   515         * @param TInt aVolume: volume value
       
   516         * @return void
       
   517         */
       
   518         void UpdateVolume( TInt aVolume );
       
   519 
       
   520     private:       // From MHwKeyEventsObserver
       
   521 
       
   522         /**
       
   523         * Called when volume level should be changed.
       
   524         * Set volume control visible into navi pane.
       
   525         * @param aVolumeChange: +1 change volume up
       
   526         *                       -1 change volume down
       
   527         */
       
   528         void BavpHwKeyVolumeChange( TInt aVolumeChange );
       
   529 
       
   530         /**
       
   531         * Called when a media hardware key (play, pause...) was presed.
       
   532         * @since 3.2
       
   533         * @param aCommand: Command ID representing Play, Pause, ...
       
   534         * @return void
       
   535         */
       
   536         // void BavpHwKeyCommand( TBavpCommandIds aCommand );
       
   537 
       
   538     public:         // Data, public
       
   539 
       
   540         // Is Bavp Plugin in focus
       
   541         TBool iBavpHasFocus;
       
   542 
       
   543         // Audio Video plugin current state
       
   544         TAudioVideoState iCurrentState;
       
   545 
       
   546         // ClipInfo contains our metadata from the MMF/Helix and content file
       
   547         CBavpClipInfo* iClipInfo;
       
   548 
       
   549         // Array of pointers of CBavpController (this) instances
       
   550         static RPointerArray<CBavpController> iBavpControllerArray;
       
   551 
       
   552     protected:      // Data
       
   553 
       
   554         // The player is initialized and ready to be used
       
   555         TBool iPlayerInitialized;
       
   556 
       
   557         // Bavp plugin previous state - used when handling interrupted
       
   558         // media, because of a phone call
       
   559         TAudioVideoState iPreCallState;
       
   560 
       
   561         // Last command
       
   562         TBavpCommandIds iLastCommand;
       
   563 
       
   564         // The number of times the audio or video file will play (loop)
       
   565         TInt iLoopCount;
       
   566 
       
   567         // Hold the initial value of loop
       
   568         TInt iInitLoopCount;
       
   569 
       
   570         // The infinite loop flag, we currently set to EFalse and use loop=50
       
   571         // if a web site requests infinite looping
       
   572         TBool iInfiniteLoopFlag;
       
   573 
       
   574         // Access pt id
       
   575         TUint iAccessPtId;
       
   576 
       
   577         // Bavp View
       
   578         MBavpView* iBavpView;
       
   579 
       
   580         // Events from Hardware Keys
       
   581         CBavpHwKeyEvents* iHwKeyEvents;
       
   582 
       
   583         // System state
       
   584         RProperty iIncomingCalls;
       
   585 
       
   586         // Volume hander
       
   587         CBavpVolumeHandler* iBavpVolumeHandler;
       
   588 
       
   589         // Current volume level
       
   590         TInt iCurrentVolume;
       
   591 
       
   592         // Audio or Video player max volume
       
   593         TInt iPlayerMaxVolume;
       
   594 
       
   595         // Timer to jump to a new position, used for Fast Forward, Rewind
       
   596         CPeriodic* iPositionUpdater;
       
   597 
       
   598         // original file name. added for scripting functionality
       
   599         HBufC* iOriginalFileName;
       
   600 
       
   601         // mime type. added for scripting functionality
       
   602         HBufC8* iMimeType;
       
   603 
       
   604         //Normal display mode screen rect
       
   605         TRect iNormalScreenRect;
       
   606     };
       
   607 
       
   608 #endif      // CBAVPCONTROLLER_H
       
   609 
       
   610 // End of File