Commit 3eb4e035 authored by Sebastian Ramacher's avatar Sebastian Ramacher Committed by Jean-Baptiste Kempf

upnp: Add support for libupnp 1.8

Callbacks now take const void* as second argument and some members can
only be accessed via getter functions.
Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sramacher@debian.org>
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 34e330d7
......@@ -38,6 +38,30 @@
#include <set>
#include <string>
#if UPNP_VERSION < 10800
/*
* Compat functions and typedefs for libupnp prior to 1.8
*/
typedef Upnp_Discovery UpnpDiscovery;
typedef Upnp_Action_Complete UpnpActionComplete;
static const char* UpnpDiscovery_get_Location_cstr( const UpnpDiscovery* p_discovery )
{
return p_discovery->Location;
}
static const char* UpnpDiscovery_get_DeviceID_cstr( const UpnpDiscovery* p_discovery )
{
return p_discovery->DeviceId;
}
static IXML_Document* UpnpActionComplete_get_ActionResult( const UpnpActionComplete* p_result )
{
return p_result->ActionResult;
}
#endif
/*
* Constants
*/
......@@ -679,19 +703,19 @@ void MediaServerList::removeServer( const std::string& udn )
/*
* Handles servers listing UPnP events
*/
int MediaServerList::Callback( Upnp_EventType event_type, void* p_event )
int MediaServerList::Callback( Upnp_EventType event_type, UpnpEventPtr p_event )
{
switch( event_type )
{
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_SEARCH_RESULT:
{
struct Upnp_Discovery* p_discovery = ( struct Upnp_Discovery* )p_event;
const UpnpDiscovery* p_discovery = ( const UpnpDiscovery* )p_event;
IXML_Document *p_description_doc = NULL;
int i_res;
i_res = UpnpDownloadXmlDoc( p_discovery->Location, &p_description_doc );
i_res = UpnpDownloadXmlDoc( UpnpDiscovery_get_Location_cstr( p_discovery ), &p_description_doc );
MediaServerList *self = UpnpInstanceWrapper::lockMediaServerList();
if ( !self )
......@@ -704,11 +728,11 @@ int MediaServerList::Callback( Upnp_EventType event_type, void* p_event )
{
msg_Warn( self->m_sd, "Could not download device description! "
"Fetching data from %s failed: %s",
p_discovery->Location, UpnpGetErrorMessage( i_res ) );
UpnpDiscovery_get_Location_cstr( p_discovery ), UpnpGetErrorMessage( i_res ) );
UpnpInstanceWrapper::unlockMediaServerList();
return i_res;
}
self->parseNewServer( p_description_doc, p_discovery->Location );
self->parseNewServer( p_description_doc, UpnpDiscovery_get_Location_cstr( p_discovery ) );
UpnpInstanceWrapper::unlockMediaServerList();
ixmlDocument_free( p_description_doc );
}
......@@ -716,11 +740,11 @@ int MediaServerList::Callback( Upnp_EventType event_type, void* p_event )
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
{
struct Upnp_Discovery* p_discovery = ( struct Upnp_Discovery* )p_event;
const UpnpDiscovery* p_discovery = ( const UpnpDiscovery* )p_event;
MediaServerList *self = UpnpInstanceWrapper::lockMediaServerList();
if ( self )
self->removeServer( p_discovery->DeviceId );
self->removeServer( UpnpDiscovery_get_DeviceID_cstr( p_discovery ) );
UpnpInstanceWrapper::unlockMediaServerList();
}
break;
......@@ -953,7 +977,7 @@ void Upnp_i11e_cb::waitAndRelease( void )
}
}
int Upnp_i11e_cb::run( Upnp_EventType eventType, void *p_event, void *p_cookie )
int Upnp_i11e_cb::run( Upnp_EventType eventType, UpnpEventPtr p_event, void *p_cookie )
{
Upnp_i11e_cb *self = static_cast<Upnp_i11e_cb*>( p_cookie );
......@@ -1082,15 +1106,15 @@ bool MediaServer::addItem( IXML_Element* itemElement )
}
int MediaServer::sendActionCb( Upnp_EventType eventType,
void *p_event, void *p_cookie )
UpnpEventPtr p_event, void *p_cookie )
{
if( eventType != UPNP_CONTROL_ACTION_COMPLETE )
return 0;
IXML_Document** pp_sendActionResult = (IXML_Document** )p_cookie;
Upnp_Action_Complete *p_result = (Upnp_Action_Complete *)p_event;
const UpnpActionComplete *p_result = (const UpnpActionComplete *)p_event;
/* The only way to dup the result is to print it and parse it again */
DOMString tmpStr = ixmlPrintNode( ( IXML_Node * ) p_result->ActionResult );
DOMString tmpStr = ixmlPrintNode( ( IXML_Node * ) UpnpActionComplete_get_ActionResult( p_result ) );
if (tmpStr == NULL)
return 0;
......@@ -1616,7 +1640,7 @@ UpnpClient_Handle UpnpInstanceWrapper::handle() const
return m_handle;
}
int UpnpInstanceWrapper::Callback(Upnp_EventType event_type, void *p_event, void *p_user_data)
int UpnpInstanceWrapper::Callback(Upnp_EventType event_type, UpnpEventPtr p_event, void *p_user_data)
{
VLC_UNUSED(p_user_data);
vlc_mutex_lock( &s_lock );
......
......@@ -37,6 +37,12 @@
#include <vlc_common.h>
#include <vlc_url.h>
#if UPNP_VERSION < 10800
typedef void* UpnpEventPtr;
#else
typedef const void* UpnpEventPtr;
#endif
namespace SD
{
class MediaServerList;
......@@ -63,7 +69,7 @@ public:
static void unlockMediaServerList();
private:
static int Callback( Upnp_EventType event_type, void* p_event, void* p_user_data );
static int Callback( Upnp_EventType event_type, UpnpEventPtr p_event, void* p_user_data );
UpnpInstanceWrapper();
~UpnpInstanceWrapper();
......@@ -104,7 +110,7 @@ public:
bool addServer(MediaServerDesc *desc );
void removeServer(const std::string &udn );
MediaServerDesc* getServer( const std::string& udn );
static int Callback( Upnp_EventType event_type, void* p_event );
static int Callback( Upnp_EventType event_type, UpnpEventPtr p_event );
private:
void parseNewServer( IXML_Document* doc, const std::string& location );
......@@ -126,7 +132,7 @@ public:
Upnp_i11e_cb( Upnp_FunPtr callback, void *cookie );
~Upnp_i11e_cb();
void waitAndRelease( void );
static int run( Upnp_EventType, void *, void *);
static int run( Upnp_EventType, UpnpEventPtr, void *);
private:
vlc_sem_t m_sem;
......@@ -152,7 +158,7 @@ private:
IXML_Document* _browseAction(const char*, const char*,
const char*, const char*, const char* );
static int sendActionCb( Upnp_EventType, void *, void *);
static int sendActionCb( Upnp_EventType, UpnpEventPtr, void *);
private:
char* m_psz_root;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment