1 /*****************************************************************************
2 * Upnp_intel.cpp : UPnP discovery module (Intel SDK)
3 *****************************************************************************
4 * Copyright (C) 2004-2008 the VideoLAN team
7 * Authors: RĂ©mi Denis-Courmont <rem # videolan.org> (original plugin)
8 * Christian Henz <henz # c-lab.de>
9 * Mirsal Ennaime <mirsal dot ennaime at gmail dot com>
11 * UPnP Plugin using the Intel SDK (libupnp) instead of CyberLink
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 *****************************************************************************/
29 \TODO: Debug messages: "__FILE__, __LINE__" ok ???, Wrn/Err ???
30 \TODO: Change names to VLC standard ???
37 #include <upnp/upnp.h>
38 #include <upnp/upnptools.h>
45 #include <vlc_common.h>
46 #include <vlc_plugin.h>
47 #include <vlc_services_discovery.h>
51 const char* MEDIA_SERVER_DEVICE_TYPE = "urn:schemas-upnp-org:device:MediaServer:1";
52 const char* CONTENT_DIRECTORY_SERVICE_TYPE = "urn:schemas-upnp-org:service:ContentDirectory:1";
57 class MediaServerList;
64 struct services_discovery_sys_t
66 UpnpClient_Handle clientHandle;
67 MediaServerList* serverList;
68 Lockable* callbackLock;
71 // Class definitions...
79 vlc_mutex_init( &_mutex );
84 vlc_mutex_destroy( &_mutex );
87 void lock() { vlc_mutex_lock( &_mutex ); }
88 void unlock() { vlc_mutex_unlock( &_mutex ); }
119 static void parseDeviceDescription( IXML_Document* doc,
120 const char* location,
121 services_discovery_t* p_sd );
123 MediaServer( const char* UDN,
124 const char* friendlyName,
125 services_discovery_t* p_sd );
129 const char* getUDN() const;
130 const char* getFriendlyName() const;
132 void setContentDirectoryEventURL( const char* url );
133 const char* getContentDirectoryEventURL() const;
135 void setContentDirectoryControlURL( const char* url );
136 const char* getContentDirectoryControlURL() const;
138 void subscribeToContentDirectory();
139 void fetchContents();
141 void setInputItem( input_item_t* p_input_item );
143 bool compareSID( const char* sid );
147 bool _fetchContents( Container* parent );
148 void _buildPlaylist( Container* container );
150 IXML_Document* _browseAction( const char*, const char*,
151 const char*, const char*, const char*, const char* );
153 services_discovery_t* _p_sd;
155 Container* _contents;
156 input_item_t* _inputItem;
159 std::string _friendlyName;
161 std::string _contentDirectoryEventURL;
162 std::string _contentDirectoryControlURL;
164 int _subscriptionTimeOut;
165 Upnp_SID _subscriptionID;
169 class MediaServerList
173 MediaServerList( services_discovery_t* p_sd );
176 bool addServer( MediaServer* s );
177 void removeServer( const char* UDN );
179 MediaServer* getServer( const char* UDN );
180 MediaServer* getServerBySID( const char* );
184 services_discovery_t* _p_sd;
186 std::vector<MediaServer*> _list;
194 Item( Container* parent,
195 const char* objectID,
197 const char* resource );
200 const char* getObjectID() const;
201 const char* getTitle() const;
202 const char* getResource() const;
204 void setInputItem( input_item_t* p_input_item );
205 input_item_t* getInputItem() const ;
209 input_item_t* _inputItem;
212 std::string _objectID;
214 std::string _resource;
222 Container( Container* parent, const char* objectID, const char* title );
225 void addItem( Item* item );
226 void addContainer( Container* container );
228 const char* getObjectID() const;
229 const char* getTitle() const;
231 unsigned int getNumItems() const;
232 unsigned int getNumContainers() const;
234 Item* getItem( unsigned int i ) const;
235 Container* getContainer( unsigned int i ) const;
236 Container* getParent();
238 void setInputItem( input_item_t* p_input_item );
239 input_item_t* getInputItem() const;
243 input_item_t* _inputItem;
247 std::string _objectID;
249 std::vector<Item*> _items;
250 std::vector<Container*> _containers;
253 // VLC callback prototypes
255 static int Open( vlc_object_t* );
256 static void Close( vlc_object_t* );
261 set_shortname( "UPnP" );
262 set_description( N_( "Universal Plug'n'Play discovery ( Intel SDK )" ) );
263 set_category( CAT_PLAYLIST );
264 set_subcategory( SUBCAT_PLAYLIST_SD );
265 set_capability( "services_discovery", 0 );
266 set_callbacks( Open, Close );
270 // More prototypes...
272 static int Callback( Upnp_EventType eventType, void* event, void* user_data );
274 const char* xml_getChildElementValue( IXML_Element* parent,
275 const char* tagName );
277 IXML_Document* parseBrowseResult( IXML_Document* doc );
282 static int Open( vlc_object_t *p_this )
285 services_discovery_t *p_sd = ( services_discovery_t* )p_this;
286 services_discovery_sys_t *p_sys = ( services_discovery_sys_t * )
287 calloc( 1, sizeof( services_discovery_sys_t ) );
289 if(!(p_sd->p_sys = p_sys))
292 services_discovery_SetLocalizedName( p_sd, _("UPnP devices") );
294 res = UpnpInit( 0, 0 );
295 if( res != UPNP_E_SUCCESS )
297 msg_Err( p_sd, "%s", UpnpGetErrorMessage( res ) );
301 p_sys->serverList = new MediaServerList( p_sd );
302 p_sys->callbackLock = new Lockable();
304 res = UpnpRegisterClient( Callback, p_sd, &p_sys->clientHandle );
305 if( res != UPNP_E_SUCCESS )
307 msg_Err( p_sd, "%s", UpnpGetErrorMessage( res ) );
308 Close( (vlc_object_t*) p_sd );
312 res = UpnpSearchAsync( p_sys->clientHandle, 5,
313 MEDIA_SERVER_DEVICE_TYPE, p_sd );
315 if( res != UPNP_E_SUCCESS )
317 msg_Err( p_sd, "%s", UpnpGetErrorMessage( res ) );
318 Close( (vlc_object_t*) p_sd );
325 static void Close( vlc_object_t *p_this )
327 services_discovery_t *p_sd = ( services_discovery_t* )p_this;
330 delete p_sd->p_sys->serverList;
331 delete p_sd->p_sys->callbackLock;
336 // XML utility functions:
338 // Returns the value of a child element, or 0 on error
339 const char* xml_getChildElementValue( IXML_Element* parent,
340 const char* tagName )
342 if ( !parent ) return 0;
343 if ( !tagName ) return 0;
345 char* s = strdup( tagName );
346 IXML_NodeList* nodeList = ixmlElement_getElementsByTagName( parent, s );
348 if ( !nodeList ) return 0;
350 IXML_Node* element = ixmlNodeList_item( nodeList, 0 );
351 ixmlNodeList_free( nodeList );
352 if ( !element ) return 0;
354 IXML_Node* textNode = ixmlNode_getFirstChild( element );
355 if ( !textNode ) return 0;
357 return ixmlNode_getNodeValue( textNode );
360 // Extracts the result document from a SOAP response
361 IXML_Document* parseBrowseResult( IXML_Document* doc )
365 if ( !doc ) return 0;
367 IXML_NodeList* resultList = ixmlDocument_getElementsByTagName( doc,
370 if ( !resultList ) return 0;
372 IXML_Node* resultNode = ixmlNodeList_item( resultList, 0 );
374 ixmlNodeList_free( resultList );
376 if ( !resultNode ) return 0;
378 IXML_Node* textNode = ixmlNode_getFirstChild( resultNode );
379 if ( !textNode ) return 0;
381 const char* resultString = ixmlNode_getNodeValue( textNode );
382 char* resultXML = strdup( resultString );
384 IXML_Document* browseDoc = ixmlParseBuffer( resultXML );
392 // Handles all UPnP events
393 static int Callback( Upnp_EventType eventType, void* event, void* user_data )
395 services_discovery_t *p_sd = ( services_discovery_t* ) user_data;
396 services_discovery_sys_t* p_sys = p_sd->p_sys;
397 Locker locker( p_sys->callbackLock );
399 switch( eventType ) {
401 case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
402 case UPNP_DISCOVERY_SEARCH_RESULT:
404 struct Upnp_Discovery* discovery = ( struct Upnp_Discovery* )event;
406 IXML_Document *descriptionDoc = 0;
409 res = UpnpDownloadXmlDoc( discovery->Location, &descriptionDoc );
410 if ( res != UPNP_E_SUCCESS )
413 "%s:%d: Could not download device description!",
414 __FILE__, __LINE__ );
418 MediaServer::parseDeviceDescription( descriptionDoc,
419 discovery->Location, p_sd );
421 ixmlDocument_free( descriptionDoc );
425 case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
427 struct Upnp_Discovery* discovery = ( struct Upnp_Discovery* )event;
429 p_sys->serverList->removeServer( discovery->DeviceId );
433 case UPNP_EVENT_RECEIVED:
435 Upnp_Event* e = ( Upnp_Event* )event;
437 MediaServer* server = p_sys->serverList->getServerBySID( e->Sid );
438 if ( server ) server->fetchContents();
442 case UPNP_EVENT_AUTORENEWAL_FAILED:
443 case UPNP_EVENT_SUBSCRIPTION_EXPIRED:
447 Upnp_Event_Subscribe* s = ( Upnp_Event_Subscribe* )event;
449 MediaServer* server = p_sys->serverList->getServerBySID( s->Sid );
450 if ( server ) server->subscribeToContentDirectory();
454 case UPNP_EVENT_SUBSCRIBE_COMPLETE:
455 msg_Warn( p_sd, "subscription complete" );
458 case UPNP_DISCOVERY_SEARCH_TIMEOUT:
459 msg_Warn( p_sd, "search timeout" );
464 "%s:%d: DEBUG: UNHANDLED EVENT ( TYPE=%d )",
465 __FILE__, __LINE__, eventType );
469 return UPNP_E_SUCCESS;
473 // Class implementations...
477 void MediaServer::parseDeviceDescription( IXML_Document* doc,
478 const char* location,
479 services_discovery_t* p_sd )
483 msg_Dbg( p_sd, "%s:%d: NULL", __FILE__, __LINE__ );
489 msg_Dbg( p_sd, "%s:%d: NULL", __FILE__, __LINE__ );
493 const char* baseURL = location;
495 // Try to extract baseURL
497 IXML_NodeList* urlList = ixmlDocument_getElementsByTagName( doc, "baseURL" );
501 if ( IXML_Node* urlNode = ixmlNodeList_item( urlList, 0 ) )
503 IXML_Node* textNode = ixmlNode_getFirstChild( urlNode );
504 if ( textNode ) baseURL = ixmlNode_getNodeValue( textNode );
507 ixmlNodeList_free( urlList );
512 IXML_NodeList* deviceList =
513 ixmlDocument_getElementsByTagName( doc, "device" );
517 for ( unsigned int i = 0; i < ixmlNodeList_length( deviceList ); i++ )
519 IXML_Element* deviceElement =
520 ( IXML_Element* ) ixmlNodeList_item( deviceList, i );
522 const char* deviceType = xml_getChildElementValue( deviceElement,
527 "%s:%d: no deviceType!",
528 __FILE__, __LINE__ );
532 if ( strcmp( MEDIA_SERVER_DEVICE_TYPE, deviceType ) != 0 )
535 const char* UDN = xml_getChildElementValue( deviceElement, "UDN" );
538 msg_Dbg( p_sd, "%s:%d: no UDN!",
539 __FILE__, __LINE__ );
543 if ( p_sd->p_sys->serverList->getServer( UDN ) != 0 )
546 const char* friendlyName =
547 xml_getChildElementValue( deviceElement,
552 msg_Dbg( p_sd, "%s:%d: no friendlyName!", __FILE__, __LINE__ );
556 MediaServer* server = new MediaServer( UDN, friendlyName, p_sd );
558 if ( !p_sd->p_sys->serverList->addServer( server ) )
566 // Check for ContentDirectory service...
567 IXML_NodeList* serviceList =
568 ixmlElement_getElementsByTagName( deviceElement,
572 for ( unsigned int j = 0;
573 j < ixmlNodeList_length( serviceList ); j++ )
575 IXML_Element* serviceElement =
576 ( IXML_Element* ) ixmlNodeList_item( serviceList, j );
578 const char* serviceType =
579 xml_getChildElementValue( serviceElement,
584 if ( strcmp( CONTENT_DIRECTORY_SERVICE_TYPE,
588 const char* eventSubURL =
589 xml_getChildElementValue( serviceElement,
594 const char* controlURL =
595 xml_getChildElementValue( serviceElement,
600 // Try to subscribe to ContentDirectory service
602 char* url = ( char* ) malloc( strlen( baseURL ) +
603 strlen( eventSubURL ) + 1 );
606 char* s1 = strdup( baseURL );
607 char* s2 = strdup( eventSubURL );
609 if ( UpnpResolveURL( s1, s2, url ) ==
612 server->setContentDirectoryEventURL( url );
613 server->subscribeToContentDirectory();
621 // Try to browse content directory...
623 url = ( char* ) malloc( strlen( baseURL ) +
624 strlen( controlURL ) + 1 );
627 char* s1 = strdup( baseURL );
628 char* s2 = strdup( controlURL );
630 if ( UpnpResolveURL( s1, s2, url ) ==
633 server->setContentDirectoryControlURL( url );
634 server->fetchContents();
642 ixmlNodeList_free( serviceList );
645 ixmlNodeList_free( deviceList );
649 MediaServer::MediaServer( const char* UDN,
650 const char* friendlyName,
651 services_discovery_t* p_sd )
656 _friendlyName = friendlyName;
662 MediaServer::~MediaServer()
667 const char* MediaServer::getUDN() const
669 const char* s = _UDN.c_str();
673 const char* MediaServer::getFriendlyName() const
675 const char* s = _friendlyName.c_str();
679 void MediaServer::setContentDirectoryEventURL( const char* url )
681 _contentDirectoryEventURL = url;
684 const char* MediaServer::getContentDirectoryEventURL() const
686 const char* s = _contentDirectoryEventURL.c_str();
690 void MediaServer::setContentDirectoryControlURL( const char* url )
692 _contentDirectoryControlURL = url;
695 const char* MediaServer::getContentDirectoryControlURL() const
697 return _contentDirectoryControlURL.c_str();
700 void MediaServer::subscribeToContentDirectory()
702 const char* url = getContentDirectoryEventURL();
703 if ( !url || strcmp( url, "" ) == 0 )
705 msg_Dbg( _p_sd, "No subscription url set!" );
712 int res = UpnpSubscribe( _p_sd->p_sys->clientHandle, url, &timeOut, sid );
714 if ( res == UPNP_E_SUCCESS )
716 _subscriptionTimeOut = timeOut;
717 memcpy( _subscriptionID, sid, sizeof( Upnp_SID ) );
722 "%s:%d: WARNING: '%s': %s", __FILE__, __LINE__,
723 getFriendlyName(), UpnpGetErrorMessage( res ) );
727 IXML_Document* MediaServer::_browseAction( const char* pObjectID,
728 const char* pBrowseFlag,
730 const char* pStartingIndex,
731 const char* pRequestedCount,
732 const char* pSortCriteria )
734 IXML_Document* action = 0;
735 IXML_Document* response = 0;
736 const char* url = getContentDirectoryControlURL();
738 if ( !url || strcmp( url, "" ) == 0 )
740 msg_Dbg( _p_sd, "No subscription url set!" );
744 char* ObjectID = strdup( pObjectID );
745 char* BrowseFlag = strdup( pBrowseFlag );
746 char* Filter = strdup( pFilter );
747 char* StartingIndex = strdup( pStartingIndex );
748 char* RequestedCount = strdup( pRequestedCount );
749 char* SortCriteria = strdup( pSortCriteria );
750 char* serviceType = strdup( CONTENT_DIRECTORY_SERVICE_TYPE );
754 res = UpnpAddToAction( &action, "Browse",
755 serviceType, "ObjectID", ObjectID );
757 if ( res != UPNP_E_SUCCESS )
760 "%s:%d: ERROR: %s", __FILE__, __LINE__,
761 UpnpGetErrorMessage( res ) );
762 goto browseActionCleanup;
765 res = UpnpAddToAction( &action, "Browse",
766 serviceType, "BrowseFlag", BrowseFlag );
768 if ( res != UPNP_E_SUCCESS )
771 "%s:%d: ERROR: %s", __FILE__, __LINE__,
772 UpnpGetErrorMessage( res ) );
773 goto browseActionCleanup;
776 res = UpnpAddToAction( &action, "Browse",
777 serviceType, "Filter", Filter );
779 if ( res != UPNP_E_SUCCESS )
782 "%s:%d: ERROR: %s", __FILE__, __LINE__,
783 UpnpGetErrorMessage( res ) );
784 goto browseActionCleanup;
787 res = UpnpAddToAction( &action, "Browse",
788 serviceType, "StartingIndex", StartingIndex );
790 if ( res != UPNP_E_SUCCESS )
793 "%s:%d: ERROR: %s", __FILE__, __LINE__,
794 UpnpGetErrorMessage( res ) );
795 goto browseActionCleanup;
798 res = UpnpAddToAction( &action, "Browse",
799 serviceType, "RequestedCount", RequestedCount );
801 if ( res != UPNP_E_SUCCESS )
804 "%s:%d: ERROR: %s", __FILE__, __LINE__,
805 UpnpGetErrorMessage( res ) ); goto browseActionCleanup; }
807 res = UpnpAddToAction( &action, "Browse",
808 serviceType, "SortCriteria", SortCriteria );
810 if ( res != UPNP_E_SUCCESS )
813 "%s:%d: ERROR: %s", __FILE__, __LINE__,
814 UpnpGetErrorMessage( res ) );
815 goto browseActionCleanup;
818 res = UpnpSendAction( _p_sd->p_sys->clientHandle,
820 CONTENT_DIRECTORY_SERVICE_TYPE,
825 if ( res != UPNP_E_SUCCESS )
828 "%s:%d: ERROR: %s when trying the send() action with URL: %s",
830 UpnpGetErrorMessage( res ), url );
832 ixmlDocument_free( response );
841 free( StartingIndex );
842 free( RequestedCount );
843 free( SortCriteria );
847 ixmlDocument_free( action );
851 void MediaServer::fetchContents()
853 Container* root = new Container( 0, "0", getFriendlyName() );
854 _fetchContents( root );
859 // playlist_NodeEmpty( p_playlist, _playlistNode, true );
865 _contents->setInputItem( _inputItem );
867 _buildPlaylist( _contents );
870 bool MediaServer::_fetchContents( Container* parent )
875 "%s:%d: parent==NULL", __FILE__, __LINE__ );
879 IXML_Document* response = _browseAction( parent->getObjectID(),
880 "BrowseDirectChildren",
885 "%s:%d: ERROR! No response from browse() action",
886 __FILE__, __LINE__ );
890 IXML_Document* result = parseBrowseResult( response );
891 ixmlDocument_free( response );
896 "%s:%d: ERROR! browse() response parsing failed",
897 __FILE__, __LINE__ );
901 IXML_NodeList* containerNodeList =
902 ixmlDocument_getElementsByTagName( result, "container" );
904 if ( containerNodeList )
906 for ( unsigned int i = 0;
907 i < ixmlNodeList_length( containerNodeList ); i++ )
909 IXML_Element* containerElement =
910 ( IXML_Element* )ixmlNodeList_item( containerNodeList, i );
912 const char* objectID = ixmlElement_getAttribute( containerElement,
917 const char* childCountStr =
918 ixmlElement_getAttribute( containerElement, "childCount" );
920 if ( !childCountStr )
923 int childCount = atoi( childCountStr );
924 const char* title = xml_getChildElementValue( containerElement,
930 const char* resource = xml_getChildElementValue( containerElement,
933 if ( resource && childCount < 1 )
935 Item* item = new Item( parent, objectID, title, resource );
936 parent->addItem( item );
941 Container* container = new Container( parent, objectID, title );
942 parent->addContainer( container );
944 if ( childCount > 0 )
945 _fetchContents( container );
948 ixmlNodeList_free( containerNodeList );
951 IXML_NodeList* itemNodeList = ixmlDocument_getElementsByTagName( result,
955 for ( unsigned int i = 0; i < ixmlNodeList_length( itemNodeList ); i++ )
957 IXML_Element* itemElement =
958 ( IXML_Element* )ixmlNodeList_item( itemNodeList, i );
960 const char* objectID =
961 ixmlElement_getAttribute( itemElement, "id" );
967 xml_getChildElementValue( itemElement, "dc:title" );
972 const char* resource =
973 xml_getChildElementValue( itemElement, "res" );
978 Item* item = new Item( parent, objectID, title, resource );
979 parent->addItem( item );
981 ixmlNodeList_free( itemNodeList );
984 ixmlDocument_free( result );
988 void MediaServer::_buildPlaylist( Container* parent )
990 for ( unsigned int i = 0; i < parent->getNumContainers(); i++ )
992 Container* container = parent->getContainer( i );
994 input_item_t* p_input_item = input_item_New( _p_sd, "vlc://nop", parent->getTitle() );
995 input_item_AddSubItem( parent->getInputItem(), p_input_item );
997 container->setInputItem( p_input_item );
998 _buildPlaylist( container );
1001 for ( unsigned int i = 0; i < parent->getNumItems(); i++ )
1003 Item* item = parent->getItem( i );
1005 input_item_t* p_input_item = input_item_New( _p_sd,
1006 item->getResource(),
1008 assert( p_input_item );
1009 input_item_AddSubItem( parent->getInputItem(), p_input_item );
1010 item->setInputItem( p_input_item );
1014 void MediaServer::setInputItem( input_item_t* p_input_item )
1016 if(_inputItem == p_input_item)
1020 vlc_gc_decref( _inputItem );
1022 vlc_gc_incref( p_input_item );
1023 _inputItem = p_input_item;
1026 bool MediaServer::compareSID( const char* sid )
1028 return ( strncmp( _subscriptionID, sid, sizeof( Upnp_SID ) ) == 0 );
1032 // MediaServerList...
1034 MediaServerList::MediaServerList( services_discovery_t* p_sd )
1039 MediaServerList::~MediaServerList()
1041 for ( unsigned int i = 0; i < _list.size(); i++ )
1047 bool MediaServerList::addServer( MediaServer* s )
1049 input_item_t* p_input_item = NULL;
1050 if ( getServer( s->getUDN() ) != 0 ) return false;
1052 msg_Dbg( _p_sd, "Adding server '%s'",
1053 s->getFriendlyName() );
1055 services_discovery_t* p_sd = _p_sd;
1057 p_input_item = input_item_New( p_sd, "vlc://nop", s->getFriendlyName() );
1058 s->setInputItem( p_input_item );
1060 services_discovery_AddItem( p_sd, p_input_item, NULL );
1062 _list.push_back( s );
1067 MediaServer* MediaServerList::getServer( const char* UDN )
1069 MediaServer* result = 0;
1071 for ( unsigned int i = 0; i < _list.size(); i++ )
1073 if( strcmp( UDN, _list[i]->getUDN() ) == 0 )
1083 MediaServer* MediaServerList::getServerBySID( const char* sid )
1085 MediaServer* server = 0;
1087 for ( unsigned int i = 0; i < _list.size(); i++ )
1089 if ( _list[i]->compareSID( sid ) )
1099 void MediaServerList::removeServer( const char* UDN )
1101 MediaServer* server = getServer( UDN );
1102 if ( !server ) return;
1105 "Removing server '%s'", server->getFriendlyName() );
1107 std::vector<MediaServer*>::iterator it;
1108 for ( it = _list.begin(); it != _list.end(); it++ )
1110 if ( *it == server )
1122 Item::Item( Container* parent, const char* objectID, const char* title, const char* resource )
1126 _objectID = objectID;
1128 _resource = resource;
1136 vlc_gc_decref( _inputItem );
1139 const char* Item::getObjectID() const
1141 return _objectID.c_str();
1144 const char* Item::getTitle() const
1146 return _title.c_str();
1149 const char* Item::getResource() const
1151 return _resource.c_str();
1154 void Item::setInputItem( input_item_t* p_input_item )
1156 if(_inputItem == p_input_item)
1160 vlc_gc_decref( _inputItem );
1162 vlc_gc_incref( p_input_item );
1163 _inputItem = p_input_item;
1166 input_item_t* Item::getInputItem() const
1174 Container::Container( Container* parent,
1175 const char* objectID,
1180 _objectID = objectID;
1186 Container::~Container()
1188 for ( unsigned int i = 0; i < _containers.size(); i++ )
1190 delete _containers[i];
1193 for ( unsigned int i = 0; i < _items.size(); i++ )
1199 vlc_gc_decref( _inputItem );
1202 void Container::addItem( Item* item )
1204 _items.push_back( item );
1207 void Container::addContainer( Container* container )
1209 _containers.push_back( container );
1212 const char* Container::getObjectID() const
1214 return _objectID.c_str();
1217 const char* Container::getTitle() const
1219 return _title.c_str();
1222 unsigned int Container::getNumItems() const
1224 return _items.size();
1227 unsigned int Container::getNumContainers() const
1229 return _containers.size();
1232 Item* Container::getItem( unsigned int i ) const
1234 if ( i < _items.size() ) return _items[i];
1238 Container* Container::getContainer( unsigned int i ) const
1240 if ( i < _containers.size() ) return _containers[i];
1244 Container* Container::getParent()
1249 void Container::setInputItem( input_item_t* p_input_item )
1251 if(_inputItem == p_input_item)
1255 vlc_gc_decref( _inputItem );
1257 vlc_gc_incref( p_input_item );
1258 _inputItem = p_input_item;
1261 input_item_t* Container::getInputItem() const