devsoundextensions/effects/SrcDoppler/SourceDopplerEffect/Src/SourceDopplerEffect.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     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 Source Doppler Effect class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #ifdef _DEBUG
       
    24 #include <e32svr.h>
       
    25 #endif
       
    26 
       
    27 #include <SourceDopplerBase.h>
       
    28 #include <CustomInterfaceUtility.h>
       
    29 #include "SourceDopplerProxy.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 // CSourceDoppler::CSourceDoppler
       
    49 // C++ default constructor can NOT contain any code, that
       
    50 // might leave.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 EXPORT_C CSourceDoppler::CSourceDoppler()
       
    54     {
       
    55     }
       
    56 
       
    57 // Destructor
       
    58 EXPORT_C CSourceDoppler::~CSourceDoppler()
       
    59     {
       
    60     }
       
    61 
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CSourceDoppler::NewL
       
    65 // Static function for creating an instance of the Doppler object.
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 EXPORT_C CSourceDoppler* CSourceDoppler::NewL(
       
    69 	CMdaAudioInputStream& aUtility )
       
    70 	{
       
    71 
       
    72     DEBPRN0;
       
    73     CSourceDopplerProxy* dopplerProxy = (CSourceDopplerProxy*)aUtility.CustomInterface(KUidSourceDopplerEffect);
       
    74 
       
    75 	if (dopplerProxy == NULL)
       
    76 		{
       
    77         DEBPRN1("No Adaptation Support - leaving");
       
    78     	User::Leave(KErrNotSupported);
       
    79 		}
       
    80 
       
    81     return dopplerProxy;
       
    82 	}
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CSourceDoppler::NewL
       
    86 // Static function for creating an instance of the Doppler object.
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 EXPORT_C CSourceDoppler* CSourceDoppler::NewL(
       
    90 	CMdaAudioOutputStream& aUtility )
       
    91 	{
       
    92 
       
    93 	DEBPRN0;
       
    94     CSourceDopplerProxy* dopplerProxy = (CSourceDopplerProxy*)aUtility.CustomInterface(KUidSourceDopplerEffect);
       
    95 
       
    96 	if (dopplerProxy == NULL)
       
    97 		{
       
    98         DEBPRN1("No Adaptation Support - leaving");
       
    99     	User::Leave(KErrNotSupported);
       
   100 		}
       
   101 
       
   102     return dopplerProxy;
       
   103 	}
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CSourceDoppler::NewL
       
   107 // Static function for creating an instance of the Doppler object.
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 EXPORT_C CSourceDoppler* CSourceDoppler::NewL(
       
   111 	CMdaAudioConvertUtility& aUtility )
       
   112 	{
       
   113 
       
   114     DEBPRN0;
       
   115    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   116     CleanupStack::PushL(customInterface);
       
   117 
       
   118 	CSourceDopplerProxy* dopplerProxy = (CSourceDopplerProxy*)customInterface->CustomInterface(KUidSourceDopplerEffect);
       
   119 
       
   120 	if ( !dopplerProxy )
       
   121 		{
       
   122 		DEBPRN1("No Adaptation Support - leaving");
       
   123 		User::Leave(KErrNotSupported);
       
   124 		}
       
   125 
       
   126 	CleanupStack::Pop(customInterface);
       
   127 
       
   128     return dopplerProxy;
       
   129 	}
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CSourceDoppler::NewL
       
   133 // Static function for creating an instance of the Doppler object.
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 EXPORT_C CSourceDoppler* CSourceDoppler::NewL(
       
   137 	CMdaAudioPlayerUtility& aUtility )
       
   138 	{
       
   139 
       
   140     DEBPRN0;
       
   141    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   142     CleanupStack::PushL(customInterface);
       
   143 
       
   144 	CSourceDopplerProxy* dopplerProxy = (CSourceDopplerProxy*)customInterface->CustomInterface(KUidSourceDopplerEffect);
       
   145 
       
   146 	if ( !dopplerProxy )
       
   147 		{
       
   148 		DEBPRN1("No Adaptation Support - leaving");
       
   149 		User::Leave(KErrNotSupported);
       
   150 		}
       
   151 
       
   152 	CleanupStack::Pop(customInterface);
       
   153 
       
   154     return dopplerProxy;
       
   155 	}
       
   156 
       
   157 // -----------------------------------------------------------------------------
       
   158 // CSourceDoppler::NewL
       
   159 // Static function for creating an instance of the Doppler object.
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 EXPORT_C CSourceDoppler* CSourceDoppler::NewL(
       
   163 	CMdaAudioRecorderUtility& aUtility,
       
   164 	TBool aRecordStream )
       
   165 	{
       
   166 
       
   167     DEBPRN0;
       
   168    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility, aRecordStream);
       
   169     CleanupStack::PushL(customInterface);
       
   170 
       
   171 	CSourceDopplerProxy* dopplerProxy = (CSourceDopplerProxy*)customInterface->CustomInterface(KUidSourceDopplerEffect);
       
   172 
       
   173 	if ( !dopplerProxy )
       
   174 		{
       
   175 		DEBPRN1("No Adaptation Support - leaving");
       
   176 		User::Leave(KErrNotSupported);
       
   177 		}
       
   178 
       
   179 	CleanupStack::Pop(customInterface);
       
   180 
       
   181     return dopplerProxy;
       
   182 	}
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // CSourceDoppler::NewL
       
   186 // Static function for creating an instance of the Doppler object.
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 EXPORT_C CSourceDoppler* CSourceDoppler::NewL(
       
   190 	CMdaAudioToneUtility& aUtility )
       
   191 	{
       
   192 
       
   193 	DEBPRN0;
       
   194     CSourceDopplerProxy* dopplerProxy = (CSourceDopplerProxy*)aUtility.CustomInterface(KUidSourceDopplerEffect);
       
   195 
       
   196 	if (dopplerProxy == NULL)
       
   197 		{
       
   198         DEBPRN1("No Adaptation Support - leaving");
       
   199     	User::Leave(KErrNotSupported);
       
   200 		}
       
   201 
       
   202     return dopplerProxy;
       
   203 	}
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 // CSourceDoppler::NewL
       
   207 // Static function for creating an instance of the Doppler object.
       
   208 // -----------------------------------------------------------------------------
       
   209 //
       
   210 EXPORT_C CSourceDoppler* CSourceDoppler::NewL(
       
   211 	CMMFDevSound& aDevSound)
       
   212 	{
       
   213 
       
   214 	DEBPRN0;
       
   215     CSourceDopplerProxy* dopplerProxy = (CSourceDopplerProxy*)aDevSound.CustomInterface(KUidSourceDopplerEffect);
       
   216 
       
   217 	if (dopplerProxy == NULL)
       
   218 		{
       
   219         DEBPRN1("No Adaptation Support - leaving");
       
   220     	User::Leave(KErrNotSupported);
       
   221 		}
       
   222 
       
   223     return dopplerProxy;
       
   224 	}
       
   225 
       
   226 // -----------------------------------------------------------------------------
       
   227 // CSourceDoppler::NewL
       
   228 // Static function for creating an instance of the Doppler object.
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 EXPORT_C CSourceDoppler* CSourceDoppler::NewL(
       
   232 	CCustomCommandUtility* aUtility)
       
   233 	{
       
   234 
       
   235     DEBPRN0;
       
   236    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   237     CleanupStack::PushL(customInterface);
       
   238 
       
   239 	CSourceDopplerProxy* dopplerProxy = (CSourceDopplerProxy*)customInterface->CustomInterface(KUidSourceDopplerEffect);
       
   240 
       
   241 	if ( !dopplerProxy )
       
   242 		{
       
   243 		DEBPRN1("No Adaptation Support - leaving");
       
   244 		User::Leave(KErrNotSupported);
       
   245 		}
       
   246 
       
   247 	CleanupStack::Pop(customInterface);
       
   248 
       
   249     return dopplerProxy;
       
   250 	}
       
   251 
       
   252 // -----------------------------------------------------------------------------
       
   253 // CSourceDoppler::NewL
       
   254 // Static function for creating an instance of the Doppler object.
       
   255 // -----------------------------------------------------------------------------
       
   256 //
       
   257 EXPORT_C CSourceDoppler* CSourceDoppler::NewL(
       
   258 	MCustomInterface& aCustomInterface )
       
   259 	{
       
   260 
       
   261     DEBPRN0;
       
   262 	CSourceDopplerProxy* dopplerProxy = (CSourceDopplerProxy*)aCustomInterface.CustomInterface(KUidSourceDopplerEffect);
       
   263 
       
   264 	if ( !dopplerProxy )
       
   265 		{
       
   266 		DEBPRN1("No Adaptation Support - leaving");
       
   267 		User::Leave(KErrNotSupported);
       
   268 		}
       
   269 
       
   270     return dopplerProxy;
       
   271 	}
       
   272 
       
   273 // -----------------------------------------------------------------------------
       
   274 // CSourceDoppler::NewL
       
   275 // Static function for creating an instance of the Doppler object.
       
   276 // -----------------------------------------------------------------------------
       
   277 //
       
   278 EXPORT_C CSourceDoppler* CSourceDoppler::NewL(
       
   279 	CMidiClientUtility& aUtility )
       
   280 	{
       
   281 
       
   282     DEBPRN0;
       
   283    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   284     CleanupStack::PushL(customInterface);
       
   285 
       
   286 	CSourceDopplerProxy* dopplerProxy = (CSourceDopplerProxy*)customInterface->CustomInterface(KUidSourceDopplerEffect);
       
   287 
       
   288 	if ( !dopplerProxy )
       
   289 		{
       
   290 		DEBPRN1("No Adaptation Support - leaving");
       
   291 		User::Leave(KErrNotSupported);
       
   292 		}
       
   293 
       
   294 	CleanupStack::Pop(customInterface);
       
   295 
       
   296     return dopplerProxy;
       
   297 	}
       
   298 
       
   299 // -----------------------------------------------------------------------------
       
   300 // CSourceDoppler::NewL
       
   301 // Static function for creating an instance of the Doppler object.
       
   302 // -----------------------------------------------------------------------------
       
   303 //
       
   304 EXPORT_C CSourceDoppler* CSourceDoppler::NewL(
       
   305 	CDrmPlayerUtility& aUtility )
       
   306 	{
       
   307 
       
   308     DEBPRN0;
       
   309    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   310     CleanupStack::PushL(customInterface);
       
   311 
       
   312 	CSourceDopplerProxy* dopplerProxy = (CSourceDopplerProxy*)customInterface->CustomInterface(KUidSourceDopplerEffect);
       
   313 
       
   314 	if ( !dopplerProxy )
       
   315 		{
       
   316 		DEBPRN1("No Adaptation Support - leaving");
       
   317 		User::Leave(KErrNotSupported);
       
   318 		}
       
   319 
       
   320 	CleanupStack::Pop(customInterface);
       
   321 
       
   322     return dopplerProxy;
       
   323 	}
       
   324 
       
   325 // -----------------------------------------------------------------------------
       
   326 // CSourceDoppler::NewL
       
   327 // Static function for creating an instance of the Doppler object.
       
   328 // -----------------------------------------------------------------------------
       
   329 //
       
   330 EXPORT_C CSourceDoppler* CSourceDoppler::NewL(
       
   331 	CVideoPlayerUtility& aUtility )
       
   332 	{
       
   333 
       
   334     DEBPRN0;
       
   335    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   336     CleanupStack::PushL(customInterface);
       
   337 
       
   338 	CSourceDopplerProxy* dopplerProxy = (CSourceDopplerProxy*)customInterface->CustomInterface(KUidSourceDopplerEffect);
       
   339 
       
   340 	if ( !dopplerProxy )
       
   341 		{
       
   342 		DEBPRN1("No Adaptation Support - leaving");
       
   343 		User::Leave(KErrNotSupported);
       
   344 		}
       
   345 
       
   346 	CleanupStack::Pop(customInterface);
       
   347 
       
   348     return dopplerProxy;
       
   349 	}
       
   350 
       
   351 // -----------------------------------------------------------------------------
       
   352 // CSourceDoppler::Uid
       
   353 // -----------------------------------------------------------------------------
       
   354 //
       
   355 EXPORT_C TUid CSourceDoppler::Uid() const
       
   356 	{
       
   357 	return KUidSourceDopplerEffect;
       
   358 	}
       
   359 
       
   360 
       
   361 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   362 
       
   363 // End of File