omxil_generic/omxilcomplib/src/omxilotherportimpl.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 #include <openmax/il/common/omxilotherport.h>
       
    23 #include <openmax/il/common/omxilutil.h>
       
    24 #include "omxilotherportimpl.h"
       
    25 
       
    26 COmxILOtherPortImpl* COmxILOtherPortImpl::NewL(const RArray<OMX_OTHER_FORMATTYPE>& aSupportedOtherFormats, const TOmxILCommonPortData& aCommonPortData)
       
    27 	{
       
    28 	COmxILOtherPortImpl* self = new(ELeave) COmxILOtherPortImpl(aCommonPortData);
       
    29 	CleanupStack::PushL(self);
       
    30 	self->ConstructL(aSupportedOtherFormats);
       
    31 	CleanupStack::Pop();
       
    32 	return self;	
       
    33 	}
       
    34 
       
    35 COmxILOtherPortImpl::COmxILOtherPortImpl(const TOmxILCommonPortData& aCommonPortData) 
       
    36 	{
       
    37 	iParamOtherPortFormat.nSize = sizeof(OMX_OTHER_PARAM_PORTFORMATTYPE);
       
    38 	iParamOtherPortFormat.nVersion = aCommonPortData.iOmxVersion;
       
    39 	iParamOtherPortFormat.nPortIndex = aCommonPortData.iPortIndex;
       
    40 	iParamOtherPortFormat.nIndex = 0;
       
    41 	}
       
    42 
       
    43 void COmxILOtherPortImpl::ConstructL(const RArray<OMX_OTHER_FORMATTYPE>& aSupportedOtherFormats)
       
    44 	{
       
    45 	TUint count = aSupportedOtherFormats.Count();
       
    46 	for (TInt i = 0; i < count; i++)
       
    47 		{
       
    48 		iSupportedOtherFormats.AppendL(aSupportedOtherFormats[i]);
       
    49 		}
       
    50 	iParamOtherPortFormat.eFormat = count ? iSupportedOtherFormats[0] : OMX_OTHER_FormatMax;	
       
    51 	}
       
    52 
       
    53 COmxILOtherPortImpl::~COmxILOtherPortImpl()
       
    54 	{
       
    55 	iSupportedOtherFormats.Close();
       
    56 	}
       
    57 
       
    58 OMX_ERRORTYPE COmxILOtherPortImpl::GetParameter(OMX_INDEXTYPE aParamIndex, 
       
    59 													TAny* apComponentParameterStructure) const
       
    60 	{
       
    61 	switch(aParamIndex)
       
    62 		{
       
    63 		case OMX_IndexParamOtherPortFormat:
       
    64 			{
       
    65 			OMX_ERRORTYPE omxRetValue = TOmxILUtil::CheckOmxStructSizeAndVersion(apComponentParameterStructure,
       
    66 					  															sizeof(OMX_OTHER_PARAM_PORTFORMATTYPE));
       
    67 			
       
    68 			if (omxRetValue != OMX_ErrorNone)
       
    69 				{
       
    70 				return omxRetValue;
       
    71 				}
       
    72 
       
    73 			OMX_OTHER_PARAM_PORTFORMATTYPE* pParamOtherPortFormat = 
       
    74 				static_cast<OMX_OTHER_PARAM_PORTFORMATTYPE*>(apComponentParameterStructure);
       
    75 
       
    76 			if (pParamOtherPortFormat->nIndex >= iSupportedOtherFormats.Count())
       
    77 				{
       
    78 				return OMX_ErrorNoMore;
       
    79 				}
       
    80 	
       
    81 			pParamOtherPortFormat->eFormat = iSupportedOtherFormats[pParamOtherPortFormat->nIndex];
       
    82 			}
       
    83 			break;
       
    84 		default:
       
    85 			__ASSERT_ALWAYS(EFalse, User::Panic(KOmxILOtherPortPanicCategory, 1));
       
    86 		};
       
    87 
       
    88 	return OMX_ErrorNone;
       
    89 	}
       
    90 
       
    91 OMX_ERRORTYPE COmxILOtherPortImpl::SetParameter(OMX_INDEXTYPE aParamIndex, 
       
    92 						     const TAny* apComponentParameterStructure,
       
    93 						     TBool& aUpdateProcessingFunction)
       
    94 	{
       
    95 	aUpdateProcessingFunction = EFalse;
       
    96 
       
    97 	switch(aParamIndex)
       
    98 		{
       
    99 		case OMX_IndexParamOtherPortFormat:
       
   100 			{
       
   101 			OMX_ERRORTYPE omxRetValue = TOmxILUtil::CheckOmxStructSizeAndVersion(const_cast<OMX_PTR>(apComponentParameterStructure),
       
   102 								  												sizeof(OMX_OTHER_PARAM_PORTFORMATTYPE));
       
   103 
       
   104 			if (omxRetValue != OMX_ErrorNone)
       
   105 				{
       
   106 				return omxRetValue;
       
   107 				}
       
   108 						
       
   109 			const OMX_OTHER_PARAM_PORTFORMATTYPE* pParamOtherPortFormat = 
       
   110 				static_cast<const  OMX_OTHER_PARAM_PORTFORMATTYPE*>(apComponentParameterStructure);
       
   111 
       
   112 			// Check in case the specified format is not actually supported by this
       
   113 			// port
       
   114 			OMX_OTHER_FORMATTYPE newFormatType = pParamOtherPortFormat->eFormat;
       
   115 
       
   116 			// OMX_OTHER_FormatVendorReserved is the last of the supported values as of
       
   117 			// v1.1.1
       
   118 			if (newFormatType > OMX_OTHER_FormatVendorReserved)
       
   119 			    {
       
   120 			    return OMX_ErrorBadParameter;
       
   121 			    }
       
   122 
       
   123 			if (KErrNotFound == iSupportedOtherFormats.Find(newFormatType))
       
   124 			    {
       
   125 			    return OMX_ErrorUnsupportedSetting;
       
   126 			    }
       
   127 
       
   128 			// Set the new default format, but check first that we are actually
       
   129 			// changing something...
       
   130 			if (iParamOtherPortFormat.eFormat != newFormatType)
       
   131 			    {
       
   132 			    iParamOtherPortFormat.eFormat = newFormatType;
       
   133 
       
   134 			    // This is an indication to the PortManager that the processing
       
   135 			    // function needs to get updated
       
   136 			    //
       
   137 			    aUpdateProcessingFunction = ETrue;
       
   138 			    }
       
   139 			}
       
   140 			break;
       
   141 		default:
       
   142 			__ASSERT_ALWAYS(EFalse, User::Panic(KOmxILOtherPortPanicCategory, 1));
       
   143 		};
       
   144 
       
   145 	return OMX_ErrorNone;
       
   146 	}
       
   147 
       
   148 const RArray<OMX_OTHER_FORMATTYPE>& COmxILOtherPortImpl::GetSupportedOtherFormats() const
       
   149         {
       
   150         return iSupportedOtherFormats;
       
   151         }
       
   152 
       
   153 const OMX_OTHER_PARAM_PORTFORMATTYPE& COmxILOtherPortImpl::GetParamOtherPortFormat() const
       
   154         {
       
   155         return iParamOtherPortFormat;
       
   156         }
       
   157 
       
   158 RArray<OMX_OTHER_FORMATTYPE>& COmxILOtherPortImpl::GetSupportedOtherFormats()
       
   159         {
       
   160         return iSupportedOtherFormats;
       
   161         }
       
   162 
       
   163 OMX_OTHER_PARAM_PORTFORMATTYPE& COmxILOtherPortImpl::GetParamOtherPortFormat()
       
   164         {
       
   165         return iParamOtherPortFormat;
       
   166         }
       
   167 
       
   168