mmfenh/advancedaudiocontroller/audiotonecontrollerplugin/src/mmfaudiotonecontroller.cpp
branchRCL_3
changeset 46 0ac9a5310753
parent 45 095bea5f582e
child 54 53984cc2f70a
equal deleted inserted replaced
45:095bea5f582e 46:0ac9a5310753
    20 #include <mmfcontrollerimplementationuids.hrh>
    20 #include <mmfcontrollerimplementationuids.hrh>
    21 #include <mmf/common/mmffourcc.h>
    21 #include <mmf/common/mmffourcc.h>
    22 #include <mmf/common/mmfpaniccodes.h>
    22 #include <mmf/common/mmfpaniccodes.h>
    23 #include "mmfaudiotonecontroller.h"
    23 #include "mmfaudiotonecontroller.h"
    24 #include <mmf/server/mmfaudiooutput.h>
    24 #include <mmf/server/mmfaudiooutput.h>
    25 #include <ConfigurationComponentsFactory.h>
       
    26 #include <AudioOutputControlUtility.h>
       
    27 #include <mmf/server/mmffile.h>
       
    28 
    25 
    29 /*
    26 /*
    30  A list of panic codes for the Audio Tone Controller
    27  A list of panic codes for the Audio Tone Controller
    31 @internalTechnology
    28 @internalTechnology
    32 
    29 
   112 @internalComponent
   109 @internalComponent
   113 */
   110 */
   114 void CMMFAudioToneController::ConstructL()
   111 void CMMFAudioToneController::ConstructL()
   115 	{
   112 	{
   116 	iSourceAndSinkAdded = EFalse;
   113 	iSourceAndSinkAdded = EFalse;
   117     iDataSink           = NULL;
       
   118 
   114 
   119 	// Construct custom command parsers
   115 	// Construct custom command parsers
   120 	CMMFAudioPlayDeviceCustomCommandParser* audPlayDevParser = CMMFAudioPlayDeviceCustomCommandParser::NewL(*this);
   116 	CMMFAudioPlayDeviceCustomCommandParser* audPlayDevParser = CMMFAudioPlayDeviceCustomCommandParser::NewL(*this);
   121 	CleanupStack::PushL(audPlayDevParser);
   117 	CleanupStack::PushL(audPlayDevParser);
   122 	AddCustomCommandParserL(*audPlayDevParser);
   118 	AddCustomCommandParserL(*audPlayDevParser);
   129 	
   125 	
   130 	CMMFAudioPlayControllerSetRepeatsCustomCommandParser* audPlayConSetRepeatsParser = CMMFAudioPlayControllerSetRepeatsCustomCommandParser::NewL(*this);
   126 	CMMFAudioPlayControllerSetRepeatsCustomCommandParser* audPlayConSetRepeatsParser = CMMFAudioPlayControllerSetRepeatsCustomCommandParser::NewL(*this);
   131 	CleanupStack::PushL(audPlayConSetRepeatsParser);
   127 	CleanupStack::PushL(audPlayConSetRepeatsParser);
   132 	AddCustomCommandParserL(*audPlayConSetRepeatsParser);
   128 	AddCustomCommandParserL(*audPlayConSetRepeatsParser);
   133 	CleanupStack::Pop(audPlayConSetRepeatsParser);
   129 	CleanupStack::Pop(audPlayConSetRepeatsParser);
   134 	// for drm CR/Error 417-45879/ESLM-82JAHL
       
   135     TInt err = CConfigurationComponentsFactory::CreateFactoryL(iFactory);
       
   136     User::LeaveIfError(err);    
       
   137     
       
   138     if (iFactory)
       
   139         {
       
   140         User::LeaveIfError(iFactory->CreateAudioOutputControlUtility(iAudioOutputControlUtility));                
       
   141         }    
       
   142  //end drm cr
       
   143    
       
   144    
       
   145   //For Error : Update s60 tone controller to update the DRM rights 
       
   146   CMMFDRMCustomCommandParser* drmParser = CMMFDRMCustomCommandParser::NewL(*this);
       
   147 	CleanupStack::PushL(drmParser);
       
   148 	AddCustomCommandParserL(*drmParser);
       
   149 	CleanupStack::Pop(drmParser);
       
   150 	
   130 	
   151 	// [ assert the invariant now that we are constructed ]
   131 	// [ assert the invariant now that we are constructed ]
   152 	__ASSERT_ALWAYS( Invariant(), Panic( EStateNotConstructed));
   132 	__ASSERT_ALWAYS( Invariant(), Panic( EStateNotConstructed));
   153 	}
   133 	}
   154 
   134 
   168 
   148 
   169 @internalTechnology
   149 @internalTechnology
   170 */
   150 */
   171 CMMFAudioToneController::~CMMFAudioToneController()
   151 CMMFAudioToneController::~CMMFAudioToneController()
   172 	{
   152 	{
   173     delete iAudioOutputControlUtility;
       
   174     delete iFactory;
       
   175 	delete iMMFDevSound;
   153 	delete iMMFDevSound;
   176 	delete iToneSequenceData;
   154 	delete iToneSequenceData;
   177 	delete iMessage;
   155 	delete iMessage;
   178 	}
   156 	}
   179 
   157 
   242 		User::Leave(KErrAlreadyExists);
   220 		User::Leave(KErrAlreadyExists);
   243 
   221 
   244 	//Only support playing to audio output 
   222 	//Only support playing to audio output 
   245 	if (aSink.DataSinkType() != KUidMmfAudioOutput)
   223 	if (aSink.DataSinkType() != KUidMmfAudioOutput)
   246 		User::Leave( KErrNotSupported );
   224 		User::Leave( KErrNotSupported );
   247 			
       
   248 			
       
   249     iDataSink = &aSink;
       
   250 
   225 
   251 	iMMFDevSound = CMMFDevSound::NewL();
   226 	iMMFDevSound = CMMFDevSound::NewL();
   252 
   227 
   253 	// [ assert post conditions that a sink has been added ]
   228 	// [ assert post conditions that a sink has been added ]
   254 	__ASSERT_ALWAYS(iMMFDevSound, Panic(EMMFAudioControllerPanicDataSinkDoesNotExist));
   229 	__ASSERT_ALWAYS(iMMFDevSound, Panic(EMMFAudioControllerPanicDataSinkDoesNotExist));
   290 			delete iMessage;
   265 			delete iMessage;
   291 			iMessage = NULL;
   266 			iMessage = NULL;
   292 			User::Leave(err);
   267 			User::Leave(err);
   293 			}
   268 			}
   294 		}
   269 		}
   295 		
   270 	
   296 	//For Error : Update s60 tone controller to update the DRM rights 
       
   297 	 if (iDataSource->DataSourceType()==KUidMmfFileSource)
       
   298        {
       
   299        CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
       
   300        // we only support protected files for playback
       
   301        if (file->IsProtectedL())
       
   302            {
       
   303            if (iDataSink->DataSinkType()!=KUidMmfAudioOutput)
       
   304              {       
       
   305                // Conversion is not allowed for DRM protected files
       
   306                User::Leave(KErrNotSupported);
       
   307               }        
       
   308            }
       
   309        }
       
   310 	   
       
   311 	// for drm CR/Error 417-45879/ESLM-82JAHL
       
   312     if (iDataSource->DataSourceType()==KUidMmfFileSource)
       
   313         {
       
   314         CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
       
   315         
       
   316         if (file->IsProtectedL())
       
   317             {
       
   318             User::LeaveIfError(iAudioOutputControlUtility->SetDataSource(iDataSource));
       
   319             }         
       
   320         }
       
   321 	   // end drm cr
       
   322 	__ASSERT_ALWAYS( Invariant(), Panic( EStateNotPrimed ) );
   271 	__ASSERT_ALWAYS( Invariant(), Panic( EStateNotPrimed ) );
   323 
   272 
   324 	}
   273 	}
   325 
   274 
   326 /**
   275 /**
   395 	if ( State() != EPrimed && State() != EPausePlaying)
   344 	if ( State() != EPrimed && State() != EPausePlaying)
   396 		User::Leave(KErrNotReady);
   345 		User::Leave(KErrNotReady);
   397 
   346 
   398 	// [ assert the Invariant ]
   347 	// [ assert the Invariant ]
   399 	__ASSERT_ALWAYS( Invariant(), Panic(EStateNotReadyToPlay));
   348 	__ASSERT_ALWAYS( Invariant(), Panic(EStateNotReadyToPlay));
   400         // for drm CR/Error 417-45879/ESLM-82JAHL
   349 
   401 	   //configure Devsound with output restriction for a DRM protected file
       
   402 	    if (iDataSource->DataSourceType()==KUidMmfFileSource)
       
   403 	        {
       
   404 	        CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
       
   405 	        
       
   406 	        if (file->IsProtectedL())
       
   407 	            {
       
   408 	            iAudioOutputControlUtility->Configure(*iMMFDevSound);    //ignoring errors since rouitng changes are only suggestions to adaptation
       
   409 	            }
       
   410 	        }
       
   411 	
       
   412 	//For Error : Update s60 tone controller to update the DRM rights 
       
   413 	//Getting the Intent for Play if AutomaticIntent is Enabled		
       
   414 	if (!iDisableAutoIntent && iDataSource->DataSourceType()==KUidMmfFileSource)
       
   415 	   {
       
   416 	   CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
       
   417 	   TInt err = file->ExecuteIntent(ContentAccess::EPlay);
       
   418 	   if (err != KErrNone)
       
   419 	      {
       
   420 	      User::LeaveIfError(err);
       
   421 	      }
       
   422 	   }
       
   423 	
       
   424 	if(State() == EPausePlaying && iIsResumeSupported)
   350 	if(State() == EPausePlaying && iIsResumeSupported)
   425 		{
   351 		{
   426 		User::LeaveIfError(iMMFDevSound->Resume());
   352 		User::LeaveIfError(iMMFDevSound->Resume());
   427 		}
   353 		}
   428 	else
   354 	else
   452 	//[ assert the invariant ]
   378 	//[ assert the invariant ]
   453 	__ASSERT_ALWAYS( Invariant(), Panic(EBadStateToPause));
   379 	__ASSERT_ALWAYS( Invariant(), Panic(EBadStateToPause));
   454 
   380 
   455 	__ASSERT_ALWAYS(iMMFDevSound, Panic(EMMFAudioControllerPanicDataSinkDoesNotExist));
   381 	__ASSERT_ALWAYS(iMMFDevSound, Panic(EMMFAudioControllerPanicDataSinkDoesNotExist));
   456 
   382 
   457    //For Error : Update s60 tone controller to update the DRM rights 
       
   458 	 //Getting the Intent for Pause if AutomaticIntent is Enabled
       
   459      if (!iDisableAutoIntent && iDataSource->DataSourceType()==KUidMmfFileSource)
       
   460 	    {
       
   461 	    CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
       
   462 	    TInt err = file->ExecuteIntent(ContentAccess::EPause);
       
   463 	
       
   464 	    if (err != KErrNone)
       
   465 	       {
       
   466 	        User::LeaveIfError(err);
       
   467 	       }
       
   468 	    }
       
   469 	if(iIsResumeSupported)
   383 	if(iIsResumeSupported)
   470 		{
   384 		{
   471 		iMMFDevSound->Pause();
   385 		iMMFDevSound->Pause();
   472 		SetState(EPausePlaying);
   386 		SetState(EPausePlaying);
   473 		}
   387 		}
   500 	// [ precondition that we are not already stopped 
   414 	// [ precondition that we are not already stopped 
   501 	// && if we are stopped do nothing.
   415 	// && if we are stopped do nothing.
   502 	// Due to the asynchronous nature of the controller
   416 	// Due to the asynchronous nature of the controller
   503 	// interaction the response to stopped when stopped 
   417 	// interaction the response to stopped when stopped 
   504 	// should not be an error ]
   418 	// should not be an error ]
   505     
       
   506 	
       
   507 	//For Error : Update s60 tone controller to update the DRM rights 
       
   508 	//Getting the Intent for Stop if AutomaticIntent is Enabled
       
   509     if (!iDisableAutoIntent && iDataSource->DataSourceType()==KUidMmfFileSource)
       
   510 	   {
       
   511 	   CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
       
   512 	   TInt err = file->ExecuteIntent(ContentAccess::EStop);
       
   513 	      if (err != KErrNone)
       
   514 		    {
       
   515 			 User::LeaveIfError(err);
       
   516 			}
       
   517 	   }
       
   518 	if (State() != EStopped)
   419 	if (State() != EStopped)
   519 		{
   420 		{
   520 		//[ update state to stopped propogate to devsound ]
   421 		//[ update state to stopped propogate to devsound ]
   521 		iMMFDevSound->Stop();
   422 		iMMFDevSound->Stop();
   522 		SetState(EStopped);
   423 		SetState(EStopped);
  1124 			err = KErrNotSupported;
  1025 			err = KErrNotSupported;
  1125 			}
  1026 			}
  1126 		}
  1027 		}
  1127 	return err;
  1028 	return err;
  1128 	}
  1029 	}
  1129 
       
  1130 //For Error : Update s60 tone controller to update the DRM rights 
       
  1131 //Methods from MMMFDRMCustomCommandImplementor
       
  1132 //Checking for the Intents if AutomaticIntent is Disabled
       
  1133 
       
  1134 TInt CMMFAudioToneController::MdcExecuteIntent(ContentAccess::TIntent aIntent)
       
  1135     {
       
  1136     
       
  1137     if (iDataSource->DataSourceType()==KUidMmfFileSource)
       
  1138          {
       
  1139          CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
       
  1140          TInt err = file->ExecuteIntent(aIntent);
       
  1141          return err;
       
  1142          }
       
  1143     else
       
  1144          {
       
  1145          // Evaluating intent will always succeed on sinks that 
       
  1146          // don't support DRM
       
  1147          return KErrNone;
       
  1148          }   
       
  1149     
       
  1150     }
       
  1151 
       
  1152 TInt CMMFAudioToneController::MdcEvaluateIntent(ContentAccess::TIntent aIntent)
       
  1153     {
       
  1154     if (iDataSource->DataSourceType()==KUidMmfFileSource)
       
  1155          {
       
  1156          CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
       
  1157          TInt err = file->EvaluateIntent(aIntent);
       
  1158          return err;
       
  1159          }
       
  1160     else
       
  1161          {
       
  1162          // Evaluating intent will always succeed on sinks that 
       
  1163          // don't support DRM
       
  1164          return KErrNone;
       
  1165          } 
       
  1166       }
       
  1167 
       
  1168 TInt CMMFAudioToneController::MdcDisableAutomaticIntent(TBool aDisableAutoIntent)
       
  1169     {
       
  1170     iDisableAutoIntent = aDisableAutoIntent;
       
  1171     return KErrNone;
       
  1172     }
       
  1173     
       
  1174     
       
  1175 TInt CMMFAudioToneController::MdcSetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue)
       
  1176     {
       
  1177     if (iDataSource->DataSourceType()==KUidMmfFileSource)
       
  1178         {
       
  1179         CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
       
  1180         TInt err = file->SetAgentProperty(aProperty, aValue);
       
  1181         return err;
       
  1182         }
       
  1183     else
       
  1184         {
       
  1185         return KErrNone;
       
  1186         }
       
  1187     }
       
  1188