22 |
22 |
23 // INCLUDE FILES |
23 // INCLUDE FILES |
24 #include "upnpdevicerepository.h" |
24 #include "upnpdevicerepository.h" |
25 |
25 |
26 #include "upnpavdeviceextended.h" |
26 #include "upnpavdeviceextended.h" |
|
27 #include "upnpavcontrolpoint.h" |
27 |
28 |
28 #include <upnpservice.h> |
29 #include <upnpservice.h> |
29 #include <upnpdevice.h> |
30 #include <upnpdevice.h> |
30 #include <upnpavcontrolpoint.h> |
31 #include <upnpicon.h> |
|
32 #include "upnpavcontrollerglobals.h" // For KRel_Time |
31 |
33 |
32 // CONSTANTS |
34 // CONSTANTS |
33 _LIT8( KSearch, "Search" ); |
35 _LIT8( KSearch, "Search" ); |
34 _LIT8( KVolume, "Volume" ); |
36 _LIT8( KVolume, "Volume" ); |
35 _LIT8( KCreateObject, "CreateObject" ); |
37 _LIT8( KCreateObject, "CreateObject" ); |
38 _LIT8( KGetVolume, "GetVolume"); |
40 _LIT8( KGetVolume, "GetVolume"); |
39 _LIT8( KGetMute, "GetMute"); |
41 _LIT8( KGetMute, "GetMute"); |
40 _LIT8( KSetMute, "SetMute"); |
42 _LIT8( KSetMute, "SetMute"); |
41 _LIT8( KMediaServer, "MediaServer" ); |
43 _LIT8( KMediaServer, "MediaServer" ); |
42 _LIT8( KFriendlyName, "friendlyName" ); |
44 _LIT8( KFriendlyName, "friendlyName" ); |
|
45 _LIT8( KModelName, "modelName" ); |
43 _LIT8( KAVTransportService, "AVTransport" ); |
46 _LIT8( KAVTransportService, "AVTransport" ); |
44 _LIT8( KRenderingControlService, "RenderingControl" ); |
47 _LIT8( KRenderingControlService, "RenderingControl" ); |
45 _LIT8( KSetNextUri, "SetNextAVTransportURI" ); |
48 _LIT8( KSetNextUri, "SetNextAVTransportURI" ); |
|
49 _LIT8( KPrepareForConnection, "PrepareForConnection" ); |
46 _LIT8( KDestroyObject, "DestroyObject" ); |
50 _LIT8( KDestroyObject, "DestroyObject" ); |
47 _LIT8( KDlnaDoc, "dlna:X_DLNADOC" ); |
51 _LIT8( KDlnaDoc, "dlna:X_DLNADOC" ); |
48 _LIT8( KDlnaCap, "dlna:X_DLNACAP" ); |
52 _LIT8( KDlnaCap, "dlna:X_DLNACAP" ); |
49 _LIT8( KAudioUpload, "audio-upload" ); |
53 _LIT8( KAudioUpload, "audio-upload" ); |
50 _LIT8( KImageUpload, "image-upload" ); |
54 _LIT8( KImageUpload, "image-upload" ); |
51 _LIT8( KVideoUpload, "av-upload" ); |
55 _LIT8( KVideoUpload, "av-upload" ); |
52 _LIT8( KCreateChildContainer, "create-child-container" ); |
56 _LIT8( KCreateChildContainer, "create-child-container" ); |
53 _LIT8( KDMS, "DMS" ); |
57 _LIT8( KDMS, "DMS" ); |
54 _LIT8( KDMP, "DMP" ); |
58 _LIT8( KDMP, "DMP" ); |
55 _LIT8( KDMR, "DMR" ); |
59 _LIT8( KDMR, "DMR" ); |
|
60 _LIT8( KJpg, "jpg" ); |
|
61 _LIT8( KJpeg, "jpeg" ); |
|
62 _LIT8( KPng, "png" ); |
|
63 // Prefer 48x48 color icons and then greater size color icons |
|
64 const TInt KPreferredIconSize = 48; |
|
65 |
|
66 // Seek mode argument type string |
|
67 _LIT8( KArgumentTypeSeekMode, "A_ARG_TYPE_SeekMode" ); |
56 |
68 |
57 const TInt KFirstSubscription = 1; |
69 const TInt KFirstSubscription = 1; |
58 |
70 |
59 _LIT( KComponentLogfile, "upnpavcontrollerserver.txt"); |
71 _LIT( KComponentLogfile, "upnpavcontrollerserver.txt"); |
60 #include "upnplog.h" |
72 #include "upnplog.h" |
112 |
124 |
113 // -------------------------------------------------------------------------- |
125 // -------------------------------------------------------------------------- |
114 // CUPnPDeviceRepository::AddDeviceL |
126 // CUPnPDeviceRepository::AddDeviceL |
115 // See upnpdevicerepository.h |
127 // See upnpdevicerepository.h |
116 // -------------------------------------------------------------------------- |
128 // -------------------------------------------------------------------------- |
117 void CUPnPDeviceRepository::AddDeviceL( CUpnpDevice& aDevice ) |
129 CUpnpAVDeviceExtended& CUPnPDeviceRepository::AddDeviceL( CUpnpDevice& aDevice ) |
118 { |
130 { |
119 __LOG( "CUPnPDeviceRepository::AddDeviceL" ); |
131 __LOG( "CUPnPDeviceRepository::AddDeviceL" ); |
120 |
132 |
121 CUpnpAVDeviceExtended* dev = CUpnpAVDeviceExtended::NewL(); |
133 CUpnpAVDeviceExtended* dev = CUpnpAVDeviceExtended::NewL(); |
122 CleanupStack::PushL( dev ); |
134 CleanupStack::PushL( dev ); |
175 dev->SetDeviceType( CUpnpAVDevice::EMediaRenderer ); |
187 dev->SetDeviceType( CUpnpAVDevice::EMediaRenderer ); |
176 } |
188 } |
177 |
189 |
178 dev->SetFriendlyNameL( aDevice.DescriptionProperty( KFriendlyName ) ); |
190 dev->SetFriendlyNameL( aDevice.DescriptionProperty( KFriendlyName ) ); |
179 |
191 |
|
192 dev->SetModelNameL( aDevice.DescriptionProperty( KModelName ) ); |
|
193 |
180 dev->SetUuidL( aDevice.Uuid() ); |
194 dev->SetUuidL( aDevice.Uuid() ); |
181 |
195 |
182 dev->SetLocal( aDevice.Local() ); |
196 dev->SetLocal( aDevice.Local() ); |
183 |
197 |
184 ParseDeviceServicesL( aDevice, *dev ); |
198 ParseDeviceServicesL( aDevice, *dev ); |
|
199 |
|
200 SelectDeviceIconL( aDevice, *dev ); |
|
201 |
185 CleanupStack::Pop( dev ); |
202 CleanupStack::Pop( dev ); |
186 iDevices.AppendL( dev ); |
203 iDevices.AppendL( dev ); |
|
204 return *dev; |
187 } |
205 } |
188 |
206 |
189 // -------------------------------------------------------------------------- |
207 // -------------------------------------------------------------------------- |
190 // CUPnPDeviceRepository::AddProtocolInfoL |
208 // CUPnPDeviceRepository::AddProtocolInfoL |
191 // See upnpdevicerepository.h |
209 // See upnpdevicerepository.h |
484 { |
502 { |
485 // No need to unsubscibe |
503 // No need to unsubscibe |
486 } |
504 } |
487 } |
505 } |
488 |
506 |
|
507 // -------------------------------------------------------------------------- |
|
508 // CUPnPDeviceRepository::ConnectionLost |
|
509 // See upnpdevicerepository.h |
|
510 // -------------------------------------------------------------------------- |
489 void CUPnPDeviceRepository::ConnectionLost() |
511 void CUPnPDeviceRepository::ConnectionLost() |
490 { |
512 { |
491 __LOG( "CUPnPDeviceRepository::ConnectionLost" ); |
513 __LOG( "CUPnPDeviceRepository::ConnectionLost" ); |
492 iIsWlanActive = EFalse; |
514 iIsWlanActive = EFalse; |
493 iDevices.ResetAndDestroy(); |
515 iDevices.ResetAndDestroy(); |
494 } |
516 } |
495 |
517 |
|
518 // -------------------------------------------------------------------------- |
|
519 // CUPnPDeviceRepository::IsWlanActive |
|
520 // See upnpdevicerepository.h |
|
521 // -------------------------------------------------------------------------- |
496 TBool CUPnPDeviceRepository::IsWlanActive() |
522 TBool CUPnPDeviceRepository::IsWlanActive() |
497 { |
523 { |
498 __LOG1( "CUPnPDeviceRepository::IsWlanActive, %d", (TInt)iIsWlanActive ); |
524 __LOG1( "CUPnPDeviceRepository::IsWlanActive, %d", (TInt)iIsWlanActive ); |
499 return iIsWlanActive; |
525 return iIsWlanActive; |
|
526 } |
|
527 |
|
528 // -------------------------------------------------------------------------- |
|
529 // CUPnPDeviceRepository::SetMaxVolume |
|
530 // See upnpdevicerepository.h |
|
531 // -------------------------------------------------------------------------- |
|
532 void CUPnPDeviceRepository::SetMaxVolume(CUpnpStateVariable* aVolumeState, |
|
533 CUpnpAVDeviceExtended& aTarget) |
|
534 { |
|
535 if( aVolumeState ) |
|
536 { |
|
537 // If volume info found, save it to the device |
|
538 TInt maxVolume = aVolumeState->MaxValue(); |
|
539 // If max volume not defined, it is set to 100 |
|
540 if( maxVolume == KErrNotFound ) |
|
541 { |
|
542 maxVolume = 100; |
|
543 } |
|
544 aTarget.SetMaxVolume( maxVolume ); |
|
545 } |
|
546 } |
|
547 |
|
548 // -------------------------------------------------------------------------- |
|
549 // CUPnPDeviceRepository::SetSeekCapabilityL |
|
550 // See upnpdevicerepository.h |
|
551 // -------------------------------------------------------------------------- |
|
552 void CUPnPDeviceRepository::SetSeekCapabilityL(CUpnpStateVariable* seekModeStateVariable, |
|
553 CUpnpAVDeviceExtended& aTarget) |
|
554 { |
|
555 if ( seekModeStateVariable ) |
|
556 { |
|
557 CDesC8Array* allowedSeekModes = |
|
558 seekModeStateVariable->AllowedValuesLC(); |
|
559 if ( allowedSeekModes ) |
|
560 { |
|
561 for ( TInt i=0 ; i < allowedSeekModes->Count() ; i++ ) |
|
562 { |
|
563 if ( 0 == allowedSeekModes-> |
|
564 operator[](i).CompareC( KRel_Time() ) ) |
|
565 { |
|
566 aTarget.SetSeekCapability( CUpnpAVDevice::ERelTime ); |
|
567 break; |
|
568 } |
|
569 } |
|
570 } |
|
571 CleanupStack::PopAndDestroy( allowedSeekModes ); |
|
572 } |
500 } |
573 } |
501 |
574 |
502 // -------------------------------------------------------------------------- |
575 // -------------------------------------------------------------------------- |
503 // CUPnPDeviceRepository::ParseDeviceServicesL |
576 // CUPnPDeviceRepository::ParseDeviceServicesL |
504 // See upnpdevicerepository.h |
577 // See upnpdevicerepository.h |
512 TBool getMuteSupported = EFalse; |
585 TBool getMuteSupported = EFalse; |
513 TBool setMuteSupported = EFalse; |
586 TBool setMuteSupported = EFalse; |
514 TBool getVolumeSupported = EFalse; |
587 TBool getVolumeSupported = EFalse; |
515 TBool setVolumeSupported = EFalse; |
588 TBool setVolumeSupported = EFalse; |
516 |
589 |
517 RPointerArray<CUpnpService>services = aSource.ServiceList(); |
590 RPointerArray<CUpnpService>& services = aSource.ServiceList(); |
518 |
591 |
519 TInt i; |
592 TInt i; |
520 TInt count = services.Count(); |
593 TInt count = services.Count(); |
521 for( i = 0; i < count; i++ ) |
594 for( i = 0; i < count; i++ ) |
522 { |
595 { |
523 // Get max volume if it exists |
596 CUpnpStateVariable* volumeState = |
524 CUpnpStateVariable* volumeState = |
|
525 services[ i ]->StateVariable( KVolume ); |
597 services[ i ]->StateVariable( KVolume ); |
526 |
598 |
527 // If volume info found, save it to the device |
599 SetMaxVolume(volumeState, aTarget); |
528 if( volumeState ) |
600 |
529 { |
601 CUpnpStateVariable* seekModeStateVariable = |
530 TInt maxVolume = volumeState->MaxValue(); |
602 services[i]->StateVariable( KArgumentTypeSeekMode() ); |
531 // If max volume not defined, it is set to 100 |
603 |
532 if( maxVolume == KErrNotFound ) |
604 SetSeekCapabilityL(seekModeStateVariable, aTarget); |
533 { |
|
534 maxVolume = 100; |
|
535 } |
|
536 aTarget.SetMaxVolume( maxVolume ); |
|
537 } |
|
538 |
605 |
539 // Get the actions |
606 // Get the actions |
540 RPointerArray<CUpnpAction> actions; |
607 RPointerArray<CUpnpAction> actions; |
|
608 // 'actions' cannot be closed, it is the same instance that is inside 'service' |
541 services[ i ]->GetActionList( actions ); |
609 services[ i ]->GetActionList( actions ); |
542 |
610 |
543 // Go through the action elements |
611 // Go through the action elements |
544 TInt j; |
612 TInt j; |
545 TInt count2 = actions.Count(); |
613 TInt count2 = actions.Count(); |
606 if( getMuteSupported && |
678 if( getMuteSupported && |
607 setMuteSupported ) |
679 setMuteSupported ) |
608 { |
680 { |
609 aTarget.SetMuteCapability( ETrue ); |
681 aTarget.SetMuteCapability( ETrue ); |
610 } |
682 } |
611 } |
683 |
|
684 } |
|
685 |
|
686 // -------------------------------------------------------------------------- |
|
687 // CUPnPDeviceRepository::SelectDeviceIconL |
|
688 // See upnpdevicerepository.h |
|
689 // -------------------------------------------------------------------------- |
|
690 void CUPnPDeviceRepository::SelectDeviceIconL( CUpnpDevice& aSource, |
|
691 CUpnpAVDeviceExtended& aTarget ) |
|
692 { |
|
693 // Icon selection rules: |
|
694 // 1. Select any if none selected |
|
695 // 2. Select the most colorful |
|
696 // 3. Select greater until preferred size reached |
|
697 // 4. Select the closest greater size after preferred size has passed |
|
698 TPtrC8 deviceName( aTarget.FriendlyName() ); |
|
699 __LOG8_1( "CUPnPDeviceRepository::SelectDeviceIconL - Device: %S", &deviceName ); |
|
700 RPointerArray< CUpnpIcon >& icons( aSource.Icons() ); |
|
701 TInt iconCount( icons.Count() ); |
|
702 CUpnpIcon* selectedIcon = NULL; |
|
703 TInt selectedDepth( 0 ); |
|
704 TInt selectedWd( 0 ); |
|
705 TInt selectedHd( 0 ); |
|
706 TInt selectedWhdSquare( 0 ); |
|
707 for ( TInt i( 0 ); i < iconCount; ++i ) |
|
708 { |
|
709 CUpnpIcon* icon = icons[ i ]; |
|
710 TPtrC8 iconMimeType( icon->MimeType() ); |
|
711 __LOG8_1( "CUPnPDeviceRepository::SelectDeviceIconL - Found: %S", &iconMimeType ); |
|
712 __LOG3( "CUPnPDeviceRepository::SelectDeviceIconL - Width: %d Height: %d Depth: %d", |
|
713 icon->Width(), icon->Height(), icon->Depth() ); |
|
714 if ( iconMimeType.FindF( KJpg ) != KErrNotFound || |
|
715 iconMimeType.FindF( KJpeg ) != KErrNotFound || |
|
716 iconMimeType.FindF( KPng ) != KErrNotFound ) |
|
717 { |
|
718 TInt depth( icon->Depth() ); |
|
719 TInt wd( icon->Width() - KPreferredIconSize ); // Width diff to preferred size |
|
720 TInt hd( icon->Height() - KPreferredIconSize ); // Height diff to preferred size |
|
721 TInt whdSquare( wd * wd + hd * hd ); // Diffs combined |
|
722 if ( !selectedIcon || // Rule 1 |
|
723 ( depth >= selectedDepth && // Rule 2 |
|
724 ( ( selectedWd < 0 && selectedWd < 0 && ( wd > selectedWd || hd > selectedHd ) ) || // Rule 3 |
|
725 ( whdSquare < selectedWhdSquare && ( wd >= 0 || hd >= 0 ) ) ) // Rule 4 |
|
726 ) |
|
727 ) |
|
728 { |
|
729 selectedIcon = icon; |
|
730 selectedDepth = depth; |
|
731 selectedWd = wd; |
|
732 selectedHd = hd; |
|
733 selectedWhdSquare = whdSquare; |
|
734 } |
|
735 } |
|
736 } |
|
737 if ( selectedIcon ) |
|
738 { |
|
739 TPtrC8 iconMimeType( selectedIcon->MimeType() ); |
|
740 __LOG8_1( "CUPnPDeviceRepository::SelectDeviceIconL - Selected: %S", &iconMimeType ); |
|
741 __LOG3( "CUPnPDeviceRepository::SelectDeviceIconL - Width: %d Height: %d Depth: %d", |
|
742 selectedIcon->Width(), selectedIcon->Height(), selectedIcon->Depth() ); |
|
743 aTarget.SetIconUrlL( aSource.Address(), aSource.UrlBase(), selectedIcon->Url() ); |
|
744 } |
|
745 else |
|
746 { |
|
747 __LOG( "CUPnPDeviceRepository::SelectDeviceIconL - None selected" ); |
|
748 } |
|
749 } |
612 |
750 |
613 // end of file |
751 // end of file |