512 // -------------------------------------------------------------------------- |
633 // -------------------------------------------------------------------------- |
513 // CUPnPPlaybackSession::AvtSetTransportUriResponse |
634 // CUPnPPlaybackSession::AvtSetTransportUriResponse |
514 // See upnpplaybacksession.h |
635 // See upnpplaybacksession.h |
515 // -------------------------------------------------------------------------- |
636 // -------------------------------------------------------------------------- |
516 void CUPnPPlaybackSession::AvtSetTransportUriResponse( |
637 void CUPnPPlaybackSession::AvtSetTransportUriResponse( |
517 const TDesC8& /*aUuid*/, |
638 TInt aErr ) |
518 TInt aSessionId, |
639 { |
|
640 __LOG1( "CUPnPPlaybackSession::AvtSetTransportUriResponse: %d", aErr ); |
|
641 |
|
642 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
643 |
|
644 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
645 EUPnPAVTransportError ); |
|
646 |
|
647 if( aErr == KErrNone ) |
|
648 { |
|
649 if( iPlaybackState == EStopped ) |
|
650 { |
|
651 __LOG( "CUPnPPlaybackSession::AvtSetTransportUriResponse - \ |
|
652 Already in stopped state" ); |
|
653 |
|
654 // Lastchangeevent came already! |
|
655 } |
|
656 else |
|
657 { |
|
658 iIPSessionIdCommand = KErrNotFound; |
|
659 |
|
660 __LOG( "CUPnPPlaybackSession::AvtSetTransportUriResponse - \ |
|
661 Start waiting for CurrentUriMetadata" ); |
|
662 |
|
663 iTimer->Cancel(); |
|
664 iTimer->Start( KTimerCycle10 ); |
|
665 } |
|
666 } |
|
667 else |
|
668 { |
|
669 __ASSERT( iCommandMessage, __FILE__, __LINE__ ); |
|
670 |
|
671 iPlaybackState = EStopped; |
|
672 iExpectedEvent = EEventNone; |
|
673 iCommandMessage->Complete( aErr ); |
|
674 delete iCommandMessage; iCommandMessage = NULL; |
|
675 } |
|
676 } |
|
677 |
|
678 // -------------------------------------------------------------------------- |
|
679 // CUPnPPlaybackSession::AvtGetMediaInfoResponse |
|
680 // See upnpplaybacksession.h |
|
681 // -------------------------------------------------------------------------- |
|
682 // |
|
683 void CUPnPPlaybackSession::AvtGetMediaInfoResponse( |
519 TInt aErr, |
684 TInt aErr, |
520 const TDesC8& aInstanceId, |
685 const TDesC8& aCurrentUri ) |
521 const TDesC8& /*aCurrentUri*/, |
686 { |
522 const TDesC8& /*aCurrentUriMetaData*/) |
687 // GetMediaInfo action request is issued in playing state when an unexpected |
523 { |
688 // playing event is received. If the URI in the renderer does not match with |
524 __LOG1( "CUPnPPlaybackSession::AvtSetTransportUriResponse: %d", aErr ); |
689 // iCurrentUri, it is intepreted as a case where the renderer is being |
525 |
690 // controlled by some other Control Point and therefore a stop event is propagated. |
526 __ASSERTD( iIPSessionIdCommand == aSessionId, __FILE__, __LINE__ ); |
691 |
527 |
692 __LOG1( "CUPnPPlaybackSession::AvtGetMediaInfoResponse %d", aErr ); |
|
693 |
|
694 if ( iCheckForHijackedRenderer ) |
|
695 { |
|
696 __LOG8_1( "CUPnPPlaybackSession::AvtGetMediaInfoResponse: %S", |
|
697 &aCurrentUri ); |
|
698 |
|
699 __LOG8_1( "CUPnPPlaybackSession::AvtGetMediaInfoResponse, iCurrentUri: %S", |
|
700 iCurrentUri ); |
|
701 |
|
702 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
703 iIPSessionIdCommand = KErrNotFound; |
|
704 |
|
705 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
706 EUPnPConnectionManagerError ); |
|
707 |
|
708 if( aErr == KErrNone && iCurrentUri && *iCurrentUri != aCurrentUri ) |
|
709 { |
|
710 // not our URI playing, renderer is hijacked |
|
711 if( iPlaybackState != EStopped ) |
|
712 { |
|
713 // if we're not yet stopped, propagate a stop event |
|
714 __LOG( "CUPnPPlaybackSession::AvtGetMediaInfoResponse -\ |
|
715 unexpected Uri, renderer is being controlled by someone else - propagate a stop event" ); |
|
716 iPlaybackState = EHalted; |
|
717 TUnsolicitedEventC event; |
|
718 event.iEvent = EStop; |
|
719 event.iValue = KErrNotReady; |
|
720 PropagateEvent( event ); |
|
721 } |
|
722 else |
|
723 { |
|
724 // just ignore as someone else keeps controlling the renderer |
|
725 __LOG( "CUPnPPlaybackSession::AvtGetMediaInfoResponse -\ |
|
726 unexpected Uri, renderer is still being controlled by someone else - ignoring this event" ); |
|
727 } |
|
728 } |
|
729 |
|
730 iCheckForHijackedRenderer = EFalse; |
|
731 } |
|
732 } |
|
733 |
|
734 // -------------------------------------------------------------------------- |
|
735 // CUPnPPlaybackSession::AvtGetTransportInfoResponse |
|
736 // Two-phased constructor. |
|
737 // -------------------------------------------------------------------------- |
|
738 // |
|
739 void CUPnPPlaybackSession::AvtGetTransportInfoResponse( |
|
740 TInt aErr, |
|
741 const TDesC8& aCurrenTransportState ) |
|
742 { |
|
743 __LOG1( "CUPnPPlaybackSession::AvtGetTransportInfoResponse %d", aErr ); |
|
744 |
|
745 __LOG8_1( "CUPnPPlaybackSession::AvtGetTransportInfoResponse: %S", |
|
746 &aCurrenTransportState ); |
|
747 |
528 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
748 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
529 iIPSessionIdCommand = KErrNotFound; |
749 iIPSessionIdCommand = KErrNotFound; |
530 TInt temp; |
750 |
531 TLex8 lex( aInstanceId ); |
751 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
532 TInt err = lex.Val( temp ); |
752 EUPnPConnectionManagerError ); |
533 if( err == KErrNone ) |
753 |
534 { |
754 if( aErr == KErrNone ) |
535 __LOG1( "AvtSetTransportUriResponse, instance id: %d", temp ); |
755 { |
536 iInstanceId = temp; |
756 // Send AVTranportUri-action. If an error occurs (leaves), complete |
537 iPlaybackState = EStopped; |
757 // the message with error code. No futher processing can be done |
538 } |
|
539 |
|
540 if( iCommandMessage ) |
|
541 { |
|
542 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
543 EUPnPAVTransportError ); |
|
544 |
758 |
545 if( aErr == KErrNone ) |
759 if( aCurrenTransportState == KNoMedia ) |
546 { |
760 { |
547 iCommandMessage->Complete( EAVControllerSetURICompleted ); |
761 iPlaybackState = ENoMedia; |
548 delete iCommandMessage; iCommandMessage = NULL; |
762 } |
|
763 else if( aCurrenTransportState == KPlaying ) |
|
764 { |
|
765 iPlaybackState = EPlaying; |
|
766 } |
|
767 else if( aCurrenTransportState == KPausedPlayback ) |
|
768 { |
|
769 iPlaybackState = EPaused; |
549 } |
770 } |
550 else |
771 else |
551 { |
772 { |
|
773 iPlaybackState = EStopped; |
|
774 } |
|
775 |
|
776 TRAP( aErr, SendAVTransportUriActionL() ); |
|
777 if( aErr != KErrNone ) |
|
778 { |
|
779 __LOG1( "CUPnPPlaybackSession::AvtGetTransportInfoResponse -\ |
|
780 SendAVTransportUriActionL failed with code %d", aErr ); |
552 iCommandMessage->Complete( aErr ); |
781 iCommandMessage->Complete( aErr ); |
553 delete iCommandMessage; iCommandMessage = NULL; |
782 delete iCommandMessage; iCommandMessage = NULL; |
554 } |
783 } |
555 } |
784 } |
556 else |
785 else |
557 { |
786 { |
558 __LOG( "AvtSetTransportUriResponse - no msg" ); |
787 // Something wrong with the action. Complete the message with error |
559 } |
788 // code. No further processing can be dome. |
560 } |
789 __LOG1( "CUPnPPlaybackSession::AvtGetTransportInfoResponse - \ |
561 |
790 action failed with code %d", aErr ); |
562 // -------------------------------------------------------------------------- |
791 |
563 // CUPnPPlaybackSession::AvtSetNextTransportUriResponse |
792 delete iCurrentItem; iCurrentItem = NULL; |
564 // See upnpplaybacksession.h |
793 delete iCurrentUri; iCurrentUri = NULL; |
565 // -------------------------------------------------------------------------- |
794 |
566 void CUPnPPlaybackSession::AvtSetNextTransportUriResponse( |
795 iCommandMessage->Complete( aErr ); |
567 const TDesC8& /*aUuid*/, |
796 delete iCommandMessage; iCommandMessage = NULL; |
568 TInt aSessionId, |
797 } |
|
798 |
|
799 __LOG( "CUPnPPlaybackSession::AvtGetTransportInfoResponse - end" ); |
|
800 |
|
801 } |
|
802 |
|
803 // -------------------------------------------------------------------------- |
|
804 // CUPnPPlaybackSession::AvtPositionInfoResponse |
|
805 // See upnpplaybacksession.h |
|
806 // -------------------------------------------------------------------------- |
|
807 void CUPnPPlaybackSession::AvtPositionInfoResponse( |
569 TInt aErr, |
808 TInt aErr, |
570 const TDesC8& aInstanceId, |
809 const TDesC8& aTrackDuration, |
571 const TDesC8& /*aNextUri*/, |
810 const TDesC8& aRelTime ) |
572 const TDesC8& /*aNextUriMetaData*/) |
811 { |
573 { |
812 __LOG1( "CUPnPPlaybackSession::AvtPositionInfoResponse: %d", aErr ); |
574 __LOG1( "CUPnPPlaybackSession::AvtSetNextTransportUriResponse: %d", |
813 |
575 aErr ); |
|
576 |
|
577 __ASSERTD( iIPSessionIdCommand == aSessionId, __FILE__, __LINE__ ); |
|
578 |
|
579 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
814 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
580 iIPSessionIdCommand = KErrNotFound; |
815 iIPSessionIdCommand = KErrNotFound; |
581 |
816 |
582 TInt temp; |
|
583 TLex8 lex( aInstanceId ); |
|
584 TInt err = lex.Val( temp ); |
|
585 if( err == KErrNone ) |
|
586 { |
|
587 __LOG1( "AvtSetNextTransportUriResponse, instance id: %d", temp ); |
|
588 //iInstanceId = temp; |
|
589 } |
|
590 |
|
591 if( iCommandMessage ) |
817 if( iCommandMessage ) |
592 { |
818 { |
593 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
819 TInt err = iCommandMessage->Write( 1, aTrackDuration ); |
594 EUPnPAVTransportError ); |
820 err = iCommandMessage->Write( 2, aRelTime ); |
595 |
|
596 if( aErr == KErrNone ) |
|
597 { |
|
598 iCommandMessage->Complete( EAVControllerSetNextURICompleted ); |
|
599 delete iCommandMessage; iCommandMessage = NULL; |
|
600 } |
|
601 else |
|
602 { |
|
603 iCommandMessage->Complete( aErr ); |
|
604 delete iCommandMessage; iCommandMessage = NULL; |
|
605 } |
|
606 } |
|
607 else |
|
608 { |
|
609 __LOG( "AvtSetNextTransportUriResponse - no msg" ); |
|
610 } |
|
611 |
|
612 } |
|
613 |
|
614 // -------------------------------------------------------------------------- |
|
615 // CUPnPPlaybackSession::AvtMediaInfoResponse |
|
616 // See upnpplaybacksession.h |
|
617 // -------------------------------------------------------------------------- |
|
618 void CUPnPPlaybackSession::AvtMediaInfoResponse( |
|
619 const TDesC8& /*aUuid*/, |
|
620 TInt /*aSessionId*/, |
|
621 TInt /*aErr*/, |
|
622 const TDesC8& /*aInstanceId*/, |
|
623 const TDesC8& /*aNrTracks*/, |
|
624 const TDesC8& /*aMediaDuration*/, |
|
625 const TDesC8& /*aCurrentUri*/, |
|
626 const TDesC8& /*aCurrentUriMetaData*/, |
|
627 const TDesC8& /*aNextUri*/, |
|
628 const TDesC8& /*aNextUriMetaData*/, |
|
629 const TDesC8& /*aPlayMedium*/, |
|
630 const TDesC8& /*aRecordMedium*/, |
|
631 const TDesC8& /*aWriteStatus*/) |
|
632 { |
|
633 // No implementation required |
|
634 } |
|
635 |
|
636 // -------------------------------------------------------------------------- |
|
637 // CUPnPPlaybackSession::AvtGetTransportInfoResponse |
|
638 // Two-phased constructor. |
|
639 // -------------------------------------------------------------------------- |
|
640 // |
|
641 void CUPnPPlaybackSession::AvtGetTransportInfoResponse( |
|
642 const TDesC8& /*aUuid*/, |
|
643 TInt /*aSessionId*/, |
|
644 TInt /*aErr*/, |
|
645 const TDesC8& /*aInstanceId*/, |
|
646 const TDesC8& /*aCurrenTransportState*/, |
|
647 const TDesC8& /*aCurrentTransportStatus*/, |
|
648 const TDesC8& /*aCurrentSpeed*/) |
|
649 { |
|
650 // No implementation required |
|
651 } |
|
652 |
|
653 // -------------------------------------------------------------------------- |
|
654 // CUPnPPlaybackSession::AvtPositionInfoResponse |
|
655 // See upnpplaybacksession.h |
|
656 // -------------------------------------------------------------------------- |
|
657 void CUPnPPlaybackSession::AvtPositionInfoResponse( |
|
658 const TDesC8& /*aUuid*/, |
|
659 TInt aSessionId, |
|
660 TInt aErr, |
|
661 const TDesC8& /*aInstanceId*/, |
|
662 const TDesC8& /*aTrack*/, |
|
663 const TDesC8& aTrackDuration, |
|
664 const TDesC8& /*aTrackMetaData*/, |
|
665 const TDesC8& /*aTrackURI*/, |
|
666 const TDesC8& aRelTime, |
|
667 const TDesC8& /*aAbsTime*/, |
|
668 const TDesC8& /*aRelCount*/, |
|
669 const TDesC8& /*aAbsCount*/) |
|
670 { |
|
671 __LOG1( "CUPnPPlaybackSession::AvtPositionInfoResponse: %d", aErr ); |
|
672 |
|
673 __ASSERTD( iIPSessionIdSetting == aSessionId, __FILE__, __LINE__ ); |
|
674 |
|
675 iServer.Dispatcher().UnRegister( iIPSessionIdSetting ); |
|
676 iIPSessionIdSetting = KErrNotFound; |
|
677 |
|
678 if( iSettingMessage ) |
|
679 { |
|
680 TInt err = iSettingMessage->Write( 1, aTrackDuration ); |
|
681 err = iSettingMessage->Write( 2, aRelTime ); |
|
682 // Howto handle err? |
821 // Howto handle err? |
683 |
822 |
684 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
823 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
685 EUPnPAVTransportError ); |
824 EUPnPAVTransportError ); |
686 |
825 |
687 if( aErr == KErrNone ) |
826 if( aErr == KErrNone ) |
688 { |
827 { |
689 iSettingMessage->Complete( EAVControllerPositionInfoCompleted ); |
828 iCommandMessage->Complete( EAVControllerPositionInfoCompleted ); |
690 delete iSettingMessage; iSettingMessage = NULL; |
|
691 } |
829 } |
692 else |
830 else |
693 { |
831 { |
694 iSettingMessage->Complete( aErr ); |
832 iCommandMessage->Complete( aErr ); |
695 delete iSettingMessage; iSettingMessage = NULL; |
|
696 } |
833 } |
|
834 delete iCommandMessage; iCommandMessage = NULL; |
697 } |
835 } |
698 else |
836 else |
699 { |
837 { |
700 __LOG( "AvtPositionInfoResponse - no msg" ); |
838 __LOG( "AvtPositionInfoResponse - no msg" ); |
701 } |
839 } |
702 } |
840 } |
703 |
841 |
704 // -------------------------------------------------------------------------- |
842 // -------------------------------------------------------------------------- |
705 // CUPnPPlaybackSession::AvtDeviceCapabilitiesResponse |
|
706 // See upnpplaybacksession.h |
|
707 // -------------------------------------------------------------------------- |
|
708 void CUPnPPlaybackSession::AvtDeviceCapabilitiesResponse( |
|
709 const TDesC8& /*aUuid*/, |
|
710 TInt /*aSessionId*/, |
|
711 TInt /*aErr*/, |
|
712 const TDesC8& /*aInstanceId*/, |
|
713 const TDesC8& /*aPlayMedia*/, |
|
714 const TDesC8& /*aRecMedia*/, |
|
715 const TDesC8& /*aRecQualityMode*/) |
|
716 { |
|
717 // No implementation required |
|
718 } |
|
719 |
|
720 // -------------------------------------------------------------------------- |
|
721 // CUPnPPlaybackSession::AvtTransportSettingsResponse |
|
722 // See upnpplaybacksession.h |
|
723 // -------------------------------------------------------------------------- |
|
724 void CUPnPPlaybackSession::AvtTransportSettingsResponse( |
|
725 const TDesC8& /*aUuid*/, |
|
726 TInt /*aSessionId*/, |
|
727 TInt /*aErr*/, |
|
728 const TDesC8& /*aInstanceId*/, |
|
729 const TDesC8& /*aPlayMode*/, |
|
730 const TDesC8& /*aRecQualityMode*/) |
|
731 { |
|
732 // No implementation required |
|
733 } |
|
734 |
|
735 // -------------------------------------------------------------------------- |
|
736 // CUPnPPlaybackSession::AvtStopResponse |
843 // CUPnPPlaybackSession::AvtStopResponse |
737 // See upnpplaybacksession.h |
844 // See upnpplaybacksession.h |
738 // -------------------------------------------------------------------------- |
845 // -------------------------------------------------------------------------- |
739 void CUPnPPlaybackSession::AvtStopResponse( |
846 void CUPnPPlaybackSession::AvtStopResponse( |
740 const TDesC8& /*aUuid*/, |
847 TInt aErr ) |
741 TInt aSessionId, |
848 { |
|
849 __LOG1( "CUPnPPlaybackSession::AvtStopResponse: %d", aErr ); |
|
850 |
|
851 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
852 iIPSessionIdCommand = KErrNotFound; |
|
853 |
|
854 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
855 EUPnPAVTransportError ); |
|
856 |
|
857 if( aErr == KErrNone ) |
|
858 { |
|
859 __LOG( "CUPnPPlaybackSession::AvtStopResponse - \ |
|
860 Start waiting for stop event" ); |
|
861 |
|
862 iTimer->Cancel(); |
|
863 iTimer->Start( KTimerCycle10 ); |
|
864 } |
|
865 else |
|
866 { |
|
867 __ASSERT( iCommandMessage, __FILE__, __LINE__ ); |
|
868 |
|
869 //iWaitingResponse = EFalse; |
|
870 iExpectedEvent = EEventNone; |
|
871 iCommandMessage->Complete( aErr ); |
|
872 delete iCommandMessage; iCommandMessage = NULL; |
|
873 } |
|
874 } |
|
875 |
|
876 // -------------------------------------------------------------------------- |
|
877 // CUPnPPlaybackSession::AvtPlayResponse |
|
878 // See upnpplaybacksession.h |
|
879 // -------------------------------------------------------------------------- |
|
880 void CUPnPPlaybackSession::AvtPlayResponse( |
|
881 TInt aErr ) |
|
882 { |
|
883 __LOG1( "CUPnPPlaybackSession::AvtPlayResponse: %d", aErr ); |
|
884 |
|
885 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
886 iIPSessionIdCommand = KErrNotFound; |
|
887 |
|
888 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
889 EUPnPAVTransportError ); |
|
890 |
|
891 if( aErr == KErrNone ) |
|
892 { |
|
893 __LOG( "CUPnPPlaybackSession::AvtPlayResponse - \ |
|
894 Start waiting for play event" ); |
|
895 |
|
896 iTimer->Cancel(); |
|
897 iTimer->Start( KTimerCycle10 ); |
|
898 } |
|
899 else |
|
900 { |
|
901 __ASSERT( iCommandMessage, __FILE__, __LINE__ ); |
|
902 |
|
903 //iWaitingResponse = EFalse; |
|
904 iExpectedEvent = EEventNone; |
|
905 iCommandMessage->Complete( aErr ); |
|
906 delete iCommandMessage; iCommandMessage = NULL; |
|
907 } |
|
908 |
|
909 } |
|
910 |
|
911 // -------------------------------------------------------------------------- |
|
912 // CUPnPPlaybackSession::AvtPauseResponse |
|
913 // See upnpplaybacksession.h |
|
914 // -------------------------------------------------------------------------- |
|
915 void CUPnPPlaybackSession::AvtPauseResponse( |
|
916 TInt aErr ) |
|
917 { |
|
918 __LOG1( "CUPnPPlaybackSession::AvtPauseResponse: %d", aErr ); |
|
919 |
|
920 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
921 iIPSessionIdCommand = KErrNotFound; |
|
922 |
|
923 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
924 EUPnPAVTransportError ); |
|
925 |
|
926 if( aErr == KErrNone ) |
|
927 { |
|
928 __LOG( "CUPnPPlaybackSession::AvtPauseResponse - \ |
|
929 Start waiting for pause event" ); |
|
930 |
|
931 iTimer->Cancel(); |
|
932 iTimer->Start( KTimerCycle10 ); |
|
933 } |
|
934 else |
|
935 { |
|
936 __ASSERT( iCommandMessage, __FILE__, __LINE__ ); |
|
937 |
|
938 //iWaitingResponse = EFalse; |
|
939 iExpectedEvent = EEventNone; |
|
940 iCommandMessage->Complete( aErr ); |
|
941 delete iCommandMessage; iCommandMessage = NULL; |
|
942 } |
|
943 } |
|
944 |
|
945 // -------------------------------------------------------------------------- |
|
946 // CUPnPPlaybackSession::AvtSeekResponse |
|
947 // See upnpplaybacksession.h |
|
948 // -------------------------------------------------------------------------- |
|
949 void CUPnPPlaybackSession::AvtSeekResponse( |
|
950 TInt aErr ) |
|
951 { |
|
952 __LOG1( "CUPnPPlaybackSession::AvtSeekResponse: %d", aErr ); |
|
953 |
|
954 __ASSERT( iCommandMessage, __FILE__, __LINE__ ); |
|
955 |
|
956 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
957 iIPSessionIdCommand = KErrNotFound; |
|
958 |
|
959 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
960 EUPnPAVTransportError ); |
|
961 |
|
962 if( aErr == KErrNone ) |
|
963 { |
|
964 iCommandMessage->Complete( EAVControllerSeekCompleted ); |
|
965 } |
|
966 else |
|
967 { |
|
968 iCommandMessage->Complete( aErr ); |
|
969 } |
|
970 delete iCommandMessage; |
|
971 iCommandMessage = NULL; |
|
972 } |
|
973 |
|
974 |
|
975 // -------------------------------------------------------------------------- |
|
976 // CUPnPPlaybackSession::CmPrepareResponse |
|
977 // See upnpplaybacksession.h |
|
978 // -------------------------------------------------------------------------- |
|
979 void CUPnPPlaybackSession::CmPrepareResponse( |
742 TInt aErr, |
980 TInt aErr, |
743 const TDesC8& /*aInstanceId*/) |
981 TInt aConnection, |
744 { |
982 TInt aTransport, |
745 __LOG1( "CUPnPPlaybackSession::AvtStopResponse: %d", aErr ); |
983 TInt aRsc ) |
746 |
984 { |
747 __ASSERTD( iIPSessionIdCommand == aSessionId, __FILE__, __LINE__ ); |
985 __LOG1( "CUPnPPlaybackSession::CmPrepareResponse %d", aErr ); |
748 |
986 |
749 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
987 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
750 //iCommandPending = EFalse; |
|
751 iIPSessionIdCommand = KErrNotFound; |
988 iIPSessionIdCommand = KErrNotFound; |
752 |
989 |
753 if( iCommandMessage ) |
990 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
754 { |
991 EUPnPConnectionManagerError ); |
755 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
992 |
756 EUPnPAVTransportError ); |
993 if( aErr == KErrNone ) |
757 |
994 { |
758 if( aErr == KErrNone ) |
995 // FIX IOP problem with RC events with Simple Center |
759 { |
996 // Note that this is likely a problem in SC and needs to be verified |
760 iPlaybackState = EStopped; |
997 // once there is another device supporting CM:PrepareForConnection |
761 iCommandMessage->Complete( EAVControllerStopCompleted ); |
998 iRCInstanceId = KDefaultInstanceId; //iRCInstanceId = aRsc; |
762 delete iCommandMessage; iCommandMessage = NULL; |
999 iAVTInstanceId = aTransport; |
763 } |
1000 iConnectionId = aConnection; |
764 else |
1001 |
765 { |
1002 TRAP( aErr, SendGetTransportInfoActionL() ) |
766 iCommandMessage->Complete( aErr ); |
1003 if( aErr != KErrNone ) |
767 delete iCommandMessage; iCommandMessage = NULL; |
1004 { |
768 } |
1005 __LOG1( "CUPnPPlaybackSession::CmPrepareResponse - \ |
769 } |
1006 SendGetTransportInfoActionL failed with code %d", aErr ); |
770 else |
|
771 { |
|
772 __LOG( "AvtStopResponse - no msg" ); |
|
773 } |
|
774 } |
|
775 |
|
776 // -------------------------------------------------------------------------- |
|
777 // CUPnPPlaybackSession::AvtPlayResponse |
|
778 // See upnpplaybacksession.h |
|
779 // -------------------------------------------------------------------------- |
|
780 void CUPnPPlaybackSession::AvtPlayResponse( |
|
781 const TDesC8& /*aUuid*/, |
|
782 TInt aSessionId, |
|
783 TInt aErr, |
|
784 const TDesC8& /*aInstanceId*/, |
|
785 const TDesC8& /*aSpeed*/) |
|
786 { |
|
787 __LOG1( "CUPnPPlaybackSession::AvtPlayResponse: %d", aErr ); |
|
788 |
|
789 __ASSERTD( iIPSessionIdCommand == aSessionId, __FILE__, __LINE__ ); |
|
790 |
|
791 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
792 //iCommandPending = EFalse; |
|
793 iIPSessionIdCommand = KErrNotFound; |
|
794 |
|
795 if( iCommandMessage ) |
|
796 { |
|
797 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
798 EUPnPAVTransportError ); |
|
799 |
|
800 if( aErr == KErrNone ) |
|
801 { |
|
802 iPlaybackState = EPlaying; |
|
803 iCommandMessage->Complete( EAVControllerPlayCompleted ); |
|
804 delete iCommandMessage; iCommandMessage = NULL; |
|
805 } |
|
806 else |
|
807 { |
|
808 iCommandMessage->Complete( aErr ); |
1007 iCommandMessage->Complete( aErr ); |
809 delete iCommandMessage; iCommandMessage = NULL; |
1008 delete iCommandMessage; iCommandMessage = NULL; |
810 } |
1009 } |
|
1010 |
|
1011 __LOG3( "CUPnPPlaybackSession::CmPrepareResponse - \ |
|
1012 AVTid = %d, RCid = %d, connectionid = %d", aTransport, aRsc, aConnection ); |
811 } |
1013 } |
812 else |
1014 else |
813 { |
1015 { |
814 __LOG( "AvtPlayResponse - no msg" ); |
1016 // Something wrong with the action. Complete the message with error |
815 } |
1017 // code. No further processing can be dome. |
816 } |
1018 __LOG1( "CUPnPPlaybackSession::CmPrepareResponse - \ |
817 |
1019 action failed with code %d", aErr ); |
818 // -------------------------------------------------------------------------- |
1020 |
819 // CUPnPPlaybackSession::AvtPauseResponse |
1021 delete iCurrentItem; iCurrentItem = NULL; |
820 // See upnpplaybacksession.h |
1022 delete iCurrentUri; iCurrentUri = NULL; |
821 // -------------------------------------------------------------------------- |
1023 |
822 void CUPnPPlaybackSession::AvtPauseResponse( |
1024 iCommandMessage->Complete( aErr ); |
823 const TDesC8& /*aUuid*/, |
1025 delete iCommandMessage; iCommandMessage = NULL; |
824 TInt aSessionId, |
1026 } |
825 TInt aErr, |
1027 |
826 const TDesC8& /*aInstanceId*/) |
1028 __LOG( "CUPnPPlaybackSession::CmPrepareResponse - end" ); |
827 { |
1029 } |
828 __LOG1( "CUPnPPlaybackSession::AvtPauseResponse: %d", aErr ); |
1030 |
829 |
|
830 __ASSERTD( iIPSessionIdCommand == aSessionId, __FILE__, __LINE__ ); |
|
831 |
|
832 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
833 //iCommandPending = EFalse; |
|
834 iIPSessionIdCommand = KErrNotFound; |
|
835 |
|
836 if( iCommandMessage ) |
|
837 { |
|
838 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
839 EUPnPAVTransportError ); |
|
840 |
|
841 if( aErr == KErrNone ) |
|
842 { |
|
843 iPlaybackState = EPaused; |
|
844 iCommandMessage->Complete( EAVControllerPauseCompleted ); |
|
845 delete iCommandMessage; iCommandMessage = NULL; |
|
846 } |
|
847 else |
|
848 { |
|
849 iCommandMessage->Complete( aErr ); |
|
850 delete iCommandMessage; iCommandMessage = NULL; |
|
851 } |
|
852 } |
|
853 else |
|
854 { |
|
855 __LOG( "AvtPauseResponse - no msg" ); |
|
856 } |
|
857 } |
|
858 |
|
859 // -------------------------------------------------------------------------- |
|
860 // CUPnPPlaybackSession::AvtRecordResponse |
|
861 // See upnpplaybacksession.h |
|
862 // -------------------------------------------------------------------------- |
|
863 void CUPnPPlaybackSession::AvtRecordResponse( |
|
864 const TDesC8& /*aUuid*/, |
|
865 TInt /*aSessionId*/, |
|
866 TInt /*aErr*/, |
|
867 const TDesC8& /*aInstanceId*/) |
|
868 { |
|
869 // No implementation required |
|
870 } |
|
871 |
|
872 // -------------------------------------------------------------------------- |
|
873 // CUPnPPlaybackSession::AvtSeekResponse |
|
874 // See upnpplaybacksession.h |
|
875 // -------------------------------------------------------------------------- |
|
876 void CUPnPPlaybackSession::AvtSeekResponse( |
|
877 const TDesC8& /*aUuid*/, |
|
878 TInt /*aSessionId*/, |
|
879 TInt /*aErr*/, |
|
880 const TDesC8& /*aInstanceId*/, |
|
881 const TDesC8& /*aUnit*/, |
|
882 const TDesC8& /*aTarget*/) |
|
883 { |
|
884 // No implementation required |
|
885 } |
|
886 |
|
887 // -------------------------------------------------------------------------- |
|
888 // CUPnPPlaybackSession::AvtNextResponse |
|
889 // See upnpplaybacksession.h |
|
890 // -------------------------------------------------------------------------- |
|
891 void CUPnPPlaybackSession::AvtNextResponse( |
|
892 const TDesC8& /*aUuid*/, |
|
893 TInt /*aSessionId*/, |
|
894 TInt /*aErr*/, |
|
895 const TDesC8& /*aInstanceId*/) |
|
896 { |
|
897 // No implementation required |
|
898 } |
|
899 |
|
900 // -------------------------------------------------------------------------- |
|
901 // CUPnPPlaybackSession::AvtPreviousResponse |
|
902 // See upnpplaybacksession.h |
|
903 // -------------------------------------------------------------------------- |
|
904 void CUPnPPlaybackSession::AvtPreviousResponse( |
|
905 const TDesC8& /*aUuid*/, |
|
906 TInt /*aSessionId*/, |
|
907 TInt /*aErr*/, |
|
908 const TDesC8& /*aInstanceId*/) |
|
909 { |
|
910 // No implementation required |
|
911 } |
|
912 |
|
913 // -------------------------------------------------------------------------- |
|
914 // CUPnPPlaybackSession::AvtSetPlayModeResponse |
|
915 // See upnpplaybacksession.h |
|
916 // -------------------------------------------------------------------------- |
|
917 void CUPnPPlaybackSession::AvtSetPlayModeResponse( |
|
918 const TDesC8& /*aUuid*/, |
|
919 TInt /*aSessionId*/, |
|
920 TInt /*aErr*/, |
|
921 const TDesC8& /*aInstanceId*/, |
|
922 const TDesC8& /*aNewPlayMode*/) |
|
923 { |
|
924 // No implementation required |
|
925 } |
|
926 |
|
927 // -------------------------------------------------------------------------- |
|
928 // CUPnPPlaybackSession::AvtSetRecordModeResponse |
|
929 // See upnpplaybacksession.h |
|
930 // -------------------------------------------------------------------------- |
|
931 void CUPnPPlaybackSession::AvtSetRecordModeResponse( |
|
932 const TDesC8& /*aUuid*/, |
|
933 TInt /*aSessionId*/, |
|
934 TInt /*aErr*/, |
|
935 const TDesC8& /*aInstanceId*/, |
|
936 const TDesC8& /*aNewRecordQuality*/) |
|
937 { |
|
938 // No implementation required |
|
939 } |
|
940 |
|
941 // -------------------------------------------------------------------------- |
|
942 // CUPnPPlaybackSession::CdsSearchCapabilitiesResponse |
|
943 // See upnpplaybacksession.h |
|
944 // -------------------------------------------------------------------------- |
|
945 void CUPnPPlaybackSession::CdsSearchCapabilitiesResponse( |
|
946 const TDesC8& /*aUuid*/, |
|
947 TInt /*aSessionId*/, |
|
948 TInt /*aErr*/, |
|
949 const TDesC8& /*aSearchCaps*/) |
|
950 { |
|
951 // No implementation required |
|
952 } |
|
953 |
|
954 // -------------------------------------------------------------------------- |
|
955 // CUPnPPlaybackSession::CdsSortCapabilitiesResponse |
|
956 // See upnpplaybacksession.h |
|
957 // -------------------------------------------------------------------------- |
|
958 void CUPnPPlaybackSession::CdsSortCapabilitiesResponse( |
|
959 const TDesC8& /*aUuid*/, |
|
960 TInt /*aSessionId*/, |
|
961 TInt /*aErr*/, |
|
962 const TDesC8& /*aSortCaps*/) |
|
963 { |
|
964 // No implementation required |
|
965 } |
|
966 |
|
967 // -------------------------------------------------------------------------- |
|
968 // CUPnPPlaybackSession::CdsSystemUpdateIdResponse |
|
969 // See upnpplaybacksession.h |
|
970 // -------------------------------------------------------------------------- |
|
971 void CUPnPPlaybackSession::CdsSystemUpdateIdResponse( |
|
972 const TDesC8& /*aUuid*/, |
|
973 TInt /*aSessionId*/, |
|
974 TInt /*aErr*/, |
|
975 TInt /*aSystemUpdateId*/) |
|
976 { |
|
977 // No implementation required |
|
978 } |
|
979 |
|
980 // -------------------------------------------------------------------------- |
|
981 // CUPnPPlaybackSession::CdsBrowseResponse |
|
982 // See upnpplaybacksession.h |
|
983 // -------------------------------------------------------------------------- |
|
984 void CUPnPPlaybackSession::CdsBrowseResponse( |
|
985 const TDesC8& /*aUuid*/, |
|
986 TInt /*aSessionId*/, |
|
987 TInt /*aErr*/, |
|
988 const TDesC8& /*aObjectID*/, |
|
989 const TDesC8& /*aBrowseFlag*/, |
|
990 const TDesC8& /*aFilter*/, |
|
991 TInt /*aIndex*/, |
|
992 TInt /*aRequest*/, |
|
993 const TDesC8& /*aSortCriteria*/, |
|
994 const TDesC8& /*aResult*/, |
|
995 TInt /*aReturned*/, |
|
996 TInt /*aMatches*/, |
|
997 const TDesC8& /*aUpdateID*/ ) |
|
998 { |
|
999 } |
|
1000 |
|
1001 // -------------------------------------------------------------------------- |
|
1002 // CUPnPPlaybackSession::CdsSearchResponse |
|
1003 // See upnpplaybacksession.h |
|
1004 // -------------------------------------------------------------------------- |
|
1005 void CUPnPPlaybackSession::CdsSearchResponse( |
|
1006 const TDesC8& /*aUuid*/, |
|
1007 TInt /*aSessionId*/, |
|
1008 TInt /*aErr*/, |
|
1009 const TDesC8& /*aContainerId*/, |
|
1010 const TDesC8& /*aSearchCriteria*/, |
|
1011 const TDesC8& /*aFilter*/, |
|
1012 TInt /*aIndex*/, |
|
1013 TInt /*aRequest*/, |
|
1014 const TDesC8& /*aSortCriteria*/, |
|
1015 const TDesC8& /*aResult*/, |
|
1016 TInt /*aReturned*/, |
|
1017 TInt /*aMatches*/, |
|
1018 const TDesC8& /*aUpdateID*/) |
|
1019 { |
|
1020 // No implementation required |
|
1021 } |
|
1022 |
|
1023 // -------------------------------------------------------------------------- |
|
1024 // CUPnPPlaybackSession::CdsDestroyObjectResponse |
|
1025 // See upnpplaybacksession.h |
|
1026 // -------------------------------------------------------------------------- |
|
1027 void CUPnPPlaybackSession::CdsDestroyObjectResponse( |
|
1028 const TDesC8& /*aUuid*/, |
|
1029 TInt /*aSessionId*/, |
|
1030 TInt /*aErr*/, |
|
1031 const TDesC8& /*aObjectId*/ ) |
|
1032 { |
|
1033 // No implementation required |
|
1034 } |
|
1035 |
|
1036 // -------------------------------------------------------------------------- |
|
1037 // CUPnPPlaybackSession::CdsUpdateObjectResponse |
|
1038 // See upnpplaybacksession.h |
|
1039 // -------------------------------------------------------------------------- |
|
1040 void CUPnPPlaybackSession::CdsUpdateObjectResponse( |
|
1041 const TDesC8& /*aUuid*/, |
|
1042 TInt /*aSessionId*/, |
|
1043 TInt /*aErr*/, |
|
1044 const TDesC8& /*aObjectId*/, |
|
1045 const TDesC8& /*aCurrentTagValue*/, |
|
1046 const TDesC8& /*aNewTagValue*/ ) |
|
1047 { |
|
1048 // No implementation required |
|
1049 } |
|
1050 |
|
1051 // -------------------------------------------------------------------------- |
|
1052 // CUPnPPlaybackSession::CdsImportResponse |
|
1053 // See upnpplaybacksession.h |
|
1054 // -------------------------------------------------------------------------- |
|
1055 void CUPnPPlaybackSession::CdsImportResponse( |
|
1056 const TDesC8& /*aUuid*/, |
|
1057 TInt /*aSessionId*/, |
|
1058 TInt /*aErr*/, |
|
1059 const TDesC8& /*aSourceURI*/, |
|
1060 const TDesC8& /*aDestinationURI*/, |
|
1061 const TDesC8& /*aTransferId*/ ) |
|
1062 { |
|
1063 // No implementation required |
|
1064 } |
|
1065 |
|
1066 // -------------------------------------------------------------------------- |
|
1067 // CUPnPPlaybackSession::CdsExportResponse |
|
1068 // See upnpplaybacksession.h |
|
1069 // -------------------------------------------------------------------------- |
|
1070 void CUPnPPlaybackSession::CdsExportResponse( |
|
1071 const TDesC8& /*aUuid*/, |
|
1072 TInt /*aSessionId*/, |
|
1073 TInt /*aErr*/, |
|
1074 const TDesC8& /*aSourceURI*/, |
|
1075 const TDesC8& /*aDestinationURI*/, |
|
1076 const TDesC8& /*aTransferId*/ ) |
|
1077 { |
|
1078 // No implementation required |
|
1079 } |
|
1080 |
|
1081 // -------------------------------------------------------------------------- |
|
1082 // CUPnPPlaybackSession::CdsStopTransferResponse |
|
1083 // See upnpplaybacksession.h |
|
1084 // -------------------------------------------------------------------------- |
|
1085 void CUPnPPlaybackSession::CdsStopTransferResponse( |
|
1086 const TDesC8& /*aUuid*/, |
|
1087 TInt /*aSessionId*/, |
|
1088 TInt /*aErr*/, |
|
1089 const TDesC8& /*aTransferId*/ ) |
|
1090 { |
|
1091 // No implementation required |
|
1092 } |
|
1093 |
|
1094 // -------------------------------------------------------------------------- |
|
1095 // CUPnPPlaybackSession::CdsCTransferProgressResponse |
|
1096 // See upnpplaybacksession.h |
|
1097 // -------------------------------------------------------------------------- |
|
1098 void CUPnPPlaybackSession::CdsCTransferProgressResponse( |
|
1099 const TDesC8& /*aUuid*/, |
|
1100 TInt /*aSessionId*/, |
|
1101 TInt /*aErr*/, |
|
1102 const TDesC8& /*aTransferId*/, |
|
1103 const TDesC8& /*aTransferStatus*/, |
|
1104 const TDesC8& /*aTransferLength*/, |
|
1105 const TDesC8& /*aTransferTotal*/ ) |
|
1106 { |
|
1107 // No implementation required |
|
1108 } |
|
1109 |
|
1110 // -------------------------------------------------------------------------- |
|
1111 // CUPnPPlaybackSession::CdsDeleteResourceResponse |
|
1112 // See upnpplaybacksession.h |
|
1113 // -------------------------------------------------------------------------- |
|
1114 void CUPnPPlaybackSession::CdsDeleteResourceResponse( |
|
1115 const TDesC8& /*aUuid*/, |
|
1116 TInt /*aSessionId*/, |
|
1117 TInt /*aErr*/, |
|
1118 const TDesC8& /*aResourceUri*/ ) |
|
1119 { |
|
1120 // No implementation required |
|
1121 } |
|
1122 |
|
1123 // -------------------------------------------------------------------------- |
|
1124 // CUPnPPlaybackSession::CdsCreateReferenceResponse |
|
1125 // See upnpplaybacksession.h |
|
1126 // -------------------------------------------------------------------------- |
|
1127 void CUPnPPlaybackSession::CdsCreateReferenceResponse( |
|
1128 const TDesC8& /*aUuid*/, |
|
1129 TInt /*aSessionId*/, |
|
1130 TInt /*aErr*/, |
|
1131 const TDesC8& /*aContainerId*/, |
|
1132 const TDesC8& /*ObjectId*/, |
|
1133 const TDesC8& /*aNewId*/ ) |
|
1134 { |
|
1135 // No implementation required |
|
1136 } |
|
1137 |
|
1138 // -------------------------------------------------------------------------- |
|
1139 // CUPnPPlaybackSession::CdsCreateObjectResponse |
|
1140 // See upnpplaybacksession.h |
|
1141 // -------------------------------------------------------------------------- |
|
1142 void CUPnPPlaybackSession::CdsCreateObjectResponse( |
|
1143 const TDesC8& /*aUuid*/, |
|
1144 TInt /*aSessionId*/, |
|
1145 TInt /*aErr*/, |
|
1146 const TDesC8& /*aContainerID*/, |
|
1147 const TDesC8& /*aElements*/, |
|
1148 const TDesC8& /*aObjectID*/, |
|
1149 const TDesC8& /*aResult*/ ) |
|
1150 { |
|
1151 // No implementation required |
|
1152 } |
|
1153 |
|
1154 // -------------------------------------------------------------------------- |
|
1155 // CUPnPPlaybackSession::CmProtocolInfoResponse |
|
1156 // See upnpplaybacksession.h |
|
1157 // -------------------------------------------------------------------------- |
|
1158 void CUPnPPlaybackSession::CmProtocolInfoResponse( |
|
1159 const TDesC8& /*aUuid*/, |
|
1160 TInt /*aSessionId*/, |
|
1161 TInt /*aErr*/, |
|
1162 const TDesC8& /*aSource*/, |
|
1163 const TDesC8& /*aSink*/ ) |
|
1164 { |
|
1165 // No implementation required |
|
1166 } |
|
1167 |
|
1168 // -------------------------------------------------------------------------- |
|
1169 // CUPnPPlaybackSession::CmPrepareResponse |
|
1170 // See upnpplaybacksession.h |
|
1171 // -------------------------------------------------------------------------- |
|
1172 void CUPnPPlaybackSession::CmPrepareResponse( |
|
1173 const TDesC8& /*aUuid*/, |
|
1174 TInt /*aSessionId*/, |
|
1175 TInt /*aErr*/, |
|
1176 const TDesC8& /*aRemoteProtocolInfo*/, |
|
1177 const TDesC8& /*aPeerConnectionManager*/, |
|
1178 const TDesC8& /*aPeerConnectionId*/, |
|
1179 const TDesC8& /*aDirection*/, |
|
1180 TInt /*aConnection*/, |
|
1181 TInt /*aTransport*/, |
|
1182 TInt /*aRsc*/ ) |
|
1183 { |
|
1184 // No implementation required |
|
1185 } |
|
1186 |
|
1187 // -------------------------------------------------------------------------- |
|
1188 // CUPnPPlaybackSession::CmComplete |
|
1189 // See upnpplaybacksession.h |
|
1190 // -------------------------------------------------------------------------- |
|
1191 void CUPnPPlaybackSession::CmComplete( |
|
1192 const TDesC8& /*aUuid*/, |
|
1193 TInt /*aSessionId*/, |
|
1194 TInt /*aErr*/, |
|
1195 TInt /*aConnection*/ ) |
|
1196 { |
|
1197 // No implementation required |
|
1198 } |
|
1199 |
|
1200 // -------------------------------------------------------------------------- |
|
1201 // CUPnPPlaybackSession::CmCurrentConnections |
|
1202 // See upnpplaybacksession.h |
|
1203 // -------------------------------------------------------------------------- |
|
1204 void CUPnPPlaybackSession::CmCurrentConnections( |
|
1205 const TDesC8& /*aUuid*/, |
|
1206 TInt /*aSessionId*/, |
|
1207 TInt /*aErr*/, |
|
1208 const TDesC8& /*aConnections*/) |
|
1209 { |
|
1210 // No implementation required |
|
1211 } |
|
1212 |
|
1213 // -------------------------------------------------------------------------- |
|
1214 // CUPnPPlaybackSession::CmCurrentInfo |
|
1215 // See upnpplaybacksession.h |
|
1216 // -------------------------------------------------------------------------- |
|
1217 void CUPnPPlaybackSession::CmCurrentInfo( |
|
1218 const TDesC8& /*aUuid*/, |
|
1219 TInt /*aSessionId*/, |
|
1220 TInt /*aErr*/, |
|
1221 TInt /*rscId*/, |
|
1222 TInt /*transportId*/, |
|
1223 const TDesC8& /*aProtocolInfo*/, |
|
1224 const TDesC8& /*aPeerConnectionManager*/, |
|
1225 TInt /*peerId*/, |
|
1226 const TDesC8& /*aDirection*/, |
|
1227 const TDesC8& /*aStatus*/ ) |
|
1228 { |
|
1229 // No implementation required |
|
1230 } |
|
1231 |
|
1232 // -------------------------------------------------------------------------- |
|
1233 // CUPnPPlaybackSession::CdsUpdateEvent |
|
1234 // See upnpplaybacksession.h |
|
1235 // -------------------------------------------------------------------------- |
|
1236 void CUPnPPlaybackSession::CdsUpdateEvent( |
|
1237 const TDesC8& /*aUuid*/, |
|
1238 TInt /*aSystemUpdateId*/ |
|
1239 ) |
|
1240 { |
|
1241 // No implementation required |
|
1242 } |
|
1243 |
|
1244 // -------------------------------------------------------------------------- |
|
1245 // CUPnPPlaybackSession::CdsContainerEvent |
|
1246 // See upnpplaybacksession.h |
|
1247 // -------------------------------------------------------------------------- |
|
1248 void CUPnPPlaybackSession::CdsContainerEvent( |
|
1249 const TDesC8& /*aUuid*/, |
|
1250 const TDesC8& /*aConteinerIds*/ |
|
1251 ) |
|
1252 { |
|
1253 // No implementation required |
|
1254 } |
|
1255 |
|
1256 // -------------------------------------------------------------------------- |
|
1257 // CUPnPPlaybackSession::CdsTransferEvent |
|
1258 // See upnpplaybacksession.h |
|
1259 // -------------------------------------------------------------------------- |
|
1260 void CUPnPPlaybackSession::CdsTransferEvent( |
|
1261 const TDesC8& /*aUuid*/, |
|
1262 const TDesC8& /*aTransferIds*/ |
|
1263 ) |
|
1264 { |
|
1265 // No implementation required |
|
1266 } |
|
1267 |
1031 |
1268 // -------------------------------------------------------------------------- |
1032 // -------------------------------------------------------------------------- |
1269 // CUPnPPlaybackSession::RcLastChangeEvent |
1033 // CUPnPPlaybackSession::RcLastChangeEvent |
1270 // See upnpplaybacksession.h |
1034 // See upnpplaybacksession.h |
1271 // -------------------------------------------------------------------------- |
1035 // -------------------------------------------------------------------------- |
1272 void CUPnPPlaybackSession::RcLastChangeEvent( |
1036 void CUPnPPlaybackSession::RcLastChangeEvent( |
1273 const TDesC8& /*aUuid*/, |
1037 const TDesC8& aLastChange ) |
1274 const TDesC8& aLastChange |
1038 { |
1275 ) |
1039 if( iPlaybackState != EHalted ) |
1276 { |
|
1277 // No implementation required |
|
1278 if( iPlaybackState != EUninitialized ) |
|
1279 { |
1040 { |
1280 __LOG( "CUPnPPlaybackSession::RcLastChangeEvent" ); |
1041 __LOG( "CUPnPPlaybackSession::RcLastChangeEvent" ); |
1281 //__LOG8( aLastChange ); |
1042 CUPnPAVTEvent* event = NULL; |
1282 |
1043 TRAPD( err, event = iEventParser->ParseRcEventDataL( aLastChange, |
1283 TInt instanceId = -1; |
1044 iRCInstanceId ) ); |
1284 TInt volume = -1; |
1045 |
1285 TBool mute = EFalse; |
1046 if( err == KErrNone ) |
1286 if( iMuteState == EMuted ) |
1047 { |
1287 { |
1048 TUnsolicitedEventC unsolicitEvent; |
1288 mute = ETrue; |
1049 TInt volume = event->Volume(); |
1289 } |
1050 TInt mute = event->Mute(); |
1290 |
1051 // check if it Mute state change |
1291 TRAPD( err, iEventParser->ParseResultDataL( aLastChange, instanceId, |
1052 if( EUnknown != (TMuteState)mute && |
1292 volume, mute ) ); |
1053 iMuteState != (TMuteState)mute) |
1293 if( err == KErrNone && instanceId == iInstanceId ) |
|
1294 { |
|
1295 TUnsolicitedEventC unEvent; |
|
1296 if( iMuteState != (TMuteState)mute ) |
|
1297 { |
1054 { |
1298 // State of mute changed, create an event and send it to |
1055 unsolicitEvent.iEvent = EMute; |
1299 // the client side |
1056 unsolicitEvent.iValue = (TInt)mute; |
1300 unEvent.iEvent = EMute; |
1057 iMuteState = (TMuteState)mute; |
1301 unEvent.iValue = (TInt)mute; |
1058 PropagateEvent( unsolicitEvent ); |
1302 |
1059 } |
1303 // If mute's value isn't ENotMuted or EMuted, |
1060 // check if it has valid volume information. |
1304 // we think the value is incorrect. |
1061 if (volume >= 0 ) |
1305 if ( mute != ENotMuted && mute != EMuted ) |
1062 { |
1306 { |
1063 // Scale the volume level |
1307 err = KErrArgument; |
1064 // Get device's maximum volume value |
|
1065 TInt maxVolume = iDevice->MaxVolume(); |
|
1066 // If max volume not KMaxVolume |
|
1067 if( maxVolume != KMaxVolume ) |
|
1068 { |
|
1069 // Convert volume to match max volume 100 |
|
1070 TReal tempVolumeLevel = volume; |
|
1071 TReal tempMaxVolume = maxVolume; |
|
1072 |
|
1073 volume = KMaxVolume * |
|
1074 tempVolumeLevel/tempMaxVolume; |
|
1075 } |
|
1076 if( iVolume != volume) |
|
1077 { |
|
1078 // State of volume changed, create an event and send it |
|
1079 // to the client side |
|
1080 unsolicitEvent.iEvent = EVolume; |
|
1081 unsolicitEvent.iValue = volume; |
|
1082 iVolume = volume; |
|
1083 PropagateEvent( unsolicitEvent ); |
1308 } |
1084 } |
1309 else |
1085 } |
|
1086 } |
|
1087 delete event; |
|
1088 } |
|
1089 } |
|
1090 |
|
1091 // -------------------------------------------------------------------------- |
|
1092 // CUPnPPlaybackSession::AvtLastChangeEvent |
|
1093 // See upnpplaybacksession.h |
|
1094 // -------------------------------------------------------------------------- |
|
1095 void CUPnPPlaybackSession::AvtLastChangeEvent( |
|
1096 const TDesC8& aLastChange ) |
|
1097 { |
|
1098 __LOG2( "CUPnPPlaybackSession::AvtLastChangeEvent, pb state %d, exp evt %d", |
|
1099 iPlaybackState, iExpectedEvent ); |
|
1100 |
|
1101 CUPnPAVTEvent* avtevent = NULL; |
|
1102 TRAPD( err, avtevent = iEventParser->ParseAvtEventDataL( aLastChange, |
|
1103 iAVTInstanceId ) ); |
|
1104 if( err == KErrNone && iPlaybackState != EHalted ) |
|
1105 { |
|
1106 CUPnPAVTEvent::TTransportState transportState = avtevent->TransportState(); |
|
1107 PropagateState( transportState ); |
|
1108 |
|
1109 if( avtevent->TransportURI().Length() > 0 ) |
|
1110 { |
|
1111 AVTransportUriEventReceived( avtevent->TransportURI(), |
|
1112 avtevent->TransportState() ); |
|
1113 } |
|
1114 else |
|
1115 { |
|
1116 iInitialEventReceived = EFalse; |
|
1117 switch( transportState ) |
|
1118 { |
|
1119 case CUPnPAVTEvent::EPlaying: |
1310 { |
1120 { |
1311 iMuteState = (TMuteState)mute; |
1121 PlayingEventReceived(); |
|
1122 break; |
|
1123 } |
|
1124 case CUPnPAVTEvent::EStopped: |
|
1125 { |
|
1126 StoppedEventReceived(); |
|
1127 break; |
|
1128 } |
|
1129 case CUPnPAVTEvent::EPausedPlayback: |
|
1130 { |
|
1131 PausedEventReceived(); |
|
1132 break; |
1312 } |
1133 } |
1313 if( iEventMessage ) |
1134 case CUPnPAVTEvent::ENoMediaPresent: |
1314 { |
1135 { |
1315 TPckg<TUnsolicitedEventC> resp1( unEvent ); |
1136 NoMediaEventReceived(); |
1316 TInt error = iEventMessage->Write( 1, resp1 ); |
1137 break; |
1317 if ( error == KErrNone ) |
|
1318 { |
|
1319 error = err; |
|
1320 } |
|
1321 iEventMessage->Complete( error ); |
|
1322 delete iEventMessage; iEventMessage = NULL; |
|
1323 } |
1138 } |
1324 else if ( err == KErrNone ) |
1139 default: |
1325 { |
1140 { |
1326 // If iEventMessage is invalid and mute's value is |
1141 __LOG( "CUPnPPlaybackSession::AvtLastChangeEvent - \ |
1327 // right, we will append event to iEventQue. |
1142 TRANSITIONING, IDLE, RECORDING or PAUSED_RECORDING" ); |
1328 // Else nothing to do. |
1143 break; |
1329 iEventQue.AppendL( unEvent ); |
1144 } |
1330 } |
|
1331 } |
1145 } |
1332 |
1146 } |
1333 // Scale the volume level |
1147 iPreviousTransportState = transportState; |
1334 // Get device's maximum volume value |
1148 } |
1335 TInt maxVolume = iDevice->MaxVolume(); |
1149 else |
1336 // If max volume not KMaxVolume |
1150 { |
1337 if( maxVolume != KMaxVolume ) |
1151 __LOG( "CUPnPPlaybackSession::AvtLastChangeEvent - We are halted, or \ |
1338 { |
1152 parsing failed. No can do." ); |
1339 // Convert volume to match max volume 100 |
1153 } |
1340 TReal tempVolumeLevel = volume; |
1154 delete avtevent; |
1341 TReal tempMaxVolume = maxVolume; |
1155 __LOG( "CUPnPPlaybackSession::AvtLastChangeEvent" ); |
1342 |
1156 } |
1343 volume = KMaxVolume * tempVolumeLevel / tempMaxVolume; |
1157 |
1344 } |
|
1345 |
|
1346 if( iVolume != volume && volume >= 0 ) |
|
1347 { |
|
1348 // State of volume changed, create an event and send it to |
|
1349 // the client side |
|
1350 unEvent.iEvent = EVolume; |
|
1351 unEvent.iValue = volume; |
|
1352 iVolume = volume; |
|
1353 if( iEventMessage ) |
|
1354 { |
|
1355 TPckg<TUnsolicitedEventC> resp1( unEvent ); |
|
1356 TInt err = iEventMessage->Write( 1, resp1 ); |
|
1357 iEventMessage->Complete( err ); |
|
1358 delete iEventMessage; iEventMessage = NULL; |
|
1359 } |
|
1360 else |
|
1361 { |
|
1362 iEventQue.AppendL( unEvent ); |
|
1363 } |
|
1364 } |
|
1365 |
|
1366 } |
|
1367 } |
|
1368 } |
|
1369 |
|
1370 // -------------------------------------------------------------------------- |
|
1371 // CUPnPPlaybackSession::AvtLastChangeEvent |
|
1372 // See upnpplaybacksession.h |
|
1373 // -------------------------------------------------------------------------- |
|
1374 void CUPnPPlaybackSession::AvtLastChangeEvent( |
|
1375 const TDesC8& /*aUuid*/, |
|
1376 const TDesC8& aLastChange |
|
1377 ) |
|
1378 { |
|
1379 // Is it for this device? |
|
1380 if( iPlaybackState != EUninitialized ) |
|
1381 { |
|
1382 __LOG( "CUPnPPlaybackSession::AvtLastChangeEvent" ); |
|
1383 |
|
1384 TUnsolicitedEventC event; |
|
1385 if( aLastChange.Find( KPlaying ) >= 0 ) |
|
1386 { |
|
1387 __LOG( "AvtLastChangeEvent - PlayUser received" ); |
|
1388 event.iEvent = EPlay; |
|
1389 iPlaybackState = EPlaying; |
|
1390 if( iEventMessage ) |
|
1391 { |
|
1392 TPckg<TUnsolicitedEventC> resp1( event ); |
|
1393 TInt err = iEventMessage->Write( 1, resp1 ); |
|
1394 iEventMessage->Complete( err ); // Ok to complete with err? |
|
1395 delete iEventMessage; iEventMessage = NULL; |
|
1396 } |
|
1397 else |
|
1398 { |
|
1399 __LOG( "AvtLastChangeEvent - appending playuser" ); |
|
1400 iEventQue.AppendL( event ); |
|
1401 } |
|
1402 } |
|
1403 else if( aLastChange.Find( KStopped ) >= 0 && |
|
1404 iPlaybackState != EStopped ) |
|
1405 { |
|
1406 __LOG( "AvtLastChangeEvent - StopUser received" ); |
|
1407 event.iEvent = EStop; |
|
1408 iPlaybackState = EStopped; |
|
1409 if( iEventMessage ) |
|
1410 { |
|
1411 TPckg<TUnsolicitedEventC> resp1( event ); |
|
1412 TInt err = iEventMessage->Write( 1, resp1 ); |
|
1413 iEventMessage->Complete( err ); // Ok to complete with err? |
|
1414 delete iEventMessage; iEventMessage = NULL; |
|
1415 } |
|
1416 else |
|
1417 { |
|
1418 __LOG( "AvtLastChangeEvent - appending stopuser" ); |
|
1419 iEventQue.AppendL( event ); |
|
1420 } |
|
1421 } |
|
1422 else if( aLastChange.Find( KPaused ) >= 0 && |
|
1423 iPlaybackState != EPaused ) |
|
1424 { |
|
1425 __LOG( "AvtLastChangeEvent - PauseUser received" ); |
|
1426 event.iEvent = EPause; |
|
1427 iPlaybackState = EPaused; |
|
1428 if( iEventMessage ) |
|
1429 { |
|
1430 __LOG( "CUPnPPlaybackSession::AvtLastChangeEvent" ); |
|
1431 TPckg<TUnsolicitedEventC> resp1( event ); |
|
1432 TInt err = iEventMessage->Write( 1, resp1 ); |
|
1433 iEventMessage->Complete( err ); // Ok to complete with err? |
|
1434 delete iEventMessage; iEventMessage = NULL; |
|
1435 } |
|
1436 else |
|
1437 { |
|
1438 __LOG( "AvtLastChangeEvent - appending pauseuser" ); |
|
1439 iEventQue.AppendL( event ); |
|
1440 } |
|
1441 } |
|
1442 } |
|
1443 } |
|
1444 |
|
1445 // -------------------------------------------------------------------------- |
|
1446 // CUPnPPlaybackSession::CmSourceEvent |
|
1447 // See upnpplaybacksession.h |
|
1448 // -------------------------------------------------------------------------- |
|
1449 void CUPnPPlaybackSession::CmSourceEvent( |
|
1450 const TDesC8& /*aUuid*/, |
|
1451 const TDesC8& /*aSource*/ |
|
1452 ) |
|
1453 { |
|
1454 // No implementation required |
|
1455 } |
|
1456 |
|
1457 // -------------------------------------------------------------------------- |
|
1458 // CUPnPPlaybackSession::CmSinkEvent |
|
1459 // See upnpplaybacksession.h |
|
1460 // -------------------------------------------------------------------------- |
|
1461 void CUPnPPlaybackSession::CmSinkEvent( |
|
1462 const TDesC8& /*aUuid*/, |
|
1463 const TDesC8& /*aSink*/ |
|
1464 ) |
|
1465 { |
|
1466 // No implementation required |
|
1467 } |
|
1468 |
|
1469 // -------------------------------------------------------------------------- |
|
1470 // CUPnPPlaybackSession::CmConnectionsEvent |
|
1471 // See upnpplaybacksession.h |
|
1472 // -------------------------------------------------------------------------- |
|
1473 void CUPnPPlaybackSession::CmConnectionsEvent( |
|
1474 const TDesC8& /*aUuid*/, |
|
1475 const TDesC8& /*aConnections*/ |
|
1476 ) |
|
1477 { |
|
1478 // No implementation required |
|
1479 } |
|
1480 |
|
1481 // -------------------------------------------------------------------------- |
|
1482 // CUPnPPlaybackSession::HttpResponseL |
|
1483 // See upnpplaybacksession.h |
|
1484 // -------------------------------------------------------------------------- |
|
1485 void CUPnPPlaybackSession::HttpResponseL( CUpnpHttpMessage* /*aMessage*/ ) |
|
1486 { |
|
1487 // No implementation required |
|
1488 } |
|
1489 |
|
1490 // -------------------------------------------------------------------------- |
|
1491 // CUPnPPlaybackSession::DeviceDiscoveredL |
|
1492 // See upnpplaybacksession.h |
|
1493 // -------------------------------------------------------------------------- |
|
1494 void CUPnPPlaybackSession::DeviceDiscoveredL( CUpnpDevice* /*aDevice*/ ) |
|
1495 { |
|
1496 // No implementation required |
|
1497 } |
|
1498 |
|
1499 // -------------------------------------------------------------------------- |
|
1500 // CUPnPPlaybackSession::DeviceDisappearedL |
|
1501 // See upnpplaybacksession.h |
|
1502 // -------------------------------------------------------------------------- |
|
1503 void CUPnPPlaybackSession::DeviceDisappearedL( CUpnpDevice* /*aDevice*/ ) |
|
1504 { |
|
1505 // No implementation required |
|
1506 } |
|
1507 |
1158 |
1508 // -------------------------------------------------------------------------- |
1159 // -------------------------------------------------------------------------- |
1509 // CUPnPPlaybackSession::DeviceDisappearedL |
1160 // CUPnPPlaybackSession::DeviceDisappearedL |
1510 // See upnpplaybacksession.h |
1161 // See upnpplaybacksession.h |
1511 // -------------------------------------------------------------------------- |
1162 // -------------------------------------------------------------------------- |
1611 // -------------------------------------------------------------------------- |
1271 // -------------------------------------------------------------------------- |
1612 void CUPnPPlaybackSession::SetURIL( const RMessage2& aMessage ) |
1272 void CUPnPPlaybackSession::SetURIL( const RMessage2& aMessage ) |
1613 { |
1273 { |
1614 __LOG( "CUPnPPlaybackSession::SetURIL" ); |
1274 __LOG( "CUPnPPlaybackSession::SetURIL" ); |
1615 |
1275 |
1616 __ASSERTD( !iCommandMessage, __FILE__, __LINE__ ); |
1276 __ASSERT( !iCommandMessage, __FILE__, __LINE__ ); |
1617 |
1277 |
1618 ResetL(); |
1278 ResetL(); |
1619 |
1279 |
1620 if( iPlaybackState == EPlaying || iPlaybackState == EPaused || |
1280 // Read and store the item and URI from the request |
1621 iPlaybackState == EPlaySent ) |
|
1622 { |
|
1623 iServer.ControlPoint().AvtStopActionL( iDevice->Uuid(), |
|
1624 iInstanceId ); |
|
1625 } |
|
1626 |
|
1627 if( iItemShared ) |
|
1628 { |
|
1629 iFileSharing->UnShareItemL( iSharedItem->Id() ); |
|
1630 iItemShared = EFalse; |
|
1631 } |
|
1632 |
|
1633 // Uri is set by providing an item. Convert the item to xml document and |
|
1634 // send the action |
|
1635 |
|
1636 __LOG( "SetURIL" ); |
|
1637 |
|
1638 CUpnpAVRequest* tmpRequest = CUpnpAVRequest::NewLC(); |
1281 CUpnpAVRequest* tmpRequest = CUpnpAVRequest::NewLC(); |
1639 |
|
1640 ReadReqFromMessageL( aMessage, 1 ,tmpRequest ); |
1282 ReadReqFromMessageL( aMessage, 1 ,tmpRequest ); |
1641 |
1283 |
1642 CUpnpItem* tmpItem = CUpnpItem::NewL(); |
1284 CUpnpItem* tmpItem = CUpnpItem::NewL(); |
1643 CleanupStack::PushL( tmpItem ); |
1285 CleanupStack::PushL( tmpItem ); |
1644 |
1286 |
1645 ReadObjFromMessageL( aMessage, 2 ,tmpItem ); |
1287 ReadObjFromMessageL( aMessage, 2 ,tmpItem ); |
1646 |
1288 |
1647 TPtrC8 uri = tmpRequest->URI(); |
1289 HBufC8* tmpUri = tmpRequest->URI().AllocL(); |
1648 |
1290 |
|
1291 CleanupStack::Pop( tmpItem ); |
|
1292 CleanupStack::PopAndDestroy( tmpRequest ); |
|
1293 |
|
1294 delete iCurrentItem; |
|
1295 iCurrentItem = tmpItem; |
|
1296 |
|
1297 delete iCurrentUri; |
|
1298 iCurrentUri = tmpUri; |
|
1299 |
|
1300 // Get protocolInfo from the item |
1649 const CUpnpElement& res = |
1301 const CUpnpElement& res = |
1650 UPnPItemUtility::ResourceFromItemL( *tmpItem ); |
1302 UPnPItemUtility::ResourceFromItemL( *iCurrentItem ); |
1651 const CUpnpAttribute* protocolInfo = |
1303 const CUpnpAttribute* protocolInfo = |
1652 UPnPItemUtility::FindAttributeByName( |
1304 UPnPItemUtility::FindAttributeByName( |
1653 res, KAttributeProtocolInfo ); |
1305 res, KAttributeProtocolInfo ); |
1654 |
1306 |
|
1307 // Store the message. We are going to perfom asynchronous operation |
|
1308 // so it's needed (completed) afterwards |
|
1309 iCommandMessage = new (ELeave) RMessage2( aMessage ); |
|
1310 |
|
1311 // Check if we have a valid connection (or if it's even needed. |
|
1312 // Anyway,that does not matter since if no connection, we can used |
|
1313 // default instance id) |
|
1314 if( CheckConnectionL( protocolInfo->Value() ) ) |
|
1315 { |
|
1316 // Connection ok, continue with sending AvtSetTransportUri-action |
|
1317 __LOG( "CUPnPPlaybackSession::SetURIL - \ |
|
1318 connection ok, or using default" ); |
|
1319 |
|
1320 SendGetTransportInfoActionL(); |
|
1321 } |
|
1322 else |
|
1323 { |
|
1324 // Connection needs to be established |
|
1325 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
|
1326 CpDeviceL(), KConnectionManager, KPrepareForConnection ); |
|
1327 |
|
1328 action->SetArgumentL( KRemoteProtocolInfo, protocolInfo->Value() ); |
|
1329 action->SetArgumentL( KPeerConnectionManager, KConnectioMgr ); |
|
1330 action->SetArgumentL( KPeerConnectionID, KDefaultPeerConnectionID ); |
|
1331 action->SetArgumentL( KDirection, KInput ); |
|
1332 |
|
1333 iServer.ControlPoint().SendL( action ); |
|
1334 CleanupStack::Pop( action ); |
|
1335 if (action->SessionId() < 0) User::Leave( action->SessionId() ); |
|
1336 iIPSessionIdCommand = action->SessionId(); |
|
1337 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
1338 } |
|
1339 |
|
1340 // Store protocolinfo, so it can be checked in PrepareConnectionL when |
|
1341 // a next item is played |
|
1342 CUpnpDlnaProtocolInfo* tmpInfo = |
|
1343 CUpnpDlnaProtocolInfo::NewL( protocolInfo->Value() ); |
|
1344 |
|
1345 delete iPInfoForPrevious; |
|
1346 iPInfoForPrevious = tmpInfo; |
|
1347 |
|
1348 __LOG( "CUPnPPlaybackSession::SetURIL - end" ); |
|
1349 } |
|
1350 |
|
1351 // -------------------------------------------------------------------------- |
|
1352 // CUPnPPlaybackSession::CancelSetURIL |
|
1353 // See upnpplaybacksession.h |
|
1354 // -------------------------------------------------------------------------- |
|
1355 void CUPnPPlaybackSession::CancelSetURIL() |
|
1356 { |
|
1357 __LOG( "CUPnPPlaybackSession::CancelSetURIL" ); |
|
1358 |
|
1359 if( iCommandMessage ) |
|
1360 { |
|
1361 //iSetUri = EFalse; |
|
1362 iExpectedEvent = EEventNone; |
|
1363 iPlaybackState = EStopped; |
|
1364 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
1365 iIPSessionIdCommand = KErrNotFound; |
|
1366 iCommandMessage->Complete( KErrCancel ); |
|
1367 delete iCommandMessage; iCommandMessage = NULL; |
|
1368 } |
|
1369 } |
|
1370 |
|
1371 // -------------------------------------------------------------------------- |
|
1372 // CUPnPPlaybackSession::SetNextURIL |
|
1373 // See upnpplaybacksession.h |
|
1374 // -------------------------------------------------------------------------- |
|
1375 void CUPnPPlaybackSession::SetNextURIL( const RMessage2& /*aMessage*/ ) |
|
1376 { |
|
1377 __LOG( "CUPnPPlaybackSession::SetNextURIL" ); |
|
1378 |
|
1379 User::Leave( KErrNotSupported ); |
|
1380 |
|
1381 __LOG( "CUPnPPlaybackSession::SetNextURIL - end" ); |
|
1382 } |
|
1383 |
|
1384 // -------------------------------------------------------------------------- |
|
1385 // CUPnPPlaybackSession::CancelSetNextURIL |
|
1386 // See upnpplaybacksession.h |
|
1387 // -------------------------------------------------------------------------- |
|
1388 void CUPnPPlaybackSession::CancelSetNextURIL() |
|
1389 { |
|
1390 __LOG( "CUPnPPlaybackSession::CancelSetNextURIL" ); |
|
1391 |
|
1392 User::Leave( KErrNotSupported ); |
|
1393 } |
|
1394 |
|
1395 // -------------------------------------------------------------------------- |
|
1396 // CUPnPPlaybackSession::PlayL |
|
1397 // See upnpplaybacksession.h |
|
1398 // -------------------------------------------------------------------------- |
|
1399 void CUPnPPlaybackSession::PlayL( const RMessage2& aMessage ) |
|
1400 { |
|
1401 __LOG( "CUPnPPlaybackSession::PlayL" ); |
|
1402 |
|
1403 __ASSERT( !iCommandMessage, __FILE__, __LINE__ ); |
|
1404 |
|
1405 ResetL(); |
|
1406 |
|
1407 if( !(iPlaybackState == EPaused || iPlaybackState == EStopped) ) |
|
1408 { |
|
1409 User::Leave( KErrNotReady ); |
|
1410 } |
|
1411 |
|
1412 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
|
1413 CpDeviceL(), KAVTransport, KPlay ); |
|
1414 |
|
1415 TBuf8<KMaxIntLength> buf; |
|
1416 buf.Num( iAVTInstanceId ); |
|
1417 action->SetArgumentL( KInstanceID, buf ); |
|
1418 action->SetArgumentL( KSpeed, KNormalSpeed ); |
|
1419 |
|
1420 iServer.ControlPoint().SendL( action ); |
|
1421 CleanupStack::Pop( action ); |
|
1422 iIPSessionIdCommand = action->SessionId(); |
|
1423 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
1424 iCommandMessage = new (ELeave) RMessage2( aMessage ); |
|
1425 |
|
1426 iExpectedEvent = EEventPlaying; |
|
1427 |
|
1428 __LOG( "CUPnPPlaybackSession::PlayL - end" ); |
|
1429 } |
|
1430 |
|
1431 // -------------------------------------------------------------------------- |
|
1432 // CUPnPPlaybackSession::CancelPlayL |
|
1433 // See upnpplaybacksession.h |
|
1434 // -------------------------------------------------------------------------- |
|
1435 void CUPnPPlaybackSession::CancelPlayL() |
|
1436 { |
|
1437 __LOG( "CUPnPPlaybackSession::CancelPlayL" ); |
|
1438 |
|
1439 //__ASSERT( iCommandPending, User::Panic( KPanicText, __LINE__ ) ); |
|
1440 if( iCommandMessage ) |
|
1441 { |
|
1442 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
1443 iIPSessionIdCommand = KErrNotFound; |
|
1444 iCommandMessage->Complete( KErrCancel ); |
|
1445 delete iCommandMessage; iCommandMessage = NULL; |
|
1446 |
|
1447 iExpectedEvent = EEventNone; |
|
1448 } |
|
1449 } |
|
1450 |
|
1451 // -------------------------------------------------------------------------- |
|
1452 // CUPnPPlaybackSession::StopL |
|
1453 // See upnpplaybacksession.h |
|
1454 // -------------------------------------------------------------------------- |
|
1455 void CUPnPPlaybackSession::StopL( const RMessage2& aMessage ) |
|
1456 { |
|
1457 __LOG( "CUPnPPlaybackSession::StopL" ); |
|
1458 |
|
1459 __ASSERT( !iCommandMessage, __FILE__, __LINE__ ); |
|
1460 |
|
1461 ResetL(); |
|
1462 // state stopped must be check before stopped action. According to |
|
1463 // AVTransPort specification stop may be requested in any other state |
|
1464 // except NO_MEDIA_PRESENT |
|
1465 if( iPlaybackState == ENoMedia ) |
|
1466 { |
|
1467 User::Leave( KErrNotReady ); |
|
1468 } |
|
1469 else |
|
1470 { |
|
1471 __LOG1( "CUPnPPlaybackSession::StopL - sending stop in state %d", |
|
1472 iPlaybackState); |
|
1473 } |
|
1474 |
|
1475 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
|
1476 CpDeviceL(), KAVTransport, KStop ); |
|
1477 |
|
1478 TBuf8<KMaxIntLength> buf; |
|
1479 buf.Num( iAVTInstanceId ); |
|
1480 action->SetArgumentL( KInstanceID, buf ); |
|
1481 |
|
1482 iServer.ControlPoint().SendL( action ); //action ownership is transfered |
|
1483 CleanupStack::Pop( action ); |
|
1484 if (action->SessionId() < 0) User::Leave( action->SessionId() ); |
|
1485 iIPSessionIdCommand = action->SessionId(); |
|
1486 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
1487 iCommandMessage = new (ELeave) RMessage2( aMessage ); |
|
1488 |
|
1489 iExpectedEvent = EEventStopped; |
|
1490 __LOG( "CUPnPPlaybackSession::StopL - end" ); |
|
1491 } |
|
1492 |
|
1493 // -------------------------------------------------------------------------- |
|
1494 // CUPnPPlaybackSession::EmergencyStopL |
|
1495 // See upnpplaybacksession.h |
|
1496 // -------------------------------------------------------------------------- |
|
1497 void CUPnPPlaybackSession::EmergencyStopL() |
|
1498 { |
|
1499 __LOG( "CUPnPPlaybackSession::EmergencyStopL" ); |
|
1500 |
|
1501 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
|
1502 CpDeviceL(), KAVTransport, KStop ); |
|
1503 |
|
1504 TBuf8<KMaxIntLength> buf; |
|
1505 buf.Num( iAVTInstanceId ); |
|
1506 action->SetArgumentL( KInstanceID, buf ); |
|
1507 iServer.ControlPoint().SendL( action ); |
|
1508 CleanupStack::Pop( action ); |
|
1509 __LOG( "CUPnPPlaybackSession::StopL - end" ); |
|
1510 } |
|
1511 |
|
1512 // -------------------------------------------------------------------------- |
|
1513 // CUPnPPlaybackSession::PropagateState |
|
1514 // See upnpplaybacksession.h |
|
1515 // -------------------------------------------------------------------------- |
|
1516 void CUPnPPlaybackSession::PropagateState( |
|
1517 CUPnPAVTEvent::TTransportState aTransportState ) |
|
1518 { |
|
1519 __LOG2( "CUPnPPlaybackSession::PropagateState - curState %d, prevState %d", |
|
1520 aTransportState, iPreviousTransportState ); |
|
1521 |
|
1522 if( aTransportState == CUPnPAVTEvent::ETransitioning ) |
|
1523 { |
|
1524 __LOG( "CUPnPPlaybackSession::PropagateState - \ |
|
1525 TRANSITIONING" ); |
|
1526 TUnsolicitedEventC event; |
|
1527 event.iEvent = ETransition; |
|
1528 event.iValue = ETransitionEnter; |
|
1529 PropagateEvent( event ); |
|
1530 } |
|
1531 else if( aTransportState != CUPnPAVTEvent::ETransitioning && |
|
1532 iPreviousTransportState == CUPnPAVTEvent::ETransitioning ) |
|
1533 { |
|
1534 __LOG( "CUPnPPlaybackSession::PropagateState - \ |
|
1535 TRANSITIONING ended" ); |
|
1536 TUnsolicitedEventC event; |
|
1537 event.iEvent = ETransition; |
|
1538 event.iValue = ETransitionExit; |
|
1539 PropagateEvent( event ); |
|
1540 } |
|
1541 } |
|
1542 |
|
1543 // -------------------------------------------------------------------------- |
|
1544 // CUPnPPlaybackSession::CancelStopL |
|
1545 // See upnpplaybacksession.h |
|
1546 // -------------------------------------------------------------------------- |
|
1547 void CUPnPPlaybackSession::CancelStopL() |
|
1548 { |
|
1549 __LOG( "CUPnPPlaybackSession::CancelStopL" ); |
|
1550 |
|
1551 if( iCommandMessage ) |
|
1552 { |
|
1553 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
1554 iIPSessionIdCommand = KErrNotFound; |
|
1555 iCommandMessage->Complete( KErrCancel ); |
|
1556 delete iCommandMessage; iCommandMessage = NULL; |
|
1557 |
|
1558 iExpectedEvent = EEventNone; |
|
1559 } |
|
1560 } |
|
1561 |
|
1562 // -------------------------------------------------------------------------- |
|
1563 // CUPnPPlaybackSession::PauseL |
|
1564 // See upnpplaybacksession.h |
|
1565 // -------------------------------------------------------------------------- |
|
1566 void CUPnPPlaybackSession::PauseL( const RMessage2& aMessage ) |
|
1567 { |
|
1568 __LOG( "CUPnPPlaybackSession::PauseL" ); |
|
1569 |
|
1570 __ASSERT( !iCommandMessage, __FILE__, __LINE__ ); |
|
1571 |
|
1572 ResetL(); |
|
1573 |
|
1574 if( !(iPlaybackState == EPlaying) ) |
|
1575 { |
|
1576 User::Leave( KErrNotReady ); |
|
1577 } |
|
1578 |
|
1579 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
|
1580 CpDeviceL(), KAVTransport, KPause ); |
|
1581 |
|
1582 TBuf8<KMaxIntLength> buf; |
|
1583 buf.Num( iAVTInstanceId ); |
|
1584 action->SetArgumentL( KInstanceID, buf ); |
|
1585 |
|
1586 iServer.ControlPoint().SendL( action ); |
|
1587 CleanupStack::Pop( action ); |
|
1588 if (action->SessionId() < 0) User::Leave( action->SessionId() ); |
|
1589 iIPSessionIdCommand = action->SessionId(); |
|
1590 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
1591 iCommandMessage = new (ELeave) RMessage2( aMessage ); |
|
1592 |
|
1593 iExpectedEvent = EEventPaused; |
|
1594 |
|
1595 __LOG( "CUPnPPlaybackSession::PauseL - end" ); |
|
1596 } |
|
1597 |
|
1598 // -------------------------------------------------------------------------- |
|
1599 // CUPnPPlaybackSession::CancelPauseL |
|
1600 // See upnpplaybacksession.h |
|
1601 // -------------------------------------------------------------------------- |
|
1602 void CUPnPPlaybackSession::CancelPauseL() |
|
1603 { |
|
1604 __LOG( "CUPnPPlaybackSession::CancelPauseL" ); |
|
1605 |
|
1606 if( iCommandMessage ) |
|
1607 { |
|
1608 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
1609 iIPSessionIdCommand = KErrNotFound; |
|
1610 iCommandMessage->Complete( KErrCancel ); |
|
1611 delete iCommandMessage; iCommandMessage = NULL; |
|
1612 |
|
1613 iExpectedEvent = EEventNone; |
|
1614 } |
|
1615 } |
|
1616 |
|
1617 // -------------------------------------------------------------------------- |
|
1618 // CUPnPPlaybackSession::SetVolumeL |
|
1619 // See upnpplaybacksession.h |
|
1620 // -------------------------------------------------------------------------- |
|
1621 void CUPnPPlaybackSession::SetVolumeL( const RMessage2& aMessage ) |
|
1622 { |
|
1623 __LOG( "CUPnPPlaybackSession::SetVolumeL" ); |
|
1624 |
|
1625 __ASSERT( !iSettingMessage, __FILE__, __LINE__ ); |
|
1626 |
|
1627 ResetL(); |
|
1628 |
|
1629 TInt volume = aMessage.Int1(); |
|
1630 |
|
1631 TInt maxVolume = iDevice->MaxVolume(); |
|
1632 |
|
1633 // If max volume not KMaxVolume |
|
1634 if( maxVolume != KMaxVolume ) |
|
1635 { |
|
1636 // Convert volume to match device's max volume |
|
1637 TReal tempVolumeLevel = volume; |
|
1638 TReal tempMaxVolume = maxVolume; |
|
1639 |
|
1640 volume = tempMaxVolume * tempVolumeLevel / KMaxVolume; |
|
1641 } |
|
1642 |
|
1643 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
|
1644 CpDeviceL(), KRenderingControl, KSetVolume ); |
|
1645 |
|
1646 TBuf8<KMaxIntLength> buf; |
|
1647 buf.Num( KDefaultInstanceId ); |
|
1648 action->SetArgumentL( KInstanceID, buf ); |
|
1649 action->SetArgumentL( KChannel, KMasterVolume ); |
|
1650 buf.Num( volume ); |
|
1651 action->SetArgumentL( KDesiredVolume, buf ); |
|
1652 |
|
1653 iServer.ControlPoint().SendL( action ); |
|
1654 CleanupStack::Pop( action ); |
|
1655 if (action->SessionId() < 0) User::Leave( action->SessionId() ); |
|
1656 iIPSessionIdSetting = action->SessionId(); |
|
1657 |
|
1658 // Register |
|
1659 iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this ); |
|
1660 iSettingMessage = new (ELeave) RMessage2( aMessage ); |
|
1661 } |
|
1662 |
|
1663 // -------------------------------------------------------------------------- |
|
1664 // CUPnPPlaybackSession::CancelSetVolumeL |
|
1665 // See upnpplaybacksession.h |
|
1666 // -------------------------------------------------------------------------- |
|
1667 void CUPnPPlaybackSession::CancelSetVolumeL() |
|
1668 { |
|
1669 __LOG( "CUPnPPlaybackSession::CancelSetVolumeL" ); |
|
1670 |
|
1671 if( iSettingMessage ) |
|
1672 { |
|
1673 iServer.Dispatcher().UnRegister( iIPSessionIdSetting ); |
|
1674 iIPSessionIdSetting = KErrNotFound; |
|
1675 iSettingMessage->Complete( KErrCancel ); |
|
1676 delete iSettingMessage; iSettingMessage = NULL; |
|
1677 } |
|
1678 } |
|
1679 |
|
1680 // -------------------------------------------------------------------------- |
|
1681 // CUPnPPlaybackSession::GetVolumeL |
|
1682 // See upnpplaybacksession.h |
|
1683 // -------------------------------------------------------------------------- |
|
1684 void CUPnPPlaybackSession::GetVolumeL( const RMessage2& aMessage ) |
|
1685 { |
|
1686 __LOG( "CUPnPPlaybackSession::GetVolumeL" ); |
|
1687 |
|
1688 __ASSERT( !iSettingMessage, __FILE__, __LINE__ ); |
|
1689 |
|
1690 ResetL(); |
|
1691 |
|
1692 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
|
1693 CpDeviceL(), KRenderingControl, KGetVolume ); |
|
1694 |
|
1695 TBuf8<KMaxIntLength> buf; |
|
1696 buf.Num( KDefaultInstanceId ); |
|
1697 action->SetArgumentL( KInstanceID, buf ); |
|
1698 action->SetArgumentL( KChannel, KMasterVolume ); |
|
1699 |
|
1700 iServer.ControlPoint().SendL( action ); |
|
1701 CleanupStack::Pop( action ); |
|
1702 if (action->SessionId() < 0) User::Leave( action->SessionId() ); |
|
1703 iIPSessionIdSetting = action->SessionId(); |
|
1704 |
|
1705 // Register |
|
1706 iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this ); |
|
1707 iSettingMessage = new (ELeave) RMessage2( aMessage ); |
|
1708 } |
|
1709 |
|
1710 // -------------------------------------------------------------------------- |
|
1711 // CUPnPPlaybackSession::CancelGetVolumeL |
|
1712 // See upnpplaybacksession.h |
|
1713 // -------------------------------------------------------------------------- |
|
1714 void CUPnPPlaybackSession::CancelGetVolumeL() |
|
1715 { |
|
1716 __LOG( "CUPnPPlaybackSession::CancelGetVolumeL" ); |
|
1717 |
|
1718 if( iSettingMessage ) |
|
1719 { |
|
1720 iServer.Dispatcher().UnRegister( iIPSessionIdSetting ); |
|
1721 iIPSessionIdSetting = KErrNotFound; |
|
1722 iSettingMessage->Complete( KErrCancel ); |
|
1723 delete iSettingMessage; iSettingMessage = NULL; |
|
1724 } |
|
1725 } |
|
1726 |
|
1727 // -------------------------------------------------------------------------- |
|
1728 // CUPnPPlaybackSession::SetMuteL |
|
1729 // See upnpplaybacksession.h |
|
1730 // -------------------------------------------------------------------------- |
|
1731 void CUPnPPlaybackSession::SetMuteL( const RMessage2& aMessage ) |
|
1732 { |
|
1733 __LOG( "CUPnPPlaybackSession::SetMuteL" ); |
|
1734 |
|
1735 __ASSERT( !iSettingMessage, __FILE__, __LINE__ ); |
|
1736 |
|
1737 ResetL(); |
|
1738 |
|
1739 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
|
1740 CpDeviceL(), KRenderingControl, KSetMute ); |
|
1741 |
|
1742 TBuf8<KMaxIntLength> buf; |
|
1743 buf.Num( KDefaultInstanceId ); |
|
1744 action->SetArgumentL( KInstanceID, buf ); |
|
1745 action->SetArgumentL( KChannel, KMasterVolume ); |
|
1746 if ( aMessage.Int1() ) |
|
1747 { |
|
1748 action->SetArgumentL( KDesiredMute, KMuteOn ); |
|
1749 } |
|
1750 else |
|
1751 { |
|
1752 action->SetArgumentL( KDesiredMute, KMuteOff ); |
|
1753 } |
|
1754 |
|
1755 iServer.ControlPoint().SendL( action ); |
|
1756 CleanupStack::Pop( action ); |
|
1757 if (action->SessionId() < 0) User::Leave( action->SessionId() ); |
|
1758 iIPSessionIdSetting = action->SessionId(); |
|
1759 |
|
1760 // Register |
|
1761 iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this ); |
|
1762 iSettingMessage = new (ELeave) RMessage2( aMessage ); |
|
1763 } |
|
1764 |
|
1765 // -------------------------------------------------------------------------- |
|
1766 // CUPnPPlaybackSession::CancelSetMuteL |
|
1767 // See upnpplaybacksession.h |
|
1768 // -------------------------------------------------------------------------- |
|
1769 void CUPnPPlaybackSession::CancelSetMuteL() |
|
1770 { |
|
1771 __LOG( "CUPnPPlaybackSession::CancelSetMuteL" ); |
|
1772 |
|
1773 if( iSettingMessage ) |
|
1774 { |
|
1775 iServer.Dispatcher().UnRegister( iIPSessionIdSetting ); |
|
1776 iIPSessionIdSetting = KErrNotFound; |
|
1777 iSettingMessage->Complete( KErrCancel ); |
|
1778 delete iSettingMessage; iSettingMessage = NULL; |
|
1779 } |
|
1780 } |
|
1781 |
|
1782 // -------------------------------------------------------------------------- |
|
1783 // CUPnPPlaybackSession::GetMuteL |
|
1784 // See upnpplaybacksession.h |
|
1785 // -------------------------------------------------------------------------- |
|
1786 void CUPnPPlaybackSession::GetMuteL( const RMessage2& aMessage ) |
|
1787 { |
|
1788 __LOG( "CUPnPPlaybackSession::GetMuteL" ); |
|
1789 |
|
1790 __ASSERT( !iSettingMessage, __FILE__, __LINE__ ); |
|
1791 |
|
1792 ResetL(); |
|
1793 |
|
1794 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
|
1795 CpDeviceL(), KRenderingControl, KGetMute ); |
|
1796 |
|
1797 TBuf8<KMaxIntLength> buf; |
|
1798 buf.Num( KDefaultInstanceId ); |
|
1799 action->SetArgumentL( KInstanceID, buf ); |
|
1800 action->SetArgumentL( KChannel, KMasterVolume ); |
|
1801 |
|
1802 iServer.ControlPoint().SendL( action ); |
|
1803 CleanupStack::Pop( action ); |
|
1804 if (action->SessionId() < 0) User::Leave( action->SessionId() ); |
|
1805 iIPSessionIdSetting = action->SessionId(); |
|
1806 |
|
1807 // Register |
|
1808 iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this ); |
|
1809 iSettingMessage = new (ELeave) RMessage2( aMessage ); |
|
1810 |
|
1811 } |
|
1812 |
|
1813 // -------------------------------------------------------------------------- |
|
1814 // CUPnPPlaybackSession::CancelGetMuteL |
|
1815 // See upnpplaybacksession.h |
|
1816 // -------------------------------------------------------------------------- |
|
1817 void CUPnPPlaybackSession::CancelGetMuteL() |
|
1818 { |
|
1819 __LOG( "CUPnPPlaybackSession::CancelGetMuteL" ); |
|
1820 |
|
1821 if( iSettingMessage ) |
|
1822 { |
|
1823 iServer.Dispatcher().UnRegister( iIPSessionIdSetting ); |
|
1824 iIPSessionIdSetting = KErrNotFound; |
|
1825 iSettingMessage->Complete( KErrCancel ); |
|
1826 delete iSettingMessage; iSettingMessage = NULL; |
|
1827 } |
|
1828 } |
|
1829 |
|
1830 // -------------------------------------------------------------------------- |
|
1831 // CUPnPPlaybackSession::GetPositionInfoL |
|
1832 // See upnpplaybacksession.h |
|
1833 // -------------------------------------------------------------------------- |
|
1834 void CUPnPPlaybackSession::GetPositionInfoL( const RMessage2& aMessage ) |
|
1835 { |
|
1836 __LOG( "CUPnPPlaybackSession::GetPositionInfoL" ); |
|
1837 |
|
1838 __ASSERT( !iCommandMessage, __FILE__, __LINE__ ); |
|
1839 |
|
1840 ResetL(); |
|
1841 |
|
1842 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
|
1843 CpDeviceL(), KAVTransport, KGetPositionInfo ); |
|
1844 |
|
1845 TBuf8<KMaxIntLength> buf; |
|
1846 buf.Num( iAVTInstanceId ); |
|
1847 action->SetArgumentL( KInstanceID, buf ); |
|
1848 |
|
1849 iServer.ControlPoint().SendL( action ); |
|
1850 CleanupStack::Pop( action ); |
|
1851 if (action->SessionId() < 0) User::Leave( action->SessionId() ); |
|
1852 iIPSessionIdCommand = action->SessionId(); |
|
1853 |
|
1854 // Register |
|
1855 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
1856 iCommandMessage = new (ELeave) RMessage2( aMessage ); |
|
1857 |
|
1858 } |
|
1859 |
|
1860 // -------------------------------------------------------------------------- |
|
1861 // CUPnPPlaybackSession::CancelGetPositionInfoL |
|
1862 // See upnpplaybacksession.h |
|
1863 // -------------------------------------------------------------------------- |
|
1864 void CUPnPPlaybackSession::CancelGetPositionInfoL() |
|
1865 { |
|
1866 __LOG( "CUPnPPlaybackSession::CancelGetPositionInfoL" ); |
|
1867 |
|
1868 if( iCommandMessage ) |
|
1869 { |
|
1870 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
1871 iIPSessionIdCommand = KErrNotFound; |
|
1872 iCommandMessage->Complete( KErrCancel ); |
|
1873 delete iCommandMessage; iCommandMessage = NULL; |
|
1874 } |
|
1875 } |
|
1876 |
|
1877 // -------------------------------------------------------------------------- |
|
1878 // CUPnPPlaybackSession::SeekRelTimeL |
|
1879 // See upnpplaybacksession.h |
|
1880 // -------------------------------------------------------------------------- |
|
1881 void CUPnPPlaybackSession::SeekRelTimeL( const RMessage2& aMessage ) |
|
1882 { |
|
1883 __LOG( "CUPnPPlaybackSession::SeekRelTimeL" ); |
|
1884 |
|
1885 __ASSERT( !iCommandMessage, __FILE__, __LINE__ ); |
|
1886 |
|
1887 ResetL(); |
|
1888 |
|
1889 // Get the seek target value from aMessage parameter |
|
1890 // create buffer |
|
1891 TInt len = aMessage.GetDesMaxLength( 1 ); |
|
1892 HBufC8* buf = HBufC8::NewLC( len ); |
|
1893 TPtr8 ptr( buf->Des() ); |
|
1894 User::LeaveIfError( aMessage.Read( 1, ptr ) ); |
|
1895 |
|
1896 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
|
1897 CpDeviceL(), KAVTransport, KSeek ); |
|
1898 |
|
1899 TBuf8<KMaxIntLength> bufInt; |
|
1900 bufInt.Num( iAVTInstanceId ); |
|
1901 action->SetArgumentL( KInstanceID, bufInt ); |
|
1902 action->SetArgumentL( KUnit, KRel_Time ); |
|
1903 action->SetArgumentL( KTarget, *buf ); |
|
1904 |
|
1905 iServer.ControlPoint().SendL( action ); |
|
1906 CleanupStack::Pop( action ); |
|
1907 if (action->SessionId() < 0) User::Leave( action->SessionId() ); |
|
1908 iIPSessionIdCommand = action->SessionId(); |
|
1909 |
|
1910 CleanupStack::PopAndDestroy( buf ); |
|
1911 |
|
1912 // Register |
|
1913 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
1914 iCommandMessage = new (ELeave) RMessage2( aMessage ); |
|
1915 } |
|
1916 |
|
1917 // -------------------------------------------------------------------------- |
|
1918 // CUPnPPlaybackSession::CancelSeekRelTimeL |
|
1919 // See upnpplaybacksession.h |
|
1920 // -------------------------------------------------------------------------- |
|
1921 void CUPnPPlaybackSession::CancelSeekRelTimeL() |
|
1922 { |
|
1923 __LOG( "CUPnPPlaybackSession::CancelSeekRelTimeL" ); |
|
1924 |
|
1925 if( iCommandMessage ) |
|
1926 { |
|
1927 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
1928 iIPSessionIdCommand = KErrNotFound; |
|
1929 iCommandMessage->Complete( KErrCancel ); |
|
1930 delete iCommandMessage; |
|
1931 iCommandMessage = NULL; |
|
1932 } |
|
1933 } |
|
1934 |
|
1935 // -------------------------------------------------------------------------- |
|
1936 // CUPnPPlaybackSession::GetRendererStateL |
|
1937 // See upnpplaybacksession.h |
|
1938 // -------------------------------------------------------------------------- |
|
1939 void CUPnPPlaybackSession::GetRendererStateL( const RMessage2& aMessage ) |
|
1940 { |
|
1941 __LOG( "CUPnPPlaybackSession::GetRendererStateL" ); |
|
1942 |
|
1943 if( iPlaybackState == EStopped || iPlaybackState == ENoMedia ) |
|
1944 { |
|
1945 __LOG( "CUPnPPlaybackSession::GetRendererStateL - \ |
|
1946 Stopped or no_media" ); |
|
1947 TUnsolicitedEventE event( EStop ); |
|
1948 TPckg<TUnsolicitedEventE> resp1( event ); |
|
1949 TInt err = aMessage.Write( 1, resp1 ); |
|
1950 aMessage.Complete( err ); |
|
1951 } |
|
1952 else if( iPlaybackState == EPlaying ) |
|
1953 { |
|
1954 __LOG( "CUPnPPlaybackSession::GetRendererStateL - Playing" ); |
|
1955 TUnsolicitedEventE event( EPlay ); |
|
1956 TPckg<TUnsolicitedEventE> resp1( event ); |
|
1957 TInt err = aMessage.Write( 1, resp1 ); |
|
1958 aMessage.Complete( err ); |
|
1959 } |
|
1960 else if( iPlaybackState == EPaused ) |
|
1961 { |
|
1962 __LOG( "CUPnPPlaybackSession::GetRendererStateL - Paused" ); |
|
1963 TUnsolicitedEventE event( EPause ); |
|
1964 TPckg<TUnsolicitedEventE> resp1( event ); |
|
1965 TInt err = aMessage.Write( 1, resp1 ); |
|
1966 aMessage.Complete( err ); |
|
1967 } |
|
1968 else |
|
1969 { |
|
1970 __LOG( "CUPnPPlaybackSession::GetRendererStateL - Waiting.." ); |
|
1971 // Waiting the initial event |
|
1972 __ASSERT( !iInitialEventMsg, __FILE__, __LINE__ ); |
|
1973 iTimer->Start( KTimerCycle10 ); |
|
1974 iInitialEventMsg = new (ELeave) RMessage2( aMessage ); |
|
1975 } |
|
1976 } |
|
1977 |
|
1978 // -------------------------------------------------------------------------- |
|
1979 // CUPnPPlaybackSession::DeviceDisappearedRequestL |
|
1980 // See upnpplaybacksession.h |
|
1981 // -------------------------------------------------------------------------- |
|
1982 void CUPnPPlaybackSession::DeviceDisappearedRequestL( |
|
1983 const RMessage2& aMessage ) |
|
1984 { |
|
1985 __LOG( "CUPnPPlaybackSession::DeviceDisappearedRequestL" ); |
|
1986 |
|
1987 __ASSERT( !iDeviceMessage, __FILE__, __LINE__ ); |
|
1988 |
|
1989 iDeviceMessage = new (ELeave ) RMessage2( aMessage ); |
|
1990 } |
|
1991 |
|
1992 // -------------------------------------------------------------------------- |
|
1993 // CUPnPPlaybackSession::CancelDeviceDisappearedRequestL |
|
1994 // See upnpplaybacksession.h |
|
1995 // -------------------------------------------------------------------------- |
|
1996 void CUPnPPlaybackSession::CancelDeviceDisappearedRequestL() |
|
1997 { |
|
1998 __LOG( "CUPnPPlaybackSession::CancelDeviceDisappearedRequestL" ); |
|
1999 |
|
2000 if( iDeviceMessage ) |
|
2001 { |
|
2002 iDeviceMessage->Complete( KErrCancel ); |
|
2003 delete iDeviceMessage; iDeviceMessage = NULL; |
|
2004 } |
|
2005 } |
|
2006 |
|
2007 // -------------------------------------------------------------------------- |
|
2008 // CUPnPPlaybackSession::Uuid |
|
2009 // See upnpplaybacksession.h |
|
2010 // -------------------------------------------------------------------------- |
|
2011 const TDesC8& CUPnPPlaybackSession::Uuid() const |
|
2012 { |
|
2013 if( iDevice ) |
|
2014 { |
|
2015 return iDevice->Uuid(); |
|
2016 } |
|
2017 else |
|
2018 { |
|
2019 return KNullDesC8; |
|
2020 } |
|
2021 } |
|
2022 |
|
2023 // -------------------------------------------------------------------------- |
|
2024 // CUPnPPlaybackSession::EncodeXmlL |
|
2025 // See upnpplaybacksession.h |
|
2026 // -------------------------------------------------------------------------- |
|
2027 HBufC8* CUPnPPlaybackSession::EncodeXmlL( const TDesC8& aResult ) |
|
2028 { |
|
2029 HBufC8* tmpBuf = aResult.AllocLC(); |
|
2030 HBufC8* result = UpnpString::EncodeXmlStringL( tmpBuf ); |
|
2031 CleanupStack::PopAndDestroy( tmpBuf ); |
|
2032 return result; |
|
2033 } |
|
2034 |
|
2035 // -------------------------------------------------------------------------- |
|
2036 // CUPnPPlaybackSession::Reset |
|
2037 // See upnpplaybacksession.h |
|
2038 // -------------------------------------------------------------------------- |
|
2039 void CUPnPPlaybackSession::ResetL() |
|
2040 { |
|
2041 __LOG( "CUPnPPlaybackSession::ResetL" ); |
|
2042 |
|
2043 if( !iServer.DeviceRepository().IsWlanActive() ) |
|
2044 { |
|
2045 __LOG( "Reset - disconnected" ); |
|
2046 User::Leave( KErrDisconnected ); |
|
2047 } |
|
2048 } |
|
2049 |
|
2050 // -------------------------------------------------------------------------- |
|
2051 // CUPnPPlaybackSession::ReadObjFromMessageL |
|
2052 // See upnpplaybacksession.h |
|
2053 // -------------------------------------------------------------------------- |
|
2054 void CUPnPPlaybackSession::ReadObjFromMessageL( const RMessage2& aMessage, |
|
2055 TInt aSlot, CUpnpObject* aObj ) |
|
2056 { |
|
2057 // create buffer |
|
2058 TInt len = aMessage.GetDesMaxLength( aSlot ); |
|
2059 HBufC8* buf = HBufC8::NewLC( len ); |
|
2060 TPtr8 ptr( buf->Des() ); |
|
2061 User::LeaveIfError( aMessage.Read( aSlot, ptr ) ); |
|
2062 |
|
2063 // read stream |
|
2064 RDesReadStream stream( *buf ); |
|
2065 CleanupClosePushL( stream ); |
|
2066 |
|
2067 // internalize object |
|
2068 stream >> *aObj; |
|
2069 |
|
2070 // clean up |
|
2071 CleanupStack::PopAndDestroy( &stream ); |
|
2072 CleanupStack::PopAndDestroy( buf ); |
|
2073 } |
|
2074 |
|
2075 // -------------------------------------------------------------------------- |
|
2076 // CUPnPPlaybackSession::ReadReqFromMessageL |
|
2077 // See upnpplaybacksession.h |
|
2078 // -------------------------------------------------------------------------- |
|
2079 void CUPnPPlaybackSession::ReadReqFromMessageL( const RMessage2& aMessage, |
|
2080 TInt aSlot, CUpnpAVRequest* aReq ) |
|
2081 { |
|
2082 // create buffer |
|
2083 TInt len = aMessage.GetDesMaxLength( aSlot ); |
|
2084 HBufC8* buf = HBufC8::NewLC( len ); |
|
2085 TPtr8 ptr( buf->Des() ); |
|
2086 User::LeaveIfError( aMessage.Read( aSlot, ptr ) ); |
|
2087 |
|
2088 // read stream |
|
2089 RDesReadStream stream( *buf ); |
|
2090 CleanupClosePushL( stream ); |
|
2091 |
|
2092 // internalize object |
|
2093 stream >> *aReq; |
|
2094 |
|
2095 // clean up |
|
2096 CleanupStack::PopAndDestroy( &stream ); |
|
2097 CleanupStack::PopAndDestroy( buf ); |
|
2098 } |
|
2099 |
|
2100 void CUPnPPlaybackSession::ValidateProtocolInfoL( const CUpnpAttribute& |
|
2101 aResource ) |
|
2102 { |
|
2103 __LOG( "CUPnPPlaybackSession::ValidateProtocolInfoL" ); |
|
2104 |
|
2105 // Whe'd like to modify the original protocolInfo, that's why constness |
|
2106 // is casted away |
|
2107 CUpnpAttribute& attr = const_cast<CUpnpAttribute&>( aResource ); |
|
2108 |
|
2109 // ProtocolInfo-wrapper takes care of 4th field validation, omitting |
|
2110 // invalid optional parameters |
|
2111 CUpnpDlnaProtocolInfo* tmpInfo = |
|
2112 CUpnpDlnaProtocolInfo::NewL( attr.Value() ); |
|
2113 CleanupStack::PushL( tmpInfo ); |
|
2114 |
|
2115 tmpInfo->SetSecondFieldL( KAsterisk ); // Second field must be '*' |
|
2116 |
|
2117 attr.SetValueL( tmpInfo->ProtocolInfoL() ); |
|
2118 |
|
2119 CleanupStack::PopAndDestroy( tmpInfo ); |
|
2120 |
|
2121 __LOG( "CUPnPPlaybackSession::ValidateProtocolInfoL - end" ); |
|
2122 } |
|
2123 |
|
2124 // -------------------------------------------------------------------------- |
|
2125 // CUPnPPlaybackSession::CheckConnectionL |
|
2126 // See upnpplaybacksession.h |
|
2127 // -------------------------------------------------------------------------- |
|
2128 TBool CUPnPPlaybackSession::CheckConnectionL( |
|
2129 const TDesC8& aProtocolInfo ) |
|
2130 { |
|
2131 __LOG( "CUPnPPlaybackSession::CheckConnectionL" ); |
|
2132 |
|
2133 // 1. Check that is CM:PrepareForConnection supported. If not, return |
|
2134 // true. This means that we don't need to establish a new connection |
|
2135 // (we can just used instance id 0) |
|
2136 // 2. If PrepareForConnection is supported, check that do have a |
|
2137 // connection already (!iPInfoForPrevious). If not, return false |
|
2138 // (a new connection is needed). If we have a connection, check that |
|
2139 // does the type of content change. If it changes, a new connection |
|
2140 // is needed. |
|
2141 |
|
2142 if( iDevice->PrepareForConnection() ) |
|
2143 { |
|
2144 __LOG( "CUPnPPlaybackSession::CheckConnectionL - \ |
|
2145 CM:PrepareForConnection supported" ); |
|
2146 |
|
2147 if( iPInfoForPrevious && ( iConnectionId != KErrNotFound ) ) |
|
2148 { |
|
2149 CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL( |
|
2150 aProtocolInfo ); |
|
2151 |
|
2152 if( tmpInfo->SecondField() == iPInfoForPrevious->SecondField() && |
|
2153 tmpInfo->PnParameter() == iPInfoForPrevious->PnParameter() ) |
|
2154 { |
|
2155 __LOG( "CUPnPPlaybackSession::CheckConnectionL - \ |
|
2156 same as previous" ); |
|
2157 delete tmpInfo; |
|
2158 return ETrue; |
|
2159 } |
|
2160 else |
|
2161 { |
|
2162 __LOG( "CUPnPPlaybackSession::CheckConnectionL - \ |
|
2163 media type changes, a new connection is needed" ); |
|
2164 // Close existing. Ignore error code (we can do nothing |
|
2165 // useful in error case) |
|
2166 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
|
2167 CpDeviceL(), KConnectionManager, KConnectionComplete ); |
|
2168 |
|
2169 TBuf8<KMaxIntLength> buf; |
|
2170 buf.Num( iConnectionId ); |
|
2171 action->SetArgumentL( KConnectionID, buf ); |
|
2172 |
|
2173 iServer.ControlPoint().SendL( action ); |
|
2174 CleanupStack::Pop( action ); |
|
2175 |
|
2176 iConnectionId = KErrNotFound; |
|
2177 iAVTInstanceId = KDefaultInstanceId; |
|
2178 iRCInstanceId = KDefaultInstanceId; |
|
2179 delete tmpInfo; |
|
2180 return EFalse; |
|
2181 } |
|
2182 } |
|
2183 else |
|
2184 { |
|
2185 // No existing connection, a new connection is needed |
|
2186 return EFalse; |
|
2187 } |
|
2188 } |
|
2189 else |
|
2190 { |
|
2191 __LOG( "CUPnPPlaybackSession::CheckConnectionL - \ |
|
2192 CM:PrepareForConnection not supported" ); |
|
2193 |
|
2194 // CM:PrepareForConnection is not supported |
|
2195 return ETrue; |
|
2196 } |
|
2197 } |
|
2198 |
|
2199 // -------------------------------------------------------------------------- |
|
2200 // CUPnPPlaybackSession::SendAVTransportUriActionL |
|
2201 // See upnpplaybacksession.h |
|
2202 // -------------------------------------------------------------------------- |
|
2203 void CUPnPPlaybackSession::SendAVTransportUriActionL() |
|
2204 { |
|
2205 __LOG( "CUPnPPlaybackSession::SendAVTransportUriActionL" ); |
|
2206 |
|
2207 const CUpnpElement& res = |
|
2208 UPnPItemUtility::ResourceFromItemL( *iCurrentItem ); |
|
2209 const CUpnpAttribute* protocolInfo = |
|
2210 UPnPItemUtility::FindAttributeByName( |
|
2211 res, KAttributeProtocolInfo ); |
|
2212 |
|
2213 TPtrC8 uri( *iCurrentUri ); |
|
2214 |
1655 if( !iDevice->MatchSinkProtocolInfo( protocolInfo->Value() ) ) |
2215 if( !iDevice->MatchSinkProtocolInfo( protocolInfo->Value() ) ) |
1656 { |
2216 { |
1657 // Did not match, try to find a match |
2217 // Did not match, try to find a match |
1658 TRAPD( err, uri.Set( iDevice->FindFirstMatchingInSinkL( |
2218 TRAPD( err, uri.Set( iDevice->FindFirstMatchingInSinkL( |
1659 *tmpItem ) ) ); |
2219 *iCurrentItem ) ) ); |
1660 if( err == KErrNone ) |
2220 if( err == KErrNone ) |
1661 { |
2221 { |
1662 // Suitable res-element found! |
2222 // Suitable res-element found! |
1663 __LOG( "Suitable element found!" ); |
2223 __LOG( "Suitable element found!" ); |
1664 } |
2224 } |
1684 } |
2244 } |
1685 } |
2245 } |
1686 |
2246 |
1687 ValidateProtocolInfoL( *protocolInfo ); |
2247 ValidateProtocolInfoL( *protocolInfo ); |
1688 |
2248 |
|
2249 if( !iDevice->DlnaCompatible() ) |
|
2250 { |
|
2251 // down grade to upnpitem |
|
2252 RemoveDlnaFlagsFromResElementsL(); |
|
2253 } |
|
2254 else if( ( iDevice->DLNADeviceType() != CUpnpAVDeviceExtended::EDMR ) || |
|
2255 ( !iDevice->MatchSinkProfileId( protocolInfo->Value() ) && |
|
2256 iDevice->MatchSinkMime( protocolInfo->Value()) ) ) |
|
2257 { |
|
2258 // remove DLNA profile |
|
2259 RemoveDlnaProfileFromResElementsL(); |
|
2260 } |
|
2261 |
1689 // Create metadata xml document |
2262 // Create metadata xml document |
1690 HBufC8* xmlDoc = CUPnPXMLParser::ItemAsXmlLC( *tmpItem ); |
2263 HBufC8* xmlDoc = CUPnPXMLParser::ItemAsXmlLC( *iCurrentItem ); |
1691 |
2264 |
1692 iIPSessionIdCommand = iServer.ControlPoint(). |
2265 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
1693 AvtSetTransportUriActionL( iDevice->Uuid(), iInstanceId, uri, |
2266 CpDeviceL(), KAVTransport, KSetAVTransportURI ); |
1694 //KNullDesC8 ); |
2267 |
1695 *xmlDoc ); |
2268 TBuf8<KMaxIntLength> buf; |
1696 |
2269 buf.Num( iAVTInstanceId ); |
1697 CleanupStack::PopAndDestroy( xmlDoc ); |
2270 action->SetArgumentL( KInstanceID, buf ); |
1698 CleanupStack::PopAndDestroy( tmpItem ); |
2271 action->SetArgumentL( KCurrentURI, uri ); |
1699 CleanupStack::PopAndDestroy( tmpRequest ); |
2272 action->SetArgumentL( KCurrentURIMetaData, *xmlDoc ); |
1700 |
2273 |
|
2274 iServer.ControlPoint().SendL( action ); |
|
2275 CleanupStack::Pop( action ); |
|
2276 if (action->SessionId() < 0) User::Leave(action->SessionId()); |
|
2277 iIPSessionIdCommand = action->SessionId(); |
|
2278 |
|
2279 CleanupStack::PopAndDestroy( xmlDoc ); |
|
2280 |
|
2281 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
2282 |
|
2283 // Set playback state artificially to no media. This way we can recognize |
|
2284 // if renderer has responded with CurrentTrackUri |
|
2285 iPlaybackState = ENoMedia; |
|
2286 iExpectedEvent = EEventAVTransportUri; |
|
2287 |
|
2288 __LOG( "CUPnPPlaybackSession::SendAVTransportUriActionL - end" ); |
|
2289 } |
|
2290 |
|
2291 // -------------------------------------------------------------------------- |
|
2292 // CUPnPPlaybackSession::RemoveDlnaFlagsFromResElementL |
|
2293 // -------------------------------------------------------------------------- |
|
2294 void CUPnPPlaybackSession::RemoveDlnaFlagsFromResElementsL() |
|
2295 { |
|
2296 __LOG( "CUPnPPlaybackSession::RemoveDlnaFlagsFromResElementL" ); |
|
2297 RUPnPElementsArray& elements = const_cast<RUPnPElementsArray&>( |
|
2298 iCurrentItem->GetElements()); |
|
2299 |
|
2300 for( TInt resIndex(0); resIndex < elements.Count(); ++resIndex ) |
|
2301 { |
|
2302 if( elements[resIndex]->Name() == KElementRes() ) |
|
2303 { |
|
2304 const RUPnPAttributesArray& array = |
|
2305 elements[resIndex]->GetAttributes(); |
|
2306 CUpnpElement* elem = CUpnpElement::NewLC( KElementRes() ); |
|
2307 for( TInt i = 0; i < array.Count(); i++ ) |
|
2308 { |
|
2309 _LIT8( KProtocolInfo, "protocolInfo" ); |
|
2310 _LIT8( KDlnaOrg, "DLNA.ORG" ); |
1701 |
2311 |
1702 if( iIPSessionIdCommand > 0 ) |
2312 if( array[ i ]->Name() == KProtocolInfo() ) |
1703 { |
|
1704 // Register |
|
1705 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
1706 } |
|
1707 else |
|
1708 { |
|
1709 User::Leave( iIPSessionIdCommand ); |
|
1710 } |
|
1711 |
|
1712 iCommandMessage = new (ELeave) RMessage2( aMessage ); |
|
1713 |
|
1714 // after settransporturi, there is a delay to send play action. |
|
1715 if ( !iPlayDelayTimer->IsActive() ) |
|
1716 { |
|
1717 iPlayDelayTimer->Start( |
|
1718 0, KPlayDelayTimerInterval, |
|
1719 TCallBack( PlayDelayTimeExpired , this ) ); |
|
1720 } |
|
1721 else |
|
1722 { |
|
1723 iPlayDelayTimer->Cancel(); |
|
1724 iPlayDelayTimer->Start( |
|
1725 0, KPlayDelayTimerInterval, |
|
1726 TCallBack( PlayDelayTimeExpired , this ) ); |
|
1727 } |
|
1728 __LOG( "CUPnPPlaybackSession::SetURIL - end" ); |
|
1729 } |
|
1730 |
|
1731 // -------------------------------------------------------------------------- |
|
1732 // CUPnPPlaybackSession::CancelSetURIL |
|
1733 // See upnpplaybacksession.h |
|
1734 // -------------------------------------------------------------------------- |
|
1735 void CUPnPPlaybackSession::CancelSetURIL() |
|
1736 { |
|
1737 __LOG( "CUPnPPlaybackSession::CancelSetURIL" ); |
|
1738 |
|
1739 if( iCommandMessage ) |
|
1740 { |
|
1741 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
1742 iIPSessionIdCommand = KErrNotFound; |
|
1743 iCommandMessage->Complete( KErrCancel ); |
|
1744 delete iCommandMessage; iCommandMessage = NULL; |
|
1745 } |
|
1746 } |
|
1747 |
|
1748 // -------------------------------------------------------------------------- |
|
1749 // CUPnPPlaybackSession::SetNextURIL |
|
1750 // See upnpplaybacksession.h |
|
1751 // -------------------------------------------------------------------------- |
|
1752 void CUPnPPlaybackSession::SetNextURIL( const RMessage2& aMessage ) |
|
1753 { |
|
1754 __LOG( "CUPnPPlaybackSession::SetNextURIL" ); |
|
1755 |
|
1756 __ASSERTD( !iCommandMessage, __FILE__, __LINE__ ); |
|
1757 |
|
1758 ResetL(); |
|
1759 |
|
1760 if( iNextItemShared ) |
|
1761 { |
|
1762 iFileSharing->UnShareItemL( iNextSharedItem->Id() ); |
|
1763 iNextItemShared = EFalse; |
|
1764 } |
|
1765 |
|
1766 // Uri is set by providing an item. Convert the item to xml document and |
|
1767 // send the action |
|
1768 CUpnpAVRequest* tmpRequest = CUpnpAVRequest::NewLC(); |
|
1769 |
|
1770 ReadReqFromMessageL( aMessage, 1 ,tmpRequest ); |
|
1771 |
|
1772 CUpnpItem* tmpItem = CUpnpItem::NewL(); |
|
1773 CleanupStack::PushL( tmpItem ); |
|
1774 |
|
1775 ReadObjFromMessageL( aMessage, 2 ,tmpItem ); |
|
1776 |
|
1777 TPtrC8 uri = tmpRequest->URI(); |
|
1778 |
|
1779 const CUpnpElement& res = |
|
1780 UPnPItemUtility::ResourceFromItemL( *tmpItem ); |
|
1781 const CUpnpAttribute* protocolInfo = |
|
1782 UPnPItemUtility::FindAttributeByName( |
|
1783 res, KAttributeProtocolInfo ); |
|
1784 |
|
1785 if( !iDevice->MatchSinkProtocolInfo( protocolInfo->Value() ) ) |
|
1786 { |
|
1787 // Did not match, try to find a match |
|
1788 TRAPD( err, uri.Set( iDevice->FindFirstMatchingInSinkL( |
|
1789 *tmpItem ) ) ); |
|
1790 if( err == KErrNone ) |
|
1791 { |
|
1792 // Suitable res-element found! |
|
1793 } |
|
1794 else if( err == KErrNotSupported ) |
|
1795 { |
|
1796 // No suitable res-element |
|
1797 if( iDevice->DLNADeviceType() == |
|
1798 CUpnpAVDeviceExtended::EDMR ) |
|
1799 { |
|
1800 // DLNA content, DLNA device, no match -> leave |
|
1801 User::Leave( KErrNotSupported ); |
|
1802 } |
|
1803 else |
|
1804 { |
|
1805 // Not a dlna device, try to set the uri of |
|
1806 // original res-element anyways |
|
1807 } |
|
1808 } |
|
1809 else |
|
1810 { |
|
1811 // Some error occured |
|
1812 User::Leave( err ); |
|
1813 } |
|
1814 } |
|
1815 |
|
1816 // Create metadata xml document |
|
1817 HBufC8* xmlDoc = CUPnPXMLParser::ItemAsXmlLC( *tmpItem ); |
|
1818 |
|
1819 iIPSessionIdCommand = iServer.ControlPoint(). |
|
1820 AvtSetNextTransportUriActionL( iDevice->Uuid(), iInstanceId, uri, |
|
1821 *xmlDoc ); |
|
1822 |
|
1823 |
|
1824 CleanupStack::PopAndDestroy( xmlDoc ); |
|
1825 CleanupStack::PopAndDestroy( tmpItem ); |
|
1826 CleanupStack::PopAndDestroy( tmpRequest ); |
|
1827 |
|
1828 if( iIPSessionIdCommand > 0 ) |
|
1829 { |
|
1830 // Register |
|
1831 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
1832 } |
|
1833 else |
|
1834 { |
|
1835 User::Leave( iIPSessionIdCommand ); |
|
1836 } |
|
1837 |
|
1838 iCommandMessage = new (ELeave) RMessage2( aMessage ); |
|
1839 |
|
1840 __LOG( "CUPnPPlaybackSession::SetNextURIL - end" ); |
|
1841 |
|
1842 } |
|
1843 |
|
1844 // -------------------------------------------------------------------------- |
|
1845 // CUPnPPlaybackSession::CancelSetNextURIL |
|
1846 // See upnpplaybacksession.h |
|
1847 // -------------------------------------------------------------------------- |
|
1848 void CUPnPPlaybackSession::CancelSetNextURIL() |
|
1849 { |
|
1850 __LOG( "CUPnPPlaybackSession::CancelSetNextURIL" ); |
|
1851 |
|
1852 //__ASSERTD( iCommandPending, User::Panic( KPanicText, __LINE__ ) ); |
|
1853 if( iCommandMessage ) |
|
1854 { |
|
1855 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
1856 iIPSessionIdCommand = KErrNotFound; |
|
1857 iCommandMessage->Complete( KErrCancel ); |
|
1858 delete iCommandMessage; iCommandMessage = NULL; |
|
1859 } |
|
1860 } |
|
1861 |
|
1862 // -------------------------------------------------------------------------- |
|
1863 // CUPnPPlaybackSession::PlayL |
|
1864 // See upnpplaybacksession.h |
|
1865 // -------------------------------------------------------------------------- |
|
1866 void CUPnPPlaybackSession::PlayL( const RMessage2& aMessage ) |
|
1867 { |
|
1868 __LOG( "CUPnPPlaybackSession::PlayL" ); |
|
1869 if ( !iPlayDelayTimer->IsActive() ) |
|
1870 { |
|
1871 // timer is not running so some time has passed since subscribing |
|
1872 __ASSERTD( !iCommandMessage, __FILE__, __LINE__ ); |
|
1873 |
|
1874 ResetL(); |
|
1875 |
|
1876 iIPSessionIdCommand = iServer.ControlPoint().AvtPlayActionL( |
|
1877 iDevice->Uuid(), iInstanceId, KNormalSpeed ); |
|
1878 |
|
1879 if( iIPSessionIdCommand > 0 ) |
|
1880 { |
|
1881 __LOG( "CUPnPPlaybackSession::PlayL - registering" ); |
|
1882 // Register |
|
1883 iPlaybackState = EPlaySent; |
|
1884 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
1885 } |
|
1886 else |
|
1887 { |
|
1888 User::Leave( iIPSessionIdCommand ); |
|
1889 } |
|
1890 |
|
1891 } |
|
1892 else // less than KPlayDelayInterval passed since subscribe. |
|
1893 { |
|
1894 // issue the play after the timer expires to make sure some HW |
|
1895 // renderers are not confused when beginning the playback. |
|
1896 iPlayRequested = ETrue; |
|
1897 } |
|
1898 |
|
1899 iCommandMessage = new (ELeave) RMessage2( aMessage ); |
|
1900 __LOG( "CUPnPPlaybackSession::PlayL - end" ); |
|
1901 } |
|
1902 |
|
1903 // -------------------------------------------------------------------------- |
|
1904 // CUPnPPlaybackSession::CancelPlayL |
|
1905 // See upnpplaybacksession.h |
|
1906 // -------------------------------------------------------------------------- |
|
1907 void CUPnPPlaybackSession::CancelPlayL() |
|
1908 { |
|
1909 __LOG( "CUPnPPlaybackSession::CancelPlayL" ); |
|
1910 |
|
1911 //__ASSERTD( iCommandPending, User::Panic( KPanicText, __LINE__ ) ); |
|
1912 if( iCommandMessage ) |
|
1913 { |
|
1914 // cancel postponed play |
|
1915 if ( iPlayDelayTimer->IsActive() ) |
|
1916 { |
|
1917 iPlayDelayTimer->Cancel(); |
|
1918 } |
|
1919 |
|
1920 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
1921 iIPSessionIdCommand = KErrNotFound; |
|
1922 iCommandMessage->Complete( KErrCancel ); |
|
1923 delete iCommandMessage; iCommandMessage = NULL; |
|
1924 } |
|
1925 } |
|
1926 |
|
1927 // -------------------------------------------------------------------------- |
|
1928 // CUPnPPlaybackSession::StopL |
|
1929 // See upnpplaybacksession.h |
|
1930 // -------------------------------------------------------------------------- |
|
1931 void CUPnPPlaybackSession::StopL( const RMessage2& aMessage ) |
|
1932 { |
|
1933 __LOG( "CUPnPPlaybackSession::StopL" ); |
|
1934 |
|
1935 __ASSERTD( !iCommandMessage, __FILE__, __LINE__ ); |
|
1936 |
|
1937 ResetL(); |
|
1938 // state stopped must be check before stopped action |
|
1939 if( iPlaybackState != EStopped ) |
|
1940 { |
|
1941 iIPSessionIdCommand = iServer.ControlPoint().AvtStopActionL( |
|
1942 iDevice->Uuid(), iInstanceId ); |
|
1943 } |
|
1944 |
|
1945 if( iIPSessionIdCommand > 0 ) |
|
1946 { |
|
1947 // Register |
|
1948 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
1949 } |
|
1950 else |
|
1951 { |
|
1952 User::Leave( iIPSessionIdCommand ); |
|
1953 } |
|
1954 iCommandMessage = new (ELeave) RMessage2( aMessage ); |
|
1955 |
|
1956 __LOG( "CUPnPPlaybackSession::StopL - end" ); |
|
1957 } |
|
1958 |
|
1959 // -------------------------------------------------------------------------- |
|
1960 // CUPnPPlaybackSession::CancelStopL |
|
1961 // See upnpplaybacksession.h |
|
1962 // -------------------------------------------------------------------------- |
|
1963 void CUPnPPlaybackSession::CancelStopL() |
|
1964 { |
|
1965 __LOG( "CUPnPPlaybackSession::CancelStopL" ); |
|
1966 |
|
1967 if( iCommandMessage ) |
|
1968 { |
|
1969 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
1970 iIPSessionIdCommand = KErrNotFound; |
|
1971 iCommandMessage->Complete( KErrCancel ); |
|
1972 delete iCommandMessage; iCommandMessage = NULL; |
|
1973 } |
|
1974 } |
|
1975 |
|
1976 // -------------------------------------------------------------------------- |
|
1977 // CUPnPPlaybackSession::PauseL |
|
1978 // See upnpplaybacksession.h |
|
1979 // -------------------------------------------------------------------------- |
|
1980 void CUPnPPlaybackSession::PauseL( const RMessage2& aMessage ) |
|
1981 { |
|
1982 __LOG( "CUPnPPlaybackSession::PauseL" ); |
|
1983 |
|
1984 __ASSERTD( !iCommandMessage, __FILE__, __LINE__ ); |
|
1985 |
|
1986 ResetL(); |
|
1987 |
|
1988 iIPSessionIdCommand = iServer.ControlPoint().AvtPauseActionL( |
|
1989 iDevice->Uuid(), iInstanceId ); |
|
1990 |
|
1991 if( iIPSessionIdCommand > 0 ) |
|
1992 { |
|
1993 // Register |
|
1994 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
1995 } |
|
1996 else |
|
1997 { |
|
1998 User::Leave( iIPSessionIdCommand ); |
|
1999 } |
|
2000 iCommandMessage = new (ELeave) RMessage2( aMessage ); |
|
2001 |
|
2002 __LOG( "CUPnPPlaybackSession::PauseL - end" ); |
|
2003 } |
|
2004 |
|
2005 // -------------------------------------------------------------------------- |
|
2006 // CUPnPPlaybackSession::CancelPauseL |
|
2007 // See upnpplaybacksession.h |
|
2008 // -------------------------------------------------------------------------- |
|
2009 void CUPnPPlaybackSession::CancelPauseL() |
|
2010 { |
|
2011 __LOG( "CUPnPPlaybackSession::CancelPauseL" ); |
|
2012 |
|
2013 if( iCommandMessage ) |
|
2014 { |
|
2015 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
2016 iIPSessionIdCommand = KErrNotFound; |
|
2017 iCommandMessage->Complete( KErrCancel ); |
|
2018 delete iCommandMessage; iCommandMessage = NULL; |
|
2019 } |
|
2020 } |
|
2021 |
|
2022 // -------------------------------------------------------------------------- |
|
2023 // CUPnPPlaybackSession::SetVolumeL |
|
2024 // See upnpplaybacksession.h |
|
2025 // -------------------------------------------------------------------------- |
|
2026 void CUPnPPlaybackSession::SetVolumeL( const RMessage2& aMessage ) |
|
2027 { |
|
2028 __LOG( "CUPnPPlaybackSession::SetVolumeL" ); |
|
2029 |
|
2030 __ASSERTD( !iSettingMessage, __FILE__, __LINE__ ); |
|
2031 |
|
2032 ResetL(); |
|
2033 |
|
2034 TInt volume = aMessage.Int1(); |
|
2035 |
|
2036 TInt maxVolume = iDevice->MaxVolume(); |
|
2037 |
|
2038 // If max volume not KMaxVolume |
|
2039 if( maxVolume != KMaxVolume ) |
|
2040 { |
|
2041 // Convert volume to match device's max volume |
|
2042 TReal tempVolumeLevel = volume; |
|
2043 TReal tempMaxVolume = maxVolume; |
|
2044 |
|
2045 volume = tempMaxVolume * tempVolumeLevel / KMaxVolume; |
|
2046 } |
|
2047 |
|
2048 |
|
2049 |
|
2050 iIPSessionIdSetting = iServer.ControlPoint().RcSetVolumetActionL( |
|
2051 iDevice->Uuid(), iInstanceId, KMasterVolume, volume ); |
|
2052 |
|
2053 if( iIPSessionIdSetting > 0 ) |
|
2054 { |
|
2055 __LOG( "CUPnPPlaybackSession::SetVolumeL - registering" ); |
|
2056 // Register |
|
2057 iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this ); |
|
2058 } |
|
2059 else |
|
2060 { |
|
2061 User::Leave( iIPSessionIdSetting ); |
|
2062 } |
|
2063 |
|
2064 iSettingMessage = new (ELeave) RMessage2( aMessage ); |
|
2065 } |
|
2066 |
|
2067 // -------------------------------------------------------------------------- |
|
2068 // CUPnPPlaybackSession::CancelSetVolumeL |
|
2069 // See upnpplaybacksession.h |
|
2070 // -------------------------------------------------------------------------- |
|
2071 void CUPnPPlaybackSession::CancelSetVolumeL() |
|
2072 { |
|
2073 __LOG( "CUPnPPlaybackSession::CancelSetVolumeL" ); |
|
2074 |
|
2075 if( iSettingMessage ) |
|
2076 { |
|
2077 iServer.Dispatcher().UnRegister( iIPSessionIdSetting ); |
|
2078 iIPSessionIdSetting = KErrNotFound; |
|
2079 iSettingMessage->Complete( KErrCancel ); |
|
2080 delete iSettingMessage; iSettingMessage = NULL; |
|
2081 } |
|
2082 } |
|
2083 |
|
2084 // -------------------------------------------------------------------------- |
|
2085 // CUPnPPlaybackSession::GetVolumeL |
|
2086 // See upnpplaybacksession.h |
|
2087 // -------------------------------------------------------------------------- |
|
2088 void CUPnPPlaybackSession::GetVolumeL( const RMessage2& aMessage ) |
|
2089 { |
|
2090 __LOG( "CUPnPPlaybackSession::GetVolumeL" ); |
|
2091 |
|
2092 __ASSERTD( !iSettingMessage, __FILE__, __LINE__ ); |
|
2093 |
|
2094 ResetL(); |
|
2095 |
|
2096 iIPSessionIdSetting = iServer.ControlPoint().RcGetVolumetActionL( |
|
2097 iDevice->Uuid(), iInstanceId, KMasterVolume ); |
|
2098 |
|
2099 if( iIPSessionIdSetting > 0 ) |
|
2100 { |
|
2101 // Register |
|
2102 iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this ); |
|
2103 } |
|
2104 else |
|
2105 { |
|
2106 User::Leave( iIPSessionIdSetting ); |
|
2107 } |
|
2108 iSettingMessage = new (ELeave) RMessage2( aMessage ); |
|
2109 } |
|
2110 |
|
2111 // -------------------------------------------------------------------------- |
|
2112 // CUPnPPlaybackSession::CancelGetVolumeL |
|
2113 // See upnpplaybacksession.h |
|
2114 // -------------------------------------------------------------------------- |
|
2115 void CUPnPPlaybackSession::CancelGetVolumeL() |
|
2116 { |
|
2117 __LOG( "CUPnPPlaybackSession::CancelGetVolumeL" ); |
|
2118 |
|
2119 if( iSettingMessage ) |
|
2120 { |
|
2121 iServer.Dispatcher().UnRegister( iIPSessionIdSetting ); |
|
2122 iIPSessionIdSetting = KErrNotFound; |
|
2123 iSettingMessage->Complete( KErrCancel ); |
|
2124 delete iSettingMessage; iSettingMessage = NULL; |
|
2125 } |
|
2126 } |
|
2127 |
|
2128 // -------------------------------------------------------------------------- |
|
2129 // CUPnPPlaybackSession::SetMuteL |
|
2130 // See upnpplaybacksession.h |
|
2131 // -------------------------------------------------------------------------- |
|
2132 void CUPnPPlaybackSession::SetMuteL( const RMessage2& aMessage ) |
|
2133 { |
|
2134 __LOG( "CUPnPPlaybackSession::SetMuteL" ); |
|
2135 |
|
2136 __ASSERTD( !iSettingMessage, __FILE__, __LINE__ ); |
|
2137 |
|
2138 ResetL(); |
|
2139 |
|
2140 TInt mute = aMessage.Int1(); |
|
2141 if( mute ) |
|
2142 { |
|
2143 iIPSessionIdSetting = iServer.ControlPoint().RcSetMuteActionL( |
|
2144 iDevice->Uuid(), iInstanceId, KMasterVolume, KMuteOn ); |
|
2145 } |
|
2146 else |
|
2147 { |
|
2148 iIPSessionIdSetting = iServer.ControlPoint().RcSetMuteActionL( |
|
2149 iDevice->Uuid(), iInstanceId, KMasterVolume, KMuteOff ); |
|
2150 } |
|
2151 |
|
2152 if( iIPSessionIdSetting > 0 ) |
|
2153 { |
|
2154 // Register |
|
2155 iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this ); |
|
2156 } |
|
2157 else |
|
2158 { |
|
2159 User::Leave( iIPSessionIdSetting ); |
|
2160 } |
|
2161 |
|
2162 iSettingMessage = new (ELeave) RMessage2( aMessage ); |
|
2163 } |
|
2164 |
|
2165 // -------------------------------------------------------------------------- |
|
2166 // CUPnPPlaybackSession::CancelSetMuteL |
|
2167 // See upnpplaybacksession.h |
|
2168 // -------------------------------------------------------------------------- |
|
2169 void CUPnPPlaybackSession::CancelSetMuteL() |
|
2170 { |
|
2171 __LOG( "CUPnPPlaybackSession::CancelSetMuteL" ); |
|
2172 |
|
2173 if( iSettingMessage ) |
|
2174 { |
|
2175 iServer.Dispatcher().UnRegister( iIPSessionIdSetting ); |
|
2176 iIPSessionIdSetting = KErrNotFound; |
|
2177 iSettingMessage->Complete( KErrCancel ); |
|
2178 delete iSettingMessage; iSettingMessage = NULL; |
|
2179 } |
|
2180 } |
|
2181 |
|
2182 // -------------------------------------------------------------------------- |
|
2183 // CUPnPPlaybackSession::GetMuteL |
|
2184 // See upnpplaybacksession.h |
|
2185 // -------------------------------------------------------------------------- |
|
2186 void CUPnPPlaybackSession::GetMuteL( const RMessage2& aMessage ) |
|
2187 { |
|
2188 __LOG( "CUPnPPlaybackSession::GetMuteL" ); |
|
2189 |
|
2190 __ASSERTD( !iSettingMessage, __FILE__, __LINE__ ); |
|
2191 |
|
2192 ResetL(); |
|
2193 |
|
2194 iIPSessionIdSetting = iServer.ControlPoint().RcGetMuteActionL( |
|
2195 iDevice->Uuid(), iInstanceId, KMasterVolume ); |
|
2196 |
|
2197 if( iIPSessionIdSetting > 0 ) |
|
2198 { |
|
2199 // Register |
|
2200 iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this ); |
|
2201 } |
|
2202 else |
|
2203 { |
|
2204 User::Leave( iIPSessionIdSetting ); |
|
2205 } |
|
2206 iSettingMessage = new (ELeave) RMessage2( aMessage ); |
|
2207 |
|
2208 } |
|
2209 |
|
2210 // -------------------------------------------------------------------------- |
|
2211 // CUPnPPlaybackSession::CancelGetMuteL |
|
2212 // See upnpplaybacksession.h |
|
2213 // -------------------------------------------------------------------------- |
|
2214 void CUPnPPlaybackSession::CancelGetMuteL() |
|
2215 { |
|
2216 __LOG( "CUPnPPlaybackSession::CancelGetMuteL" ); |
|
2217 |
|
2218 if( iSettingMessage ) |
|
2219 { |
|
2220 iServer.Dispatcher().UnRegister( iIPSessionIdSetting ); |
|
2221 iIPSessionIdSetting = KErrNotFound; |
|
2222 iSettingMessage->Complete( KErrCancel ); |
|
2223 delete iSettingMessage; iSettingMessage = NULL; |
|
2224 } |
|
2225 } |
|
2226 |
|
2227 // -------------------------------------------------------------------------- |
|
2228 // CUPnPPlaybackSession::GetPositionInfoL |
|
2229 // See upnpplaybacksession.h |
|
2230 // -------------------------------------------------------------------------- |
|
2231 void CUPnPPlaybackSession::GetPositionInfoL( const RMessage2& aMessage ) |
|
2232 { |
|
2233 __LOG( "CUPnPPlaybackSession::GetPositionInfoL" ); |
|
2234 |
|
2235 __ASSERTD( !iSettingMessage, __FILE__, __LINE__ ); |
|
2236 |
|
2237 ResetL(); |
|
2238 |
|
2239 iIPSessionIdSetting = iServer.ControlPoint().AvtPositionInfoActionL( |
|
2240 iDevice->Uuid(), iInstanceId ); |
|
2241 |
|
2242 if( iIPSessionIdSetting > 0 ) |
|
2243 { |
|
2244 // Register |
|
2245 iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this ); |
|
2246 } |
|
2247 else |
|
2248 { |
|
2249 User::Leave( iIPSessionIdSetting ); |
|
2250 } |
|
2251 iSettingMessage = new (ELeave) RMessage2( aMessage ); |
|
2252 |
|
2253 } |
|
2254 |
|
2255 // -------------------------------------------------------------------------- |
|
2256 // CUPnPPlaybackSession::CancelGetPositionInfoL |
|
2257 // See upnpplaybacksession.h |
|
2258 // -------------------------------------------------------------------------- |
|
2259 void CUPnPPlaybackSession::CancelGetPositionInfoL() |
|
2260 { |
|
2261 __LOG( "CUPnPPlaybackSession::CancelGetPositionInfoL" ); |
|
2262 |
|
2263 if( iSettingMessage ) |
|
2264 { |
|
2265 iServer.Dispatcher().UnRegister( iIPSessionIdSetting ); |
|
2266 iIPSessionIdSetting = KErrNotFound; |
|
2267 iSettingMessage->Complete( KErrCancel ); |
|
2268 delete iSettingMessage; iSettingMessage = NULL; |
|
2269 } |
|
2270 } |
|
2271 |
|
2272 // -------------------------------------------------------------------------- |
|
2273 // CUPnPPlaybackSession::DeviceDisappearedRequestL |
|
2274 // See upnpplaybacksession.h |
|
2275 // -------------------------------------------------------------------------- |
|
2276 void CUPnPPlaybackSession::DeviceDisappearedRequestL( |
|
2277 const RMessage2& aMessage ) |
|
2278 { |
|
2279 __LOG( "CUPnPPlaybackSession::DeviceDisappearedRequestL" ); |
|
2280 |
|
2281 __ASSERTD( !iDeviceMessage, __FILE__, __LINE__ ); |
|
2282 |
|
2283 iDeviceMessage = new (ELeave ) RMessage2( aMessage ); |
|
2284 } |
|
2285 |
|
2286 // -------------------------------------------------------------------------- |
|
2287 // CUPnPPlaybackSession::CancelDeviceDisappearedRequestL |
|
2288 // See upnpplaybacksession.h |
|
2289 // -------------------------------------------------------------------------- |
|
2290 void CUPnPPlaybackSession::CancelDeviceDisappearedRequestL() |
|
2291 { |
|
2292 __LOG( "CUPnPPlaybackSession::CancelDeviceDisappearedRequestL" ); |
|
2293 |
|
2294 if( iDeviceMessage ) |
|
2295 { |
|
2296 iDeviceMessage->Complete( KErrCancel ); |
|
2297 delete iDeviceMessage; iDeviceMessage = NULL; |
|
2298 } |
|
2299 } |
|
2300 |
|
2301 // -------------------------------------------------------------------------- |
|
2302 // CUPnPPlaybackSession::ParseBrowseResponseL |
|
2303 // See upnpplaybacksession.h |
|
2304 // -------------------------------------------------------------------------- |
|
2305 HBufC8* CUPnPPlaybackSession::ParseBrowseResponseL( const TDesC8& aResponse ) |
|
2306 { |
|
2307 __LOG( "CUPnPPlaybackSession::ParseBrowseResponseL" ); |
|
2308 |
|
2309 HBufC8* resource = NULL; |
|
2310 |
|
2311 CUPnPXMLParser* parser = CUPnPXMLParser::NewL(); |
|
2312 CleanupStack::PushL( parser ); |
|
2313 |
|
2314 RPointerArray<CUpnpObject> array; |
|
2315 CleanupResetAndDestroyPushL( array ); |
|
2316 |
|
2317 parser->ParseResultDataL( array, aResponse ); |
|
2318 |
|
2319 if( array.Count() == KExpectedCount ) |
|
2320 { |
|
2321 if( array[ 0 ]->ObjectType() == EUPnPItem ) |
|
2322 { |
|
2323 CUpnpItem* item = static_cast<CUpnpItem*>( array[ 0 ] ); |
|
2324 resource = UPnPItemUtility::ResourceFromItemL( |
|
2325 *item ).Value().AllocL(); |
|
2326 CleanupStack::PushL( resource ); |
|
2327 |
|
2328 const CUpnpElement& res = |
|
2329 UPnPItemUtility::ResourceFromItemL( *item ); |
|
2330 const CUpnpAttribute* protocolInfo = |
|
2331 UPnPItemUtility::FindAttributeByName( |
|
2332 res, KAttributeProtocolInfo ); |
|
2333 |
|
2334 if( !iDevice->MatchSinkProtocolInfo( protocolInfo->Value() ) ) |
|
2335 { |
|
2336 TPtrC8 uri; |
|
2337 // Did not match, try to find a match |
|
2338 TRAPD( err, uri.Set( iDevice->FindFirstMatchingInSinkL( |
|
2339 *item ) ) ); |
|
2340 if( err == KErrNone ) |
|
2341 { |
2313 { |
2342 // Suitable res-element found! |
2314 // remove dlna stuff from protocolinfo |
2343 CleanupStack::PopAndDestroy( resource ); |
2315 TPtrC8 protValue( array[ i ]->Value() ); |
2344 resource = uri.AllocL(); |
2316 TInt index = protValue.Find( KDlnaOrg() ); |
2345 } |
2317 __LOG1( "CUPnPPlaybackSession::RemoveDlnaFlagsFromRes\ |
2346 else if( err == KErrNotSupported ) |
2318 ElementL dlnaflags found protinfo index = %d",index ); |
2347 { |
2319 if( index > 0 ) |
2348 // No suitable res-element |
|
2349 if( iDevice->DLNADeviceType() == |
|
2350 CUpnpAVDeviceExtended::EDMR ) |
|
2351 { |
2320 { |
2352 // DLNA content, DLNA device, no match -> leave |
2321 _LIT8( KWildCard, ":*" ); |
2353 User::Leave( KErrNotSupported ); |
2322 CUpnpAttribute* attribute = CUpnpAttribute::NewLC( |
|
2323 array[ i ]->Name() ); |
|
2324 HBufC8* tmp = HBufC8::NewLC( |
|
2325 protValue.Mid(0, index-1).Length() + |
|
2326 KWildCard().Length() ); |
|
2327 |
|
2328 tmp->Des().Copy( protValue.Mid(0, index-1) ); |
|
2329 tmp->Des().Append( KWildCard() ); |
|
2330 |
|
2331 attribute->SetValueL( *tmp ); |
|
2332 CleanupStack::PopAndDestroy( tmp ); |
|
2333 elem->AddAttributeL(attribute); |
|
2334 CleanupStack::Pop( attribute ); |
2354 } |
2335 } |
2355 else |
2336 else |
2356 { |
2337 { |
2357 // Not a dlna device, try to set the uri of |
2338 // if item was allready down graded to upnpitem |
2358 // original res-element anyways |
2339 // clean and break from here |
2359 CleanupStack::Pop( resource ); |
2340 CleanupStack::PopAndDestroy( elem ); |
2360 } |
2341 elem = NULL; |
|
2342 break; |
|
2343 } |
2361 } |
2344 } |
2362 else |
2345 else |
2363 { |
2346 { |
2364 // Some error occured |
2347 CUpnpAttribute* attribute = CUpnpAttribute::NewLC( |
2365 User::Leave( err ); |
2348 array[ i ]->Name() ); |
2366 } |
2349 attribute->SetValueL( array[ i ]->Value() ); |
|
2350 elem->AddAttributeL(attribute); |
|
2351 CleanupStack::Pop( attribute ); |
|
2352 } |
|
2353 } |
|
2354 if( elem ) |
|
2355 { |
|
2356 elem->SetValueL( elements[resIndex]->Value() ); |
|
2357 CleanupStack::Pop( elem ); |
|
2358 |
|
2359 if( elements.Insert( elem, resIndex ) ) |
|
2360 { |
|
2361 delete elem; |
|
2362 continue; |
|
2363 } |
|
2364 |
|
2365 delete elements[++resIndex]; |
|
2366 elements.Remove(resIndex); |
|
2367 |
|
2368 __LOG( "CUPnPPlaybackSession::RemoveDlnaFlagsFromResElementL\ |
|
2369 res found and replaced protocol info without dlna stuff" ); |
2367 } |
2370 } |
2368 } |
2371 } |
|
2372 } |
|
2373 __LOG( "CUPnPPlaybackSession::RemoveDlnaFlagsFromResElementL end" ); |
|
2374 } |
|
2375 |
|
2376 // -------------------------------------------------------------------------- |
|
2377 // CUPnPPlaybackSession::RemoveDlnaProfileFromResElementsL |
|
2378 // -------------------------------------------------------------------------- |
|
2379 void CUPnPPlaybackSession::RemoveDlnaProfileFromResElementsL() |
|
2380 { |
|
2381 __LOG( "CUPnPPlaybackSession::RemoveDlnaProfileFromResElementsL" ); |
|
2382 RUPnPElementsArray& elements = const_cast<RUPnPElementsArray&>( |
|
2383 iCurrentItem->GetElements()); |
|
2384 |
|
2385 for( TInt resIndex(0); resIndex < elements.Count(); ++resIndex ) |
|
2386 { |
|
2387 if( elements[resIndex]->Name() == KElementRes() ) |
|
2388 { |
|
2389 const RUPnPAttributesArray& array = |
|
2390 elements[resIndex]->GetAttributes(); |
|
2391 CUpnpElement* elem = CUpnpElement::NewLC( KElementRes() ); |
|
2392 for( TInt i = 0; i < array.Count(); i++ ) |
|
2393 { |
|
2394 _LIT8( KProtocolInfo, "protocolInfo" ); |
|
2395 _LIT8( KDlnaOrgPn, "DLNA.ORG_PN=" ); |
|
2396 _LIT8( KDlnaOrgPnEnd, ";" ); |
|
2397 |
|
2398 if( array[ i ]->Name() == KProtocolInfo() ) |
|
2399 { |
|
2400 // remove dlna profile from protocolinfo |
|
2401 TPtrC8 protValue( array[ i ]->Value() ); |
|
2402 TInt length = 0; |
|
2403 TInt index = 0; |
|
2404 |
|
2405 __LOG8_1("CUPnPPlaybackSession::RemoveDlnaProfileFromRes protocol info = %S", &protValue); |
|
2406 |
|
2407 index = protValue.Find( KDlnaOrgPn() ); |
|
2408 if (index != KErrNotFound) |
|
2409 { |
|
2410 length = protValue.Mid(index).Find( KDlnaOrgPnEnd() ); |
|
2411 } |
|
2412 __LOG1( "CUPnPPlaybackSession::RemoveDlnaProfileFromRes ElementsL DLNA profile found protinfo index = %d", index ); |
|
2413 if( index > 0 && length > 0 ) |
|
2414 { |
|
2415 ++length; |
|
2416 |
|
2417 CUpnpAttribute* attribute = CUpnpAttribute::NewLC( |
|
2418 array[ i ]->Name() ); |
|
2419 HBufC8* tmp = HBufC8::NewLC( |
|
2420 protValue.Length() - |
|
2421 protValue.Mid( index, length ).Length() ); |
|
2422 |
|
2423 tmp->Des().Copy( protValue.Mid ( 0, index ) ); |
|
2424 tmp->Des().Append( protValue.Mid( index + length ) ); |
|
2425 |
|
2426 attribute->SetValueL( *tmp ); |
|
2427 |
|
2428 CleanupStack::PopAndDestroy( tmp ); |
|
2429 elem->AddAttributeL(attribute); |
|
2430 CleanupStack::Pop( attribute ); |
|
2431 } |
|
2432 else |
|
2433 { |
|
2434 // just clean if profile not found |
|
2435 CleanupStack::PopAndDestroy( elem ); |
|
2436 elem = NULL; |
|
2437 break; |
|
2438 } |
|
2439 } |
|
2440 else |
|
2441 { |
|
2442 CUpnpAttribute* attribute = CUpnpAttribute::NewLC( |
|
2443 array[ i ]->Name() ); |
|
2444 attribute->SetValueL( array[ i ]->Value() ); |
|
2445 elem->AddAttributeL(attribute); |
|
2446 CleanupStack::Pop( attribute ); |
|
2447 } |
|
2448 } |
|
2449 if( elem ) |
|
2450 { |
|
2451 elem->SetValueL( elements[resIndex]->Value() ); |
|
2452 CleanupStack::Pop( elem ); |
|
2453 |
|
2454 if( elements.Insert( elem, resIndex ) ) |
|
2455 { |
|
2456 delete elem; |
|
2457 continue; |
|
2458 } |
|
2459 |
|
2460 delete elements[++resIndex]; |
|
2461 elements.Remove(resIndex); |
|
2462 |
|
2463 __LOG( "CUPnPPlaybackSession::RemoveDlnaProfileFromResElementsL\ |
|
2464 res found and replaced protocol info without dlna profile" ); |
|
2465 } |
|
2466 } |
|
2467 } |
|
2468 __LOG( "CUPnPPlaybackSession::RemoveDlnaProfileFromResElementsL end" ); |
|
2469 } |
|
2470 |
|
2471 // -------------------------------------------------------------------------- |
|
2472 // CUPnPPlaybackSession::SendGetMediaInfoActionL |
|
2473 // See upnpplaybacksession.h |
|
2474 // -------------------------------------------------------------------------- |
|
2475 void CUPnPPlaybackSession::SendGetMediaInfoActionL() |
|
2476 { |
|
2477 __LOG( "CUPnPPlaybackSession::SendGetMediaInfoActionL" ); |
|
2478 |
|
2479 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
|
2480 CpDeviceL(), KAVTransport, KGetMediaInfo ); |
|
2481 |
|
2482 TBuf8<KMaxIntLength> buf; |
|
2483 buf.Num( iAVTInstanceId ); |
|
2484 action->SetArgumentL( KInstanceID, buf ); |
|
2485 |
|
2486 iServer.ControlPoint().SendL( action ); |
|
2487 CleanupStack::Pop( action ); |
|
2488 if (action->SessionId() < 0) User::Leave(action->SessionId()); |
|
2489 iIPSessionIdCommand = action->SessionId(); |
|
2490 |
|
2491 // Register |
|
2492 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
2493 |
|
2494 __LOG( "CUPnPPlaybackSession::SendGetMediaInfoActionL - end" ); |
|
2495 } |
|
2496 |
|
2497 // -------------------------------------------------------------------------- |
|
2498 // CUPnPPlaybackSession::SendGetTransportInfoActionL |
|
2499 // See upnpplaybacksession.h |
|
2500 // -------------------------------------------------------------------------- |
|
2501 void CUPnPPlaybackSession::SendGetTransportInfoActionL() |
|
2502 { |
|
2503 __LOG( "CUPnPPlaybackSession::SendGetTransportInfoActionL" ); |
|
2504 |
|
2505 CUpnpAction* action = iServer.ControlPoint().CreateActionLC( |
|
2506 CpDeviceL(), KAVTransport, KGetTransportInfo ); |
|
2507 |
|
2508 TBuf8<KMaxIntLength> buf; |
|
2509 buf.Num( iAVTInstanceId ); |
|
2510 action->SetArgumentL( KInstanceID, buf ); |
|
2511 |
|
2512 iServer.ControlPoint().SendL( action ); |
|
2513 CleanupStack::Pop( action ); |
|
2514 if (action->SessionId() < 0) User::Leave(action->SessionId()); |
|
2515 iIPSessionIdCommand = action->SessionId(); |
|
2516 |
|
2517 // Register |
|
2518 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
2519 |
|
2520 __LOG( "CUPnPPlaybackSession::SendGetTransportInfoActionL - end" ); |
|
2521 } |
|
2522 |
|
2523 // -------------------------------------------------------------------------- |
|
2524 // CUPnPPlaybackSession::PlayingEventReceived |
|
2525 // See upnpplaybacksession.h |
|
2526 // -------------------------------------------------------------------------- |
|
2527 void CUPnPPlaybackSession::PlayingEventReceived() |
|
2528 { |
|
2529 __LOG( "CUPnPPlaybackSession::PlayingEventReceived" ); |
|
2530 |
|
2531 if( iExpectedEvent == EEventPlaying ) |
|
2532 { |
|
2533 // We were expecting a state change from stopped to playing since we |
|
2534 // sent the play action. |
|
2535 __LOG( "CUPnPPlaybackSession::PlayingEventReceived - \ |
|
2536 Response to play" ); |
|
2537 __ASSERT( iCommandMessage, __FILE__, __LINE__ ); |
|
2538 iTimer->Cancel(); |
|
2539 // Unregister from the dispatcher. This way we do not get |
|
2540 // ::AvtPlayResponse callback (it would be ignored, anyway) |
|
2541 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
2542 iIPSessionIdCommand = KErrNotFound; |
|
2543 iCommandMessage->Complete( EAVControllerPlayCompleted ); |
|
2544 delete iCommandMessage; iCommandMessage = NULL; |
|
2545 iExpectedEvent = EEventNone; |
|
2546 } |
|
2547 else if( iPlaybackState == EPaused ) |
|
2548 { |
|
2549 // Unsolicited play event from the renderer. This means that device |
|
2550 // is playing. Propagate the event. |
|
2551 __LOG( "CUPnPPlaybackSession::PlayingEventReceived - \ |
|
2552 Unsolicited play" ); |
|
2553 TUnsolicitedEventC event; |
|
2554 event.iEvent = EPlay; event.iValue = KErrNone; |
|
2555 PropagateEvent( event ); |
|
2556 } |
|
2557 else if( iInitialEventMsg ) |
|
2558 { |
|
2559 __LOG( "CUPnPPlaybackSession::PlayingEventReceived - \ |
|
2560 initial event" ); |
|
2561 iTimer->Cancel(); |
|
2562 TUnsolicitedEventE event( EPlay ); |
|
2563 TPckg<TUnsolicitedEventE> resp1( event ); |
|
2564 TInt err = iInitialEventMsg->Write( 1, resp1 ); |
|
2565 iInitialEventMsg->Complete( err ); |
|
2566 delete iInitialEventMsg; iInitialEventMsg = NULL; |
|
2567 iInitialEventReceived = ETrue; |
|
2568 } |
|
2569 else if( iPlaybackState == EPlaying || iPlaybackState == EStopped) |
|
2570 { |
|
2571 // Unsolicited play event when we already were in playing state |
|
2572 // or already swithced to stopped state due to previous unsolicited play |
|
2573 // - most probably someone else has issued play command, check current URI |
|
2574 __LOG( "CUPnPPlaybackSession::PlayingEventReceived - \ |
|
2575 Unsolicited play event, check if renderer is hijacked" ); |
|
2576 |
|
2577 TRAPD( aErr, SendGetMediaInfoActionL() ) |
|
2578 if( aErr != KErrNone ) |
|
2579 { |
|
2580 __LOG1( "CUPnPPlaybackSession::CmPrepareResponse - \ |
|
2581 SendGetMediaInfoActionL failed with code %d", aErr ); |
|
2582 } |
2369 else |
2583 else |
2370 { |
2584 { |
2371 User::Leave( KErrGeneral ); |
2585 iCheckForHijackedRenderer = ETrue; |
2372 } |
2586 } |
|
2587 } |
|
2588 |
|
2589 iPlaybackState = EPlaying; |
|
2590 } |
|
2591 |
|
2592 // -------------------------------------------------------------------------- |
|
2593 // CUPnPPlaybackSession::StoppedEventReceived |
|
2594 // See upnpplaybacksession.h |
|
2595 // -------------------------------------------------------------------------- |
|
2596 void CUPnPPlaybackSession::StoppedEventReceived() |
|
2597 { |
|
2598 __LOG( "CUPnPPlaybackSession::StoppedEventReceived" ); |
|
2599 |
|
2600 if( iExpectedEvent == EEventStopped ) |
|
2601 { |
|
2602 // We were expecting a state change from playing/paused to stopped |
|
2603 // since we sent the stop action. |
|
2604 RespondToStopRequest(); |
|
2605 } |
|
2606 else if( iPlaybackState == EPlaying || |
|
2607 iPlaybackState == EPaused ) |
|
2608 { |
|
2609 // Unsolicted stop event from the renderer. This means that playback |
|
2610 // stopped. Propagate the event. |
|
2611 __LOG( "CUPnPPlaybackSession::StoppedEventReceived - \ |
|
2612 Unsolicted stop" ); |
|
2613 TUnsolicitedEventC event; |
|
2614 event.iEvent = EStop; event.iValue = KErrNone; |
|
2615 PropagateEvent( event ); |
|
2616 } |
|
2617 else if( iInitialEventMsg ) |
|
2618 { |
|
2619 __LOG( "CUPnPPlaybackSession::StoppedEventReceived - \ |
|
2620 initial event" ); |
|
2621 iTimer->Cancel(); |
|
2622 TUnsolicitedEventE event( EStop ); |
|
2623 TPckg<TUnsolicitedEventE> resp1( event ); |
|
2624 TInt err = iInitialEventMsg->Write( 1, resp1 ); |
|
2625 iInitialEventMsg->Complete( err ); |
|
2626 delete iInitialEventMsg; iInitialEventMsg = NULL; |
|
2627 } |
|
2628 iPlaybackState = EStopped; |
|
2629 } |
|
2630 |
|
2631 // -------------------------------------------------------------------------- |
|
2632 // CUPnPPlaybackSession::PausedEventReceived |
|
2633 // See upnpplaybacksession.h |
|
2634 // -------------------------------------------------------------------------- |
|
2635 void CUPnPPlaybackSession::PausedEventReceived() |
|
2636 { |
|
2637 __LOG( "CUPnPPlaybackSession::PausedEventReceived - \ |
|
2638 PauseUser received" ); |
|
2639 |
|
2640 if( iExpectedEvent == EEventPaused ) |
|
2641 { |
|
2642 // We were expecting a state change from playing to paused |
|
2643 // since we sent the pause action. |
|
2644 __LOG( "CUPnPPlaybackSession::PausedEventReceived - \ |
|
2645 Response to pause" ); |
|
2646 __ASSERT( iCommandMessage, __FILE__, __LINE__ ); |
|
2647 iTimer->Cancel(); |
|
2648 // Unregister from the dispatcher. This way we do not get |
|
2649 // ::AvtPauseResponse callback (it would be ignored, anyway) |
|
2650 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
2651 iIPSessionIdCommand = KErrNotFound; |
|
2652 iCommandMessage->Complete( EAVControllerPauseCompleted ); |
|
2653 delete iCommandMessage; iCommandMessage = NULL; |
|
2654 iExpectedEvent = EEventNone; |
|
2655 } |
|
2656 else if( iPlaybackState == EPlaying ) |
|
2657 { |
|
2658 // Unsolicted pause event from the renderer. This means that playback |
|
2659 // paused. Propagate the event. |
|
2660 __LOG( "CUPnPPlaybackSession::PausedEventReceived - \ |
|
2661 Unsolicted pause" ); |
|
2662 TUnsolicitedEventC event; |
|
2663 event.iEvent = EPause; event.iValue = KErrNone; |
|
2664 PropagateEvent( event ); |
|
2665 } |
|
2666 else if( iInitialEventMsg ) |
|
2667 { |
|
2668 __LOG( "CUPnPPlaybackSession::PausedEventReceived - \ |
|
2669 initial event" ); |
|
2670 iTimer->Cancel(); |
|
2671 TUnsolicitedEventE event( EPause ); |
|
2672 TPckg<TUnsolicitedEventE> resp1( event ); |
|
2673 TInt err = iInitialEventMsg->Write( 1, resp1 ); |
|
2674 iInitialEventMsg->Complete( err ); |
|
2675 delete iInitialEventMsg; iInitialEventMsg = NULL; |
|
2676 iInitialEventReceived = ETrue; |
|
2677 } |
|
2678 iPlaybackState = EPaused; |
|
2679 } |
|
2680 void CUPnPPlaybackSession::NoMediaEventReceived() |
|
2681 { |
|
2682 __LOG( "CUPnPPlaybackSession::NoMediaEventReceived" ); |
|
2683 |
|
2684 if( iInitialEventMsg ) |
|
2685 { |
|
2686 __LOG( "CUPnPPlaybackSession::NoMediaEventReceived - \ |
|
2687 initial event" ); |
|
2688 iTimer->Cancel(); |
|
2689 TUnsolicitedEventE event( EStop ); |
|
2690 TPckg<TUnsolicitedEventE> resp1( event ); |
|
2691 TInt err = iInitialEventMsg->Write( 1, resp1 ); |
|
2692 iInitialEventMsg->Complete( err ); |
|
2693 delete iInitialEventMsg; iInitialEventMsg = NULL; |
|
2694 } |
|
2695 else if( iExpectedEvent == EEventStopped ) |
|
2696 { |
|
2697 // After reconnecting to renderer, a stop command may |
|
2698 // result to no media present event. |
|
2699 RespondToStopRequest(); |
|
2700 } |
|
2701 |
|
2702 if( iPlaybackState == EStopped || iPlaybackState == EUninitialized ) |
|
2703 { |
|
2704 iPlaybackState = ENoMedia; |
2373 } |
2705 } |
2374 else |
2706 else |
2375 { |
2707 { |
2376 User::Leave( KErrGeneral ); |
2708 __LOG( "CUPnPPlaybackSession::NoMediaEventReceived - \ |
|
2709 illegal NO_MEDIA_PRESENT -> ignore" ); |
|
2710 } |
|
2711 } |
|
2712 |
|
2713 // -------------------------------------------------------------------------- |
|
2714 // CUPnPPlaybackSession::CurrentTrackUriEventReceived |
|
2715 // See upnpplaybacksession.h |
|
2716 // -------------------------------------------------------------------------- |
|
2717 void CUPnPPlaybackSession::AVTransportUriEventReceived( const TDesC8& aUri, |
|
2718 CUPnPAVTEvent::TTransportState aTransportState ) |
|
2719 { |
|
2720 __LOG8_1( "CUPnPPlaybackSession::AVTransportUriEventReceived, uri: %S", |
|
2721 &aUri ); |
|
2722 |
|
2723 if( iExpectedEvent == EEventAVTransportUri ) |
|
2724 { |
|
2725 // We were expecting to get AVTransportUri from the renderer |
|
2726 // since we sent the SetAVTransportUri - action |
|
2727 __LOG( "CUPnPPlaybackSession::AVTransportUriEventReceived - \ |
|
2728 complete seturi" ); |
|
2729 |
|
2730 __ASSERT( iCommandMessage, __FILE__, __LINE__ ); |
|
2731 // Unregister from the dispatcher. This way we do not get |
|
2732 // ::AvtSetUriResponse callback (it would be ignored, anyway) |
|
2733 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
|
2734 iIPSessionIdCommand = KErrNotFound; |
|
2735 iTimer->Cancel(); |
|
2736 iCommandMessage->Complete( EAVControllerSetURICompleted ); |
|
2737 delete iCommandMessage; iCommandMessage = NULL; |
|
2738 iExpectedEvent = EEventNone; |
|
2739 iPlaybackState = EStopped; |
|
2740 } |
|
2741 else if( iCurrentUri && ( *iCurrentUri != aUri ) ) |
|
2742 { |
|
2743 __LOG( "CUPnPPlaybackSession::AVTransportUriEventReceived - \ |
|
2744 different AVTransportUri - propagate a stop event" ); |
|
2745 |
|
2746 // Uri changes. Some malicous Control Point captured our device |
|
2747 // or something else is wrong. Propagate a stop event with error |
|
2748 // code KErrNotReady |
|
2749 iPlaybackState = EHalted; |
|
2750 TUnsolicitedEventC event; |
|
2751 event.iEvent = EStop; |
|
2752 event.iValue = KErrNotReady; |
|
2753 PropagateEvent( event ); |
|
2754 } |
|
2755 else if( iInitialEventMsg ) |
|
2756 { |
|
2757 __LOG( "CUPnPPlaybackSession::AVTransportUriEventReceived - \ |
|
2758 initial event" ); |
|
2759 iTimer->Cancel(); |
|
2760 TUnsolicitedEventE event( EStop ); |
|
2761 iPlaybackState = EStopped; |
|
2762 if( aTransportState == CUPnPAVTEvent::EPlaying ) |
|
2763 { |
|
2764 event = EPlay; |
|
2765 iPlaybackState = EPlaying; |
|
2766 } |
|
2767 else if( aTransportState == CUPnPAVTEvent::EPausedPlayback ) |
|
2768 { |
|
2769 event = EPause; |
|
2770 iPlaybackState = EPaused; |
|
2771 } |
|
2772 TPckg<TUnsolicitedEventE> resp1( event ); |
|
2773 TInt err = iInitialEventMsg->Write( 1, resp1 ); |
|
2774 iInitialEventMsg->Complete( err ); |
|
2775 delete iInitialEventMsg; iInitialEventMsg = NULL; |
2377 } |
2776 } |
2378 |
2777 } |
2379 CleanupStack::PopAndDestroy( &array ); |
2778 |
2380 CleanupStack::PopAndDestroy( parser ); |
2779 // -------------------------------------------------------------------------- |
2381 |
2780 // CUPnPPlaybackSession::PropagateEvent |
2382 __LOG( "CUPnPPlaybackSession::ParseBrowseResponseL - end" ); |
2781 // See upnpplaybacksession.h |
2383 |
2782 // -------------------------------------------------------------------------- |
2384 if( !resource ) |
2783 void CUPnPPlaybackSession::PropagateEvent( TUnsolicitedEventC event ) |
2385 { |
2784 { |
2386 User::Leave( KErrGeneral ); |
2785 __LOG( "CUPnPPlaybackSession::PropagateEvent" ); |
2387 } |
2786 |
2388 |
2787 if( iEventMessage ) |
2389 return resource; |
2788 { |
2390 } |
2789 TPckg<TUnsolicitedEventC> resp1( event ); |
2391 |
2790 TInt err = iEventMessage->Write( 1, resp1 ); |
2392 // -------------------------------------------------------------------------- |
2791 iEventMessage->Complete( err ); |
2393 // CUPnPPlaybackSession::Uuid |
2792 delete iEventMessage; iEventMessage = NULL; |
2394 // See upnpplaybacksession.h |
|
2395 // -------------------------------------------------------------------------- |
|
2396 const TDesC8& CUPnPPlaybackSession::Uuid() const |
|
2397 { |
|
2398 if( iDevice ) |
|
2399 { |
|
2400 return iDevice->Uuid(); |
|
2401 } |
2793 } |
2402 else |
2794 else |
2403 { |
2795 { |
2404 return KNullDesC8; |
2796 __LOG( "CUPnPPlaybackSession::PropagateEvent - add event to queu" ); |
2405 } |
2797 iEventQue.Append( event ); |
2406 } |
2798 } |
2407 |
2799 } |
2408 // -------------------------------------------------------------------------- |
2800 |
2409 // CUPnPPlaybackSession::EncodeXmlL |
2801 // -------------------------------------------------------------------------- |
2410 // See upnpplaybacksession.h |
2802 // CUPnPPlaybackSession::UPnPAVTimerCallback |
2411 // -------------------------------------------------------------------------- |
2803 // See upnpplaybacksession.h |
2412 HBufC8* CUPnPPlaybackSession::EncodeXmlL( const TDesC8& aResult ) |
2804 // -------------------------------------------------------------------------- |
2413 { |
2805 void CUPnPPlaybackSession::UPnPAVTimerCallback( |
2414 HBufC8* tmpBuf = aResult.AllocLC(); |
2806 CUPnPAVTimer::TAVTimerType /*aType*/ ) |
2415 HBufC8* result = UpnpString::EncodeXmlStringL( tmpBuf ); |
2807 { |
2416 CleanupStack::PopAndDestroy( tmpBuf ); |
2808 __LOG( "CUPnPPlaybackSession::UPnPAVTimerCallback" ); |
2417 return result; |
2809 |
2418 } |
2810 // Fail safe timer expired. Check what event we were expecting |
2419 |
2811 if( iExpectedEvent == EEventAVTransportUri ) |
2420 // -------------------------------------------------------------------------- |
2812 { |
2421 // CUPnPPlaybackSession::Reset |
2813 __LOG( "CUPnPPlaybackSession::UPnPAVTimerCallback - \ |
2422 // See upnpplaybacksession.h |
2814 CurrentTrackUri" ); |
2423 // -------------------------------------------------------------------------- |
2815 __ASSERT( iCommandMessage, __FILE__, __LINE__ ); |
2424 void CUPnPPlaybackSession::ResetL() |
2816 iCommandMessage->Complete( EAVControllerSetURICompleted ); |
2425 { |
2817 delete iCommandMessage; iCommandMessage = NULL; |
2426 __LOG( "CUPnPPlaybackSession::ResetL" ); |
2818 iExpectedEvent = EEventNone; |
2427 |
2819 iPlaybackState = EStopped; |
2428 if( !iServer.DeviceRepository().IsWlanActive() ) |
2820 } |
2429 { |
2821 else if( iExpectedEvent == EEventStopped ) |
2430 __LOG( "Reset - disconnected" ); |
2822 { |
2431 User::Leave( KErrDisconnected ); |
2823 __LOG( "CUPnPPlaybackSession::UPnPAVTimerCallback - Stop" ); |
2432 } |
2824 __ASSERT( iCommandMessage, __FILE__, __LINE__ ); |
2433 } |
2825 iCommandMessage->Complete( EAVControllerStopCompleted ); |
2434 |
2826 delete iCommandMessage; iCommandMessage = NULL; |
2435 // -------------------------------------------------------------------------- |
2827 iExpectedEvent = EEventNone; |
2436 // CUPnPPlaybackSession::ReadObjFromMessageL |
2828 iPlaybackState = EStopped; |
2437 // See upnpplaybacksession.h |
2829 } |
2438 // -------------------------------------------------------------------------- |
2830 else if( iExpectedEvent == EEventPlaying ) |
2439 void CUPnPPlaybackSession::ReadObjFromMessageL( const RMessage2& aMessage, |
2831 { |
2440 TInt aSlot, CUpnpObject* aObj ) |
2832 __LOG( "CUPnPPlaybackSession::UPnPAVTimerCallback - Play" ); |
2441 { |
2833 __ASSERT( iCommandMessage, __FILE__, __LINE__ ); |
2442 // create buffer |
2834 iCommandMessage->Complete( EAVControllerPlayCompleted ); |
2443 TInt len = aMessage.GetDesMaxLength( aSlot ); |
2835 delete iCommandMessage; iCommandMessage = NULL; |
2444 HBufC8* buf = HBufC8::NewLC( len ); |
2836 iExpectedEvent = EEventNone; |
2445 TPtr8 ptr( buf->Des() ); |
2837 iPlaybackState = EPlaying; |
2446 User::LeaveIfError( aMessage.Read( aSlot, ptr ) ); |
2838 } |
2447 |
2839 else if( iExpectedEvent == EEventPaused ) |
2448 // read stream |
2840 { |
2449 RDesReadStream stream( *buf ); |
2841 __LOG( "CUPnPPlaybackSession::UPnPAVTimerCallback - Pause" ); |
2450 CleanupClosePushL( stream ); |
2842 __ASSERT( iCommandMessage, __FILE__, __LINE__ ); |
2451 |
2843 iCommandMessage->Complete( EAVControllerPauseCompleted ); |
2452 // internalize object |
2844 delete iCommandMessage; iCommandMessage = NULL; |
2453 stream >> *aObj; |
2845 iExpectedEvent = EEventNone; |
2454 |
2846 iPlaybackState = EPaused; |
2455 // clean up |
2847 } |
2456 CleanupStack::PopAndDestroy( &stream ); |
2848 else if( iInitialEventMsg ) |
2457 CleanupStack::PopAndDestroy( buf ); |
2849 { |
2458 } |
2850 __LOG( "CUPnPPlaybackSession::UPnPAVTimerCallback - initial event" ); |
2459 |
2851 TUnsolicitedEventE event( EStop ); |
2460 // -------------------------------------------------------------------------- |
2852 TPckg<TUnsolicitedEventE> resp1( event ); |
2461 // CUPnPPlaybackSession::ReadReqFromMessageL |
2853 TInt err = iInitialEventMsg->Write( 1, resp1 ); |
2462 // See upnpplaybacksession.h |
2854 iInitialEventMsg->Complete( err ); |
2463 // -------------------------------------------------------------------------- |
2855 delete iInitialEventMsg; iInitialEventMsg = NULL; |
2464 void CUPnPPlaybackSession::ReadReqFromMessageL( const RMessage2& aMessage, |
2856 } |
2465 TInt aSlot, CUpnpAVRequest* aReq ) |
2857 else |
2466 { |
2858 { |
2467 // create buffer |
2859 __LOG( "CUPnPPlaybackSession::UPnPAVTimerCallback - Not Expected!" ); |
2468 TInt len = aMessage.GetDesMaxLength( aSlot ); |
2860 __PANIC( __FILE__, __LINE__ ); |
2469 HBufC8* buf = HBufC8::NewLC( len ); |
2861 } |
2470 TPtr8 ptr( buf->Des() ); |
2862 } |
2471 User::LeaveIfError( aMessage.Read( aSlot, ptr ) ); |
2863 |
2472 |
2864 // -------------------------------------------------------------------------- |
2473 // read stream |
2865 // CUPnPPlaybackSession::RespondToStopRequest |
2474 RDesReadStream stream( *buf ); |
2866 // See upnpplaybacksession.h |
2475 CleanupClosePushL( stream ); |
2867 // -------------------------------------------------------------------------- |
2476 |
2868 void CUPnPPlaybackSession::RespondToStopRequest() |
2477 // internalize object |
2869 { |
2478 stream >> *aReq; |
2870 __LOG( "CUPnPPlaybackSession::RespondToStopRequest - \ |
2479 |
2871 Response to stop" ); |
2480 // clean up |
2872 __ASSERT( iCommandMessage, __FILE__, __LINE__ ); |
2481 CleanupStack::PopAndDestroy( &stream ); |
2873 iTimer->Cancel(); |
2482 CleanupStack::PopAndDestroy( buf ); |
2874 // Unregister from the dispatcher. This way we do not get |
2483 } |
2875 // ::AvtStopResponse callback (it would be ignored, anyway) |
2484 |
2876 iServer.Dispatcher().UnRegister( iIPSessionIdCommand ); |
2485 void CUPnPPlaybackSession::ValidateProtocolInfoL( const CUpnpAttribute& |
2877 iIPSessionIdCommand = KErrNotFound; |
2486 aResource ) |
2878 iCommandMessage->Complete( EAVControllerStopCompleted ); |
2487 { |
2879 delete iCommandMessage; iCommandMessage = NULL; |
2488 __LOG( "CUPnPPlaybackSession::ValidateProtocolInfoL" ); |
2880 iExpectedEvent = EEventNone; |
2489 |
|
2490 // Whe'd like to modify the original protocolInfo, that's why constness |
|
2491 // is casted away |
|
2492 CUpnpAttribute& attr = const_cast<CUpnpAttribute&>( aResource ); |
|
2493 |
|
2494 // ProtocolInfo-wrapper takes care of 4th field validation, omitting |
|
2495 // invalid optional parameters |
|
2496 CUpnpDlnaProtocolInfo* tmpInfo = |
|
2497 CUpnpDlnaProtocolInfo::NewL( attr.Value() ); |
|
2498 CleanupStack::PushL( tmpInfo ); |
|
2499 |
|
2500 tmpInfo->SetSecondFieldL( KAsterisk ); // Second field must be '*' |
|
2501 |
|
2502 attr.SetValueL( tmpInfo->ProtocolInfoL() ); |
|
2503 |
|
2504 CleanupStack::PopAndDestroy( tmpInfo ); |
|
2505 } |
|
2506 |
|
2507 // -------------------------------------------------------------------------- |
|
2508 // CUPnPPlaybackSession::SendPlayIfNeededL |
|
2509 // See upnpplaybacksession.h |
|
2510 // -------------------------------------------------------------------------- |
|
2511 void CUPnPPlaybackSession::SendPlayIfNeededL() |
|
2512 { |
|
2513 __LOG( "CUPnPPlaybackSession::SendPlayIfNeededL" ); |
|
2514 if ( iPlayRequested ) |
|
2515 { |
|
2516 // during the timer was running, there was a play request. |
|
2517 // handle it here |
|
2518 iPlayRequested = EFalse; // play request is being handled |
|
2519 |
|
2520 ResetL(); |
|
2521 |
|
2522 iIPSessionIdCommand = iServer.ControlPoint().AvtPlayActionL( |
|
2523 iDevice->Uuid(), iInstanceId, KNormalSpeed ); |
|
2524 |
|
2525 if( iIPSessionIdCommand > 0 ) |
|
2526 { |
|
2527 __LOG( "CUPnPPlaybackSession::SendPlayIfNeededL - registering" ); |
|
2528 // Register |
|
2529 iPlaybackState = EPlaySent; |
|
2530 iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this ); |
|
2531 } |
|
2532 else |
|
2533 { |
|
2534 User::Leave( iIPSessionIdCommand ); |
|
2535 } |
|
2536 } |
|
2537 } |
|
2538 |
|
2539 // -------------------------------------------------------------------------- |
|
2540 // CUPnPPlaybackSession::PlayDelayTimeExpired |
|
2541 // See upnpplaybacksession.h |
|
2542 // -------------------------------------------------------------------------- |
|
2543 TInt CUPnPPlaybackSession::PlayDelayTimeExpired( TAny* aPtr ) |
|
2544 { |
|
2545 __LOG( "CUPnPPlaybackSession::PlayDelayTimeExpired" ); |
|
2546 TRAPD( err, ( static_cast< CUPnPPlaybackSession* >( aPtr ) )-> |
|
2547 SendPlayIfNeededL() ); |
|
2548 |
|
2549 if ( err ) |
|
2550 { |
|
2551 __LOG( "CUPnPPlaybackSession::PlayDelayTimeExpired error" ); |
|
2552 } |
|
2553 |
|
2554 return ETrue; |
|
2555 } |
2881 } |
2556 |
2882 |
2557 // end of file |
2883 // end of file |