mmfenh/audiooutputcontrolutility/AudioOutputControlUtilityProxy/src/AudioOutputControlUtilityProxyImpl.cpp
changeset 0 71ca22bcf22a
child 12 2eb3b066cc7d
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2007 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:  This is the implementation of the CAudioOutputControlUtilityProxy class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32svr.h>
       
    22 #include "AudioOutputControlUtilityProxyImpl.h"
       
    23 #include "DRMConfigTypes.h"
       
    24 #include "DRMConfigIntfc.h"
       
    25 #include <RestrictedAudioOutput.h>
       
    26 #include <platform/mw/drmagents.h>
       
    27 #include <mmf/server/mmffile.h>
       
    28 #include <MultimediaDataSource.h>
       
    29 
       
    30 using namespace ContentAccess;
       
    31 using namespace DRM;
       
    32 #ifdef _DEBUG
       
    33 #define DEBPRN0(str)                RDebug::Print(str, this)
       
    34 #define DEBPRN1(str)    RDebug::Printf( "%s %s", __PRETTY_FUNCTION__, str );
       
    35 #else
       
    36 #define DEBPRN0
       
    37 #define DEBPRN1(str)
       
    38 #endif
       
    39 
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CAudioOutputControlUtilityProxyImpl::CAudioOutputControlUtilityProxyImpl
       
    43 // C++ default constructor can NOT contain any code, that
       
    44 // might leave.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CAudioOutputControlUtilityProxyImpl::CAudioOutputControlUtilityProxyImpl()
       
    48     {
       
    49 	DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl[0x%x]::CAudioOutputControlUtilityProxyImpl\n"));
       
    50 	iRestrictedAudioOutput = NULL;
       
    51 	iDRMConfigIntfc = NULL;
       
    52 	iAudioOutput = NULL;
       
    53 	iFactory = NULL;
       
    54     iMMDataSource = NULL;
       
    55     iDataSource = NULL;
       
    56     }
       
    57 
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CAudioOutputControlUtilityProxyImpl::ConstructL
       
    61 // Symbian 2nd phase constructor can leave.
       
    62 // assumes that iParent has already been set up properly
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 void CAudioOutputControlUtilityProxyImpl::ConstructL()
       
    66     {
       
    67     }
       
    68 
       
    69 
       
    70 // Two-phased constructor.
       
    71 CAudioOutputControlUtilityProxyImpl* CAudioOutputControlUtilityProxyImpl::NewL()
       
    72 	{	    
       
    73 	CAudioOutputControlUtilityProxyImpl* self = new(ELeave) CAudioOutputControlUtilityProxyImpl();
       
    74 	CleanupStack::PushL(self);
       
    75 	self->ConstructL();
       
    76 	CleanupStack::Pop(self);
       
    77 	return self;  
       
    78 
       
    79     }
       
    80     
       
    81 // -----------------------------------------------------------------------------
       
    82 // CAudioOutputControlUtilityProxyImpl::~CAudioOutputControlUtilityProxyImpl
       
    83 // Destructor
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 CAudioOutputControlUtilityProxyImpl::~CAudioOutputControlUtilityProxyImpl()
       
    87     {
       
    88 	DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl[0x%x]::~CAudioOutputControlUtilityProxyImpl\n"));
       
    89 	
       
    90 	if (iRestrictedAudioOutput)
       
    91 		delete iRestrictedAudioOutput;
       
    92 	if (iDRMConfigIntfc)
       
    93 		delete iDRMConfigIntfc;
       
    94 	if (iAudioOutput)
       
    95 		delete iAudioOutput;
       
    96 	if (iFactory)
       
    97 		delete iFactory;
       
    98 	if (iDataSource)
       
    99 	    iDataSource = NULL;		// dont own iDataSource
       
   100 	if (iMMDataSource)
       
   101 	    iMMDataSource = NULL;	// dont own iMMDataSource
       
   102     } 
       
   103        
       
   104 // ---------------------------------------------------------
       
   105 // CAudioOutputControlUtilityProxyImpl::Configure
       
   106 // configures the adapatation to use allowed outputs through CRestrictedAudioOutput 
       
   107 // or CAudioOutput in case the former doesn't work
       
   108 // (other items were commented in a header).
       
   109 // ---------------------------------------------------------
       
   110 //
       
   111 TInt CAudioOutputControlUtilityProxyImpl::Configure(CMMFDevSound& aDevSound)
       
   112     {
       
   113 #ifdef _DEBUG    
       
   114 	RDebug::Print(_L("CAudioOutputControlUtilityProxyImpl::Configure\n")); 
       
   115 #endif      
       
   116 	TInt err = KErrNotSupported;
       
   117   
       
   118     if (iFactory)
       
   119         {
       
   120         delete iFactory;
       
   121         iFactory = NULL;
       
   122         }
       
   123     if (iRestrictedAudioOutput)
       
   124         {
       
   125         delete iRestrictedAudioOutput;
       
   126         iRestrictedAudioOutput = NULL;
       
   127         }
       
   128               
       
   129     TRAP(err,CConfigurationComponentsFactory::CreateFactoryL(iFactory));
       
   130 	if (err == KErrNone) 
       
   131     	{
       
   132     	//iFactory constructed
       
   133     	CleanupStack::PushL(iFactory);
       
   134     	
       
   135 	    err = iFactory->CreateRestrictedAudioOutput(aDevSound, iRestrictedAudioOutput);
       
   136 	    if(err == KErrNone)
       
   137 	        {
       
   138 	        //iRestrictedAudioOutput constructed
       
   139             CleanupStack::PushL(iRestrictedAudioOutput);
       
   140             DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::Configure - after creating iRestrictedAudioOutput"));
       
   141 	        }
       
   142 	    else
       
   143 	        {
       
   144             //cleanup iFactory
       
   145             CleanupStack::PopAndDestroy(iFactory);
       
   146             iFactory = NULL;
       
   147 	        }
       
   148 	    }
       
   149 
       
   150     // If error, resort to using audio output and CAudioOutput  
       
   151     if (err != KErrNone)
       
   152         {
       
   153         if (iAudioOutput)
       
   154             {
       
   155             delete iAudioOutput;
       
   156             iAudioOutput = NULL;
       
   157             }
       
   158         TRAP(err, iAudioOutput = CAudioOutput::NewL(aDevSound));
       
   159         if (err == KErrNone)
       
   160             {
       
   161             //iAudioOutput constructed
       
   162             CleanupStack::PushL(iAudioOutput);
       
   163             
       
   164             DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::Configure - iAudioOutput created")); 
       
   165             TRAP(err, iAudioOutput->SetSecureOutputL(ETrue));
       
   166             if(err == KErrNone)
       
   167                 CleanupStack::Pop(iAudioOutput);
       
   168             else
       
   169                 CleanupStack::PopAndDestroy(iAudioOutput);
       
   170             }
       
   171         return err;
       
   172         }
       
   173 
       
   174     //RestrictedAudioOutput created successfully
       
   175     //EMC sources
       
   176     if (iMMDataSource)
       
   177         {
       
   178         DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::Configure - EMC sources"));
       
   179         //Get DRM config interface
       
   180         if(iDRMConfigIntfc)
       
   181 			{
       
   182           	delete  iDRMConfigIntfc;
       
   183           	iDRMConfigIntfc = NULL;
       
   184          	}
       
   185         TVersion version(KDRMConfigIntfcMajorVer1,KDRMConfigIntfcMinorVer1,KDRMConfigIntfcBuildVer1);
       
   186         err = iMMDataSource->GetInterface(KDRMConfigIntfc, version, (TAny*&)iDRMConfigIntfc);
       
   187         if (err == KErrNone)
       
   188             {
       
   189             //iDRMConfigIntfc constructed
       
   190             CleanupStack::PushL(iDRMConfigIntfc);
       
   191                     
       
   192             //Append allowed outputs in DRMConfigIntfc:
       
   193             TInt count(0);
       
   194             CRestrictedAudioOutput::TAllowedOutputPreference pref;  
       
   195             iDRMConfigIntfc->GetAllowedOutputDeviceCount(count);
       
   196             TDRMAllowedOutputDevice allowedDevice;
       
   197             for ( TInt index(0); index < count; index++ )
       
   198                 {
       
   199                 iDRMConfigIntfc->GetAllowedOutputDevice(index, allowedDevice);
       
   200                 err = CalcPref(allowedDevice, pref); 
       
   201                 if ( err == KErrNone )
       
   202                     {
       
   203                     err = iRestrictedAudioOutput->AppendAllowedOutput(pref);
       
   204                     if (err != KErrNone)
       
   205                         break;
       
   206                     }
       
   207                 else
       
   208                     {
       
   209                     break;
       
   210                     }
       
   211                 }//end for
       
   212             }
       
   213         }
       
   214      
       
   215     //MMF sources
       
   216     if (iDataSource)
       
   217         {
       
   218         DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::Configure - MMF sources"));
       
   219         ContentAccess::CData* data(NULL);
       
   220         static_cast<CMMFFile*>(iDataSource)->Data(data);
       
   221         
       
   222         //Obtain the bitmask for allowed outputs
       
   223         TInt value(0);
       
   224         err = data->GetAttribute(EDrmAllowedOutputs,value);
       
   225         
       
   226         //Append allowed outputs in value bitmask
       
   227         if(err == KErrNone)
       
   228             {
       
   229             err = SetCalculatedPreference(value);
       
   230             }
       
   231         }
       
   232 
       
   233     //Commit the outputs appended to RestrictedAudioOutput
       
   234     if(err == KErrNone)
       
   235         {
       
   236         err = iRestrictedAudioOutput->Commit();
       
   237         DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::Configure - iRestrictedAudioOutput->Commit"));
       
   238         }
       
   239     
       
   240     if(err == KErrNone)
       
   241         {
       
   242         if(iDRMConfigIntfc) 
       
   243             {
       
   244             //in case of EMC sources
       
   245             CleanupStack::Pop(iDRMConfigIntfc);
       
   246             }
       
   247         CleanupStack::Pop(iRestrictedAudioOutput);
       
   248         CleanupStack::Pop(iFactory);
       
   249         }
       
   250     else
       
   251         {
       
   252         if(iDRMConfigIntfc) 
       
   253             {
       
   254             //in case of EMC sources
       
   255             CleanupStack::PopAndDestroy(iDRMConfigIntfc);
       
   256             }
       
   257         CleanupStack::PopAndDestroy(iRestrictedAudioOutput);
       
   258         CleanupStack::PopAndDestroy(iFactory);
       
   259         }
       
   260         
       
   261     return err;
       
   262     }    
       
   263          
       
   264         
       
   265 // ---------------------------------------------------------
       
   266 // CAudioOutputControlUtilityProxyImpl::CalcPref
       
   267 // ?implementation_description
       
   268 // (other items were commented in a header).
       
   269 // ---------------------------------------------------------
       
   270 //
       
   271 /*
       
   272 CRestrictedAudioOutput::TAllowedOutputPreference CAudioOutputControlUtilityProxyImpl::CalcPref(TDRMAllowedOutputDevice aOutputDevice)
       
   273     {
       
   274 #ifdef _DEBUG    
       
   275  	RDebug::Print(_L("CalcPref: %d\n"), aOutputDevice); 
       
   276 #endif
       
   277  	   
       
   278  	CRestrictedAudioOutput::TAllowedOutputPreference pref = CRestrictedAudioOutput::EAllowAllAudio; //default
       
   279  	switch (aOutputDevice)
       
   280  	{
       
   281     	case EAudioAllowAll:
       
   282     	pref = CRestrictedAudioOutput::EAllowAllAudio;
       
   283     	break;
       
   284     	
       
   285     	case EAudioAllowAnalog:
       
   286     	pref = CRestrictedAudioOutput::EAllowAudioAnalog;
       
   287     	break;
       
   288     	
       
   289        	case EAudioAllowFMTx:
       
   290     	pref = CRestrictedAudioOutput::EAllowAudioFMTransmitter;
       
   291     	break;
       
   292     	
       
   293        	case EAudioAllowBTA2DP:
       
   294     	pref = CRestrictedAudioOutput::EAllowAudioBtA2DP;
       
   295     	break;
       
   296     	
       
   297      	case EAudioAllowBTHFP:
       
   298     	pref = CRestrictedAudioOutput::EAllowAudioStereoBtHFP;
       
   299     	break;
       
   300     	
       
   301     	case EAudioAllowUplink:
       
   302     	pref = CRestrictedAudioOutput::EAllowAudioUplink;
       
   303     	break;
       
   304     	
       
   305      	case EAudioAllowUSB:
       
   306     	pref = CRestrictedAudioOutput::EAllowAudioUsb;
       
   307     	break;
       
   308     	
       
   309     	case EAudioAllowRecording:
       
   310     	pref = CRestrictedAudioOutput::EAllowAudioRecording;
       
   311     	break;
       
   312     	
       
   313     	case EAudioAllowVisualization:
       
   314     	pref = CRestrictedAudioOutput::EAllowVisualization;
       
   315     	break; 
       
   316     
       
   317     	case EAudioAllowBTHSP:
       
   318     	//pref = CRestrictedAudioOutput::EAllowAudioBTHSP;
       
   319     	break;     	
       
   320     	default:
       
   321     	break;
       
   322  		
       
   323  	} // End switch
       
   324 
       
   325     	
       
   326     return pref;
       
   327     }  
       
   328 */
       
   329 TInt CAudioOutputControlUtilityProxyImpl::CalcPref(TDRMAllowedOutputDevice aOutputDevice, CRestrictedAudioOutput::TAllowedOutputPreference& aAllowedOutput)
       
   330     {
       
   331 #ifdef _DEBUG    
       
   332  	RDebug::Print(_L("CalcPref: %d\n"), aOutputDevice); 
       
   333 #endif
       
   334     TInt status(KErrNone);
       
   335  	   
       
   336  	switch (aOutputDevice)
       
   337  	    {
       
   338     	case EAudioAllowAll:
       
   339         	aAllowedOutput = CRestrictedAudioOutput::EAllowAllAudio;
       
   340         	break;
       
   341     	
       
   342     	case EAudioAllowAnalog:
       
   343         	aAllowedOutput = CRestrictedAudioOutput::EAllowAudioAnalog;
       
   344         	break;
       
   345     	
       
   346        	case EAudioAllowFMTx:
       
   347         	aAllowedOutput = CRestrictedAudioOutput::EAllowAudioFMTransmitter;
       
   348         	break;
       
   349     	
       
   350        	case EAudioAllowBTA2DP:
       
   351         	aAllowedOutput = CRestrictedAudioOutput::EAllowAudioBtA2DP;
       
   352         	break;
       
   353     	
       
   354      	case EAudioAllowBTHFPHSP:
       
   355         	aAllowedOutput = CRestrictedAudioOutput::EAllowAudioBtHFPHSP;
       
   356         	break;
       
   357     	
       
   358     	case EAudioAllowUplink:
       
   359         	aAllowedOutput = CRestrictedAudioOutput::EAllowAudioUplink;
       
   360         	break;
       
   361     	
       
   362      	case EAudioAllowUSB:
       
   363         	aAllowedOutput = CRestrictedAudioOutput::EAllowAudioUsb;
       
   364         	break;
       
   365     	
       
   366     	case EAudioAllowRecording:
       
   367         	aAllowedOutput = CRestrictedAudioOutput::EAllowAudioRecording;
       
   368         	break;
       
   369     	
       
   370     	case EAudioAllowVisualization:
       
   371         	aAllowedOutput = CRestrictedAudioOutput::EAllowVisualization;
       
   372         	break;
       
   373         /**
       
   374 		* RIM CR 417-7642: HDMI with HDCP to Resctricted Audio Output API
       
   375 		* Due to addition of new ENUMs to CRestrictedAudioOutput::TAllowedOutputPreference for HDMI and HDCP
       
   376 		* EAllowAudioHDMI and EAllowAudioHdmiHdcpRequired,the same is matched by adding
       
   377 		* EAudioAllowHDMI and EAudioAllowHdmiHdcpRequired
       
   378 		*/
       
   379         case EAudioAllowHDMI:
       
   380         	aAllowedOutput = CRestrictedAudioOutput::EAllowAudioHDMI;
       
   381         	break;
       
   382 
       
   383         case EAudioAllowHdmiHdcpRequired:
       
   384         	aAllowedOutput = CRestrictedAudioOutput::EAllowAudioHdmiHdcpRequired;
       
   385         	break;
       
   386 
       
   387 /*
       
   388     	case EAudioAllowBTHSP:
       
   389     	// For now CRestrictedAudioOutput maps EAudioAllowBTHSP and
       
   390     	// EAudioAllowBTHFP to EAllowAudioStereoBtHFP.
       
   391     	// SCB-CR VRAH-77THZ7. Once approved, uncomment the following line
       
   392     	// So until then, eat the enum and return KErrNone.
       
   393     	// WMDRM defines BT which is mapped by MW to A2DP, HFP, HSP
       
   394     	// MW maps A2DP, HFP, HSP to A2DB, HFP in CRestrictedAudioOutput
       
   395     	// So we don't loose any original restriction.
       
   396     	//aAllowedOutput = CRestrictedAudioOutput::EAllowAudioBTHSP;
       
   397     	break;     	
       
   398 */
       
   399     	default:
       
   400     	    status = KErrNotSupported;
       
   401     	    break;
       
   402  		
       
   403     	} // End switch
       
   404     return status;
       
   405     }  
       
   406 
       
   407 // ---------------------------------------------------------
       
   408 // CAudioOutputControlUtilityProxyImpl::CalcDrmAllowedOutputDevice
       
   409 // ?implementation_description
       
   410 // (other items were commented in a header).
       
   411 // ---------------------------------------------------------
       
   412 //
       
   413 /*****
       
   414 TDRMAllowedOutputDevice CAudioOutputControlUtilityProxyImpl::CalcDrmAllowedOutputDevice(CRestrictedAudioOutput::TAllowedOutputPreference aPref)
       
   415     {
       
   416 #ifdef _DEBUG    
       
   417  	RDebug::Print(_L("CalcDrmAllowedOutputDevice for: %d\n"), aPref); 
       
   418 #endif
       
   419  	   
       
   420  	TDRMAllowedOutputDevice device = EAudioAllowAll; //default
       
   421  	
       
   422  	switch (aPref)
       
   423  	{
       
   424     	case CRestrictedAudioOutput::EAllowAllAudio:
       
   425     	device = EAudioAllowAll;
       
   426     	break;
       
   427     	
       
   428     	case CRestrictedAudioOutput::EAllowAudioAnalog:
       
   429     	device = EAudioAllowAnalog;
       
   430     	break;
       
   431     	
       
   432        	case CRestrictedAudioOutput::EAllowAudioFMTransmitter:
       
   433        	device = EAudioAllowFMTx;
       
   434     	break;
       
   435     	
       
   436        	case CRestrictedAudioOutput::EAllowAudioBTA2DP:
       
   437        	device = EAudioAllowBTA2DP;
       
   438     	break;
       
   439     	
       
   440      	case CRestrictedAudioOutput::EAllowAudioBtHFPHSP:
       
   441      	device = EAudioAllowBTHFPHSP;
       
   442     	break;
       
   443     	
       
   444     	case CRestrictedAudioOutput::EAllowAudioUplink:
       
   445     	device = EAudioAllowUplink;
       
   446     	break;
       
   447     	
       
   448      	case CRestrictedAudioOutput::EAllowAudioUsb:
       
   449      	device = EAudioAllowUSB;
       
   450     	break;
       
   451     	
       
   452     	case CRestrictedAudioOutput::EAllowAudioRecording:
       
   453     	device = EAudioAllowRecording;
       
   454 	   	break;
       
   455     	
       
   456     	case CRestrictedAudioOutput::EAllowVisualization:
       
   457     	device = EAudioAllowVisualization;
       
   458        	break;   
       
   459        	
       
   460  		case CRestrictedAudioOutput::EAllowAudioBTHSP:
       
   461  		device = EAudioAllowBTHSP;
       
   462  		break;
       
   463     	
       
   464     	default:
       
   465     	break;
       
   466  		
       
   467  	} // End switch
       
   468 
       
   469     	
       
   470     return device;
       
   471     }    
       
   472 *****/
       
   473     
       
   474 // ---------------------------------------------------------
       
   475 // CAudioOutputControlUtilityProxyImpl::SetDRMConfigIntfc
       
   476 // ?implementation_description
       
   477 // (other items were commented in a header).
       
   478 // ---------------------------------------------------------
       
   479 //
       
   480 TInt CAudioOutputControlUtilityProxyImpl::SetDRMConfigIntfc(CDRMConfigIntfc* aDRMConfigIntfc)
       
   481     {
       
   482    	RDebug::Print(_L("CAudioOutputControlUtilityProxyImpl::SetDRMConfigIntfc"));    
       
   483     
       
   484     if(iDRMConfigIntfc)
       
   485 		{
       
   486 		delete 	iDRMConfigIntfc;
       
   487 		iDRMConfigIntfc = NULL;
       
   488 		}    
       
   489     
       
   490     iDRMConfigIntfc = aDRMConfigIntfc;
       
   491     return KErrNone;
       
   492     }   
       
   493     
       
   494 // ---------------------------------------------------------
       
   495 // CAudioOutputControlUtilityProxyImpl::ConfigureRestrictedAudioOutput
       
   496 // ?implementation_description
       
   497 // (other items were commented in a header).
       
   498 // ---------------------------------------------------------
       
   499 //
       
   500 TInt CAudioOutputControlUtilityProxyImpl::ConfigureRestrictedAudioOutputL(CMMFDevSound& aDevSound) 
       
   501 	{
       
   502 #ifdef _DEBUG 
       
   503   	RDebug::Print(_L("CAudioOutputControlUtilityProxyImpl::ConfigureRestrictedAudioOutput")); 
       
   504 #endif
       
   505   	
       
   506 	TInt err = CConfigurationComponentsFactory::CreateFactoryL(iFactory);
       
   507 	err = iFactory->CreateRestrictedAudioOutput(aDevSound, iRestrictedAudioOutput); 
       
   508 	
       
   509 	// If error, resort to using audio output and SetSecureOutput:  
       
   510  	if (err != KErrNone)
       
   511  	{
       
   512 		TRAP(err, iAudioOutput = CAudioOutput::NewL(aDevSound));
       
   513  		if (err == KErrNone) 
       
   514  		{
       
   515 			TRAP(err, iAudioOutput->SetSecureOutputL(ETrue)); 
       
   516  		}
       
   517  		else 
       
   518  			return err;
       
   519  	}
       
   520  	else
       
   521  	{
       
   522  			
       
   523 		// Append allowed outputs in DRMConfigIntfc:
       
   524   		TInt count(0);
       
   525   		CRestrictedAudioOutput::TAllowedOutputPreference pref;	
       
   526    		iDRMConfigIntfc->GetAllowedOutputDeviceCount(count);
       
   527   		TDRMAllowedOutputDevice allowedDevice;
       
   528   		for ( TInt index(0); index < count; index++ )
       
   529    		{
       
   530    			iDRMConfigIntfc->GetAllowedOutputDevice(index, allowedDevice);
       
   531 #ifdef _DEBUG    			
       
   532 RDebug::Print(_L("ConfigureRestrictedAudioOutput:DRMAllowedOutput[%d]=[%d]"), index, allowedDevice);
       
   533 #endif   			
       
   534    			//pref = CalcPref(allowedDevice);         
       
   535    			if ( CalcPref(allowedDevice, pref) == KErrNone )
       
   536    			{
       
   537      			err = iRestrictedAudioOutput->AppendAllowedOutput(pref);
       
   538      			if (err != KErrNone)
       
   539      				return err;
       
   540  			}
       
   541  			else
       
   542  			{
       
   543 #ifdef _DEBUG  
       
   544 RDebug::Print(_L("ConfigureRestrictedAudioOutput:DRMAllowedOutput err = %D"), err);
       
   545 #endif 
       
   546  			    return err;
       
   547     	    }
       
   548     	}
       
   549     	
       
   550     // Commit
       
   551   	err = iRestrictedAudioOutput->Commit();    	
       
   552  	}
       
   553     
       
   554     return err;
       
   555               	  	
       
   556 	}
       
   557 
       
   558 // ---------------------------------------------------------
       
   559 // CAudioOutputControlUtilityProxyImpl::SetDataSource
       
   560 // sets a MMF source to the utility
       
   561 // (other items were commented in a header).
       
   562 // ---------------------------------------------------------
       
   563 //
       
   564 TInt CAudioOutputControlUtilityProxyImpl::SetDataSource(MDataSource* aDataSource)
       
   565     {
       
   566     DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::SetDataSource for MMF"));    
       
   567     
       
   568     if(iDataSource)
       
   569         {
       
   570         iDataSource = NULL;
       
   571         }    
       
   572     
       
   573     iDataSource = aDataSource;
       
   574     return KErrNone;
       
   575     }   
       
   576 
       
   577 // ---------------------------------------------------------
       
   578 // CAudioOutputControlUtilityProxyImpl::SetDataSource
       
   579 // sets an EMC source to the utility
       
   580 // (other items were commented in a header).
       
   581 // ---------------------------------------------------------
       
   582 //
       
   583 TInt CAudioOutputControlUtilityProxyImpl::SetDataSource(CMultimediaDataSource* aDataSource)
       
   584     {
       
   585     DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::SetDataSource for EMC"));    
       
   586     
       
   587     if(iMMDataSource)
       
   588         {
       
   589         iMMDataSource = NULL;
       
   590         }    
       
   591     
       
   592     iMMDataSource = aDataSource;
       
   593     return KErrNone;
       
   594     }  
       
   595 
       
   596 // ---------------------------------------------------------
       
   597 // CAudioOutputControlUtilityProxyImpl::SetCalculatedPreference
       
   598 // obtains the allowed output from the passed bitmask and appends to RestrictedAudioOutput
       
   599 // (other items were commented in a header).
       
   600 // ---------------------------------------------------------
       
   601 //
       
   602 TInt CAudioOutputControlUtilityProxyImpl::SetCalculatedPreference(const TInt& aValue)
       
   603     {
       
   604     DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::SetCalcPref")); 
       
   605     TInt err = KErrNone;
       
   606     if(aValue == EDrmAllowAll)
       
   607         {
       
   608         err = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAllAudio);
       
   609         DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::SetCalcPref - EDrmAllowAll"));
       
   610         return err;
       
   611         }
       
   612     if(aValue & EDrmAllowAudioAnalog)
       
   613         {
       
   614         err = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioAnalog);
       
   615         if (err != KErrNone)
       
   616 			{
       
   617 			return err;
       
   618 			}
       
   619         DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::SetCalcPref - EDrmAllowAudioAnalog"));
       
   620         }
       
   621     if(aValue & EDrmAllowAudioFmTransmitter)
       
   622         {
       
   623         err = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioFMTransmitter);
       
   624         if (err != KErrNone)    
       
   625 			{
       
   626 			return err;
       
   627 			}
       
   628         DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::SetCalcPref - EDrmAllowAudioFmTransmitter"));
       
   629         }
       
   630     if(aValue & EDrmAllowAudioBluetooth)
       
   631         {
       
   632         err = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioBtA2DP);
       
   633         if (err != KErrNone)    
       
   634 			{
       
   635 			return err;
       
   636 			}
       
   637         err = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioBtHFPHSP);
       
   638         if (err != KErrNone)    
       
   639 			{
       
   640 			return err;
       
   641 			}
       
   642         DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::SetCalcPref - EDrmAllowAudioBluetooth"));
       
   643         }
       
   644     if(aValue & EDrmAllowAudioUplink)
       
   645         {
       
   646         err = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioUplink);
       
   647         if (err != KErrNone)    
       
   648 			{
       
   649 			return err;
       
   650 			}
       
   651         DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::SetCalcPref - EDrmAllowAudioUplink"));
       
   652         }
       
   653     if(aValue & EDrmAllowAudioUsb)
       
   654         {
       
   655         err = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioUsb);
       
   656         if (err != KErrNone)    
       
   657 			{
       
   658 			return err;
       
   659 			}
       
   660         DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::SetCalcPref - EDrmAllowAudioUsb"));
       
   661         }
       
   662     if(aValue & EDrmAllowAudioHdmi)
       
   663         {
       
   664         err = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioHDMI);
       
   665         if (err != KErrNone)    
       
   666             {
       
   667             return err;
       
   668             }
       
   669         DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::SetCalcPref - EDrmAllowAudioHdmi"));
       
   670         }
       
   671     if(aValue & EDrmAllowAudioHdmiHdcpRequired)
       
   672         {
       
   673         err = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioHdmiHdcpRequired);
       
   674         if (err != KErrNone)    
       
   675             {
       
   676             return err;
       
   677             }
       
   678         DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::SetCalcPref - EDrmAllowAudioHdmiHdcpRequired"));
       
   679         }
       
   680     DEBPRN0(_L("CAudioOutputControlUtilityProxyImpl::SetCalcPref"));
       
   681     return err;
       
   682     }
       
   683 // End of file
       
   684