9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
|
17 /* |
|
18 Media Helper Class for handling surface events |
|
19 |
|
20 Shy Ward |
|
21 */ |
16 */ |
22 |
17 |
23 #include "cmmfbackendengine.h" |
18 #include "cmmfbackendengine.h" |
24 #include <string.h> |
19 #include <string.h> |
25 #include <ctype.h> |
20 #include <ctype.h> |
26 #include <uri8.h> |
21 #include <uri8.h> |
|
22 #include <uri16.h> |
|
23 #include "markerpositiontimer.h" |
|
24 #include "positionupdatetimer.h" |
|
25 #include "profileutilmacro.h" |
27 |
26 |
28 extern "C" { |
27 extern "C" { |
29 #include "xaadaptationmmf.h" |
28 #include "xaadaptationmmf.h" |
30 } |
29 } |
31 |
30 |
32 |
31 #define RET_IF_ERR(res, val) if (res != KErrNone) return val |
33 #define ENABLE_GRAPHICS_SURFACE_INTEGRATION_NOT_NOW |
32 |
|
33 const XAuint32 XA_PLAYSTATE_PLAYERUNINITIALIZED = 0; |
34 |
34 |
35 CMMFBackendEngine* CMMFBackendEngine::NewL() |
35 CMMFBackendEngine* CMMFBackendEngine::NewL() |
36 { |
36 { |
37 CMMFBackendEngine* self = new (ELeave) CMMFBackendEngine(); |
37 CMMFBackendEngine* self = new (ELeave) CMMFBackendEngine(); |
|
38 CleanupStack::PushL(self); |
38 self->ConstructL(); |
39 self->ConstructL(); |
|
40 CleanupStack::Pop(self); |
39 return self; |
41 return self; |
40 } |
42 } |
41 |
43 |
42 CMMFBackendEngine::~CMMFBackendEngine() |
44 CMMFBackendEngine::~CMMFBackendEngine() |
43 { |
45 { |
44 CloseAndDestroy(); |
46 Close(); |
45 } |
47 Destroy(); |
46 |
48 } |
47 CMMFBackendEngine::CMMFBackendEngine() |
49 |
48 { |
50 CMMFBackendEngine::CMMFBackendEngine() |
49 iVideoPlayer = NULL; |
51 :iPositionUpdatePeriod(1000), /* default is 1000 millisec */ |
50 m_bWindowReferencePassed = FALSE; |
52 iUriPtr(NULL,0) |
|
53 { |
|
54 /* m_bWindowReferencePassed = FALSE;*/ |
51 iRecordState = ERecorderNotReady; |
55 iRecordState = ERecorderNotReady; |
52 iPositionUpdateTimer = NULL; |
56 iPositionUpdateTimer = NULL; |
53 } |
57 iMediaPlayerState = XA_PLAYSTATE_PLAYERUNINITIALIZED; |
54 |
58 iMMFPlayerState = EPlayerClosed; |
|
59 } |
|
60 |
|
61 void CMMFBackendEngine::ConstructL() |
|
62 { |
|
63 iAPIBeingUsed = ENoUtility; |
|
64 iBaseAudioRecorder = CMdaAudioRecorderUtility::NewL(*this); |
|
65 iAudioRecorder = (CMdaAudioRecorderUtility*)iBaseAudioRecorder; |
|
66 iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait; |
|
67 } |
|
68 |
|
69 void CMMFBackendEngine::InitAudioPlayerUtilityL() |
|
70 { |
|
71 if (!iAudioPlayer) |
|
72 { |
|
73 iBaseAudioPlayer = CMdaAudioPlayerUtility::NewL(*this); |
|
74 iAudioPlayer = (CMdaAudioPlayerUtility*)iBaseAudioPlayer; |
|
75 } |
|
76 InitPlayerTimersL(); |
|
77 } |
55 |
78 |
56 void CMMFBackendEngine::InitVideoPlayerUtilityL() |
79 void CMMFBackendEngine::InitVideoPlayerUtilityL() |
57 { |
80 { |
58 iBaseVideoPlayer = CVideoPlayerUtility2::NewL(*this,EMdaPriorityNormal,EMdaPriorityPreferenceTimeAndQuality); |
81 if (!iVideoPlayer) |
59 iVideoPlayer = (CVideoPlayerUtility2*)iBaseVideoPlayer; |
82 { |
60 iVideoPlayer->RegisterForVideoLoadingNotification(*this); |
83 iBaseVideoPlayer = CVideoPlayerUtility2::NewL(*this, EMdaPriorityNormal, EMdaPriorityPreferenceTimeAndQuality); |
61 } |
84 iVideoPlayer = (CVideoPlayerUtility2*)iBaseVideoPlayer; |
62 |
85 iVideoPlayer->RegisterForVideoLoadingNotification(*this); |
63 void CMMFBackendEngine::CreateAndConfigureWindowL() |
86 } |
64 { |
87 InitPlayerTimersL(); |
65 #ifdef ENABLE_GRAPHICS_SURFACE_INTEGRATION_NOT_NOW |
88 } |
|
89 |
|
90 void CMMFBackendEngine::InitPlayerTimersL() |
|
91 { |
|
92 if (!iMarkerPositionTimer) |
|
93 { |
|
94 iMarkerPositionTimer = CMarkerPositionTimer::NewL(iAudioPlayer, iVideoPlayer); |
|
95 iMarkerPositionTimer->SetContext(iAdaptContext); |
|
96 } |
|
97 if (!iPlayItfPositionUpdateTimer) |
|
98 { |
|
99 iPlayItfPositionUpdateTimer = CPositionUpdateTimer::NewL(iAudioPlayer, iVideoPlayer); |
|
100 iPlayItfPositionUpdateTimer->SetContext(iAdaptContext); |
|
101 } |
|
102 iMarkerPositionTimer->Stop(); |
|
103 iPlayItfPositionUpdateTimer->Stop(); |
|
104 } |
|
105 |
|
106 TInt CMMFBackendEngine::SetFileName(char* uri, XAuint32 format, TFuncInUse func) |
|
107 { |
|
108 TInt err(KErrNone); |
|
109 _LIT8(KFileSlash,"file:///"); |
|
110 TInt fileslashlen = KFileSlash().Length(); |
|
111 if (func == ERecord) |
|
112 { |
|
113 if (iRecordState == ERecorderNotReady) |
|
114 { |
|
115 iFileFormat = format; |
|
116 iAPIBeingUsed = EAudioRecorderUtility; |
|
117 TPtr8 fileuri(((TUint8*)uri), strlen(uri) ,strlen(uri)); |
|
118 TPtr8 filepath = fileuri.RightTPtr(strlen(uri)-fileslashlen); |
|
119 TInt pos = filepath.LocateReverse(':'); |
|
120 if(pos != KErrNotFound) |
|
121 { |
|
122 fileuri.Delete(fileslashlen+pos,1); |
|
123 } |
|
124 |
|
125 TUriParser8 localfileUri; |
|
126 TInt ret = localfileUri.Parse(fileuri); |
|
127 HBufC* file = NULL; |
|
128 TRAP(err,file = localfileUri.GetFileNameL()); |
|
129 TPtr des = file->Des(); |
|
130 iFileName = des; |
|
131 delete file; |
|
132 file = NULL; |
|
133 TRAP(err, iAudioRecorder->OpenFileL(iFileName)); |
|
134 if (!err) |
|
135 { /* Wait until we receive moscostatechanged callback */ |
|
136 if(!iActiveSchedulerWait->IsStarted()) |
|
137 { |
|
138 iActiveSchedulerWait->Start(); |
|
139 } |
|
140 err = iErrorCode; |
|
141 } |
|
142 } |
|
143 } |
|
144 else |
|
145 { |
|
146 /* The second one is needed for dynamic source interface */ |
|
147 if ((iMediaPlayerState == XA_PLAYSTATE_PLAYERUNINITIALIZED) || |
|
148 (iMediaPlayerState == XA_PLAYSTATE_STOPPED)) |
|
149 { |
|
150 iFileFormat = format; |
|
151 iAPIBeingUsed = DetermineAPIToUse(uri, EPlay); |
|
152 err = XA_RESULT_INTERNAL_ERROR; |
|
153 if (iAPIBeingUsed == EAudioPlayerUtility) |
|
154 { |
|
155 /* Initialize URI as needed by MMF utilities */ |
|
156 err = InitializeURIForMMFUtil(uri); |
|
157 RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR); |
|
158 /* Initalize Player related objects */ |
|
159 TRAP(err, InitAudioPlayerUtilityL()); |
|
160 RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR); |
|
161 |
|
162 TAG_TIME_PROFILING_BEGIN; |
|
163 TRAP(err, iAudioPlayer->OpenFileL(iUriPtr)); |
|
164 RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR); |
|
165 TAG_TIME_PROFILING_END; |
|
166 PRINT_TO_CONSOLE_TIME_DIFF; |
|
167 |
|
168 /* Wait until we receive mapc init complete */ |
|
169 PRINT_TO_CONSOLE_HOME_TIME; |
|
170 if (!iActiveSchedulerWait->IsStarted()) |
|
171 { |
|
172 iActiveSchedulerWait->Start(); |
|
173 } |
|
174 RET_IF_ERR(iErrorCode, XA_RESULT_INTERNAL_ERROR); |
|
175 } |
|
176 else if (iAPIBeingUsed == EVideoPlayerUtility) |
|
177 { |
|
178 /* Initialize URI as needed by MMF utilities */ |
|
179 err = InitializeURIForMMFUtil(uri); |
|
180 RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR); |
|
181 /* Initalize Player related objects */ |
|
182 TRAP(err, InitVideoPlayerUtilityL()); |
|
183 RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR); |
|
184 |
|
185 /* Open file */ |
|
186 TAG_TIME_PROFILING_BEGIN; |
|
187 TRAP(err, iVideoPlayer->OpenFileL(iUriPtr)); |
|
188 RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR); |
|
189 TAG_TIME_PROFILING_END; |
|
190 PRINT_TO_CONSOLE_TIME_DIFF; |
|
191 |
|
192 /* Wait until we receive MvpuoOpenComplete */ |
|
193 PRINT_TO_CONSOLE_HOME_TIME; |
|
194 if (!iActiveSchedulerWait->IsStarted()) |
|
195 { |
|
196 iActiveSchedulerWait->Start(); |
|
197 } |
|
198 RET_IF_ERR(iErrorCode, XA_RESULT_INTERNAL_ERROR); |
|
199 |
|
200 /* Prepare utility */ |
|
201 TAG_TIME_PROFILING_BEGIN_NO_VAR_DEF; |
|
202 iVideoPlayer->Prepare(); |
|
203 TAG_TIME_PROFILING_END_NO_VAR_DEF; |
|
204 PRINT_TO_CONSOLE_TIME_DIFF; |
|
205 |
|
206 /* Wait until we receive MvpuoPrepareComplete */ |
|
207 PRINT_TO_CONSOLE_HOME_TIME_NO_VAR_DEF; |
|
208 if (!iActiveSchedulerWait->IsStarted()) |
|
209 { |
|
210 iActiveSchedulerWait->Start(); |
|
211 } |
|
212 RET_IF_ERR(iErrorCode, XA_RESULT_INTERNAL_ERROR); |
|
213 } |
|
214 } |
|
215 } |
|
216 if (err != KErrNone) |
|
217 { |
|
218 err = XA_RESULT_INTERNAL_ERROR; |
|
219 } |
|
220 return err; |
|
221 } |
|
222 |
|
223 TInt CMMFBackendEngine::DetermineAPIToUse(char* uri, TFuncInUse aFunc) |
|
224 { |
|
225 char* dotPtr = NULL; |
|
226 char ext[MAX_EXTENSION_SIZE] = { 0 }; |
|
227 int extLen; |
|
228 |
|
229 dotPtr = strrchr(uri, (int)'.'); |
|
230 if (!dotPtr) |
|
231 { |
|
232 return KErrNotFound; |
|
233 } |
|
234 |
|
235 strncpy(ext, dotPtr,strlen(dotPtr)); |
|
236 /*Null terminate the string*/ |
|
237 ext[strlen(dotPtr)] = '\0'; |
|
238 extLen = sizeof(ext); |
|
239 for(unsigned int i=0; i < extLen; i++) |
|
240 { |
|
241 ext[i] = tolower(ext[i]); |
|
242 } |
|
243 |
|
244 if (aFunc == ERecord) |
|
245 { |
|
246 return EAudioRecorderUtility; |
|
247 } |
|
248 else |
|
249 { |
|
250 if (!strcasecmp(ext, ".mp3") || |
|
251 !strcasecmp(ext, ".amr") || |
|
252 !strcasecmp(ext, ".aac") || |
|
253 !strcasecmp(ext, ".mid") || |
|
254 !strcasecmp(ext, ".wav") || |
|
255 !strcasecmp(ext, ".awb")) |
|
256 { |
|
257 return EAudioPlayerUtility; |
|
258 } |
|
259 else |
|
260 { |
|
261 return EVideoPlayerUtility; |
|
262 } |
|
263 } |
|
264 } |
|
265 |
|
266 //From MVidePlayerUtilityObserver |
|
267 void CMMFBackendEngine::MvpuoOpenComplete(TInt aError) |
|
268 { |
|
269 PRINT_TO_CONSOLE_HOME_TIME; |
|
270 |
|
271 iErrorCode = aError; |
|
272 if (iErrorCode == KErrNone) |
|
273 { |
|
274 iMMFPlayerState = EPlayerOpened; |
|
275 } |
|
276 if (iActiveSchedulerWait->IsStarted()) |
|
277 { |
|
278 iActiveSchedulerWait->AsyncStop(); |
|
279 } |
|
280 } |
|
281 |
|
282 void CMMFBackendEngine::MvpuoPrepareComplete(TInt aError) |
|
283 { |
|
284 PRINT_TO_CONSOLE_HOME_TIME; |
|
285 |
|
286 TAutoScaleType autoScale = EAutoScaleBestFit; |
|
287 iErrorCode = aError; |
|
288 iMediaPlayerState = XA_PLAYSTATE_PLAYERUNINITIALIZED; |
|
289 iMediaDuration = 0; |
|
290 iMarkerPositionTimer->ResetPlayer(); |
|
291 iPlayItfPositionUpdateTimer->ResetPlayer(); |
|
292 if (iErrorCode == KErrNone) |
|
293 { |
|
294 iMMFPlayerState = EPlayerPrepared; |
|
295 TAG_TIME_PROFILING_BEGIN; |
|
296 TRAP(iErrorCode, iMediaDuration = iVideoPlayer->DurationL()); |
|
297 TAG_TIME_PROFILING_END; |
|
298 PRINT_TO_CONSOLE_TIME_DIFF; |
|
299 if (iErrorCode == KErrNone) |
|
300 { |
|
301 iPlaybackHead = 0; |
|
302 iMediaPlayerState = XA_PLAYSTATE_STOPPED; |
|
303 iMarkerPositionTimer->UseVideoPlayer(); |
|
304 iPlayItfPositionUpdateTimer->UseVideoPlayer(); |
|
305 if (m_pWs && m_pScr && m_pWindow) |
|
306 { |
|
307 TRect videoExtent = TRect(m_pWindow->Size()); |
|
308 TRect clipRect = TRect(m_pWindow->Size()); |
|
309 TAG_TIME_PROFILING_BEGIN; |
|
310 TRAP_IGNORE(iVideoPlayer->AddDisplayWindowL(*m_pWs, *m_pScr, *m_pWindow, videoExtent, clipRect)); |
|
311 TRAP_IGNORE(iVideoPlayer->SetAutoScaleL(*m_pWindow, autoScale)); |
|
312 TAG_TIME_PROFILING_END; |
|
313 PRINT_TO_CONSOLE_TIME_DIFF; |
|
314 } |
|
315 } |
|
316 } |
|
317 if (iActiveSchedulerWait->IsStarted()) |
|
318 { |
|
319 iActiveSchedulerWait->AsyncStop(); |
|
320 } |
|
321 } |
|
322 |
|
323 void CMMFBackendEngine::MvpuoFrameReady(CFbsBitmap& /*aFrame*/,TInt /*aError*/) |
|
324 { |
|
325 |
|
326 } |
|
327 void CMMFBackendEngine::MvpuoPlayComplete(TInt aError) |
|
328 { |
|
329 iErrorCode = aError; |
|
330 if (iErrorCode == KErrNone) |
|
331 { |
|
332 iPlaybackHead = iMediaDuration; |
|
333 /* Per OpenMAX AL Spec, when playback is completed, media player stays in |
|
334 * paused state with playhead at the end of the media clip */ |
|
335 iMediaPlayerState = XA_PLAYSTATE_PAUSED; |
|
336 DoPostEvent(XA_PLAYEVENT_HEADATEND); |
|
337 } |
|
338 else |
|
339 { |
|
340 iPlaybackHead = 0; |
|
341 iMediaPlayerState = XA_PLAYSTATE_STOPPED; |
|
342 XAAdaptEvent event = {XA_PLAYITFEVENTS, XA_OBJECT_EVENT_RESOURCES_LOST, 0, NULL}; |
|
343 XAAdaptationBase_SendAdaptEvents((XAAdaptationBaseCtx*)iAdaptContext, &event ); |
|
344 } |
|
345 iMMFPlayerState = EPlayerPrepared; |
|
346 iMarkerPositionTimer->Stop(); |
|
347 iPlayItfPositionUpdateTimer->Stop(); |
|
348 } |
|
349 |
|
350 void CMMFBackendEngine::MvpuoEvent(class TMMFEvent const & event) |
|
351 { |
|
352 //RDebug::Print(_L("CMMFBackendEngine::MvpuoEvent (0x%x %d)"), event.iEventType, event.iErrorCode); |
|
353 |
|
354 if (event.iEventType == KMMFEventCategoryVideoPlayerGeneralError && |
|
355 event.iErrorCode == KErrHardwareNotAvailable) |
|
356 { |
|
357 //RDebug::Print(_L("CMMFBackendEngine::MvpuoEvent: Hardware Not Available")); |
|
358 } |
|
359 |
|
360 else if (event.iEventType == KMMFEventCategoryVideoPlayerGeneralError && |
|
361 event.iErrorCode == KErrMMPartialPlayback) |
|
362 { |
|
363 //RDebug::Print(_L("CMMFBackendEngine::MvpuoEvent: Partial playback")); |
|
364 } |
|
365 if (event.iEventType == KMMFEventCategoryVideoPlayerGeneralError && |
|
366 event.iErrorCode == -12014) |
|
367 { |
|
368 //RDebug::Print(_L("CMMFBackendEngine::MvpuoEvent: Audio Device taken")); |
|
369 PausePlayback(); |
|
370 XAAdaptEvent event = {XA_PLAYITFEVENTS, XA_OBJECT_EVENT_RESOURCES_LOST, 0, NULL}; |
|
371 XAAdaptationBase_SendAdaptEvents((XAAdaptationBaseCtx*)iAdaptContext, &event ); |
|
372 } |
|
373 else if (event.iEventType == KMMFRefreshMetaData) |
|
374 { |
|
375 //RDebug::Print(_L("CMMFBackendEngine::MvpuoEvent: EventType == KMMFRefreshMetaData")); |
|
376 } |
|
377 else |
|
378 { |
|
379 //RDebug::Print(_L("CMMFBackendEngine::MvpuoEvent: Unhandled event")); |
|
380 } |
|
381 |
|
382 } |
|
383 |
|
384 // From MRebufferCallback |
|
385 void CMMFBackendEngine::MvloLoadingStarted() |
|
386 { |
|
387 } |
|
388 |
|
389 void CMMFBackendEngine::MvloLoadingComplete() |
|
390 { |
|
391 //file playing |
|
392 } |
|
393 |
|
394 //MMdaAudioPlayerCallback |
|
395 void CMMFBackendEngine::MapcInitComplete(TInt aError, |
|
396 const TTimeIntervalMicroSeconds& aDuration) |
|
397 { |
|
398 PRINT_TO_CONSOLE_HOME_TIME; |
|
399 |
|
400 iErrorCode = aError; |
|
401 iMediaPlayerState = XA_PLAYSTATE_PLAYERUNINITIALIZED; |
|
402 iMMFPlayerState = EPlayerClosed; |
|
403 iMediaDuration = 0; |
|
404 iMarkerPositionTimer->ResetPlayer(); |
|
405 iPlayItfPositionUpdateTimer->ResetPlayer(); |
|
406 if (iErrorCode == KErrNone) |
|
407 { |
|
408 iMediaDuration = aDuration; |
|
409 iPlaybackHead = 0; |
|
410 iMediaPlayerState = XA_PLAYSTATE_STOPPED; |
|
411 iMMFPlayerState = EPlayerOpened; |
|
412 iMarkerPositionTimer->UseAudioPlayer(); |
|
413 iPlayItfPositionUpdateTimer->UseAudioPlayer(); |
|
414 } |
|
415 if (iActiveSchedulerWait->IsStarted()) |
|
416 { |
|
417 iActiveSchedulerWait->AsyncStop(); |
|
418 } |
|
419 } |
|
420 |
|
421 |
|
422 void CMMFBackendEngine::MapcPlayComplete(TInt aError) |
|
423 { |
|
424 iErrorCode = aError; |
|
425 if (iErrorCode == KErrNone) |
|
426 { |
|
427 /* Now we should have better value. Start using that */ |
|
428 iAudioPlayer->Duration(iMediaDuration); |
|
429 iPlaybackHead = iMediaDuration; |
|
430 /* Per OpenMAX AL Spec, when playback is completed, media player stays in |
|
431 * paused state with playhead at the end of the media clip */ |
|
432 iMediaPlayerState = XA_PLAYSTATE_PAUSED; |
|
433 DoPostEvent(XA_PLAYEVENT_HEADATEND); |
|
434 iMMFPlayerState = EPlayerOpened; |
|
435 } |
|
436 else |
|
437 { |
|
438 iAudioPlayer->GetPosition(iPlaybackHead); |
|
439 iMediaPlayerState = XA_PLAYSTATE_PAUSED; |
|
440 iMMFPlayerState = EPlayerPaused; |
|
441 XAAdaptEvent event = {XA_PLAYITFEVENTS, XA_OBJECT_EVENT_RESOURCES_LOST, 0, NULL}; |
|
442 XAAdaptationBase_SendAdaptEvents((XAAdaptationBaseCtx*)iAdaptContext, &event ); |
|
443 } |
|
444 iMarkerPositionTimer->Stop(); |
|
445 iPlayItfPositionUpdateTimer->Stop(); |
|
446 } |
|
447 |
|
448 // from MMdaObjectStateChangeObserver |
|
449 void CMMFBackendEngine::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode) |
|
450 { |
|
451 TInt err(KErrNone); |
|
452 iPreviousRecordState = aPreviousState; |
|
453 iCurrentRecordState = aCurrentState; |
|
454 iErrorCode = aErrorCode; |
|
455 //RDebug::Print(_L("CMMFBackendEngine::MoscoStateChangeEvent 1 Error[%d]"),aErrorCode); |
|
456 if (iCurrentRecordState == CMdaAudioClipUtility::EOpen) //EOpen |
|
457 { |
|
458 //outputfile is open and ready for recording |
|
459 iRecordState = CMMFBackendEngine::ERecorderOpen; |
|
460 if (iErrorCode == KErrNone) |
|
461 { |
|
462 if (iPreviousRecordState == CMdaAudioClipUtility::ENotReady) |
|
463 { |
|
464 //RDebug::Print(_L("CMMFBackendEngine::MoscoStateChangeEvent 2")); |
|
465 TRAP(err,iaudioInputRecord = CAudioInput::NewL( *iAudioRecorder )); |
|
466 RArray<CAudioInput::TAudioInputPreference> inputArray; |
|
467 inputArray.Append( CAudioInput::EDefaultMic ); |
|
468 // Set Audio Input |
|
469 iaudioInputRecord->SetAudioInputL( inputArray.Array( ) ); |
|
470 inputArray.Close(); |
|
471 TMMFMessageDestination destination(KUidMetaDataWriteCustomCommand); |
|
472 TMMFMessageDestinationPckg pckg = TMMFMessageDestinationPckg(destination); |
|
473 TInt ret = iAudioRecorder->RecordControllerCustomCommandSync(pckg, 0, KNullDesC8, KNullDesC8); |
|
474 //RDebug::Print(_L("CMMFBackendEngine::MoscoStateChangeEvent 3 [%d]"),ret); |
|
475 if (ret != KErrNone && iFileFormat == XA_CONTAINERTYPE_MP4) |
|
476 { |
|
477 iPauseSupportMP4 = FALSE; |
|
478 } |
|
479 if (iActiveSchedulerWait->IsStarted()) |
|
480 { |
|
481 iActiveSchedulerWait->AsyncStop(); |
|
482 } |
|
483 } |
|
484 } |
|
485 else |
|
486 { |
|
487 XAAdaptEvent event = {XA_RECORDITFEVENTS, XA_OBJECT_EVENT_RESOURCES_LOST, 0, NULL}; |
|
488 XAAdaptationBase_SendAdaptEvents((XAAdaptationBaseCtx*)iAdaptContext, &event ); |
|
489 } |
|
490 } |
|
491 else if (iCurrentRecordState == CMdaAudioClipUtility::ERecording) //ERecording |
|
492 { |
|
493 iRecordState = CMMFBackendEngine::ERecorderRecording; |
|
494 iPositionUpdateTimer->Start(iTimerDelay); |
|
495 XAAdaptEvent event = {XA_RECORDITFEVENTS, XA_RECORDEVENT_HEADMOVING, 0, NULL}; |
|
496 XAAdaptationBase_SendAdaptEvents((XAAdaptationBaseCtx*)iAdaptContext, &event ); |
|
497 } |
|
498 else //ENotReady |
|
499 { |
|
500 //outputfile is not open |
|
501 iRecordState = CMMFBackendEngine::ERecorderNotReady; |
|
502 } |
|
503 } |
|
504 |
|
505 TInt CMMFBackendEngine::SetRecorderState(TRecorderState state, XAboolean stopCalled) |
|
506 { |
|
507 TInt err(KErrNone); |
|
508 switch(state) |
|
509 { |
|
510 case ERecorderNotReady: |
|
511 iAudioRecorder->Close(); |
|
512 iRecordState = ERecorderNotReady; |
|
513 break; |
|
514 case ERecorderOpen: |
|
515 if (iFileFormat == XA_CONTAINERTYPE_MP4 && !iPauseSupportMP4 && !stopCalled) |
|
516 { |
|
517 err = KErrNotSupported; |
|
518 return err; |
|
519 } |
|
520 iPositionUpdateTimer->Stop(); |
|
521 iAudioRecorder->Stop(); |
|
522 iRecordState = ERecorderOpen; |
|
523 break; |
|
524 case ERecorderRecording: |
|
525 TRAP(err, iAudioRecorder->RecordL()); |
|
526 break; |
|
527 } |
|
528 return err; |
|
529 } |
|
530 |
|
531 void CMMFBackendEngine::Close() |
|
532 { |
|
533 if (iMarkerPositionTimer) |
|
534 { |
|
535 iMarkerPositionTimer->Stop(); |
|
536 } |
|
537 if (iPlayItfPositionUpdateTimer) |
|
538 { |
|
539 iPlayItfPositionUpdateTimer->Stop(); |
|
540 } |
|
541 |
|
542 if (iBaseVideoPlayer && iVideoPlayer) |
|
543 { |
|
544 switch(iMMFPlayerState) |
|
545 { |
|
546 case EPlayerPlaying: |
|
547 case EPlayerPaused: |
|
548 case EPlayerPrepared: |
|
549 iVideoPlayer->Stop(); |
|
550 case EPlayerOpened: |
|
551 if (m_pWs && m_pScr && m_pWindow) |
|
552 { |
|
553 iVideoPlayer->RemoveDisplayWindow(*m_pWindow); |
|
554 } |
|
555 iVideoPlayer->Close(); |
|
556 case EPlayerClosed: |
|
557 default: |
|
558 break; |
|
559 }; |
|
560 } |
|
561 |
|
562 if (iBaseAudioPlayer && iAudioPlayer) |
|
563 { |
|
564 iAudioPlayer->Close(); |
|
565 } |
|
566 |
|
567 if (iBaseAudioRecorder) |
|
568 { |
|
569 iAudioRecorder->Close(); |
|
570 } |
|
571 |
|
572 if(iPositionUpdateTimer) |
|
573 { |
|
574 iPositionUpdateTimer->Stop(); |
|
575 } |
|
576 |
|
577 if(iActiveSchedulerWait) |
|
578 { |
|
579 if(iActiveSchedulerWait->IsStarted()) |
|
580 { |
|
581 iActiveSchedulerWait->AsyncStop(); |
|
582 } |
|
583 } |
|
584 } |
|
585 |
|
586 void CMMFBackendEngine::Destroy() |
|
587 { |
|
588 |
|
589 if (iBaseAudioRecorder) |
|
590 { |
|
591 iAudioRecorder->Close(); |
|
592 } |
|
593 |
|
594 if (iActiveSchedulerWait && iActiveSchedulerWait->IsStarted()) |
|
595 { |
|
596 iActiveSchedulerWait->AsyncStop(); |
|
597 } |
|
598 |
|
599 delete iPositionUpdateTimer; |
|
600 iPositionUpdateTimer = NULL; |
|
601 delete iUri; |
|
602 iUri = NULL; |
|
603 delete iMarkerPositionTimer; |
|
604 iMarkerPositionTimer = NULL; |
|
605 delete iPlayItfPositionUpdateTimer; |
|
606 iPlayItfPositionUpdateTimer = NULL; |
|
607 delete iBaseVideoPlayer; |
|
608 iBaseVideoPlayer = NULL; |
|
609 iVideoPlayer = NULL; |
|
610 if (iaudioInputRecord) |
|
611 { |
|
612 delete iaudioInputRecord; |
|
613 iaudioInputRecord = NULL; |
|
614 } |
|
615 |
|
616 delete iBaseAudioPlayer; |
|
617 iBaseAudioPlayer = NULL; |
|
618 iAudioPlayer = NULL; |
|
619 delete iBaseAudioRecorder; |
|
620 iBaseAudioRecorder = NULL; |
|
621 iAudioRecorder = NULL; |
|
622 delete iActiveSchedulerWait; |
|
623 iActiveSchedulerWait = NULL; |
|
624 delete m_pScr; |
|
625 m_pScr = NULL; |
|
626 } |
|
627 |
|
628 TInt CMMFBackendEngine::GetRecordPosition(XAuint64* position) |
|
629 { |
|
630 TInt err(KErrNone); |
|
631 *position = iAudioRecorder->Position().Int64(); |
|
632 return err; |
|
633 } |
|
634 |
|
635 TInt CMMFBackendEngine::SetPositionUpdatePerioed(XAmillisecond period) |
|
636 { |
|
637 TInt err(KErrNone); |
|
638 iTimerDelay = period; |
|
639 return err; |
|
640 } |
|
641 |
|
642 TInt CMMFBackendEngine::SetAdaptContext(void* adaptcontext) |
|
643 { |
|
644 TInt err(KErrNone); |
|
645 iAdaptContext = adaptcontext; |
|
646 TRAP(err, iPositionUpdateTimer = new (ELeave) LocalTimer(this, iAdaptContext)); |
|
647 if (!err) |
|
648 { |
|
649 iPositionUpdateTimer->PostInit(); |
|
650 } |
|
651 return err; |
|
652 } |
|
653 |
|
654 TInt CMMFBackendEngine::GetCodecId(XAuint32* codecid) |
|
655 { |
|
656 TInt err(KErrNone); |
|
657 |
|
658 if(iAPIBeingUsed == EAudioRecorderUtility) |
|
659 { |
|
660 if(iRecordState != CMMFBackendEngine::ERecorderNotReady) |
|
661 { |
|
662 TFourCC dest; |
|
663 TRAP(err, dest = iAudioRecorder->DestinationDataTypeL()); |
|
664 if(err == KErrNone) |
|
665 { |
|
666 *codecid = dest.FourCC(); |
|
667 } |
|
668 } |
|
669 } |
|
670 else if(iAPIBeingUsed == EAudioPlayerUtility) |
|
671 { |
|
672 if(iMediaPlayerState != XA_PLAYSTATE_PLAYERUNINITIALIZED) |
|
673 { |
|
674 TMMFMessageDestinationPckg pckg(KUidInterfaceMMFAudioController); |
|
675 TPckgBuf<TMMFAudioConfig> configPackage; |
|
676 TInt err = iAudioPlayer->CustomCommandSync(pckg, |
|
677 EMMFAudioControllerGetSourceDataType, |
|
678 KNullDesC8, |
|
679 KNullDesC8, |
|
680 configPackage); |
|
681 if(err == KErrNone) |
|
682 { |
|
683 *codecid = configPackage().iSourceDataTypeCode.FourCC(); |
|
684 } |
|
685 } |
|
686 } |
|
687 return err; |
|
688 } |
|
689 |
|
690 TInt CMMFBackendEngine::GetBitRate(XAuint32* bitrate) |
|
691 { |
|
692 TInt err(KErrNone); |
|
693 TUint br(0); |
|
694 if(iAPIBeingUsed == EAudioRecorderUtility) |
|
695 { |
|
696 if(iRecordState != CMMFBackendEngine::ERecorderNotReady) |
|
697 { |
|
698 TRAP(err, br = iAudioRecorder->DestinationBitRateL()); |
|
699 if(err == KErrNone) |
|
700 { |
|
701 *bitrate = br; |
|
702 } |
|
703 } |
|
704 } |
|
705 else if(iAPIBeingUsed == EAudioPlayerUtility) |
|
706 { |
|
707 if(iMediaPlayerState != XA_PLAYSTATE_PLAYERUNINITIALIZED) |
|
708 { |
|
709 TInt err = iAudioPlayer->GetBitRate(br); |
|
710 *bitrate = br; |
|
711 } |
|
712 } |
|
713 return err; |
|
714 } |
|
715 |
|
716 TInt CMMFBackendEngine::GetSampleRate(XAmilliHertz* samplerate) |
|
717 { |
|
718 TInt err(KErrNone); |
|
719 TUint sr(0); |
|
720 if(iAPIBeingUsed == EAudioRecorderUtility) |
|
721 { |
|
722 if(iRecordState != CMMFBackendEngine::ERecorderNotReady) |
|
723 { |
|
724 TRAP(err, sr = iAudioRecorder->DestinationSampleRateL()); |
|
725 if(err == KErrNone) |
|
726 { |
|
727 *samplerate = sr; |
|
728 } |
|
729 } |
|
730 } |
|
731 else if(iAPIBeingUsed == EAudioPlayerUtility) |
|
732 { |
|
733 if(iMediaPlayerState != XA_PLAYSTATE_PLAYERUNINITIALIZED) |
|
734 { |
|
735 TMMFMessageDestinationPckg pckg(KUidInterfaceMMFAudioController); |
|
736 TPckgBuf<TMMFAudioConfig> configPackage; |
|
737 TInt err = iAudioPlayer->CustomCommandSync(pckg, |
|
738 EMMFAudioControllerGetSourceSampleRate, |
|
739 KNullDesC8, |
|
740 KNullDesC8, |
|
741 configPackage); |
|
742 if(err == KErrNone) |
|
743 { |
|
744 *samplerate = configPackage().iSampleRate; |
|
745 } |
|
746 } |
|
747 } |
|
748 return err; |
|
749 } |
|
750 |
|
751 TInt CMMFBackendEngine::GetChannels(XAuint32* channels) |
|
752 { |
|
753 TInt err(KErrNone); |
|
754 TUint ch(0); |
|
755 if(iAPIBeingUsed == EAudioRecorderUtility) |
|
756 { |
|
757 if(iRecordState != CMMFBackendEngine::ERecorderNotReady) |
|
758 { |
|
759 TRAP(err,ch = iAudioRecorder->DestinationNumberOfChannelsL()); |
|
760 if(err == KErrNone) |
|
761 { |
|
762 *channels = ch; |
|
763 } |
|
764 } |
|
765 } |
|
766 else if(iAPIBeingUsed == EAudioPlayerUtility) |
|
767 { |
|
768 if(iMediaPlayerState != XA_PLAYSTATE_PLAYERUNINITIALIZED) |
|
769 { |
|
770 TMMFMessageDestinationPckg pckg(KUidInterfaceMMFAudioController); |
|
771 TPckgBuf<TMMFAudioConfig> configPackage; |
|
772 TInt err = iAudioPlayer->CustomCommandSync( pckg, |
|
773 EMMFAudioControllerGetSourceNumChannels, |
|
774 KNullDesC8, |
|
775 KNullDesC8, |
|
776 configPackage ); |
|
777 if(err == KErrNone) |
|
778 { |
|
779 *channels = configPackage().iChannels; |
|
780 } |
|
781 } |
|
782 } |
|
783 return err; |
|
784 } |
|
785 |
|
786 TInt CMMFBackendEngine::SetDestinationBitRate(XAuint32* bitrate) |
|
787 { |
|
788 TInt err(KErrNone); |
|
789 if(iRecordState == CMMFBackendEngine::ERecorderOpen) |
|
790 { |
|
791 TRAP(err, iAudioRecorder->SetDestinationBitRateL(*bitrate)); |
|
792 if(err != KErrNone) |
|
793 { |
|
794 return XA_RESULT_PARAMETER_INVALID; |
|
795 } |
|
796 } |
|
797 return err; |
|
798 } |
|
799 |
|
800 TInt CMMFBackendEngine::SetDestinationSampleRate(XAmilliHertz* samplerate) |
|
801 { |
|
802 TInt err(KErrNone); |
|
803 if(iRecordState == CMMFBackendEngine::ERecorderOpen) |
|
804 { |
|
805 TRAP(err, iAudioRecorder->SetDestinationSampleRateL(*samplerate)); |
|
806 if(err != KErrNone) |
|
807 { |
|
808 return XA_RESULT_PARAMETER_INVALID; |
|
809 } |
|
810 } |
|
811 return err; |
|
812 } |
|
813 |
|
814 TInt CMMFBackendEngine::SetDestinationChannels(XAuint32* channels) |
|
815 { |
|
816 TInt err(KErrNone); |
|
817 if (iRecordState == CMMFBackendEngine::ERecorderOpen) |
|
818 { |
|
819 TRAP(err,iAudioRecorder->SetDestinationNumberOfChannelsL(*channels)); |
|
820 if (err != KErrNone) |
|
821 { |
|
822 return XA_RESULT_PARAMETER_INVALID; |
|
823 } |
|
824 } |
|
825 return err; |
|
826 } |
|
827 |
|
828 /* |
|
829 XAresult CMMFBackendEngine::SetWindowHandle(void* display_info) |
|
830 { |
|
831 XADataLocator_NativeDisplay* nativeDisplay; |
|
832 XADataSink* videoSink = (XADataSink*)display_info; |
|
833 |
|
834 nativeDisplay = (XADataLocator_NativeDisplay*) (videoSink->pLocator); |
|
835 |
|
836 m_pWindow = ((RWindow*)(nativeDisplay->hWindow)); |
|
837 m_pWs = ((RWsSession*)(nativeDisplay->hDisplay)); |
|
838 |
|
839 m_bWindowReferencePassed = TRUE; |
|
840 return XA_RESULT_SUCCESS; |
|
841 } |
|
842 |
|
843 */ |
|
844 XAresult CMMFBackendEngine::CreateAndConfigureWindowL() |
|
845 { |
|
846 #ifdef USE_LOCAL_WINDOW_RESOURCES |
66 // create window for attaching the surface as its background |
847 // create window for attaching the surface as its background |
67 //RWsSession ws; |
848 //RWsSession ws; |
68 //TInt err2(KErrNone); |
849 //TInt err2(KErrNone); |
69 TInt err2 = m_ws.Connect(); |
850 TInt err2 = m_ws.Connect(); |
70 m_pScr = new(ELeave) CWsScreenDevice(m_ws); |
851 m_pScr = new(ELeave) CWsScreenDevice(m_ws); |
92 // Add the display window |
873 // Add the display window |
93 m_cropRegion = TRect(m_pWindow->Size()); |
874 m_cropRegion = TRect(m_pWindow->Size()); |
94 m_clipRect = TRect(m_pWindow->Size()); |
875 m_clipRect = TRect(m_pWindow->Size()); |
95 m_videoExtent = TRect(m_pWindow->Size()); |
876 m_videoExtent = TRect(m_pWindow->Size()); |
96 m_rotation = EVideoRotationNone; |
877 m_rotation = EVideoRotationNone; |
97 |
878 #endif /* USE_LOCAL_WINDOW_RESOURCES */ |
98 #endif // ENABLE_GRAPHICS_SURFACE_INTEGRATION_NOT_NOW |
879 |
99 |
880 return XA_RESULT_SUCCESS; |
100 } |
881 } |
101 |
882 |
102 void CMMFBackendEngine::ConstructL() |
883 XAresult CMMFBackendEngine::SetNativeDisplayInformation(void* display_info) |
103 { |
884 { |
104 //iBaseAudioPlayer = CMdaAudioPlayerUtility::NewL(*this); |
885 XAresult retVal(XA_RESULT_SUCCESS); |
105 //iAudioPlayer = (CMdaAudioPlayerUtility*)iBaseAudioPlayer; |
886 //display_info is of type XADataSink |
106 iAPIBeingUsed = EAudioPlayerUtility; |
887 //display_info.pLocator is of type XADataLocator_NativeDisplay |
107 //InitVideoPlayerUtilityL(); |
|
108 iPlayerState = EPlayerClosed; |
|
109 iBaseAudioRecorder = CMdaAudioRecorderUtility::NewL(*this); |
|
110 iAudioRecorder = (CMdaAudioRecorderUtility*)iBaseAudioRecorder; |
|
111 iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait; |
|
112 } |
|
113 |
|
114 TInt CMMFBackendEngine::SetFileName(char* uri, XAuint32 format, TFuncInUse func) |
|
115 { |
|
116 TInt err(KErrNone); |
|
117 _LIT8(KFileSlash,"file:///"); |
|
118 TInt fileslashlen = KFileSlash().Length(); |
|
119 if(func == ERecord) |
|
120 { |
|
121 if(iRecordState == ERecorderNotReady) |
|
122 { |
|
123 iFileFormat = format; |
|
124 iAPIBeingUsed = DetermineAPIToUse(uri, ERecord); |
|
125 TPtr8 fileuri(((TUint8*)uri), strlen(uri) ,strlen(uri)); |
|
126 TPtr8 filepath = fileuri.RightTPtr(strlen(uri)-fileslashlen); |
|
127 if(iAPIBeingUsed == EAudioPlayerUtility) |
|
128 { |
|
129 TInt pos = filepath.LocateReverse(':'); |
|
130 if(pos != KErrNotFound) |
|
131 { |
|
132 fileuri.Delete(fileslashlen+pos,1); |
|
133 } |
|
134 |
|
135 TUriParser8 localfileUri; |
|
136 TInt ret = localfileUri.Parse(fileuri); |
|
137 HBufC* file = NULL; |
|
138 TRAP(err,file = localfileUri.GetFileNameL()); |
|
139 TPtr des = file->Des(); |
|
140 iFileName = des; |
|
141 delete file; |
|
142 file = NULL; |
|
143 TRAP(err, iAudioRecorder->OpenFileL(iFileName)); |
|
144 if(!iActiveSchedulerWait->IsStarted()) |
|
145 { |
|
146 iActiveSchedulerWait->Start(); |
|
147 } |
|
148 } |
|
149 } |
|
150 } |
|
151 else |
|
152 { |
|
153 if(iPlayerState == EPlayerClosed) |
|
154 { |
|
155 iFileFormat = format; |
|
156 iAPIBeingUsed = DetermineAPIToUse(uri,EPlay); |
|
157 TPtr8 fileuri((TUint8*)uri, strlen(uri),strlen(uri)); |
|
158 |
|
159 if(iAPIBeingUsed == EAudioPlayerUtility) |
|
160 { |
|
161 TInt pos = fileuri.LocateReverse(':'); |
|
162 fileuri.Delete(pos,1); |
|
163 |
|
164 TUriParser8 localfileUri; |
|
165 TInt ret = localfileUri.Parse(fileuri); |
|
166 HBufC* file = NULL; |
|
167 TRAP(err,file = localfileUri.GetFileNameL()); |
|
168 TPtr des = file->Des(); |
|
169 iFileName = des; |
|
170 delete file; |
|
171 file = NULL; |
|
172 } |
|
173 else |
|
174 { |
|
175 HBufC* f(NULL); |
|
176 TRAP(err, f = HBufC::NewL(strlen(uri))); |
|
177 TPtr des = f->Des(); |
|
178 des.Copy(fileuri); |
|
179 iFileName = des; |
|
180 delete f; |
|
181 f = NULL; |
|
182 } |
|
183 } |
|
184 } |
|
185 return err; |
|
186 } |
|
187 |
|
188 TInt CMMFBackendEngine::DetermineAPIToUse(char* uri, TFuncInUse aFunc) |
|
189 { |
|
190 char* tempExtensionPtr = NULL; |
|
191 char extension[MAX_EXTENSION_SIZE] = { 0 }; |
|
192 |
|
193 tempExtensionPtr = strchr(uri, (int)'.'); |
|
194 strcpy(extension, tempExtensionPtr); |
|
195 |
|
196 for(unsigned int i=0;i<sizeof(extension);i++) |
|
197 { |
|
198 extension[i] = tolower(extension[i]); |
|
199 } |
|
200 |
|
201 if(aFunc == ERecord) |
|
202 { |
|
203 return EAudioPlayerUtility; |
|
204 } |
|
205 else |
|
206 { |
|
207 if(!strcmp(extension, ".mp3") || (!strcmp(extension, ".amr")) || (!strcmp(extension, ".aac")) || (!strcmp(extension, ".mid")) || |
|
208 (!strcmp(extension, ".awb"))) |
|
209 { |
|
210 return EAudioPlayerUtility; |
|
211 } |
|
212 else |
|
213 { |
|
214 return EVideoPlayerUtility; |
|
215 } |
|
216 } |
|
217 } |
|
218 |
|
219 void CMMFBackendEngine::SetWindowHandle(void* display_info) |
|
220 { |
|
221 XADataLocator_NativeDisplay* nativeDisplay; |
888 XADataLocator_NativeDisplay* nativeDisplay; |
222 XADataSink* videoSink = (XADataSink*)display_info; |
889 XADataSink* videoSink = (XADataSink*)display_info; |
|
890 |
|
891 if (videoSink) |
|
892 { |
|
893 nativeDisplay = (XADataLocator_NativeDisplay*) (videoSink->pLocator); |
|
894 m_pWindow = ((RWindow*)(nativeDisplay->hWindow)); |
|
895 m_pWs = ((RWsSession*)(nativeDisplay->hDisplay)); |
|
896 /* |
|
897 m_cropRegion = TRect(m_pWindow->Size()); |
|
898 m_videoExtent = TRect(m_pWindow->Size()); |
|
899 m_cropRect = TRect(m_pWindow->Size()); |
|
900 m_clipRect = TRect(m_pWindow->Size()); |
|
901 m_cropRegion = TRect(m_pWindow->Size()); |
|
902 */ |
|
903 if (m_pWs) |
|
904 { |
|
905 delete m_pScr; |
|
906 m_pScr = NULL; |
|
907 TRAPD(err, m_pScr = new CWsScreenDevice(*m_pWs)); |
|
908 RET_IF_ERR(err, XA_RESULT_MEMORY_FAILURE); |
|
909 m_pScr->Construct(); |
|
910 } |
|
911 } |
|
912 return retVal; |
|
913 } |
|
914 |
|
915 XAresult CMMFBackendEngine::ResumePlayback() |
|
916 { |
|
917 XAresult retVal(XA_RESULT_SUCCESS); |
|
918 TBool postHeadMovingEvent(EFalse); |
|
919 switch (iMediaPlayerState) |
|
920 { |
|
921 case XA_PLAYSTATE_STOPPED: |
|
922 case XA_PLAYSTATE_PAUSED: |
|
923 /* If we are already at the end of clip, do nothing |
|
924 * check ::MapcPlayComplete for documentation */ |
|
925 if ((iPlaybackHead < iMediaDuration) && |
|
926 ((iAPIBeingUsed == EAudioPlayerUtility) || |
|
927 (iAPIBeingUsed == EVideoPlayerUtility)) ) |
|
928 { |
|
929 if (iAPIBeingUsed == EAudioPlayerUtility) |
|
930 { |
|
931 TAG_TIME_PROFILING_BEGIN; |
|
932 iAudioPlayer->Play(); |
|
933 TAG_TIME_PROFILING_END; |
|
934 PRINT_TO_CONSOLE_TIME_DIFF; |
|
935 } |
|
936 else if (iAPIBeingUsed == EVideoPlayerUtility) |
|
937 { |
|
938 TAG_TIME_PROFILING_BEGIN; |
|
939 //iVideoPlayer->Play( iPlaybackHead, iMediaDuration); |
|
940 iVideoPlayer->Play(); |
|
941 TAG_TIME_PROFILING_END; |
|
942 PRINT_TO_CONSOLE_TIME_DIFF; |
|
943 } |
|
944 postHeadMovingEvent = ETrue; |
|
945 iMediaPlayerState = XA_PLAYSTATE_PLAYING; |
|
946 iMMFPlayerState = EPlayerPlaying; |
|
947 iMarkerPositionTimer->Start(); |
|
948 iPlayItfPositionUpdateTimer->Start(); |
|
949 } |
|
950 break; |
|
951 case XA_PLAYSTATE_PLAYING: |
|
952 break; |
|
953 case XA_PLAYSTATE_PLAYERUNINITIALIZED: |
|
954 default: |
|
955 retVal = XA_RESULT_INTERNAL_ERROR; |
|
956 break; |
|
957 } |
|
958 |
|
959 if (postHeadMovingEvent) |
|
960 { |
|
961 DoPostEvent(XA_PLAYEVENT_HEADMOVING); |
|
962 } |
|
963 return retVal; |
|
964 } |
|
965 |
|
966 XAresult CMMFBackendEngine::PausePlayback() |
|
967 { |
|
968 XAresult retVal(XA_RESULT_SUCCESS); |
|
969 switch (iMediaPlayerState) |
|
970 { |
|
971 case XA_PLAYSTATE_PLAYING: |
|
972 case XA_PLAYSTATE_STOPPED: |
|
973 if ((iAPIBeingUsed == EAudioPlayerUtility) || |
|
974 (iAPIBeingUsed == EVideoPlayerUtility) ) |
|
975 { |
|
976 TInt pauseOpRes(KErrNone); |
|
977 if (iAPIBeingUsed == EAudioPlayerUtility) |
|
978 { |
|
979 TAG_TIME_PROFILING_BEGIN; |
|
980 pauseOpRes = iAudioPlayer->Pause(); |
|
981 TAG_TIME_PROFILING_END; |
|
982 PRINT_TO_CONSOLE_TIME_DIFF; |
|
983 } |
|
984 else if (iAPIBeingUsed == EVideoPlayerUtility) |
|
985 { |
|
986 TAG_TIME_PROFILING_BEGIN; |
|
987 TRAP(pauseOpRes, iVideoPlayer->PauseL()); |
|
988 if (pauseOpRes == KErrNone) |
|
989 { |
|
990 TRAPD(err, iPlaybackHead = iVideoPlayer->PositionL()); |
|
991 if (err != KErrNone) |
|
992 { |
|
993 iPlaybackHead = 0; |
|
994 } |
|
995 } |
|
996 TAG_TIME_PROFILING_END; |
|
997 PRINT_TO_CONSOLE_TIME_DIFF; |
|
998 } |
|
999 if ( pauseOpRes == KErrNone) |
|
1000 { |
|
1001 iMediaPlayerState = XA_PLAYSTATE_PAUSED; |
|
1002 iMMFPlayerState = EPlayerPaused; |
|
1003 iMarkerPositionTimer->Stop(); |
|
1004 iPlayItfPositionUpdateTimer->Stop(); |
|
1005 } |
|
1006 } |
|
1007 break; |
|
1008 case XA_PLAYSTATE_PAUSED: |
|
1009 break; |
|
1010 case XA_PLAYSTATE_PLAYERUNINITIALIZED: |
|
1011 default: |
|
1012 retVal = XA_RESULT_INTERNAL_ERROR; |
|
1013 break; |
|
1014 } |
|
1015 return retVal; |
|
1016 } |
|
1017 |
|
1018 XAresult CMMFBackendEngine::StopPlayback() |
|
1019 { |
|
1020 XAresult retVal(XA_RESULT_SUCCESS); |
|
1021 switch (iMediaPlayerState) |
|
1022 { |
|
1023 case XA_PLAYSTATE_PAUSED: |
|
1024 case XA_PLAYSTATE_PLAYING: |
|
1025 if ((iAPIBeingUsed == EAudioPlayerUtility) || |
|
1026 (iAPIBeingUsed == EVideoPlayerUtility) ) |
|
1027 { |
|
1028 if (iAPIBeingUsed == EAudioPlayerUtility) |
|
1029 { |
|
1030 TAG_TIME_PROFILING_BEGIN; |
|
1031 iAudioPlayer->Stop(); |
|
1032 TAG_TIME_PROFILING_END; |
|
1033 PRINT_TO_CONSOLE_TIME_DIFF; |
|
1034 |
|
1035 iMMFPlayerState = EPlayerOpened; |
|
1036 } |
|
1037 else if (iAPIBeingUsed == EVideoPlayerUtility) |
|
1038 { |
|
1039 TAG_TIME_PROFILING_BEGIN; |
|
1040 iVideoPlayer->Stop(); |
|
1041 TAG_TIME_PROFILING_END; |
|
1042 PRINT_TO_CONSOLE_TIME_DIFF; |
|
1043 |
|
1044 iMMFPlayerState = EPlayerPrepared; |
|
1045 } |
|
1046 iMediaPlayerState = XA_PLAYSTATE_STOPPED; |
|
1047 iPlaybackHead = 0; |
|
1048 iMarkerPositionTimer->Stop(); |
|
1049 iPlayItfPositionUpdateTimer->Stop(); |
|
1050 } |
|
1051 break; |
|
1052 case XA_PLAYSTATE_STOPPED: |
|
1053 break; |
|
1054 case XA_PLAYSTATE_PLAYERUNINITIALIZED: |
|
1055 default: |
|
1056 retVal = XA_RESULT_INTERNAL_ERROR; |
|
1057 break; |
|
1058 } |
|
1059 return retVal; |
|
1060 } |
|
1061 XAresult CMMFBackendEngine::GetPlayState(XAuint32 *pState) |
|
1062 { |
|
1063 XAresult retVal(XA_RESULT_INTERNAL_ERROR); |
|
1064 switch (iMediaPlayerState) |
|
1065 { |
|
1066 case XA_PLAYSTATE_STOPPED: |
|
1067 case XA_PLAYSTATE_PAUSED: |
|
1068 case XA_PLAYSTATE_PLAYING: |
|
1069 *pState = iMediaPlayerState; |
|
1070 retVal = XA_RESULT_SUCCESS; |
|
1071 break; |
|
1072 case XA_PLAYSTATE_PLAYERUNINITIALIZED: |
|
1073 default: |
|
1074 break; |
|
1075 } |
|
1076 return retVal; |
|
1077 } |
|
1078 |
|
1079 XAresult CMMFBackendEngine::GetDuration(XAmillisecond *pMsec) |
|
1080 { |
|
1081 XAresult retVal(XA_RESULT_INTERNAL_ERROR); |
|
1082 /* to convert from microseconds to milliseconds */ |
|
1083 TInt64 divider(1000); |
|
1084 switch (iMediaPlayerState) |
|
1085 { |
|
1086 case XA_PLAYSTATE_STOPPED: |
|
1087 case XA_PLAYSTATE_PAUSED: |
|
1088 case XA_PLAYSTATE_PLAYING: |
|
1089 /* TODO Check if we query from MMF*/ |
|
1090 *pMsec = iMediaDuration.Int64() / divider; |
|
1091 retVal = XA_RESULT_SUCCESS; |
|
1092 break; |
|
1093 case XA_PLAYSTATE_PLAYERUNINITIALIZED: |
|
1094 default: |
|
1095 break; |
|
1096 } |
|
1097 return retVal; |
|
1098 } |
|
1099 |
|
1100 XAresult CMMFBackendEngine::GetPosition(XAmillisecond *pMsec) |
|
1101 { |
|
1102 XAresult retVal(XA_RESULT_INTERNAL_ERROR); |
|
1103 TInt64 divider(1000); |
|
1104 TTimeIntervalMicroSeconds pos; |
|
1105 switch (iMediaPlayerState) |
|
1106 { |
|
1107 case XA_PLAYSTATE_STOPPED: |
|
1108 case XA_PLAYSTATE_PAUSED: |
|
1109 case XA_PLAYSTATE_PLAYING: |
|
1110 if (iAPIBeingUsed == EAudioPlayerUtility) |
|
1111 { |
|
1112 if (iAudioPlayer->GetPosition(pos) == KErrNone) |
|
1113 { |
|
1114 *pMsec = pos.Int64() / divider; |
|
1115 retVal = XA_RESULT_SUCCESS; |
|
1116 } |
|
1117 } |
|
1118 else if (iAPIBeingUsed == EVideoPlayerUtility) |
|
1119 { |
|
1120 TInt err(KErrNone); |
|
1121 TRAP(err, pos = iVideoPlayer->PositionL()); |
|
1122 if (err == KErrNone) |
|
1123 { |
|
1124 *pMsec = pos.Int64() / divider; |
|
1125 retVal = XA_RESULT_SUCCESS; |
|
1126 } |
|
1127 } |
|
1128 break; |
|
1129 case XA_PLAYSTATE_PLAYERUNINITIALIZED: |
|
1130 default: |
|
1131 break; |
|
1132 } |
|
1133 return retVal; |
|
1134 } |
|
1135 |
|
1136 XAresult CMMFBackendEngine::SetPosition(XAmillisecond pMsec) |
|
1137 { |
|
1138 XAresult retVal(XA_RESULT_INTERNAL_ERROR); |
|
1139 TInt64 multiplier(1000); |
|
1140 TTimeIntervalMicroSeconds pos; |
|
1141 switch (iMediaPlayerState) |
|
1142 { |
|
1143 case XA_PLAYSTATE_STOPPED: |
|
1144 case XA_PLAYSTATE_PAUSED: |
|
1145 case XA_PLAYSTATE_PLAYING: |
|
1146 if(iAPIBeingUsed == EAudioPlayerUtility) |
|
1147 { |
|
1148 pos = pMsec * multiplier; |
|
1149 TAG_TIME_PROFILING_BEGIN; |
|
1150 iAudioPlayer->SetPosition(pos); |
|
1151 TAG_TIME_PROFILING_END; |
|
1152 PRINT_TO_CONSOLE_TIME_DIFF; |
|
1153 |
|
1154 retVal = XA_RESULT_SUCCESS; |
|
1155 } |
|
1156 else if (iAPIBeingUsed == EVideoPlayerUtility) |
|
1157 { |
|
1158 pos = pMsec * multiplier; |
|
1159 TAG_TIME_PROFILING_BEGIN; |
|
1160 TRAPD(err, iVideoPlayer->SetPositionL(pos)); |
|
1161 TAG_TIME_PROFILING_END; |
|
1162 PRINT_TO_CONSOLE_TIME_DIFF; |
|
1163 if (err == KErrNone) |
|
1164 { |
|
1165 retVal = XA_RESULT_SUCCESS; |
|
1166 } |
|
1167 } |
|
1168 break; |
|
1169 case XA_PLAYSTATE_PLAYERUNINITIALIZED: |
|
1170 default: |
|
1171 break; |
|
1172 } |
|
1173 return retVal; |
|
1174 } |
|
1175 |
|
1176 XAresult CMMFBackendEngine::SetRepeats(XAboolean repeat) |
|
1177 { |
|
1178 XAresult retVal(XA_RESULT_INTERNAL_ERROR); |
|
1179 TInt numRepeats(0); |
|
1180 switch (iMediaPlayerState) |
|
1181 { |
|
1182 case XA_PLAYSTATE_STOPPED: |
|
1183 case XA_PLAYSTATE_PAUSED: |
|
1184 case XA_PLAYSTATE_PLAYING: |
|
1185 if(iAPIBeingUsed == EAudioPlayerUtility) |
|
1186 { |
|
1187 numRepeats = repeat ? -2 : 0; |
|
1188 iAudioPlayer->SetRepeats(numRepeats, 0); |
|
1189 retVal = XA_RESULT_SUCCESS; |
|
1190 } |
|
1191 else |
|
1192 { |
|
1193 } |
|
1194 break; |
|
1195 case XA_PLAYSTATE_PLAYERUNINITIALIZED: |
|
1196 default: |
|
1197 break; |
|
1198 } |
|
1199 return retVal; |
|
1200 } |
|
1201 |
|
1202 XAresult CMMFBackendEngine::SetPlayWindow(XAmillisecond start, XAmillisecond end) |
|
1203 { |
|
1204 XAresult retVal(XA_RESULT_INTERNAL_ERROR); |
|
1205 TInt64 multiplier(1000); |
|
1206 TTimeIntervalMicroSeconds startpos(0); |
|
1207 TTimeIntervalMicroSeconds endpos(0); |
|
1208 |
|
1209 switch (iMediaPlayerState) |
|
1210 { |
|
1211 case XA_PLAYSTATE_STOPPED: |
|
1212 case XA_PLAYSTATE_PAUSED: |
|
1213 case XA_PLAYSTATE_PLAYING: |
|
1214 if(iAPIBeingUsed == EAudioPlayerUtility) |
|
1215 { |
|
1216 startpos = start * multiplier; |
|
1217 endpos = end * multiplier; |
|
1218 retVal = iAudioPlayer->SetPlayWindow(startpos,endpos); |
|
1219 } |
|
1220 else |
|
1221 { |
|
1222 } |
|
1223 break; |
|
1224 case XA_PLAYSTATE_PLAYERUNINITIALIZED: |
|
1225 default: |
|
1226 break; |
|
1227 } |
|
1228 return retVal; |
|
1229 } |
|
1230 |
|
1231 XAresult CMMFBackendEngine::SetPlayAdaptContext(void * adaptcontext) |
|
1232 { |
|
1233 XAresult retVal(XA_RESULT_SUCCESS); |
|
1234 |
|
1235 iAdaptContext = adaptcontext; |
|
1236 |
|
1237 return retVal; |
|
1238 } |
|
1239 |
|
1240 XAresult CMMFBackendEngine::RegisterCallback(xaPlayCallback cbFunction) |
|
1241 { |
|
1242 iPlayItfCBFunction = cbFunction; |
|
1243 return DoHandlePlayItfAttributesChanged(); |
|
1244 } |
|
1245 |
|
1246 XAresult CMMFBackendEngine::SetCallbackEventsMask(XAuint32 eventflags) |
|
1247 { |
|
1248 iPlayItfEventFlags = eventflags; |
|
1249 return DoHandlePlayItfAttributesChanged(); |
|
1250 } |
|
1251 |
|
1252 XAresult CMMFBackendEngine::SetMarkerPosition(XAmillisecond mSec) |
|
1253 { |
|
1254 iMarkerPosition = mSec; |
|
1255 return DoHandlePlayItfAttributesChanged(); |
|
1256 } |
|
1257 |
|
1258 XAresult CMMFBackendEngine::ClearMarkerPosition() |
|
1259 { |
|
1260 iMarkerPosition = XA_TIME_UNKNOWN; |
|
1261 DoHandlePlayItfAttributesChanged(); |
|
1262 return XA_RESULT_SUCCESS; |
|
1263 } |
|
1264 |
|
1265 XAresult CMMFBackendEngine::SetPositionUpdatePeriod(XAmillisecond mSec) |
|
1266 { |
|
1267 iPositionUpdatePeriod = mSec; |
|
1268 DoHandlePlayItfAttributesChanged(); |
|
1269 return XA_RESULT_SUCCESS; |
|
1270 } |
|
1271 |
|
1272 XAresult CMMFBackendEngine::DoHandlePlayItfAttributesChanged() |
|
1273 { |
|
1274 XAresult retVal(XA_RESULT_SUCCESS); |
|
1275 |
|
1276 iMarkerPositionTimer->SetCallbackEventMask(iPlayItfEventFlags); |
|
1277 iMarkerPositionTimer->RegisterCallback(iPlayItfCBFunction); |
|
1278 iMarkerPositionTimer->SetMarkerPosition(iMarkerPosition); |
|
1279 |
|
1280 iPlayItfPositionUpdateTimer->SetCallbackEventMask(iPlayItfEventFlags); |
|
1281 iPlayItfPositionUpdateTimer->RegisterCallback(iPlayItfCBFunction); |
|
1282 iPlayItfPositionUpdateTimer->SetPositionUpdatePeriod(iPositionUpdatePeriod); |
|
1283 |
|
1284 switch (iMediaPlayerState) |
|
1285 { |
|
1286 case XA_PLAYSTATE_STOPPED: |
|
1287 case XA_PLAYSTATE_PAUSED: |
|
1288 break; |
|
1289 case XA_PLAYSTATE_PLAYING: |
|
1290 iMarkerPositionTimer->Start(); |
|
1291 iPlayItfPositionUpdateTimer->Start(); |
|
1292 break; |
|
1293 case XA_PLAYSTATE_PLAYERUNINITIALIZED: |
|
1294 default: |
|
1295 break; |
|
1296 } |
|
1297 return retVal; |
|
1298 } |
|
1299 |
|
1300 void CMMFBackendEngine::DoPostEvent(XAuint32 event) |
|
1301 { |
|
1302 if ((iPlayItfEventFlags & event) && |
|
1303 (iPlayItfCBFunction != NULL)) |
|
1304 { |
|
1305 XAAdaptEvent xaevent = {XA_PLAYITFEVENTS, event, 0, 0 }; |
|
1306 XAAdaptationBase_SendAdaptEvents((XAAdaptationBaseCtx*)iAdaptContext, &xaevent ); |
|
1307 } |
|
1308 } |
|
1309 |
|
1310 XAresult CMMFBackendEngine::GetNumStreams(XAuint32* numstreams) |
|
1311 { |
|
1312 XAresult retVal(XA_RESULT_SUCCESS); |
|
1313 TInt bitRate(0); |
|
1314 TInt numS(0); |
|
1315 if(iAPIBeingUsed == EAudioPlayerUtility) |
|
1316 { |
|
1317 numS = 1; |
|
1318 *numstreams = numS; |
|
1319 } |
|
1320 else if (iAPIBeingUsed == EVideoPlayerUtility) |
|
1321 { |
|
1322 TRAPD(err, bitRate = iVideoPlayer->VideoBitRateL()); |
|
1323 if(!err && bitRate) |
|
1324 { |
|
1325 numS++; |
|
1326 *numstreams = numS; |
|
1327 } |
|
1328 |
|
1329 bitRate = 0; |
|
1330 TRAP(err, bitRate = iVideoPlayer->AudioBitRateL()); |
|
1331 if(!err && bitRate) |
|
1332 { |
|
1333 numS++; |
|
1334 *numstreams = numS; |
|
1335 } |
|
1336 } |
|
1337 return retVal; |
|
1338 } |
|
1339 |
|
1340 XAresult CMMFBackendEngine::GetStreamInfo(XAuint32 streamindex, XAuint32* streamtype) |
|
1341 { |
|
1342 XAresult retVal(XA_RESULT_SUCCESS); |
|
1343 if(iAPIBeingUsed == EAudioPlayerUtility) |
|
1344 { |
|
1345 *streamtype = XA_DOMAINTYPE_AUDIO; |
|
1346 } |
|
1347 else if (iAPIBeingUsed == EVideoPlayerUtility) |
|
1348 { |
|
1349 switch(streamindex) |
|
1350 { |
|
1351 case 1: |
|
1352 *streamtype = XA_DOMAINTYPE_VIDEO; |
|
1353 break; |
|
1354 case 2: |
|
1355 *streamtype = XA_DOMAINTYPE_AUDIO; |
|
1356 break; |
|
1357 default: |
|
1358 retVal = XA_RESULT_PARAMETER_INVALID; |
|
1359 break; |
|
1360 } |
|
1361 } |
|
1362 return retVal; |
|
1363 } |
|
1364 |
|
1365 |
|
1366 XAresult CMMFBackendEngine::GetVideoFrameSize(XAuint32* height, XAuint32* width, XAuint32* frameRate) |
|
1367 { |
|
1368 XAresult retVal(XA_RESULT_SUCCESS); |
|
1369 if(iAPIBeingUsed == EVideoPlayerUtility) |
|
1370 { |
|
1371 if(iMediaPlayerState != XA_PLAYSTATE_PLAYERUNINITIALIZED) |
|
1372 { |
|
1373 TSize size; |
|
1374 TReal32 framerate(0); |
|
1375 TRAPD(err, iVideoPlayer->VideoFrameSizeL(size)); |
|
1376 if(!err) |
|
1377 { |
|
1378 *height = size.iHeight; |
|
1379 *width = size.iWidth; |
|
1380 } |
|
1381 else |
|
1382 { |
|
1383 retVal = err; |
|
1384 } |
|
1385 |
|
1386 TRAP(err, framerate = iVideoPlayer->VideoFrameRateL()); |
|
1387 if(!err) |
|
1388 { |
|
1389 *frameRate = framerate; |
|
1390 } |
|
1391 } |
|
1392 else |
|
1393 { |
|
1394 retVal = XA_RESULT_PRECONDITIONS_VIOLATED; |
|
1395 } |
|
1396 } |
|
1397 else |
|
1398 { |
|
1399 retVal = XA_RESULT_FEATURE_UNSUPPORTED; |
|
1400 } |
|
1401 return retVal; |
|
1402 } |
|
1403 |
|
1404 XAresult CMMFBackendEngine::SetActiveState(XAuint32 streamindex, XAboolean active) |
|
1405 { |
|
1406 XAresult retVal(XA_RESULT_SUCCESS); |
|
1407 TInt err(KErrNone); |
|
1408 if(iAPIBeingUsed == EAudioPlayerUtility) |
|
1409 { |
|
1410 retVal = XA_RESULT_FEATURE_UNSUPPORTED; |
|
1411 } |
|
1412 else if (iAPIBeingUsed == EVideoPlayerUtility) |
|
1413 { |
|
1414 switch(streamindex) |
|
1415 { |
|
1416 case 1: |
|
1417 TRAP(err, iVideoPlayer->SetVideoEnabledL(active)); |
|
1418 retVal = err; |
|
1419 break; |
|
1420 case 2: |
|
1421 TRAP(err, iVideoPlayer->SetAudioEnabledL(active)); |
|
1422 retVal = err; |
|
1423 break; |
|
1424 default: |
|
1425 retVal = XA_RESULT_PARAMETER_INVALID; |
|
1426 break; |
|
1427 } |
|
1428 } |
|
1429 return retVal; |
|
1430 } |
|
1431 |
|
1432 TInt CMMFBackendEngine::InitializeURIForMMFUtil(char *uri) |
|
1433 { |
|
1434 /* Initializes and save uri param into iUri structure */ |
|
1435 TInt err(KErrNone); |
|
1436 TInt uriLen; |
223 |
1437 |
224 nativeDisplay = (XADataLocator_NativeDisplay*) (videoSink->pLocator); |
1438 if (!uri) |
|
1439 return KErrArgument; |
|
1440 |
|
1441 if (iUri) |
|
1442 { |
|
1443 delete iUri; |
|
1444 iUri = NULL; |
|
1445 } |
225 |
1446 |
226 m_pWindow = ((RWindow*)(nativeDisplay->hWindow)); |
1447 uriLen = strlen(uri); |
227 m_pWs = ((RWsSession*)(nativeDisplay->hDisplay)); |
1448 TPtr8 uriParam((TUint8*)uri, uriLen, uriLen); |
228 |
1449 |
229 m_bWindowReferencePassed = TRUE; |
1450 TRAP(err, iUri = HBufC::NewL(uriLen)); |
230 |
1451 if (err != KErrNone) |
231 } |
1452 return err; |
232 |
1453 |
233 //From MVidePlayerUtilityObserver |
1454 iUriPtr.Set(iUri->Des()); |
234 void CMMFBackendEngine::MvpuoOpenComplete(TInt aError) |
1455 iUriPtr.Copy(uriParam); /* Copy data*/ |
235 { |
1456 iUriPtr.LowerCase(); |
236 if(aError == KErrNone) |
1457 |
237 { |
1458 /* For file scheme convert from file:///c:/folder/file.ext |
238 //Issue the command to Play the file |
1459 * format to c:\\folder\\file.ext using TUriParser. */ |
239 TRAPD (error, iVideoPlayer->Prepare()); |
1460 _LIT(KFileScheme,"file:///"); |
240 if (error == KErrNone) |
1461 if (iUriPtr.Find(KFileScheme) >= 0) |
241 { |
1462 { |
242 //prepare success |
1463 TPtr tmp(const_cast<TUint16 *>(iUriPtr.Ptr()) + KFileScheme().Length(), |
243 } |
1464 iUriPtr.Length(), |
244 else |
1465 iUriPtr.Length()); |
245 { |
1466 /* Convert from c:/folder/file.ext format to |
246 //prepare failed |
1467 * c:\\folder\\file.ext using TUriParser. |
247 } |
1468 * TUriParser8 accepts uri in format file:///c/folder/file.ext, |
248 } |
1469 * so get rid of ':' after drive letter (if any) */ |
249 else |
1470 TInt pos = tmp.Find(_L(":")); |
250 { |
1471 if (pos != KErrNotFound) |
251 //could not open file |
1472 { |
252 } |
1473 iUriPtr.Delete(KFileScheme().Length() + pos, 1); |
253 } |
1474 } |
254 |
1475 |
255 |
1476 TUriParser16 uriParser; |
256 |
1477 err = uriParser.Parse(iUriPtr); |
257 void CMMFBackendEngine::MvpuoFrameReady(CFbsBitmap& /*aFrame*/,TInt /*aError*/) |
1478 if (err != KErrNone) |
258 { |
1479 return err; |
259 |
1480 |
260 } |
1481 HBufC* file = NULL; |
261 |
1482 TRAP(err, file = uriParser.GetFileNameL()); |
262 |
1483 if (err != KErrNone) |
263 |
1484 return err; |
264 void CMMFBackendEngine::MvpuoPlayComplete(TInt aError) |
1485 |
265 { |
1486 iUriPtr.Copy(file->Des()); |
266 |
1487 delete file; |
267 |
1488 file = NULL; |
268 if(aError == KErrNone) |
1489 |
269 { |
1490 } |
270 //playback complete |
1491 return err; |
271 } |
1492 } |
272 else |
1493 |
273 { |
1494 |
274 //playback complete with error |
1495 XAresult CMMFBackendEngine::SetVolume(XAuint32 volume) |
275 } |
1496 { |
276 } |
1497 XAresult retVal(XA_RESULT_SUCCESS); |
277 |
|
278 |
|
279 |
|
280 void CMMFBackendEngine::MvpuoEvent(class TMMFEvent const & event) |
|
281 { |
|
282 RDebug::Print(_L("CMMFBackendEngine::MvpuoEvent (0x%x %d)\n"), |
|
283 event.iEventType, event.iErrorCode); |
|
284 |
|
285 if (event.iEventType == KMMFEventCategoryVideoPlayerGeneralError && |
|
286 event.iErrorCode == KErrHardwareNotAvailable) |
|
287 { |
|
288 //audio device taken |
|
289 //handle this case |
|
290 } |
|
291 |
|
292 else if (event.iEventType == KMMFEventCategoryVideoPlayerGeneralError && |
|
293 event.iErrorCode == KErrMMPartialPlayback) |
|
294 { |
|
295 //Partial Playback |
|
296 } |
|
297 |
|
298 else if (event.iEventType == KMMFRefreshMetaData) |
|
299 { |
|
300 //entry = iVideoPlayer->MetaDataEntryL( event.iErrorCode ); |
|
301 } |
|
302 else |
|
303 { |
|
304 |
|
305 } |
|
306 |
|
307 } |
|
308 |
|
309 |
|
310 |
|
311 void CMMFBackendEngine::MvpuoPrepareComplete(TInt aError) |
|
312 { |
|
313 TInt err(KErrNone); |
1498 TInt err(KErrNone); |
314 TAutoScaleType autoScale = EAutoScaleBestFit; |
|
315 if(aError == KErrNone) |
|
316 { |
|
317 if(m_pWindow == NULL) |
|
318 { |
|
319 //no RWindow was given to use so I'll create one and handle it |
|
320 //CreateAndConfigureWindowL(); |
|
321 } |
|
322 else |
|
323 { |
|
324 TRAP(err, iVideoPlayer->AddDisplayWindowL(*m_pWs, *m_pScr, *m_pWindow)); |
|
325 TRAP(err, iVideoPlayer->SetAutoScaleL(*m_pWindow, autoScale)); |
|
326 } |
|
327 |
|
328 TReal beginSecs = 1; |
|
329 TReal intervalSecs = 5; |
|
330 TTimeIntervalMicroSeconds interval(1000000*intervalSecs); |
|
331 TTimeIntervalMicroSeconds beginning(1000000*beginSecs); |
|
332 |
|
333 iVideoPlayer->Play(); |
|
334 iPlayerState = EPlayerPlaying; |
|
335 } |
|
336 } |
|
337 |
|
338 // From MRebufferCallback |
|
339 void CMMFBackendEngine::MvloLoadingStarted() |
|
340 { |
|
341 } |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 void CMMFBackendEngine::MvloLoadingComplete() |
|
347 { |
|
348 //file playing |
|
349 } |
|
350 |
|
351 //MMdaAudioPlayerCallback |
|
352 void CMMFBackendEngine::MapcInitComplete(TInt aError, |
|
353 const TTimeIntervalMicroSeconds& /* aDuration */) |
|
354 { |
|
355 if (aError == KErrNone) |
|
356 { |
|
357 iAudioPlayer->Play(); |
|
358 iPlayerState = EPlayerPlaying; |
|
359 } |
|
360 else |
|
361 { |
|
362 //init failed |
|
363 } |
|
364 } |
|
365 |
|
366 |
|
367 void CMMFBackendEngine::MapcPlayComplete(TInt /* aError */) |
|
368 { |
|
369 //audio playback complete |
|
370 } |
|
371 |
|
372 // from MMdaObjectStateChangeObserver |
|
373 void CMMFBackendEngine::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode) |
|
374 { |
|
375 iPreviousRecordState = aPreviousState; |
|
376 iCurrentRecordState = aCurrentState; |
|
377 iErrorCode = aErrorCode; |
|
378 RDebug::Print(_L("CMMFBackendEngine::MoscoStateChangeEvent 1 Error[%d]"),aErrorCode); |
|
379 if(iCurrentRecordState == CMdaAudioClipUtility::EOpen) //EOpen |
|
380 { |
|
381 //outputfile is open and ready for recording |
|
382 iRecordState = CMMFBackendEngine::ERecorderOpen; |
|
383 if(iErrorCode == KErrNone) |
|
384 { |
|
385 if (iPreviousRecordState == CMdaAudioClipUtility::ENotReady) |
|
386 { |
|
387 RDebug::Print(_L("CMMFBackendEngine::MoscoStateChangeEvent 2")); |
|
388 TMMFMessageDestination destination(KUidMetaDataWriteCustomCommand); |
|
389 TMMFMessageDestinationPckg pckg = TMMFMessageDestinationPckg(destination); |
|
390 TInt ret = iAudioRecorder->RecordControllerCustomCommandSync(pckg, 0, KNullDesC8, KNullDesC8); |
|
391 RDebug::Print(_L("CMMFBackendEngine::MoscoStateChangeEvent 3 [%d]"),ret); |
|
392 if(ret != KErrNone && iFileFormat == XA_CONTAINERTYPE_MP4) |
|
393 { |
|
394 iPauseSupportMP4 = FALSE; |
|
395 } |
|
396 if(iActiveSchedulerWait->IsStarted()) |
|
397 { |
|
398 iActiveSchedulerWait->AsyncStop(); |
|
399 } |
|
400 } |
|
401 } |
|
402 else |
|
403 { |
|
404 XAAdaptEventMMF event = {XA_RECORDITFEVENTS, XA_OBJECT_EVENT_RESOURCES_LOST, 0, NULL}; |
|
405 XAAdaptationBaseMMF_SendAdaptEvents((XAAdaptationBaseMMFCtx*)iAdaptContext, &event ); |
|
406 } |
|
407 } |
|
408 else if(iCurrentRecordState == CMdaAudioClipUtility::ERecording) //ERecording |
|
409 { |
|
410 iRecordState = CMMFBackendEngine::ERecorderRecording; |
|
411 iPositionUpdateTimer->Start(iTimerDelay); |
|
412 XAAdaptEventMMF event = {XA_RECORDITFEVENTS, XA_RECORDEVENT_HEADMOVING, 0, NULL}; |
|
413 XAAdaptationBaseMMF_SendAdaptEvents((XAAdaptationBaseMMFCtx*)iAdaptContext, &event ); |
|
414 } |
|
415 else //ENotReady |
|
416 { |
|
417 //outputfile is not open |
|
418 iRecordState = CMMFBackendEngine::ERecorderNotReady; |
|
419 } |
|
420 } |
|
421 |
|
422 TInt CMMFBackendEngine::SetRecorderState(TRecorderState state, XAboolean stopCalled) |
|
423 { |
|
424 TInt err(KErrNone); |
|
425 switch(state) |
|
426 { |
|
427 case ERecorderNotReady: |
|
428 iAudioRecorder->Close(); |
|
429 iRecordState = ERecorderNotReady; |
|
430 break; |
|
431 case ERecorderOpen: |
|
432 if(iFileFormat == XA_CONTAINERTYPE_MP4 && !iPauseSupportMP4 && !stopCalled) |
|
433 { |
|
434 err = KErrNotSupported; |
|
435 return err; |
|
436 } |
|
437 iPositionUpdateTimer->Stop(); |
|
438 iAudioRecorder->Stop(); |
|
439 iRecordState = ERecorderOpen; |
|
440 break; |
|
441 case ERecorderRecording: |
|
442 TRAP(err, iAudioRecorder->RecordL()); |
|
443 break; |
|
444 } |
|
445 return err; |
|
446 } |
|
447 |
|
448 void CMMFBackendEngine::AudioOpenFile() |
|
449 { |
|
450 TRAPD(err, iAudioPlayer->OpenFileL(iFileName)); |
|
451 if(err) |
|
452 { |
|
453 |
|
454 } |
|
455 } |
|
456 |
|
457 void CMMFBackendEngine::AudioStop() |
|
458 { |
|
459 iAudioPlayer->Stop(); |
|
460 } |
|
461 |
|
462 void CMMFBackendEngine::AudioPause() |
|
463 { |
|
464 iAudioPlayer->Pause(); |
|
465 } |
|
466 |
|
467 void CMMFBackendEngine::AudioClose() |
|
468 { |
|
469 iAudioPlayer->Close(); |
|
470 } |
|
471 |
|
472 void CMMFBackendEngine::ResumePlayback() |
|
473 { |
|
474 if(iPlayerState == EPlayerClosed) |
|
475 { |
|
476 //prepare playback |
|
477 if(iAPIBeingUsed == EAudioPlayerUtility) |
|
478 { |
|
479 AudioOpenFile(); |
|
480 } |
|
481 else |
|
482 { |
|
483 TRAPD (error, iVideoPlayer->OpenFileL(iFileName)); |
|
484 if(error != KErrNone) |
|
485 { |
|
486 |
|
487 } |
|
488 } |
|
489 iPlayerState = EPlayerPaused; |
|
490 } |
|
491 else if (iPlayerState == EPlayerPaused) |
|
492 { |
|
493 if(iAPIBeingUsed == EAudioPlayerUtility) |
|
494 { |
|
495 iAudioPlayer->Play(); |
|
496 } |
|
497 else |
|
498 { |
|
499 iVideoPlayer->Play(); |
|
500 } |
|
501 iPlayerState = EPlayerPlaying; |
|
502 } |
|
503 } |
|
504 |
|
505 void CMMFBackendEngine::PausePlayback() |
|
506 { |
|
507 if(iAPIBeingUsed == EAudioPlayerUtility) |
1499 if(iAPIBeingUsed == EAudioPlayerUtility) |
508 { |
1500 { |
509 AudioPause(); |
1501 retVal = iAudioPlayer->SetVolume(volume); |
510 } |
1502 } |
511 else |
1503 else if (iAPIBeingUsed == EVideoPlayerUtility) |
512 { |
1504 { |
513 TRAPD(err, iVideoPlayer->PauseL()); |
1505 TRAP(err, iVideoPlayer->SetVolumeL(volume)); |
514 if(err != KErrNone) |
1506 retVal = err; |
515 { |
1507 } |
516 |
1508 else if(iAPIBeingUsed == EAudioRecorderUtility) |
517 } |
1509 { |
518 } |
1510 retVal = iAudioRecorder->SetVolume(volume); |
519 iPlayerState = EPlayerPaused; |
1511 } |
520 } |
1512 return retVal; |
521 |
1513 } |
522 void CMMFBackendEngine::StopPlayback() |
1514 |
523 { |
1515 XAresult CMMFBackendEngine::GetMaxVolume(XAuint32* maxvolume) |
|
1516 { |
|
1517 XAresult retVal(XA_RESULT_SUCCESS); |
524 if(iAPIBeingUsed == EAudioPlayerUtility) |
1518 if(iAPIBeingUsed == EAudioPlayerUtility) |
525 { |
1519 { |
526 AudioStop(); |
1520 *maxvolume = iAudioPlayer->MaxVolume(); |
527 } |
1521 } |
528 if(iAPIBeingUsed == EVideoPlayerUtility) |
1522 else if (iAPIBeingUsed == EVideoPlayerUtility) |
529 { |
1523 { |
530 iVideoPlayer->Stop(); |
1524 *maxvolume = iVideoPlayer->MaxVolume(); |
531 } |
1525 } |
532 iPlayerState = EPlayerClosed; |
1526 else if(iAPIBeingUsed == EAudioRecorderUtility) |
533 } |
1527 { |
534 |
1528 *maxvolume = iAudioRecorder->MaxVolume(); |
535 void CMMFBackendEngine::CloseAndDestroy() |
1529 } |
536 { |
1530 return retVal; |
537 if (iBaseVideoPlayer && iVideoPlayer) |
1531 } |
538 { |
1532 |
539 iVideoPlayer->Close(); |
1533 XAresult CMMFBackendEngine::GetVolume(XAuint32* volume) |
540 delete iBaseVideoPlayer; |
1534 { |
541 iVideoPlayer = NULL; |
1535 XAresult retVal(XA_RESULT_SUCCESS); |
542 iBaseVideoPlayer = NULL; |
1536 TInt mmfvolume(0); |
543 } |
1537 if(iAPIBeingUsed == EAudioPlayerUtility) |
544 |
1538 { |
545 if (iBaseAudioPlayer && iAudioPlayer) |
1539 retVal = iAudioPlayer->GetVolume(mmfvolume); |
546 { |
1540 if(retVal == XA_RESULT_SUCCESS) |
547 iAudioPlayer->Close(); |
1541 { |
548 delete iBaseAudioPlayer; |
1542 *volume = mmfvolume; |
549 iAudioPlayer = NULL; |
1543 } |
550 iBaseAudioPlayer = NULL; |
1544 } |
551 } |
1545 else if (iAPIBeingUsed == EVideoPlayerUtility) |
552 |
1546 { |
553 if (iBaseAudioRecorder) |
1547 *volume = iVideoPlayer->Volume(); |
554 { |
1548 } |
555 iAudioRecorder->Close(); |
1549 else if(iAPIBeingUsed == EAudioRecorderUtility) |
556 delete iBaseAudioRecorder; |
1550 { |
557 iAudioRecorder = NULL; |
1551 retVal = iAudioRecorder->GetVolume(mmfvolume); |
558 iBaseAudioRecorder = NULL; |
1552 if(retVal == XA_RESULT_SUCCESS) |
559 } |
1553 { |
560 |
1554 *volume = mmfvolume; |
561 if(iPositionUpdateTimer) |
1555 } |
562 { |
1556 } |
563 delete iPositionUpdateTimer; |
1557 return retVal; |
564 iPositionUpdateTimer = NULL; |
|
565 } |
|
566 |
|
567 if(iActiveSchedulerWait) |
|
568 { |
|
569 if(iActiveSchedulerWait->IsStarted()) |
|
570 { |
|
571 iActiveSchedulerWait->AsyncStop(); |
|
572 } |
|
573 delete iActiveSchedulerWait; |
|
574 iActiveSchedulerWait = NULL; |
|
575 } |
|
576 } |
|
577 |
|
578 void CMMFBackendEngine::SetNativeDisplayInformation(void* display_info) |
|
579 { |
|
580 //display_info is of type XADataSink |
|
581 //display_info.pLocator is of type XADataLocator_NativeDisplay |
|
582 m_bWindowReferencePassed = TRUE; |
|
583 XADataLocator_NativeDisplay* nativeDisplay; |
|
584 XADataSink* videoSink = (XADataSink*)display_info; |
|
585 |
|
586 nativeDisplay = (XADataLocator_NativeDisplay*) (videoSink->pLocator); |
|
587 //TODO: scrDevice is not been passed Properly |
|
588 // Add the display window |
|
589 m_cropRegion = TRect(((RWindow*)(nativeDisplay->hWindow))->Size()); |
|
590 m_videoExtent = TRect(((RWindow*)(nativeDisplay->hWindow))->Size()); |
|
591 m_cropRect = TRect(((RWindow*)(nativeDisplay->hWindow))->Size()); |
|
592 m_clipRect = TRect(((RWindow*)(nativeDisplay->hWindow))->Size()); |
|
593 m_cropRegion = TRect(((RWindow*)(nativeDisplay->hWindow))->Size()); |
|
594 m_pWindow = ((RWindow*)(nativeDisplay->hWindow)); |
|
595 m_pWs = ((RWsSession*)(nativeDisplay->hDisplay)); |
|
596 |
|
597 TRAPD(err, m_pScr = new(ELeave) CWsScreenDevice(*m_pWs)); |
|
598 if(err == KErrNone) |
|
599 { |
|
600 m_pScr->Construct(); |
|
601 } |
|
602 } |
|
603 |
|
604 TInt CMMFBackendEngine::GetRecordPosition(XAuint64* position) |
|
605 { |
|
606 TInt err(KErrNone); |
|
607 *position = iAudioRecorder->Position().Int64(); |
|
608 return err; |
|
609 } |
|
610 |
|
611 TInt CMMFBackendEngine::SetPositionUpdatePerioed(XAmillisecond period) |
|
612 { |
|
613 TInt err(KErrNone); |
|
614 iTimerDelay = period; |
|
615 return err; |
|
616 } |
|
617 |
|
618 TInt CMMFBackendEngine::SetAdaptContext(void* adaptcontext) |
|
619 { |
|
620 TInt err(KErrNone); |
|
621 iAdaptContext = adaptcontext; |
|
622 TRAP(err, iPositionUpdateTimer = new (ELeave) LocalTimer(this, iAdaptContext)); |
|
623 if(!err) |
|
624 { |
|
625 iPositionUpdateTimer->PostInit(); |
|
626 } |
|
627 return err; |
|
628 } |
|
629 |
|
630 TInt CMMFBackendEngine::GetEncoderId(XAuint32* encoderId) |
|
631 { |
|
632 TInt err(KErrNone); |
|
633 if(iRecordState == CMMFBackendEngine::ERecorderOpen) |
|
634 { |
|
635 TFourCC dest; |
|
636 TRAP(err, dest = iAudioRecorder->DestinationDataTypeL()); |
|
637 if(err == KErrNone) |
|
638 { |
|
639 *encoderId = dest.FourCC(); |
|
640 } |
|
641 } |
|
642 return err; |
|
643 } |
|
644 |
|
645 TInt CMMFBackendEngine::GetDestinationBitRate(XAuint32* bitrate) |
|
646 { |
|
647 TInt err(KErrNone); |
|
648 TUint br(0); |
|
649 if(iRecordState == CMMFBackendEngine::ERecorderOpen) |
|
650 { |
|
651 TRAP(err, br = iAudioRecorder->DestinationBitRateL()); |
|
652 if(err == KErrNone) |
|
653 { |
|
654 *bitrate = br; |
|
655 } |
|
656 } |
|
657 return err; |
|
658 } |
|
659 |
|
660 TInt CMMFBackendEngine::GetDestinationSampleRate(XAmilliHertz* samplerate) |
|
661 { |
|
662 TInt err(KErrNone); |
|
663 TUint sr(0); |
|
664 if(iRecordState == CMMFBackendEngine::ERecorderOpen) |
|
665 { |
|
666 TRAP(err, sr = iAudioRecorder->DestinationSampleRateL()); |
|
667 if(err == KErrNone) |
|
668 { |
|
669 *samplerate = sr; |
|
670 } |
|
671 } |
|
672 return err; |
|
673 } |
|
674 |
|
675 TInt CMMFBackendEngine::GetDestinationChannels(XAuint32* channels) |
|
676 { |
|
677 TInt err(KErrNone); |
|
678 TUint ch(0); |
|
679 if(iRecordState == CMMFBackendEngine::ERecorderOpen) |
|
680 { |
|
681 TRAP(err,ch = iAudioRecorder->DestinationNumberOfChannelsL()); |
|
682 if(err == KErrNone) |
|
683 { |
|
684 *channels = ch; |
|
685 } |
|
686 } |
|
687 return err; |
|
688 } |
|
689 |
|
690 TInt CMMFBackendEngine::SetDestinationBitRate(XAuint32* bitrate) |
|
691 { |
|
692 TInt err(KErrNone); |
|
693 if(iRecordState == CMMFBackendEngine::ERecorderOpen) |
|
694 { |
|
695 TRAP(err, iAudioRecorder->SetDestinationBitRateL(*bitrate)); |
|
696 if(err != KErrNone) |
|
697 { |
|
698 return XA_RESULT_PARAMETER_INVALID; |
|
699 } |
|
700 } |
|
701 return err; |
|
702 } |
|
703 |
|
704 TInt CMMFBackendEngine::SetDestinationSampleRate(XAmilliHertz* samplerate) |
|
705 { |
|
706 TInt err(KErrNone); |
|
707 if(iRecordState == CMMFBackendEngine::ERecorderOpen) |
|
708 { |
|
709 TRAP(err, iAudioRecorder->SetDestinationSampleRateL(*samplerate)); |
|
710 if(err != KErrNone) |
|
711 { |
|
712 return XA_RESULT_PARAMETER_INVALID; |
|
713 } |
|
714 } |
|
715 return err; |
|
716 } |
|
717 |
|
718 TInt CMMFBackendEngine::SetDestinationChannels(XAuint32* channels) |
|
719 { |
|
720 TInt err(KErrNone); |
|
721 if(iRecordState == CMMFBackendEngine::ERecorderOpen) |
|
722 { |
|
723 TRAP(err,iAudioRecorder->SetDestinationNumberOfChannelsL(*channels)); |
|
724 if(err != KErrNone) |
|
725 { |
|
726 return XA_RESULT_PARAMETER_INVALID; |
|
727 } |
|
728 } |
|
729 return err; |
|
730 } |
1558 } |
731 |
1559 |
732 extern "C" { |
1560 extern "C" { |
733 |
1561 |
734 int mmf_backend_engine_init(void** engine) |
1562 int mmf_backend_engine_init(void** engine) |
735 { |
1563 { |
736 TRAPD(err, *engine = CMMFBackendEngine::NewL()); |
1564 TRAPD(err, *engine = CMMFBackendEngine::NewL()); |
737 return err; |
1565 return err; |
738 /*int err = CreateEngine(engine); |
1566 } |
739 return err;*/ |
1567 |
740 } |
1568 void mmf_backend_engine_deinit(void* engine) |
741 |
1569 { |
|
1570 delete ((CMMFBackendEngine*)engine); |
|
1571 } |
|
1572 |
742 int mmf_set_recorder_uri(void* context, char* uri, XAuint32 format) |
1573 int mmf_set_recorder_uri(void* context, char* uri, XAuint32 format) |
743 { |
1574 { |
744 return ((CMMFBackendEngine*)(context))->SetFileName(uri,format,CMMFBackendEngine::ERecord); |
1575 return ((CMMFBackendEngine*)(context))->SetFileName(uri,format,CMMFBackendEngine::ERecord); |
745 } |
1576 } |
746 |
1577 |
747 void mmf_set_player_uri(void* context, char* uri, XAuint32 format) |
|
748 { |
|
749 ((CMMFBackendEngine*)(context))->SetFileName(uri,format,CMMFBackendEngine::EPlay); |
|
750 } |
|
751 |
|
752 int mmf_set_adapt_context(void* context, void* adaptcontext) |
1578 int mmf_set_adapt_context(void* context, void* adaptcontext) |
753 { |
1579 { |
754 return ((CMMFBackendEngine*)(context))->SetAdaptContext(adaptcontext); |
1580 return ((CMMFBackendEngine*)(context))->SetAdaptContext(adaptcontext); |
755 } |
1581 } |
756 |
1582 |
757 void mmf_pause_playback(void* context) |
1583 void mmf_close(void* context) |
758 { |
1584 { |
759 ((CMMFBackendEngine*)(context))->PausePlayback(); |
1585 ((CMMFBackendEngine*)context)->Close(); |
760 } |
1586 } |
761 |
1587 |
762 void mmf_resume_playback(void* context) |
1588 int mmf_start_recording(void* context) |
763 { |
1589 { |
764 ((CMMFBackendEngine*)(context))->ResumePlayback(); |
1590 return ((CMMFBackendEngine*)(context))->SetRecorderState(CMMFBackendEngine::ERecorderRecording,FALSE); |
765 } |
1591 } |
766 void mmf_set_window_handle(void* context, void* display_info) |
1592 |
767 { |
1593 int mmf_stop_recording(void* context, XAboolean stopCalled ) |
768 ((CMMFBackendEngine*)(context))->SetWindowHandle(display_info); |
1594 { |
|
1595 return ((CMMFBackendEngine*)(context))->SetRecorderState(CMMFBackendEngine::ERecorderOpen, stopCalled); |
|
1596 } |
|
1597 |
|
1598 int mmf_get_record_position(void* context, XAuint64* position) |
|
1599 { |
|
1600 return ((CMMFBackendEngine*)(context))->GetRecordPosition(position); |
|
1601 } |
|
1602 |
|
1603 int mmf_set_record_position_update_period(void* context, XAmillisecond msec) |
|
1604 { |
|
1605 return ((CMMFBackendEngine*)(context))->SetPositionUpdatePerioed(msec); |
|
1606 } |
|
1607 |
|
1608 int mmf_get_codec_id(void* context, XAuint32* encoderId) |
|
1609 { |
|
1610 return ((CMMFBackendEngine*)(context))->GetCodecId(encoderId); |
|
1611 } |
|
1612 |
|
1613 int mmf_get_channels(void* context, XAuint32* channelsIn) |
|
1614 { |
|
1615 return ((CMMFBackendEngine*)(context))->GetChannels(channelsIn); |
|
1616 } |
|
1617 |
|
1618 int mmf_get_samplerate(void* context, XAmilliHertz* sampleRate) |
|
1619 { |
|
1620 return ((CMMFBackendEngine*)(context))->GetSampleRate(sampleRate); |
|
1621 } |
|
1622 |
|
1623 int mmf_get_bitrate(void* context, XAuint32* bitRate) |
|
1624 { |
|
1625 return ((CMMFBackendEngine*)(context))->GetBitRate(bitRate); |
|
1626 } |
|
1627 |
|
1628 int mmf_set_destination_channels(void* context, XAuint32* channelsIn) |
|
1629 { |
|
1630 return ((CMMFBackendEngine*)(context))->SetDestinationChannels(channelsIn); |
|
1631 } |
|
1632 |
|
1633 int mmf_set_destination_samplerate(void* context, XAmilliHertz* sampleRate) |
|
1634 { |
|
1635 return ((CMMFBackendEngine*)(context))->SetDestinationSampleRate(sampleRate); |
|
1636 } |
|
1637 |
|
1638 int mmf_set_destination_bitrate(void* context, XAuint32* bitRate) |
|
1639 { |
|
1640 return ((CMMFBackendEngine*)(context))->SetDestinationBitRate(bitRate); |
|
1641 } |
|
1642 |
|
1643 XAresult mmf_set_play_adapt_context(void * context, void * adaptcontext) |
|
1644 { |
|
1645 return ((CMMFBackendEngine *)(context))->SetPlayAdaptContext(adaptcontext); |
|
1646 } |
|
1647 |
|
1648 XAresult mmf_set_player_uri(void * context, char * uri, XAuint32 format) |
|
1649 { |
|
1650 return ((CMMFBackendEngine *)(context))->SetFileName(uri,format,CMMFBackendEngine::EPlay); |
|
1651 } |
|
1652 |
|
1653 /* |
|
1654 XAresult mmf_set_window_handle(void * context, void * display_info) |
|
1655 { |
|
1656 return ((CMMFBackendEngine *)(context))->SetWindowHandle(display_info); |
|
1657 } |
|
1658 |
|
1659 */ |
|
1660 XAresult mmf_setup_native_display(void * context, void * display_info) |
|
1661 { |
|
1662 return ((CMMFBackendEngine *)(context))->SetNativeDisplayInformation(display_info); |
|
1663 } |
|
1664 |
|
1665 XAresult mmf_playitf_resume_playback(void * context) |
|
1666 { |
|
1667 return ((CMMFBackendEngine *)(context))->ResumePlayback(); |
|
1668 } |
|
1669 |
|
1670 XAresult mmf_playitf_pause_playback(void * context) |
|
1671 { |
|
1672 return ((CMMFBackendEngine *)(context))->PausePlayback(); |
|
1673 } |
|
1674 |
|
1675 XAresult mmf_playitf_stop_playback(void * context) |
|
1676 { |
|
1677 return ((CMMFBackendEngine *)(context))->StopPlayback(); |
|
1678 } |
|
1679 |
|
1680 XAresult mmf_playitf_get_play_state(void * context, XAuint32 * pState) |
|
1681 { |
|
1682 return ((CMMFBackendEngine *)(context))->GetPlayState(pState); |
|
1683 } |
|
1684 |
|
1685 XAresult mmf_playitf_get_duration(void * context, XAmillisecond * pMsec) |
|
1686 { |
|
1687 return ((CMMFBackendEngine *)(context))->GetDuration(pMsec); |
|
1688 } |
|
1689 |
|
1690 XAresult mmf_playitf_get_position(void * context, XAmillisecond * pMsec) |
|
1691 { |
|
1692 return ((CMMFBackendEngine *)(context))->GetPosition(pMsec); |
|
1693 } |
|
1694 |
|
1695 XAresult mmf_playitf_register_callback(void * context, xaPlayCallback callback) |
|
1696 { |
|
1697 return ((CMMFBackendEngine *)(context))->RegisterCallback(callback); |
|
1698 } |
|
1699 |
|
1700 XAresult mmf_playitf_set_callback_events_mask(void * context, XAuint32 eventflags) |
|
1701 { |
|
1702 return ((CMMFBackendEngine *)(context))->SetCallbackEventsMask(eventflags); |
|
1703 } |
|
1704 |
|
1705 XAresult mmf_playitf_set_marker_position(void * context, XAmillisecond mSec) |
|
1706 { |
|
1707 return ((CMMFBackendEngine *)(context))->SetMarkerPosition(mSec); |
|
1708 } |
|
1709 |
|
1710 XAresult mmf_playitf_clear_marker_position(void * context) |
|
1711 { |
|
1712 return ((CMMFBackendEngine *)(context))->ClearMarkerPosition(); |
|
1713 |
|
1714 } |
|
1715 |
|
1716 XAresult mmf_playitf_set_position_update_period(void * context, XAmillisecond mSec) |
|
1717 { |
|
1718 return ((CMMFBackendEngine *)(context))->SetPositionUpdatePeriod(mSec); |
|
1719 } |
|
1720 |
|
1721 XAresult mmf_seekitf_set_position(void * context, XAmillisecond pMsec) |
|
1722 { |
|
1723 return ((CMMFBackendEngine *)(context))->SetPosition(pMsec); |
|
1724 } |
|
1725 |
|
1726 XAresult mmf_seekitf_set_playwindow(void * context, XAmillisecond start, XAmillisecond end) |
|
1727 { |
|
1728 return ((CMMFBackendEngine *)(context))->SetPlayWindow(start,end); |
|
1729 } |
|
1730 |
|
1731 XAresult mmf_seekitf_set_repeats(void * context, XAboolean repeat) |
|
1732 { |
|
1733 return ((CMMFBackendEngine *)(context))->SetRepeats(repeat); |
|
1734 } |
|
1735 |
|
1736 XAresult mmf_streaminformationitf_get_streaminfo(void * context, XAuint32 streamindex, |
|
1737 XAuint32* streamtype) |
|
1738 { |
|
1739 return ((CMMFBackendEngine *)(context))->GetStreamInfo(streamindex, streamtype); |
|
1740 } |
|
1741 |
|
1742 XAresult mmf_streaminformationitf_get_numstreams(void * context, XAuint32* numstreams) |
|
1743 { |
|
1744 return ((CMMFBackendEngine *)(context))->GetNumStreams(numstreams); |
|
1745 } |
|
1746 |
|
1747 XAresult mmf_streaminformationitf_get_videoframesize(void * context, XAuint32* height, |
|
1748 XAuint32* width, XAuint32* frameRate) |
|
1749 { |
|
1750 return ((CMMFBackendEngine *)(context))->GetVideoFrameSize(height,width,frameRate); |
|
1751 } |
|
1752 |
|
1753 XAresult mmf_streaminformationitf_set_activestream(void * context, XAuint32 streamindex, |
|
1754 XAboolean active) |
|
1755 { |
|
1756 return ((CMMFBackendEngine *)(context))->SetActiveState(streamindex, active); |
769 } |
1757 } |
770 |
1758 |
771 void mmf_stop_playback(void* context) |
1759 XAresult mmf_volumeitf_set_volume(void * context, XAuint32 volume) |
772 { |
1760 { |
773 ((CMMFBackendEngine*)(context))->StopPlayback(); |
1761 return ((CMMFBackendEngine *)(context))->SetVolume(volume); |
774 } |
1762 } |
775 void mmf_close(void* context) |
1763 |
776 { |
1764 XAresult mmf_volumeitf_get_maxvolume(void * context, XAuint32* volume) |
777 delete ((CMMFBackendEngine*)context); |
1765 { |
778 } |
1766 return ((CMMFBackendEngine *)(context))->GetMaxVolume(volume); |
779 void mmf_setup_native_display(void* context, void* display_info) |
|
780 { |
|
781 ((CMMFBackendEngine*)(context))->SetNativeDisplayInformation(display_info); |
|
782 } |
|
783 |
|
784 int mmf_start_recording(void* context) |
|
785 { |
|
786 return ((CMMFBackendEngine*)(context))->SetRecorderState(CMMFBackendEngine::ERecorderRecording,FALSE); |
|
787 } |
|
788 |
|
789 int mmf_stop_recording(void* context, XAboolean stopCalled ) |
|
790 { |
|
791 return ((CMMFBackendEngine*)(context))->SetRecorderState(CMMFBackendEngine::ERecorderOpen, stopCalled); |
|
792 } |
|
793 |
|
794 int mmf_get_record_position(void* context, XAuint64* position) |
|
795 { |
|
796 return ((CMMFBackendEngine*)(context))->GetRecordPosition(position); |
|
797 } |
|
798 |
|
799 int mmf_set_record_position_update_period(void* context, XAmillisecond msec) |
|
800 { |
|
801 return ((CMMFBackendEngine*)(context))->SetPositionUpdatePerioed(msec); |
|
802 } |
1767 } |
803 |
1768 |
804 int mmf_get_encoder_id(void* context, XAuint32* encoderId) |
1769 XAresult mmf_volumeitf_get_volume(void * context, XAuint32* volume) |
805 { |
1770 { |
806 return ((CMMFBackendEngine*)(context))->GetEncoderId(encoderId); |
1771 return ((CMMFBackendEngine *)(context))->GetVolume(volume); |
807 } |
1772 } |
808 |
|
809 int mmf_get_destination_channels(void* context, XAuint32* channelsIn) |
|
810 { |
|
811 return ((CMMFBackendEngine*)(context))->GetDestinationChannels(channelsIn); |
|
812 } |
|
813 |
|
814 int mmf_get_destination_samplerate(void* context, XAmilliHertz* sampleRate) |
|
815 { |
|
816 return ((CMMFBackendEngine*)(context))->GetDestinationSampleRate(sampleRate); |
|
817 } |
|
818 |
|
819 int mmf_get_destination_bitrate(void* context, XAuint32* bitRate) |
|
820 { |
|
821 return ((CMMFBackendEngine*)(context))->GetDestinationBitRate(bitRate); |
|
822 } |
|
823 |
|
824 int mmf_set_destination_channels(void* context, XAuint32* channelsIn) |
|
825 { |
|
826 return ((CMMFBackendEngine*)(context))->SetDestinationChannels(channelsIn); |
|
827 } |
|
828 |
|
829 int mmf_set_destination_samplerate(void* context, XAmilliHertz* sampleRate) |
|
830 { |
|
831 return ((CMMFBackendEngine*)(context))->SetDestinationSampleRate(sampleRate); |
|
832 } |
|
833 |
|
834 int mmf_set_destination_bitrate(void* context, XAuint32* bitRate) |
|
835 { |
|
836 return ((CMMFBackendEngine*)(context))->SetDestinationBitRate(bitRate); |
|
837 } |
|
838 |
|
839 } |
1773 } |