mmfenh/advancedaudiocontroller/audiocontrollerpluginsvariant/mp3audioplaycontroller/Src/MP3AudioPlayControllerPlugin.cpp
changeset 0 71ca22bcf22a
child 7 709f89d8c047
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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 *
       
    14 * Description:  Play controller for MP3 audio formats.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include "MP3AudioPlayControllerPlugin.h"
       
    21 #include "MP3AudioPlayControllerPlugin.hrh"
       
    22 #include "MP3AudioControllerUtility.h"
       
    23 #include "MP3AudioPlayControllerDecoderBuilder.h"
       
    24 #include "MP3AudioPlayControllerResource.h"
       
    25 #include "DevSoundAudioOutput.h"
       
    26 #include "FileAudioOutput.h"
       
    27 #include "DebugMacros.h"
       
    28 
       
    29 
       
    30 // CONSTANTS
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CMP3AudioPlayControllerPlugin::CMP3AudioPlayControllerPlugin
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CMP3AudioPlayControllerPlugin::CMP3AudioPlayControllerPlugin()
       
    39 	:	iDecoderBuilder(NULL)
       
    40     {
       
    41     }
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CMP3AudioPlayControllerPlugin::ConstructL
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 void CMP3AudioPlayControllerPlugin::ConstructL()
       
    48     {
       
    49     CAdvancedAudioPlayController::ConstructL();
       
    50 
       
    51 	iAudioResource = CMP3AudioPlayControllerResource::NewL();
       
    52     TAapProperties aapProperties = iAudioResource->PropertiesL();
       
    53     iSharedBufferMaxNum = aapProperties.iSharedBufferMaxNum;
       
    54     iSharedBufferMaxSize = aapProperties.iSharedBufferMaxSize;
       
    55     iMetaDataSupport = aapProperties.iMetaDataSupport;
       
    56 
       
    57 	iAudioUtility = CMP3AudioControllerUtility::NewL();
       
    58 	iDecoderBuilder = CMP3AudioPlayControllerDecoderBuilder::NewL();
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CMP3AudioPlayControllerPlugin::NewL
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 CMP3AudioPlayControllerPlugin* CMP3AudioPlayControllerPlugin::NewL()
       
    66     {
       
    67 	DP0(_L("CMP3AudioPlayControllerPlugin::NewL"));
       
    68     CMP3AudioPlayControllerPlugin* self = new(ELeave) CMP3AudioPlayControllerPlugin;
       
    69     CleanupStack::PushL(self);
       
    70     self->ConstructL();
       
    71     CleanupStack::Pop(self);
       
    72     return self;
       
    73     }
       
    74 
       
    75 // Destructor
       
    76 CMP3AudioPlayControllerPlugin::~CMP3AudioPlayControllerPlugin()
       
    77     {
       
    78 	DP0(_L("CMP3AudioPlayControllerPlugin::~CMP3AudioPlayControllerPlugin"));
       
    79    
       
    80     if (iIsDRMProtected)
       
    81 		{
       
    82 		delete iDataSource;
       
    83 		}
       
    84 
       
    85     if ((iState != EStopped) && (iState != EInitialized) && iAudioOutput)
       
    86         {
       
    87         TRAPD(err, iAudioOutput->StopL());
       
    88 		err = err;
       
    89         }
       
    90 
       
    91 	delete iDecoderBuilder;
       
    92     delete iAudioUtility;
       
    93     delete iAudioResource;
       
    94     delete iAudioOutput;
       
    95 	}
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CMP3AudioPlayControllerPlugin::DoAddDataSourceL
       
    99 // Initialization of Clip properties. We build a table needed for positioning.
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 void CMP3AudioPlayControllerPlugin::DoAddDataSourceL()
       
   103     {
       
   104     DP0(_L("CMP3AudioPlayControllerPlugin::DoAddDataSourceL"));
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CMP3AudioPlayControllerPlugin::DoAddDataSinkL
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 void CMP3AudioPlayControllerPlugin::DoAddDataSinkL()
       
   112     {
       
   113     DP0(_L("CMP3AudioPlayControllerPlugin::DoAddDataSinkL"));
       
   114     if (iDataSink->DataSinkType() == KUidMmfAudioOutput)
       
   115 		{
       
   116 		iAudioOutput = CDevSoundAudioOutput::NewL(iPrioritySettings, *this, *iMMFDevSound);
       
   117 		iDecoderType = KMP3Decoder;
       
   118         }
       
   119     else if (iDataSink->DataSinkType() == KUidMmfFileSink)
       
   120         {
       
   121 		iAudioOutput = CFileAudioOutput::NewL(*iDataSink, iPrioritySettings, *this);
       
   122 		iDecoderType = KMP3Converter;
       
   123         }
       
   124     else
       
   125         {
       
   126         User::Leave(KErrNotSupported);
       
   127         }
       
   128 	}
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CMP3AudioPlayControllerPlugin::DoReadHeaderL
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 void CMP3AudioPlayControllerPlugin::DoReadHeaderL(CMMFDataBuffer* aBuffer)
       
   135     {
       
   136     DP0(_L("CMP3AudioPlayControllerPlugin::DoReadHeaderL"));
       
   137 
       
   138     iAudioUtility->ScanHeaderL(aBuffer);
       
   139 
       
   140     iHeaderOffset = iAudioUtility->HeaderOffset();
       
   141     iSyncOffset = iAudioUtility->SyncOffset();
       
   142     iSampleRate = iAudioUtility->SampleRate();
       
   143     iSinkSampleRate = iSampleRate; // Default same as source
       
   144 //    iBitRate = iAudioUtility->BitRate();
       
   145 //    iDuration = iAudioUtility->Duration();
       
   146     iChannels = iAudioUtility->Channels();
       
   147 //    iSinkNumChannels = iChannels; // Default same as source
       
   148 //    iSinkNumChannels = iAudioUtility->ChannelsOut();
       
   149     iDataType = TFourCC(' ','M','P','3');
       
   150     
       
   151     if (!(iChannels == 1 || iChannels == 2))
       
   152         {
       
   153         User::Leave(KErrNotSupported);
       
   154         }
       
   155     
       
   156 //    iCurrentPosition = iHeaderOffset;
       
   157 //    iReadHeader = EFalse;
       
   158     }
       
   159 
       
   160 CAdvancedAudioDecoder* CMP3AudioPlayControllerPlugin::BuildDecoderL()
       
   161 	{
       
   162 	return iDecoderBuilder->BuildDecoderL(iDecoderType);
       
   163 	}
       
   164 
       
   165 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   166 
       
   167 // Exported proxy for instantiation method resolution
       
   168 // Define the interface UIDs
       
   169 const TImplementationProxy ImplementationTable[] =
       
   170     {
       
   171     IMPLEMENTATION_PROXY_ENTRY(KUIDMP3PlayControllerPluginImplementation, CMP3AudioPlayControllerPlugin::NewL)
       
   172     };
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // ImplementationGroupProxy
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
       
   179     TInt& aTableCount)
       
   180     {
       
   181     aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   182     return ImplementationTable;
       
   183     }
       
   184 
       
   185 // End of file