omxil/omxilcomponentcommon/src/common/omxilport.h
branchRCL_3
changeset 50 948c7f65f6d4
parent 0 40261b775718
child 16 eedf2dcd43c6
equal deleted inserted replaced
49:735348f59235 50:948c7f65f6d4
       
     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 
       
    17 /**
       
    18  @file
       
    19  @internalComponent
       
    20 */
       
    21 
       
    22 #ifndef OMXILPORT_H
       
    23 #define OMXILPORT_H
       
    24 
       
    25 #include <e32base.h>
       
    26 
       
    27 #include <openmax/il/khronos/v1_x/OMX_Component.h>
       
    28 #include "omxilspecversion.h"
       
    29 
       
    30 
       
    31 /**
       
    32    Base Port Panic category
       
    33 */
       
    34 _LIT(KOmxILPortPanicCategory, "OmxILPort");
       
    35 
       
    36 
       
    37 // Forward declarations
       
    38 class TOmxILCommonPortData;
       
    39 
       
    40 /**
       
    41    OpenMAX IL component port base class.
       
    42 */
       
    43 class COmxILPort : public CBase
       
    44 	{
       
    45 
       
    46 public:
       
    47 
       
    48 	static const TInt	KMaxBufferMarksQueueSize			= 10;
       
    49 	static const TInt	KBufferMarkPropagationPortNotNeeded = 0x7FFFFFFF;
       
    50 
       
    51 public:
       
    52 
       
    53 	IMPORT_C ~COmxILPort();
       
    54 
       
    55 	/**
       
    56 	   This method is used to retrieve the local OpenMAX IL parameter indexes
       
    57 	   managed by the specific port. The implementation should collect indexes
       
    58 	   from the parent class. Local indexes should be appended in order to the
       
    59 	   list received as parameter. The implementation should handle index
       
    60 	   duplication as a non-error situation (i.e., the resulting list will
       
    61 	   contain unique indexes).
       
    62 
       
    63 	   @param aIndexArray An array of parameter indexes where the local
       
    64 	   indexes are to be appended.
       
    65 
       
    66 	   @return OMX_ERRORTYPE
       
    67 	*/
       
    68 	IMPORT_C virtual OMX_ERRORTYPE GetLocalOmxParamIndexes(
       
    69 		RArray<TUint>& aIndexArray) const = 0;
       
    70 
       
    71 	/**
       
    72 	   This method is used to retrieve the local OpenMAX IL config indexes
       
    73 	   managed by the specific port. The implementation should collect indexes
       
    74 	   from the parent class. Local indexes should be appended in order to the
       
    75 	   list received as parameter. The implementation should handle index
       
    76 	   duplication as a non-error situation (i.e., the resulting list will
       
    77 	   contain unique indexes).
       
    78 
       
    79 	   @param aIndexArray An array of config indexes where the local indexes
       
    80 	   are to be appended.
       
    81 
       
    82 	   @return OMX_ERRORTYPE
       
    83 	*/
       
    84 	IMPORT_C virtual OMX_ERRORTYPE GetLocalOmxConfigIndexes(
       
    85 		RArray<TUint>& aIndexArray) const = 0;
       
    86 
       
    87 	/**
       
    88 	   Port-specific version of the OpenMAX IL GetParameter API.
       
    89 
       
    90 	   @param aParamIndex The index of the structure that is to be filled.
       
    91 	   @param apComponentParameterStructure A pointer to the IL structure.
       
    92 
       
    93 	   @return OMX_ERRORTYPE
       
    94 	*/
       
    95 	IMPORT_C virtual OMX_ERRORTYPE GetParameter(
       
    96 		OMX_INDEXTYPE aParamIndex,
       
    97 		TAny* apComponentParameterStructure) const = 0;
       
    98 
       
    99 	/**
       
   100 	   Port-specific version of the OpenMAX IL SetParameter API.
       
   101 
       
   102 	   @param aParamIndex The index of the structure that is to be set.
       
   103 	   @param apComponentParameterStructure A pointer to the IL structure.
       
   104 	   @param aUpdateProcessingFunction A flag to signal that the component's
       
   105 	   processing function needs to be updated with this structure.
       
   106 
       
   107 	   @return OMX_ERRORTYPE
       
   108 	*/
       
   109 	IMPORT_C virtual OMX_ERRORTYPE SetParameter(
       
   110 		OMX_INDEXTYPE aParamIndex,
       
   111 		const TAny* apComponentParameterStructure,
       
   112 		TBool& aUpdateProcessingFunction) = 0;
       
   113 
       
   114 	IMPORT_C virtual OMX_ERRORTYPE GetConfig(
       
   115 		OMX_INDEXTYPE aConfigIndex,
       
   116 		TAny* apComponentConfigStructure) const;
       
   117 
       
   118 	IMPORT_C virtual OMX_ERRORTYPE SetConfig(
       
   119 		OMX_INDEXTYPE aConfigIndex,
       
   120 		const TAny* apComponentConfigStructure,
       
   121 		TBool& aUpdateProcessingFunction);
       
   122 
       
   123 	IMPORT_C virtual OMX_ERRORTYPE GetExtensionIndex(
       
   124 		OMX_STRING aParameterName,
       
   125 		OMX_INDEXTYPE* apIndexType) const;
       
   126 
       
   127 	IMPORT_C virtual OMX_ERRORTYPE PopulateBuffer(
       
   128 		OMX_BUFFERHEADERTYPE** appBufferHdr,
       
   129 		const OMX_PTR apAppPrivate,
       
   130 		OMX_U32 aSizeBytes,
       
   131 		OMX_U8* apBuffer,
       
   132 		TBool& portPopulationCompleted);
       
   133 
       
   134 	IMPORT_C virtual OMX_ERRORTYPE FreeBuffer(
       
   135 		OMX_BUFFERHEADERTYPE* apBufferHeader,
       
   136 		TBool& portDepopulationCompleted);
       
   137 
       
   138 	IMPORT_C virtual OMX_ERRORTYPE TunnelRequest(
       
   139 		OMX_HANDLETYPE aTunneledComp,
       
   140 		OMX_U32 aTunneledPort,
       
   141 		OMX_TUNNELSETUPTYPE* apTunnelSetup);
       
   142 
       
   143 	IMPORT_C virtual OMX_ERRORTYPE PopulateTunnel(
       
   144 		TBool& portPopulationCompleted);
       
   145 
       
   146 	IMPORT_C virtual OMX_ERRORTYPE FreeTunnel(
       
   147 		TBool& portDepopulationCompleted);
       
   148 
       
   149 	IMPORT_C virtual TBool SetBufferSent(
       
   150 		OMX_BUFFERHEADERTYPE* apBufferHeader,
       
   151 		TBool& aBufferMarkedWithOwnMark);
       
   152 
       
   153 	IMPORT_C virtual TBool SetBufferReturned(
       
   154 		OMX_BUFFERHEADERTYPE* apBufferHeader);
       
   155 
       
   156 	IMPORT_C virtual void SetTransitionToDisabled();
       
   157 
       
   158 	IMPORT_C virtual void SetTransitionToEnabled();
       
   159 
       
   160 	IMPORT_C virtual void SetTransitionToDisabledCompleted();
       
   161 
       
   162 	IMPORT_C virtual void SetTransitionToEnabledCompleted();
       
   163 
       
   164 	IMPORT_C virtual OMX_ERRORTYPE StoreBufferMark(
       
   165 		const OMX_MARKTYPE* pMark);
       
   166 
       
   167 	IMPORT_C virtual OMX_ERRORTYPE SetComponentRoleDefaults(
       
   168 		TUint aComponentRoleIndex);
       
   169 
       
   170 	IMPORT_C virtual OMX_ERRORTYPE DoPortReconfiguration(
       
   171 		TUint aPortSettingsIndex,
       
   172 		const TDesC8& aPortSettings,
       
   173 		OMX_EVENTTYPE& aEventForILClient);
       
   174 
       
   175 	inline OMX_DIRTYPE Direction() const;
       
   176 
       
   177 	inline TBool IsEnabled() const;
       
   178 
       
   179 	inline TBool IsPopulated() const;
       
   180 
       
   181 	inline TBool IsDePopulated() const;
       
   182 
       
   183 	inline TBool IsTunnelled() const;
       
   184 
       
   185 	inline TBool IsTunnelledAndBufferSupplier() const;
       
   186 
       
   187 	IMPORT_C virtual TBool HasAllBuffersAtHome() const;
       
   188 
       
   189 	inline TBool IsTransitioningToEnabled() const;
       
   190 
       
   191 	inline TBool IsTransitioningToDisabled() const;
       
   192 
       
   193 	IMPORT_C virtual TBool IsBufferAtHome(
       
   194 		OMX_BUFFERHEADERTYPE* apHeaderHeader) const;
       
   195 
       
   196 	inline OMX_U32 Index() const;
       
   197 
       
   198 	inline OMX_PORTDOMAINTYPE Domain() const;
       
   199 
       
   200 	inline OMX_U32 Count() const;
       
   201 
       
   202 	inline OMX_BUFFERHEADERTYPE* const& operator[](TInt anIndex) const;
       
   203 
       
   204 	inline OMX_BUFFERHEADERTYPE*& operator[](TInt anIndex);
       
   205 
       
   206 	inline OMX_U32 BufferMarkPropagationPort() const;
       
   207 
       
   208 protected:
       
   209 
       
   210 	class TBufferMarkInfo;
       
   211 
       
   212 	/**
       
   213 	   Buffer mark info list
       
   214 	*/
       
   215 	class TBufferMarkInfoQue :
       
   216 		public TSglQue<TBufferMarkInfo>
       
   217 		{
       
   218 
       
   219 	public:
       
   220 
       
   221 		// Convenience typedef....
       
   222 		typedef TSglQue<TBufferMarkInfo> Tq;
       
   223 
       
   224 	public:
       
   225 
       
   226 		inline explicit TBufferMarkInfoQue(TInt aOffset);
       
   227 
       
   228 		inline TBufferMarkInfo* First() const;
       
   229 
       
   230 		inline void AddLast(TBufferMarkInfo& aRef);
       
   231 
       
   232 		inline void Remove(TBufferMarkInfo& aRef);
       
   233 
       
   234 		inline TInt Elements() const;
       
   235 
       
   236 		inline void ResetAndDestroy();
       
   237 
       
   238 	private:
       
   239 
       
   240 		TBufferMarkInfoQue();
       
   241 		void AddFirst(TBufferMarkInfo& aRef);
       
   242 		TBool IsFirst(const TBufferMarkInfo* aPtr) const;
       
   243 		TBool IsLast(const TBufferMarkInfo* aPtr) const;
       
   244 
       
   245 		TBufferMarkInfo* Last() const;
       
   246 
       
   247 	private:
       
   248 
       
   249 		TInt iNumElements;
       
   250 
       
   251 		};
       
   252 
       
   253 
       
   254 	class TBufferInfo;
       
   255 
       
   256 protected:
       
   257 
       
   258 	enum TPortIntermediateState
       
   259 		{
       
   260 		EPortNotTransitioning,
       
   261 		EPortTransitioningToDisabled,
       
   262 		EPortTransitioningToEnabled
       
   263 		};
       
   264 
       
   265 
       
   266 protected:
       
   267 
       
   268 	IMPORT_C explicit COmxILPort(const TOmxILCommonPortData& aCommonPortData);
       
   269 
       
   270 	/**
       
   271 	   When the IL Client calls SetParameter with index
       
   272 	   OMX_IndexParamPortDefinition, this method is called to set the fields in
       
   273 	   the OMX_PARAM_PORTDEFINITIONTYPE (@see iParamPortDefinition) structure
       
   274 	   that are specific to this port's domain.
       
   275 
       
   276 	   @param aPortDefinition The OpenMAX IL structure received from the IL Client.
       
   277 	   @param aUpdateProcessingFunction A flag to signal that the component's
       
   278 	   processing function needs to be updated with the this structure.
       
   279 
       
   280 	   @return OMX_ERRORTYPE
       
   281 	*/
       
   282 	virtual OMX_ERRORTYPE SetFormatInPortDefinition(
       
   283 		const OMX_PARAM_PORTDEFINITIONTYPE& aPortDefinition,
       
   284 		TBool& aUpdateProcessingFunction) = 0;
       
   285 
       
   286 	/**
       
   287 	   On a tunnel request, this method is called to check the compatibility of
       
   288 	   the fields in the OMX_PARAM_PORTDEFINITIONTYPE structure of the
       
   289 	   tunnelled component that are specific to this port's domain.
       
   290 
       
   291 	   @param aPortDefinition The OpenMAX IL structure received from a
       
   292 	   tunnelled component.
       
   293 
       
   294 	   @return ETrue if compatible, EFalse otherwise.
       
   295 	*/
       
   296 	virtual TBool IsTunnelledPortCompatible(
       
   297 		const OMX_PARAM_PORTDEFINITIONTYPE& aPortDefinition) const = 0;
       
   298 
       
   299 	IMPORT_C virtual OMX_ERRORTYPE DoBufferAllocation(
       
   300 		OMX_U32 aSizeBytes,
       
   301 		OMX_U8*& apPortSpecificBuffer,
       
   302 		OMX_PTR& apPortPrivate,
       
   303 		OMX_PTR& apPlatformPrivate,
       
   304 		OMX_PTR apAppPrivate = 0);
       
   305 
       
   306 	IMPORT_C virtual void DoBufferDeallocation(
       
   307 		OMX_PTR apPortSpecificBuffer,
       
   308 		OMX_PTR apPortPrivate,
       
   309 		OMX_PTR apPlatformPrivate,
       
   310 		OMX_PTR apAppPrivate = 0);
       
   311 
       
   312 	IMPORT_C virtual OMX_ERRORTYPE DoBufferWrapping(
       
   313 		OMX_U32 aSizeBytes,
       
   314 		OMX_U8* apBuffer,
       
   315 		OMX_PTR& apPortPrivate,
       
   316 		OMX_PTR& apPlatformPrivate,
       
   317 		OMX_PTR apAppPrivate = 0);
       
   318 
       
   319 	IMPORT_C virtual void DoBufferUnwrapping(
       
   320 		OMX_PTR apPortSpecificBuffer,
       
   321 		OMX_PTR apPortPrivate,
       
   322 		OMX_PTR apPlatformPrivate,
       
   323 		OMX_PTR apAppPrivate = 0);
       
   324 
       
   325 	IMPORT_C virtual OMX_ERRORTYPE DoOmxUseBuffer(
       
   326 		OMX_HANDLETYPE aTunnelledComponent,
       
   327 		OMX_BUFFERHEADERTYPE** appBufferHdr,
       
   328 		OMX_U32 aTunnelledPortIndex,
       
   329 		OMX_PTR apPortPrivate,
       
   330 		OMX_PTR apPlatformPrivate,
       
   331 		OMX_U32 aSizeBytes,
       
   332 		OMX_U8* apBuffer);
       
   333 
       
   334 	template<typename T>
       
   335 	inline OMX_ERRORTYPE GetParamStructureFromTunnel(
       
   336 		T& aComponentConfigStructure, OMX_INDEXTYPE aParamIndex) const;
       
   337 
       
   338 	IMPORT_C OMX_ERRORTYPE StoreBufferMark(
       
   339 		OMX_HANDLETYPE& ipMarkTargetComponent,
       
   340 		OMX_PTR& ipMarkData);
       
   341 
       
   342 	IMPORT_C void CleanUpPort();
       
   343 
       
   344 protected:
       
   345 
       
   346 	// Tunnelled component
       
   347 	OMX_HANDLETYPE iTunnelledComponent;
       
   348 
       
   349 	// Tunnelled component's port
       
   350 	OMX_U32 iTunnelledPort;
       
   351 
       
   352 	// Buffer headers store
       
   353 	RArray<TBufferInfo> iBufferHeaders;
       
   354 
       
   355 	// Buffer marks store
       
   356 	TBufferMarkInfoQue iBufferMarks;
       
   357 
       
   358 	// Port's intermediate state to enabled or disabled
       
   359 	TPortIntermediateState iTransitionState;
       
   360 
       
   361 	// Associated port that will be used to propagate buffer marks
       
   362 	OMX_U32 iBufferMarkPropagationPortIndex;
       
   363 
       
   364 	// OpenMAX IL port definition structure
       
   365 	OMX_PARAM_PORTDEFINITIONTYPE iParamPortDefinition;
       
   366 
       
   367 	// OpenMAX IL buffer supplier structure
       
   368 	OMX_PARAM_BUFFERSUPPLIERTYPE iParamCompBufferSupplier;
       
   369 
       
   370 	};
       
   371 
       
   372 
       
   373 /**
       
   374    Structure used to pass the common information that an OpenMAX IL port needs
       
   375    at instantiation time.
       
   376 */
       
   377 class TOmxILCommonPortData
       
   378 	{
       
   379 
       
   380 public:
       
   381 
       
   382 	// OMX specification version information
       
   383 	OMX_VERSIONTYPE iOmxVersion;
       
   384 	// Port number the structure applies to
       
   385 	OMX_U32 iPortIndex;
       
   386 	// Direction (input or output) of this port
       
   387 	OMX_DIRTYPE iDirection;
       
   388     // The minimum number of buffers this port requires
       
   389 	OMX_U32 iBufferCountMin;
       
   390 	// Minimum size, in bytes, for buffers to be used for this port
       
   391 	OMX_U32 iBufferSizeMin;
       
   392 	// Domain of the port
       
   393 	OMX_PORTDOMAINTYPE iPortDomain;
       
   394 	// Buffers contiguous requirement (true or false)
       
   395 	OMX_BOOL iBuffersContiguous;
       
   396 	// Buffer aligment requirements
       
   397 	OMX_U32 iBufferAlignment;
       
   398 	// Port supplier preference when tunneling between two ports
       
   399 	OMX_BUFFERSUPPLIERTYPE iBufferSupplier;
       
   400 
       
   401 	// \brief This is the associated port that will be used to propagate buffer marks
       
   402 	// found in incoming buffer headers.
       
   403 	//
       
   404 	// In general, for any output port, this parameter should be configured
       
   405 	// with constant COmxILPort::KBufferMarkPropagationPortNotNeeded except
       
   406 	// for an output port of a source component, in which case it must be used
       
   407 	// the same index of the port that this structure applies to. For an input
       
   408 	// port of a sink component,
       
   409 	// COmxILPort::KBufferMarkPropagationPortNotNeeded must also be used.
       
   410 	OMX_U32 iBufferMarkPropagationPortIndex;
       
   411 
       
   412 	// Constructor
       
   413 	IMPORT_C TOmxILCommonPortData(
       
   414 		OMX_VERSIONTYPE aOmxVersion,
       
   415 		OMX_U32 aPortIndex,
       
   416 		OMX_DIRTYPE aDirection,
       
   417 		OMX_U32 aBufferCountMin,
       
   418 		OMX_U32 aBufferSizeMin,
       
   419 		OMX_PORTDOMAINTYPE aPortDomain,
       
   420 		OMX_BOOL aBuffersContiguous,
       
   421 		OMX_U32 aBufferAlignment,
       
   422 		OMX_BUFFERSUPPLIERTYPE aBufferSupplier,
       
   423 		OMX_U32 aBufferMarkPropagationPortIndex);
       
   424 
       
   425 	};
       
   426 
       
   427 /**
       
   428    Buffer mark info structure
       
   429 */
       
   430 class COmxILPort::TBufferMarkInfo
       
   431 	{
       
   432 
       
   433 public:
       
   434 
       
   435 	inline explicit TBufferMarkInfo(
       
   436 		const OMX_MARKTYPE*& apMark,
       
   437 		TBool aOwnMark = ETrue);
       
   438 
       
   439 	inline TBufferMarkInfo(
       
   440 		OMX_HANDLETYPE& apMarkTargetComponent,
       
   441 		OMX_PTR& apMarkData,
       
   442 		TBool aOwnMark = ETrue);
       
   443 
       
   444 public:
       
   445 
       
   446 	OMX_HANDLETYPE ipMarkTargetComponent;
       
   447 	OMX_PTR ipMarkData;
       
   448 	TBool iOwnMark;
       
   449 	TSglQueLink iLink;
       
   450 
       
   451 	};
       
   452 
       
   453 /**
       
   454    Buffer info structure
       
   455 */
       
   456 class COmxILPort::TBufferInfo
       
   457 	{
       
   458 
       
   459 public:
       
   460 
       
   461 	enum THeaderLocationProperty
       
   462 		{
       
   463 		EBufferAtHome	= 0x01,
       
   464 		EBufferAway		= 0x00
       
   465 		};
       
   466 
       
   467 	enum THeaderOwnershipProperty
       
   468 		{
       
   469 		EBufferOwned	= 0x02,
       
   470 		EBufferNotOwned = 0x00
       
   471 		};
       
   472 
       
   473 public:
       
   474 
       
   475 	inline TBufferInfo(OMX_BUFFERHEADERTYPE* apHeader,
       
   476 					   THeaderLocationProperty aLocation,
       
   477 					   THeaderOwnershipProperty aOwnership,
       
   478 					   OMX_U8* apBuffer,
       
   479 					   OMX_PTR apApp,
       
   480 					   OMX_PTR apPlatform,
       
   481 					   OMX_PTR apPort);
       
   482 
       
   483 	inline explicit TBufferInfo(OMX_BUFFERHEADERTYPE* apHeader);
       
   484 
       
   485 	IMPORT_C static TBool Compare(const TBufferInfo& aBi1,
       
   486 								  const TBufferInfo& aBi2);
       
   487 
       
   488 	inline const OMX_BUFFERHEADERTYPE* GetHeader() const;
       
   489 
       
   490 	inline OMX_BUFFERHEADERTYPE* GetHeader();
       
   491 
       
   492 	inline operator OMX_BUFFERHEADERTYPE*&();
       
   493 
       
   494 	inline operator OMX_BUFFERHEADERTYPE* const&() const;
       
   495 
       
   496 	inline OMX_U8* GetBufferPointer() const;
       
   497 
       
   498 	inline OMX_U8* GetBufferPointer();
       
   499 
       
   500 	inline OMX_PTR GetPortPointer() const;
       
   501 
       
   502 	inline OMX_PTR GetPortPointer();
       
   503 
       
   504 	inline OMX_PTR GetPlatformPointer() const;
       
   505 
       
   506 	inline OMX_PTR GetPlatformPointer();
       
   507 
       
   508 	inline OMX_PTR GetAppPointer() const;
       
   509 
       
   510 	inline OMX_PTR GetAppPointer();
       
   511 
       
   512 	inline void SetBufferAtHome();
       
   513 
       
   514 	inline void SetBufferAway();
       
   515 
       
   516 	inline void SetBufferOwned();
       
   517 
       
   518 	inline void SetBufferNotOwned();
       
   519 
       
   520 	inline TBool IsBufferAtHome() const;
       
   521 
       
   522 	inline TBool IsBufferOwned() const;
       
   523 
       
   524 private:
       
   525 
       
   526 	enum THeaderPropertyMask
       
   527 		{
       
   528 		EBufferAwayMask		= 0xFE,
       
   529 		EBufferNotOwnedMask = 0xFD
       
   530 		};
       
   531 
       
   532 private:
       
   533 
       
   534 	OMX_BUFFERHEADERTYPE* ipHeader;
       
   535 	TUint8 iBufferProperties;
       
   536 	OMX_U8* ipBuffer;
       
   537 	OMX_PTR ipApp;
       
   538 	OMX_PTR ipPlatform;
       
   539 	OMX_PTR ipPort;
       
   540 
       
   541 	};
       
   542 
       
   543 #include "omxilport.inl"
       
   544 
       
   545 #endif // OMXILPORT_H