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