os/mm/devsoundextensions/effects/RoomLevel/RoomLevelEffect/Src/RoomLevelBase.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsoundextensions/effects/RoomLevel/RoomLevelEffect/Src/RoomLevelBase.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,484 @@
     1.4 +/*
     1.5 +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:   Implementation of the RoomLevel effect class
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +
    1.24 +// INCLUDE FILES
    1.25 +
    1.26 +#ifdef _DEBUG
    1.27 +#include <e32svr.h>
    1.28 +#endif
    1.29 +
    1.30 +#include "RoomLevelProxy.h"
    1.31 +
    1.32 +#include <RoomLevelBase.h>
    1.33 +#include <CustomInterfaceUtility.h>
    1.34 +#include <DrmAudioSamplePlayer.h>
    1.35 +#include <mdaaudioinputstream.h>
    1.36 +#include <mdaaudiooutputstream.h>
    1.37 +#include <mdaaudiotoneplayer.h>
    1.38 +#include <mmf/server/sounddevice.h>
    1.39 +#include <videoplayer.h>
    1.40 +
    1.41 +#ifdef _DEBUG
    1.42 +#define DEBPRN0         RDebug::Printf( "%s", __PRETTY_FUNCTION__);
    1.43 +#define DEBPRN1(str)    RDebug::Printf( "%s %s", __PRETTY_FUNCTION__, str );
    1.44 +#else
    1.45 +#define DEBPRN0
    1.46 +#define DEBPRN1(str)
    1.47 +#endif
    1.48 +
    1.49 +// ============================ MEMBER FUNCTIONS ===============================
    1.50 +
    1.51 +// -----------------------------------------------------------------------------
    1.52 +// CRoomLevel::CRoomLevel
    1.53 +// C++ default constructor can NOT contain any code, that
    1.54 +// might leave.
    1.55 +// -----------------------------------------------------------------------------
    1.56 +//
    1.57 +EXPORT_C CRoomLevel::CRoomLevel()
    1.58 +    : 	iRoomLevelData(),
    1.59 +    	iDataPckgTo(iRoomLevelData)
    1.60 +    {
    1.61 +
    1.62 +    }
    1.63 +
    1.64 +
    1.65 +// -----------------------------------------------------------------------------
    1.66 +// CRoomLevel::~CRoomLevel
    1.67 +// Destructor
    1.68 +// -----------------------------------------------------------------------------
    1.69 +//
    1.70 +//
    1.71 +EXPORT_C CRoomLevel::~CRoomLevel()
    1.72 +    {
    1.73 +
    1.74 +    }
    1.75 +
    1.76 +
    1.77 +// -----------------------------------------------------------------------------
    1.78 +// CRoomLevel::NewL
    1.79 +// Static function for creating an instance of the RoomLevel object.
    1.80 +// -----------------------------------------------------------------------------
    1.81 +//
    1.82 +EXPORT_C CRoomLevel* CRoomLevel::NewL(
    1.83 +	CMdaAudioConvertUtility& aUtility, CEnvironmentalReverb& aReverb )
    1.84 +	{
    1.85 +
    1.86 +    DEBPRN0;
    1.87 +   	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
    1.88 +    CleanupStack::PushL(customInterface);
    1.89 +
    1.90 +	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
    1.91 +
    1.92 +	if ( !roomLevelProxy )
    1.93 +		{
    1.94 +		DEBPRN1("No Adaptation Support - leaving");
    1.95 +		User::Leave(KErrNotSupported);
    1.96 +		}
    1.97 +
    1.98 +	CleanupStack::Pop(customInterface);
    1.99 +
   1.100 +    roomLevelProxy->iClientReverb = &aReverb;
   1.101 +    roomLevelProxy->AttachReverb(aReverb);
   1.102 +
   1.103 +    return roomLevelProxy;
   1.104 +
   1.105 +	}
   1.106 +
   1.107 +// -----------------------------------------------------------------------------
   1.108 +// CRoomLevel::NewL
   1.109 +// Static function for creating an instance of the RoomLevel object.
   1.110 +// -----------------------------------------------------------------------------
   1.111 +//
   1.112 +EXPORT_C CRoomLevel* CRoomLevel::NewL(
   1.113 +	CMdaAudioInputStream& aUtility, CEnvironmentalReverb& aReverb )
   1.114 +	{
   1.115 +
   1.116 +    DEBPRN0;
   1.117 +    CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aUtility.CustomInterface(KUidRoomLevelEffect);
   1.118 +
   1.119 +	if (roomLevelProxy == NULL)
   1.120 +		{
   1.121 +        DEBPRN1("No Adaptation Support - leaving");
   1.122 +    	User::Leave(KErrNotSupported);
   1.123 +		}
   1.124 +
   1.125 +	roomLevelProxy->iClientReverb = &aReverb;
   1.126 +    roomLevelProxy->AttachReverb(aReverb);
   1.127 +
   1.128 +    return roomLevelProxy;
   1.129 +	}
   1.130 +
   1.131 +// -----------------------------------------------------------------------------
   1.132 +// CRoomLevel::NewL
   1.133 +// Static function for creating an instance of the RoomLevel object.
   1.134 +// -----------------------------------------------------------------------------
   1.135 +//
   1.136 +EXPORT_C CRoomLevel* CRoomLevel::NewL(
   1.137 +	CMdaAudioOutputStream& aUtility, CEnvironmentalReverb& aReverb )
   1.138 +	{
   1.139 +
   1.140 +    DEBPRN0;
   1.141 +    CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aUtility.CustomInterface(KUidRoomLevelEffect);
   1.142 +
   1.143 +	if (roomLevelProxy == NULL)
   1.144 +		{
   1.145 +        DEBPRN1("No Adaptation Support - leaving");
   1.146 +    	User::Leave(KErrNotSupported);
   1.147 +		}
   1.148 +
   1.149 +	roomLevelProxy->iClientReverb = &aReverb;
   1.150 +    roomLevelProxy->AttachReverb(aReverb);
   1.151 +
   1.152 +    return roomLevelProxy;
   1.153 +	}
   1.154 +
   1.155 +// -----------------------------------------------------------------------------
   1.156 +// CRoomLevel::NewL
   1.157 +// Static function for creating an instance of the RoomLevel object.
   1.158 +// -----------------------------------------------------------------------------
   1.159 +//
   1.160 +EXPORT_C CRoomLevel* CRoomLevel::NewL(
   1.161 +	CMdaAudioPlayerUtility& aUtility, CEnvironmentalReverb& aReverb )
   1.162 +	{
   1.163 +
   1.164 +    DEBPRN0;
   1.165 +   	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
   1.166 +    CleanupStack::PushL(customInterface);
   1.167 +
   1.168 +	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
   1.169 +
   1.170 +	if ( !roomLevelProxy )
   1.171 +		{
   1.172 +		DEBPRN1("No Adaptation Support - leaving");
   1.173 +		User::Leave(KErrNotSupported);
   1.174 +		}
   1.175 +
   1.176 +	CleanupStack::Pop(customInterface);
   1.177 +
   1.178 +
   1.179 +    roomLevelProxy->iClientReverb = &aReverb;
   1.180 +    roomLevelProxy->AttachReverb(aReverb);
   1.181 +
   1.182 +    return roomLevelProxy;
   1.183 +	}
   1.184 +
   1.185 +// -----------------------------------------------------------------------------
   1.186 +// CRoomLevel::NewL
   1.187 +// Static function for creating an instance of the RoomLevel object.
   1.188 +// -----------------------------------------------------------------------------
   1.189 +//
   1.190 +EXPORT_C CRoomLevel* CRoomLevel::NewL(
   1.191 +	CMdaAudioRecorderUtility& aUtility,
   1.192 +	TBool aRecordStream, CEnvironmentalReverb& aReverb )
   1.193 +	{
   1.194 +
   1.195 +    DEBPRN0;
   1.196 +   	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility, aRecordStream);
   1.197 +    CleanupStack::PushL(customInterface);
   1.198 +
   1.199 +	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
   1.200 +
   1.201 +	if ( !roomLevelProxy )
   1.202 +		{
   1.203 +		DEBPRN1("No Adaptation Support - leaving");
   1.204 +		User::Leave(KErrNotSupported);
   1.205 +		}
   1.206 +
   1.207 +	CleanupStack::Pop(customInterface);
   1.208 +
   1.209 +    roomLevelProxy->iClientReverb = &aReverb;
   1.210 +    roomLevelProxy->AttachReverb(aReverb);
   1.211 +
   1.212 +    return roomLevelProxy;
   1.213 +	}
   1.214 +
   1.215 +// -----------------------------------------------------------------------------
   1.216 +// CRoomLevel::NewL
   1.217 +// Static function for creating an instance of the RoomLevel object.
   1.218 +// -----------------------------------------------------------------------------
   1.219 +//
   1.220 +EXPORT_C CRoomLevel* CRoomLevel::NewL(
   1.221 +	CMdaAudioToneUtility& aUtility, CEnvironmentalReverb& aReverb )
   1.222 +	{
   1.223 +
   1.224 +	DEBPRN0;
   1.225 +    CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aUtility.CustomInterface(KUidRoomLevelEffect);
   1.226 +
   1.227 +	if (roomLevelProxy == NULL)
   1.228 +		{
   1.229 +        DEBPRN1("No Adaptation Support - leaving");
   1.230 +    	User::Leave(KErrNotSupported);
   1.231 +		}
   1.232 +
   1.233 +	roomLevelProxy->iClientReverb = &aReverb;
   1.234 +    roomLevelProxy->AttachReverb(aReverb);
   1.235 +
   1.236 +    return roomLevelProxy;
   1.237 +	}
   1.238 +
   1.239 +// -----------------------------------------------------------------------------
   1.240 +// CAudioEqualizer::NewL
   1.241 +// Static function for creating an instance of the RoomLevel object.
   1.242 +// -----------------------------------------------------------------------------
   1.243 +//
   1.244 +EXPORT_C CRoomLevel* CRoomLevel::NewL(
   1.245 +	CMMFDevSound& aDevSound, CEnvironmentalReverb& aReverb )
   1.246 +	{
   1.247 +
   1.248 +	DEBPRN0;
   1.249 +    CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aDevSound.CustomInterface(KUidRoomLevelEffect);
   1.250 +
   1.251 +	if (roomLevelProxy == NULL)
   1.252 +		{
   1.253 +        DEBPRN1("No Adaptation Support - leaving");
   1.254 +    	User::Leave(KErrNotSupported);
   1.255 +		}
   1.256 +
   1.257 +	roomLevelProxy->iClientReverb = &aReverb;
   1.258 +    roomLevelProxy->AttachReverb(aReverb);
   1.259 +
   1.260 +    return roomLevelProxy;
   1.261 +	}
   1.262 +
   1.263 +// -----------------------------------------------------------------------------
   1.264 +// CRoomLevel::NewL
   1.265 +// Static function for creating an instance of the RoomLevel object.
   1.266 +// -----------------------------------------------------------------------------
   1.267 +//
   1.268 +EXPORT_C CRoomLevel* CRoomLevel::NewL(
   1.269 +	CCustomCommandUtility* aUtility, CEnvironmentalReverb& aReverb )
   1.270 +	{
   1.271 +
   1.272 +    DEBPRN0;
   1.273 +   	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
   1.274 +    CleanupStack::PushL(customInterface);
   1.275 +
   1.276 +	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
   1.277 +
   1.278 +	if ( !roomLevelProxy )
   1.279 +		{
   1.280 +		DEBPRN1("No Adaptation Support - leaving");
   1.281 +		User::Leave(KErrNotSupported);
   1.282 +		}
   1.283 +
   1.284 + 	CleanupStack::Pop(customInterface);
   1.285 +
   1.286 +    roomLevelProxy->iClientReverb = &aReverb;
   1.287 +    roomLevelProxy->AttachReverb(aReverb);
   1.288 +
   1.289 +    return roomLevelProxy;
   1.290 +	}
   1.291 +
   1.292 +// -----------------------------------------------------------------------------
   1.293 +// CRoomLevel::NewL
   1.294 +// Static function for creating an instance of the RoomLevel object.
   1.295 +// -----------------------------------------------------------------------------
   1.296 +//
   1.297 +EXPORT_C CRoomLevel* CRoomLevel::NewL(
   1.298 +	MCustomInterface& aCustomInterface, CEnvironmentalReverb& aReverb )
   1.299 +	{
   1.300 +
   1.301 +    DEBPRN0;
   1.302 +	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aCustomInterface.CustomInterface(KUidRoomLevelEffect);
   1.303 +	if ( !roomLevelProxy )
   1.304 +		{
   1.305 +		DEBPRN1("No Adaptation Support - leaving");
   1.306 +		User::Leave(KErrNotSupported);
   1.307 +		}
   1.308 +
   1.309 +    roomLevelProxy->iClientReverb = &aReverb;
   1.310 +
   1.311 +    roomLevelProxy->AttachReverb(aReverb);
   1.312 +
   1.313 +    return roomLevelProxy;
   1.314 +	}
   1.315 +
   1.316 +// -----------------------------------------------------------------------------
   1.317 +// CRoomLevel::NewL
   1.318 +// Static function for creating an instance of the RoomLevel object.
   1.319 +// -----------------------------------------------------------------------------
   1.320 +//
   1.321 +EXPORT_C CRoomLevel* CRoomLevel::NewL(
   1.322 +    CMidiClientUtility& aUtility, CEnvironmentalReverb& aReverb)
   1.323 +	{
   1.324 +
   1.325 +    DEBPRN0;
   1.326 +   	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
   1.327 +    CleanupStack::PushL(customInterface);
   1.328 +
   1.329 +	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
   1.330 +
   1.331 +	if ( !roomLevelProxy )
   1.332 +		{
   1.333 +		DEBPRN1("No Adaptation Support - leaving");
   1.334 +		User::Leave(KErrNotSupported);
   1.335 +		}
   1.336 +
   1.337 +	CleanupStack::Pop(customInterface);
   1.338 +
   1.339 +    roomLevelProxy->iClientReverb = &aReverb;
   1.340 +
   1.341 +    roomLevelProxy->AttachReverb(aReverb);
   1.342 +
   1.343 +    return roomLevelProxy;
   1.344 +	}
   1.345 +
   1.346 +// -----------------------------------------------------------------------------
   1.347 +// CRoomLevel::NewL
   1.348 +// Static function for creating an instance of the RoomLevel object.
   1.349 +// -----------------------------------------------------------------------------
   1.350 +//
   1.351 +EXPORT_C CRoomLevel* CRoomLevel::NewL(
   1.352 +    CDrmPlayerUtility& aUtility, CEnvironmentalReverb& aReverb)
   1.353 +	{
   1.354 +
   1.355 +    DEBPRN0;
   1.356 +   	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
   1.357 +    CleanupStack::PushL(customInterface);
   1.358 +
   1.359 +	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
   1.360 +
   1.361 +	if ( !roomLevelProxy )
   1.362 +		{
   1.363 +		DEBPRN1("No Adaptation Support - leaving");
   1.364 +		User::Leave(KErrNotSupported);
   1.365 +		}
   1.366 +
   1.367 +	CleanupStack::Pop(customInterface);
   1.368 +
   1.369 +    roomLevelProxy->iClientReverb = &aReverb;
   1.370 +
   1.371 +    roomLevelProxy->AttachReverb(aReverb);
   1.372 +
   1.373 +    return roomLevelProxy;
   1.374 +	}
   1.375 +
   1.376 +// -----------------------------------------------------------------------------
   1.377 +// CRoomLevel::NewL
   1.378 +// Static function for creating an instance of the RoomLevel object.
   1.379 +// -----------------------------------------------------------------------------
   1.380 +//
   1.381 +EXPORT_C CRoomLevel* CRoomLevel::NewL(
   1.382 +    CVideoPlayerUtility& aUtility, CEnvironmentalReverb& aReverb)
   1.383 +	{
   1.384 +
   1.385 +    DEBPRN0;
   1.386 +   	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
   1.387 +    CleanupStack::PushL(customInterface);
   1.388 +
   1.389 +	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
   1.390 +
   1.391 +	if ( !roomLevelProxy )
   1.392 +		{
   1.393 +		DEBPRN1("No Adaptation Support - leaving");
   1.394 +		User::Leave(KErrNotSupported);
   1.395 +		}
   1.396 +
   1.397 +	CleanupStack::Pop(customInterface);
   1.398 +
   1.399 +    roomLevelProxy->iClientReverb = &aReverb;
   1.400 +
   1.401 +    roomLevelProxy->AttachReverb(aReverb);
   1.402 +
   1.403 +    return roomLevelProxy;
   1.404 +	}
   1.405 +
   1.406 +// -----------------------------------------------------------------------------
   1.407 +// CRoomLevel::RoomLevel
   1.408 +// -----------------------------------------------------------------------------
   1.409 +//
   1.410 +EXPORT_C TInt32 CRoomLevel::Level() const
   1.411 +	{
   1.412 +	return iRoomLevelData.iStreamRoomLevel;
   1.413 +	}
   1.414 +
   1.415 +// -----------------------------------------------------------------------------
   1.416 +// CRoomLevel::RoomLevelLevelRange
   1.417 +// -----------------------------------------------------------------------------
   1.418 +//
   1.419 +EXPORT_C void CRoomLevel::LevelRange(
   1.420 +	TInt32& aMin,
   1.421 +	TInt32& aMax)
   1.422 +	{
   1.423 +
   1.424 +	aMin = iRoomLevelData.iStreamMinRoomLevel;
   1.425 +	aMax = iRoomLevelData.iStreamMaxRoomLevel;
   1.426 +	}
   1.427 +
   1.428 +
   1.429 +// -----------------------------------------------------------------------------
   1.430 +// CRoomLevel::SetRoomLevelL
   1.431 +// -----------------------------------------------------------------------------
   1.432 +//
   1.433 +EXPORT_C void CRoomLevel::SetRoomLevelL(
   1.434 +	TInt32 aRoomLevel )
   1.435 +	{
   1.436 +	if ( (aRoomLevel >= iRoomLevelData.iStreamMinRoomLevel) && (aRoomLevel <= iRoomLevelData.iStreamMaxRoomLevel) )
   1.437 +		{
   1.438 +		iRoomLevelData.iStreamRoomLevel = aRoomLevel;
   1.439 +		}
   1.440 +	else
   1.441 +		{
   1.442 +		User::Leave(KErrArgument);
   1.443 +		}
   1.444 +	}
   1.445 +
   1.446 +
   1.447 +// -----------------------------------------------------------------------------
   1.448 +// CRoomLevel::Uid
   1.449 +// -----------------------------------------------------------------------------
   1.450 +//
   1.451 +EXPORT_C TUid CRoomLevel::Uid() const
   1.452 +	{
   1.453 +	return KUidRoomLevelEffect;
   1.454 +	}
   1.455 +
   1.456 +
   1.457 +// -----------------------------------------------------------------------------
   1.458 +// CRoomLevel::DoEffectData
   1.459 +// -----------------------------------------------------------------------------
   1.460 +//
   1.461 +EXPORT_C const TDesC8& CRoomLevel::DoEffectData()
   1.462 +	{
   1.463 +    DEBPRN0;
   1.464 +	iDataPckgTo = iRoomLevelData;
   1.465 +	return iDataPckgTo;
   1.466 +	}
   1.467 +
   1.468 +// -----------------------------------------------------------------------------
   1.469 +// CRoomLevel::SetEffectData
   1.470 +// -----------------------------------------------------------------------------
   1.471 +//
   1.472 +EXPORT_C void CRoomLevel::SetEffectData(
   1.473 +	const TDesC8& aEffectDataBuffer )
   1.474 +	{
   1.475 +    DEBPRN0;
   1.476 +	TEfRoomLevelDataPckg dataPckg;
   1.477 +	dataPckg.Copy(aEffectDataBuffer);
   1.478 +	iRoomLevelData = dataPckg();
   1.479 +	iEnabled = iRoomLevelData.iEnabled;
   1.480 +	iEnforced = iRoomLevelData.iEnforced;
   1.481 +	iHaveUpdateRights = iRoomLevelData.iHaveUpdateRights;
   1.482 +	}
   1.483 +
   1.484 +
   1.485 +// ========================== OTHER EXPORTED FUNCTIONS =========================
   1.486 +
   1.487 +