omxil_generic/omxilcomplib/src/omxilutil.cpp
changeset 0 0e4a32b9112d
equal deleted inserted replaced
-1:000000000000 0:0e4a32b9112d
       
     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 
       
    23 #include <openmax/il/common/omxilutil.h>
       
    24 #include <openmax/il/common/omxilspecversion.h>
       
    25 
       
    26 /**
       
    27    This method checks that the size of an OpenMAX IL data structure is
       
    28    correct. It also checks that the OpenMAX IL version stated in the structure
       
    29    is the same as the one returned by TOmxILSpecVersion() (at the time of
       
    30    writting this is 1.1.1). In this version of the component framework,
       
    31    backward compatibility in not supported for OpenMAX IL structures.
       
    32 
       
    33    @param apHeader An OpenMAX IL data structure.
       
    34 
       
    35    @param aSize sizeof(OMXIL structure)
       
    36 
       
    37    @return OMX_ErrorVersionMismatch if the version is not
       
    38    1.1.1. OMX_ErrorBadParameter if versions are the same but the nSize is
       
    39    different. OMX_ErrorNone otherwise
       
    40  */
       
    41 EXPORT_C OMX_ERRORTYPE
       
    42 TOmxILUtil::CheckOmxStructSizeAndVersion(OMX_PTR apHeader, OMX_U32 aSize)
       
    43 	{
       
    44 
       
    45 	if (!apHeader || aSize == 0)
       
    46 		{
       
    47 		return OMX_ErrorBadParameter;
       
    48 		}
       
    49 
       
    50 #ifdef _OMXIL_COMMON_SPEC_VERSION_CHECKS_ON
       
    51 
       
    52 	OMX_U32* const pStructSize =
       
    53 		reinterpret_cast<OMX_U32*>(apHeader);
       
    54 
       
    55     // In an OpenMAX IL structure the nSize and nVersion fields are used to
       
    56     // detect the difference in spec versions.
       
    57 	OMX_VERSIONTYPE* const pOmxVersion =
       
    58 		reinterpret_cast<OMX_VERSIONTYPE*>(
       
    59 			pStructSize + (sizeof(OMX_U32)/sizeof(OMX_U32)));
       
    60 
       
    61 	if ( (TOmxILSpecVersion() != *pOmxVersion)&&(TOmxILVersion(OMX_VERSION_MAJOR, OMX_VERSION_MINOR, 1, OMX_VERSION_STEP) != *pOmxVersion) )
       
    62 
       
    63 		{
       
    64 		return OMX_ErrorVersionMismatch;
       
    65 		}
       
    66 
       
    67 	// If the spec versions are the same, then the struct sizes must be the
       
    68 	// same too...
       
    69 	if (*pStructSize != aSize)
       
    70 		{
       
    71 		return OMX_ErrorBadParameter;
       
    72 		}
       
    73 
       
    74 #endif // _OMXIL_COMMON_SPEC_VERSION_CHECKS_ON
       
    75 
       
    76 	return OMX_ErrorNone;
       
    77 
       
    78 	}
       
    79 
       
    80 /**
       
    81    This method simply resets the following fields in the OMX IL 1.1.x buffer header:
       
    82    nFilledLen
       
    83    hMarkTargetComponent
       
    84    pMarkData
       
    85    nTickCount
       
    86    nTimeStamp
       
    87    nFlags
       
    88 
       
    89    @param apBufferHeader An OpenMAX IL buffer header structure.
       
    90 
       
    91  */
       
    92 EXPORT_C void
       
    93 TOmxILUtil::ClearBufferContents(
       
    94 	OMX_BUFFERHEADERTYPE* apBufferHeader)
       
    95 	{
       
    96 
       
    97 	if (!apBufferHeader)
       
    98 		{
       
    99 		return;
       
   100 		}
       
   101 
       
   102 	apBufferHeader->nFilledLen			 = 0;
       
   103 	apBufferHeader->hMarkTargetComponent = 0;
       
   104 	apBufferHeader->pMarkData			 = 0;
       
   105 	apBufferHeader->nTickCount			 = 0;
       
   106 	apBufferHeader->nTimeStamp			 = 0;
       
   107 	apBufferHeader->nFlags				 = 0;
       
   108 
       
   109 	}