videoeditorengine/audioeditorengine/inc/AudProcessorImpl.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 __CAUDPROCESSORIMPL_H__
       
    22 #define __CAUDPROCESSORIMPL_H__
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <e32math.h>
       
    26 #include "AudClipInfo.h"
       
    27 #include "AudCommon.h"
       
    28 #include "AudSong.h"
       
    29 #include "ProcInFileHandler.h"
       
    30 
       
    31 #include "ProcFrameHandler.h"
       
    32 #include "ProcWAVFrameHandler.h"
       
    33 
       
    34 
       
    35 
       
    36 
       
    37 #include "ProcTools.h"
       
    38 
       
    39 
       
    40 class MProcClipInfoObserver;
       
    41 
       
    42 class CAudProcessorImpl : public CBase
       
    43     {
       
    44     
       
    45 public:
       
    46 
       
    47     /*
       
    48     *
       
    49     * Symbian constructors and a destructor
       
    50     *
       
    51     */
       
    52 
       
    53     static CAudProcessorImpl* NewL();
       
    54     static CAudProcessorImpl* NewLC();
       
    55 
       
    56     virtual ~CAudProcessorImpl();
       
    57 
       
    58 
       
    59     /**
       
    60     * Performs all initializations needed for a song processing
       
    61     * such as output file opening
       
    62     * 
       
    63     * Can leave with one of the system wide error codes
       
    64     * related to memory allocation and file opening
       
    65     *
       
    66     * Possible panic code
       
    67     * <code>ESongProcessingOperationAlreadyRunning</code>
       
    68     *
       
    69     *
       
    70     *
       
    71     * @param aSong              song to be processed
       
    72     * @param aRawFrameSize      length of raw audio frames
       
    73     * @param aGetTimeEstimation ETrue if getting a time estimation
       
    74     *
       
    75     * @return
       
    76     *
       
    77     */
       
    78     void ProcessSongL(const CAudSong* aSong, TInt aRawFrameSize, 
       
    79                       TBool aGetTimeEstimation = EFalse);
       
    80     
       
    81     /**
       
    82     * Processes one audio frame and writes it to an output file
       
    83     *
       
    84     * Possible panic code
       
    85     * <code>ESongProcessingOperationNotRunning</code>
       
    86     *
       
    87     * @param aProgress    output parameter to indicate progress in percents
       
    88     *
       
    89     *
       
    90     * @return            ETrue if processing completed, EFalse otherwise
       
    91     *
       
    92     */
       
    93     TBool ProcessSyncPieceL(HBufC8*& aFrame, TInt& aProgress,
       
    94                                        TTimeIntervalMicroSeconds& aDuration, TBool& aRaw);
       
    95 
       
    96 
       
    97 
       
    98     /**
       
    99     * Gets properties of an audio file
       
   100     * 
       
   101     * Can leave with one of the error codes related to file opening
       
   102     * 
       
   103     * @param aFileName        name of the file
       
   104     * @param aFileHandle      file handle of the file to read
       
   105     * @param aProperties    pointer to audio file properties (needs to be
       
   106     *                        allocated before calling this function)
       
   107     *
       
   108     */
       
   109     void GetAudFilePropertiesL(const TDesC& aFileName, RFile* aFileHandle,
       
   110                                TAudFileProperties* aProperties);
       
   111 
       
   112     /**
       
   113     *
       
   114     * Gets time estimate once the time estimate has been calculated
       
   115     *
       
   116     * If time estimation has not been processed, returns 0
       
   117     *
       
   118     * @return processing time estimate in microseconds
       
   119     */
       
   120     
       
   121     TInt64 GetFinalTimeEstimate() const;
       
   122     
       
   123 
       
   124 private:
       
   125     
       
   126     /*
       
   127     * Symbian constructor
       
   128     */
       
   129     void ConstructL();
       
   130 
       
   131     /*
       
   132     * Generates processing events for the output clip
       
   133     */
       
   134     void GetProcessingEventsL();
       
   135 
       
   136     /*
       
   137     * Calculates a gain value on a given time
       
   138     */
       
   139     TInt8 GetGainNow(const CAudClip* aClip, TInt32 aTimeMilliSeconds);
       
   140 
       
   141     /*
       
   142     * Stops processing
       
   143     */
       
   144     TBool StopProcessing();
       
   145 
       
   146     /*
       
   147     * Writes one frame of silence
       
   148     */
       
   149     TBool WriteSilenceL(HBufC8*& aFrame, TInt& aProgress,
       
   150                                        TTimeIntervalMicroSeconds& aDuration, TBool& aRaw);
       
   151     /*
       
   152     * Returns the index of the clip with highest priority 
       
   153     */
       
   154     TBool HighestInFilePriority(TInt& aFirst, TInt& aSecond);
       
   155     
       
   156     /*
       
   157     * Compares the two properties and returns true if decoding is required
       
   158     */
       
   159     TBool IsDecodingRequired(const TAudFileProperties& prop1, const TAudFileProperties& prop2);
       
   160 
       
   161     /*
       
   162     * C++ constructor
       
   163     */
       
   164     CAudProcessorImpl();
       
   165     
       
   166 private:
       
   167     
       
   168     // Array for all the input clips
       
   169     RPointerArray<CProcInFileHandler> iInFiles;
       
   170     
       
   171     // Song
       
   172     const CAudSong* iSong;
       
   173 
       
   174     // frame handler for PCM operations such as mixing
       
   175     CProcWAVFrameHandler* iWAVFrameHandler;
       
   176 
       
   177     // time left before the end of last clip
       
   178     // (additional silence may be written after that)
       
   179     TInt32 iTimeLeft;
       
   180     
       
   181     // index of the current processing event
       
   182     TInt iCurEvent;
       
   183 
       
   184     // array for processing events
       
   185     RPointerArray<CProcessingEvent> iProcessingEvents;
       
   186     
       
   187     // array for storing clip indexes that are currenty written
       
   188     RArray<TInt> iClipsWritten;
       
   189     
       
   190     
       
   191     // song duration in milliseconds
       
   192     TInt iSongDurationMilliSeconds;
       
   193 
       
   194     // how much has already been processed
       
   195     TInt iSongProcessedMilliSeconds;
       
   196 
       
   197     // index of the clip that was previously processed
       
   198     TInt iLastInClip1;
       
   199     
       
   200     // a flag to indicate if we are getting a processing time estimate
       
   201     TBool iGetTimeEstimation;
       
   202     
       
   203     // timer for calculating time estimation
       
   204     TTime iTimer;
       
   205     
       
   206     // a variable for time estimate
       
   207     TInt64 iTimeEstimate;
       
   208     
       
   209     // a variable for time estimate calculation
       
   210     TReal iTimeEstimateCoefficient;
       
   211     
       
   212     TBool iSilenceStarted;
       
   213     
       
   214     };
       
   215 
       
   216 
       
   217 #endif