devsoundextensions/effects/StereoWidening/StereoWideningEffect/Src/StereoWideningBase.cpp
changeset 0 b8ed18f6c07b
equal deleted inserted replaced
-1:000000000000 0:b8ed18f6c07b
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Implementation of the StereoWidening effect class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #ifdef _DEBUG
       
    24 #include <e32svr.h>
       
    25 #endif
       
    26 
       
    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>
       
    37 
       
    38 #ifdef _DEBUG
       
    39 #define DEBPRN0         RDebug::Printf( "%s", __PRETTY_FUNCTION__);
       
    40 #define DEBPRN1(str)    RDebug::Printf( "%s %s", __PRETTY_FUNCTION__, str );
       
    41 #else
       
    42 #define DEBPRN0
       
    43 #define DEBPRN1(str)
       
    44 #endif
       
    45 
       
    46 // ============================ MEMBER FUNCTIONS ===============================
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CStereoWidening::CStereoWidening
       
    50 // C++ default constructor can NOT contain any code, that
       
    51 // might leave.
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 EXPORT_C CStereoWidening::CStereoWidening()
       
    55     : 	iStereoWideningData(0, 0),
       
    56     	iDataPckgTo(iStereoWideningData)
       
    57     {
       
    58     }
       
    59 
       
    60 // Destructor
       
    61 EXPORT_C CStereoWidening::~CStereoWidening()
       
    62     {
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CStereoWidening::NewL
       
    67 // Static function for creating an instance of the StereoWidening object.
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 EXPORT_C CStereoWidening* CStereoWidening::NewL()
       
    71 	{
       
    72 	User::Leave(KErrNotSupported);
       
    73 	return NULL;
       
    74 	}
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CStereoWidening::NewL
       
    78 // Static function for creating an instance of the StereoWidening object.
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 EXPORT_C CStereoWidening* CStereoWidening::NewL(CMdaAudioConvertUtility& aUtility ,	TBool aEnable, TInt8 aInitialLevel)
       
    82 	{
       
    83 
       
    84     DEBPRN0;
       
    85    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
    86     CleanupStack::PushL(customInterface);
       
    87 
       
    88 	CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
       
    89 
       
    90 	if ( !stereoWideningProxy )
       
    91 		{
       
    92 		DEBPRN1("No Adaptation Support - leaving");
       
    93 		User::Leave(KErrNotSupported);
       
    94 		}
       
    95 
       
    96 	CleanupStack::Pop(customInterface);
       
    97 
       
    98 	stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
       
    99 
       
   100 	if(aEnable)
       
   101 	{
       
   102 		stereoWideningProxy->EnableL();
       
   103 	}
       
   104 
       
   105     return stereoWideningProxy;
       
   106 	}
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CStereoWidening::NewL
       
   110 // Static function for creating an instance of the StereoWidening object.
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 EXPORT_C CStereoWidening* CStereoWidening::NewL(
       
   114 	CMdaAudioInputStream& aUtility, TBool aEnable, TInt8 aInitialLevel )
       
   115 	{
       
   116 
       
   117 	DEBPRN0;
       
   118     CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aUtility.CustomInterface(KUidStereoWideningEffect);
       
   119 
       
   120 	if (stereoWideningProxy == NULL)
       
   121 		{
       
   122         DEBPRN1("No Adaptation Support - leaving");
       
   123     	User::Leave(KErrNotSupported);
       
   124 		}
       
   125 
       
   126     stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
       
   127 
       
   128 	if(aEnable)
       
   129 	    {
       
   130 		stereoWideningProxy->EnableL();
       
   131 	    }
       
   132 
       
   133     return stereoWideningProxy;
       
   134 	}
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CStereoWidening::NewL
       
   138 // Static function for creating an instance of the StereoWidening object.
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 EXPORT_C CStereoWidening* CStereoWidening::NewL(
       
   142 	CMdaAudioOutputStream& aUtility, TBool aEnable, TInt8 aInitialLevel )
       
   143 	{
       
   144 
       
   145     DEBPRN0;
       
   146     CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aUtility.CustomInterface(KUidStereoWideningEffect);
       
   147 
       
   148 	if (stereoWideningProxy == NULL)
       
   149 		{
       
   150         DEBPRN1("No Adaptation Support - leaving");
       
   151     	User::Leave(KErrNotSupported);
       
   152 		}
       
   153 
       
   154     stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
       
   155 
       
   156 	if(aEnable)
       
   157 	    {
       
   158 		stereoWideningProxy->EnableL();
       
   159 	    }
       
   160 
       
   161     return stereoWideningProxy;
       
   162 	}
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CStereoWidening::NewL
       
   166 // Static function for creating an instance of the StereoWidening object.
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 EXPORT_C CStereoWidening* CStereoWidening::NewL(
       
   170 	CMdaAudioPlayerUtility& aUtility , TBool aEnable, TInt8 aInitialLevel)
       
   171 	{
       
   172 
       
   173     DEBPRN0;
       
   174    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   175     CleanupStack::PushL(customInterface);
       
   176 
       
   177 	CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
       
   178 
       
   179 	if ( !stereoWideningProxy )
       
   180 		{
       
   181 		DEBPRN1("No Adaptation Support - leaving");
       
   182 		User::Leave(KErrNotSupported);
       
   183 		}
       
   184 
       
   185 	CleanupStack::Pop(customInterface);
       
   186 
       
   187 	stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
       
   188 
       
   189 	if(aEnable)
       
   190 	{
       
   191 		stereoWideningProxy->EnableL();
       
   192 	}
       
   193 
       
   194     return stereoWideningProxy;
       
   195 	}
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 // CStereoWidening::NewL
       
   199 // Static function for creating an instance of the StereoWidening object.
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 EXPORT_C CStereoWidening* CStereoWidening::NewL(
       
   203 	CMdaAudioRecorderUtility& aUtility,
       
   204 	TBool aRecordStream, TBool aEnable, TInt8 aInitialLevel)
       
   205 	{
       
   206 
       
   207     DEBPRN0;
       
   208    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility, aRecordStream);
       
   209     CleanupStack::PushL(customInterface);
       
   210 
       
   211 	CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
       
   212 
       
   213 	if ( !stereoWideningProxy )
       
   214 		{
       
   215 		DEBPRN1("No Adaptation Support - leaving");
       
   216 		User::Leave(KErrNotSupported);
       
   217 		}
       
   218 
       
   219 	CleanupStack::Pop(customInterface);
       
   220 
       
   221 	stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
       
   222 
       
   223 	if(aEnable)
       
   224 	{
       
   225 		stereoWideningProxy->EnableL();
       
   226 	}
       
   227 
       
   228     return stereoWideningProxy;
       
   229 	}
       
   230 
       
   231 // -----------------------------------------------------------------------------
       
   232 // CStereoWidening::NewL
       
   233 // Static function for creating an instance of the StereoWidening object.
       
   234 // -----------------------------------------------------------------------------
       
   235 //
       
   236 EXPORT_C CStereoWidening* CStereoWidening::NewL(
       
   237 	CMdaAudioToneUtility& aUtility, TBool aEnable, TInt8 aInitialLevel)
       
   238 	{
       
   239 
       
   240 	DEBPRN0;
       
   241     CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aUtility.CustomInterface(KUidStereoWideningEffect);
       
   242 
       
   243 	if (stereoWideningProxy == NULL)
       
   244 		{
       
   245         DEBPRN1("No Adaptation Support - leaving");
       
   246     	User::Leave(KErrNotSupported);
       
   247 		}
       
   248 
       
   249     stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
       
   250 
       
   251 	if(aEnable)
       
   252 	    {
       
   253 		stereoWideningProxy->EnableL();
       
   254 	    }
       
   255 
       
   256     return stereoWideningProxy;
       
   257 	}
       
   258 
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // CStereoWidening::NewL
       
   262 // Static function for creating an instance of the StereoWidening object.
       
   263 // -----------------------------------------------------------------------------
       
   264 //
       
   265 EXPORT_C CStereoWidening* CStereoWidening::NewL(
       
   266 	CMMFDevSound& aDevSound, TBool aEnable, TInt8 aInitialLevel)
       
   267 	{
       
   268 
       
   269 	DEBPRN0;
       
   270     CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aDevSound.CustomInterface(KUidStereoWideningEffect);
       
   271 
       
   272 	if (stereoWideningProxy == NULL)
       
   273 		{
       
   274         DEBPRN1("No Adaptation Support - leaving");
       
   275     	User::Leave(KErrNotSupported);
       
   276 		}
       
   277 
       
   278     stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
       
   279 
       
   280 	if(aEnable)
       
   281 	    {
       
   282 		stereoWideningProxy->EnableL();
       
   283 	    }
       
   284 
       
   285     return stereoWideningProxy;
       
   286 	}
       
   287 
       
   288 
       
   289 
       
   290 // -----------------------------------------------------------------------------
       
   291 // CStereoWidening::NewL
       
   292 // Static function for creating an instance of the StereoWidening object.
       
   293 // -----------------------------------------------------------------------------
       
   294 //
       
   295 EXPORT_C CStereoWidening* CStereoWidening::NewL(
       
   296 	CCustomCommandUtility* aUtility , TBool aEnable, TInt8 aInitialLevel)
       
   297 	{
       
   298 
       
   299     DEBPRN0;
       
   300    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   301     CleanupStack::PushL(customInterface);
       
   302 
       
   303 	CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
       
   304 
       
   305 	if ( !stereoWideningProxy )
       
   306 		{
       
   307 		DEBPRN1("No Adaptation Support - leaving");
       
   308 		User::Leave(KErrNotSupported);
       
   309 		}
       
   310 
       
   311 	CleanupStack::Pop(customInterface);
       
   312 
       
   313 	stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
       
   314 
       
   315 	if(aEnable)
       
   316 	{
       
   317 		stereoWideningProxy->EnableL();
       
   318 	}
       
   319 
       
   320     return stereoWideningProxy;
       
   321 	}
       
   322 
       
   323 // -----------------------------------------------------------------------------
       
   324 // CStereoWidening::NewL
       
   325 // Static function for creating an instance of the StereoWidening object.
       
   326 // -----------------------------------------------------------------------------
       
   327 //
       
   328 EXPORT_C CStereoWidening* CStereoWidening::NewL(
       
   329 	MCustomInterface& aCustomInterface , TBool aEnable, TInt8 aInitialLevel)
       
   330 	{
       
   331 
       
   332     DEBPRN0;
       
   333 	CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)aCustomInterface.CustomInterface(KUidStereoWideningEffect);
       
   334 
       
   335 	if ( !stereoWideningProxy )
       
   336 		{
       
   337 		DEBPRN1("No Adaptation Support - leaving");
       
   338 		User::Leave(KErrNotSupported);
       
   339 		}
       
   340 
       
   341 	stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
       
   342 
       
   343 	if(aEnable)
       
   344     	{
       
   345 		stereoWideningProxy->EnableL();
       
   346 	    }
       
   347 
       
   348     return stereoWideningProxy;
       
   349 	}
       
   350 
       
   351 // -----------------------------------------------------------------------------
       
   352 // CStereoWidening::NewL
       
   353 // Static function for creating an instance of the StereoWidening object.
       
   354 // -----------------------------------------------------------------------------
       
   355 //
       
   356 EXPORT_C CStereoWidening* CStereoWidening::NewL(
       
   357 	CMidiClientUtility& aUtility , TBool aEnable, TInt8 aInitialLevel )
       
   358 	{
       
   359 
       
   360     DEBPRN0;
       
   361    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   362     CleanupStack::PushL(customInterface);
       
   363 
       
   364 	CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
       
   365 
       
   366 	if ( !stereoWideningProxy )
       
   367 		{
       
   368 		DEBPRN1("No Adaptation Support - leaving");
       
   369 		User::Leave(KErrNotSupported);
       
   370 		}
       
   371 
       
   372 	CleanupStack::Pop(customInterface);
       
   373 
       
   374 	stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
       
   375 
       
   376 	if(aEnable)
       
   377 	    {
       
   378 		stereoWideningProxy->EnableL();
       
   379 	    }
       
   380 
       
   381     return stereoWideningProxy;
       
   382 	}
       
   383 
       
   384 // -----------------------------------------------------------------------------
       
   385 // CStereoWidening::NewL
       
   386 // Static function for creating an instance of the StereoWidening object.
       
   387 // -----------------------------------------------------------------------------
       
   388 //
       
   389 EXPORT_C CStereoWidening* CStereoWidening::NewL(
       
   390 	CDrmPlayerUtility& aUtility , TBool aEnable, TInt8 aInitialLevel )
       
   391 	{
       
   392     DEBPRN0;
       
   393    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   394     CleanupStack::PushL(customInterface);
       
   395 
       
   396 	CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
       
   397 
       
   398 	if ( !stereoWideningProxy )
       
   399 		{
       
   400 		DEBPRN1("No Adaptation Support - leaving");
       
   401 		User::Leave(KErrNotSupported);
       
   402 		}
       
   403 
       
   404 	CleanupStack::Pop(customInterface);
       
   405 
       
   406 	stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
       
   407 
       
   408 	if(aEnable)
       
   409 	    {
       
   410 		stereoWideningProxy->EnableL();
       
   411 	    }
       
   412 
       
   413     return stereoWideningProxy;
       
   414 	}
       
   415 
       
   416 // -----------------------------------------------------------------------------
       
   417 // CStereoWidening::NewL
       
   418 // Static function for creating an instance of the StereoWidening object.
       
   419 // -----------------------------------------------------------------------------
       
   420 //
       
   421 EXPORT_C CStereoWidening* CStereoWidening::NewL(
       
   422 	CVideoPlayerUtility& aUtility , TBool aEnable, TInt8 aInitialLevel )
       
   423 	{
       
   424     DEBPRN0;
       
   425    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   426     CleanupStack::PushL(customInterface);
       
   427 
       
   428 	CStereoWideningProxy* stereoWideningProxy = (CStereoWideningProxy*)customInterface->CustomInterface(KUidStereoWideningEffect);
       
   429 
       
   430 	if ( !stereoWideningProxy )
       
   431 		{
       
   432 		DEBPRN1("No Adaptation Support - leaving");
       
   433 		User::Leave(KErrNotSupported);
       
   434 		}
       
   435 
       
   436 	CleanupStack::Pop(customInterface);
       
   437 
       
   438 	stereoWideningProxy->SetStereoWideningLevelL(aInitialLevel);
       
   439 
       
   440 	if(aEnable)
       
   441 	    {
       
   442 		stereoWideningProxy->EnableL();
       
   443 	    }
       
   444 
       
   445     return stereoWideningProxy;
       
   446 	}
       
   447 
       
   448 // -----------------------------------------------------------------------------
       
   449 // CStereoWidening::BandLevel
       
   450 // -----------------------------------------------------------------------------
       
   451 //
       
   452 
       
   453 EXPORT_C TBool CStereoWidening::IsContinuousLevelSupported() const
       
   454 	{
       
   455 		return iStereoWideningData.iContinuousLevelSupported;
       
   456 	}
       
   457 
       
   458 // -----------------------------------------------------------------------------
       
   459 // CStereoWidening::BandWidth
       
   460 // -----------------------------------------------------------------------------
       
   461 //
       
   462 
       
   463 EXPORT_C void CStereoWidening::SetStereoWideningLevelL( TUint8 aLevel )
       
   464 	{
       
   465 	iStereoWideningData.iLevel = aLevel;
       
   466 	}
       
   467 
       
   468 // -----------------------------------------------------------------------------
       
   469 // CStereoWidening::CenterFrequency
       
   470 // -----------------------------------------------------------------------------
       
   471 //
       
   472 EXPORT_C TUint8 CStereoWidening::StereoWideningLevel() const
       
   473 	{
       
   474 		return iStereoWideningData.iLevel;
       
   475 	}
       
   476 
       
   477 
       
   478 // -----------------------------------------------------------------------------
       
   479 // CStereoWidening::Uid
       
   480 // -----------------------------------------------------------------------------
       
   481 //
       
   482 EXPORT_C TUid CStereoWidening::Uid() const
       
   483 	{
       
   484 	return KUidStereoWideningEffect;
       
   485 	}
       
   486 
       
   487 
       
   488 // -----------------------------------------------------------------------------
       
   489 // CStereoWidening::DoEffectData
       
   490 // -----------------------------------------------------------------------------
       
   491 //
       
   492 EXPORT_C const TDesC8& CStereoWidening::DoEffectData()
       
   493 	{
       
   494     DEBPRN0;
       
   495 	iDataPckgTo = iStereoWideningData;
       
   496 	return iDataPckgTo;
       
   497 	}
       
   498 
       
   499 // -----------------------------------------------------------------------------
       
   500 // CStereoWidening::SetEffectData
       
   501 // -----------------------------------------------------------------------------
       
   502 //
       
   503 EXPORT_C void CStereoWidening::SetEffectData(
       
   504 	const TDesC8& aEffectDataBuffer )
       
   505 	{
       
   506     DEBPRN0;
       
   507 	TEfStereoWideningDataPckg dataPckg;
       
   508 	dataPckg.Copy(aEffectDataBuffer);
       
   509 	iStereoWideningData = dataPckg();
       
   510 	iEnabled = iStereoWideningData.iEnabled;
       
   511 	iEnforced = iStereoWideningData.iEnforced;
       
   512 	iHaveUpdateRights = iStereoWideningData.iHaveUpdateRights;
       
   513 	}
       
   514 
       
   515 
       
   516 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   517 
       
   518 // End of File
       
   519