videoeditorengine/vedengine/inc/VedAudioClipInfoImp.h
changeset 0 951a5db380a0
equal deleted inserted replaced
-1:000000000000 0:951a5db380a0
       
     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 
       
    21 #ifndef __VEDAUDIOCLIPINFOIMP_H__
       
    22 #define __VEDAUDIOCLIPINFOIMP_H__
       
    23 
       
    24 
       
    25 #include <e32base.h>
       
    26 #include "VedCommon.h"
       
    27 #include "VedAudioClipInfo.h"
       
    28 
       
    29 #include "AudClip.h"
       
    30 #include "AudObservers.h"
       
    31 
       
    32 /*
       
    33  *  Forward declarations.
       
    34  */
       
    35 class CVedAudioClipInfo;
       
    36 class CVedAudioClipInfoOperation;
       
    37 
       
    38 /**
       
    39  * Utility class for getting information about audio clip files.
       
    40  *
       
    41  */
       
    42 class CVedAudioClipInfoImp : public CVedAudioClipInfo, public MAudClipInfoObserver,
       
    43                              public MAudVisualizationObserver
       
    44     {
       
    45 public:
       
    46     /* Constuctor */
       
    47     CVedAudioClipInfoImp();
       
    48 
       
    49     /* Symbian two phased constructor. */
       
    50     void ConstructL(const TDesC& aFileName,
       
    51                     MVedAudioClipInfoObserver& aObserver);
       
    52                     
       
    53     /* Symbian two phased constructor. */
       
    54     void ConstructL(RFile* aFileHandle,
       
    55                     MVedAudioClipInfoObserver& aObserver);
       
    56 
       
    57     /* Two-phased constructor variant for use within a movie. */
       
    58     void ConstructL(CAudClip* aAudClip,
       
    59                     MVedAudioClipInfoObserver& aObserver);
       
    60 
       
    61     /**
       
    62      * Destroys the object and releases all resources.
       
    63      */    
       
    64     ~CVedAudioClipInfoImp();
       
    65 
       
    66 
       
    67     /* Property methods. */
       
    68 
       
    69     /**
       
    70      * Returns the file name of the clip. Panics if info
       
    71      * is not yet ready for reading.
       
    72      * 
       
    73      * @return  file name
       
    74      */
       
    75     TPtrC FileName() const;
       
    76 
       
    77     /**
       
    78      * Returns the audio format of the clip. Panics if info
       
    79      * is not yet ready for reading.
       
    80      * 
       
    81      * @return  audio format of the clip
       
    82      */
       
    83     TVedAudioFormat Format() const;
       
    84 
       
    85     /**
       
    86      * Returns the audio type of the clip. Panics if info
       
    87      * is not yet ready for reading.
       
    88      * 
       
    89      * @return  audio type
       
    90      */
       
    91     TVedAudioType Type() const;
       
    92 
       
    93     /**
       
    94      * Returns the duration of the clip. Panics if info
       
    95      * is not yet ready for reading.
       
    96      * 
       
    97      * @return  duration in microseconds
       
    98      */
       
    99     TTimeIntervalMicroSeconds Duration() const;
       
   100 
       
   101     /**
       
   102      * Returns the channel mode of the audio if applicable.
       
   103      *
       
   104      * @return  channel mode
       
   105      */
       
   106     TVedAudioChannelMode ChannelMode() const;
       
   107 
       
   108     /**
       
   109      * Returns the sampling rate.
       
   110      *
       
   111      * @return  sampling rate in hertz
       
   112      */
       
   113     TInt SamplingRate() const;
       
   114 
       
   115     /**
       
   116      * Returns the bitrate mode.
       
   117      *
       
   118      * @return  bitrate mode
       
   119      */
       
   120     TVedBitrateMode BitrateMode() const;
       
   121 
       
   122     /**
       
   123      * Returns the bitrate.
       
   124      *
       
   125      * @return  bitrate in bits per second
       
   126      */
       
   127     TInt Bitrate() const;
       
   128 
       
   129 
       
   130     /**
       
   131      * Comparison method for sorting arrays of audio clip infos.
       
   132      *
       
   133      * @param c1  first info to compare
       
   134      * @param c2  second info to compare
       
   135      *
       
   136      * @return 
       
   137      */
       
   138     static TInt Compare(const CVedAudioClipInfoImp& c1, const CVedAudioClipInfoImp& c2);
       
   139 
       
   140     /* Visualization methods. */
       
   141 
       
   142     /**
       
   143      * Generates a visualization of the audio clip. The visualization consists
       
   144      * of an array of values with the specified resolution. This method is 
       
   145      * asynchronous. The visualization is generated in background and the observer 
       
   146      * is notified when the visualization is complete. This method panics if info 
       
   147      * is not yet ready for reading or the resolution is illegal.
       
   148      * 
       
   149      * Possible leave codes:
       
   150      *  - <code>KErrNoMemory</code> if memory allocation fails
       
   151      *
       
   152      * @param aObserver    observer to be notified when the visualization is completed
       
   153      * @param aResolution  resolution of the visualization (i.e., the number of values
       
   154      *                     in the visualization array)
       
   155      * @param aPriority    priority of the visualization
       
   156      */
       
   157     void GetVisualizationL(MVedAudioClipVisualizationObserver& aObserver,
       
   158                            TInt aResolution, TInt aPriority);
       
   159     
       
   160     /**
       
   161      * Cancels visualization generation. If no visualization is currently being 
       
   162      * generated, the function does nothing.
       
   163      */
       
   164     void CancelVisualizationL();
       
   165     
       
   166 
       
   167     /**
       
   168      * Factory constructor for constucting the info without creating an audio clip
       
   169      * info object, using the supplied audio clip pointer instead.This variant is for
       
   170      * use in movie.
       
   171      * 
       
   172      * @param aAudClip   audio clip instance
       
   173      * @param aObserver  observer to notify when clip info is ready
       
   174      */
       
   175     static CVedAudioClipInfoImp* NewL(CAudClip* aAudClip, MVedAudioClipInfoObserver& aObserver);
       
   176 
       
   177     /**
       
   178      * Factory constructor for constucting the info without creating an audio clip
       
   179      * info object, using the supplied audio clip pointer instead.This variant is for
       
   180      * use in movie. Leaves the created instance on the cleanup stack.
       
   181      * 
       
   182      * @param aAudClip   audio clip instance
       
   183      * @param aObserver  observer to notify when clip info is ready
       
   184      */
       
   185     static CVedAudioClipInfoImp* NewLC(CAudClip* aAudClip, MVedAudioClipInfoObserver& aObserver);
       
   186     
       
   187     /**
       
   188      * Returns the file handle of the clip. Panics if info
       
   189      * is not yet ready for reading.
       
   190      * 
       
   191      * @return  file name
       
   192      */
       
   193     RFile* FileHandle() const;
       
   194 
       
   195 private: // Functions from base classes
       
   196 
       
   197     /* From base class MAudVisualizationObserver */
       
   198     
       
   199     void NotifyClipInfoVisualizationCompleted(const CAudClipInfo& aClipInfo, 
       
   200         TInt aError, TInt8* aVisualization, TInt aSize);
       
   201     
       
   202     void NotifyClipInfoVisualizationStarted(const CAudClipInfo& aClipInfo, 
       
   203         TInt aError);
       
   204 
       
   205     void NotifyClipInfoVisualizationProgressed(const CAudClipInfo& aClipInfo, 
       
   206         TInt aPercentage);
       
   207 
       
   208     /* From base class MAudClipInfoObserver */
       
   209     void NotifyClipInfoReady(CAudClipInfo& aInfo, TInt aError);
       
   210 
       
   211 private:
       
   212 
       
   213     // Audio clip info from Audio Engine
       
   214     CAudClipInfo* iAudClipInfo;
       
   215 
       
   216     // Audio clip if this clip info is included in a song
       
   217     CAudClip* iAudClip;
       
   218 
       
   219     // Operation class
       
   220     CVedAudioClipInfoOperation* iOperation;
       
   221 
       
   222     // Audio properties
       
   223     TAudFileProperties iAudioProperties;
       
   224 
       
   225     // Whether we are ready to return info.
       
   226     TBool iReady;
       
   227 
       
   228     MVedAudioClipInfoObserver* iObserver;
       
   229     
       
   230     // Visualization observer
       
   231     MVedAudioClipVisualizationObserver* iVisualizationObserver;
       
   232     friend class CVedAudioClip;
       
   233     friend class CVedMovieImp;
       
   234     };
       
   235 
       
   236 class CVedAudioClipInfoOperation : public CActive
       
   237     {
       
   238 public:
       
   239     static CVedAudioClipInfoOperation* NewL(CVedAudioClipInfoImp* aInfo, MVedAudioClipInfoObserver& aObserver);
       
   240     ~CVedAudioClipInfoOperation();
       
   241 
       
   242 protected:
       
   243     TInt RunError(TInt aError);
       
   244     void RunL();
       
   245     void DoCancel();
       
   246     CVedAudioClipInfoOperation(CVedAudioClipInfoImp* aInfo,MVedAudioClipInfoObserver& aObserver);
       
   247     void ConstructL();
       
   248 
       
   249 private:
       
   250     MVedAudioClipInfoObserver& iObserver;
       
   251     CVedAudioClipInfoImp* iInfo;
       
   252     };
       
   253 #endif // __VEDAUDIOCLIPINFOIMP_H__