phoneapp/phoneuiview/inc/cphonevideoplayer.h
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  Video ringing tone player.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPHONEVIDEOPLAYER_H
       
    20 #define CPHONEVIDEOPLAYER_H
       
    21 
       
    22 // INCLUDES
       
    23 
       
    24 #include <VideoPlayer.h>
       
    25 
       
    26 // CONSTANTS
       
    27 
       
    28 // MACROS
       
    29 
       
    30 // DATA TYPES
       
    31 
       
    32 // FUNCTION PROTOTYPES
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CFileMan;
       
    36 class CVideoPlayerUtility;
       
    37 class MPhoneVideoPlayerObserver;
       
    38 class CPhoneRingingTone;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 *  Video ringing tone player
       
    44 *  Uses CVideoPlayerUtility to play video clips.
       
    45 *
       
    46 *  @lib PhoneUIView.lib
       
    47 *  @since Series 60 3.1
       
    48 */
       
    49 class CPhoneVideoPlayer : 
       
    50     public CBase,
       
    51     public MVideoPlayerUtilityObserver
       
    52     {
       
    53     public:
       
    54         enum TVideoPlayerState // from MMF-VideoPlayer IF spec.
       
    55             {
       
    56             EVideoError = -1,
       
    57             EVideoClosed,
       
    58             EVideoOpening,
       
    59             EVideoOpen,
       
    60             EVideoPreparing,
       
    61             EVideoReady, // player's stopped state
       
    62             EVideoPlaying,
       
    63             EVideoPaused
       
    64             };
       
    65 
       
    66         enum TRingingType
       
    67             {
       
    68             ETypeRinging,
       
    69             ETypeRingingOnce,
       
    70             ETypeAscending
       
    71             };
       
    72 
       
    73         enum TVideoResolution
       
    74             {
       
    75             EVideoQCIF,
       
    76             EVideoSubQCIF
       
    77             };
       
    78 
       
    79     public:  // Constructor and destructor
       
    80 
       
    81         /**
       
    82         * Two-phased constructor.
       
    83         * @param aRingingTone The ringing tone
       
    84         * @param aPriority The priority for the playing
       
    85         * @param aPreference The preference value
       
    86         * @param aObserver Video player observer
       
    87         * @param aVideo Window for video
       
    88         * @return The instance of the video player.
       
    89         */
       
    90         static CPhoneVideoPlayer* NewL( 
       
    91             const CPhoneRingingTone& aRingingTone, 
       
    92             TInt aPriority, 
       
    93             TUint aPreference,
       
    94             MPhoneVideoPlayerObserver& aObserver, 
       
    95             RWindow& aVideoTarget,
       
    96             TBool aExtSecNeeded = EFalse );
       
    97 
       
    98         /**
       
    99         * Two-phased constructor (non leaving).
       
   100         * @param aFileName The ringing tone
       
   101         * @param aPriority The priority for the playing
       
   102         * @param aPreference The preference value
       
   103         * @param aObserver Video player observer
       
   104         * @param aVideo Window for video
       
   105         * @return The instance of the video player. NULL is
       
   106         *         returned if creation failed.
       
   107         */
       
   108         static CPhoneVideoPlayer* New( 
       
   109             const CPhoneRingingTone& aRingingTone, 
       
   110             TInt aPriority, 
       
   111             TUint aPreference,
       
   112             MPhoneVideoPlayerObserver& aObserver, 
       
   113             RWindow& aVideoTarget,
       
   114             TBool aExtSecNeeded = EFalse );
       
   115 
       
   116         /**
       
   117         * Destructor.
       
   118         */
       
   119         virtual ~CPhoneVideoPlayer();
       
   120 
       
   121     public:
       
   122         /**
       
   123         * Plays the loaded video.
       
   124         * @since Series 60 3.1
       
   125         * @param aRingingType Ringing type.
       
   126         * @param aVolume take value from 1 to 10
       
   127         */
       
   128         void Play( TRingingType aRingType, TInt aVolume );
       
   129 
       
   130         /**
       
   131         * Stops video playback.
       
   132         * @since Series 60 3.1
       
   133         */
       
   134         void StopPlaying();
       
   135 
       
   136        /**
       
   137         * Pauses video playback.
       
   138         * @since Series 60 3.1
       
   139         * @return KErrNone is successful.
       
   140         */
       
   141         TInt PausePlaying();
       
   142         
       
   143         /**
       
   144         * Resumes video playback.
       
   145         * @since Series 60 3.1
       
   146         */
       
   147         void ResumePlaying();
       
   148         
       
   149         /**
       
   150         * Make video to play silent.
       
   151         * @since Series 60 3.1
       
   152         */
       
   153         void MuteAudio();
       
   154 
       
   155         /**
       
   156         * Get the state of the phone video player.
       
   157         * @since Series 60 3.1
       
   158         * @return The status of video player
       
   159         */
       
   160         TVideoPlayerState State() const;
       
   161 
       
   162         /**
       
   163         * Get the resolution of the loaded video.
       
   164         * @since Series 60 3.1
       
   165         * @return The resolution.
       
   166         */
       
   167         TVideoResolution VideoResolution() const;
       
   168 
       
   169         /**
       
   170         * Scales and crops video to cover target window.
       
   171         * @since Series 60 3.1
       
   172         * @param aDisplayWindow Window for video.
       
   173         * @param aUncropPane Rectangle for cropping control.
       
   174         */
       
   175         void AdjustToWindow( RWindow& aDisplayWindow,
       
   176         					 const TRect& aUncropPane );
       
   177 
       
   178     private: // Functions from MVideoPlayerUtilityObserver
       
   179         /** 
       
   180         * MvpuoOpenComplete
       
   181         */
       
   182         void MvpuoOpenComplete( TInt aError );
       
   183 
       
   184         /** 
       
   185         * MvpuoPrepareComplete
       
   186         */
       
   187         void MvpuoPrepareComplete( TInt aError );
       
   188 
       
   189         /** 
       
   190         * MvpuoFrameReady
       
   191         */
       
   192         void MvpuoFrameReady( CFbsBitmap& aFrame ,TInt aError );
       
   193 
       
   194         /** 
       
   195         * MvpuoPlayComplete
       
   196         */
       
   197         void MvpuoPlayComplete( TInt aError );
       
   198         
       
   199         /** 
       
   200         * MvpuoEvent
       
   201         */
       
   202         void MvpuoEvent( const TMMFEvent& aEvent );
       
   203     
       
   204     private: // Constructors
       
   205 
       
   206         /**
       
   207         * C++ default constructor.
       
   208         */
       
   209         CPhoneVideoPlayer();
       
   210         
       
   211         /**
       
   212         * C++ constructor.
       
   213         */
       
   214         CPhoneVideoPlayer( MPhoneVideoPlayerObserver& aObserver );
       
   215 
       
   216         /**
       
   217         * By default Symbian 2nd phase constructor is private.
       
   218         */
       
   219         void ConstructL( 
       
   220             const TDesC& aFileName, 
       
   221             TInt aPriority, 
       
   222             TUint aPreference,
       
   223             RWindow& aVideoTarget );
       
   224 
       
   225     private:
       
   226         /**
       
   227         * SetRingingType
       
   228         */
       
   229         void SetRingingType( TRingingType aRingingType );
       
   230 
       
   231         /**
       
   232         * SetVolume
       
   233         */
       
   234         void SetVolume( TInt aVolume );
       
   235 
       
   236         /**
       
   237         * VolumeRampTimerCallback
       
   238         */
       
   239         static TInt VolumeRampTimerCallback( TAny* aObj );
       
   240 
       
   241         /**
       
   242         * DoVolumeRamp
       
   243         */
       
   244         TInt DoVolumeRamp();
       
   245         
       
   246         /**
       
   247         * Frame size
       
   248         */
       
   249         TSize VideoFrameSize() const;
       
   250 
       
   251     private: //Data
       
   252 
       
   253         MPhoneVideoPlayerObserver&  iObserver;
       
   254         CVideoPlayerUtility*        iVideoPlayer;
       
   255         TVideoPlayerState           iPlayerState;
       
   256         TBool                       iToBePlayed;
       
   257 
       
   258         // Ringing properties
       
   259         TInt                        iVolume;
       
   260         TRingingType                iRingingType;
       
   261 
       
   262         // Ascending volume
       
   263         TInt                        iRampedVolume;
       
   264         CPeriodic*                  iVolumeRampTimer;
       
   265         
       
   266         // Ringing tone
       
   267         RFile                       iFileHandle;
       
   268         
       
   269     };
       
   270 
       
   271 #endif // CPHONEVIDEOPLAYER