First public contribution.
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 RoomLevel effect class
27 #include "RoomLevelProxy.h"
29 #include <RoomLevelBase.h>
30 #include <CustomInterfaceUtility.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 // CRoomLevel::CRoomLevel
50 // C++ default constructor can NOT contain any code, that
52 // -----------------------------------------------------------------------------
54 EXPORT_C CRoomLevel::CRoomLevel()
56 iDataPckgTo(iRoomLevelData)
62 // -----------------------------------------------------------------------------
63 // CRoomLevel::~CRoomLevel
65 // -----------------------------------------------------------------------------
68 EXPORT_C CRoomLevel::~CRoomLevel()
74 // -----------------------------------------------------------------------------
76 // Static function for creating an instance of the RoomLevel object.
77 // -----------------------------------------------------------------------------
79 EXPORT_C CRoomLevel* CRoomLevel::NewL(
80 CMdaAudioConvertUtility& aUtility, CEnvironmentalReverb& aReverb )
84 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
85 CleanupStack::PushL(customInterface);
87 CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
89 if ( !roomLevelProxy )
91 DEBPRN1("No Adaptation Support - leaving");
92 User::Leave(KErrNotSupported);
95 CleanupStack::Pop(customInterface);
97 roomLevelProxy->iClientReverb = &aReverb;
98 roomLevelProxy->AttachReverb(aReverb);
100 return roomLevelProxy;
104 // -----------------------------------------------------------------------------
106 // Static function for creating an instance of the RoomLevel object.
107 // -----------------------------------------------------------------------------
109 EXPORT_C CRoomLevel* CRoomLevel::NewL(
110 CMdaAudioInputStream& aUtility, CEnvironmentalReverb& aReverb )
114 CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aUtility.CustomInterface(KUidRoomLevelEffect);
116 if (roomLevelProxy == NULL)
118 DEBPRN1("No Adaptation Support - leaving");
119 User::Leave(KErrNotSupported);
122 roomLevelProxy->iClientReverb = &aReverb;
123 roomLevelProxy->AttachReverb(aReverb);
125 return roomLevelProxy;
128 // -----------------------------------------------------------------------------
130 // Static function for creating an instance of the RoomLevel object.
131 // -----------------------------------------------------------------------------
133 EXPORT_C CRoomLevel* CRoomLevel::NewL(
134 CMdaAudioOutputStream& aUtility, CEnvironmentalReverb& aReverb )
138 CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aUtility.CustomInterface(KUidRoomLevelEffect);
140 if (roomLevelProxy == NULL)
142 DEBPRN1("No Adaptation Support - leaving");
143 User::Leave(KErrNotSupported);
146 roomLevelProxy->iClientReverb = &aReverb;
147 roomLevelProxy->AttachReverb(aReverb);
149 return roomLevelProxy;
152 // -----------------------------------------------------------------------------
154 // Static function for creating an instance of the RoomLevel object.
155 // -----------------------------------------------------------------------------
157 EXPORT_C CRoomLevel* CRoomLevel::NewL(
158 CMdaAudioPlayerUtility& aUtility, CEnvironmentalReverb& aReverb )
162 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
163 CleanupStack::PushL(customInterface);
165 CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
167 if ( !roomLevelProxy )
169 DEBPRN1("No Adaptation Support - leaving");
170 User::Leave(KErrNotSupported);
173 CleanupStack::Pop(customInterface);
176 roomLevelProxy->iClientReverb = &aReverb;
177 roomLevelProxy->AttachReverb(aReverb);
179 return roomLevelProxy;
182 // -----------------------------------------------------------------------------
184 // Static function for creating an instance of the RoomLevel object.
185 // -----------------------------------------------------------------------------
187 EXPORT_C CRoomLevel* CRoomLevel::NewL(
188 CMdaAudioRecorderUtility& aUtility,
189 TBool aRecordStream, CEnvironmentalReverb& aReverb )
193 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility, aRecordStream);
194 CleanupStack::PushL(customInterface);
196 CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
198 if ( !roomLevelProxy )
200 DEBPRN1("No Adaptation Support - leaving");
201 User::Leave(KErrNotSupported);
204 CleanupStack::Pop(customInterface);
206 roomLevelProxy->iClientReverb = &aReverb;
207 roomLevelProxy->AttachReverb(aReverb);
209 return roomLevelProxy;
212 // -----------------------------------------------------------------------------
214 // Static function for creating an instance of the RoomLevel object.
215 // -----------------------------------------------------------------------------
217 EXPORT_C CRoomLevel* CRoomLevel::NewL(
218 CMdaAudioToneUtility& aUtility, CEnvironmentalReverb& aReverb )
222 CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aUtility.CustomInterface(KUidRoomLevelEffect);
224 if (roomLevelProxy == NULL)
226 DEBPRN1("No Adaptation Support - leaving");
227 User::Leave(KErrNotSupported);
230 roomLevelProxy->iClientReverb = &aReverb;
231 roomLevelProxy->AttachReverb(aReverb);
233 return roomLevelProxy;
236 // -----------------------------------------------------------------------------
237 // CAudioEqualizer::NewL
238 // Static function for creating an instance of the RoomLevel object.
239 // -----------------------------------------------------------------------------
241 EXPORT_C CRoomLevel* CRoomLevel::NewL(
242 CMMFDevSound& aDevSound, CEnvironmentalReverb& aReverb )
246 CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aDevSound.CustomInterface(KUidRoomLevelEffect);
248 if (roomLevelProxy == NULL)
250 DEBPRN1("No Adaptation Support - leaving");
251 User::Leave(KErrNotSupported);
254 roomLevelProxy->iClientReverb = &aReverb;
255 roomLevelProxy->AttachReverb(aReverb);
257 return roomLevelProxy;
260 // -----------------------------------------------------------------------------
262 // Static function for creating an instance of the RoomLevel object.
263 // -----------------------------------------------------------------------------
265 EXPORT_C CRoomLevel* CRoomLevel::NewL(
266 CCustomCommandUtility* aUtility, CEnvironmentalReverb& aReverb )
270 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
271 CleanupStack::PushL(customInterface);
273 CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
275 if ( !roomLevelProxy )
277 DEBPRN1("No Adaptation Support - leaving");
278 User::Leave(KErrNotSupported);
281 CleanupStack::Pop(customInterface);
283 roomLevelProxy->iClientReverb = &aReverb;
284 roomLevelProxy->AttachReverb(aReverb);
286 return roomLevelProxy;
289 // -----------------------------------------------------------------------------
291 // Static function for creating an instance of the RoomLevel object.
292 // -----------------------------------------------------------------------------
294 EXPORT_C CRoomLevel* CRoomLevel::NewL(
295 MCustomInterface& aCustomInterface, CEnvironmentalReverb& aReverb )
299 CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aCustomInterface.CustomInterface(KUidRoomLevelEffect);
300 if ( !roomLevelProxy )
302 DEBPRN1("No Adaptation Support - leaving");
303 User::Leave(KErrNotSupported);
306 roomLevelProxy->iClientReverb = &aReverb;
308 roomLevelProxy->AttachReverb(aReverb);
310 return roomLevelProxy;
313 // -----------------------------------------------------------------------------
315 // Static function for creating an instance of the RoomLevel object.
316 // -----------------------------------------------------------------------------
318 EXPORT_C CRoomLevel* CRoomLevel::NewL(
319 CMidiClientUtility& aUtility, CEnvironmentalReverb& aReverb)
323 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
324 CleanupStack::PushL(customInterface);
326 CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
328 if ( !roomLevelProxy )
330 DEBPRN1("No Adaptation Support - leaving");
331 User::Leave(KErrNotSupported);
334 CleanupStack::Pop(customInterface);
336 roomLevelProxy->iClientReverb = &aReverb;
338 roomLevelProxy->AttachReverb(aReverb);
340 return roomLevelProxy;
343 // -----------------------------------------------------------------------------
345 // Static function for creating an instance of the RoomLevel object.
346 // -----------------------------------------------------------------------------
348 EXPORT_C CRoomLevel* CRoomLevel::NewL(
349 CDrmPlayerUtility& aUtility, CEnvironmentalReverb& aReverb)
353 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
354 CleanupStack::PushL(customInterface);
356 CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
358 if ( !roomLevelProxy )
360 DEBPRN1("No Adaptation Support - leaving");
361 User::Leave(KErrNotSupported);
364 CleanupStack::Pop(customInterface);
366 roomLevelProxy->iClientReverb = &aReverb;
368 roomLevelProxy->AttachReverb(aReverb);
370 return roomLevelProxy;
373 // -----------------------------------------------------------------------------
375 // Static function for creating an instance of the RoomLevel object.
376 // -----------------------------------------------------------------------------
378 EXPORT_C CRoomLevel* CRoomLevel::NewL(
379 CVideoPlayerUtility& aUtility, CEnvironmentalReverb& aReverb)
383 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
384 CleanupStack::PushL(customInterface);
386 CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
388 if ( !roomLevelProxy )
390 DEBPRN1("No Adaptation Support - leaving");
391 User::Leave(KErrNotSupported);
394 CleanupStack::Pop(customInterface);
396 roomLevelProxy->iClientReverb = &aReverb;
398 roomLevelProxy->AttachReverb(aReverb);
400 return roomLevelProxy;
403 // -----------------------------------------------------------------------------
404 // CRoomLevel::RoomLevel
405 // -----------------------------------------------------------------------------
407 EXPORT_C TInt32 CRoomLevel::Level() const
409 return iRoomLevelData.iStreamRoomLevel;
412 // -----------------------------------------------------------------------------
413 // CRoomLevel::RoomLevelLevelRange
414 // -----------------------------------------------------------------------------
416 EXPORT_C void CRoomLevel::LevelRange(
421 aMin = iRoomLevelData.iStreamMinRoomLevel;
422 aMax = iRoomLevelData.iStreamMaxRoomLevel;
426 // -----------------------------------------------------------------------------
427 // CRoomLevel::SetRoomLevelL
428 // -----------------------------------------------------------------------------
430 EXPORT_C void CRoomLevel::SetRoomLevelL(
433 if ( (aRoomLevel >= iRoomLevelData.iStreamMinRoomLevel) && (aRoomLevel <= iRoomLevelData.iStreamMaxRoomLevel) )
435 iRoomLevelData.iStreamRoomLevel = aRoomLevel;
439 User::Leave(KErrArgument);
444 // -----------------------------------------------------------------------------
446 // -----------------------------------------------------------------------------
448 EXPORT_C TUid CRoomLevel::Uid() const
450 return KUidRoomLevelEffect;
454 // -----------------------------------------------------------------------------
455 // CRoomLevel::DoEffectData
456 // -----------------------------------------------------------------------------
458 EXPORT_C const TDesC8& CRoomLevel::DoEffectData()
461 iDataPckgTo = iRoomLevelData;
465 // -----------------------------------------------------------------------------
466 // CRoomLevel::SetEffectData
467 // -----------------------------------------------------------------------------
469 EXPORT_C void CRoomLevel::SetEffectData(
470 const TDesC8& aEffectDataBuffer )
473 TEfRoomLevelDataPckg dataPckg;
474 dataPckg.Copy(aEffectDataBuffer);
475 iRoomLevelData = dataPckg();
476 iEnabled = iRoomLevelData.iEnabled;
477 iEnforced = iRoomLevelData.iEnforced;
478 iHaveUpdateRights = iRoomLevelData.iHaveUpdateRights;
482 // ========================== OTHER EXPORTED FUNCTIONS =========================