omxil/omxilcomponentcommon/src/common/omxilstate.cpp
changeset 0 40261b775718
child 16 eedf2dcd43c6
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     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 "log.h"
       
    23 #include "omxilstate.h"
       
    24 #include "omxilfsm.h"
       
    25 #include "omxilcommand.h"
       
    26 #include "omxilconfigmanager.h"
       
    27 #include "omxilcallbackmanager.h"
       
    28 
       
    29 
       
    30 OMX_ERRORTYPE
       
    31 COmxILFsm::COmxILState::GetParameter(
       
    32 	const COmxILFsm& aFsm,
       
    33 	OMX_INDEXTYPE aParamIndex,
       
    34 	TAny* apComponentParameterStructure) const
       
    35 	{
       
    36     DEBUG_PRINTF(_L8("COmxILState::GetParameter"));
       
    37 
       
    38 	// This API can be used independently of the current state of the
       
    39 	// component.  Let's try first the Port Manager to check if the index is
       
    40 	// known there
       
    41 	OMX_ERRORTYPE retValue =
       
    42 		aFsm.iPortManager.GetParameter(aParamIndex,
       
    43 									   apComponentParameterStructure);
       
    44 
       
    45 	if (OMX_ErrorUnsupportedIndex == retValue)
       
    46 		{
       
    47 		// Otherwise, try Config Manager...
       
    48 		retValue = aFsm.iConfigManager.GetParameter(
       
    49 			aParamIndex,
       
    50 			apComponentParameterStructure);
       
    51 		}
       
    52 
       
    53 	return retValue;
       
    54 
       
    55 	}
       
    56 
       
    57 // This SetParameter version must be used in the following states:
       
    58 // - OMX_StateIdle,
       
    59 // - OMX_StateExecuting,
       
    60 // - OMX_StatePaused, and
       
    61 //
       
    62 OMX_ERRORTYPE
       
    63 COmxILFsm::COmxILState::SetParameter(
       
    64 	COmxILFsm& aFsm,
       
    65 	OMX_INDEXTYPE aParamIndex,
       
    66 	const TAny* apComponentParameterStructure)
       
    67 	{
       
    68     DEBUG_PRINTF(_L8("COmxILState::SetParameter"));
       
    69 
       
    70 	OMX_ERRORTYPE retValue =
       
    71 		aFsm.iPortManager.SetParameter(
       
    72 			aParamIndex,
       
    73 			apComponentParameterStructure,
       
    74 			OMX_TRUE				// Port must be disabled
       
    75 			);
       
    76 
       
    77 	if (OMX_ErrorUnsupportedIndex == retValue)
       
    78 		{
       
    79 		// Try Config Manager now...
       
    80 		retValue = aFsm.iConfigManager.SetParameter(
       
    81 			aParamIndex,
       
    82 			apComponentParameterStructure,
       
    83 			OMX_FALSE // run-time
       
    84 			);
       
    85 		}
       
    86 
       
    87 	return retValue;
       
    88 
       
    89 	}
       
    90 
       
    91 // This SetParameter version must be used in the following states:
       
    92 // - OMX_StateLoaded and derived states,
       
    93 // - OMX_StateWaitForResources
       
    94 //
       
    95 OMX_ERRORTYPE
       
    96 COmxILFsm::COmxILState::SetParameterV2(
       
    97 	COmxILFsm& aFsm,
       
    98 	OMX_INDEXTYPE aParamIndex,
       
    99 	const TAny* apComponentParameterStructure)
       
   100 	{
       
   101     DEBUG_PRINTF(_L8("COmxILState::SetParameterV2"));
       
   102 
       
   103 	OMX_ERRORTYPE retValue =
       
   104 		aFsm.iPortManager.SetParameter(aParamIndex,
       
   105 									   apComponentParameterStructure);
       
   106 
       
   107 	if (OMX_ErrorUnsupportedIndex == retValue)
       
   108 		{
       
   109 		// Try Config Manager now...
       
   110 		retValue = aFsm.iConfigManager.SetParameter(
       
   111 			aParamIndex,
       
   112 			apComponentParameterStructure);
       
   113 		}
       
   114 
       
   115 	return retValue;
       
   116 
       
   117 	}
       
   118 
       
   119 OMX_ERRORTYPE
       
   120 COmxILFsm::COmxILState::GetConfig(
       
   121 	const COmxILFsm& aFsm,
       
   122 	OMX_INDEXTYPE aConfigIndex,
       
   123 	TAny* apComponentConfigStructure) const
       
   124 	{
       
   125     DEBUG_PRINTF(_L8("COmxILState::GetConfig"));
       
   126 
       
   127 	OMX_ERRORTYPE retValue =
       
   128 		aFsm.iPortManager.GetConfig(aConfigIndex,
       
   129 									apComponentConfigStructure);
       
   130 
       
   131 	if (OMX_ErrorUnsupportedIndex == retValue)
       
   132 		{
       
   133 		// Try Config Manager now...
       
   134 		retValue = aFsm.iConfigManager.GetConfig(
       
   135 			aConfigIndex,
       
   136 			apComponentConfigStructure);
       
   137 		}
       
   138 
       
   139 	return retValue;
       
   140 
       
   141 	}
       
   142 
       
   143 OMX_ERRORTYPE
       
   144 COmxILFsm::COmxILState::SetConfig(COmxILFsm& aFsm,
       
   145 								  OMX_INDEXTYPE aConfigIndex,
       
   146 								  const TAny* apComponentConfigStructure)
       
   147 	{
       
   148     DEBUG_PRINTF(_L8("COmxILState::SetConfig"));
       
   149 
       
   150 	OMX_ERRORTYPE retValue =
       
   151 		aFsm.iPortManager.SetConfig(aConfigIndex,
       
   152 									apComponentConfigStructure);
       
   153 
       
   154 	if (OMX_ErrorUnsupportedIndex == retValue)
       
   155 		{
       
   156 		// Try Config Manager now...
       
   157 		retValue = aFsm.iConfigManager.SetConfig(
       
   158 			aConfigIndex,
       
   159 			apComponentConfigStructure);
       
   160 		}
       
   161 
       
   162 	return retValue;
       
   163 
       
   164 	}
       
   165 
       
   166 OMX_ERRORTYPE
       
   167 COmxILFsm::COmxILState::GetExtensionIndex(const COmxILFsm& aFsm,
       
   168 										  OMX_STRING aParameterName,
       
   169 										  OMX_INDEXTYPE* apIndexType) const
       
   170 	{
       
   171     DEBUG_PRINTF(_L8("COmxILState::GetExtensionIndex"));
       
   172 
       
   173 	OMX_ERRORTYPE retValue =
       
   174 		aFsm.iPortManager.GetExtensionIndex(aParameterName,
       
   175 											apIndexType);
       
   176 
       
   177 	if (OMX_ErrorUnsupportedIndex == retValue)
       
   178 		{
       
   179 		// Try Config Manager now...
       
   180 		retValue = aFsm.iConfigManager.GetExtensionIndex(
       
   181 			aParameterName,
       
   182 			apIndexType);
       
   183 		}
       
   184 
       
   185 	return retValue;
       
   186 
       
   187 	}
       
   188 
       
   189 //
       
   190 //
       
   191 //
       
   192 
       
   193 OMX_ERRORTYPE
       
   194 COmxILFsm::COmxILState::CommandFlush(COmxILFsm& aFsm,
       
   195 									 const TOmxILCommand& aCommand)
       
   196 	{
       
   197     DEBUG_PRINTF(_L8("COmxILState::CommandFlush"));
       
   198 
       
   199 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandFlush,
       
   200 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
   201 
       
   202 	return aFsm.iPortManager.BufferFlushIndicationFlushCommand(
       
   203 		aCommand.iParam1);
       
   204 
       
   205 	}
       
   206 
       
   207 OMX_ERRORTYPE
       
   208 COmxILFsm::COmxILState::CommandPortDisable(COmxILFsm& aFsm,
       
   209 										   const TOmxILCommand& aCommand)
       
   210 	{
       
   211     DEBUG_PRINTF(_L8("COmxILState::CommandPortDisable"));
       
   212 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandPortDisable,
       
   213 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
   214 
       
   215 	// First, flush all buffers in the port(s) that is(are) to be disabled.
       
   216 	return aFsm.iPortManager.PortDisableIndication(
       
   217 		aCommand.iParam1);
       
   218 
       
   219 	}
       
   220 
       
   221 OMX_ERRORTYPE
       
   222 COmxILFsm::COmxILState::CommandPortEnable(COmxILFsm& aFsm,
       
   223 										  const TOmxILCommand& aCommand)
       
   224 	{
       
   225     DEBUG_PRINTF(_L8("COmxILState::CommandPortEnable"));
       
   226 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandPortEnable,
       
   227 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
   228 
       
   229 	TBool indicationIsFinal = EFalse;
       
   230 	return aFsm.iPortManager.PortEnableIndication(
       
   231 		aCommand.iParam1,
       
   232 		indicationIsFinal);
       
   233 
       
   234 	}
       
   235 
       
   236 OMX_ERRORTYPE
       
   237 COmxILFsm::COmxILState::CommandMarkBuffer(COmxILFsm& aFsm,
       
   238 										  const TOmxILCommand& aCommand)
       
   239 	{
       
   240     DEBUG_PRINTF(_L8("COmxILState::CommandMarkBuffer"));
       
   241 
       
   242 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandMarkBuffer,
       
   243 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
   244 
       
   245 	if (!aCommand.ipCommandData)
       
   246 		{
       
   247 		return OMX_ErrorBadParameter;
       
   248 		}
       
   249 
       
   250 	return aFsm.iPortManager.BufferMarkIndication(aCommand.iParam1,
       
   251 												  aCommand.ipCommandData);
       
   252 
       
   253 	}
       
   254 
       
   255 
       
   256 //
       
   257 // COmxILStateInvalid
       
   258 //
       
   259 OMX_ERRORTYPE
       
   260 COmxILFsm::COmxILStateInvalid::GetParameter(
       
   261 	const COmxILFsm& /*aFsm*/,
       
   262 	OMX_INDEXTYPE /*aParamIndex*/,
       
   263 	TAny* /*apComponentParameterStructure*/) const
       
   264 	{
       
   265     DEBUG_PRINTF(_L8("COmxILStateInvalid::GetParameter"));
       
   266 	return OMX_ErrorInvalidState;
       
   267 	}
       
   268 
       
   269 OMX_ERRORTYPE
       
   270 COmxILFsm::COmxILStateInvalid::SetParameter(
       
   271 	COmxILFsm& /*aFsm*/,
       
   272 	OMX_INDEXTYPE /*aParamIndex*/,
       
   273 	const TAny* /*apComponentParameterStructure*/)
       
   274 	{
       
   275     DEBUG_PRINTF(_L8("COmxILStateInvalid::SetParameter"));
       
   276 	return OMX_ErrorInvalidState;
       
   277 	}
       
   278 
       
   279 OMX_ERRORTYPE
       
   280 COmxILFsm::COmxILStateInvalid::GetConfig(
       
   281 	const COmxILFsm& /*aFsm*/,
       
   282 	OMX_INDEXTYPE /*aConfigIndex*/,
       
   283 	TAny* /*apComponentConfigStructure*/) const
       
   284 	{
       
   285     DEBUG_PRINTF(_L8("COmxILStateInvalid::GetConfig"));
       
   286 	return OMX_ErrorInvalidState;
       
   287 	}
       
   288 
       
   289 OMX_ERRORTYPE
       
   290 COmxILFsm::COmxILStateInvalid::SetConfig(
       
   291 	COmxILFsm& /*aFsm*/,
       
   292 	OMX_INDEXTYPE /*aConfigIndex*/,
       
   293 	const TAny* /*apComponentConfigStructure*/)
       
   294 	{
       
   295     DEBUG_PRINTF(_L8("COmxILStateInvalid::SetConfig"));
       
   296 	return OMX_ErrorInvalidState;
       
   297 	}
       
   298 
       
   299 OMX_ERRORTYPE
       
   300 COmxILFsm::COmxILStateInvalid::GetExtensionIndex(
       
   301 	const COmxILFsm& /*aFsm*/,
       
   302 	OMX_STRING /*aParameterName*/,
       
   303 	OMX_INDEXTYPE* /*apIndexType*/) const
       
   304 	{
       
   305 	DEBUG_PRINTF(_L8("COmxILStateInvalid::GetExtensionIndex"));
       
   306 	return OMX_ErrorInvalidState;
       
   307 	}
       
   308 
       
   309 OMX_STATETYPE
       
   310 COmxILFsm::COmxILStateInvalid::GetState() const
       
   311 	{
       
   312     DEBUG_PRINTF(_L8("COmxILStateInvalid::GetState"));
       
   313 	return OMX_StateInvalid;
       
   314 	}
       
   315 
       
   316 OMX_ERRORTYPE
       
   317 COmxILFsm::COmxILStateInvalid::ComponentTunnelRequest(
       
   318 	COmxILFsm& /*aFsm*/,
       
   319 	OMX_U32 /*aPort*/,
       
   320 	OMX_HANDLETYPE /*aTunneledComp*/,
       
   321 	OMX_U32 /*aTunneledPort*/,
       
   322 	OMX_TUNNELSETUPTYPE* /*apTunnelSetup*/)
       
   323 	{
       
   324     DEBUG_PRINTF(_L8("COmxILStateInvalid::ComponentTunnelRequest"));
       
   325 
       
   326 	return OMX_ErrorInvalidState;
       
   327 
       
   328 	}
       
   329 
       
   330 OMX_ERRORTYPE
       
   331 COmxILFsm::COmxILStateInvalid::PopulateBuffer(
       
   332 	COmxILFsm& /*aFsm*/,
       
   333 	OMX_BUFFERHEADERTYPE** /*appBufferHdr*/,
       
   334 	OMX_U32 /*aPortIndex*/,
       
   335 	OMX_PTR /*apAppPrivate*/,
       
   336 	OMX_U32 /*aSizeBytes*/,
       
   337 	OMX_U8* /*apBuffer*/,
       
   338 	TBool& /*portPopulationCompleted*/)
       
   339 	{
       
   340     DEBUG_PRINTF(_L8("COmxILStateInvalid::PopulateBuffer"));
       
   341 
       
   342 	return OMX_ErrorInvalidState;
       
   343 
       
   344 	}
       
   345 
       
   346 OMX_ERRORTYPE
       
   347 COmxILFsm::COmxILStateInvalid::FreeBuffer(COmxILFsm& aFsm,
       
   348 										  OMX_U32 aPortIndex,
       
   349 										  OMX_BUFFERHEADERTYPE* apBuffer,
       
   350 										  TBool& aPortDepopulationCompleted)
       
   351 	{
       
   352     DEBUG_PRINTF(_L8("COmxILStateInvalid::FreeBuffer"));
       
   353 
       
   354 	return COmxILState::FreeBufferV2(
       
   355 		aFsm,
       
   356 		aPortIndex,
       
   357 		apBuffer,
       
   358 		aPortDepopulationCompleted);
       
   359 
       
   360 	}
       
   361 
       
   362 OMX_ERRORTYPE
       
   363 COmxILFsm::COmxILStateInvalid::EmptyThisBuffer(
       
   364 	COmxILFsm& /*aFsm*/,
       
   365 	OMX_BUFFERHEADERTYPE* /*apBuffer*/)
       
   366 	{
       
   367     DEBUG_PRINTF(_L8("COmxILStateInvalid::EmptyThisBuffer"));
       
   368 
       
   369 	return OMX_ErrorInvalidState;
       
   370 
       
   371 	}
       
   372 
       
   373 OMX_ERRORTYPE
       
   374 COmxILFsm::COmxILStateInvalid::FillThisBuffer(
       
   375 	COmxILFsm& /*aFsm*/,
       
   376 	OMX_BUFFERHEADERTYPE* /*apBuffer*/)
       
   377 	{
       
   378     DEBUG_PRINTF(_L8("COmxILStateInvalid::FillThisBuffer"));
       
   379 
       
   380 	return OMX_ErrorInvalidState;
       
   381 
       
   382 	}
       
   383 
       
   384 OMX_ERRORTYPE
       
   385 COmxILFsm::COmxILStateInvalid::CommandStateSet(
       
   386 	COmxILFsm& /*aFsm*/,
       
   387 	const TOmxILCommand& /*aCommand*/)
       
   388 	{
       
   389     DEBUG_PRINTF(_L8("COmxILStateInvalid::CommandStateSet"));
       
   390 	return OMX_ErrorInvalidState;
       
   391 	}
       
   392 
       
   393 OMX_ERRORTYPE
       
   394 COmxILFsm::COmxILStateInvalid::CommandFlush(
       
   395 	COmxILFsm& /*aFsm*/,
       
   396 	const TOmxILCommand& /*aCommand*/)
       
   397 	{
       
   398     DEBUG_PRINTF(_L8("COmxILStateInvalid::CommandFlush"));
       
   399 	return OMX_ErrorInvalidState;
       
   400 	}
       
   401 
       
   402 OMX_ERRORTYPE
       
   403 COmxILFsm::COmxILStateInvalid::CommandPortEnable(
       
   404 	COmxILFsm& /*aFsm*/,
       
   405 	const TOmxILCommand& /*aCommand*/)
       
   406 	{
       
   407     DEBUG_PRINTF(_L8("COmxILStateInvalid::CommandPortEnable"));
       
   408 	return OMX_ErrorInvalidState;
       
   409 	}
       
   410 
       
   411 OMX_ERRORTYPE
       
   412 COmxILFsm::COmxILStateInvalid::CommandPortDisable(
       
   413 	COmxILFsm& /*aFsm*/,
       
   414 	const TOmxILCommand& /*aCommand*/)
       
   415 	{
       
   416     DEBUG_PRINTF(_L8("COmxILStateInvalid::CommandPortDisable"));
       
   417 	return OMX_ErrorInvalidState;
       
   418 	}
       
   419 
       
   420 OMX_ERRORTYPE
       
   421 COmxILFsm::COmxILStateInvalid::CommandMarkBuffer(
       
   422 	COmxILFsm& /*aFsm*/,
       
   423 	const TOmxILCommand& /*aCommand*/)
       
   424 	{
       
   425     DEBUG_PRINTF(_L8("COmxILStateInvalid::CommandMarkBuffer"));
       
   426 	return OMX_ErrorInvalidState;
       
   427 	}
       
   428 
       
   429 
       
   430 //
       
   431 // COmxILStateLoaded
       
   432 //
       
   433 OMX_STATETYPE
       
   434 COmxILFsm::COmxILStateLoaded::GetState() const
       
   435 	{
       
   436     DEBUG_PRINTF(_L8("COmxILStateLoaded::GetState"));
       
   437 	return OMX_StateLoaded;
       
   438 	}
       
   439 
       
   440 OMX_ERRORTYPE
       
   441 COmxILFsm::COmxILStateLoaded::SetParameter(
       
   442 	COmxILFsm& aFsm,
       
   443 	OMX_INDEXTYPE aParamIndex,
       
   444 	const TAny* apComponentParameterStructure)
       
   445 	{
       
   446     DEBUG_PRINTF(_L8("COmxILStateLoaded::SetParameter"));
       
   447 
       
   448 	return COmxILState::SetParameterV2(aFsm,
       
   449 									   aParamIndex,
       
   450 									   apComponentParameterStructure);
       
   451 
       
   452 	}
       
   453 
       
   454 OMX_ERRORTYPE
       
   455 COmxILFsm::COmxILStateLoaded::PopulateBuffer(
       
   456 	COmxILFsm& aFsm,
       
   457 	OMX_BUFFERHEADERTYPE** appBufferHdr,
       
   458 	OMX_U32 aPortIndex,
       
   459 	OMX_PTR apAppPrivate,
       
   460 	OMX_U32 aSizeBytes,
       
   461 	OMX_U8* apBuffer,
       
   462 	TBool& portPopulationCompleted)
       
   463 	{
       
   464     DEBUG_PRINTF(_L8("COmxILStateLoaded::PopulateBuffer"));
       
   465 
       
   466 	// At this point, the command requesting the transition from Loaded to Idle
       
   467 	// has not been received yet.. (see COmxILStateLoadedToIdle). Therefore,
       
   468 	// this can only be successful if the port is disabled
       
   469 	return COmxILState::PopulateBuffer(aFsm,
       
   470 									   appBufferHdr,
       
   471 									   aPortIndex,
       
   472 									   apAppPrivate,
       
   473 									   aSizeBytes,
       
   474 									   apBuffer,
       
   475 									   portPopulationCompleted);
       
   476 
       
   477 	}
       
   478 
       
   479 
       
   480 OMX_ERRORTYPE
       
   481 COmxILFsm::COmxILStateLoaded::FreeBuffer(COmxILFsm& aFsm,
       
   482 										 OMX_U32 aPortIndex,
       
   483 										 OMX_BUFFERHEADERTYPE* apBuffer,
       
   484 										 TBool& aPortDepopulationCompleted)
       
   485 	{
       
   486     DEBUG_PRINTF(_L8("COmxILStateLoaded::FreeBuffer"));
       
   487 
       
   488 	return COmxILState::FreeBuffer(aFsm,
       
   489 								   aPortIndex,
       
   490 								   apBuffer,
       
   491 								   aPortDepopulationCompleted);
       
   492 
       
   493 	}
       
   494 
       
   495 OMX_ERRORTYPE
       
   496 COmxILFsm::COmxILStateLoaded::EmptyThisBuffer(COmxILFsm& aFsm,
       
   497 											  OMX_BUFFERHEADERTYPE* apBuffer)
       
   498 	{
       
   499     DEBUG_PRINTF(_L8("COmxILStateLoaded::EmptyThisBuffer"));
       
   500 
       
   501 	return COmxILState::EmptyThisBuffer(aFsm,
       
   502 										apBuffer);
       
   503 
       
   504 	}
       
   505 
       
   506 OMX_ERRORTYPE
       
   507 COmxILFsm::COmxILStateLoaded::FillThisBuffer(COmxILFsm& aFsm,
       
   508 											 OMX_BUFFERHEADERTYPE* apBuffer)
       
   509 	{
       
   510     DEBUG_PRINTF(_L8("COmxILStateLoaded::FillThisBuffer"));
       
   511 
       
   512 	return COmxILState::FillThisBuffer(aFsm,
       
   513 									   apBuffer);
       
   514 
       
   515 	}
       
   516 
       
   517 OMX_ERRORTYPE
       
   518 COmxILFsm::COmxILStateLoaded::ComponentTunnelRequest(
       
   519 	COmxILFsm& aFsm,
       
   520 	OMX_U32 aPort,
       
   521 	OMX_HANDLETYPE aTunneledComp,
       
   522 	OMX_U32 aTunneledPort,
       
   523 	OMX_TUNNELSETUPTYPE* apTunnelSetup)
       
   524 	{
       
   525     DEBUG_PRINTF(_L8("COmxILStateLoaded::ComponentTunnelRequest"));
       
   526 
       
   527 	return COmxILState::ComponentTunnelRequestV2(aFsm,
       
   528 												 aPort,
       
   529 												 aTunneledComp,
       
   530 												 aTunneledPort,
       
   531 												 apTunnelSetup);
       
   532 
       
   533 	}
       
   534 
       
   535 
       
   536 OMX_ERRORTYPE
       
   537 COmxILFsm::COmxILStateLoaded::CommandStateSet(
       
   538 	COmxILFsm& aFsm,
       
   539 	const TOmxILCommand& aCommand)
       
   540 	{
       
   541     DEBUG_PRINTF(_L8("COmxILStateLoaded::CommandStateSet"));
       
   542 
       
   543 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandStateSet,
       
   544 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
   545 
       
   546 	// The only two transitions allowed are :
       
   547 	// - OMX_StateIdle and
       
   548 	// - OMX_StateWaitForResources.
       
   549 	COmxILFsm::TStateIndex nextState = COmxILFsm::EStateMax;
       
   550 	switch(aCommand.iParam1)
       
   551 		{
       
   552 	case OMX_StateIdle:
       
   553 		{
       
   554 		nextState = COmxILFsm::ESubStateLoadedToIdle;
       
   555 		}
       
   556 		break;
       
   557 	case OMX_StateWaitForResources:
       
   558 		{
       
   559 		nextState = COmxILFsm::EStateWaitForResources;
       
   560 		}
       
   561 		break;
       
   562 	case OMX_StateLoaded:
       
   563 		{
       
   564 		return OMX_ErrorSameState;
       
   565 		}
       
   566 	case OMX_StateInvalid:
       
   567 		{
       
   568 		// Notify the IL client... ignore the ret value..
       
   569 		aFsm.iCallbacks.TransitionCompleteNotification(OMX_StateInvalid);
       
   570 		// Invalidate component
       
   571 		return OMX_ErrorInvalidState;
       
   572 		}
       
   573 	default:
       
   574 		{
       
   575 		return OMX_ErrorIncorrectStateTransition;
       
   576 		}
       
   577 
       
   578 		};
       
   579 
       
   580 	// Initial checks OK. The component is commanded to make a transition to
       
   581 	// OMX_StateIdle or OMX_StateWaitForResources.
       
   582 	OMX_ERRORTYPE omxRetValue = aFsm.FsmTransition(nextState);
       
   583 	if (OMX_ErrorNone != omxRetValue)
       
   584 		{
       
   585 		return omxRetValue;
       
   586 		}
       
   587 
       
   588 	if (COmxILFsm::ESubStateLoadedToIdle == nextState)
       
   589 		{
       
   590 		// Lets tell port manager in case there are buffer supplier tunnelled ports
       
   591 		TBool componentPopulationCompleted = EFalse;
       
   592 		omxRetValue =
       
   593 			aFsm.iPortManager.TunnellingBufferAllocation(
       
   594 				componentPopulationCompleted);
       
   595 		if (OMX_ErrorNone != omxRetValue)
       
   596 			{
       
   597 			return omxRetValue;
       
   598 			}
       
   599 
       
   600 		if (componentPopulationCompleted)
       
   601 			{
       
   602 			// Complete here the transition to OMX_StateIdle
       
   603 			omxRetValue = aFsm.FsmTransition(COmxILFsm::EStateIdle);
       
   604 			if (OMX_ErrorNone == omxRetValue)
       
   605 				{
       
   606 				// Notify the IL client that port population has completed
       
   607 				// sucessfully
       
   608 				omxRetValue =
       
   609 					aFsm.iCallbacks.TransitionCompleteNotification(
       
   610 						OMX_StateIdle);
       
   611 				}
       
   612 
       
   613 			}
       
   614 
       
   615 		}
       
   616 	else
       
   617 		{
       
   618 		// Notify the IL client that the transition to
       
   619 		// OMX_StateWaitForResources has completed sucessfully
       
   620 		omxRetValue = aFsm.iCallbacks.TransitionCompleteNotification(
       
   621 			OMX_StateWaitForResources);
       
   622 
       
   623 		}
       
   624 
       
   625 	return omxRetValue;
       
   626 
       
   627 	}
       
   628 
       
   629 OMX_ERRORTYPE
       
   630 COmxILFsm::COmxILStateLoaded::CommandPortEnable(
       
   631 	COmxILFsm& aFsm,
       
   632 	const TOmxILCommand& aCommand)
       
   633 	{
       
   634     DEBUG_PRINTF(_L8("COmxILStateLoaded::CommandPortEnable"));
       
   635 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandPortEnable,
       
   636 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
   637 
       
   638 	TBool indicationIsFinal = ETrue;
       
   639 	return aFsm.iPortManager.PortEnableIndication(
       
   640 		aCommand.iParam1,
       
   641 		indicationIsFinal);
       
   642 
       
   643 	}
       
   644 
       
   645 
       
   646 //
       
   647 // COmxILStateLoadedToIdle
       
   648 //
       
   649 OMX_ERRORTYPE
       
   650 COmxILFsm::COmxILStateLoadedToIdle::SetParameter(
       
   651 	COmxILFsm& aFsm,
       
   652 	OMX_INDEXTYPE aParamIndex,
       
   653 	const TAny* apComponentParameterStructure)
       
   654 	{
       
   655 
       
   656 	// In this transitional state, OMX_SetParameter is allowed only if
       
   657 	// OMX_UseBuffer has not been received yet...
       
   658 	if (iUseBufferReceived)
       
   659 		{
       
   660 		return OMX_ErrorIncorrectStateOperation;
       
   661 		}
       
   662 
       
   663 
       
   664 	return COmxILStateLoaded::SetParameter(aFsm,
       
   665 										   aParamIndex,
       
   666 										   apComponentParameterStructure);
       
   667 
       
   668 	}
       
   669 
       
   670 OMX_ERRORTYPE
       
   671 COmxILFsm::COmxILStateLoadedToIdle::PopulateBuffer(
       
   672 	COmxILFsm& aFsm,
       
   673 	OMX_BUFFERHEADERTYPE** appBufferHdr,
       
   674 	OMX_U32 aPortIndex,
       
   675 	OMX_PTR apAppPrivate,
       
   676 	OMX_U32 aSizeBytes,
       
   677 	OMX_U8* apBuffer,
       
   678 	TBool& portPopulationCompleted)
       
   679 	{
       
   680     DEBUG_PRINTF(_L8("COmxILStateLoadedToIdle::PopulateBuffer"));
       
   681 
       
   682 	OMX_ERRORTYPE omxError =
       
   683 		COmxILState::PopulateBufferV2(aFsm,
       
   684 									  appBufferHdr,
       
   685 									  aPortIndex,
       
   686 									  apAppPrivate,
       
   687 									  aSizeBytes,
       
   688 									  apBuffer,
       
   689 									  portPopulationCompleted);
       
   690 
       
   691 	if (apBuffer && OMX_ErrorNone == omxError)
       
   692 		{
       
   693 		// Flag that OMX_UseBuffer has been called in LoadedToIdle state. This
       
   694 		// will be used to know if an OMX_SetParameter call will be allowed in
       
   695 		// this state... It will be allowed only if false...
       
   696 		iUseBufferReceived = ETrue;
       
   697 		}
       
   698 
       
   699 	return omxError;
       
   700 
       
   701 	}
       
   702 
       
   703 
       
   704 OMX_ERRORTYPE
       
   705 COmxILFsm::COmxILStateLoadedToIdle::CommandStateSet(
       
   706 	COmxILFsm& aFsm,
       
   707 	const TOmxILCommand& aCommand)
       
   708 	{
       
   709     DEBUG_PRINTF(_L8("COmxILStateLoadedToIdle::CommandStateSet"));
       
   710 
       
   711 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandStateSet,
       
   712 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
   713 
       
   714 	switch(aCommand.iParam1)
       
   715 		{
       
   716 	case OMX_StateWaitForResources:
       
   717 		{
       
   718 		// Not implemented for now...
       
   719 		return OMX_ErrorNotImplemented;
       
   720 		}
       
   721 	case OMX_StateLoaded:
       
   722 		{
       
   723 		// Here, return "same state" as the transition to OMX_StateLoaded has
       
   724 		// not completed yet.
       
   725 		return OMX_ErrorSameState;
       
   726 		}
       
   727 	case OMX_StateInvalid:
       
   728 		{
       
   729 		// Notify the IL client... ignore the ret value...
       
   730 		aFsm.iCallbacks.TransitionCompleteNotification(OMX_StateInvalid);
       
   731 		// Invalidate component
       
   732 		return OMX_ErrorInvalidState;
       
   733 		}
       
   734 	default:
       
   735 		{
       
   736 		return OMX_ErrorIncorrectStateTransition;
       
   737 		}
       
   738 		};
       
   739 
       
   740 	}
       
   741 
       
   742 OMX_ERRORTYPE
       
   743 COmxILFsm::COmxILStateLoadedToIdle::CommandPortEnable(
       
   744 	COmxILFsm& aFsm,
       
   745 	const TOmxILCommand& aCommand)
       
   746 	{
       
   747     DEBUG_PRINTF(_L8("COmxILStateLoadedToIdle::CommandPortEnable"));
       
   748 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandPortEnable,
       
   749 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
   750 
       
   751 	TBool indicationIsFinal = EFalse;
       
   752 	OMX_ERRORTYPE omxRetValue =
       
   753 		aFsm.iPortManager.PortEnableIndication(
       
   754 			aCommand.iParam1,
       
   755 			indicationIsFinal);
       
   756 	if (OMX_ErrorNone != omxRetValue)
       
   757 		{
       
   758 		return omxRetValue;
       
   759 		}
       
   760 
       
   761 	// Lets tell port manager in case the port being enabled is a tunnel
       
   762 	// supplier...
       
   763 	TBool componentPopulationCompleted = EFalse;
       
   764 	omxRetValue =
       
   765 		aFsm.iPortManager.TunnellingBufferAllocation(
       
   766 			componentPopulationCompleted, aCommand.iParam1);
       
   767 	if (OMX_ErrorNone != omxRetValue)
       
   768 		{
       
   769 		return omxRetValue;
       
   770 		}
       
   771 
       
   772 	// Let's do this check here although this situation is going to be very
       
   773 	// unlikely...
       
   774 	if (componentPopulationCompleted)
       
   775 		{
       
   776 		// Complete here the transition to OMX_StateIdle
       
   777 		omxRetValue = aFsm.FsmTransition(COmxILFsm::EStateIdle);
       
   778 		if (OMX_ErrorNone == omxRetValue)
       
   779 			{
       
   780 			// Notify the IL client that port population has completed sucessfully
       
   781 			aFsm.iCallbacks.TransitionCompleteNotification(
       
   782 				OMX_StateIdle);
       
   783 			}
       
   784 
       
   785 		}
       
   786 
       
   787 	return omxRetValue;
       
   788 
       
   789 	}
       
   790 
       
   791 
       
   792 //
       
   793 // COmxILStateWaitForResources
       
   794 //
       
   795 OMX_STATETYPE
       
   796 COmxILFsm::COmxILStateWaitForResources::GetState() const
       
   797 	{
       
   798     DEBUG_PRINTF(_L8("COmxILStateWaitForResources::GetState"));
       
   799 	return OMX_StateWaitForResources;
       
   800 	}
       
   801 
       
   802 
       
   803 OMX_ERRORTYPE
       
   804 COmxILFsm::COmxILStateWaitForResources::SetParameter(
       
   805 	COmxILFsm& aFsm,
       
   806 	OMX_INDEXTYPE aParamIndex,
       
   807 	const TAny* apComponentParameterStructure)
       
   808 	{
       
   809     DEBUG_PRINTF(_L8("COmxILStateWaitForResources::SetParameter"));
       
   810 
       
   811 	return COmxILState::SetParameterV2(aFsm,
       
   812 									   aParamIndex,
       
   813 									   apComponentParameterStructure);
       
   814 
       
   815 	}
       
   816 
       
   817 
       
   818 OMX_ERRORTYPE
       
   819 COmxILFsm::COmxILStateWaitForResources::PopulateBuffer(
       
   820 	COmxILFsm& aFsm,
       
   821 	OMX_BUFFERHEADERTYPE** appBufferHdr,
       
   822 	OMX_U32 aPortIndex,
       
   823 	OMX_PTR apAppPrivate,
       
   824 	OMX_U32 aSizeBytes,
       
   825 	OMX_U8* apBuffer,
       
   826 	TBool& portPopulationCompleted)
       
   827 	{
       
   828     DEBUG_PRINTF(_L8("COmxILStateWaitForResources::PopulateBuffer"));
       
   829 
       
   830 	// NOTE that according to the spec, PopulateBuffer could be used here even
       
   831 	// if the port is enabled. However, for now the transition from
       
   832 	// OMX_StateWaitForResouces -> OMX_StateIdle is not supported, therefore
       
   833 	// buffer population is only allowed for disabled ports. This should be
       
   834 	// changed once Resource Management functionality is available and this
       
   835 	// state is revisited.
       
   836 	return COmxILState::PopulateBuffer(aFsm,
       
   837 									   appBufferHdr,
       
   838 									   aPortIndex,
       
   839 									   apAppPrivate,
       
   840 									   aSizeBytes,
       
   841 									   apBuffer,
       
   842 									   portPopulationCompleted);
       
   843 
       
   844 	}
       
   845 
       
   846 
       
   847 OMX_ERRORTYPE
       
   848 COmxILFsm::COmxILStateWaitForResources::FreeBuffer(
       
   849 	COmxILFsm& aFsm,
       
   850 	OMX_U32 aPortIndex,
       
   851 	OMX_BUFFERHEADERTYPE* apBuffer,
       
   852 	TBool& aPortDepopulationCompleted)
       
   853 	{
       
   854     DEBUG_PRINTF(_L8("COmxILStateWaitForResources::FreeBuffer"));
       
   855 
       
   856 	return COmxILState::FreeBuffer(aFsm,
       
   857 								   aPortIndex,
       
   858 								   apBuffer,
       
   859 								   aPortDepopulationCompleted);
       
   860 
       
   861 	}
       
   862 
       
   863 OMX_ERRORTYPE
       
   864 COmxILFsm::COmxILStateWaitForResources::EmptyThisBuffer(
       
   865 	COmxILFsm& aFsm,
       
   866 	OMX_BUFFERHEADERTYPE* apBuffer)
       
   867 	{
       
   868     DEBUG_PRINTF(_L8("COmxILStateWaitForResources::EmptyThisBuffer"));
       
   869 
       
   870 	return COmxILState::EmptyThisBuffer(aFsm,
       
   871 										apBuffer);
       
   872 
       
   873 
       
   874 	}
       
   875 
       
   876 OMX_ERRORTYPE
       
   877 COmxILFsm::COmxILStateWaitForResources::FillThisBuffer(
       
   878 	COmxILFsm& aFsm,
       
   879 	OMX_BUFFERHEADERTYPE* apBuffer)
       
   880 	{
       
   881     DEBUG_PRINTF(_L8("COmxILStateWaitForResources::FillThisBuffer"));
       
   882 
       
   883 	return COmxILState::FillThisBuffer(aFsm,
       
   884 									   apBuffer);
       
   885 
       
   886 	}
       
   887 
       
   888 
       
   889 OMX_ERRORTYPE
       
   890 COmxILFsm::COmxILStateWaitForResources::ComponentTunnelRequest(
       
   891 	COmxILFsm& aFsm,
       
   892 	OMX_U32 aPort,
       
   893 	OMX_HANDLETYPE aTunneledComp,
       
   894 	OMX_U32 aTunneledPort,
       
   895 	OMX_TUNNELSETUPTYPE* apTunnelSetup)
       
   896 	{
       
   897     DEBUG_PRINTF(_L8("COmxILStateWaitForResources::ComponentTunnelRequest"));
       
   898 
       
   899 	return COmxILState::ComponentTunnelRequest(aFsm,
       
   900 											   aPort,
       
   901 											   aTunneledComp,
       
   902 											   aTunneledPort,
       
   903 											   apTunnelSetup);
       
   904 
       
   905 	}
       
   906 
       
   907 
       
   908 OMX_ERRORTYPE
       
   909 COmxILFsm::COmxILStateWaitForResources::CommandStateSet(
       
   910 	COmxILFsm& aFsm,
       
   911 	const TOmxILCommand& aCommand)
       
   912 	{
       
   913     DEBUG_PRINTF(_L8("COmxILStateWaitForResources::CommandStateSet"));
       
   914 
       
   915 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandStateSet,
       
   916 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
   917 
       
   918 	// Transition to OMX_StateIdle not implemented for now...
       
   919 	COmxILFsm::TStateIndex nextState = COmxILFsm::EStateMax;
       
   920 	switch(aCommand.iParam1)
       
   921 		{
       
   922 	case OMX_StateLoaded:
       
   923 		{
       
   924 		nextState = COmxILFsm::EStateLoaded;
       
   925 		}
       
   926 		break;
       
   927 	case OMX_StateWaitForResources:
       
   928 		{
       
   929 		return OMX_ErrorSameState;
       
   930 		}
       
   931 	case OMX_StateInvalid:
       
   932 		{
       
   933 		// Notify the IL client... ignore the ret value...
       
   934 		aFsm.iCallbacks.TransitionCompleteNotification(OMX_StateInvalid);
       
   935 		// Invalidate component
       
   936 		return OMX_ErrorInvalidState;
       
   937 		}
       
   938 	default:
       
   939 		{
       
   940 		return OMX_ErrorIncorrectStateTransition;
       
   941 		}
       
   942 		};
       
   943 
       
   944 	// Initial checks OK. The component is commanded to make a transition to
       
   945 	// OMX_StateLoaded
       
   946 	OMX_ERRORTYPE omxRetValue = aFsm.FsmTransition(nextState);
       
   947 	if (OMX_ErrorNone == omxRetValue)
       
   948 		{
       
   949 		// Notify the IL client that the transition to
       
   950 		// OMX_StateLoaded has completed sucessfully
       
   951 		omxRetValue =
       
   952 			aFsm.iCallbacks.TransitionCompleteNotification(OMX_StateLoaded);
       
   953 		}
       
   954 
       
   955 	return omxRetValue;
       
   956 
       
   957 	}
       
   958 
       
   959 OMX_ERRORTYPE
       
   960 COmxILFsm::COmxILStateWaitForResources::CommandPortEnable(
       
   961 	COmxILFsm& aFsm,
       
   962 	const TOmxILCommand& aCommand)
       
   963 	{
       
   964     DEBUG_PRINTF(_L8("COmxILStateWaitForResources::CommandPortEnable"));
       
   965 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandPortEnable,
       
   966 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
   967 
       
   968     // NOTE: Here, we only care about the port enabled flag. Transition from
       
   969     // OMX_StateWaitForResources to OMX_StateIdle is not implemented at this
       
   970     // stage until a Resource Manager is available. Whenever a Resource Manager
       
   971     // becomes available, a COmxILStateWaitForResourcesToIdle substate should
       
   972     // be implemented to handle the allocation of buffers mandated by the
       
   973     // standard when a port is enabled in this transition.
       
   974 	TBool indicationIsFinal = ETrue;
       
   975 	return aFsm.iPortManager.PortEnableIndication(
       
   976 		aCommand.iParam1,
       
   977 		indicationIsFinal);
       
   978 
       
   979 	}
       
   980 
       
   981 
       
   982 //
       
   983 // COmxILStateIdle
       
   984 //
       
   985 OMX_STATETYPE
       
   986 COmxILFsm::COmxILStateIdle::GetState() const
       
   987 	{
       
   988     DEBUG_PRINTF(_L8("COmxILStateIdle::GetState"));
       
   989 	return OMX_StateIdle;
       
   990 	}
       
   991 
       
   992 
       
   993 OMX_ERRORTYPE
       
   994 COmxILFsm::COmxILStateIdle::SetParameter(
       
   995 	COmxILFsm& aFsm,
       
   996 	OMX_INDEXTYPE aParamIndex,
       
   997 	const TAny* apComponentParameterStructure)
       
   998 	{
       
   999     DEBUG_PRINTF(_L8("COmxILStateIdle::SetParameter"));
       
  1000 
       
  1001 	return COmxILState::SetParameter(aFsm,
       
  1002 									 aParamIndex,
       
  1003 									 apComponentParameterStructure);
       
  1004 
       
  1005 	}
       
  1006 
       
  1007 OMX_ERRORTYPE
       
  1008 COmxILFsm::COmxILStateIdle::PopulateBuffer(COmxILFsm& aFsm,
       
  1009 										   OMX_BUFFERHEADERTYPE** appBufferHdr,
       
  1010 										   OMX_U32 aPortIndex,
       
  1011 										   OMX_PTR apAppPrivate,
       
  1012 										   OMX_U32 aSizeBytes,
       
  1013 										   OMX_U8* apBuffer,
       
  1014 										   TBool& portPopulationCompleted)
       
  1015 	{
       
  1016     DEBUG_PRINTF(_L8("COmxILStateIdle::PopulateBuffer"));
       
  1017 
       
  1018 	// At this point, no buffer population can take place unless the port is disabled
       
  1019 	return COmxILState::PopulateBuffer(aFsm,
       
  1020 									   appBufferHdr,
       
  1021 									   aPortIndex,
       
  1022 									   apAppPrivate,
       
  1023 									   aSizeBytes,
       
  1024 									   apBuffer,
       
  1025 									   portPopulationCompleted);
       
  1026 
       
  1027 	}
       
  1028 
       
  1029 
       
  1030 OMX_ERRORTYPE
       
  1031 COmxILFsm::COmxILStateIdle::FreeBuffer(COmxILFsm& aFsm,
       
  1032 									   OMX_U32 aPortIndex,
       
  1033 									   OMX_BUFFERHEADERTYPE* apBuffer,
       
  1034 									   TBool& aPortDepopulationCompleted)
       
  1035 	{
       
  1036     DEBUG_PRINTF(_L8("COmxILStateIdle::FreeBuffer"));
       
  1037 
       
  1038 	// At this point, the command requesting the transition from Idle to Loaded
       
  1039 	// has not been received yet.. (see COmxILStateIdleToLoaded). Therefore,
       
  1040 	// this can only be successful if the port is disabled
       
  1041 	return COmxILState::FreeBuffer(aFsm,
       
  1042 								   aPortIndex,
       
  1043 								   apBuffer,
       
  1044 								   aPortDepopulationCompleted);
       
  1045 
       
  1046 	}
       
  1047 
       
  1048 OMX_ERRORTYPE
       
  1049 COmxILFsm::COmxILStateIdle::EmptyThisBuffer(
       
  1050 	COmxILFsm& aFsm,
       
  1051 	OMX_BUFFERHEADERTYPE* apBuffer)
       
  1052 	{
       
  1053     DEBUG_PRINTF(_L8("COmxILStateIdle::EmptyThisBuffer"));
       
  1054 
       
  1055 	return COmxILState::EmptyThisBufferV2(aFsm,
       
  1056 										  apBuffer);
       
  1057 
       
  1058 	}
       
  1059 
       
  1060 OMX_ERRORTYPE
       
  1061 COmxILFsm::COmxILStateIdle::FillThisBuffer(COmxILFsm& aFsm,
       
  1062 										   OMX_BUFFERHEADERTYPE* apBuffer)
       
  1063 	{
       
  1064     DEBUG_PRINTF(_L8("COmxILStateIdle::FillThisBuffer"));
       
  1065 
       
  1066 	return COmxILState::FillThisBufferV2(aFsm,
       
  1067 										 apBuffer);
       
  1068 
       
  1069 	}
       
  1070 
       
  1071 OMX_ERRORTYPE
       
  1072 COmxILFsm::COmxILStateIdle::ComponentTunnelRequest(
       
  1073 	COmxILFsm& aFsm,
       
  1074 	OMX_U32 aPort,
       
  1075 	OMX_HANDLETYPE aTunneledComp,
       
  1076 	OMX_U32 aTunneledPort,
       
  1077 	OMX_TUNNELSETUPTYPE* apTunnelSetup)
       
  1078 	{
       
  1079     DEBUG_PRINTF(_L8("COmxILStateIdle::ComponentTunnelRequest"));
       
  1080 
       
  1081 	return COmxILState::ComponentTunnelRequest(aFsm,
       
  1082 											   aPort,
       
  1083 											   aTunneledComp,
       
  1084 											   aTunneledPort,
       
  1085 											   apTunnelSetup);
       
  1086 
       
  1087 	}
       
  1088 
       
  1089 OMX_ERRORTYPE
       
  1090 COmxILFsm::COmxILStateIdle::CommandStateSet(
       
  1091 	COmxILFsm& aFsm,
       
  1092 	const TOmxILCommand& aCommand)
       
  1093 	{
       
  1094     DEBUG_PRINTF(_L8("COmxILStateIdle::CommandStateSet"));
       
  1095 
       
  1096 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandStateSet,
       
  1097 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
  1098 
       
  1099 	COmxILFsm::TStateIndex nextState = COmxILFsm::EStateInvalid;
       
  1100 	switch(aCommand.iParam1)
       
  1101 		{
       
  1102 	case OMX_StateLoaded:
       
  1103 		{
       
  1104 		nextState = COmxILFsm::ESubStateIdleToLoaded;
       
  1105 		}
       
  1106 		break;
       
  1107 	case OMX_StateExecuting:
       
  1108 		{
       
  1109 		nextState = COmxILFsm::EStateExecuting;
       
  1110 		}
       
  1111 		break;
       
  1112 	case OMX_StatePause:
       
  1113 		{
       
  1114 		nextState = COmxILFsm::EStatePause;
       
  1115 		}
       
  1116 		break;
       
  1117 	case OMX_StateIdle:
       
  1118 		{
       
  1119 		return OMX_ErrorSameState;
       
  1120 		}
       
  1121 	case OMX_StateInvalid:
       
  1122 		{
       
  1123 		// Notify the IL client... ignore the ret value...
       
  1124 		aFsm.iCallbacks.TransitionCompleteNotification(OMX_StateInvalid);
       
  1125 		// Invalidate component
       
  1126 		return OMX_ErrorInvalidState;
       
  1127 		}
       
  1128 	default:
       
  1129 		{
       
  1130 		return OMX_ErrorIncorrectStateTransition;
       
  1131 		}
       
  1132 		};
       
  1133 
       
  1134 	// Initial command checks OK
       
  1135 
       
  1136 	// Commit transition to the valid state
       
  1137 	OMX_ERRORTYPE omxRetValue = aFsm.FsmTransition(nextState);
       
  1138 	if (OMX_ErrorNone != omxRetValue)
       
  1139 		{
       
  1140 		return omxRetValue;
       
  1141 		}
       
  1142 
       
  1143 	if (COmxILFsm::ESubStateIdleToLoaded == nextState)
       
  1144 		{
       
  1145 		// Lets tell port manager in case there are tunnelled ports...
       
  1146 		TBool componentDepopulationCompleted = EFalse;
       
  1147 		omxRetValue =
       
  1148 			aFsm.iPortManager.TunnellingBufferDeallocation(
       
  1149 				componentDepopulationCompleted);
       
  1150 		if (OMX_ErrorNone != omxRetValue)
       
  1151 			{
       
  1152 			return omxRetValue;
       
  1153 			}
       
  1154 
       
  1155 		if (componentDepopulationCompleted)
       
  1156 			{
       
  1157 			// Complete here the transition to OMX_StateLoaded
       
  1158 			omxRetValue = aFsm.FsmTransition(COmxILFsm::EStateLoaded);
       
  1159 			if (OMX_ErrorNone == omxRetValue)
       
  1160 				{
       
  1161 				// Notify the IL client that port population has completed sucessfully
       
  1162 				omxRetValue = aFsm.iCallbacks.TransitionCompleteNotification(
       
  1163 					OMX_StateLoaded);
       
  1164 				}
       
  1165 			}
       
  1166 
       
  1167 		}
       
  1168 	else
       
  1169 		{
       
  1170 		// Notify the IL client that the transition to the valid state
       
  1171 		// OMX_StatePause or OMX_StateExecuting has completed sucessfully
       
  1172 		omxRetValue = aFsm.iCallbacks.TransitionCompleteNotification(
       
  1173 			static_cast<OMX_STATETYPE>(aCommand.iParam1));
       
  1174 
       
  1175 		if (OMX_ErrorNone == omxRetValue)
       
  1176 			{
       
  1177 			// Fire up the tunnelled buffer exchange, if any tunnelled ports are
       
  1178 			// found in the component...
       
  1179 			omxRetValue = aFsm.iPortManager.InitiateTunnellingDataFlow();
       
  1180 			}
       
  1181 
       
  1182 		}
       
  1183 
       
  1184 	return omxRetValue;
       
  1185 
       
  1186 	}
       
  1187 
       
  1188 OMX_ERRORTYPE
       
  1189 COmxILFsm::COmxILStateIdle::CommandFlush(COmxILFsm& aFsm,
       
  1190 										 const TOmxILCommand& aCommand)
       
  1191 	{
       
  1192     DEBUG_PRINTF(_L8("COmxILStateIdle::CommandFlush"));
       
  1193 
       
  1194 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandFlush,
       
  1195 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
  1196 
       
  1197 	return aFsm.iPortManager.BufferFlushIndicationFlushCommand(
       
  1198 		aCommand.iParam1, OMX_FALSE); // Do not eject buffers
       
  1199 
       
  1200 	}
       
  1201 
       
  1202 
       
  1203 OMX_ERRORTYPE
       
  1204 COmxILFsm::COmxILStateIdle::CommandPortEnable(
       
  1205 	COmxILFsm& aFsm,
       
  1206 	const TOmxILCommand& aCommand)
       
  1207 	{
       
  1208     DEBUG_PRINTF(_L8("COmxILStateIdle::CommandPortEnable"));
       
  1209 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandPortEnable,
       
  1210 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
  1211 
       
  1212 	// In this state, the port allocation has finished for enabled
       
  1213 	// ports. However, a port is being enabled here. The port being enabled
       
  1214 	// must populate (if tunnel supplier) or be populated (if non-tunnel
       
  1215 	// supplier or IL Client communication)
       
  1216 	TBool indicationIsFinal = EFalse;
       
  1217 	OMX_ERRORTYPE omxRetValue =
       
  1218 		aFsm.iPortManager.PortEnableIndication(
       
  1219 			aCommand.iParam1,
       
  1220 			indicationIsFinal);
       
  1221 
       
  1222 	if (OMX_ErrorNone == omxRetValue)
       
  1223 		{
       
  1224 		// From section 3.2.2.6, "If the IL client enables a port while the
       
  1225 		// component is in any state other than OMX_StateLoaded or
       
  1226 		// OMX_WaitForResources, then that port shall allocate its buffers via
       
  1227 		// the same call sequence used on a transition from OMX_StateLoaded to
       
  1228 		// OMX_StateIdle."
       
  1229 
       
  1230 		// Lets tell port manager in case the port being enabled is a tunnel
       
  1231 		// supplier...
       
  1232 		TBool componentPopulationCompleted = EFalse;
       
  1233 		omxRetValue =
       
  1234 			aFsm.iPortManager.TunnellingBufferAllocation(
       
  1235 				componentPopulationCompleted, aCommand.iParam1);
       
  1236 		}
       
  1237 
       
  1238 	return omxRetValue;
       
  1239 
       
  1240 	}
       
  1241 
       
  1242 
       
  1243 //
       
  1244 // COmxILStateIdleToLoaded
       
  1245 //
       
  1246 OMX_ERRORTYPE
       
  1247 COmxILFsm::COmxILStateIdleToLoaded::FreeBuffer(COmxILFsm& aFsm,
       
  1248 											   OMX_U32 aPortIndex,
       
  1249 											   OMX_BUFFERHEADERTYPE* apBuffer,
       
  1250 											   TBool& aPortDepopulationCompleted)
       
  1251 	{
       
  1252     DEBUG_PRINTF(_L8("COmxILStateIdleToLoaded::FreeBuffer"));
       
  1253 
       
  1254 	return COmxILState::FreeBufferV2(aFsm,
       
  1255 									 aPortIndex,
       
  1256 									 apBuffer,
       
  1257 									 aPortDepopulationCompleted);
       
  1258 
       
  1259 	}
       
  1260 
       
  1261 
       
  1262 OMX_ERRORTYPE
       
  1263 COmxILFsm::COmxILStateIdleToLoaded::CommandStateSet(
       
  1264 	COmxILFsm& aFsm,
       
  1265 	const TOmxILCommand& aCommand)
       
  1266 	{
       
  1267     DEBUG_PRINTF(_L8("COmxILStateIdleToLoaded::CommandStateSet"));
       
  1268 
       
  1269 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandStateSet,
       
  1270 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
  1271 
       
  1272 	switch (aCommand.iParam1)
       
  1273 		{
       
  1274 	case OMX_StateIdle:
       
  1275 		{
       
  1276 		// Here, return "same state" as the transition to OMX_StateLoaded has
       
  1277 		// not completed yet.
       
  1278 		return OMX_ErrorSameState;
       
  1279 		}
       
  1280 	case OMX_StateInvalid:
       
  1281 		{
       
  1282 		// Notify the IL client... ignore the ret value...
       
  1283 		aFsm.iCallbacks.TransitionCompleteNotification(OMX_StateInvalid);
       
  1284 		// Invalidate component
       
  1285 		return OMX_ErrorInvalidState;
       
  1286 		}
       
  1287 	default:
       
  1288 		{
       
  1289 		__ASSERT_ALWAYS(0, User::Panic(KOmxILFsmPanicCategory, 1));
       
  1290 		}
       
  1291 		};
       
  1292 
       
  1293 	return OMX_ErrorNone;
       
  1294 
       
  1295 	}
       
  1296 
       
  1297 
       
  1298 //
       
  1299 // COmxILStateExecuting
       
  1300 //
       
  1301 OMX_STATETYPE
       
  1302 COmxILFsm::COmxILStateExecuting::GetState() const
       
  1303 	{
       
  1304     DEBUG_PRINTF(_L8("COmxILStateExecuting::GetState"));
       
  1305 	return OMX_StateExecuting;
       
  1306 	}
       
  1307 
       
  1308 
       
  1309 OMX_ERRORTYPE
       
  1310 COmxILFsm::COmxILStateExecuting::SetParameter(COmxILFsm& aFsm,
       
  1311 											  OMX_INDEXTYPE aParamIndex,
       
  1312 											  const TAny* apComponentParameterStructure)
       
  1313 	{
       
  1314     DEBUG_PRINTF(_L8("COmxILStateExecuting::SetParameter"));
       
  1315 
       
  1316 	return COmxILState::SetParameter(aFsm,
       
  1317 									 aParamIndex,
       
  1318 									 apComponentParameterStructure);
       
  1319 
       
  1320 	}
       
  1321 
       
  1322 
       
  1323 OMX_ERRORTYPE
       
  1324 COmxILFsm::COmxILStateExecuting::PopulateBuffer(COmxILFsm& aFsm,
       
  1325 												OMX_BUFFERHEADERTYPE** appBufferHdr,
       
  1326 												OMX_U32 aPortIndex,
       
  1327 												OMX_PTR apAppPrivate,
       
  1328 												OMX_U32 aSizeBytes,
       
  1329 												OMX_U8* apBuffer,
       
  1330 												TBool& portPopulationCompleted)
       
  1331 	{
       
  1332     DEBUG_PRINTF(_L8("COmxILStateExecuting::PopulateBuffer"));
       
  1333 
       
  1334 	return COmxILState::PopulateBuffer(aFsm,
       
  1335 									   appBufferHdr,
       
  1336 									   aPortIndex,
       
  1337 									   apAppPrivate,
       
  1338 									   aSizeBytes,
       
  1339 									   apBuffer,
       
  1340 									   portPopulationCompleted);
       
  1341 
       
  1342 	}
       
  1343 
       
  1344 
       
  1345 OMX_ERRORTYPE
       
  1346 COmxILFsm::COmxILStateExecuting::FreeBuffer(COmxILFsm& aFsm,
       
  1347 											OMX_U32 aPortIndex,
       
  1348 											OMX_BUFFERHEADERTYPE* apBuffer,
       
  1349 											TBool& aPortDepopulationCompleted)
       
  1350 	{
       
  1351     DEBUG_PRINTF(_L8("COmxILStateExecuting::FreeBuffer"));
       
  1352 
       
  1353 	return COmxILState::FreeBuffer(aFsm,
       
  1354 								   aPortIndex,
       
  1355 								   apBuffer,
       
  1356 								   aPortDepopulationCompleted);
       
  1357 
       
  1358 	}
       
  1359 
       
  1360 
       
  1361 OMX_ERRORTYPE
       
  1362 COmxILFsm::COmxILStateExecuting::EmptyThisBuffer(
       
  1363 	COmxILFsm& aFsm,
       
  1364 	OMX_BUFFERHEADERTYPE* apBuffer)
       
  1365 	{
       
  1366     DEBUG_PRINTF(_L8("COmxILStateExecuting::EmptyThisBuffer"));
       
  1367 
       
  1368 	return COmxILState::EmptyThisBufferV2(aFsm,
       
  1369 										  apBuffer);
       
  1370 
       
  1371 	}
       
  1372 
       
  1373 
       
  1374 OMX_ERRORTYPE
       
  1375 COmxILFsm::COmxILStateExecuting::FillThisBuffer(COmxILFsm& aFsm,
       
  1376 												OMX_BUFFERHEADERTYPE* apBuffer)
       
  1377 	{
       
  1378     DEBUG_PRINTF(_L8("COmxILStateExecuting::FillThisBuffer"));
       
  1379 
       
  1380 	return COmxILState::FillThisBufferV2(aFsm,
       
  1381 										 apBuffer);
       
  1382 
       
  1383 	}
       
  1384 
       
  1385 
       
  1386 OMX_ERRORTYPE
       
  1387 COmxILFsm::COmxILStateExecuting::ComponentTunnelRequest(
       
  1388 	COmxILFsm& aFsm,
       
  1389 	OMX_U32 aPort,
       
  1390 	OMX_HANDLETYPE aTunneledComp,
       
  1391 	OMX_U32 aTunneledPort,
       
  1392 	OMX_TUNNELSETUPTYPE* apTunnelSetup)
       
  1393 	{
       
  1394     DEBUG_PRINTF(_L8("COmxILStateExecuting::ComponentTunnelRequest"));
       
  1395 
       
  1396 	return COmxILState::ComponentTunnelRequest(aFsm,
       
  1397 											   aPort,
       
  1398 											   aTunneledComp,
       
  1399 											   aTunneledPort,
       
  1400 											   apTunnelSetup);
       
  1401 
       
  1402 	}
       
  1403 
       
  1404 
       
  1405 OMX_ERRORTYPE
       
  1406 COmxILFsm::COmxILStateExecuting::CommandStateSet(
       
  1407 	COmxILFsm& aFsm,
       
  1408 	const TOmxILCommand& aCommand)
       
  1409 	{
       
  1410     DEBUG_PRINTF(_L8("COmxILStateExecuting::CommandStateSet"));
       
  1411 
       
  1412 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandStateSet,
       
  1413 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
  1414 
       
  1415 	COmxILFsm::TStateIndex nextState = COmxILFsm::EStateMax;
       
  1416 	switch(aCommand.iParam1)
       
  1417 		{
       
  1418 	case OMX_StateIdle:
       
  1419 		{
       
  1420 		nextState = COmxILFsm::ESubStateExecutingToIdle;
       
  1421 		}
       
  1422 		break;
       
  1423 	case OMX_StatePause:
       
  1424 		{
       
  1425 		nextState = COmxILFsm::EStatePause;
       
  1426 		}
       
  1427 		break;
       
  1428 	case OMX_StateExecuting:
       
  1429 		{
       
  1430 		return OMX_ErrorSameState;
       
  1431 		}
       
  1432 	case OMX_StateInvalid:
       
  1433 		{
       
  1434 		// Notify the IL client... ignore the ret value...
       
  1435 		aFsm.iCallbacks.TransitionCompleteNotification(OMX_StateInvalid);
       
  1436 		// Invalidate component
       
  1437 		return OMX_ErrorInvalidState;
       
  1438 		}
       
  1439 	default:
       
  1440 		{
       
  1441 		return OMX_ErrorIncorrectStateTransition;
       
  1442 		}
       
  1443 		};
       
  1444 
       
  1445 
       
  1446 	// Initial checks OK. The component is commanded to make a transition to
       
  1447 	// ESubStateExecutingToIdle substate or OMX_StatePause.
       
  1448 	OMX_ERRORTYPE omxRetValue = aFsm.FsmTransition(nextState);
       
  1449 	if (OMX_ErrorNone != omxRetValue)
       
  1450 		{
       
  1451 		return omxRetValue;
       
  1452 		}
       
  1453 
       
  1454 	if (COmxILFsm::ESubStateExecutingToIdle == nextState)
       
  1455 		{
       
  1456 		// Lets tell port manager since at this point it is mandated that all
       
  1457 		// buffers must be returned to their suppliers (IL Client and/or
       
  1458 		// tunnelled components).
       
  1459 		TBool allBuffersReturnedToSuppliers = EFalse;
       
  1460 		omxRetValue =
       
  1461 			aFsm.iPortManager.BufferFlushIndicationPauseOrExeToIdleCommand(
       
  1462 				allBuffersReturnedToSuppliers);
       
  1463 		if (OMX_ErrorNone != omxRetValue)
       
  1464 			{
       
  1465 			return omxRetValue;
       
  1466 			}
       
  1467 
       
  1468 		if (allBuffersReturnedToSuppliers)
       
  1469 			{
       
  1470 			// Complete here the transition to OMX_StateIdle
       
  1471 			omxRetValue = aFsm.FsmTransition(COmxILFsm::EStateIdle);
       
  1472 			if (OMX_ErrorNone == omxRetValue)
       
  1473 				{
       
  1474 				// Notify the IL client that port population has completed sucessfully
       
  1475 				omxRetValue = aFsm.iCallbacks.TransitionCompleteNotification(
       
  1476 					OMX_StateIdle);
       
  1477 				}
       
  1478 			}
       
  1479 
       
  1480 		}
       
  1481 	else
       
  1482 		{
       
  1483 		// Notify the IL client that the transition to OMX_StatePause has
       
  1484 		// completed sucessfully
       
  1485 		omxRetValue = aFsm.iCallbacks.TransitionCompleteNotification(
       
  1486 			OMX_StatePause);
       
  1487 
       
  1488 		}
       
  1489 
       
  1490 	return omxRetValue;
       
  1491 
       
  1492 	}
       
  1493 
       
  1494 
       
  1495 OMX_ERRORTYPE
       
  1496 COmxILFsm::COmxILStateExecuting::CommandPortEnable(
       
  1497 	COmxILFsm& aFsm,
       
  1498 	const TOmxILCommand& aCommand)
       
  1499 	{
       
  1500     DEBUG_PRINTF(_L8("COmxILStateExecuting::CommandPortEnable"));
       
  1501 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandPortEnable,
       
  1502 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
  1503 
       
  1504 	// In this state, the port allocation has finished for enabled
       
  1505 	// ports. However, a port is being enabled here. The port being enabled
       
  1506 	// must populate (if tunnel supplier) or be populated (if non-tunnel
       
  1507 	// supplier or IL Client communication)
       
  1508 	TBool indicationIsFinal = EFalse;
       
  1509 	OMX_ERRORTYPE omxRetValue =
       
  1510 		aFsm.iPortManager.PortEnableIndication(
       
  1511 			aCommand.iParam1,
       
  1512 			indicationIsFinal);
       
  1513 
       
  1514 	if (OMX_ErrorNone == omxRetValue)
       
  1515 		{
       
  1516 		// From section 3.2.2.6, "If the IL client enables a port while the
       
  1517 		// component is in any state other than OMX_StateLoaded or
       
  1518 		// OMX_WaitForResources, then that port shall allocate its buffers via
       
  1519 		// the same call sequence used on a transition from OMX_StateLoaded to
       
  1520 		// OMX_StateIdle. If the IL client enables while the component is in
       
  1521 		// the OMX_Executing state, then that port shall begin transferring
       
  1522 		// buffers"
       
  1523 
       
  1524 		// Lets tell port manager in case the port being enabled is a tunnel
       
  1525 		// supplier...
       
  1526 		TBool componentPopulationCompleted = EFalse;
       
  1527 		omxRetValue =
       
  1528 			aFsm.iPortManager.TunnellingBufferAllocation(
       
  1529 				componentPopulationCompleted, aCommand.iParam1);
       
  1530 
       
  1531 		// No need to use here componentPopulationCompleted. A port is being
       
  1532 		// enabled in OMX_StateExecuting. If the port is a supplier, after
       
  1533 		// being re-enabled it should start the buffer allocation phase,
       
  1534 		// regardless of the population state of other ports in the component.
       
  1535 		if (OMX_ErrorNone == omxRetValue)
       
  1536 			{
       
  1537 			// Fire up the tunnelled buffer exchange in the enabled port...
       
  1538 			omxRetValue = aFsm.iPortManager.InitiateTunnellingDataFlow(
       
  1539 				aCommand.iParam1);
       
  1540 			}
       
  1541 		}
       
  1542 
       
  1543 	return omxRetValue;
       
  1544 
       
  1545 	}
       
  1546 
       
  1547 
       
  1548 //
       
  1549 // MOmxILPauseOrExecutingToIdle
       
  1550 //
       
  1551 OMX_ERRORTYPE
       
  1552 COmxILFsm::MOmxILPauseOrExecutingToIdle::ReturnThisBuffer(
       
  1553 	COmxILFsm& aFsm,
       
  1554 	OMX_BUFFERHEADERTYPE* apBuffer,
       
  1555 	OMX_DIRTYPE aDirection)
       
  1556 	{
       
  1557     DEBUG_PRINTF(_L8("MOmxILPauseOrExecutingToIdle::ReturnThisBuffer"));
       
  1558 
       
  1559 	TBool allBuffersReturned = EFalse;
       
  1560 	OMX_ERRORTYPE omxRetValue =
       
  1561 		aFsm.iPortManager.BufferReturnIndication(
       
  1562 			apBuffer,
       
  1563 			aDirection,
       
  1564 			allBuffersReturned
       
  1565 			);
       
  1566 
       
  1567 	if (OMX_ErrorNone != omxRetValue)
       
  1568 		{
       
  1569 		return omxRetValue;
       
  1570 		}
       
  1571 
       
  1572 	if (allBuffersReturned &&
       
  1573 		aFsm.iPortManager.AllBuffersAtHome())
       
  1574 		{
       
  1575 		// Complete here the transition to OMX_StateIdle
       
  1576 		omxRetValue = aFsm.FsmTransition(COmxILFsm::EStateIdle);
       
  1577 		if (OMX_ErrorNone == omxRetValue)
       
  1578 			{
       
  1579 			// Notify the IL client that transition to Idle has completed
       
  1580 			// sucessfully
       
  1581 			omxRetValue = aFsm.iCallbacks.TransitionCompleteNotification(
       
  1582 				OMX_StateIdle);
       
  1583 			}
       
  1584 		}
       
  1585 
       
  1586 	return omxRetValue;
       
  1587 
       
  1588 	}
       
  1589 
       
  1590 
       
  1591 
       
  1592 //
       
  1593 // COmxILStateExecutingToIdle
       
  1594 //
       
  1595 OMX_ERRORTYPE
       
  1596 COmxILFsm::COmxILStateExecutingToIdle::EmptyThisBuffer(
       
  1597 	COmxILFsm& aFsm,
       
  1598 	OMX_BUFFERHEADERTYPE* apBuffer)
       
  1599 	{
       
  1600     DEBUG_PRINTF(_L8("COmxILStateExecutingToIdle::EmptyThisBuffer"));
       
  1601 
       
  1602 	return ReturnThisBuffer(aFsm,
       
  1603 							apBuffer,
       
  1604 							OMX_DirInput);
       
  1605 
       
  1606 	}
       
  1607 
       
  1608 
       
  1609 OMX_ERRORTYPE
       
  1610 COmxILFsm::COmxILStateExecutingToIdle::FillThisBuffer(
       
  1611 	COmxILFsm& aFsm,
       
  1612 	OMX_BUFFERHEADERTYPE* apBuffer)
       
  1613 	{
       
  1614     DEBUG_PRINTF(_L8("COmxILStateExecutingToIdle::FillThisBuffer"));
       
  1615 
       
  1616 	return ReturnThisBuffer(aFsm,
       
  1617 							apBuffer,
       
  1618 							OMX_DirOutput);
       
  1619 
       
  1620 	}
       
  1621 
       
  1622 
       
  1623 OMX_ERRORTYPE
       
  1624 COmxILFsm::COmxILStateExecutingToIdle::CommandStateSet(
       
  1625 	COmxILFsm& aFsm,
       
  1626 	const TOmxILCommand& aCommand)
       
  1627 	{
       
  1628     DEBUG_PRINTF(_L8("COmxILStateExecutingToIdle::CommandStateSet"));
       
  1629 
       
  1630 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandStateSet,
       
  1631 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
  1632 
       
  1633 	switch(aCommand.iParam1)
       
  1634 		{
       
  1635 	case OMX_StateExecuting:
       
  1636 		{
       
  1637 		// Here, return "same state" as the transition to OMX_StateIdle has
       
  1638 		// not completed yet.
       
  1639 		return OMX_ErrorSameState;
       
  1640 		}
       
  1641 	case OMX_StateInvalid:
       
  1642 		{
       
  1643 		// Notify the IL client... ignore the ret value...
       
  1644 		aFsm.iCallbacks.TransitionCompleteNotification(OMX_StateInvalid);
       
  1645 		// Invalidate component
       
  1646 		return OMX_ErrorInvalidState;
       
  1647 		}
       
  1648 	default:
       
  1649 		{
       
  1650 		return OMX_ErrorIncorrectStateTransition;
       
  1651 		}
       
  1652 		};
       
  1653 
       
  1654 	}
       
  1655 
       
  1656 
       
  1657 //
       
  1658 // COmxILStatePause
       
  1659 //
       
  1660 OMX_STATETYPE
       
  1661 COmxILFsm::COmxILStatePause::GetState() const
       
  1662 	{
       
  1663     DEBUG_PRINTF(_L8("COmxILStatePause::GetState"));
       
  1664 	return OMX_StatePause;
       
  1665 	}
       
  1666 
       
  1667 
       
  1668 OMX_ERRORTYPE
       
  1669 COmxILFsm::COmxILStatePause::SetParameter(
       
  1670 	COmxILFsm& aFsm,
       
  1671 	OMX_INDEXTYPE aParamIndex,
       
  1672 	const TAny* apComponentParameterStructure)
       
  1673 	{
       
  1674     DEBUG_PRINTF(_L8("COmxILStatePause::SetParameter"));
       
  1675 
       
  1676 	return COmxILState::SetParameter(aFsm,
       
  1677 									 aParamIndex,
       
  1678 									 apComponentParameterStructure);
       
  1679 
       
  1680 	}
       
  1681 
       
  1682 
       
  1683 OMX_ERRORTYPE
       
  1684 COmxILFsm::COmxILStatePause::PopulateBuffer(
       
  1685 	COmxILFsm& aFsm,
       
  1686 	OMX_BUFFERHEADERTYPE** appBufferHdr,
       
  1687 	OMX_U32 aPortIndex,
       
  1688 	OMX_PTR apAppPrivate,
       
  1689 	OMX_U32 aSizeBytes,
       
  1690 	OMX_U8* apBuffer,
       
  1691 	TBool& portPopulationCompleted)
       
  1692 	{
       
  1693     DEBUG_PRINTF(_L8("COmxILStatePause::PopulateBuffer"));
       
  1694 
       
  1695 	return COmxILState::PopulateBuffer(aFsm,
       
  1696 									   appBufferHdr,
       
  1697 									   aPortIndex,
       
  1698 									   apAppPrivate,
       
  1699 									   aSizeBytes,
       
  1700 									   apBuffer,
       
  1701 									   portPopulationCompleted);
       
  1702 
       
  1703 	}
       
  1704 
       
  1705 
       
  1706 OMX_ERRORTYPE
       
  1707 COmxILFsm::COmxILStatePause::FreeBuffer(COmxILFsm& aFsm,
       
  1708 										OMX_U32 aPortIndex,
       
  1709 										OMX_BUFFERHEADERTYPE* apBuffer,
       
  1710 										TBool& aPortDepopulationCompleted)
       
  1711 	{
       
  1712     DEBUG_PRINTF(_L8("COmxILStatePause::FreeBuffer"));
       
  1713 
       
  1714 	return COmxILState::FreeBuffer(aFsm,
       
  1715 								   aPortIndex,
       
  1716 								   apBuffer,
       
  1717 								   aPortDepopulationCompleted);
       
  1718 
       
  1719 	}
       
  1720 
       
  1721 
       
  1722 OMX_ERRORTYPE
       
  1723 COmxILFsm::COmxILStatePause::EmptyThisBuffer(
       
  1724 	COmxILFsm& aFsm,
       
  1725 	OMX_BUFFERHEADERTYPE* apBuffer)
       
  1726 	{
       
  1727     DEBUG_PRINTF(_L8("COmxILStatePause::EmptyThisBuffer"));
       
  1728 
       
  1729 	return COmxILState::EmptyThisBufferV2(aFsm,
       
  1730 										  apBuffer);
       
  1731 
       
  1732 	}
       
  1733 
       
  1734 OMX_ERRORTYPE
       
  1735 COmxILFsm::COmxILStatePause::FillThisBuffer(COmxILFsm& aFsm,
       
  1736 											OMX_BUFFERHEADERTYPE* apBuffer)
       
  1737 	{
       
  1738     DEBUG_PRINTF(_L8("COmxILStatePause::FillThisBuffer"));
       
  1739 
       
  1740 	return COmxILState::FillThisBufferV2(aFsm,
       
  1741 										 apBuffer);
       
  1742 
       
  1743 	}
       
  1744 
       
  1745 OMX_ERRORTYPE
       
  1746 COmxILFsm::COmxILStatePause::ComponentTunnelRequest(
       
  1747 	COmxILFsm& aFsm,
       
  1748 	OMX_U32 aPort,
       
  1749 	OMX_HANDLETYPE aTunneledComp,
       
  1750 	OMX_U32 aTunneledPort,
       
  1751 	OMX_TUNNELSETUPTYPE* apTunnelSetup)
       
  1752 	{
       
  1753     DEBUG_PRINTF(_L8("COmxILStatePause::ComponentTunnelRequest"));
       
  1754 
       
  1755 	return COmxILState::ComponentTunnelRequest(aFsm,
       
  1756 											   aPort,
       
  1757 											   aTunneledComp,
       
  1758 											   aTunneledPort,
       
  1759 											   apTunnelSetup);
       
  1760 
       
  1761 	}
       
  1762 
       
  1763 
       
  1764 OMX_ERRORTYPE
       
  1765 COmxILFsm::COmxILStatePause::CommandStateSet(
       
  1766 	COmxILFsm& aFsm,
       
  1767 	const TOmxILCommand& aCommand)
       
  1768 	{
       
  1769     DEBUG_PRINTF(_L8("COmxILStatePause::CommandStateSet"));
       
  1770 
       
  1771 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandStateSet,
       
  1772 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
  1773 
       
  1774 	COmxILFsm::TStateIndex nextState = COmxILFsm::EStateInvalid;
       
  1775 	switch(aCommand.iParam1)
       
  1776 		{
       
  1777 	case OMX_StateIdle:
       
  1778 		{
       
  1779 		nextState = COmxILFsm::ESubStatePauseToIdle;
       
  1780 		}
       
  1781 		break;
       
  1782 	case OMX_StateExecuting:
       
  1783 		{
       
  1784 		nextState = COmxILFsm::EStateExecuting;
       
  1785 		}
       
  1786 		break;
       
  1787 	case OMX_StatePause:
       
  1788 		{
       
  1789 		return OMX_ErrorSameState;
       
  1790 		}
       
  1791 	case OMX_StateInvalid:
       
  1792 		{
       
  1793 		// Notify the IL client... ignore the ret value...
       
  1794 		aFsm.iCallbacks.TransitionCompleteNotification(OMX_StateInvalid);
       
  1795 		// Invalidate component
       
  1796 		return OMX_ErrorInvalidState;
       
  1797 		}
       
  1798 	default:
       
  1799 		{
       
  1800 		return OMX_ErrorIncorrectStateTransition;
       
  1801 		}
       
  1802 		};
       
  1803 
       
  1804 	// Initial command checks OK. The component is commanded to make a
       
  1805 	// transition to ESubStatePauseToIdle substate or OMX_StateExecuting.
       
  1806 	// Commit transition to the valid state
       
  1807 	OMX_ERRORTYPE omxRetValue = aFsm.FsmTransition(nextState);
       
  1808 	if (OMX_ErrorNone != omxRetValue)
       
  1809 		{
       
  1810 		return omxRetValue;
       
  1811 		}
       
  1812 
       
  1813 	if (COmxILFsm::ESubStatePauseToIdle == nextState)
       
  1814 		{
       
  1815 		// Lets tell port manager since at this point it is mandated that all
       
  1816 		// buffers must be returned to their suppliers (IL Client and/or
       
  1817 		// tunnelled components).
       
  1818 		TBool allBuffersReturnedToSuppliers = EFalse;
       
  1819 		omxRetValue =
       
  1820 			aFsm.iPortManager.BufferFlushIndicationPauseOrExeToIdleCommand(
       
  1821 				allBuffersReturnedToSuppliers);
       
  1822 		if (OMX_ErrorNone != omxRetValue)
       
  1823 			{
       
  1824 			return omxRetValue;
       
  1825 			}
       
  1826 
       
  1827 		if (allBuffersReturnedToSuppliers)
       
  1828 			{
       
  1829 			// Complete here the transition to OMX_StateIdle
       
  1830 			omxRetValue = aFsm.FsmTransition(COmxILFsm::EStateIdle);
       
  1831 			if (OMX_ErrorNone == omxRetValue)
       
  1832 				{
       
  1833 				// Notify the IL client that port population has completed sucessfully
       
  1834 				aFsm.iCallbacks.TransitionCompleteNotification(
       
  1835 					OMX_StateIdle);
       
  1836 				}
       
  1837 			}
       
  1838 
       
  1839 		}
       
  1840 	else
       
  1841 		{
       
  1842 		// Notify the IL client that the transition to OMX_StateExecuting has
       
  1843 		// completed sucessfully
       
  1844 		omxRetValue = aFsm.iCallbacks.TransitionCompleteNotification(
       
  1845 			OMX_StateExecuting);
       
  1846 
       
  1847 		if (OMX_ErrorNone == omxRetValue)
       
  1848 			{
       
  1849 			// Fire up the tunnelled buffer exchange, if any tunnelled ports are
       
  1850 			// found in the component...
       
  1851 			omxRetValue = aFsm.iPortManager.InitiateTunnellingDataFlow();
       
  1852 			}
       
  1853 
       
  1854 		}
       
  1855 
       
  1856 	return omxRetValue;
       
  1857 
       
  1858 	}
       
  1859 
       
  1860 OMX_ERRORTYPE
       
  1861 COmxILFsm::COmxILStatePause::CommandPortEnable(
       
  1862 	COmxILFsm& aFsm,
       
  1863 	const TOmxILCommand& aCommand)
       
  1864 	{
       
  1865     DEBUG_PRINTF(_L8("COmxILStatePause::CommandPortEnable"));
       
  1866 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandPortEnable,
       
  1867 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
  1868 
       
  1869 	// In this state, the port allocation has finished for enabled
       
  1870 	// ports. However, a port is being enabled here. The port being enabled
       
  1871 	// must populate (if tunnel supplier) or be populated (if non-tunnel
       
  1872 	// supplier or IL Client communication)
       
  1873 	TBool indicationIsFinal = EFalse;
       
  1874 	OMX_ERRORTYPE omxRetValue = aFsm.iPortManager.PortEnableIndication(
       
  1875 		aCommand.iParam1,
       
  1876 		indicationIsFinal);
       
  1877 
       
  1878 	if (OMX_ErrorNone == omxRetValue)
       
  1879 		{
       
  1880 		// From section 3.2.2.6, "If the IL client enables a port while the
       
  1881 		// component is in any state other than OMX_StateLoaded or
       
  1882 		// OMX_WaitForResources, then that port shall allocate its buffers via
       
  1883 		// the same call sequence used on a transition from OMX_StateLoaded to
       
  1884 		// OMX_StateIdle."
       
  1885 
       
  1886 		// Lets tell port manager in case the port being enabled is a tunnel
       
  1887 		// supplier...
       
  1888 		TBool componentPopulationCompleted = EFalse;
       
  1889 		omxRetValue =
       
  1890 			aFsm.iPortManager.TunnellingBufferAllocation(
       
  1891 				componentPopulationCompleted, aCommand.iParam1);
       
  1892 
       
  1893 		}
       
  1894 
       
  1895 	return omxRetValue;
       
  1896 
       
  1897 	}
       
  1898 
       
  1899 
       
  1900 //
       
  1901 // COmxILStatePauseToIdle
       
  1902 //
       
  1903 OMX_ERRORTYPE
       
  1904 COmxILFsm::COmxILStatePauseToIdle::EmptyThisBuffer(
       
  1905 	COmxILFsm& aFsm,
       
  1906 	OMX_BUFFERHEADERTYPE* apBuffer)
       
  1907 	{
       
  1908     DEBUG_PRINTF(_L8("COmxILStatePauseToIdle::EmptyThisBuffer"));
       
  1909 
       
  1910 	return ReturnThisBuffer(aFsm,
       
  1911 							apBuffer,
       
  1912 							OMX_DirInput);
       
  1913 
       
  1914 	}
       
  1915 
       
  1916 
       
  1917 OMX_ERRORTYPE
       
  1918 COmxILFsm::COmxILStatePauseToIdle::FillThisBuffer(
       
  1919 	COmxILFsm& aFsm,
       
  1920 	OMX_BUFFERHEADERTYPE* apBuffer)
       
  1921 	{
       
  1922     DEBUG_PRINTF(_L8("COmxILStatePauseToIdle::FillThisBuffer"));
       
  1923 
       
  1924 	return ReturnThisBuffer(aFsm,
       
  1925 							apBuffer,
       
  1926 							OMX_DirOutput);
       
  1927 
       
  1928 	}
       
  1929 
       
  1930 
       
  1931 OMX_ERRORTYPE
       
  1932 COmxILFsm::COmxILStatePauseToIdle::CommandStateSet(
       
  1933 	COmxILFsm& aFsm,
       
  1934 	const TOmxILCommand& aCommand)
       
  1935 	{
       
  1936     DEBUG_PRINTF(_L8("COmxILStatePauseToIdle::CommandStateSet"));
       
  1937 
       
  1938 	__ASSERT_DEBUG(aCommand.iCommandType == OMX_CommandStateSet,
       
  1939 				   User::Panic(KOmxILFsmPanicCategory, 1));
       
  1940 
       
  1941 	switch(aCommand.iParam1)
       
  1942 		{
       
  1943 	case OMX_StatePause:
       
  1944 		{
       
  1945 		// Here, return "same state" as the transition to OMX_StateIdle has not
       
  1946 		// completed yet.
       
  1947 		return OMX_ErrorSameState;
       
  1948 		}
       
  1949 	case OMX_StateInvalid:
       
  1950 		{
       
  1951 		// Notify the IL client... ignore the ret value...
       
  1952 		aFsm.iCallbacks.TransitionCompleteNotification(OMX_StateInvalid);
       
  1953 		// Invalidate component
       
  1954 		return OMX_ErrorInvalidState;
       
  1955 		}
       
  1956 	default:
       
  1957 		{
       
  1958 		return OMX_ErrorIncorrectStateTransition;
       
  1959 		}
       
  1960 		};
       
  1961 
       
  1962 	}
       
  1963 
       
  1964