os/mm/devsoundextensions/effects/StereoWidening/StereoWideningEffect/Src/StereoWideningBase.cpp
Update contrib.
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Implementation of the StereoWidening effect class
27 #include <StereoWideningData.h>
28 #include <StereoWideningBase.h>
29 #include <CustomInterfaceUtility.h>
30 #include "StereoWideningProxy.h"
31 #include <DrmAudioSamplePlayer.h>
32 #include <mdaaudioinputstream.h>
33 #include <mdaaudiooutputstream.h>
34 #include <mdaaudiotoneplayer.h>
35 #include <mmf/server/sounddevice.h>
36 #include <videoplayer.h>
39 #define DEBPRN0 RDebug::Printf( "%s", __PRETTY_FUNCTION__);
40 #define DEBPRN1(str) RDebug::Printf( "%s %s", __PRETTY_FUNCTION__, str );
46 // ============================ MEMBER FUNCTIONS ===============================
48 // -----------------------------------------------------------------------------
49 // CStereoWidening::CStereoWidening
50 // C++ default constructor can NOT contain any code, that
52 // -----------------------------------------------------------------------------
54 EXPORT_C CStereoWidening::CStereoWidening()
55 : iStereoWideningData(0, 0),
56 iDataPckgTo(iStereoWideningData)
61 EXPORT_C CStereoWidening::~CStereoWidening()
65 // -----------------------------------------------------------------------------
66 // CStereoWidening::NewL
67 // Static function for creating an instance of the StereoWidening object.
68 // -----------------------------------------------------------------------------
70 EXPORT_C CStereoWidening* CStereoWidening::NewL()
72 User::Leave(KErrNotSupported);
76 // -----------------------------------------------------------------------------
77 // CStereoWidening::NewL
78 // Static function for creating an instance of the StereoWidening object.
79 // -----------------------------------------------------------------------------
81 EXPORT_C CStereoWidening* CStereoWidening::NewL(CMdaAudioConvertUtility& aUtility , TBool aEnable, TInt8 aInitialLevel)
85 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
86 CleanupStack::PushL(customInterface);
88 CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
90 if ( !stereoWideningProxy )
92 DEBPRN1("No Adaptation Support - leaving");
93 User::Leave(KErrNotSupported);
96 CleanupStack::Pop(customInterface);
98 stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
102 stereoWideningProxy->EnableL();
105 return stereoWideningProxy;
108 // -----------------------------------------------------------------------------
109 // CStereoWidening::NewL
110 // Static function for creating an instance of the StereoWidening object.
111 // -----------------------------------------------------------------------------
113 EXPORT_C CStereoWidening* CStereoWidening::NewL(
114 CMdaAudioInputStream& aUtility, TBool aEnable, TInt8 aInitialLevel )
118 CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aUtility.CustomInterface(KUidStereoWideningEffect);
120 if (stereoWideningProxy == NULL)
122 DEBPRN1("No Adaptation Support - leaving");
123 User::Leave(KErrNotSupported);
126 stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
130 stereoWideningProxy->EnableL();
133 return stereoWideningProxy;
136 // -----------------------------------------------------------------------------
137 // CStereoWidening::NewL
138 // Static function for creating an instance of the StereoWidening object.
139 // -----------------------------------------------------------------------------
141 EXPORT_C CStereoWidening* CStereoWidening::NewL(
142 CMdaAudioOutputStream& aUtility, TBool aEnable, TInt8 aInitialLevel )
146 CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aUtility.CustomInterface(KUidStereoWideningEffect);
148 if (stereoWideningProxy == NULL)
150 DEBPRN1("No Adaptation Support - leaving");
151 User::Leave(KErrNotSupported);
154 stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
158 stereoWideningProxy->EnableL();
161 return stereoWideningProxy;
164 // -----------------------------------------------------------------------------
165 // CStereoWidening::NewL
166 // Static function for creating an instance of the StereoWidening object.
167 // -----------------------------------------------------------------------------
169 EXPORT_C CStereoWidening* CStereoWidening::NewL(
170 CMdaAudioPlayerUtility& aUtility , TBool aEnable, TInt8 aInitialLevel)
174 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
175 CleanupStack::PushL(customInterface);
177 CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
179 if ( !stereoWideningProxy )
181 DEBPRN1("No Adaptation Support - leaving");
182 User::Leave(KErrNotSupported);
185 CleanupStack::Pop(customInterface);
187 stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
191 stereoWideningProxy->EnableL();
194 return stereoWideningProxy;
197 // -----------------------------------------------------------------------------
198 // CStereoWidening::NewL
199 // Static function for creating an instance of the StereoWidening object.
200 // -----------------------------------------------------------------------------
202 EXPORT_C CStereoWidening* CStereoWidening::NewL(
203 CMdaAudioRecorderUtility& aUtility,
204 TBool aRecordStream, TBool aEnable, TInt8 aInitialLevel)
208 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility, aRecordStream);
209 CleanupStack::PushL(customInterface);
211 CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
213 if ( !stereoWideningProxy )
215 DEBPRN1("No Adaptation Support - leaving");
216 User::Leave(KErrNotSupported);
219 CleanupStack::Pop(customInterface);
221 stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
225 stereoWideningProxy->EnableL();
228 return stereoWideningProxy;
231 // -----------------------------------------------------------------------------
232 // CStereoWidening::NewL
233 // Static function for creating an instance of the StereoWidening object.
234 // -----------------------------------------------------------------------------
236 EXPORT_C CStereoWidening* CStereoWidening::NewL(
237 CMdaAudioToneUtility& aUtility, TBool aEnable, TInt8 aInitialLevel)
241 CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aUtility.CustomInterface(KUidStereoWideningEffect);
243 if (stereoWideningProxy == NULL)
245 DEBPRN1("No Adaptation Support - leaving");
246 User::Leave(KErrNotSupported);
249 stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
253 stereoWideningProxy->EnableL();
256 return stereoWideningProxy;
260 // -----------------------------------------------------------------------------
261 // CStereoWidening::NewL
262 // Static function for creating an instance of the StereoWidening object.
263 // -----------------------------------------------------------------------------
265 EXPORT_C CStereoWidening* CStereoWidening::NewL(
266 CMMFDevSound& aDevSound, TBool aEnable, TInt8 aInitialLevel)
270 CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aDevSound.CustomInterface(KUidStereoWideningEffect);
272 if (stereoWideningProxy == NULL)
274 DEBPRN1("No Adaptation Support - leaving");
275 User::Leave(KErrNotSupported);
278 stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
282 stereoWideningProxy->EnableL();
285 return stereoWideningProxy;
290 // -----------------------------------------------------------------------------
291 // CStereoWidening::NewL
292 // Static function for creating an instance of the StereoWidening object.
293 // -----------------------------------------------------------------------------
295 EXPORT_C CStereoWidening* CStereoWidening::NewL(
296 CCustomCommandUtility* aUtility , TBool aEnable, TInt8 aInitialLevel)
300 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
301 CleanupStack::PushL(customInterface);
303 CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
305 if ( !stereoWideningProxy )
307 DEBPRN1("No Adaptation Support - leaving");
308 User::Leave(KErrNotSupported);
311 CleanupStack::Pop(customInterface);
313 stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
317 stereoWideningProxy->EnableL();
320 return stereoWideningProxy;
323 // -----------------------------------------------------------------------------
324 // CStereoWidening::NewL
325 // Static function for creating an instance of the StereoWidening object.
326 // -----------------------------------------------------------------------------
328 EXPORT_C CStereoWidening* CStereoWidening::NewL(
329 MCustomInterface& aCustomInterface , TBool aEnable, TInt8 aInitialLevel)
333 CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aCustomInterface.CustomInterface(KUidStereoWideningEffect);
335 if ( !stereoWideningProxy )
337 DEBPRN1("No Adaptation Support - leaving");
338 User::Leave(KErrNotSupported);
341 stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
345 stereoWideningProxy->EnableL();
348 return stereoWideningProxy;
351 // -----------------------------------------------------------------------------
352 // CStereoWidening::NewL
353 // Static function for creating an instance of the StereoWidening object.
354 // -----------------------------------------------------------------------------
356 EXPORT_C CStereoWidening* CStereoWidening::NewL(
357 CMidiClientUtility& aUtility , TBool aEnable, TInt8 aInitialLevel )
361 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
362 CleanupStack::PushL(customInterface);
364 CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
366 if ( !stereoWideningProxy )
368 DEBPRN1("No Adaptation Support - leaving");
369 User::Leave(KErrNotSupported);
372 CleanupStack::Pop(customInterface);
374 stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
378 stereoWideningProxy->EnableL();
381 return stereoWideningProxy;
384 // -----------------------------------------------------------------------------
385 // CStereoWidening::NewL
386 // Static function for creating an instance of the StereoWidening object.
387 // -----------------------------------------------------------------------------
389 EXPORT_C CStereoWidening* CStereoWidening::NewL(
390 CDrmPlayerUtility& aUtility , TBool aEnable, TInt8 aInitialLevel )
393 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
394 CleanupStack::PushL(customInterface);
396 CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
398 if ( !stereoWideningProxy )
400 DEBPRN1("No Adaptation Support - leaving");
401 User::Leave(KErrNotSupported);
404 CleanupStack::Pop(customInterface);
406 stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
410 stereoWideningProxy->EnableL();
413 return stereoWideningProxy;
416 // -----------------------------------------------------------------------------
417 // CStereoWidening::NewL
418 // Static function for creating an instance of the StereoWidening object.
419 // -----------------------------------------------------------------------------
421 EXPORT_C CStereoWidening* CStereoWidening::NewL(
422 CVideoPlayerUtility& aUtility , TBool aEnable, TInt8 aInitialLevel )
425 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
426 CleanupStack::PushL(customInterface);
428 CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
430 if ( !stereoWideningProxy )
432 DEBPRN1("No Adaptation Support - leaving");
433 User::Leave(KErrNotSupported);
436 CleanupStack::Pop(customInterface);
438 stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
442 stereoWideningProxy->EnableL();
445 return stereoWideningProxy;
448 // -----------------------------------------------------------------------------
449 // CStereoWidening::BandLevel
450 // -----------------------------------------------------------------------------
453 EXPORT_C TBool CStereoWidening::IsContinuousLevelSupported() const
455 return iStereoWideningData.iContinuousLevelSupported;
458 // -----------------------------------------------------------------------------
459 // CStereoWidening::BandWidth
460 // -----------------------------------------------------------------------------
463 EXPORT_C void CStereoWidening::SetStereoWideningLevelL( TUint8 aLevel )
465 iStereoWideningData.iLevel = aLevel;
468 // -----------------------------------------------------------------------------
469 // CStereoWidening::CenterFrequency
470 // -----------------------------------------------------------------------------
472 EXPORT_C TUint8 CStereoWidening::StereoWideningLevel() const
474 return iStereoWideningData.iLevel;
478 // -----------------------------------------------------------------------------
479 // CStereoWidening::Uid
480 // -----------------------------------------------------------------------------
482 EXPORT_C TUid CStereoWidening::Uid() const
484 return KUidStereoWideningEffect;
488 // -----------------------------------------------------------------------------
489 // CStereoWidening::DoEffectData
490 // -----------------------------------------------------------------------------
492 EXPORT_C const TDesC8& CStereoWidening::DoEffectData()
495 iDataPckgTo = iStereoWideningData;
499 // -----------------------------------------------------------------------------
500 // CStereoWidening::SetEffectData
501 // -----------------------------------------------------------------------------
503 EXPORT_C void CStereoWidening::SetEffectData(
504 const TDesC8& aEffectDataBuffer )
507 TEfStereoWideningDataPckg dataPckg;
508 dataPckg.Copy(aEffectDataBuffer);
509 iStereoWideningData = dataPckg();
510 iEnabled = iStereoWideningData.iEnabled;
511 iEnforced = iStereoWideningData.iEnforced;
512 iHaveUpdateRights = iStereoWideningData.iHaveUpdateRights;
516 // ========================== OTHER EXPORTED FUNCTIONS =========================