1 /* |
1 /* |
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
25 _LIT( KMimeType, "MimeType" ); |
25 _LIT( KMimeType, "MimeType" ); |
26 _LIT8( KImageEncoderMimeType, "image/jpeg" ); |
26 _LIT8( KImageEncoderMimeType, "image/jpeg" ); |
27 _LIT( KMimeTypeAudio, "audio/*" ); |
27 _LIT( KMimeTypeAudio, "audio/*" ); |
28 _LIT( KMimeTypeVideo, "video/*" ); |
28 _LIT( KMimeTypeVideo, "video/*" ); |
29 |
29 |
30 const TInt KVideoClipTimeout( 10000000 ); // 10 sec. |
30 const TInt KRequestTimeOut( 20000000 ); // 20 sec. |
31 |
31 |
32 // ----------------------------------------------------------------------------- |
32 // ----------------------------------------------------------------------------- |
33 // CSConVideoParser::CSConVideoParser() |
33 // CSConVideoParser::CSConVideoParser() |
34 // ----------------------------------------------------------------------------- |
34 // ----------------------------------------------------------------------------- |
35 // |
35 // |
88 TRACE_FUNC_ENTRY; |
95 TRACE_FUNC_ENTRY; |
89 |
96 |
90 User::LeaveIfError( iWsSession.Connect() ); |
97 User::LeaveIfError( iWsSession.Connect() ); |
91 |
98 |
92 iScreen = new(ELeave) CWsScreenDevice( iWsSession ); |
99 iScreen = new(ELeave) CWsScreenDevice( iWsSession ); |
93 iScreen->Construct(); |
100 User::LeaveIfError( iScreen->Construct() ); |
94 |
101 |
95 RWindowGroup wg( iWsSession ); |
102 iRootWindow = RWindowGroup(iWsSession); |
96 User::LeaveIfError( wg.Construct(reinterpret_cast<TUint32>(&wg), EFalse) ); |
103 User::LeaveIfError( iRootWindow.Construct(reinterpret_cast<TUint32>(&iWsSession), EFalse) ); |
97 CleanupClosePushL( wg ); |
104 |
98 |
105 iWindow = new(ELeave) RWindow( iWsSession ); |
99 CWindowGc* gc; |
106 User::LeaveIfError( iWindow->Construct(iRootWindow, reinterpret_cast<TUint32>(&iRootWindow) + 1) ); |
100 User::LeaveIfError( iScreen->CreateContext(gc) ); |
|
101 CleanupStack::PushL(gc); |
|
102 |
|
103 RWindow window( iWsSession ); |
|
104 User::LeaveIfError( window.Construct(wg, reinterpret_cast<TUint32>(&wg) + 1) ); |
|
105 CleanupClosePushL( window ); |
|
106 |
107 |
107 TRect temp(0,0,320,240); // dummy parameter |
108 TRect temp(0,0,320,240); // dummy parameter |
108 iVideoUtil = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal, EMdaPriorityPreferenceNone, iWsSession, *(iScreen), window, temp, temp); |
109 iVideoUtil = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal, EMdaPriorityPreferenceNone, iWsSession, *iScreen, *iWindow, temp, temp); |
109 |
|
110 CleanupStack::PopAndDestroy( &window ); |
|
111 CleanupStack::PopAndDestroy( gc ); |
|
112 CleanupStack::PopAndDestroy( &wg ); |
|
113 |
110 |
114 iTimeOut = CSconTimeOut::NewL( *this ); |
111 iTimeOut = CSconTimeOut::NewL( *this ); |
115 |
112 |
116 TRACE_FUNC_EXIT; |
113 TRACE_FUNC_EXIT; |
117 } |
114 } |
151 TBool fileExist = BaflUtils::FileExists( aFs, aFileName ); |
148 TBool fileExist = BaflUtils::FileExists( aFs, aFileName ); |
152 if ( !fileExist ) |
149 if ( !fileExist ) |
153 { |
150 { |
154 User::Leave( KErrNotFound ); |
151 User::Leave( KErrNotFound ); |
155 } |
152 } |
156 |
153 iAsyncStopCalled = EFalse; |
157 iVideoClip = CTNEVideoClipInfo::NewL( aFileName, *this ); |
154 iVideoClip = CTNEVideoClipInfo::NewL( aFileName, *this ); |
158 |
155 |
159 iVideoUtil->OpenFileL( aFileName ); |
156 iVideoUtil->OpenFileL( aFileName ); |
160 |
157 |
|
158 LOGGER_WRITE("Start timeout"); |
|
159 iTimeOut->Start( KRequestTimeOut ); |
161 |
160 |
162 LOGGER_WRITE("iWait.Start()"); |
161 LOGGER_WRITE("iWait.Start()"); |
163 iWait.Start(); |
162 iWait.Start(); |
164 |
163 |
165 TRACE_FUNC_EXIT; |
164 TRACE_FUNC_EXIT; |
354 // ----------------------------------------------------------------------------- |
353 // ----------------------------------------------------------------------------- |
355 // |
354 // |
356 void CSConVideoParser::MvpuoOpenComplete( TInt aError ) |
355 void CSConVideoParser::MvpuoOpenComplete( TInt aError ) |
357 { |
356 { |
358 TRACE_FUNC_ENTRY; |
357 TRACE_FUNC_ENTRY; |
|
358 if ( iVideoUtilReady ) |
|
359 { |
|
360 // already timeout |
|
361 LOGGER_WRITE("Already timeout"); |
|
362 return; |
|
363 } |
359 LOGGER_WRITE_1( "aError: %d", aError ); |
364 LOGGER_WRITE_1( "aError: %d", aError ); |
360 if ( aError == KErrNone ) |
365 if ( aError == KErrNone ) |
361 { |
366 { |
362 iVideoUtil->Prepare(); |
367 iVideoUtil->Prepare(); |
363 } |
368 } |
381 // ----------------------------------------------------------------------------- |
388 // ----------------------------------------------------------------------------- |
382 // |
389 // |
383 void CSConVideoParser::MvpuoPrepareComplete( TInt aError ) |
390 void CSConVideoParser::MvpuoPrepareComplete( TInt aError ) |
384 { |
391 { |
385 TRACE_FUNC_ENTRY; |
392 TRACE_FUNC_ENTRY; |
|
393 if ( iVideoUtilReady ) |
|
394 { |
|
395 // already timeout |
|
396 LOGGER_WRITE("Already timeout"); |
|
397 return; |
|
398 } |
386 LOGGER_WRITE_1( "aError: %d", aError ); |
399 LOGGER_WRITE_1( "aError: %d", aError ); |
387 |
400 |
388 iVideoUtilReady = ETrue; |
401 iVideoUtilReady = ETrue; |
389 iVideoUtilErr = aError; |
402 iVideoUtilErr = aError; |
390 |
403 |
391 if ( iVideoUtilReady && iVideoClipReady ) |
404 if ( iVideoUtilReady && iVideoClipReady && !iAsyncStopCalled ) |
392 { |
405 { |
|
406 iAsyncStopCalled = ETrue; |
|
407 iTimeOut->Cancel(); |
393 LOGGER_WRITE("AsyncStop"); |
408 LOGGER_WRITE("AsyncStop"); |
394 iWait.AsyncStop(); |
409 iWait.AsyncStop(); |
395 } |
410 } |
396 TRACE_FUNC_EXIT; |
411 TRACE_FUNC_EXIT; |
397 } |
412 } |
429 // ----------------------------------------------------------------------------- |
444 // ----------------------------------------------------------------------------- |
430 // |
445 // |
431 void CSConVideoParser::NotifyVideoClipInfoReady(CTNEVideoClipInfo& aInfo, TInt aError) |
446 void CSConVideoParser::NotifyVideoClipInfoReady(CTNEVideoClipInfo& aInfo, TInt aError) |
432 { |
447 { |
433 TRACE_FUNC_ENTRY; |
448 TRACE_FUNC_ENTRY; |
|
449 if ( iVideoClipReady ) |
|
450 { |
|
451 // already timeout |
|
452 LOGGER_WRITE("Already timeout"); |
|
453 return; |
|
454 } |
434 LOGGER_WRITE_1("aError: %d", aError); |
455 LOGGER_WRITE_1("aError: %d", aError); |
435 if ( aError == KErrNone ) |
456 if ( aError == KErrNone ) |
436 { |
457 { |
437 TSize resolution(320,240); |
458 TSize resolution(320,240); |
438 TRAPD( err, aInfo.GetThumbL(*this,KBestThumbIndex, &resolution ) ); |
459 TRAPD( err, aInfo.GetThumbL(*this,KBestThumbIndex, &resolution ) ); |
441 { |
462 { |
442 LOGGER_WRITE_1("aInfo.GetThumbL err: %d", err); |
463 LOGGER_WRITE_1("aInfo.GetThumbL err: %d", err); |
443 iVideoClipReady = ETrue; |
464 iVideoClipReady = ETrue; |
444 iVideoClipErr = err; |
465 iVideoClipErr = err; |
445 } |
466 } |
446 else |
|
447 { |
|
448 LOGGER_WRITE("Start timeout"); |
|
449 iTimeOut->Start( KVideoClipTimeout ); |
|
450 } |
|
451 } |
467 } |
452 else |
468 else |
453 { |
469 { |
454 iVideoClipReady = ETrue; |
470 iVideoClipReady = ETrue; |
455 iVideoClipErr = aError; |
471 iVideoClipErr = aError; |
456 } |
472 } |
457 |
473 |
458 if ( iVideoUtilReady && iVideoClipReady ) |
474 if ( iVideoUtilReady && iVideoClipReady && !iAsyncStopCalled ) |
459 { |
475 { |
|
476 iAsyncStopCalled = ETrue; |
|
477 iTimeOut->Cancel(); |
460 LOGGER_WRITE("AsyncStop"); |
478 LOGGER_WRITE("AsyncStop"); |
461 iWait.AsyncStop(); |
479 iWait.AsyncStop(); |
462 } |
480 } |
463 TRACE_FUNC_EXIT; |
481 TRACE_FUNC_EXIT; |
464 } |
482 } |
471 void CSConVideoParser::NotifyVideoClipThumbCompleted(CTNEVideoClipInfo& /*aInfo*/, |
489 void CSConVideoParser::NotifyVideoClipThumbCompleted(CTNEVideoClipInfo& /*aInfo*/, |
472 TInt aError, |
490 TInt aError, |
473 CFbsBitmap* aThumb) |
491 CFbsBitmap* aThumb) |
474 { |
492 { |
475 TRACE_FUNC_ENTRY; |
493 TRACE_FUNC_ENTRY; |
|
494 if ( iVideoClipReady ) |
|
495 { |
|
496 // already timeout |
|
497 LOGGER_WRITE("Already timeout"); |
|
498 delete aThumb; |
|
499 return; |
|
500 } |
476 LOGGER_WRITE_1("aError: %d", aError); |
501 LOGGER_WRITE_1("aError: %d", aError); |
477 iTimeOut->Cancel(); |
|
478 if ( aError == KErrNone) |
502 if ( aError == KErrNone) |
479 { |
503 { |
480 delete iThumbnail; |
504 delete iThumbnail; |
481 iThumbnail = NULL; |
505 iThumbnail = NULL; |
482 LOGGER_WRITE("create CImageEncoder"); |
506 LOGGER_WRITE("create CImageEncoder"); |
523 LOGGER_WRITE("videoclip cancelled"); |
549 LOGGER_WRITE("videoclip cancelled"); |
524 iVideoClipReady = ETrue; |
550 iVideoClipReady = ETrue; |
525 iVideoClipErr = KErrCancel; |
551 iVideoClipErr = KErrCancel; |
526 } |
552 } |
527 |
553 |
528 if ( iVideoUtilReady && iVideoClipReady ) |
554 if ( !iVideoUtilReady ) |
|
555 { |
|
556 LOGGER_WRITE("videoUtil cancelled"); |
|
557 iVideoUtilReady = ETrue; |
|
558 iVideoUtilErr = KErrCancel; |
|
559 } |
|
560 |
|
561 if ( iVideoUtilReady && iVideoClipReady && !iAsyncStopCalled ) |
529 { |
562 { |
530 LOGGER_WRITE("AsyncStop"); |
563 LOGGER_WRITE("AsyncStop"); |
|
564 iAsyncStopCalled = ETrue; |
531 iWait.AsyncStop(); |
565 iWait.AsyncStop(); |
532 } |
566 } |
533 TRACE_FUNC_EXIT; |
567 TRACE_FUNC_EXIT; |
534 } |
568 } |