[vlc-commits] upnp: refactor containers addition
Thomas Guillem
git at videolan.org
Thu May 19 15:57:26 CEST 2016
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue May 3 13:44:05 2016 +0200| [a64f371c97762bf5012a5ad394f57f0381c935f6] | committer: Thomas Guillem
upnp: refactor containers addition
And rename addItem to addContainer.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a64f371c97762bf5012a5ad394f57f0381c935f6
---
modules/services_discovery/upnp.cpp | 30 +++++++++++++-----------------
modules/services_discovery/upnp.hpp | 2 +-
2 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp
index 122c378..02ca710 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -775,20 +775,29 @@ MediaServer::~MediaServer()
free( psz_root_ );
}
-void MediaServer::addItem(const char *objectID, const char *title )
+bool MediaServer::addContainer( IXML_Element* containerElement )
{
char* psz_url;
+ const char* objectID = ixmlElement_getAttribute( containerElement, "id" );
+ if ( !objectID )
+ return false;
+
+ const char* title = xml_getChildElementValue( containerElement, "dc:title" );
+ if ( !title )
+ return false;
+
if( asprintf( &psz_url, "upnp://%s?ObjectID=%s", psz_root_, objectID ) < 0 )
- return;
+ return false;
input_item_t* p_item = input_item_NewDirectory( psz_url, title, ITEM_NET );
free( psz_url);
if ( !p_item )
- return;
+ return false;
input_item_CopyOptions( p_item, node_->p_item );
input_item_node_AppendItem( node_, p_item );
input_item_Release( p_item );
+ return true;
}
int MediaServer::sendActionCb( Upnp_EventType eventType,
@@ -944,20 +953,7 @@ bool MediaServer::fetchContents()
if ( containerNodeList )
{
for ( unsigned int i = 0; i < ixmlNodeList_length( containerNodeList ); i++ )
- {
- IXML_Element* containerElement = (IXML_Element*)ixmlNodeList_item( containerNodeList, i );
-
- const char* objectID = ixmlElement_getAttribute( containerElement,
- "id" );
- if ( !objectID )
- continue;
-
- const char* title = xml_getChildElementValue( containerElement,
- "dc:title" );
- if ( !title )
- continue;
- addItem(objectID, title);
- }
+ addContainer( (IXML_Element*)ixmlNodeList_item( containerNodeList, i ) );
ixmlNodeList_free( containerNodeList );
}
diff --git a/modules/services_discovery/upnp.hpp b/modules/services_discovery/upnp.hpp
index 26593d0..a1cfa97 100644
--- a/modules/services_discovery/upnp.hpp
+++ b/modules/services_discovery/upnp.hpp
@@ -149,7 +149,7 @@ private:
MediaServer(const MediaServer&);
MediaServer& operator=(const MediaServer&);
- void addItem(const char* objectID, const char* title);
+ bool addContainer( IXML_Element* containerElement );
IXML_Document* _browseAction(const char*, const char*,
const char*, const char*, const char* );
More information about the vlc-commits
mailing list