omxil_generic/omxilcomplib/src/omxilport.cpp
changeset 0 0e4a32b9112d
child 2 6add9366d894
equal deleted inserted replaced
-1:000000000000 0:0e4a32b9112d
       
     1 // Copyright (c) 2008-2010 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 
       
    17 /**
       
    18  @file
       
    19  @internalComponent
       
    20 */
       
    21 
       
    22 #include <mmf/server/mmfbuffer.h>
       
    23 #include <mmf/server/mmfdatabuffer.h>
       
    24 
       
    25 #include "log.h"
       
    26 #include "omxilportimpl.h"
       
    27 #include <openmax/il/common/omxilport.h>
       
    28 #include <openmax/il/common/omxilutil.h>
       
    29 
       
    30 const TInt COmxILPort::KBufferMarkPropagationPortNotNeeded;
       
    31 
       
    32 EXPORT_C
       
    33 TOmxILCommonPortData::TOmxILCommonPortData(
       
    34 	OMX_VERSIONTYPE aOmxVersion,
       
    35 	OMX_U32 aPortIndex,
       
    36 	OMX_DIRTYPE aDirection,
       
    37 	OMX_U32 aBufferCountMin,
       
    38 	OMX_U32 aBufferSizeMin,
       
    39 	OMX_PORTDOMAINTYPE aPortDomain,
       
    40 	OMX_BOOL aBuffersContiguous,
       
    41 	OMX_U32 aBufferAlignment,
       
    42 	OMX_BUFFERSUPPLIERTYPE aBufferSupplier,
       
    43 	OMX_U32 aBufferMarkPropagationPortIndex)
       
    44 	:
       
    45 	iOmxVersion(aOmxVersion),
       
    46 	iPortIndex(aPortIndex),
       
    47 	iDirection(aDirection),
       
    48 	iBufferCountMin(aBufferCountMin),
       
    49 	iBufferSizeMin(aBufferSizeMin),
       
    50 	iPortDomain(aPortDomain),
       
    51 	iBuffersContiguous(aBuffersContiguous),
       
    52 	iBufferAlignment(aBufferAlignment),
       
    53 	iBufferSupplier(aBufferSupplier),
       
    54 	iBufferMarkPropagationPortIndex(aBufferMarkPropagationPortIndex)
       
    55 	{
       
    56 	}
       
    57 
       
    58 
       
    59 COmxILPort::COmxILPort()
       
    60 	{
       
    61     DEBUG_PRINTF(_L8("COmxILPort::COmxILPort"));
       
    62 	}
       
    63 
       
    64 
       
    65 COmxILPort::~COmxILPort()
       
    66 	{
       
    67     DEBUG_PRINTF(_L8("COmxILPort::~COmxILPort"));
       
    68 	delete ipPortImpl;
       
    69 	}
       
    70 
       
    71 void COmxILPort::ConstructL(const TOmxILCommonPortData& aCommonPortData)
       
    72 	{
       
    73     __ASSERT_DEBUG(aCommonPortData.iDirection == OMX_DirInput ||
       
    74                    aCommonPortData.iDirection == OMX_DirOutput,
       
    75                    User::Panic(KOmxILPortPanicCategory, 1));
       
    76 
       
    77     // From Section 3.1.2.12.1 .
       
    78     //
       
    79     // nBufferCountMin : "The component shall define this non-zero default
       
    80     // value."
       
    81     //
       
    82     // nBufferCountActual : "The component shall set a default value no less
       
    83     // than nBufferCountMin for this field"
       
    84     __ASSERT_DEBUG(aCommonPortData.iBufferCountMin > 0,
       
    85                    User::Panic(KOmxILPortPanicCategory, 1));
       
    86     
       
    87 	ipPortImpl=COmxILPortImpl::NewL(aCommonPortData, *this);
       
    88 	}
       
    89 	
       
    90 OMX_ERRORTYPE
       
    91 COmxILPort::GetLocalOmxParamIndexes(RArray<TUint>& aIndexArray) const
       
    92 	{
       
    93     DEBUG_PRINTF(_L8("COmxILPort::GetLocalOmxParamIndexes"));
       
    94 	
       
    95 	TInt err = aIndexArray.InsertInOrder(OMX_IndexParamPortDefinition);
       
    96 
       
    97 	// Note that index duplication is OK.
       
    98 	if (KErrNone == err || KErrAlreadyExists == err)
       
    99 		{
       
   100 		err = aIndexArray.InsertInOrder(OMX_IndexParamCompBufferSupplier);
       
   101 		}
       
   102 
       
   103 	if (KErrNone != err && KErrAlreadyExists != err)
       
   104 		{
       
   105 		return OMX_ErrorInsufficientResources;
       
   106 		}
       
   107 
       
   108 	return OMX_ErrorNone;
       
   109 
       
   110 	}
       
   111 
       
   112 OMX_ERRORTYPE
       
   113 COmxILPort::GetLocalOmxConfigIndexes(RArray<TUint>& /*aIndexArray*/) const
       
   114 	{
       
   115     DEBUG_PRINTF(_L8("COmxILPort::GetLocalOmxConfigIndexes"));
       
   116 
       
   117 	return OMX_ErrorNone;
       
   118 
       
   119 	}
       
   120 
       
   121 
       
   122 OMX_ERRORTYPE
       
   123 COmxILPort::GetParameter(OMX_INDEXTYPE aParamIndex,
       
   124 						 TAny* apComponentParameterStructure) const
       
   125 	{
       
   126     DEBUG_PRINTF(_L8("COmxILPort::GetParameter"));
       
   127 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   128 	return ipPortImpl->GetParameter(aParamIndex, apComponentParameterStructure);
       
   129 	}
       
   130 
       
   131 OMX_ERRORTYPE
       
   132 COmxILPort::SetParameter(OMX_INDEXTYPE aParamIndex,
       
   133 						 const TAny* apComponentParameterStructure,
       
   134 						 TBool& aUpdateProcessingFunction)
       
   135 	{
       
   136     DEBUG_PRINTF(_L8("COmxILPort::SetParameter"));
       
   137 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   138 	return ipPortImpl->SetParameter(aParamIndex, apComponentParameterStructure, aUpdateProcessingFunction);
       
   139 	}
       
   140 
       
   141 
       
   142 OMX_ERRORTYPE
       
   143 COmxILPort::GetConfig(OMX_INDEXTYPE /*aConfigIndex*/,
       
   144 					  TAny* /*apComponentConfigStructure*/) const
       
   145 	{
       
   146     DEBUG_PRINTF(_L8("COmxILPort::GetConfig"));
       
   147 	return OMX_ErrorUnsupportedIndex;
       
   148 	}
       
   149 
       
   150 OMX_ERRORTYPE
       
   151 COmxILPort::SetConfig(OMX_INDEXTYPE /*aConfigIndex*/,
       
   152 					  const TAny* /*apComponentConfigStructure*/,
       
   153 					  TBool& /*aUpdateProcessingFunction*/)
       
   154 	{
       
   155     DEBUG_PRINTF(_L8("COmxILPort::SetConfig"));
       
   156 	return OMX_ErrorUnsupportedIndex;
       
   157 	}
       
   158 
       
   159 OMX_ERRORTYPE
       
   160 COmxILPort::GetExtensionIndex(OMX_STRING /* aParameterName */,
       
   161 							  OMX_INDEXTYPE* /* apIndexType */) const
       
   162 	{
       
   163 	// This method is intended to be overridden by the concrete ports when
       
   164 	// needed...
       
   165 	return OMX_ErrorUnsupportedIndex;
       
   166 	}
       
   167 
       
   168 OMX_ERRORTYPE
       
   169 COmxILPort::PopulateBuffer(OMX_BUFFERHEADERTYPE** appBufferHdr,
       
   170 						   const OMX_PTR apAppPrivate,
       
   171 						   OMX_U32 aSizeBytes,
       
   172 						   OMX_U8* apBuffer,
       
   173 						   TBool& aPortPopulationCompleted)
       
   174 	{
       
   175     DEBUG_PRINTF2(_L8("COmxILPort::PopulateBuffer : pBuffer [%X]"), apBuffer);
       
   176 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   177 	return ipPortImpl->PopulateBuffer(appBufferHdr, apAppPrivate, aSizeBytes, apBuffer, aPortPopulationCompleted);
       
   178 	}
       
   179 
       
   180 
       
   181 OMX_ERRORTYPE
       
   182 COmxILPort::FreeBuffer(OMX_BUFFERHEADERTYPE* apBufferHeader,
       
   183 					   TBool& aPortDepopulationCompleted)
       
   184 	{
       
   185     DEBUG_PRINTF2(_L8("COmxILPort::FreeBuffer : BUFFER [%X]"), apBufferHeader);
       
   186 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   187 	return ipPortImpl->FreeBuffer(apBufferHeader, aPortDepopulationCompleted);
       
   188 	}
       
   189 
       
   190 
       
   191 OMX_ERRORTYPE
       
   192 COmxILPort::TunnelRequest(OMX_HANDLETYPE aTunneledComp,
       
   193 						  OMX_U32 aTunneledPort,
       
   194 						  OMX_TUNNELSETUPTYPE* apTunnelSetup)
       
   195 	{
       
   196     DEBUG_PRINTF(_L8("COmxILPort::TunnelRequest"));
       
   197 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   198 	return ipPortImpl->TunnelRequest(aTunneledComp, aTunneledPort, apTunnelSetup);
       
   199 	}
       
   200 
       
   201 
       
   202 OMX_ERRORTYPE
       
   203 COmxILPort::PopulateTunnel(TBool& portPopulationCompleted)
       
   204 	{
       
   205     DEBUG_PRINTF(_L8("COmxILPort::PopulateTunnel"));
       
   206 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   207 	return ipPortImpl->PopulateTunnel(portPopulationCompleted);
       
   208 	}
       
   209 
       
   210 
       
   211 OMX_ERRORTYPE
       
   212 COmxILPort::FreeTunnel(TBool& portDepopulationCompleted)
       
   213 	{
       
   214     DEBUG_PRINTF(_L8("COmxILPort::FreeTunnel"));
       
   215 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   216 	return ipPortImpl->FreeTunnel(portDepopulationCompleted);
       
   217 	}
       
   218 
       
   219 
       
   220 
       
   221 TBool
       
   222 COmxILPort::SetBufferSent(OMX_BUFFERHEADERTYPE* apBufferHeader,
       
   223 						  TBool& aBufferMarkedWithOwnMark)
       
   224 	{
       
   225     DEBUG_PRINTF(_L8("COmxILPort::SetBufferSent"));
       
   226 	__ASSERT_DEBUG(apBufferHeader, User::Panic(KOmxILPortPanicCategory, 1));
       
   227 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   228 	return ipPortImpl->SetBufferSent(apBufferHeader, aBufferMarkedWithOwnMark);
       
   229 	}
       
   230 
       
   231 TBool
       
   232 COmxILPort::SetBufferReturned(OMX_BUFFERHEADERTYPE* apBufferHeader)
       
   233 	{
       
   234     DEBUG_PRINTF(_L8("COmxILPort::SetBufferReturned"));
       
   235 
       
   236 	__ASSERT_DEBUG(apBufferHeader, User::Panic(KOmxILPortPanicCategory, 1));
       
   237 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   238 	return ipPortImpl->SetBufferReturned(apBufferHeader);
       
   239 	}
       
   240 
       
   241 void
       
   242 COmxILPort::SetTransitionToEnabled()
       
   243 	{
       
   244     DEBUG_PRINTF(_L8("COmxILPort::SetTransitionToEnabled"));
       
   245 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   246 	return ipPortImpl->SetTransitionToEnabled();
       
   247 	}
       
   248 
       
   249 void
       
   250 COmxILPort::SetTransitionToDisabled()
       
   251 	{
       
   252     DEBUG_PRINTF(_L8("COmxILPort::SetTransitionToDisabled"));
       
   253 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   254 	return ipPortImpl->SetTransitionToDisabled();
       
   255 	}
       
   256 
       
   257 void
       
   258 COmxILPort::SetTransitionToDisabledCompleted()
       
   259 	{
       
   260     DEBUG_PRINTF(_L8("COmxILPort::SetTransitionToDisabledCompleted"));
       
   261 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   262 	return ipPortImpl->SetTransitionToDisabledCompleted();
       
   263 	}
       
   264 
       
   265 void
       
   266 COmxILPort::SetTransitionToEnabledCompleted()
       
   267 	{
       
   268     DEBUG_PRINTF(_L8("COmxILPort::SetTransitionToEnabledCompleted"));
       
   269 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   270 	return ipPortImpl->SetTransitionToEnabledCompleted();
       
   271 	}
       
   272 
       
   273 OMX_ERRORTYPE
       
   274 COmxILPort::StoreBufferMark(const OMX_MARKTYPE* apMark)
       
   275 	{
       
   276     DEBUG_PRINTF(_L8("COmxILPort::StoreBufferMark"));
       
   277 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   278 	return ipPortImpl->StoreBufferMark(apMark);
       
   279 	}
       
   280 
       
   281 
       
   282 /**
       
   283    This utility method may be called from the most derived port
       
   284    class' destructor to delete any buffer header and or buffer that may remain
       
   285    allocated in the port. This typically happens when the component is unloaded
       
   286    without being properly transitioned from OMX_StateIdle to OMX_StateLoaded.
       
   287 
       
   288  */
       
   289 EXPORT_C void
       
   290 COmxILPort::CleanUpPort()
       
   291 	{
       
   292 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   293 	return ipPortImpl->CleanUpPort();
       
   294 	}
       
   295 
       
   296 /**
       
   297    This is to be overriden by concrete ports that either support more than
       
   298    one role or that want to let the IL Client to reset the component to
       
   299    some default state...
       
   300 
       
   301    @param aComponentRoleIndex The index of the role that is to be assumed by
       
   302    the component.
       
   303 
       
   304    @return OMX_ERRORTYPE
       
   305  */
       
   306 OMX_ERRORTYPE
       
   307 COmxILPort::SetComponentRoleDefaults(TUint /*aComponentRoleIndex*/)
       
   308 	{
       
   309     DEBUG_PRINTF(_L8("COmxILPort::SetComponentRoleDefaults"));
       
   310 
       
   311 	return OMX_ErrorNotImplemented;
       
   312 	}
       
   313 
       
   314 /**
       
   315    This is to be overriden by concrete ports that either support more than one
       
   316    role or that want to let the IL Client to reset the component to some
       
   317    default state...
       
   318 
       
   319    @param aPortSettingsIndex An implementation-specific identifier that the
       
   320    implementation associates to the setting(s) that need(s) updating in the
       
   321    port.
       
   322 
       
   323    @param aPortSettings A buffer descriptor that contains an
       
   324    implementation-specific structure with the new setting(s) that need to
       
   325    be updated in the port.
       
   326 
       
   327    @param [output] aEventForILClient An event that the port may choose to
       
   328    deliver to the IL Client. This should be one of OMX_EventPortSettingsChanged
       
   329    or OMX_EventPortFormatDetected. Use OMX_EventMax if no event need to be
       
   330    sent.
       
   331  */
       
   332 OMX_ERRORTYPE
       
   333 COmxILPort::DoPortReconfiguration(TUint /* aPortSettingsIndex */,
       
   334 								  const TDesC8& /* aPortSettings */,
       
   335 								  OMX_EVENTTYPE& aEventForILClient)
       
   336 	{
       
   337     DEBUG_PRINTF(_L8("COmxILPort::DoPortReconfiguration"));
       
   338 
       
   339 	// This means no need to notify the IL Client...
       
   340 	aEventForILClient = OMX_EventMax;
       
   341 
       
   342 	return OMX_ErrorNotImplemented;
       
   343 	}
       
   344 
       
   345 OMX_ERRORTYPE
       
   346 COmxILPort::StoreBufferMark(OMX_HANDLETYPE& ipMarkTargetComponent,
       
   347 							OMX_PTR& ipMarkData)
       
   348 	{
       
   349     DEBUG_PRINTF(_L8("COmxILPort::StoreBufferMark"));
       
   350 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   351 	return ipPortImpl->StoreBufferMark(ipMarkTargetComponent, ipMarkData);
       
   352 	}
       
   353 
       
   354 TBool
       
   355 COmxILPort::HasAllBuffersAtHome() const
       
   356 	{
       
   357 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   358 	__ASSERT_ALWAYS(ipPortImpl->IsTunnelledAndBufferSupplier(),
       
   359 					User::Panic(KOmxILPortPanicCategory, 1));
       
   360 	return ipPortImpl->HasAllBuffersAtHome();
       
   361 	}
       
   362 
       
   363 TBool
       
   364 COmxILPort::IsBufferAtHome(OMX_BUFFERHEADERTYPE* apBufferHeader) const
       
   365 	{
       
   366 	DEBUG_PRINTF2(_L8("COmxILPort::IsBufferAtHome : [%X]"), apBufferHeader);
       
   367 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   368 	return ipPortImpl->IsBufferAtHome(apBufferHeader);
       
   369 	}
       
   370 
       
   371 
       
   372 /**
       
   373    This method provides a mechanism for ports to place the port-specific
       
   374    buffer allocation logic (typically used in an OMX_AllocateBuffer
       
   375    scenario).
       
   376 
       
   377    @param aSizeBytes The size in bytes of the buffer to be allocated.
       
   378 
       
   379    @param [OUT] apPortSpecificBuffer A pointer to the memory area allocated by
       
   380    the port.
       
   381 
       
   382    @param [OUT] apPortPrivate A pointer that refers to an optional
       
   383    port-specific structure.
       
   384 
       
   385    @apPlatformPrivate[OUT] A pointer to an optional platform-specific
       
   386    structure.
       
   387 
       
   388    @param apAppPrivate A pointer that refers to a buffer supplier-specific
       
   389    structure.
       
   390 
       
   391    @return OMX_ERRORTYPE
       
   392 */
       
   393 OMX_ERRORTYPE
       
   394 COmxILPort::DoBufferAllocation(OMX_U32 aSizeBytes,
       
   395 							   OMX_U8*& apPortSpecificBuffer,
       
   396 							   OMX_PTR& apPortPrivate,
       
   397 							   OMX_PTR& /* apPlatformPrivate */,
       
   398 							   OMX_PTR /* apAppPrivate = 0 */)
       
   399 	{
       
   400 	DEBUG_PRINTF2(_L8("COmxILPort::DoBufferAllocation : aSizeBytes[%u]"), aSizeBytes);
       
   401 
       
   402 	__ASSERT_DEBUG(aSizeBytes > 0, User::Panic(KOmxILPortPanicCategory, 1));
       
   403 
       
   404 	CMMFDescriptorBuffer* pDescBuffer = 0;
       
   405 	TRAPD(allocRes, pDescBuffer = CMMFDescriptorBuffer::NewL(aSizeBytes));
       
   406 	if (KErrNone != allocRes)
       
   407 		{
       
   408 		return OMX_ErrorInsufficientResources;
       
   409 		}
       
   410 
       
   411 	apPortSpecificBuffer = const_cast<TUint8*>(pDescBuffer->Data().Ptr());
       
   412 	apPortPrivate		 = static_cast<CMMFBuffer*>(pDescBuffer);
       
   413 
       
   414 	return OMX_ErrorNone;
       
   415 
       
   416 	}
       
   417 
       
   418 /**
       
   419    This method provides a mechanism for ports to place the port-specific
       
   420    buffer deallocation logic (typically used in an OMX_FreeBuffer
       
   421    scenario).
       
   422 
       
   423    @param apPortSpecificBuffer A pointer to the memory area to be deallocated
       
   424    by the port.
       
   425 
       
   426    @param apPortPrivate A pointer that refers to a port-specific structure.
       
   427 
       
   428    @param apPlatformPrivate A pointer to an optional platform-specific
       
   429    structure.
       
   430 
       
   431    @param apAppPrivate A pointer that refers to a buffer supplier-specific
       
   432    structure.
       
   433 
       
   434 */
       
   435 void
       
   436 COmxILPort::DoBufferDeallocation(OMX_PTR /*apPortSpecificBuffer */,
       
   437 								 OMX_PTR apPortPrivate,
       
   438 								 OMX_PTR /* apPlatformPrivate */,
       
   439 								 OMX_PTR /* apAppPrivate = 0 */)
       
   440 	{
       
   441 	DEBUG_PRINTF(_L8("COmxILPort::DoBufferDeallocation"));
       
   442 
       
   443 	__ASSERT_DEBUG(apPortPrivate, User::Panic(KOmxILPortPanicCategory, 1));
       
   444 
       
   445 	delete reinterpret_cast<CMMFBuffer*>(apPortPrivate);
       
   446 
       
   447 	}
       
   448 
       
   449 /**
       
   450    This method provides a mechanism for ports to place the port-specific buffer
       
   451    wrapping logic (typically used in an OMX_UseBuffer scenario).
       
   452 
       
   453    @param aSizeBytes The size in bytes of the buffer to be wrapped.
       
   454 
       
   455    @param apBuffer A pointer received from the IL Client or another
       
   456    component that references the allocated memory area .
       
   457 
       
   458    @param [OUT] apPortPrivate A pointer that refers to a port-specific
       
   459    structure.
       
   460 
       
   461    @param [OUT] apPlatformPrivate A pointer to an optional platform-specific
       
   462    structure.
       
   463 
       
   464    @param [OUT] apAppPrivate A pointer that refers to a buffer
       
   465    supplier-specific structure.
       
   466 
       
   467    @return OMX_ERRORTYPE
       
   468 */
       
   469 OMX_ERRORTYPE
       
   470 COmxILPort::DoBufferWrapping(OMX_U32 aSizeBytes,
       
   471 							 OMX_U8* apBuffer,
       
   472 							 OMX_PTR& apPortPrivate,
       
   473 							 OMX_PTR& /* apPlatformPrivate */,
       
   474 							 OMX_PTR /* apAppPrivate = 0 */)
       
   475 	{
       
   476 	DEBUG_PRINTF(_L8("COmxILPort::DoBufferWrapping"));
       
   477 
       
   478 	__ASSERT_DEBUG(aSizeBytes > 0 && apBuffer,
       
   479 				   User::Panic(KOmxILPortPanicCategory, 1));
       
   480 
       
   481 	CMMFBuffer* pMmfBuffer = 0;
       
   482 	TPtr8 ptr(apBuffer, aSizeBytes, aSizeBytes);
       
   483 	TRAPD(allocRes, pMmfBuffer = CMMFPtrBuffer::NewL(ptr));
       
   484 	if (KErrNone != allocRes)
       
   485 		{
       
   486 		return OMX_ErrorInsufficientResources;
       
   487 		}
       
   488 
       
   489 	apPortPrivate = pMmfBuffer;
       
   490 
       
   491 	return OMX_ErrorNone;
       
   492 
       
   493 	}
       
   494 
       
   495 /**
       
   496    This method provides a mechanism for ports to place the port-specific buffer
       
   497    unwrapping logic (typically used in an OMX_FreeBuffer scenario).
       
   498 
       
   499    @param apPortSpecificBuffer A pointer to the allocated memory area.
       
   500 
       
   501    @param apPortPrivate A pointer that refers to a port-specific structure.
       
   502 
       
   503    @param apPlatformPrivate A pointer to an optional platform-specific
       
   504    structure.
       
   505 
       
   506    @param apAppPrivate A pointer that refers to a buffer supplier-specific
       
   507    structure.
       
   508 
       
   509 */
       
   510 void
       
   511 COmxILPort::DoBufferUnwrapping(OMX_PTR /* apBuffer*/,
       
   512 							   OMX_PTR appPortPrivate,
       
   513 							   OMX_PTR /* apPlatformPrivate */,
       
   514 							   OMX_PTR /* apAppPrivate = 0 */)
       
   515 	{
       
   516 
       
   517 	DEBUG_PRINTF(_L8("COmxILPort::DoBufferUnwrapping"));
       
   518 
       
   519 	__ASSERT_DEBUG(appPortPrivate, User::Panic(KOmxILPortPanicCategory, 1));
       
   520 
       
   521 	delete reinterpret_cast<CMMFBuffer*>(appPortPrivate);
       
   522 
       
   523 	}
       
   524 
       
   525 /**
       
   526    This method gets called during tunnelled buffer allocation (i.e.,
       
   527    PopulateTunnel). This is to allow component implementations to override this
       
   528    default implementation in a way that the pAppPrivate pointer parameter of
       
   529    OMX_UseBuffer can be used to convey pPortPrivate or pPlatformPrivate to the
       
   530    tunnelled component.
       
   531 
       
   532    @param aTunnelledComponent Handle to the tunnelled component
       
   533 
       
   534    @param [OUT] appBufferHdr The buffer header that will be allocated by the
       
   535    tunnelled component
       
   536 
       
   537    @param aTunnelledPortIndex The index of the tunnelled port
       
   538 
       
   539    @param apPortPrivate pPortPrivate pointer as returned by DoBufferAllocation
       
   540 
       
   541    @param apPlatformPrivate pPlatformPrivate pointer as returned by
       
   542    DoBufferAllocation
       
   543 
       
   544    @aSizeBytes The size in bytes of the to be allocated buffer
       
   545 
       
   546    @apBuffer A pointer to the allocated buffer
       
   547 
       
   548    @return OMX_ERRORTYPE
       
   549 
       
   550 */
       
   551 OMX_ERRORTYPE
       
   552 COmxILPort::DoOmxUseBuffer(OMX_HANDLETYPE aTunnelledComponent,
       
   553 						   OMX_BUFFERHEADERTYPE** appBufferHdr,
       
   554 						   OMX_U32 aTunnelledPortIndex,
       
   555 						   OMX_PTR /* apPortPrivate */,
       
   556 						   OMX_PTR /* apPlatformPrivate */,
       
   557 						   OMX_U32 aSizeBytes,
       
   558 						   OMX_U8* apBuffer)
       
   559 	{
       
   560 
       
   561 	DEBUG_PRINTF(_L8("COmxILPort::DoOmxUseBuffer"));
       
   562 
       
   563 	return OMX_UseBuffer(
       
   564 		aTunnelledComponent,
       
   565 		appBufferHdr,
       
   566 		aTunnelledPortIndex,
       
   567 		0,
       
   568 		aSizeBytes,
       
   569 		apBuffer);
       
   570 
       
   571 	}
       
   572 
       
   573 
       
   574 OMX_DIRTYPE
       
   575 COmxILPort::Direction() const
       
   576 	{
       
   577 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   578 	return ipPortImpl->Direction();
       
   579 	}
       
   580 
       
   581 EXPORT_C TBool
       
   582 COmxILPort::IsEnabled() const
       
   583 	{
       
   584 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   585 	return ipPortImpl->IsEnabled();
       
   586 	}
       
   587 
       
   588 TBool
       
   589 COmxILPort::IsPopulated() const
       
   590 	{
       
   591 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   592 	return ipPortImpl->IsPopulated();
       
   593 	}
       
   594 
       
   595 TBool
       
   596 COmxILPort::IsDePopulated() const
       
   597 	{
       
   598 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   599 	return ipPortImpl->IsDePopulated();
       
   600 	}
       
   601 
       
   602 TBool
       
   603 COmxILPort::IsTunnelled() const
       
   604 	{
       
   605 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   606 	return ipPortImpl->IsTunnelled();
       
   607 	}
       
   608 
       
   609 TBool
       
   610 COmxILPort::IsTunnelledAndBufferSupplier() const
       
   611 	{
       
   612 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   613 	return ipPortImpl->IsTunnelledAndBufferSupplier();
       
   614 	}
       
   615 
       
   616 TBool
       
   617 COmxILPort::IsTransitioningToEnabled() const
       
   618 	{
       
   619 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   620 	return ipPortImpl->IsTransitioningToEnabled();
       
   621 	}
       
   622 
       
   623 TBool
       
   624 COmxILPort::IsTransitioningToDisabled() const
       
   625 	{
       
   626 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   627 	return ipPortImpl->IsTransitioningToDisabled();
       
   628 	}
       
   629 
       
   630 EXPORT_C OMX_U32
       
   631 COmxILPort::Index() const
       
   632 	{
       
   633 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   634 	return ipPortImpl->Index();
       
   635 	}
       
   636 
       
   637 OMX_PORTDOMAINTYPE
       
   638 COmxILPort::Domain() const
       
   639 	{
       
   640 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   641 	return ipPortImpl->Domain();
       
   642 	}
       
   643 
       
   644 OMX_U32
       
   645 COmxILPort::Count() const
       
   646 	{
       
   647 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   648 	return ipPortImpl->Count();
       
   649 	}
       
   650 
       
   651 OMX_BUFFERHEADERTYPE* const&
       
   652 COmxILPort::operator[](TInt anIndex) const
       
   653 	{
       
   654 	return this->operator[](anIndex);
       
   655 	}
       
   656 
       
   657 OMX_BUFFERHEADERTYPE*&
       
   658 COmxILPort::operator[](TInt anIndex)
       
   659 	{
       
   660 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   661 	return ipPortImpl->operator[](anIndex);
       
   662 	}
       
   663 
       
   664 
       
   665 OMX_U32
       
   666 COmxILPort::BufferMarkPropagationPort() const
       
   667 	{
       
   668 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   669 	return ipPortImpl->BufferMarkPropagationPort();
       
   670 	}
       
   671 
       
   672 EXPORT_C const OMX_PARAM_PORTDEFINITIONTYPE& COmxILPort::GetParamPortDefinition() const
       
   673 	{
       
   674 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   675 	return ipPortImpl->GetParamPortDefinition();
       
   676 	}
       
   677 	
       
   678 EXPORT_C const OMX_HANDLETYPE& COmxILPort::GetTunnelledComponent() const
       
   679 	{
       
   680 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   681 	return ipPortImpl->GetTunnelledComponent();
       
   682 	}
       
   683 	
       
   684 EXPORT_C const OMX_U32& COmxILPort::GetTunnelledPort() const
       
   685 	{
       
   686 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   687 	return ipPortImpl->GetTunnelledPort();
       
   688 	}
       
   689 
       
   690 EXPORT_C OMX_PARAM_PORTDEFINITIONTYPE& COmxILPort::GetParamPortDefinition()
       
   691 	{
       
   692 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   693 	return ipPortImpl->GetParamPortDefinition();
       
   694 	}
       
   695 	
       
   696 EXPORT_C OMX_HANDLETYPE& COmxILPort::GetTunnelledComponent()
       
   697 	{
       
   698 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   699 	return ipPortImpl->GetTunnelledComponent();
       
   700 	}
       
   701 	
       
   702 EXPORT_C OMX_U32& COmxILPort::GetTunnelledPort()
       
   703 	{
       
   704 	__ASSERT_ALWAYS(ipPortImpl, User::Panic(KOmxILPortPanicCategory, 1));
       
   705 	return ipPortImpl->GetTunnelledPort();
       
   706 	}
       
   707 
       
   708 EXPORT_C
       
   709 TInt COmxILPort::Extension_(TUint aExtensionId, TAny *&a0, TAny *a1)
       
   710 	{
       
   711 	return CBase::Extension_(aExtensionId, a0, a1);
       
   712 	}	
       
   713 
       
   714 
       
   715 
       
   716