videditor/ManualVideoEditor/inc/VeiCutAudioContainer.h
branchRCL_3
changeset 3 e0b5df5c0969
parent 0 951a5db380a0
child 5 4c409de21d23
equal deleted inserted replaced
0:951a5db380a0 3:e0b5df5c0969
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "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 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef VEICUTAUDIOCONTAINER_H
       
    21 #define VEICUTAUDIOCONTAINER_H
       
    22 
       
    23 #include <coecntrl.h>
       
    24 #include <aknprogressdialog.h> 
       
    25 #include <VideoPlayer.h>
       
    26 #include <VedCommon.h>
       
    27 #include <VedMovie.h>
       
    28 #include <MdaAudioSamplePlayer.h>
       
    29 #include <VedAudioClipInfo.h>
       
    30 
       
    31 #include "VeiRemConTarget.h"
       
    32 
       
    33 class CVeiCutAudioView;
       
    34 class CVeiCutterBar;
       
    35 class CAknsBasicBackgroundControlContext;
       
    36 class CVeiErrorUI;
       
    37 class CVeiTextDisplay;
       
    38 class CSampleArrayHandler;
       
    39 
       
    40 
       
    41 const TInt KMinCutAudioVolumeLevel = 1;
       
    42 const TInt KMaxCutAudioVolumeLevel = 10;
       
    43 
       
    44 /**
       
    45  * CVeiCutAudioContainer container control class.
       
    46  *  
       
    47  * Container for CVeiCutAudioView.
       
    48  */
       
    49 class CVeiCutAudioContainer: public CCoeControl, 
       
    50                              public MCoeControlObserver,
       
    51                              public MMdaAudioPlayerCallback,
       
    52                              public MVedAudioClipVisualizationObserver, 
       
    53                              public MProgressDialogCallback,
       
    54                              public MVeiMediakeyObserver
       
    55 {
       
    56 public:
       
    57     /**
       
    58      * Edit state.
       
    59      */
       
    60     enum TCutAudioState
       
    61     {
       
    62         EStateInitializing = 1,
       
    63         EStateOpening,
       
    64         EStateStoppedInitial,
       
    65         EStateStopped,
       
    66         EStatePlaying,
       
    67         EStatePlayingMenuOpen,
       
    68         EStatePaused,
       
    69         EStateTerminating
       
    70     };
       
    71 
       
    72     enum TMarkState
       
    73     {
       
    74         ENoMark = 0,
       
    75         EMarked			
       
    76     };
       
    77     
       
    78     
       
    79 			
       
    80     /**
       
    81      * Start or end mark.
       
    82      */
       
    83     enum TCutMark
       
    84     {
       
    85         ENoMarks,
       
    86         EStartMark,
       
    87         EEndMark
       
    88     };
       
    89 			
       
    90 
       
    91         
       
    92 public:
       
    93     /**
       
    94      * Creates a CStoryboardContainer object, which will draw itself to aRect.
       
    95      *
       
    96      * @param aRect Frame rectangle for container.
       
    97      * @param aMovie  movie being edited
       
    98      *
       
    99      * @return a pointer to the created instance of CStoryboardContainer
       
   100      */
       
   101     static CVeiCutAudioContainer* NewL( const TRect& aRect, 
       
   102                                         CVeiCutAudioView& aView, 
       
   103                                         CVeiErrorUI& aErrorUI );
       
   104 
       
   105     /**  
       
   106      * Creates a CStoryboardContainer object, which will draw itself to aRect.
       
   107      * Leaves the created object in the cleanup stack.
       
   108      *
       
   109      * @param aRect Frame rectangle for container.
       
   110      * @param aMovie  movie being edited
       
   111      *
       
   112      * @return a pointer to the created instance of CStoryboardContainer
       
   113      */
       
   114     static CVeiCutAudioContainer* NewLC( const TRect& aRect, 
       
   115                                          CVeiCutAudioView& aView, 
       
   116                                          CVeiErrorUI& aErrorUI );
       
   117 
       
   118     /**
       
   119      * Default constructor.
       
   120      *
       
   121      * @param aRect  Frame rectangle for container.
       
   122      * @param aView  pointer to the view.
       
   123      */
       
   124     void ConstructL( const TRect& aRect, 
       
   125                      CVeiCutAudioView& aView, 
       
   126                      CVeiErrorUI& aErrorUI );
       
   127 
       
   128     /**
       
   129      * Destructor.
       
   130      */
       
   131     virtual ~CVeiCutAudioContainer();
       
   132 
       
   133 public:
       
   134     void OpenAudioFileL( const TDesC& aFileName );
       
   135 
       
   136     /**
       
   137      * ###Missin' description###
       
   138      *
       
   139      * @param aState
       
   140      */
       
   141     void SetStateL( CVeiCutAudioContainer::TCutAudioState aState );
       
   142     /**
       
   143      * Starts playing.
       
   144      *
       
   145      * @param aStartTime
       
   146      */
       
   147     void PlayL( const TTimeIntervalMicroSeconds& aStartTime = TTimeIntervalMicroSeconds( 0 ) );
       
   148 
       
   149     /**
       
   150      * Stops playing.
       
   151      */
       
   152     void StopL();
       
   153 
       
   154     /**
       
   155      * Pauses playing.
       
   156      */
       
   157     void PauseL();
       
   158 
       
   159     /**
       
   160      * Closes the stream.
       
   161      */
       
   162     void CloseStreamL();
       
   163 
       
   164     /**
       
   165      * Returns the playback position.
       
   166      *
       
   167      * @return  playback position
       
   168      */
       
   169     const TTimeIntervalMicroSeconds& PlaybackPositionL();
       
   170 
       
   171     /**
       
   172      * Marks the in point.
       
   173      */
       
   174     void MarkedInL();
       
   175 
       
   176     /**
       
   177      * Marks the out point.
       
   178      */
       
   179     void MarkedOutL();
       
   180 
       
   181     /**
       
   182      * Change volume level. Changes current volume level by given amount.
       
   183      *
       
   184      * @param aVolumeChange		volume change
       
   185      */
       
   186     void SetVolumeL( TInt aVolumeChange );
       
   187 
       
   188     /**
       
   189      * Sets cut in time to cut video bar.
       
   190      *
       
   191      * @param aTime	Cut in time
       
   192      */
       
   193     void SetInTimeL( const TTimeIntervalMicroSeconds& aTime );
       
   194 
       
   195     /**
       
   196      * Sets cut out time to cut video bar.
       
   197      *
       
   198      * @param aTime	Cut out time
       
   199      */
       
   200     void SetOutTimeL( const TTimeIntervalMicroSeconds& aTime );
       
   201 
       
   202     /**
       
   203      * Sets duration to cut video bar.
       
   204      *
       
   205      * @param aTime	duration
       
   206      */
       
   207     void SetDuration( const TTimeIntervalMicroSeconds& aDuration );
       
   208 
       
   209 public:
       
   210     /**
       
   211      * Update function that is called by the static callback method.
       
   212      */
       
   213     void DoUpdate();
       
   214 
       
   215     /**
       
   216      * From CCoeControl, OfferKeyEventL.
       
   217      *
       
   218      * @param aKeyEvent  key event
       
   219      * @param aType  event code
       
   220      */
       
   221     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   222 
       
   223     /**
       
   224      * Returns total length of the video clip.
       
   225      *
       
   226      * @return  total length
       
   227      */
       
   228     const TTimeIntervalMicroSeconds& TotalLength();
       
   229 
       
   230     /**
       
   231      * Returns the player state.
       
   232      *
       
   233      * @return  player state
       
   234      */
       
   235     inline TCutAudioState State() { return iState; };
       
   236     /**
       
   237      * Returns current volume level.
       
   238      *
       
   239      * @return	volume level
       
   240      */
       
   241     inline TInt Volume() const { return iInternalVolume; };
       
   242 
       
   243     /**
       
   244      * Returns minimum volume level.
       
   245      *
       
   246      * @return	min volume level
       
   247      */
       
   248     inline TInt MinVolume() const { return 1; };
       
   249 
       
   250     /**
       
   251      * Returns maximum volume level.
       
   252      *
       
   253      * @return	max volume level
       
   254      */
       
   255     inline TInt MaxVolume()const { return iMaxVolume; };
       
   256 
       
   257     /**
       
   258      * Returns the visualization resolution.
       
   259      *
       
   260      * @return	The visualization resolution, i.e. the size of the sample array
       
   261      */
       
   262     TInt VisualizationResolution()const;
       
   263 
       
   264     /**
       
   265      * Prepares the control for termination; stops audio playback
       
   266      * and sets the state to EStateTerminating.
       
   267      * 
       
   268      */
       
   269     void PrepareForTerminationL();
       
   270 
       
   271 public:
       
   272     virtual void NotifyAudioClipVisualizationStarted( const CVedAudioClipInfo& aInfo );
       
   273 
       
   274     virtual void NotifyAudioClipVisualizationProgressed( const CVedAudioClipInfo& aInfo, 
       
   275                                                          TInt aPercentage );
       
   276     virtual void NotifyAudioClipVisualizationCompleted( const CVedAudioClipInfo& aInfo, 
       
   277                                                         TInt aError, 
       
   278                                                         TInt8* aVisualization,
       
   279                                                         TInt aResolution);
       
   280 
       
   281 private:
       
   282     /**
       
   283      * Callback function for the timer.
       
   284      *
       
   285      * @param aThis  self pointer
       
   286      *
       
   287      * @return  dummy value
       
   288      */
       
   289     static TInt DoAudioBarUpdate( TAny* aThis );
       
   290 
       
   291     /** 
       
   292      * From MMdaAudioPlayerCallback
       
   293      */
       
   294     virtual void MapcInitComplete( TInt aError,
       
   295                                    const TTimeIntervalMicroSeconds& aDuration );
       
   296 
       
   297     virtual void MapcPlayComplete( TInt aError );
       
   298 
       
   299     /**
       
   300      * Time increment.
       
   301      *
       
   302      * @param aKeyCount number a key events
       
   303      * @return time 
       
   304      */
       
   305     TInt TimeIncrement( TInt aKeyCount )const;
       
   306 
       
   307     /**
       
   308      * Constructor.
       
   309      *
       
   310      * @param aView	instance of cut audio view
       
   311      * @param aErrorUI instance of CVeiErrorUI
       
   312      */
       
   313     CVeiCutAudioContainer( const TRect& aRect, 
       
   314                            CVeiCutAudioView& aView, 
       
   315                            CVeiErrorUI& aErrorUI );
       
   316 
       
   317 
       
   318     /**
       
   319      * Continue playing
       
   320      */
       
   321     void ResumeL();
       
   322 
       
   323     /**
       
   324      * Gets intra frame bitmap from video clip.
       
   325      *
       
   326      * @param aTime	intra frame time.
       
   327      */
       
   328     void GetThumbAtL( TTimeIntervalMicroSeconds aTime );
       
   329 
       
   330     /**
       
   331      * From CoeControl, MopSupplyObject.
       
   332      *
       
   333      * @param aId  
       
   334      */
       
   335     virtual TTypeUid::Ptr MopSupplyObject( TTypeUid aId );
       
   336 
       
   337     /**
       
   338      * From CoeControl, SizeChanged.
       
   339      */
       
   340     void SizeChanged();
       
   341 
       
   342     /**
       
   343      * From CoeControl, CountComponentControls.
       
   344      * 
       
   345      * @return  number of component controls in this control
       
   346      */
       
   347     TInt CountComponentControls()const;
       
   348 
       
   349     /**
       
   350      * From CCoeControl, ComponentControl.
       
   351      *
       
   352      * @param aIndex  index of the control to return
       
   353      */
       
   354     CCoeControl* ComponentControl( TInt aIndex )const;
       
   355 
       
   356     /**
       
   357      * From CCoeControl,Draw.
       
   358      *
       
   359      * @param aRect  region of the control to be redrawn
       
   360      */
       
   361     void Draw( const TRect& aRect )const;
       
   362 
       
   363     /**
       
   364      * From CCoeControl, gets the control's help context. Associates the
       
   365      * control with a particular Help file and topic in a context sensitive
       
   366      * application.
       
   367      *
       
   368      * @param aContext Control's help context.
       
   369      */
       
   370     void GetHelpContext( TCoeHelpContext& aContext )const;
       
   371 
       
   372     /**
       
   373      * From CCoeControl, HandleControlEventL
       
   374      */
       
   375     void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
       
   376 
       
   377     /**
       
   378     * HandlePointerEventL
       
   379     * Handles pen inputs
       
   380     *
       
   381     * @param aPointerEvent  pointer event
       
   382     */
       
   383     void HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   384 
       
   385     /**
       
   386     * Handles progress bar touch events
       
   387     * @param aPBRect Current progress bar rectangle 
       
   388     * @param aPressedPoint The x coordinate value that was pressed
       
   389     * 			inside the progress bar
       
   390     * @param aDragMarks ETrue if the user drags start or end marks.
       
   391     *					EFalse otherwise
       
   392     */
       
   393     void HandleProgressBarTouchL( TRect aPBRect, TInt aPressedPoint, TBool aDragMarks, CVeiCutAudioContainer::TCutMark aCutMark = ENoMarks );
       
   394 
       
   395 
       
   396 
       
   397     /**
       
   398      * Update function that is called when visualization must be changed.
       
   399      */
       
   400     void UpdateVisualizationL();
       
   401 
       
   402     /**
       
   403      * Get the visualization data from the engine
       
   404      */
       
   405     void GetVisualizationL();
       
   406 
       
   407     /**
       
   408      * From MProgressDialogCallback
       
   409      */
       
   410     void DialogDismissedL( TInt aButtonId );
       
   411 
       
   412     /** Callback function */
       
   413     static TInt AsyncBack( TAny* aThis );
       
   414 
       
   415     /**
       
   416      * Propagate command to view's HandleCommandL
       
   417      */
       
   418     void HandleCommandL( TInt aCommand );
       
   419 
       
   420     /**
       
   421      * Draw the visualization, including background and indicators etc.
       
   422      * to a bitmap, which can be blitted to the screen.
       
   423      */
       
   424     void DrawToBufBitmapL();
       
   425 
       
   426     /**
       
   427      * Start a progress note dialog
       
   428      */
       
   429     void LaunchProgressNoteL();
       
   430 
       
   431     /**	HandleVolumeUpL 
       
   432      *
       
   433      *   @see MVeiMediakeyObserver
       
   434      */
       
   435     virtual void HandleVolumeUpL();
       
   436 
       
   437     /**	HandleVolumeDownL 
       
   438      *
       
   439      *   @see MVeiMediakeyObserver
       
   440      */
       
   441     virtual void HandleVolumeDownL();
       
   442 
       
   443 private:
       
   444     //data
       
   445     /** cut video view */
       
   446     CVeiCutAudioView& iView;
       
   447 
       
   448     /** Error UI */
       
   449     CVeiErrorUI& iErrorUI;
       
   450 
       
   451     /** Current state. */
       
   452     TCutAudioState iState;
       
   453 
       
   454     /** Previous state. */
       
   455     TCutAudioState iPrevState;
       
   456 
       
   457     /** cut audio bar. */
       
   458     CVeiCutterBar* iCutAudioBar;
       
   459 
       
   460     /** Last position. */
       
   461     TTimeIntervalMicroSeconds iLastPosition;
       
   462 
       
   463     /** Video clip duration */
       
   464     TTimeIntervalMicroSeconds iDuration;
       
   465 
       
   466     /**
       
   467      * Control context that provides a layout background with a 
       
   468      * background bitmap and its layout rectangle.
       
   469      */
       
   470     CAknsBasicBackgroundControlContext* iBgContext;
       
   471 
       
   472     /** Videoplayerutility volume */
       
   473     TInt iInternalVolume;
       
   474 
       
   475     /** Max volume */
       
   476     TInt iMaxVolume;
       
   477 
       
   478     /** Key repeat count in seek function. */
       
   479     TInt iKeyRepeatCount;
       
   480 
       
   481     /** Seek thumbnail position in video clip. */
       
   482     TTimeIntervalMicroSeconds iSeekPos;
       
   483 
       
   484     /** Seek - flag. */
       
   485     TBool iSeeking;
       
   486 
       
   487     /** Frame ready - flag */
       
   488     TBool iFrameReady;
       
   489 
       
   490     /** Last keycode, used in OfferKeyEventL(); */
       
   491     TUint iLastKeyCode;
       
   492 
       
   493     CFbsBitmap* iPauseBitmap;
       
   494     CFbsBitmap* iPauseBitmapMask;
       
   495 
       
   496     ///	Double buffer bitmap
       
   497     CFbsBitmap* iBufBitmap;
       
   498 
       
   499     CPeriodic* iVideoBarTimer;
       
   500     CMdaAudioPlayerUtility* iAudioSamplePlayer;
       
   501     TRect iCutTimeDisplayRect;
       
   502     CVeiTextDisplay* iCutTimeDisplay;
       
   503     TRect iIconDisplayRect;
       
   504 
       
   505     CSampleArrayHandler* iSampleArrayHandler;
       
   506 
       
   507     TInt iMarkOutCounter;
       
   508     TInt iMarkInCounter;
       
   509 
       
   510     TInt iPreviousScreenMode;
       
   511     TInt iCurrentScreenMode;
       
   512 
       
   513     TMarkState iMarkInState;
       
   514     TMarkState iMarkOutState;
       
   515 
       
   516     TTimeIntervalMicroSeconds iMarkedInTime;
       
   517     TTimeIntervalMicroSeconds iMarkedOutTime;
       
   518 
       
   519     /** Progress note. */
       
   520     CAknProgressDialog* iProgressNote;
       
   521 
       
   522     /** Callback utility */
       
   523     CAsyncCallBack* iCallBack;
       
   524 
       
   525     /** Remote connection API used to handle the volume keys. */
       
   526     CVeiRemConTarget* iRemConTarget;
       
   527     
       
   528     /** ETrue if user is dragging the start or end mark with a pen,
       
   529     	EFalse otherwise */
       
   530     TBool iIsMarkDrag;
       
   531 
       
   532     /** ETrue if the pen is in start or end mark area when it goes down,
       
   533     	EFalse otherwise */		
       
   534     TBool iIsMarkTapped;
       
   535 
       
   536     /** Indicates which mark the user has tapped */						
       
   537     TCutMark iTappedMark;    
       
   538 };
       
   539 #endif 
       
   540 
       
   541 // End of File