omxil/video/omxilvideoscheduler2/src/comxilvideoschedulerinputport.cpp
branchOpenMAX-IL_SHAI
changeset 16 eedf2dcd43c6
equal deleted inserted replaced
15:c1e808730d6c 16:eedf2dcd43c6
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20 @file
       
    21 @internalComponent
       
    22 */
       
    23 
       
    24 #include "comxilvideoschedulerinputport.h"
       
    25 #include "omxilvideoschedulerextensionsindexes.h"
       
    26 
       
    27 
       
    28 COmxILVideoSchedulerInputPort* COmxILVideoSchedulerInputPort::NewL(const TOmxILCommonPortData& aCommonPortData)
       
    29 	{
       
    30 	// TODO these arrays must left empty, to be removed from the video port constructor
       
    31 	RArray<OMX_VIDEO_CODINGTYPE> supportedCodings;
       
    32 	RArray<OMX_COLOR_FORMATTYPE> supportedColorFormats;
       
    33 	
       
    34 	CleanupClosePushL(supportedCodings);
       
    35 	CleanupClosePushL(supportedColorFormats);
       
    36 
       
    37 	COmxILVideoSchedulerInputPort* self = new(ELeave) COmxILVideoSchedulerInputPort(aCommonPortData, supportedCodings, supportedColorFormats);
       
    38 	CleanupStack::PushL(self);
       
    39 	self->ConstructL();
       
    40 	CleanupStack::Pop(self);
       
    41 	
       
    42 	CleanupStack::PopAndDestroy(2, &supportedCodings);
       
    43 	
       
    44 	return self;
       
    45 	}
       
    46 
       
    47 
       
    48 COmxILVideoSchedulerInputPort::COmxILVideoSchedulerInputPort(const TOmxILCommonPortData& aCommonPortData, 
       
    49                                                  const RArray<OMX_VIDEO_CODINGTYPE>& aSupportedCodings,
       
    50                                                  const RArray<OMX_COLOR_FORMATTYPE>& aSupportedColourFormats)
       
    51   : COmxILVideoPort(aCommonPortData, aSupportedCodings, aSupportedColourFormats)
       
    52     {
       
    53     }
       
    54 
       
    55 void COmxILVideoSchedulerInputPort::ConstructL()
       
    56 	{
       
    57 	// Port definition mime type. Mime type is not relevant for uncompressed video frames
       
    58  	iMimeTypeBuf.CreateL(KNullDesC8(), KNullDesC8().Length() + 1);
       
    59  	TUint8* pTUint = const_cast<TUint8*>(iMimeTypeBuf.PtrZ());
       
    60  	iParamPortDefinition.format.video.cMIMEType = reinterpret_cast<OMX_STRING>(pTUint);
       
    61 
       
    62  	iParamVideoScheDropFrame.nSize = sizeof(OMX_NOKIA_PARAM_DROPPEDFRAMEEVENT);
       
    63  	iParamVideoScheDropFrame.nVersion = TOmxILSpecVersion();
       
    64  	iParamVideoScheDropFrame.nPortIndex = iParamPortDefinition.nPortIndex;
       
    65  	iParamVideoScheDropFrame.bEnabled = OMX_FALSE;
       
    66 
       
    67 	iSupportedVideoFormats.AppendL(OMX_VIDEO_CodingUnused);
       
    68 	iSupportedColorFormats.AppendL(OMX_COLOR_FormatUnused);	 
       
    69 	}
       
    70 
       
    71 COmxILVideoSchedulerInputPort::~COmxILVideoSchedulerInputPort()
       
    72 	{
       
    73 	iMimeTypeBuf.Close();
       
    74 	}
       
    75 
       
    76 OMX_ERRORTYPE COmxILVideoSchedulerInputPort::GetLocalOmxParamIndexes(RArray<TUint>& aIndexArray) const
       
    77 	{
       
    78 	OMX_ERRORTYPE omxRetValue = COmxILVideoPort::GetLocalOmxParamIndexes(aIndexArray);
       
    79 	if(omxRetValue != OMX_ErrorNone)
       
    80 	    {
       
    81 	    return omxRetValue; 
       
    82 	    }
       
    83 
       
    84 	TInt err = aIndexArray.InsertInOrder(OMX_NokiaIndexParamDroppedFrameEvent);
       
    85 
       
    86 	if (err != KErrNone && err != KErrAlreadyExists)
       
    87 	    {
       
    88 	    return OMX_ErrorInsufficientResources;
       
    89 	    }
       
    90 
       
    91 	return OMX_ErrorNone;
       
    92 	}
       
    93 
       
    94 OMX_ERRORTYPE COmxILVideoSchedulerInputPort::GetLocalOmxConfigIndexes(RArray<TUint>& aIndexArray) const
       
    95 	{
       
    96 	return COmxILVideoPort::GetLocalOmxConfigIndexes(aIndexArray);
       
    97 	}
       
    98 
       
    99 /**
       
   100 This method provides the current values for the parameters present in the structure represented by the given index.
       
   101 
       
   102 @param  aParamIndex The specific param index for which the current parameter values are required.
       
   103         apComponentParameterStructure The pointer to the structure which will be updated to provide the current parameter values.
       
   104         
       
   105 @return OMX_ErrorNone if successful;
       
   106         OMX_ErrorNoMore if no more formats;
       
   107         OMX_ErrorUnsupportedSetting if unsupported setting is passed;
       
   108 */
       
   109 OMX_ERRORTYPE COmxILVideoSchedulerInputPort::GetParameter(OMX_INDEXTYPE aParamIndex,TAny* apComponentParameterStructure) const
       
   110     {
       
   111     if(aParamIndex == OMX_NokiaIndexParamDroppedFrameEvent)
       
   112         {
       
   113         OMX_NOKIA_PARAM_DROPPEDFRAMEEVENT* dropFrame = static_cast<OMX_NOKIA_PARAM_DROPPEDFRAMEEVENT*>(apComponentParameterStructure);
       
   114         *dropFrame = iParamVideoScheDropFrame;
       
   115         return OMX_ErrorNone;
       
   116         }
       
   117     else
       
   118         {
       
   119          // Try the parent's indexes
       
   120         return COmxILVideoPort::GetParameter(aParamIndex,apComponentParameterStructure);
       
   121         }
       
   122     }
       
   123 
       
   124 /**
       
   125 This method sets the values of the parameters present in the structure represented by the given index.
       
   126 
       
   127 @param  aParamIndex The specific param index for which the parameter values have to be set.
       
   128         apComponentParameterStructure The pointer to the structure which will provide the desired parameter values to be set.
       
   129         aUpdateProcessingFunction informs whether the processing function needs to be updated.
       
   130         
       
   131 @return OMX_ErrorNone if successful;
       
   132         OMX_ErrorUnsupportedSetting if non-zero framerate value;
       
   133         OMX_ErrorUnsupportedIndex if request OMX_NokiaIndexParamDroppedFrameEvent index;
       
   134 */
       
   135 OMX_ERRORTYPE COmxILVideoSchedulerInputPort::SetParameter(OMX_INDEXTYPE aParamIndex,const TAny* apComponentParameterStructure, TBool& aUpdateProcessingFunction)
       
   136 	{    
       
   137 	if(aParamIndex == OMX_NokiaIndexParamDroppedFrameEvent)
       
   138 		{
       
   139 		const OMX_NOKIA_PARAM_DROPPEDFRAMEEVENT *portParameterStructure = static_cast<const OMX_NOKIA_PARAM_DROPPEDFRAMEEVENT*>(apComponentParameterStructure);
       
   140 		if (iParamVideoScheDropFrame.bEnabled != portParameterStructure->bEnabled)
       
   141 			{
       
   142 			iParamVideoScheDropFrame.bEnabled = portParameterStructure->bEnabled;
       
   143 			aUpdateProcessingFunction = ETrue;
       
   144 			}
       
   145 		return OMX_ErrorNone;
       
   146 		}
       
   147 
       
   148 	// Try the parent's indexes
       
   149 	return COmxILVideoPort::SetParameter(aParamIndex, apComponentParameterStructure, aUpdateProcessingFunction);
       
   150 	}
       
   151 
       
   152 
       
   153 OMX_ERRORTYPE COmxILVideoSchedulerInputPort::SetFormatInPortDefinition(const OMX_PARAM_PORTDEFINITIONTYPE& aPortDefinition,
       
   154 													TBool& /*aUpdateProcessingFunction*/)
       
   155 	{
       
   156 	iParamPortDefinition.format.video = aPortDefinition.format.video;
       
   157  	TUint8* pTUint = const_cast<TUint8*>(iMimeTypeBuf.PtrZ());
       
   158  	iParamPortDefinition.format.video.cMIMEType = reinterpret_cast<OMX_STRING>(pTUint);
       
   159  	iParamPortDefinition.format.video.nSliceHeight = iParamPortDefinition.format.video.nFrameHeight;
       
   160  	iParamPortDefinition.nBufferSize = iParamPortDefinition.format.video.nStride * iParamPortDefinition.format.video.nSliceHeight;
       
   161 	return OMX_ErrorNone;
       
   162 	}
       
   163 
       
   164 TBool COmxILVideoSchedulerInputPort::IsTunnelledPortCompatible(const OMX_PARAM_PORTDEFINITIONTYPE& /*aPortDefinition*/) const
       
   165 	{
       
   166 	// TODO (The base class should do this checking) 
       
   167 	return ETrue;	
       
   168 	}
       
   169 
       
   170 /** Returns the number of buffers configured on this port. */
       
   171 TUint32 COmxILVideoSchedulerInputPort::BufferCount() const
       
   172 	{
       
   173 	return iParamPortDefinition.nBufferCountActual;
       
   174 	}
       
   175 
       
   176 /**
       
   177 This method provides the index type represented by the given parameter name.
       
   178 
       
   179 @param  aParameterName The name of extention parameter to be retrieved.
       
   180         apIndexType The pointer which will retrieve the required index.
       
   181         
       
   182 @return OMX_ErrorNone if successful;
       
   183         OMX_ErrorUnsupportedIndex if unsupported parameter name is passed;
       
   184 */  
       
   185 OMX_ERRORTYPE COmxILVideoSchedulerInputPort::GetExtensionIndex(OMX_STRING aParameterName,   OMX_INDEXTYPE* apIndexType) const
       
   186     {
       
   187     TPtrC8 receivedParameterName(const_cast<const TUint8*>(reinterpret_cast<TUint8*>(aParameterName)));
       
   188 
       
   189     TPtrC8 parameterName(reinterpret_cast<const TUint8*>(sOmxNokiaIndexParamDroppedFrameEvent));
       
   190     
       
   191     if (receivedParameterName == parameterName)
       
   192         {
       
   193         *apIndexType = static_cast<OMX_INDEXTYPE>(OMX_NokiaIndexParamDroppedFrameEvent);
       
   194         return OMX_ErrorNone;
       
   195         }
       
   196     
       
   197     *apIndexType = OMX_IndexMax;
       
   198     return OMX_ErrorUnsupportedIndex;
       
   199     }
       
   200