os/mm/devsoundextensions/effects/StereoWidening/StereoWideningEffect/Src/StereoWideningBase.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsoundextensions/effects/StereoWidening/StereoWideningEffect/Src/StereoWideningBase.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,519 @@
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 StereoWidening 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 <StereoWideningData.h>
1.31 +#include <StereoWideningBase.h>
1.32 +#include <CustomInterfaceUtility.h>
1.33 +#include "StereoWideningProxy.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 +// CStereoWidening::CStereoWidening
1.53 +// C++ default constructor can NOT contain any code, that
1.54 +// might leave.
1.55 +// -----------------------------------------------------------------------------
1.56 +//
1.57 +EXPORT_C CStereoWidening::CStereoWidening()
1.58 + : iStereoWideningData(0, 0),
1.59 + iDataPckgTo(iStereoWideningData)
1.60 + {
1.61 + }
1.62 +
1.63 +// Destructor
1.64 +EXPORT_C CStereoWidening::~CStereoWidening()
1.65 + {
1.66 + }
1.67 +
1.68 +// -----------------------------------------------------------------------------
1.69 +// CStereoWidening::NewL
1.70 +// Static function for creating an instance of the StereoWidening object.
1.71 +// -----------------------------------------------------------------------------
1.72 +//
1.73 +EXPORT_C CStereoWidening* CStereoWidening::NewL()
1.74 + {
1.75 + User::Leave(KErrNotSupported);
1.76 + return NULL;
1.77 + }
1.78 +
1.79 +// -----------------------------------------------------------------------------
1.80 +// CStereoWidening::NewL
1.81 +// Static function for creating an instance of the StereoWidening object.
1.82 +// -----------------------------------------------------------------------------
1.83 +//
1.84 +EXPORT_C CStereoWidening* CStereoWidening::NewL(CMdaAudioConvertUtility& aUtility , TBool aEnable, TInt8 aInitialLevel)
1.85 + {
1.86 +
1.87 + DEBPRN0;
1.88 + CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
1.89 + CleanupStack::PushL(customInterface);
1.90 +
1.91 + CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
1.92 +
1.93 + if ( !stereoWideningProxy )
1.94 + {
1.95 + DEBPRN1("No Adaptation Support - leaving");
1.96 + User::Leave(KErrNotSupported);
1.97 + }
1.98 +
1.99 + CleanupStack::Pop(customInterface);
1.100 +
1.101 + stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
1.102 +
1.103 + if(aEnable)
1.104 + {
1.105 + stereoWideningProxy->EnableL();
1.106 + }
1.107 +
1.108 + return stereoWideningProxy;
1.109 + }
1.110 +
1.111 +// -----------------------------------------------------------------------------
1.112 +// CStereoWidening::NewL
1.113 +// Static function for creating an instance of the StereoWidening object.
1.114 +// -----------------------------------------------------------------------------
1.115 +//
1.116 +EXPORT_C CStereoWidening* CStereoWidening::NewL(
1.117 + CMdaAudioInputStream& aUtility, TBool aEnable, TInt8 aInitialLevel )
1.118 + {
1.119 +
1.120 + DEBPRN0;
1.121 + CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aUtility.CustomInterface(KUidStereoWideningEffect);
1.122 +
1.123 + if (stereoWideningProxy == NULL)
1.124 + {
1.125 + DEBPRN1("No Adaptation Support - leaving");
1.126 + User::Leave(KErrNotSupported);
1.127 + }
1.128 +
1.129 + stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
1.130 +
1.131 + if(aEnable)
1.132 + {
1.133 + stereoWideningProxy->EnableL();
1.134 + }
1.135 +
1.136 + return stereoWideningProxy;
1.137 + }
1.138 +
1.139 +// -----------------------------------------------------------------------------
1.140 +// CStereoWidening::NewL
1.141 +// Static function for creating an instance of the StereoWidening object.
1.142 +// -----------------------------------------------------------------------------
1.143 +//
1.144 +EXPORT_C CStereoWidening* CStereoWidening::NewL(
1.145 + CMdaAudioOutputStream& aUtility, TBool aEnable, TInt8 aInitialLevel )
1.146 + {
1.147 +
1.148 + DEBPRN0;
1.149 + CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aUtility.CustomInterface(KUidStereoWideningEffect);
1.150 +
1.151 + if (stereoWideningProxy == NULL)
1.152 + {
1.153 + DEBPRN1("No Adaptation Support - leaving");
1.154 + User::Leave(KErrNotSupported);
1.155 + }
1.156 +
1.157 + stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
1.158 +
1.159 + if(aEnable)
1.160 + {
1.161 + stereoWideningProxy->EnableL();
1.162 + }
1.163 +
1.164 + return stereoWideningProxy;
1.165 + }
1.166 +
1.167 +// -----------------------------------------------------------------------------
1.168 +// CStereoWidening::NewL
1.169 +// Static function for creating an instance of the StereoWidening object.
1.170 +// -----------------------------------------------------------------------------
1.171 +//
1.172 +EXPORT_C CStereoWidening* CStereoWidening::NewL(
1.173 + CMdaAudioPlayerUtility& aUtility , TBool aEnable, TInt8 aInitialLevel)
1.174 + {
1.175 +
1.176 + DEBPRN0;
1.177 + CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
1.178 + CleanupStack::PushL(customInterface);
1.179 +
1.180 + CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
1.181 +
1.182 + if ( !stereoWideningProxy )
1.183 + {
1.184 + DEBPRN1("No Adaptation Support - leaving");
1.185 + User::Leave(KErrNotSupported);
1.186 + }
1.187 +
1.188 + CleanupStack::Pop(customInterface);
1.189 +
1.190 + stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
1.191 +
1.192 + if(aEnable)
1.193 + {
1.194 + stereoWideningProxy->EnableL();
1.195 + }
1.196 +
1.197 + return stereoWideningProxy;
1.198 + }
1.199 +
1.200 +// -----------------------------------------------------------------------------
1.201 +// CStereoWidening::NewL
1.202 +// Static function for creating an instance of the StereoWidening object.
1.203 +// -----------------------------------------------------------------------------
1.204 +//
1.205 +EXPORT_C CStereoWidening* CStereoWidening::NewL(
1.206 + CMdaAudioRecorderUtility& aUtility,
1.207 + TBool aRecordStream, TBool aEnable, TInt8 aInitialLevel)
1.208 + {
1.209 +
1.210 + DEBPRN0;
1.211 + CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility, aRecordStream);
1.212 + CleanupStack::PushL(customInterface);
1.213 +
1.214 + CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
1.215 +
1.216 + if ( !stereoWideningProxy )
1.217 + {
1.218 + DEBPRN1("No Adaptation Support - leaving");
1.219 + User::Leave(KErrNotSupported);
1.220 + }
1.221 +
1.222 + CleanupStack::Pop(customInterface);
1.223 +
1.224 + stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
1.225 +
1.226 + if(aEnable)
1.227 + {
1.228 + stereoWideningProxy->EnableL();
1.229 + }
1.230 +
1.231 + return stereoWideningProxy;
1.232 + }
1.233 +
1.234 +// -----------------------------------------------------------------------------
1.235 +// CStereoWidening::NewL
1.236 +// Static function for creating an instance of the StereoWidening object.
1.237 +// -----------------------------------------------------------------------------
1.238 +//
1.239 +EXPORT_C CStereoWidening* CStereoWidening::NewL(
1.240 + CMdaAudioToneUtility& aUtility, TBool aEnable, TInt8 aInitialLevel)
1.241 + {
1.242 +
1.243 + DEBPRN0;
1.244 + CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aUtility.CustomInterface(KUidStereoWideningEffect);
1.245 +
1.246 + if (stereoWideningProxy == NULL)
1.247 + {
1.248 + DEBPRN1("No Adaptation Support - leaving");
1.249 + User::Leave(KErrNotSupported);
1.250 + }
1.251 +
1.252 + stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
1.253 +
1.254 + if(aEnable)
1.255 + {
1.256 + stereoWideningProxy->EnableL();
1.257 + }
1.258 +
1.259 + return stereoWideningProxy;
1.260 + }
1.261 +
1.262 +
1.263 +// -----------------------------------------------------------------------------
1.264 +// CStereoWidening::NewL
1.265 +// Static function for creating an instance of the StereoWidening object.
1.266 +// -----------------------------------------------------------------------------
1.267 +//
1.268 +EXPORT_C CStereoWidening* CStereoWidening::NewL(
1.269 + CMMFDevSound& aDevSound, TBool aEnable, TInt8 aInitialLevel)
1.270 + {
1.271 +
1.272 + DEBPRN0;
1.273 + CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aDevSound.CustomInterface(KUidStereoWideningEffect);
1.274 +
1.275 + if (stereoWideningProxy == NULL)
1.276 + {
1.277 + DEBPRN1("No Adaptation Support - leaving");
1.278 + User::Leave(KErrNotSupported);
1.279 + }
1.280 +
1.281 + stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
1.282 +
1.283 + if(aEnable)
1.284 + {
1.285 + stereoWideningProxy->EnableL();
1.286 + }
1.287 +
1.288 + return stereoWideningProxy;
1.289 + }
1.290 +
1.291 +
1.292 +
1.293 +// -----------------------------------------------------------------------------
1.294 +// CStereoWidening::NewL
1.295 +// Static function for creating an instance of the StereoWidening object.
1.296 +// -----------------------------------------------------------------------------
1.297 +//
1.298 +EXPORT_C CStereoWidening* CStereoWidening::NewL(
1.299 + CCustomCommandUtility* aUtility , TBool aEnable, TInt8 aInitialLevel)
1.300 + {
1.301 +
1.302 + DEBPRN0;
1.303 + CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
1.304 + CleanupStack::PushL(customInterface);
1.305 +
1.306 + CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
1.307 +
1.308 + if ( !stereoWideningProxy )
1.309 + {
1.310 + DEBPRN1("No Adaptation Support - leaving");
1.311 + User::Leave(KErrNotSupported);
1.312 + }
1.313 +
1.314 + CleanupStack::Pop(customInterface);
1.315 +
1.316 + stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
1.317 +
1.318 + if(aEnable)
1.319 + {
1.320 + stereoWideningProxy->EnableL();
1.321 + }
1.322 +
1.323 + return stereoWideningProxy;
1.324 + }
1.325 +
1.326 +// -----------------------------------------------------------------------------
1.327 +// CStereoWidening::NewL
1.328 +// Static function for creating an instance of the StereoWidening object.
1.329 +// -----------------------------------------------------------------------------
1.330 +//
1.331 +EXPORT_C CStereoWidening* CStereoWidening::NewL(
1.332 + MCustomInterface& aCustomInterface , TBool aEnable, TInt8 aInitialLevel)
1.333 + {
1.334 +
1.335 + DEBPRN0;
1.336 + CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aCustomInterface.CustomInterface(KUidStereoWideningEffect);
1.337 +
1.338 + if ( !stereoWideningProxy )
1.339 + {
1.340 + DEBPRN1("No Adaptation Support - leaving");
1.341 + User::Leave(KErrNotSupported);
1.342 + }
1.343 +
1.344 + stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
1.345 +
1.346 + if(aEnable)
1.347 + {
1.348 + stereoWideningProxy->EnableL();
1.349 + }
1.350 +
1.351 + return stereoWideningProxy;
1.352 + }
1.353 +
1.354 +// -----------------------------------------------------------------------------
1.355 +// CStereoWidening::NewL
1.356 +// Static function for creating an instance of the StereoWidening object.
1.357 +// -----------------------------------------------------------------------------
1.358 +//
1.359 +EXPORT_C CStereoWidening* CStereoWidening::NewL(
1.360 + CMidiClientUtility& aUtility , TBool aEnable, TInt8 aInitialLevel )
1.361 + {
1.362 +
1.363 + DEBPRN0;
1.364 + CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
1.365 + CleanupStack::PushL(customInterface);
1.366 +
1.367 + CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
1.368 +
1.369 + if ( !stereoWideningProxy )
1.370 + {
1.371 + DEBPRN1("No Adaptation Support - leaving");
1.372 + User::Leave(KErrNotSupported);
1.373 + }
1.374 +
1.375 + CleanupStack::Pop(customInterface);
1.376 +
1.377 + stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
1.378 +
1.379 + if(aEnable)
1.380 + {
1.381 + stereoWideningProxy->EnableL();
1.382 + }
1.383 +
1.384 + return stereoWideningProxy;
1.385 + }
1.386 +
1.387 +// -----------------------------------------------------------------------------
1.388 +// CStereoWidening::NewL
1.389 +// Static function for creating an instance of the StereoWidening object.
1.390 +// -----------------------------------------------------------------------------
1.391 +//
1.392 +EXPORT_C CStereoWidening* CStereoWidening::NewL(
1.393 + CDrmPlayerUtility& aUtility , TBool aEnable, TInt8 aInitialLevel )
1.394 + {
1.395 + DEBPRN0;
1.396 + CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
1.397 + CleanupStack::PushL(customInterface);
1.398 +
1.399 + CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
1.400 +
1.401 + if ( !stereoWideningProxy )
1.402 + {
1.403 + DEBPRN1("No Adaptation Support - leaving");
1.404 + User::Leave(KErrNotSupported);
1.405 + }
1.406 +
1.407 + CleanupStack::Pop(customInterface);
1.408 +
1.409 + stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
1.410 +
1.411 + if(aEnable)
1.412 + {
1.413 + stereoWideningProxy->EnableL();
1.414 + }
1.415 +
1.416 + return stereoWideningProxy;
1.417 + }
1.418 +
1.419 +// -----------------------------------------------------------------------------
1.420 +// CStereoWidening::NewL
1.421 +// Static function for creating an instance of the StereoWidening object.
1.422 +// -----------------------------------------------------------------------------
1.423 +//
1.424 +EXPORT_C CStereoWidening* CStereoWidening::NewL(
1.425 + CVideoPlayerUtility& aUtility , TBool aEnable, TInt8 aInitialLevel )
1.426 + {
1.427 + DEBPRN0;
1.428 + CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
1.429 + CleanupStack::PushL(customInterface);
1.430 +
1.431 + CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
1.432 +
1.433 + if ( !stereoWideningProxy )
1.434 + {
1.435 + DEBPRN1("No Adaptation Support - leaving");
1.436 + User::Leave(KErrNotSupported);
1.437 + }
1.438 +
1.439 + CleanupStack::Pop(customInterface);
1.440 +
1.441 + stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
1.442 +
1.443 + if(aEnable)
1.444 + {
1.445 + stereoWideningProxy->EnableL();
1.446 + }
1.447 +
1.448 + return stereoWideningProxy;
1.449 + }
1.450 +
1.451 +// -----------------------------------------------------------------------------
1.452 +// CStereoWidening::BandLevel
1.453 +// -----------------------------------------------------------------------------
1.454 +//
1.455 +
1.456 +EXPORT_C TBool CStereoWidening::IsContinuousLevelSupported() const
1.457 + {
1.458 + return iStereoWideningData.iContinuousLevelSupported;
1.459 + }
1.460 +
1.461 +// -----------------------------------------------------------------------------
1.462 +// CStereoWidening::BandWidth
1.463 +// -----------------------------------------------------------------------------
1.464 +//
1.465 +
1.466 +EXPORT_C void CStereoWidening::SetStereoWideningLevelL( TUint8 aLevel )
1.467 + {
1.468 + iStereoWideningData.iLevel = aLevel;
1.469 + }
1.470 +
1.471 +// -----------------------------------------------------------------------------
1.472 +// CStereoWidening::CenterFrequency
1.473 +// -----------------------------------------------------------------------------
1.474 +//
1.475 +EXPORT_C TUint8 CStereoWidening::StereoWideningLevel() const
1.476 + {
1.477 + return iStereoWideningData.iLevel;
1.478 + }
1.479 +
1.480 +
1.481 +// -----------------------------------------------------------------------------
1.482 +// CStereoWidening::Uid
1.483 +// -----------------------------------------------------------------------------
1.484 +//
1.485 +EXPORT_C TUid CStereoWidening::Uid() const
1.486 + {
1.487 + return KUidStereoWideningEffect;
1.488 + }
1.489 +
1.490 +
1.491 +// -----------------------------------------------------------------------------
1.492 +// CStereoWidening::DoEffectData
1.493 +// -----------------------------------------------------------------------------
1.494 +//
1.495 +EXPORT_C const TDesC8& CStereoWidening::DoEffectData()
1.496 + {
1.497 + DEBPRN0;
1.498 + iDataPckgTo = iStereoWideningData;
1.499 + return iDataPckgTo;
1.500 + }
1.501 +
1.502 +// -----------------------------------------------------------------------------
1.503 +// CStereoWidening::SetEffectData
1.504 +// -----------------------------------------------------------------------------
1.505 +//
1.506 +EXPORT_C void CStereoWidening::SetEffectData(
1.507 + const TDesC8& aEffectDataBuffer )
1.508 + {
1.509 + DEBPRN0;
1.510 + TEfStereoWideningDataPckg dataPckg;
1.511 + dataPckg.Copy(aEffectDataBuffer);
1.512 + iStereoWideningData = dataPckg();
1.513 + iEnabled = iStereoWideningData.iEnabled;
1.514 + iEnforced = iStereoWideningData.iEnforced;
1.515 + iHaveUpdateRights = iStereoWideningData.iHaveUpdateRights;
1.516 + }
1.517 +
1.518 +
1.519 +// ========================== OTHER EXPORTED FUNCTIONS =========================
1.520 +
1.521 +// End of File
1.522 +