omxilcomp/omxilaudioemulator/pcmrenderer/src/omxilpcmrendererconfigmanager.cpp
changeset 1 e0d606d6e3b1
parent 0 58be5850fb6c
child 4 46e224560be8
equal deleted inserted replaced
0:58be5850fb6c 1:e0d606d6e3b1
     1 /*
       
     2 * Copyright (c) 2008-2009 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 <openmax/il/common/omxilutil.h>
       
    25 #include <openmax/il/extensions/omxilsymbianaudiopcmextensions.h>
       
    26 #include "log.h"
       
    27 #include "omxilpcmrendererconfigmanager.h"
       
    28 #include "omxilpcmrendererprocessingfunction.h"
       
    29 
       
    30 
       
    31 
       
    32 COmxILPcmRendererConfigManager*
       
    33 COmxILPcmRendererConfigManager::NewL(
       
    34 	COmxILPcmRendererProcessingFunction& aProcessingFunction,
       
    35 	const TDesC8& aComponentName,
       
    36 	const OMX_VERSIONTYPE& aComponentVersion,
       
    37 	const RPointerArray<TDesC8>& aComponentRoleList)
       
    38 	{
       
    39     DEBUG_PRINTF(_L8("COmxILPcmRendererConfigManager::NewL"));
       
    40 	ASSERT(aComponentName.Length() && aComponentRoleList.Count());
       
    41 
       
    42 	COmxILPcmRendererConfigManager* self = new (ELeave)COmxILPcmRendererConfigManager(aProcessingFunction);
       
    43 	CleanupStack::PushL(self);
       
    44 	self->ConstructL(aComponentName,
       
    45 					 aComponentVersion,
       
    46 					 aComponentRoleList);
       
    47 	CleanupStack::Pop(self);
       
    48 	return self;
       
    49 
       
    50 	}
       
    51 
       
    52 void
       
    53 COmxILPcmRendererConfigManager::ConstructL(const TDesC8& aComponentName,
       
    54 								const OMX_VERSIONTYPE& aComponentVersion,
       
    55 								const RPointerArray<TDesC8>& aComponentRoleList)
       
    56 	{
       
    57     DEBUG_PRINTF(_L8("COmxILPcmRendererConfigManager::ConstructL"));
       
    58 
       
    59 	COmxILConfigManager::ConstructL(aComponentName, aComponentVersion, aComponentRoleList);
       
    60 	
       
    61 	ManagedConfigIndexes().InsertInOrderL(OMX_SymbianIndexConfigAudioBytesPlayed);
       
    62 	}
       
    63 
       
    64 COmxILPcmRendererConfigManager::COmxILPcmRendererConfigManager(COmxILPcmRendererProcessingFunction& aProcessingFunction)
       
    65 	:iProcessingFunction(aProcessingFunction)
       
    66 	{
       
    67     DEBUG_PRINTF(_L8("COmxILPcmRendererConfigManager::COmxILPcmRendererConfigManager"));
       
    68 
       
    69 	}
       
    70 
       
    71 COmxILPcmRendererConfigManager::~COmxILPcmRendererConfigManager()
       
    72 	{
       
    73     DEBUG_PRINTF(_L8("COmxILPcmRendererConfigManager::~COmxILPcmRendererConfigManager"));
       
    74 
       
    75 	}
       
    76 
       
    77 OMX_ERRORTYPE
       
    78 COmxILPcmRendererConfigManager::GetConfig(OMX_INDEXTYPE aConfigIndex,
       
    79 							   TAny* apComponentConfigStructure) const
       
    80 	{
       
    81     DEBUG_PRINTF(_L8("COmxILPcmRendererConfigManager::GetConfig"));
       
    82 
       
    83 	TInt index = FindConfigIndex(aConfigIndex);
       
    84 	if (KErrNotFound == index)
       
    85 		{
       
    86 		return OMX_ErrorUnsupportedIndex;
       
    87 		}
       
    88 
       
    89 	OMX_ERRORTYPE omxRetValue = OMX_ErrorNone;
       
    90 	switch(aConfigIndex)
       
    91 		{
       
    92 	case OMX_SymbianIndexConfigAudioBytesPlayed:
       
    93 		{
       
    94 		if (OMX_ErrorNone !=
       
    95 			(omxRetValue =
       
    96 			 TOmxILUtil::CheckOmxStructSizeAndVersion(
       
    97 				 apComponentConfigStructure,
       
    98 				 sizeof(OMX_SYMBIAN_AUDIO_CONFIG_PCM_BYTESPLAYED))))
       
    99 			{
       
   100 			return omxRetValue;
       
   101 			}
       
   102 
       
   103 		OMX_SYMBIAN_AUDIO_CONFIG_PCM_BYTESPLAYED*
       
   104 			pPcmBytesPlayed
       
   105 			= static_cast<
       
   106 			OMX_SYMBIAN_AUDIO_CONFIG_PCM_BYTESPLAYED*>(
       
   107 				apComponentConfigStructure);
       
   108 			
       
   109 		pPcmBytesPlayed->nBytesPlayed = iProcessingFunction.GetBytesPlayed();
       
   110 		}
       
   111 		break;
       
   112 		
       
   113 	default:
       
   114 		{
       
   115 		omxRetValue = COmxILConfigManager::GetConfig(aConfigIndex, apComponentConfigStructure);
       
   116 		}
       
   117 		};
       
   118 
       
   119 	return omxRetValue;
       
   120 	}
       
   121 
       
   122 OMX_ERRORTYPE
       
   123 COmxILPcmRendererConfigManager::SetConfig(OMX_INDEXTYPE aConfigIndex,
       
   124 							   const TAny* apComponentConfigStructure)
       
   125 
       
   126 	{
       
   127     DEBUG_PRINTF(_L8("COmxILPcmRendererConfigManager::SetConfig"));
       
   128 
       
   129 	TInt index = FindConfigIndex(aConfigIndex);
       
   130 	if (KErrNotFound == index)
       
   131 		{
       
   132 		return OMX_ErrorUnsupportedIndex;
       
   133 		}
       
   134 
       
   135 	OMX_ERRORTYPE omxRetValue = OMX_ErrorNone;
       
   136 	switch(aConfigIndex)
       
   137 		{
       
   138 	case OMX_SymbianIndexConfigAudioBytesPlayed:
       
   139 		{
       
   140 		omxRetValue = OMX_ErrorUnsupportedSetting;
       
   141 		}
       
   142 		break;
       
   143 				
       
   144 	default:
       
   145 		{
       
   146 		omxRetValue = COmxILConfigManager::SetConfig(aConfigIndex, apComponentConfigStructure);
       
   147 		}
       
   148 		};
       
   149 
       
   150 	return omxRetValue;
       
   151 
       
   152 	}
       
   153 
       
   154 OMX_ERRORTYPE
       
   155 COmxILPcmRendererConfigManager::GetExtensionIndex(
       
   156 	OMX_STRING aParameterName,
       
   157 	OMX_INDEXTYPE* apIndexType) const
       
   158 	{
       
   159     DEBUG_PRINTF(_L8("COmxILPcmRendererConfigManager::GetExtensionIndex"));
       
   160 
       
   161 	TPtrC8 requestedParameterNamePtr(
       
   162 		const_cast<const TUint8*>(
       
   163 			reinterpret_cast<TUint8*>(aParameterName)));
       
   164 
       
   165 	TPtrC8 parameterNamePtr(
       
   166 		reinterpret_cast<const TUint8*>(sOmxSymbianPcmBytesPlayed));
       
   167 
       
   168 	if (requestedParameterNamePtr == parameterNamePtr)
       
   169 		{
       
   170 		*apIndexType =
       
   171 			static_cast<OMX_INDEXTYPE>(
       
   172 					OMX_SymbianIndexConfigAudioBytesPlayed);
       
   173 			
       
   174 		return OMX_ErrorNone;
       
   175 		}
       
   176 
       
   177 	*apIndexType = OMX_IndexMax;
       
   178 	return OMX_ErrorUnsupportedIndex;
       
   179 	}