mmfenh/advancedaudiocontroller/audiotonecontrollerplugin/src/mmfaudiotonecontroller.cpp
equal
deleted
inserted
replaced
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> |
25 |
28 |
26 /* |
29 /* |
27 A list of panic codes for the Audio Tone Controller |
30 A list of panic codes for the Audio Tone Controller |
28 @internalTechnology |
31 @internalTechnology |
29 |
32 |
109 @internalComponent |
112 @internalComponent |
110 */ |
113 */ |
111 void CMMFAudioToneController::ConstructL() |
114 void CMMFAudioToneController::ConstructL() |
112 { |
115 { |
113 iSourceAndSinkAdded = EFalse; |
116 iSourceAndSinkAdded = EFalse; |
|
117 iDataSink = NULL; |
114 |
118 |
115 // Construct custom command parsers |
119 // Construct custom command parsers |
116 CMMFAudioPlayDeviceCustomCommandParser* audPlayDevParser = CMMFAudioPlayDeviceCustomCommandParser::NewL(*this); |
120 CMMFAudioPlayDeviceCustomCommandParser* audPlayDevParser = CMMFAudioPlayDeviceCustomCommandParser::NewL(*this); |
117 CleanupStack::PushL(audPlayDevParser); |
121 CleanupStack::PushL(audPlayDevParser); |
118 AddCustomCommandParserL(*audPlayDevParser); |
122 AddCustomCommandParserL(*audPlayDevParser); |
125 |
129 |
126 CMMFAudioPlayControllerSetRepeatsCustomCommandParser* audPlayConSetRepeatsParser = CMMFAudioPlayControllerSetRepeatsCustomCommandParser::NewL(*this); |
130 CMMFAudioPlayControllerSetRepeatsCustomCommandParser* audPlayConSetRepeatsParser = CMMFAudioPlayControllerSetRepeatsCustomCommandParser::NewL(*this); |
127 CleanupStack::PushL(audPlayConSetRepeatsParser); |
131 CleanupStack::PushL(audPlayConSetRepeatsParser); |
128 AddCustomCommandParserL(*audPlayConSetRepeatsParser); |
132 AddCustomCommandParserL(*audPlayConSetRepeatsParser); |
129 CleanupStack::Pop(audPlayConSetRepeatsParser); |
133 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); |
130 |
150 |
131 // [ assert the invariant now that we are constructed ] |
151 // [ assert the invariant now that we are constructed ] |
132 __ASSERT_ALWAYS( Invariant(), Panic( EStateNotConstructed)); |
152 __ASSERT_ALWAYS( Invariant(), Panic( EStateNotConstructed)); |
133 } |
153 } |
134 |
154 |
148 |
168 |
149 @internalTechnology |
169 @internalTechnology |
150 */ |
170 */ |
151 CMMFAudioToneController::~CMMFAudioToneController() |
171 CMMFAudioToneController::~CMMFAudioToneController() |
152 { |
172 { |
|
173 delete iAudioOutputControlUtility; |
|
174 delete iFactory; |
153 delete iMMFDevSound; |
175 delete iMMFDevSound; |
154 delete iToneSequenceData; |
176 delete iToneSequenceData; |
155 delete iMessage; |
177 delete iMessage; |
156 } |
178 } |
157 |
179 |
220 User::Leave(KErrAlreadyExists); |
242 User::Leave(KErrAlreadyExists); |
221 |
243 |
222 //Only support playing to audio output |
244 //Only support playing to audio output |
223 if (aSink.DataSinkType() != KUidMmfAudioOutput) |
245 if (aSink.DataSinkType() != KUidMmfAudioOutput) |
224 User::Leave( KErrNotSupported ); |
246 User::Leave( KErrNotSupported ); |
|
247 |
|
248 |
|
249 iDataSink = &aSink; |
225 |
250 |
226 iMMFDevSound = CMMFDevSound::NewL(); |
251 iMMFDevSound = CMMFDevSound::NewL(); |
227 |
252 |
228 // [ assert post conditions that a sink has been added ] |
253 // [ assert post conditions that a sink has been added ] |
229 __ASSERT_ALWAYS(iMMFDevSound, Panic(EMMFAudioControllerPanicDataSinkDoesNotExist)); |
254 __ASSERT_ALWAYS(iMMFDevSound, Panic(EMMFAudioControllerPanicDataSinkDoesNotExist)); |
265 delete iMessage; |
290 delete iMessage; |
266 iMessage = NULL; |
291 iMessage = NULL; |
267 User::Leave(err); |
292 User::Leave(err); |
268 } |
293 } |
269 } |
294 } |
270 |
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 |
|
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 |
271 __ASSERT_ALWAYS( Invariant(), Panic( EStateNotPrimed ) ); |
322 __ASSERT_ALWAYS( Invariant(), Panic( EStateNotPrimed ) ); |
272 |
323 |
273 } |
324 } |
274 |
325 |
275 /** |
326 /** |
344 if ( State() != EPrimed && State() != EPausePlaying) |
395 if ( State() != EPrimed && State() != EPausePlaying) |
345 User::Leave(KErrNotReady); |
396 User::Leave(KErrNotReady); |
346 |
397 |
347 // [ assert the Invariant ] |
398 // [ assert the Invariant ] |
348 __ASSERT_ALWAYS( Invariant(), Panic(EStateNotReadyToPlay)); |
399 __ASSERT_ALWAYS( Invariant(), Panic(EStateNotReadyToPlay)); |
349 |
400 // for drm CR/Error 417-45879/ESLM-82JAHL |
|
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 |
350 if(State() == EPausePlaying && iIsResumeSupported) |
424 if(State() == EPausePlaying && iIsResumeSupported) |
351 { |
425 { |
352 User::LeaveIfError(iMMFDevSound->Resume()); |
426 User::LeaveIfError(iMMFDevSound->Resume()); |
353 } |
427 } |
354 else |
428 else |
378 //[ assert the invariant ] |
452 //[ assert the invariant ] |
379 __ASSERT_ALWAYS( Invariant(), Panic(EBadStateToPause)); |
453 __ASSERT_ALWAYS( Invariant(), Panic(EBadStateToPause)); |
380 |
454 |
381 __ASSERT_ALWAYS(iMMFDevSound, Panic(EMMFAudioControllerPanicDataSinkDoesNotExist)); |
455 __ASSERT_ALWAYS(iMMFDevSound, Panic(EMMFAudioControllerPanicDataSinkDoesNotExist)); |
382 |
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 } |
383 if(iIsResumeSupported) |
469 if(iIsResumeSupported) |
384 { |
470 { |
385 iMMFDevSound->Pause(); |
471 iMMFDevSound->Pause(); |
386 SetState(EPausePlaying); |
472 SetState(EPausePlaying); |
387 } |
473 } |
414 // [ precondition that we are not already stopped |
500 // [ precondition that we are not already stopped |
415 // && if we are stopped do nothing. |
501 // && if we are stopped do nothing. |
416 // Due to the asynchronous nature of the controller |
502 // Due to the asynchronous nature of the controller |
417 // interaction the response to stopped when stopped |
503 // interaction the response to stopped when stopped |
418 // 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 } |
419 if (State() != EStopped) |
518 if (State() != EStopped) |
420 { |
519 { |
421 //[ update state to stopped propogate to devsound ] |
520 //[ update state to stopped propogate to devsound ] |
422 iMMFDevSound->Stop(); |
521 iMMFDevSound->Stop(); |
423 SetState(EStopped); |
522 SetState(EStopped); |
1025 err = KErrNotSupported; |
1124 err = KErrNotSupported; |
1026 } |
1125 } |
1027 } |
1126 } |
1028 return err; |
1127 return err; |
1029 } |
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 |