aboutsummaryrefslogtreecommitdiff
path: root/multimedia/vlc/patch-libupnp.diff
blob: 2e0580b810be196cadf9a631af85b4255f866208 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
From 3eb4e03512f45c1fa27c7f9a6759e8e7d3905720 Mon Sep 17 00:00:00 2001
From: Sebastian Ramacher <sramacher@debian.org>
Date: Tue, 29 Aug 2017 23:10:15 +0200
Subject: [PATCH 1/1] 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 <sramacher@debian.org>
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
---
 modules/services_discovery/upnp.cpp | 48 +++++++++++++++++++++++++++----------
 modules/services_discovery/upnp.hpp | 14 +++++++----
 2 files changed, 46 insertions(+), 16 deletions(-)

diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp
index c21b2b1e37..bdd3c55ee5 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -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 );
diff --git a/modules/services_discovery/upnp.hpp b/modules/services_discovery/upnp.hpp
index 033e191aea..39e19cbd56 100644
--- a/modules/services_discovery/upnp.hpp
+++ b/modules/services_discovery/upnp.hpp
@@ -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;
-- 
2.11.0