311 AddVideoCodecL( static_cast<CMceVideoStream&>( *streams[i] ) ); |
311 AddVideoCodecL( static_cast<CMceVideoStream&>( *streams[i] ) ); |
312 } |
312 } |
313 } |
313 } |
314 } |
314 } |
315 |
315 |
316 file->TranscodeL( aFileName ); |
316 // Set dest file already before transcoding as output file is deleted in failure case |
317 |
317 iTranscodingDestFileName = aFileName; |
|
318 TRAPD( err, file->TranscodeL( aFileName ) ); |
|
319 HandleTranscodingFailureL( err ); |
318 iTranscodingOngoing = ETrue; |
320 iTranscodingOngoing = ETrue; |
319 |
321 |
320 iTranscodingDestFileName = aFileName; |
|
321 |
322 |
322 MUS_LOG( "mus: [ENGINE] <- CMusEngClipSession::TranscodeL(...)" ) |
323 MUS_LOG( "mus: [ENGINE] <- CMusEngClipSession::TranscodeL(...)" ) |
323 } |
324 } |
324 |
325 |
325 |
326 |
339 err = err; // Silence warning in UREL build |
340 err = err; // Silence warning in UREL build |
340 MUS_LOG1( "mus: [ENGINE] - cancel result %d", err ) |
341 MUS_LOG1( "mus: [ENGINE] - cancel result %d", err ) |
341 // Even if cancel fails, try to delete the partial clip |
342 // Even if cancel fails, try to delete the partial clip |
342 |
343 |
343 MUS_LOG( "mus: [ENGINE] - delete the partially converted clip" ) |
344 MUS_LOG( "mus: [ENGINE] - delete the partially converted clip" ) |
344 RFs fs; |
345 |
345 User::LeaveIfError( fs.Connect() ); |
346 DeleteTranscodingDestinationFileL(); |
346 CleanupClosePushL( fs ); |
|
347 |
|
348 CFileMan* fileMan = CFileMan::NewL( fs ); |
|
349 CleanupStack::PushL( fileMan ); |
|
350 |
|
351 MUS_LOG_TDESC8( "mus: [ENGINE] - trascoding destination filename", |
|
352 iTranscodingDestFileName ) |
|
353 err = fileMan->Delete( iTranscodingDestFileName ); |
|
354 MUS_LOG1( "mus: [ENGINE] - file delete result %d", err ) |
|
355 |
|
356 CleanupStack::PopAndDestroy( fileMan ); |
|
357 CleanupStack::PopAndDestroy(); // fs |
|
358 |
347 |
359 MUS_LOG( "mus: [ENGINE] <- CMusEngClipSession::CancelTranscodeL()" ) |
348 MUS_LOG( "mus: [ENGINE] <- CMusEngClipSession::CancelTranscodeL()" ) |
360 } |
349 } |
361 |
350 |
362 |
351 |
481 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
470 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
482 |
471 |
483 const RPointerArray<CMceMediaStream>& streams = iSession->Streams(); |
472 const RPointerArray<CMceMediaStream>& streams = iSession->Streams(); |
484 |
473 |
485 TBool transcodingRequired = EFalse; |
474 TBool transcodingRequired = EFalse; |
|
475 TBool transcodingRequiredDueUnknownCaps = EFalse; |
486 |
476 |
487 if ( iVideoCodecList ) |
477 if ( iVideoCodecList ) |
488 { |
478 { |
489 MUS_LOG_TDESC8( "iVideoCodecList: ", iVideoCodecList->Des() ) |
479 MUS_LOG_TDESC8( "iVideoCodecList: ", iVideoCodecList->Des() ) |
490 } |
480 } |
491 |
481 |
492 CMceVideoStream* videoStream = NULL; |
482 CMceVideoStream* videoStream = NULL; |
493 for ( TInt i = 0; i < streams.Count(); ++i ) |
483 for ( TInt i = 0; i < streams.Count(); ++i ) |
494 { |
484 { |
495 if ( streams[i]->State() == CMceMediaStream::ETranscodingRequired ) |
485 videoStream = static_cast<CMceVideoStream*>( streams[i] ); |
|
486 |
|
487 if ( iTranscodingRequiredDueMissingOptions ) |
|
488 { |
|
489 MUS_LOG( " -> establish with current codec, remote capa unknown!!!" ) |
|
490 TBool ignoreOptionsQueryCodecs( ETrue ); |
|
491 AddVideoCodecL( *videoStream, ignoreOptionsQueryCodecs ); |
|
492 } |
|
493 else if ( streams[i]->State() == CMceMediaStream::ETranscodingRequired ) |
496 { |
494 { |
497 transcodingRequired = ETrue; |
495 transcodingRequired = ETrue; |
498 } |
496 } |
499 else if ( streams[i]->Type() == KMceVideo && |
497 else if ( streams[i]->Type() == KMceVideo && !IsH264Supported() ) |
500 !IsH264Supported() ) |
|
501 { |
498 { |
502 MUS_LOG( " -> video stream found!!!" ) |
499 MUS_LOG( " -> video stream found!!!" ) |
503 videoStream = static_cast<CMceVideoStream*>( streams[i] ); |
|
504 |
500 |
505 //transcoding of H264 is not needed only if we know explicitly |
501 //transcoding of H264 is not needed only if we know explicitly |
506 //that the peer supports it (from OPTIONS response) |
502 //that the peer supports it (from OPTIONS response) |
507 |
|
508 const RPointerArray<CMceVideoCodec>& codecs = videoStream->Codecs(); |
503 const RPointerArray<CMceVideoCodec>& codecs = videoStream->Codecs(); |
509 for ( TInt codecIndex = 0; codecIndex < codecs.Count(); ++codecIndex ) |
504 for ( TInt codecIndex = 0; codecIndex < codecs.Count(); ++codecIndex ) |
510 { |
505 { |
511 if ( codecs[codecIndex]->SdpName() == KMceSDPNameH264() ) |
506 if ( codecs[codecIndex]->SdpName() == KMceSDPNameH264() ) |
512 { |
507 { |
513 transcodingRequired = ETrue; |
508 transcodingRequired = ETrue; |
|
509 transcodingRequiredDueUnknownCaps = !iVideoCodecList; |
514 MUS_LOG( " -> Removing H264 codec from video stream" ) |
510 MUS_LOG( " -> Removing H264 codec from video stream" ) |
515 videoStream->RemoveCodecL( *codecs[codecIndex] ); |
511 videoStream->RemoveCodecL( *codecs[codecIndex] ); |
516 codecIndex = 0; |
512 codecIndex = 0; |
517 } |
513 } |
518 } |
514 } |
524 AddVideoCodecL( *videoStream ); |
520 AddVideoCodecL( *videoStream ); |
525 } |
521 } |
526 } |
522 } |
527 } |
523 } |
528 |
524 |
|
525 iTranscodingRequiredDueMissingOptions = transcodingRequiredDueUnknownCaps; |
|
526 |
529 if ( transcodingRequired ) |
527 if ( transcodingRequired ) |
530 { |
528 { |
531 iClipSessionObserver.TranscodingNeeded(); |
529 iClipSessionObserver.TranscodingNeeded(iTranscodingRequiredDueMissingOptions); |
532 } |
530 } |
533 else |
531 else |
534 { |
532 { |
535 CMusEngMceOutSession::EstablishSessionL(); |
533 CMusEngMceOutSession::EstablishSessionL(); |
536 // Now session state is right to adjust volume |
534 // Now session state is right to adjust volume |
593 |
591 |
594 // Filename has been updated in MCE side but unfortunately |
592 // Filename has been updated in MCE side but unfortunately |
595 // there's no getter for the filename in API. |
593 // there's no getter for the filename in API. |
596 iFileName = iTranscodingDestFileName; |
594 iFileName = iTranscodingDestFileName; |
597 |
595 |
598 iTranscodingOngoing = EFalse; |
596 DoCompleteTranscoding(); |
599 |
|
600 iClipSessionObserver.TranscodingCompletedInit(); |
|
601 |
|
602 TRAPD( error, EstablishSessionL() ) |
|
603 if ( error != KErrNone ) |
|
604 { |
|
605 iSessionObserver.SessionFailed(); |
|
606 } |
|
607 |
|
608 // Next call does not return before session establishment |
|
609 iClipSessionObserver.TranscodingCompletedFinalize(); |
|
610 } |
597 } |
611 } |
598 } |
612 else if ( aStream.State() == CMceMediaStream::ETranscodingRequired && |
599 else if ( aStream.State() == CMceMediaStream::ETranscodingRequired && |
613 iTranscodingOngoing ) |
600 iTranscodingOngoing ) |
614 { |
601 { |
615 MUS_LOG( "mus: [ENGINE] Transcoding failed." ) |
602 MUS_LOG( "mus: [ENGINE] Transcoding failed." ) |
616 |
603 |
617 iClipSessionObserver.TranscodingFailed(); |
604 iClipSessionObserver.TranscodingFailed(); |
618 iTranscodingOngoing = EFalse; |
605 iTranscodingOngoing = EFalse; |
|
606 iTranscodingRequiredDueMissingOptions = EFalse; |
619 } |
607 } |
620 else if ( HasClipEnded() ) |
608 else if ( HasClipEnded() ) |
621 { |
609 { |
622 MUS_LOG( "mus: [ENGINE] Clip ended." ) |
610 MUS_LOG( "mus: [ENGINE] Clip ended." ) |
623 |
611 |
739 // ----------------------------------------------------------------------------- |
727 // ----------------------------------------------------------------------------- |
740 // Create codec instance, H264 is used only if other end supports it for sure, |
728 // Create codec instance, H264 is used only if other end supports it for sure, |
741 // otherwise H263 is used. |
729 // otherwise H263 is used. |
742 // ----------------------------------------------------------------------------- |
730 // ----------------------------------------------------------------------------- |
743 // |
731 // |
744 void CMusEngClipSession::AddVideoCodecL( CMceVideoStream& aVideoStream ) |
732 void CMusEngClipSession::AddVideoCodecL( |
|
733 CMceVideoStream& aVideoStream, TBool aIgnoreNegotiated ) |
745 { |
734 { |
746 MUS_LOG( "mus: [ENGINE] -> CMusEngClipSession::AddVideoCodecL" ) |
735 MUS_LOG( "mus: [ENGINE] -> CMusEngClipSession::AddVideoCodecL" ) |
747 |
736 |
748 // Remove old codecs |
737 // Remove old codecs |
749 |
738 |
755 const RPointerArray<const CMceVideoCodec>& supportedCodecs = |
744 const RPointerArray<const CMceVideoCodec>& supportedCodecs = |
756 iManager->SupportedVideoCodecs(); |
745 iManager->SupportedVideoCodecs(); |
757 |
746 |
758 CMceVideoCodec* addedCodec = NULL; |
747 CMceVideoCodec* addedCodec = NULL; |
759 |
748 |
760 TPtrC8 addedCodecName = |
749 TPtrC8 addedCodecName = ( aIgnoreNegotiated || IsH264Supported() ) ? |
761 IsH264Supported() ? KMceSDPNameH264() : KMceSDPNameH2632000(); |
750 KMceSDPNameH264() : KMceSDPNameH2632000(); |
762 |
751 |
763 MUS_LOG_TDESC8( "mus: [ENGINE] adding codec : ", addedCodecName ); |
752 MUS_LOG_TDESC8( "mus: [ENGINE] adding codec : ", addedCodecName ); |
764 |
753 |
765 for ( TInt i = 0; i < supportedCodecs.Count(); ++i ) |
754 for ( TInt i = 0; i < supportedCodecs.Count(); ++i ) |
766 { |
755 { |
1005 // |
994 // |
1006 TBool CMusEngClipSession::IsH264Supported() const |
995 TBool CMusEngClipSession::IsH264Supported() const |
1007 { |
996 { |
1008 return ( iVideoCodecList && iVideoCodecList->FindF( KMceSDPNameH264() ) >= 0 ); |
997 return ( iVideoCodecList && iVideoCodecList->FindF( KMceSDPNameH264() ) >= 0 ); |
1009 } |
998 } |
1010 |
999 |
|
1000 // ----------------------------------------------------------------------------- |
|
1001 // |
|
1002 // ----------------------------------------------------------------------------- |
|
1003 // |
|
1004 void CMusEngClipSession::HandleTranscodingFailureL( TInt aError ) |
|
1005 { |
|
1006 if ( aError == KErrNone ) |
|
1007 { |
|
1008 return; |
|
1009 } |
|
1010 |
|
1011 TRAP_IGNORE( DeleteTranscodingDestinationFileL() ) |
|
1012 |
|
1013 User::LeaveIfError( aError ); |
|
1014 } |
|
1015 |
|
1016 // ----------------------------------------------------------------------------- |
|
1017 // |
|
1018 // ----------------------------------------------------------------------------- |
|
1019 // |
|
1020 TInt CMusEngClipSession::DoCompleteTranscoding() |
|
1021 { |
|
1022 iTranscodingOngoing = EFalse; |
|
1023 |
|
1024 iClipSessionObserver.TranscodingCompletedInit(); |
|
1025 |
|
1026 TRAPD( error, EstablishSessionL() ) |
|
1027 iTranscodingRequiredDueMissingOptions = EFalse; |
|
1028 if ( error != KErrNone ) |
|
1029 { |
|
1030 iSessionObserver.SessionFailed(); |
|
1031 } |
|
1032 |
|
1033 // Next call does not return before session establishment |
|
1034 iClipSessionObserver.TranscodingCompletedFinalize(); |
|
1035 |
|
1036 return error; |
|
1037 } |
|
1038 |
|
1039 // ----------------------------------------------------------------------------- |
|
1040 // |
|
1041 // ----------------------------------------------------------------------------- |
|
1042 // |
|
1043 void CMusEngClipSession::DeleteTranscodingDestinationFileL() |
|
1044 { |
|
1045 RFs fs; |
|
1046 User::LeaveIfError( fs.Connect() ); |
|
1047 CleanupClosePushL( fs ); |
|
1048 |
|
1049 CFileMan* fileMan = CFileMan::NewL( fs ); |
|
1050 CleanupStack::PushL( fileMan ); |
|
1051 |
|
1052 MUS_LOG_TDESC8( "mus: [ENGINE] - deleting trascoding destination, filename", |
|
1053 iTranscodingDestFileName ) |
|
1054 TInt err = fileMan->Delete( iTranscodingDestFileName ); |
|
1055 MUS_LOG1( "mus: [ENGINE] - file delete result %d", err ) |
|
1056 |
|
1057 CleanupStack::PopAndDestroy( fileMan ); |
|
1058 CleanupStack::PopAndDestroy(); // fs |
|
1059 } |
|
1060 |
1011 // End of file |
1061 // End of file |
1012 |
1062 |