mmfenh/advancedaudiocontroller/audiotonecontrollerplugin/src/mmfaudiotonecontroller.cpp
changeset 31 8dfd592727cb
parent 22 128eb6a32b84
child 48 a493a607b5bf
equal deleted inserted replaced
22:128eb6a32b84 31:8dfd592727cb
   112 @internalComponent
   112 @internalComponent
   113 */
   113 */
   114 void CMMFAudioToneController::ConstructL()
   114 void CMMFAudioToneController::ConstructL()
   115 	{
   115 	{
   116 	iSourceAndSinkAdded = EFalse;
   116 	iSourceAndSinkAdded = EFalse;
       
   117     iDataSink           = NULL;
   117 
   118 
   118 	// Construct custom command parsers
   119 	// Construct custom command parsers
   119 	CMMFAudioPlayDeviceCustomCommandParser* audPlayDevParser = CMMFAudioPlayDeviceCustomCommandParser::NewL(*this);
   120 	CMMFAudioPlayDeviceCustomCommandParser* audPlayDevParser = CMMFAudioPlayDeviceCustomCommandParser::NewL(*this);
   120 	CleanupStack::PushL(audPlayDevParser);
   121 	CleanupStack::PushL(audPlayDevParser);
   121 	AddCustomCommandParserL(*audPlayDevParser);
   122 	AddCustomCommandParserL(*audPlayDevParser);
   136     
   137     
   137     if (iFactory)
   138     if (iFactory)
   138         {
   139         {
   139         User::LeaveIfError(iFactory->CreateAudioOutputControlUtility(iAudioOutputControlUtility));                
   140         User::LeaveIfError(iFactory->CreateAudioOutputControlUtility(iAudioOutputControlUtility));                
   140         }    
   141         }    
   141 //end drm cr
   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 	
   142 	// [ assert the invariant now that we are constructed ]
   151 	// [ assert the invariant now that we are constructed ]
   143 	__ASSERT_ALWAYS( Invariant(), Panic( EStateNotConstructed));
   152 	__ASSERT_ALWAYS( Invariant(), Panic( EStateNotConstructed));
   144 	}
   153 	}
   145 
   154 
   146 
   155 
   233 		User::Leave(KErrAlreadyExists);
   242 		User::Leave(KErrAlreadyExists);
   234 
   243 
   235 	//Only support playing to audio output 
   244 	//Only support playing to audio output 
   236 	if (aSink.DataSinkType() != KUidMmfAudioOutput)
   245 	if (aSink.DataSinkType() != KUidMmfAudioOutput)
   237 		User::Leave( KErrNotSupported );
   246 		User::Leave( KErrNotSupported );
       
   247 			
       
   248 			
       
   249     iDataSink = &aSink;
   238 
   250 
   239 	iMMFDevSound = CMMFDevSound::NewL();
   251 	iMMFDevSound = CMMFDevSound::NewL();
   240 
   252 
   241 	// [ assert post conditions that a sink has been added ]
   253 	// [ assert post conditions that a sink has been added ]
   242 	__ASSERT_ALWAYS(iMMFDevSound, Panic(EMMFAudioControllerPanicDataSinkDoesNotExist));
   254 	__ASSERT_ALWAYS(iMMFDevSound, Panic(EMMFAudioControllerPanicDataSinkDoesNotExist));
   278 			delete iMessage;
   290 			delete iMessage;
   279 			iMessage = NULL;
   291 			iMessage = NULL;
   280 			User::Leave(err);
   292 			User::Leave(err);
   281 			}
   293 			}
   282 		}
   294 		}
       
   295 		
       
   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 	   
   283 	// for drm CR/Error 417-45879/ESLM-82JAHL
   311 	// for drm CR/Error 417-45879/ESLM-82JAHL
   284     if (iDataSource->DataSourceType()==KUidMmfFileSource)
   312     if (iDataSource->DataSourceType()==KUidMmfFileSource)
   285         {
   313         {
   286         CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
   314         CMMFFile* file = static_cast<CMMFFile*>(iDataSource);
   287         
   315         
   379 	            {
   407 	            {
   380 	            iAudioOutputControlUtility->Configure(*iMMFDevSound);    //ignoring errors since rouitng changes are only suggestions to adaptation
   408 	            iAudioOutputControlUtility->Configure(*iMMFDevSound);    //ignoring errors since rouitng changes are only suggestions to adaptation
   381 	            }
   409 	            }
   382 	        }
   410 	        }
   383 	
   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 	
   384 	if(State() == EPausePlaying && iIsResumeSupported)
   424 	if(State() == EPausePlaying && iIsResumeSupported)
   385 		{
   425 		{
   386 		User::LeaveIfError(iMMFDevSound->Resume());
   426 		User::LeaveIfError(iMMFDevSound->Resume());
   387 		}
   427 		}
   388 	else
   428 	else
   412 	//[ assert the invariant ]
   452 	//[ assert the invariant ]
   413 	__ASSERT_ALWAYS( Invariant(), Panic(EBadStateToPause));
   453 	__ASSERT_ALWAYS( Invariant(), Panic(EBadStateToPause));
   414 
   454 
   415 	__ASSERT_ALWAYS(iMMFDevSound, Panic(EMMFAudioControllerPanicDataSinkDoesNotExist));
   455 	__ASSERT_ALWAYS(iMMFDevSound, Panic(EMMFAudioControllerPanicDataSinkDoesNotExist));
   416 
   456 
       
   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 	    }
   417 	if(iIsResumeSupported)
   469 	if(iIsResumeSupported)
   418 		{
   470 		{
   419 		iMMFDevSound->Pause();
   471 		iMMFDevSound->Pause();
   420 		SetState(EPausePlaying);
   472 		SetState(EPausePlaying);
   421 		}
   473 		}
   448 	// [ precondition that we are not already stopped 
   500 	// [ precondition that we are not already stopped 
   449 	// && if we are stopped do nothing.
   501 	// && if we are stopped do nothing.
   450 	// Due to the asynchronous nature of the controller
   502 	// Due to the asynchronous nature of the controller
   451 	// interaction the response to stopped when stopped 
   503 	// interaction the response to stopped when stopped 
   452 	// should not be an error ]
   504 	// 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 	   }
   453 	if (State() != EStopped)
   518 	if (State() != EStopped)
   454 		{
   519 		{
   455 		//[ update state to stopped propogate to devsound ]
   520 		//[ update state to stopped propogate to devsound ]
   456 		iMMFDevSound->Stop();
   521 		iMMFDevSound->Stop();
   457 		SetState(EStopped);
   522 		SetState(EStopped);
  1059 			err = KErrNotSupported;
  1124 			err = KErrNotSupported;
  1060 			}
  1125 			}
  1061 		}
  1126 		}
  1062 	return err;
  1127 	return err;
  1063 	}
  1128 	}
       
  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