omxilcomp/omxilaudioemulator/pcmrenderer/src/omxilpcmrenderer.cpp
changeset 0 58be5850fb6c
child 1 e0d606d6e3b1
equal deleted inserted replaced
-1:000000000000 0:58be5850fb6c
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22 */
       
    23 #include <openmax/il/common/omxilspecversion.h>
       
    24 #include <openmax/il/common/omxilclientclockport.h>
       
    25 #include <openmax/il/loader/omxilsymbiancomponentif.h>
       
    26 #include "log.h"
       
    27 #include "omxilpcmrenderer.h"
       
    28 #include "omxilpcmrendererapb0port.h"
       
    29 #include "omxilpcmrendererprocessingfunction.h"
       
    30 #include "omxilpcmrendererconfigmanager.h"
       
    31 #include "omxilpcmrenderer.hrh"
       
    32 
       
    33 
       
    34 const TUint8 COmxILPcmRenderer::iComponentVersionMajor;
       
    35 const TUint8 COmxILPcmRenderer::iComponentVersionMinor;
       
    36 const TUint8 COmxILPcmRenderer::iComponentVersionRevision;
       
    37 const TUint8 COmxILPcmRenderer::iComponentVersionStep;
       
    38 
       
    39 
       
    40 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidSymbianOmxILPcmRenderer);
       
    41 
       
    42 // Component Entry Point
       
    43 OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE aComponent)
       
    44 	{
       
    45 	// This method should be called as a result of a OMX_GetHandle call. Let's
       
    46 	// return something that is consistent with the return codes allowed for
       
    47 	// that API call.	
       
    48 	return COmxILComponent::SymbianErrorToGetHandleError(COmxILPcmRenderer::CreateComponent(aComponent));
       
    49 	}
       
    50 
       
    51 
       
    52 TInt COmxILPcmRenderer::CreateComponent(OMX_HANDLETYPE aComponent)
       
    53 	{
       
    54     DEBUG_PRINTF(_L8("COmxILPcmRenderer::CreateComponent"));
       
    55 
       
    56 	COmxILPcmRenderer* self = new COmxILPcmRenderer();
       
    57 
       
    58 	if (!self)
       
    59 		{
       
    60 		return KErrNoMemory;
       
    61 		}
       
    62 
       
    63 	TRAPD(err, self->ConstructL(aComponent));
       
    64 	if (err != KErrNone)
       
    65 		{
       
    66 		delete self;
       
    67 		}
       
    68 	return err;
       
    69 
       
    70 	}
       
    71 
       
    72 void COmxILPcmRenderer::ConstructL(OMX_HANDLETYPE aComponent)
       
    73 	{
       
    74     DEBUG_PRINTF(_L8("COmxILPcmRenderer::ConstructL"));
       
    75 
       
    76 	// STEP 1: Initialize the data received from the IL Core
       
    77 	COmxILComponent::ConstructL(aComponent);
       
    78 
       
    79 	// STEP 2: Create the call backs manager...
       
    80 	MOmxILCallbackNotificationIf* callbackNotificationIf(0);
       
    81 #ifdef _OMXIL_PCMRENDERER_INCONTEXT_CALLBACKMANAGER_ON
       
    82 	callbackNotificationIf=CreateCallbackManagerL(COmxILComponent::EInContext);
       
    83 #else
       
    84 	callbackNotificationIf=CreateCallbackManagerL(COmxILComponent::EOutofContext);
       
    85 #endif
       
    86 
       
    87 	// STEP 3: Create the PCM renderer-specific Processing Function...
       
    88 
       
    89 	// ...create PCM renderer component Client Clock port
       
    90 	COmxILClientClockPort* clientClockPort = ConstructClientClockPortL();
       
    91 	CleanupStack::PushL(clientClockPort);
       
    92 	
       
    93 	COmxILProcessingFunction* pProcessingFunction = COmxILPcmRendererProcessingFunction::NewL(*callbackNotificationIf, *clientClockPort);
       
    94 	RegisterProcessingFunction(pProcessingFunction);
       
    95 	
       
    96 	// STEP 4: Create Port manager...
       
    97 	CreatePortManagerL(COmxILComponent::ENonBufferSharingPortManager,
       
    98 					iOmxILVersion,               // Component's OMX Version
       
    99 					1,					         // The number of audio ports in this component
       
   100 					KPCMRENDERER_APB0PORT_INDEX, // The starting audio port index
       
   101 					0,					         // The number of image ports in this component
       
   102 					0,					         // The starting image port index
       
   103 					0,					         // The number of video ports in this component
       
   104 					0,					         // The starting video port index
       
   105 					1,					         // The number of other ports in this component
       
   106 					KPCMRENDERER_OPB0PORT_INDEX	 // The starting other port index
       
   107 					);
       
   108 							
       
   109 	// ...create PCM renderer component ports (no OPB0 port)
       
   110 	COmxILPcmRendererAPB0Port* pb0Port = ConstructAPB0PortL();
       
   111 	CleanupStack::PushL(pb0Port);
       
   112 	
       
   113 	// ..  and add them to the port manager...
       
   114 	User::LeaveIfError(AddPort(pb0Port, OMX_DirInput));
       
   115 	CleanupStack::Pop(); //pb0Port
       
   116 
       
   117     User::LeaveIfError(AddPort(clientClockPort, OMX_DirInput));
       
   118     CleanupStack::Pop(); //clientClockPort
       
   119 
       
   120 	
       
   121 	// STEP 5: Create the non-port related configuration manager...
       
   122 	RPointerArray<TDesC8> componentRoles;
       
   123 	CleanupClosePushL(componentRoles);
       
   124 	User::LeaveIfError(componentRoles.Append(&KSymbianOmxILPcmRendererRole()));
       
   125 
       
   126 	COmxILConfigManager* pConfigManager = COmxILPcmRendererConfigManager::NewL(
       
   127 		*static_cast<COmxILPcmRendererProcessingFunction*>(pProcessingFunction),
       
   128 		KSymbianOmxILPcmRendererName,
       
   129 		TOmxILVersion(iComponentVersionMajor,
       
   130 					  iComponentVersionMinor,
       
   131 					  iComponentVersionRevision,
       
   132 					  iComponentVersionStep),
       
   133 		componentRoles);
       
   134 		
       
   135 	RegisterConfigurationManager(pConfigManager);
       
   136 	
       
   137 	CleanupStack::Pop();	// componentRoles
       
   138 	componentRoles.Close(); // Must not destroy pointers
       
   139 
       
   140 	// And finally, let's get everything started
       
   141 	InitComponentL();
       
   142 	}
       
   143 
       
   144 COmxILPcmRenderer::COmxILPcmRenderer()
       
   145 	:
       
   146 	iOmxILVersion(TOmxILSpecVersion())
       
   147 	{
       
   148     DEBUG_PRINTF(_L8("COmxILPcmRenderer::COmxILPcmRenderer"));
       
   149 	}
       
   150 
       
   151 COmxILPcmRenderer::~COmxILPcmRenderer()
       
   152 	{
       
   153     DEBUG_PRINTF(_L8("COmxILPcmRenderer::~COmxILPcmRenderer"));
       
   154 	}
       
   155 
       
   156 
       
   157 COmxILPcmRendererAPB0Port* COmxILPcmRenderer::ConstructAPB0PortL() const
       
   158 	{
       
   159     DEBUG_PRINTF(_L8("COmxILPcmRenderer::ConstructAPB0PortL"));
       
   160 
       
   161 	RArray<OMX_AUDIO_CODINGTYPE> supportedAudioFormats;
       
   162 	CleanupClosePushL(supportedAudioFormats);
       
   163 	supportedAudioFormats.AppendL(OMX_AUDIO_CodingPCM);
       
   164 
       
   165 	OMX_AUDIO_PARAM_PCMMODETYPE	paramPcmModeType;
       
   166 	paramPcmModeType.nSize				= sizeof(OMX_AUDIO_PARAM_PCMMODETYPE);
       
   167 	paramPcmModeType.nVersion			= iOmxILVersion;
       
   168 	paramPcmModeType.nPortIndex			= KPCMRENDERER_APB0PORT_INDEX;
       
   169 	paramPcmModeType.nChannels			= KDefaultNumberChannels;
       
   170 	paramPcmModeType.eNumData			= OMX_NumericalDataSigned;
       
   171 	paramPcmModeType.eEndian			= OMX_EndianBig;
       
   172 	paramPcmModeType.bInterleaved		= OMX_TRUE;
       
   173 	paramPcmModeType.nBitPerSample		= KDefaultBitPerSample;
       
   174 	paramPcmModeType.nSamplingRate		= KDefaultSampleRate;
       
   175 	paramPcmModeType.ePCMMode			= OMX_AUDIO_PCMModeLinear;
       
   176 	paramPcmModeType.eChannelMapping[0] = OMX_AUDIO_ChannelLF;
       
   177 	paramPcmModeType.eChannelMapping[1] = OMX_AUDIO_ChannelRF;
       
   178 
       
   179 	OMX_AUDIO_CONFIG_VOLUMETYPE	configAudioVolume;
       
   180 	configAudioVolume.nSize			 = sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE);
       
   181 	configAudioVolume.nVersion		 = iOmxILVersion;
       
   182 	configAudioVolume.nPortIndex	 = KPCMRENDERER_APB0PORT_INDEX;
       
   183 	configAudioVolume.bLinear		 = OMX_FALSE;
       
   184 	configAudioVolume.sVolume.nValue = 50;
       
   185 	configAudioVolume.sVolume.nMin	 = 0;
       
   186 	configAudioVolume.sVolume.nMax	 = 100;
       
   187 
       
   188 	OMX_AUDIO_CONFIG_MUTETYPE	configAudioMute;
       
   189     configAudioMute.nSize	   = sizeof(OMX_AUDIO_CONFIG_MUTETYPE);
       
   190 	configAudioMute.nVersion   = iOmxILVersion;
       
   191 	configAudioMute.nPortIndex = KPCMRENDERER_APB0PORT_INDEX;
       
   192 	configAudioMute.bMute	   = OMX_FALSE;
       
   193 	TOmxILCommonPortData portData(iOmxILVersion,				// OMX specification version information
       
   194                                     KPCMRENDERER_APB0PORT_INDEX,// Port number the structure applies to
       
   195                                     OMX_DirInput,				// Direction of this port
       
   196                                     1,							// The minimum number of buffers this port requires
       
   197                                     15360,						// Minimum size, in bytes, for buffers to be used for this port
       
   198                                     OMX_PortDomainAudio,		// Domain of the port
       
   199                                     OMX_FALSE,					// Buffers contiguous requirement (true or false)
       
   200                                     0,							// Buffer aligment requirements
       
   201                                     OMX_BufferSupplyInput,     	// supplier preference when tunneling between two ports
       
   202                                     // This component is a sink component so there's no need to
       
   203                                     // propagate buffer marks received on input ports
       
   204                                     COmxILPort:: KBufferMarkPropagationPortNotNeeded);
       
   205 	
       
   206 	COmxILPcmRendererAPB0Port* apb0Port = COmxILPcmRendererAPB0Port::NewL(portData,
       
   207                                                                         supportedAudioFormats,
       
   208                                                                         paramPcmModeType,
       
   209                                                                         configAudioVolume,
       
   210                                                                         configAudioMute);
       
   211 	
       
   212 	CleanupStack::PopAndDestroy(&supportedAudioFormats);
       
   213 	return apb0Port;
       
   214 	}
       
   215 
       
   216 COmxILClientClockPort* COmxILPcmRenderer::ConstructClientClockPortL() const
       
   217 	{
       
   218     DEBUG_PRINTF(_L8("COmxILPcmRenderer::ConstructClientClockPortL"));
       
   219     
       
   220     TOmxILCommonPortData portData(iOmxILVersion, 
       
   221                                     KPCMRENDERER_OPB0PORT_INDEX,	// port index
       
   222                                     OMX_DirInput,
       
   223                                     4,								// minimum number of buffers
       
   224                                     sizeof(OMX_TIME_MEDIATIMETYPE),	// minimum buffer size, in bytes
       
   225                                     OMX_PortDomainOther,
       
   226                                     OMX_FALSE,						// do not need contigious buffers
       
   227                                     0,								// byte alignment
       
   228                                     OMX_BufferSupplyUnspecified, 
       
   229                                     COmxILPort::KBufferMarkPropagationPortNotNeeded);
       
   230 	
       
   231 	RArray<OMX_OTHER_FORMATTYPE> supportedOtherFormats;
       
   232 	CleanupClosePushL(supportedOtherFormats);
       
   233 	supportedOtherFormats.AppendL(OMX_OTHER_FormatTime);
       
   234 	COmxILClientClockPort* aClientClockPort = COmxILClientClockPort::NewL(portData, supportedOtherFormats);
       
   235 	CleanupStack::PopAndDestroy(&supportedOtherFormats);
       
   236 
       
   237 	return aClientClockPort;
       
   238 	}