videoeditorengine/audioeditorengine/inc/AudClipInfo.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 __AUDCLIPINFO_H__
       
    22 #define __AUDCLIPINFO_H__
       
    23 
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <MdaAudioSamplePlayer.h>
       
    27 
       
    28 #include "AudCommon.h"
       
    29 #include "AudObservers.h"
       
    30 
       
    31 
       
    32 
       
    33 /*
       
    34 *    Forward declarations.
       
    35 */
       
    36 class CAudClipInfoOperation;
       
    37 class CAudProcessor;
       
    38 
       
    39 /**
       
    40 * Utility class for getting information about audio clip files.
       
    41 */
       
    42 class CAudClipInfo : public CBase    
       
    43 
       
    44     {
       
    45     
       
    46 public:
       
    47     
       
    48     /* Constructors & destructor. */
       
    49     
       
    50     /**
       
    51     * Constructs a new CAudClipInfo object to get information
       
    52     * about the specified audio clip file. The specified observer
       
    53     * is notified when info is ready for reading. This method
       
    54     * may leave if no resources are available to construct 
       
    55     * a new object.
       
    56     * 
       
    57     * Possible leave codes:
       
    58     *    - <code>KErrNoMemory</code> if memory allocation fails
       
    59     *  - <code>KErrNotSupported</code> if the given file format is not supported 
       
    60     * or is invalid
       
    61     *
       
    62     * @param aFileName  name of audio clip file
       
    63     * @param aObserver  observer to notify when info is ready for reading
       
    64     *
       
    65     * @return  pointer to a new CAudClipInfo instance
       
    66     */
       
    67     IMPORT_C static CAudClipInfo* NewL(const TDesC& aFileName, MAudClipInfoObserver& aObserver);
       
    68     
       
    69     /**
       
    70     * Constructs a new CAudClipInfo object to get information
       
    71     * about the specified audio clip file. The constructed object
       
    72     * is left in the cleanup stack. The specified observer
       
    73     * is notified when info is ready for reading. This method
       
    74     * may leave if no resources are available to construct a new
       
    75     * object.
       
    76     * 
       
    77     * Possible leave codes:
       
    78     *    - <code>KErrNoMemory</code> if memory allocation fails
       
    79     *  - <code>KErrNotSupported</code> if the given file format is not supported 
       
    80     *    or is invalid
       
    81     *
       
    82     * @param aFileName  name of video clip file
       
    83     * @param aObserver  observer to notify when info is ready for reading
       
    84     *
       
    85     * @return  pointer to a new CAudClipInfo instance
       
    86     */
       
    87     IMPORT_C static CAudClipInfo* NewLC(const TDesC& aFileName, MAudClipInfoObserver& aObserver);
       
    88     
       
    89     
       
    90     /**
       
    91     * Returns the properties of this audio file
       
    92     * 
       
    93     * @return  properties
       
    94     */
       
    95     IMPORT_C TAudFileProperties Properties() const;
       
    96     
       
    97     /**
       
    98     * Generates a visualization of the current clip. 
       
    99     * 
       
   100     * Asynchronous operation; MAudVisualizationObserver::NotifyClipVisualizationCompleted
       
   101     * is called as soon as the visualization process has completed. This method leads to
       
   102     * memory reservation, so once NotifyClipVisualizationCompleted has occurred, 
       
   103     * the caller is responsible for memory releasing.
       
   104     * 
       
   105     * Possible leave codes:
       
   106     *    - <code>KErrNoMemory</code> if memory allocation fails
       
   107     *
       
   108     * @param aObserver            observer to be notified when visualization is completed
       
   109     * @param aSize                the size of aVisualization array (time resolution). 
       
   110     * @param aPriority            priority
       
   111     *
       
   112     */
       
   113     IMPORT_C void GetVisualizationL(MAudVisualizationObserver& aObserver,
       
   114         TInt aSize, TInt aPriority) const;
       
   115     
       
   116     /**
       
   117     * Cancels visualization generation. If no visualization is currently being 
       
   118     * generated, the function does nothing.
       
   119     */
       
   120     IMPORT_C void CancelVisualization();
       
   121     
       
   122     /**
       
   123      * Returns the file name of the clip. Panics if info
       
   124      * is not yet ready for reading.
       
   125      * 
       
   126      * @return  file name
       
   127      */
       
   128     IMPORT_C TPtrC FileName() const;
       
   129 
       
   130     /**
       
   131     * Destroys the object and releases all resources.
       
   132     */    
       
   133     IMPORT_C ~CAudClipInfo();
       
   134     
       
   135     /**
       
   136     * Constructs a new CAudClipInfo object to get information
       
   137     * about the specified audio clip file. The specified observer
       
   138     * is notified when info is ready for reading. This method
       
   139     * may leave if no resources are available to construct 
       
   140     * a new object.
       
   141     * 
       
   142     * Possible leave codes:
       
   143     *    - <code>KErrNoMemory</code> if memory allocation fails
       
   144     *  - <code>KErrNotSupported</code> if the given file format is not supported 
       
   145     * or is invalid
       
   146     *
       
   147     * @param aFileHandle file handle of audio clip file
       
   148     * @param aObserver  observer to notify when info is ready for reading
       
   149     *
       
   150     * @return  pointer to a new CAudClipInfo instance
       
   151     */
       
   152     IMPORT_C static CAudClipInfo* NewL(RFile* aFileHandle, MAudClipInfoObserver& aObserver);
       
   153     
       
   154     /**
       
   155     * Constructs a new CAudClipInfo object to get information
       
   156     * about the specified audio clip file. The constructed object
       
   157     * is left in the cleanup stack. The specified observer
       
   158     * is notified when info is ready for reading. This method
       
   159     * may leave if no resources are available to construct a new
       
   160     * object.
       
   161     * 
       
   162     * Possible leave codes:
       
   163     *    - <code>KErrNoMemory</code> if memory allocation fails
       
   164     *  - <code>KErrNotSupported</code> if the given file format is not supported 
       
   165     *    or is invalid
       
   166     *
       
   167     * @param aFileHandle file handle of audio clip file    
       
   168     * @param aObserver  observer to notify when info is ready for reading
       
   169     *
       
   170     * @return  pointer to a new CAudClipInfo instance
       
   171     */
       
   172     IMPORT_C static CAudClipInfo* NewLC(RFile* aFileHandle, MAudClipInfoObserver& aObserver);
       
   173     
       
   174     /**
       
   175      * Returns the file handle of the clip. Panics if info
       
   176      * is not yet ready for reading.
       
   177      * 
       
   178      * @return  file name
       
   179      */
       
   180     IMPORT_C RFile* FileHandle() const;
       
   181     
       
   182     
       
   183 private:
       
   184     
       
   185     // C++ constructor
       
   186     CAudClipInfo();
       
   187     
       
   188     // ConstructL
       
   189     // parameters: see NewL()
       
   190     void ConstructL(const TDesC& aFileName, MAudClipInfoObserver& aObserver);
       
   191     
       
   192     void ConstructL(RFile* aFileHandle, MAudClipInfoObserver& aObserver);
       
   193     
       
   194 private:
       
   195 
       
   196     // properties of this clip
       
   197     TAudFileProperties* iProperties;
       
   198     
       
   199     // file name of this clip
       
   200     HBufC* iFileName;
       
   201     
       
   202     // file handle of this clip
       
   203     RFile* iFileHandle;
       
   204     
       
   205     // flag to indicate whether info class is ready
       
   206     TBool iInfoReady;
       
   207 
       
   208     // operation class
       
   209     CAudClipInfoOperation* iOperation;
       
   210     
       
   211     // friends
       
   212     friend class CAudClipInfoOperation;
       
   213     friend class CAudClip;
       
   214 
       
   215     
       
   216     };
       
   217 
       
   218 
       
   219 
       
   220 /**
       
   221  * Observer for notifying that audio clip info
       
   222  * is ready for reading.
       
   223  *
       
   224  */
       
   225 class MProcClipInfoObserver
       
   226     {
       
   227 public:
       
   228     /**
       
   229      * Called to notify that audio clip info is ready
       
   230      * for reading.
       
   231      *
       
   232      * Possible error codes:
       
   233      *    - <code>KErrNotFound</code> if there is no file with the specified name
       
   234      *    in the specified directory (but the directory exists)
       
   235      *    - <code>KErrPathNotFound</code> if the specified directory
       
   236      *    does not exist
       
   237      *    - <code>KErrUnknown</code> if the specified file is of unknown type
       
   238      *
       
   239      * @param aError  <code>KErrNone</code> if info is ready
       
   240      *                for reading; one of the system wide
       
   241      *                error codes if reading file failed
       
   242      */
       
   243     virtual void NotifyClipInfoReady(TInt aError) = 0;
       
   244     };
       
   245 
       
   246 
       
   247 
       
   248 /**
       
   249  * Internal class for reading information from the audio clip file.
       
   250  * Implements a simple object 
       
   251  * to report to the audio clip info observer certain common error conditions 
       
   252  * that would otherwise leave.
       
   253  */
       
   254 class CAudClipInfoOperation :    public CBase, 
       
   255                                 public MProcClipInfoObserver, 
       
   256                                 public MAudVisualizationObserver
       
   257     {
       
   258     
       
   259 public:
       
   260 
       
   261 
       
   262     /*
       
   263     * Constructor
       
   264     *
       
   265     *
       
   266     * @param aInfo        CAudClipInfo class that owns this object
       
   267     * @param aObserver    observer for callbacks
       
   268     */
       
   269 
       
   270     static CAudClipInfoOperation* NewL(CAudClipInfo* aInfo,
       
   271                                             MAudClipInfoObserver& aObserver);
       
   272 
       
   273     /*
       
   274     * Destructor
       
   275     */
       
   276     ~CAudClipInfoOperation();
       
   277     
       
   278     
       
   279     // from base class MProcClipInfoObserver
       
   280     void NotifyClipInfoReady(TInt aError);
       
   281 
       
   282     // from base class MAudVisualizationObserver
       
   283 
       
   284     void NotifySongVisualizationCompleted(const CAudSong& aSong, 
       
   285         TInt aError, 
       
   286         TInt8* aVisualization,
       
   287         TInt aSize);
       
   288 
       
   289     void NotifyClipInfoVisualizationCompleted(const CAudClipInfo& aClipInfo, 
       
   290         TInt aError, 
       
   291         TInt8* aVisualization,
       
   292         TInt aSize);
       
   293 
       
   294     void NotifySongVisualizationStarted(const CAudSong& aSong, 
       
   295         TInt aError);
       
   296 
       
   297     void NotifyClipInfoVisualizationStarted(const CAudClipInfo& aClipInfo, 
       
   298         TInt aError);
       
   299 
       
   300     void NotifySongVisualizationProgressed(const CAudSong& aSong, 
       
   301         TInt aPercentage);
       
   302 
       
   303     void NotifyClipInfoVisualizationProgressed(const CAudClipInfo& aClipInfo, 
       
   304         TInt aPercentage);
       
   305 
       
   306     /**
       
   307     * Generates a visualization of the current clip. 
       
   308     * 
       
   309     * Asynchronous operation; MAudVisualizationObserver::NotifyClipVisualizationCompleted
       
   310     * is called as soon as the visualization process has completed. This method leads to
       
   311     * memory reservation, so once NotifyClipVisualizationCompleted has occurred, 
       
   312     * the caller is responsible for memory releasing.
       
   313     * 
       
   314     * Possible leave codes:
       
   315     *    - <code>KErrNoMemory</code> if memory allocation fails
       
   316     *
       
   317     * @param aObserver            observer to be notified when visualization is completed
       
   318     * @param aSize                the size of aVisualization array (time resolution).
       
   319     * @param aPriority            priority
       
   320     *
       
   321     */
       
   322         
       
   323     void StartVisualizationL(MAudVisualizationObserver& aObserver, TInt aSize, TInt aPriority);
       
   324 
       
   325     /**
       
   326     * Cancels visualization generation. If no visualization is currently being 
       
   327     * generated, the function does nothing.
       
   328     */
       
   329         
       
   330     void CancelVisualization();
       
   331 
       
   332     /**
       
   333      * Called to start getting file properties
       
   334      *
       
   335      * NotifyClipInfoReady is called as soon as the operation completes
       
   336      */
       
   337     void StartGetPropertiesL();
       
   338 
       
   339 
       
   340 private:
       
   341     
       
   342     CAudClipInfoOperation(CAudClipInfo* aInfo, 
       
   343                                MAudClipInfoObserver& aObserver);
       
   344     void ConstructL();
       
   345     
       
   346 
       
   347 private:
       
   348 
       
   349     // info class that owns this object
       
   350     CAudClipInfo* iInfo;
       
   351     
       
   352     // observer for clip info callbacks
       
   353     MAudClipInfoObserver* iObserver;
       
   354     
       
   355     // observer for visualization callbacks
       
   356     MAudVisualizationObserver* iVisualizationObserver;
       
   357     
       
   358     // processor class owned by this object
       
   359     CAudProcessor* iProcessor;
       
   360 
       
   361     friend class CAudClipInfo;
       
   362     friend class CAudClip;
       
   363 
       
   364     };
       
   365 
       
   366 
       
   367 
       
   368 
       
   369 #endif