omxil/mmilapi/refomxil/src/omxilgenericilif/omxilgenericilif.cpp
changeset 56 b6488ac24ddc
parent 47 481b3bce574a
child 57 1cbb0d5bf7f2
equal deleted inserted replaced
47:481b3bce574a 56:b6488ac24ddc
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "omxilgenericilif.h"
       
    17 #include "omxilgenericilifbody.h"
       
    18 #include "omxilcoreutils.h" 
       
    19 #include "ilifuids.h"
       
    20 #include <openmax/il/khronos/v1_x/OMX_Types.h>
       
    21 
       
    22 
       
    23 const TUint32  KOMXALL = 0xFFFFFFFF;
       
    24 
       
    25 
       
    26 EXPORT_C COmxILGenericILIF::COmxILGenericILIF()
       
    27 	{ 
       
    28 	}
       
    29 
       
    30 EXPORT_C COmxILGenericILIF::~COmxILGenericILIF()
       
    31 	{
       
    32 	if (iBody)
       
    33 		{
       
    34 		delete iBody;
       
    35 		}
       
    36 	}
       
    37 
       
    38 EXPORT_C void COmxILGenericILIF::CreateComponentL(const TDesC8& aComponentName, 
       
    39 												  MILIfObserver& aComponentIfObserver)
       
    40 	{
       
    41 	iBody = CBody::NewL(*this, aComponentIfObserver, aComponentName);
       
    42 
       
    43 	User::LeaveIfError(iBody->SetPortsL());
       
    44 	}
       
    45 
       
    46 EXPORT_C void COmxILGenericILIF::CreateComponentL(const TUid& /*aUid*/, 
       
    47 												  MILIfObserver& /*ComponentIfObserver*/)
       
    48 	{
       
    49 	// OMX Versions do not use this method of creation
       
    50 	User::Leave(KErrNotSupported);
       
    51 	}
       
    52 
       
    53 EXPORT_C void COmxILGenericILIF::ReleaseComponent()
       
    54 	{
       
    55 	delete iBody;
       
    56 	iBody = NULL;
       
    57 	
       
    58 	delete this;
       
    59 	}
       
    60 
       
    61 EXPORT_C TInt COmxILGenericILIF::GetComponentInputPorts(RPointerArray<MILComponentPortIf>& aComponentPorts) const
       
    62 	{
       
    63 	return (iBody->GetComponentPorts(aComponentPorts, OMX_DirInput));
       
    64 	}
       
    65 
       
    66 EXPORT_C TInt COmxILGenericILIF::GetComponentOutputPorts(RPointerArray<MILComponentPortIf>& aComponentPorts) const
       
    67 	{
       
    68 	return (iBody->GetComponentPorts(aComponentPorts, OMX_DirOutput));	
       
    69 	}
       
    70 
       
    71 EXPORT_C TInt COmxILGenericILIF::SetConfig(const TILStruct& /*aConfig*/, 
       
    72 										   const MILComponentPortIf* /*aComponentPort*/) 
       
    73 	{
       
    74 	// It should be implemented in the derived class
       
    75 	return (KErrNotSupported);
       
    76 	}	
       
    77 
       
    78 EXPORT_C TInt COmxILGenericILIF::GetConfig(TILStruct& /*aConfig*/, 
       
    79 										   const MILComponentPortIf* /*aComponentPort*/) const
       
    80 	{
       
    81 	// It should be implemented in the derived class
       
    82 	return (KErrNotSupported);
       
    83 	}
       
    84 
       
    85 EXPORT_C TInt COmxILGenericILIF::Initialize()
       
    86 	{
       
    87 	return (iBody->OmxSendCommand(OMX_CommandStateSet, OMX_StateIdle, NULL));
       
    88 	}
       
    89 
       
    90 EXPORT_C TInt COmxILGenericILIF::Execute()
       
    91 	{
       
    92 	return (iBody->OmxSendCommand(OMX_CommandStateSet, OMX_StateExecuting, NULL));
       
    93 	} 
       
    94 
       
    95 EXPORT_C TInt COmxILGenericILIF::Pause()
       
    96 	{
       
    97 	return (iBody->OmxSendCommand(OMX_CommandStateSet, OMX_StatePause, NULL));
       
    98 	}
       
    99 	
       
   100 EXPORT_C TInt COmxILGenericILIF::Stop()
       
   101 	{
       
   102 	return (iBody->OmxSendCommand(OMX_CommandStateSet, OMX_StateIdle, NULL));	
       
   103 	}
       
   104 	
       
   105 EXPORT_C TInt COmxILGenericILIF::UnInitialize()
       
   106 	{
       
   107 	return (iBody->OmxSendCommand(OMX_CommandStateSet, OMX_StateLoaded, NULL));	
       
   108 	}
       
   109 	
       
   110 EXPORT_C TInt COmxILGenericILIF::GetState(TILComponentState& aState) const
       
   111 	{
       
   112 	TInt error; 
       
   113 	OMX_STATETYPE state;
       
   114 	error = iBody->OmxGetState(&state);
       
   115 	aState = ConvertOmxState(state);
       
   116 	return error;
       
   117 	}
       
   118 
       
   119 EXPORT_C TInt COmxILGenericILIF::SendCommand(const TILCommand& aCommand)
       
   120 	{
       
   121 	OMX_COMMANDTYPE command = ConvertSymbianCommandType(aCommand.iCmd);
       
   122 	return (iBody->OmxSendCommand(command, aCommand.iData1, aCommand.iExtraData));
       
   123 	}
       
   124 
       
   125 EXPORT_C TInt COmxILGenericILIF::FlushAllPorts()
       
   126 	{
       
   127 	return (iBody->OmxSendCommand(OMX_CommandFlush, KOMXALL, NULL));
       
   128 	}
       
   129 
       
   130 EXPORT_C TInt COmxILGenericILIF::ComponentRoleEnum(TPtr8& aComponentRole, 
       
   131 												   TUint32 aIndex) const
       
   132 	{
       
   133 	return (iBody->OmxComponentRoleEnum(aComponentRole, aIndex));
       
   134 	}
       
   135 
       
   136 EXPORT_C TInt COmxILGenericILIF::GetComponentVersion(TILComponentVersion& aVersion) const
       
   137 	{
       
   138 	return (iBody->OmxGetComponentVersion(aVersion.iComponentName, 
       
   139 										  (OMX_VERSIONTYPE*)&aVersion.iComponentVersion, 
       
   140 										  (OMX_VERSIONTYPE*)&aVersion.iSpecVersion, 
       
   141 										  (OMX_UUIDTYPE*)&aVersion.iComponentUniqueID));	
       
   142 	}
       
   143 
       
   144 EXPORT_C TInt COmxILGenericILIF::SetComponentIfRole(const TUid& aComponentRole)
       
   145 	{
       
   146 	return (iBody->SetIfToRole(aComponentRole));
       
   147 	}
       
   148 	
       
   149 EXPORT_C TInt COmxILGenericILIF::SetComponentIfRole(const TDesC8& /*aComponentRole*/)
       
   150 	{
       
   151 	// Under A3F the roles are identified by Format Uid rather than role names.
       
   152 	return (KErrNotSupported);
       
   153 	}
       
   154 
       
   155 EXPORT_C TInt COmxILGenericILIF::GetComponentIfRole(TUid& aComponentRole) const
       
   156 	{
       
   157 	return (iBody->GetIfRole(aComponentRole));
       
   158 	}
       
   159 
       
   160 EXPORT_C TInt COmxILGenericILIF::GetComponentIfRole(TDes8& /*aComponentRole*/) const
       
   161 	{
       
   162 	// Under A3F the roles are identified by Format Uid rather than role names.
       
   163 	return (KErrNotSupported);
       
   164 	}
       
   165 
       
   166 EXPORT_C TInt COmxILGenericILIF::SetExtConfig(const TDesC8& /*aParameterName*/, 
       
   167 											  const TILStruct& /*aConfig*/, 
       
   168 											  const MILComponentPortIf* /*aComponentPort*/)
       
   169 	{
       
   170 	// It should be implemented in the derived class
       
   171 	return (KErrNotSupported);
       
   172 	}
       
   173 
       
   174 EXPORT_C TInt COmxILGenericILIF::GetExtConfig(const TDesC8& /*aParameterName*/, 
       
   175 											  TILStruct& /*aConfig*/, 
       
   176 											  const MILComponentPortIf* /*aComponentPort*/) const
       
   177 	{
       
   178 	// It should be implemented in the derived class
       
   179 	return (KErrNotSupported);
       
   180 	}
       
   181 
       
   182 EXPORT_C TAny* COmxILGenericILIF::CustomInterface(TUid aUid)
       
   183 	{
       
   184 	if (aUid == KUidILComponentIf)
       
   185 		{
       
   186 		MILComponentIf* componentIf = this;
       
   187 		return componentIf;
       
   188 		}
       
   189 	else		
       
   190 		{
       
   191 		return NULL;
       
   192 		}
       
   193 	}
       
   194 	
       
   195 EXPORT_C TInt COmxILGenericILIF::FillBufferDone(CMMFBuffer* aBuffer, 
       
   196 												TInt aPortIndex)
       
   197 	{
       
   198 	return (iBody->FillBufferDone(aBuffer, aPortIndex));
       
   199 	}
       
   200 
       
   201 EXPORT_C TInt COmxILGenericILIF::EmptyBufferDone(const CMMFBuffer* aBuffer, 
       
   202 												 TInt aPortIndex)
       
   203 	{
       
   204 	return (iBody->EmptyBufferDone(aBuffer, aPortIndex));
       
   205 	}
       
   206 
       
   207 EXPORT_C TInt COmxILGenericILIF::EventHandler(OMX_EVENTTYPE aEvent, 
       
   208 											  TUint32 aData1, 
       
   209 											  TUint32 aData2, 
       
   210 											  TAny* aExtraInfo)
       
   211 	{
       
   212 	return (iBody->EventHandler(aEvent, aData1, aData2, aExtraInfo));
       
   213 	}
       
   214 
       
   215 EXPORT_C TInt COmxILGenericILIF::OmxGetParameter(OMX_INDEXTYPE aParamIndex, 
       
   216 												 TAny* aComponentParameterStructure) const
       
   217 	{
       
   218 	return (iBody->OmxGetParameter(aParamIndex, aComponentParameterStructure));
       
   219 	}
       
   220 
       
   221 EXPORT_C TInt COmxILGenericILIF::OmxSetParameter(OMX_INDEXTYPE aParamIndex, 
       
   222 												 TAny* aComponentParameterStructure)
       
   223 	{
       
   224 	return (iBody->OmxSetParameter(aParamIndex, aComponentParameterStructure));
       
   225 	}
       
   226 
       
   227 EXPORT_C TInt COmxILGenericILIF::OmxGetConfig(OMX_INDEXTYPE aConfigIndex, 
       
   228 											  TAny* aValue) const
       
   229 	{
       
   230 	return (iBody->OmxGetConfig(aConfigIndex, aValue));
       
   231 	}
       
   232 
       
   233 EXPORT_C TInt COmxILGenericILIF::OmxSetConfig(OMX_INDEXTYPE aConfigIndex, 
       
   234 											  TAny* aValue) 
       
   235 	{
       
   236 	return (iBody->OmxSetConfig(aConfigIndex, aValue));
       
   237 	}
       
   238 
       
   239 EXPORT_C TInt COmxILGenericILIF::OmxGetExtensionIndex(const TDesC8& aParameterName, 
       
   240 											 OMX_INDEXTYPE* aIndexType) const
       
   241 	{
       
   242 	return (iBody->OmxGetExtensionIndex(aParameterName, aIndexType));
       
   243 	}
       
   244 	
       
   245 TInt COmxILGenericILIF::OmxSendCommand(OMX_COMMANDTYPE aCmd, 
       
   246 									   TUint32 aParam1, 
       
   247 									   TAny* aCmdData)
       
   248 	{
       
   249 	return (iBody->OmxSendCommand(aCmd, aParam1, aCmdData));
       
   250 	}
       
   251 
       
   252 TInt COmxILGenericILIF::OmxComponentTunnelRequest(TUint32 aPortInput, 
       
   253 												  OMX_HANDLETYPE aOutput, 
       
   254 												  TUint32 aPortOutput)
       
   255 	{
       
   256 	return (iBody->OmxComponentTunnelRequest(aPortInput, aOutput, aPortOutput));
       
   257 	}
       
   258 
       
   259 TInt COmxILGenericILIF::OmxComponentDisconnectTunnel(TUint32 aPortInput, 
       
   260 												    OMX_HANDLETYPE aOutput, 
       
   261 												    TUint32 aPortOutput)
       
   262 	{
       
   263 	return (iBody->OmxComponentDisconnectTunnel(aPortInput, aOutput, aPortOutput));
       
   264 	}
       
   265 
       
   266 TInt COmxILGenericILIF::OmxUseBuffer(CMMFBuffer* aBuffer, 
       
   267 									 TUint32 aPortIndex)
       
   268 	{
       
   269 	return (iBody->OmxUseBuffer(aBuffer, aPortIndex));
       
   270 	}
       
   271 
       
   272 CMMFBuffer* COmxILGenericILIF::OmxAllocateBufferL(TUint32 aPortIndex, 
       
   273 												  TUint32 aSizeBytes)
       
   274 	{
       
   275 	return (iBody->OmxAllocateBufferL(aPortIndex, aSizeBytes));
       
   276 	}
       
   277 
       
   278 TInt COmxILGenericILIF::OmxFreeBuffer(CMMFBuffer* aBuffer)
       
   279 	{
       
   280 	return (iBody->OmxFreeBuffer(aBuffer));
       
   281 	}
       
   282 
       
   283 TInt COmxILGenericILIF::OmxEmptyThisBuffer(const CMMFBuffer* aBuffer, 
       
   284 										   MOmxILComponentIfObserver* aObserver)
       
   285 	{
       
   286 	return (iBody->OmxEmptyThisBuffer(aBuffer, aObserver));
       
   287 	}
       
   288 
       
   289 TInt COmxILGenericILIF::OmxFillThisBuffer(CMMFBuffer* aBuffer, 
       
   290 										  MOmxILComponentIfObserver* aObserver)
       
   291 	{
       
   292 	return (iBody->OmxFillThisBuffer(aBuffer, aObserver));
       
   293 	}
       
   294 
       
   295 
       
   296 OMX_COMPONENTTYPE* COmxILGenericILIF::OmxHandle() const
       
   297 	{
       
   298 	return (iBody->Handle());	
       
   299 	}