videoeditorengine/audioeditorengine/src/ProcClipInfoAO.cpp
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 
       
    22 
       
    23 #include "ProcClipInfoAO.h"
       
    24 
       
    25 // Debug print macro
       
    26 #if defined _DEBUG 
       
    27 #include <e32svr.h>
       
    28 #define PRINT(x) RDebug::Print x;
       
    29 #else
       
    30 #define PRINT(x)
       
    31 #endif
       
    32 
       
    33 void CProcClipInfoAO::RunL() 
       
    34     {
       
    35     PRINT((_L("CProcClipInfoAO::RunL in") ));
       
    36     
       
    37 
       
    38     TRAPD(error, iProcessorImpl->GetAudFilePropertiesL(*iFileName, iFileHandle, iProperties));
       
    39 
       
    40     if (error != KErrNone) 
       
    41         {
       
    42         
       
    43         delete iFileName;
       
    44         iFileName = 0;
       
    45         delete iProcessorImpl;
       
    46         iProcessorImpl = 0;
       
    47         iObserver->NotifyClipInfoReady(error);
       
    48         iProperties = 0;
       
    49         iObserver = 0;
       
    50         PRINT((_L("CProcClipInfoAO::RunL out with error %d"), error ));
       
    51         return;
       
    52         }
       
    53     else 
       
    54         {
       
    55         
       
    56         
       
    57         delete iFileName;
       
    58         iFileName = 0;
       
    59         delete iProcessorImpl;
       
    60         iProcessorImpl = 0;
       
    61         
       
    62         if (iProperties->iAudioType == EAudNoAudio)
       
    63             {
       
    64             MProcClipInfoObserver* observer = iObserver;
       
    65             
       
    66             iObserver = 0;
       
    67             observer->NotifyClipInfoReady(KErrNoAudio); 
       
    68             PRINT((_L("CProcClipInfoAO::RunL no audio in the clip") ));
       
    69 
       
    70             }
       
    71         else if (iProperties->iAudioType == EAudTypeUnrecognized ||
       
    72             iProperties->iBitrate == 0 ||
       
    73             iProperties->iBitrateMode == EAudBitrateModeNotRecognized || 
       
    74             iProperties->iFileFormat == EAudFormatUnrecognized ||
       
    75             iProperties->iChannelMode == EAudChannelModeNotRecognized ||
       
    76             iProperties->iSamplingRate == 0) 
       
    77             {
       
    78             MProcClipInfoObserver* observer = iObserver;
       
    79             
       
    80             iObserver = 0;
       
    81             observer->NotifyClipInfoReady(KErrNotSupported); 
       
    82             PRINT((_L("CProcClipInfoAO::RunL audio in the clip not supported") ));
       
    83             }
       
    84         else 
       
    85             {
       
    86             MProcClipInfoObserver* observer = iObserver;
       
    87             
       
    88             iObserver = 0;
       
    89             observer->NotifyClipInfoReady(KErrNone); 
       
    90             }
       
    91         
       
    92         }
       
    93     
       
    94     PRINT((_L("CProcClipInfoAO::RunL out") ));
       
    95 
       
    96 
       
    97     }
       
    98 
       
    99 void CProcClipInfoAO::DoCancel() 
       
   100     {
       
   101 
       
   102     }
       
   103    
       
   104 CProcClipInfoAO* CProcClipInfoAO::NewL() 
       
   105     {
       
   106 
       
   107 
       
   108     CProcClipInfoAO* self = new (ELeave) CProcClipInfoAO();
       
   109     CleanupStack::PushL(self);
       
   110     self->ConstructL();
       
   111     CleanupStack::Pop(self);
       
   112     return self;
       
   113     }
       
   114 
       
   115 CProcClipInfoAO::~CProcClipInfoAO() 
       
   116     {
       
   117     PRINT((_L("CProcClipInfoAO::~CProcClipInfoAO() in") ));
       
   118     
       
   119     Cancel();
       
   120     
       
   121     if (iFileName)
       
   122         {
       
   123         delete iFileName;
       
   124         iFileName = 0;
       
   125         }
       
   126     
       
   127     if (iProcessorImpl)
       
   128         {
       
   129         delete iProcessorImpl;
       
   130         iProcessorImpl = 0;
       
   131         }
       
   132 
       
   133     PRINT((_L("CProcClipInfoAO::~CProcClipInfoAO() out") ));
       
   134     }
       
   135     
       
   136 
       
   137 void CProcClipInfoAO::StartL(const TDesC& aFilename, 
       
   138                              RFile* aFileHandle,
       
   139                              MProcClipInfoObserver &aObserver, 
       
   140                              TAudFileProperties* aProperties,
       
   141                              TInt aPriority) 
       
   142     {
       
   143 
       
   144     iObserver = &aObserver;
       
   145     iProperties = aProperties;
       
   146 
       
   147     if (!aFileHandle)
       
   148     {        
       
   149         iFileName = HBufC::NewL(aFilename.Length());
       
   150         *iFileName = aFilename;
       
   151         iFileHandle = NULL;
       
   152     } 
       
   153     else
       
   154     {        
       
   155         iFileHandle = aFileHandle;
       
   156         iFileName = HBufC::NewL(1);
       
   157     }
       
   158     
       
   159     CAudProcessorImpl* processorImpl = CAudProcessorImpl::NewLC();
       
   160     
       
   161     CleanupStack::Pop(processorImpl);
       
   162     iProcessorImpl = processorImpl;
       
   163     
       
   164     SetPriority(aPriority);
       
   165     SetActive();
       
   166     TRequestStatus* status = &iStatus;
       
   167     User::RequestComplete(status, KErrNone);
       
   168 
       
   169     }
       
   170     
       
   171 
       
   172 
       
   173 void CProcClipInfoAO::ConstructL() 
       
   174     {
       
   175 
       
   176     }
       
   177 
       
   178 CProcClipInfoAO::CProcClipInfoAO() :  CActive(0), iProperties(0), iFileName(0)
       
   179                                        
       
   180     {
       
   181 
       
   182     CActiveScheduler::Add(this);
       
   183 
       
   184     }
       
   185