Browse code

- Updated the patch to the latest changes (see previous commit) - removed pre-built rtpproxy

Carsten Bock authored on 30/08/2010 15:17:13
Showing 2 changed files
... ...
@@ -54,10 +54,18 @@ index 54c1a60..1c88b99 100644
54 54
 +AC_SUBST(LIBS_XMLRPC)
55 55
  AC_OUTPUT
56 56
 diff --git a/rtpp_command.c b/rtpp_command.c
57
-index fa342b8..2b3059d 100644
57
+index fa342b8..53c4a40 100644
58 58
 --- a/rtpp_command.c
59 59
 +++ b/rtpp_command.c
60
-@@ -67,6 +67,9 @@ struct proto_cap proto_caps[] = {
60
+@@ -52,6 +52,7 @@
61
+ #include "rtpp_record.h"
62
+ #include "rtpp_session.h"
63
+ #include "rtpp_util.h"
64
++#include "rtpp_notify.h"
65
+ 
66
+ struct proto_cap proto_caps[] = {
67
+     /*
68
+@@ -67,6 +68,9 @@ struct proto_cap proto_caps[] = {
61 69
      { "20081102", "Support for setting codecs in the update/lookup command" },
62 70
      { "20081224", "Support for session timeout notifications" },
63 71
      { "20090810", "Support for automatic bridging" },
... ...
@@ -67,15 +75,17 @@ index fa342b8..2b3059d 100644
67 75
      { NULL, NULL }
68 76
  };
69 77
  
70
-@@ -266,6 +269,7 @@ handle_command(struct cfg *cf, int controlfd, double dtime)
78
+@@ -266,7 +270,9 @@ handle_command(struct cfg *cf, int controlfd, double dtime)
71 79
      int max_argc;
72 80
      char *socket_name_u, *notify_tag;
73 81
      struct sockaddr *local_addr;
74 82
 +    struct rtpp_timeout_handler * my_timeout_h;
75 83
      char c;
84
++    int rtp_timeout_type;
76 85
  
77 86
      requested_nsamples = -1;
78
-@@ -309,6 +313,7 @@ handle_command(struct cfg *cf, int controlfd, double dtime)
87
+     ia[0] = ia[1] = NULL;
88
+@@ -309,6 +315,7 @@ handle_command(struct cfg *cf, int controlfd, double dtime)
79 89
  	    if (++ap >= &argv[10])
80 90
  		break;
81 91
  	}
... ...
@@ -83,13 +93,12 @@ index fa342b8..2b3059d 100644
83 93
      cookie = NULL;
84 94
      if (argc < 1 || (cf->umode != 0 && argc < 2)) {
85 95
  	rtpp_log_write(RTPP_LOG_ERR, cf->glog, "command syntax error");
86
-@@ -459,9 +464,11 @@ handle_command(struct cfg *cf, int controlfd, double dtime)
96
+@@ -459,22 +466,52 @@ handle_command(struct cfg *cf, int controlfd, double dtime)
87 97
      }
88 98
      call_id = argv[1];
89 99
      if (op == UPDATE || op == LOOKUP || op == PLAY) {
90 100
 -	max_argc = (op == UPDATE ? 8 : 6);
91
-+	if (op == UPDATE) max_argc = 8;
92
-+	if (op == LOOKUP) max_argc = 7;
101
++	if (op == UPDATE || op == LOOKUP) max_argc = 9;
93 102
 +	else max_argc = 6;
94 103
  	if (argc < 5 || argc > max_argc) {
95 104
 -	    rtpp_log_write(RTPP_LOG_ERR, cf->glog, "command syntax error");
... ...
@@ -97,26 +106,64 @@ index fa342b8..2b3059d 100644
97 106
  	    reply_error(cf, controlfd, &raddr, rlen, cookie, 4);
98 107
  	    return 0;
99 108
  	}
100
-@@ -469,7 +476,7 @@ handle_command(struct cfg *cf, int controlfd, double dtime)
101
- 	to_tag = argv[5];
109
+ 	from_tag = argv[4];
110
+-	to_tag = argv[5];
111
++	if ((op == UPDATE || op == LOOKUP) && argc > 5)
112
++	    to_tag = argv[5];
102 113
  	if (op == PLAY && argv[0][1] != '\0')
103 114
  	    playcount = atoi(argv[0] + 1);
104 115
 -	if (op == UPDATE && argc > 6) {
116
+-	    socket_name_u = argv[6];
105 117
 +	if ((op == UPDATE || op == LOOKUP) && argc > 6) {
106
- 	    socket_name_u = argv[6];
118
++	    if (argc == 7) {
119
++		// Only the Timeout-Socket is set:
120
++		socket_name_u = argv[6];
121
++		rtp_timeout_type = RTP_TIMEOUT_TYPE_NATIVE;
122
++	    } else {
123
++		notify_tag = 0;
124
++		if (argc == 9) {
125
++		    // 9 Parameters: timeout_type socket notify_tag
126
++		    rtp_timeout_type = atoi(argv[6]);
127
++		    socket_name_u = argv[7];
128
++		    notify_tag = argv[8];
129
++		} else {
130
++		    // 8 Parameters: May be timeout_type socket or socket tag
131
++		    rtp_timeout_type = -1;	
132
++		    for (t = argv[6]; *t != '\0'; t++) {
133
++		        // Parameter 6 is not numerical, lets assume it is std. timeout-socket + tag
134
++		        if (!isdigit(*t)) {
135
++			    socket_name_u = argv[6];
136
++		            rtp_timeout_type = RTP_TIMEOUT_TYPE_NATIVE;
137
++			    notify_tag = argv[7];	
138
++		            break;
139
++		        }
140
++		    }
141
++		    // Param 6 was numeric? So it must be a timeout_type_indicator
142
++		    if (rtp_timeout_type == -1) {
143
++			rtp_timeout_type = atoi(argv[6]);
144
++			socket_name_u = argv[7];
145
++		    }
146
++		}
147
++	    }
107 148
  	    if (strncmp("unix:", socket_name_u, 5) == 0)
108 149
  		socket_name_u += 5;
109
-@@ -924,9 +931,30 @@ handle_command(struct cfg *cf, int controlfd, double dtime)
150
+-	    if (argc == 8) {
151
+-		notify_tag = argv[7];
152
++	    if (notify_tag != 0) {
153
+ 		len = url_unquote((uint8_t *)notify_tag, strlen(notify_tag));
154
+ 		if (len == -1) {
155
+ 		    rtpp_log_write(RTPP_LOG_ERR, cf->glog,
156
+@@ -924,9 +961,29 @@ handle_command(struct cfg *cf, int controlfd, double dtime)
110 157
  	}
111 158
      }
112 159
  
113 160
 -    if (op == UPDATE) {
114 161
 -	if (cf->timeout_handler.socket_name == NULL && socket_name_u != NULL)
162
+-	    rtpp_log_write(RTPP_LOG_ERR, spa->log, "must permit notification socket with -n");
115 163
 +    if (op == UPDATE || op == LOOKUP) {
116 164
 +	if (cf->timeout_handler.socket_name == NULL && socket_name_u != NULL) {
117
-+#ifdef ENABLE_XMLRPC
118
-+	    if (strncmp("http://", socket_name_u, 7) == 0) {
119
-+		rtpp_log_write(RTPP_LOG_INFO, spa->log, "setting Kamailio-timeout handler");
165
++	    if ((rtp_timeout_type > 0) && (rtp_timeout_type <= RTP_TIMEOUT_TYPE_MAX)) {
166
++		rtpp_log_write(RTPP_LOG_INFO, spa->log, "setting custom timeout handler (%d)", rtp_timeout_type);
120 167
 +		my_timeout_h = malloc(sizeof(struct rtpp_timeout_handler));
121 168
 +		if (my_timeout_h == NULL) {
122 169
 +			rtpp_log_write(RTPP_LOG_ERR, spa->log, "Unable to allocate memory");
... ...
@@ -125,6 +172,7 @@ index fa342b8..2b3059d 100644
125 172
 +	    		my_timeout_h->socket_name = (char *)malloc(strlen(socket_name_u) + 1);
126 173
 +	    		if(my_timeout_h->socket_name != NULL) {
127 174
 +				strcpy(my_timeout_h->socket_name, socket_name_u);
175
++				spa->timeout_data.rtp_timeout_type = rtp_timeout_type;
128 176
 +				spa->timeout_data.handler = my_timeout_h;
129 177
 +				spa->timeout_data.notify_tag = 0;
130 178
 +			} else {
... ...
@@ -133,41 +181,43 @@ index fa342b8..2b3059d 100644
133 181
 +			}
134 182
 +		}
135 183
 +	    } else
136
- 	    rtpp_log_write(RTPP_LOG_ERR, spa->log, "must permit notification socket with -n");
137
-+#endif
184
++                rtpp_log_write(RTPP_LOG_ERR, spa->log, "must permit notification socket with -n");
138 185
 +	}
139 186
  	if (spa->timeout_data.notify_tag != NULL) {
140 187
  	    free(spa->timeout_data.notify_tag);
141 188
  	    spa->timeout_data.notify_tag = NULL;
142 189
 diff --git a/rtpp_notify.c b/rtpp_notify.c
143
-index 26bb9a5..9fe6a6d 100644
190
+index 26bb9a5..1553cb4 100644
144 191
 --- a/rtpp_notify.c
145 192
 +++ b/rtpp_notify.c
146
-@@ -39,10 +39,23 @@
193
+@@ -38,11 +38,26 @@
194
+ 
147 195
  #include "rtpp_log.h"
148 196
  #include "rtpp_session.h"
149
- 
197
++#include "rtpp_notify.h"
198
++
150 199
 +#ifdef ENABLE_XMLRPC
151 200
 +#include <xmlrpc.h>
152 201
 +#include <xmlrpc_client.h>
153 202
 +#define XMLRPC_CLIENT_NAME       "XML-RPC RTPProxy Client"
154 203
 +#define XMLRPC_CLIENT_VERSION    "0.1"
155 204
 +#endif
156
-+
205
+ 
157 206
  struct rtpp_notify_wi
158 207
  {
159 208
      char *notify_buf;
160 209
      int len;
210
++    int rtp_timeout_type;
161 211
 +#ifdef ENABLE_XMLRPC
162 212
 +    char *call_id;
163 213
 +    int call_id_len;
164
-+    char *xmlrpc_server;
165
-+    int xmlrpc_server_len;
214
++    char *param;
215
++    int param_len;
166 216
 +#endif
167 217
      struct rtpp_timeout_handler *th;
168 218
      rtpp_log_t glog;
169 219
      struct rtpp_notify_wi *next;
170
-@@ -170,7 +183,7 @@ rtpp_notify_schedule(struct cfg *cf, struct rtpp_session *sp)
220
+@@ -170,7 +185,7 @@ rtpp_notify_schedule(struct cfg *cf, struct rtpp_session *sp)
171 221
      struct rtpp_timeout_handler *th = sp->timeout_data.handler;
172 222
      int len;
173 223
      char *notify_buf;
... ...
@@ -176,7 +226,7 @@ index 26bb9a5..9fe6a6d 100644
176 226
      if (th == NULL) {
177 227
          /* Not an error, just nothing to do */
178 228
          return 0;
179
-@@ -202,8 +215,6 @@ rtpp_notify_schedule(struct cfg *cf, struct rtpp_session *sp)
229
+@@ -202,8 +217,6 @@ rtpp_notify_schedule(struct cfg *cf, struct rtpp_session *sp)
180 230
          }
181 231
          wi->notify_buf = notify_buf;
182 232
      }
... ...
@@ -185,35 +235,36 @@ index 26bb9a5..9fe6a6d 100644
185 235
      if (sp->timeout_data.notify_tag == NULL) {
186 236
          len = snprintf(wi->notify_buf, len, "%d %d\n",
187 237
            sp->ports[0], sp->ports[1]);
188
-@@ -211,6 +222,54 @@ rtpp_notify_schedule(struct cfg *cf, struct rtpp_session *sp)
238
+@@ -211,6 +224,55 @@ rtpp_notify_schedule(struct cfg *cf, struct rtpp_session *sp)
189 239
          len = snprintf(wi->notify_buf, len, "%s\n",
190 240
            sp->timeout_data.notify_tag);
191 241
      }
192 242
 +    wi->len = len;
193 243
 +
194
-+
244
++    // Take RTP-Timeout type
245
++    wi->rtp_timeout_type = sp->timeout_data.rtp_timeout_type;
195 246
 +#ifdef ENABLE_XMLRPC
196
-+    if (strncmp(wi->th->socket_name, "http://", 7) == 0) {
247
++    if (wi->rtp_timeout_type == RTP_TIMEOUT_TYPE_KAMAILIO_XMLRPC) {
197 248
 +	    // Copy the Socket-Name
198 249
 +	    len = strlen(wi->th->socket_name)+1;
199
-+	    if (wi->xmlrpc_server == NULL) {
200
-+		wi->xmlrpc_server = malloc(len);
201
-+		if (wi->xmlrpc_server == NULL) {
250
++	    if (wi->param == NULL) {
251
++		wi->param = malloc(len);
252
++		if (wi->param == NULL) {
202 253
 +		    rtpp_notify_queue_return_free_item(wi);
203 254
 +		    return -1;
204 255
 +		}
205 256
 +	    } else {
206
-+		notify_buf = realloc(wi->xmlrpc_server, len);
257
++		notify_buf = realloc(wi->param, len);
207 258
 +		if (notify_buf == NULL) {
208 259
 +		    rtpp_notify_queue_return_free_item(wi);
209 260
 +		    return -1;
210 261
 +		}
211
-+		wi->xmlrpc_server = notify_buf;
262
++		wi->param = notify_buf;
212 263
 +	    }
213
-+	    memset(wi->xmlrpc_server, '\0', len);
214
-+	    len = snprintf(wi->xmlrpc_server, len, "%s",
264
++	    memset(wi->param, '\0', len);
265
++	    len = snprintf(wi->param, len, "%s",
215 266
 +		  wi->th->socket_name);
216
-+	    wi->xmlrpc_server_len = len;
267
++	    wi->param_len = len;
217 268
 +
218 269
 +	    // Copy the Call-ID:
219 270
 +	    len = strlen(sp->call_id)+1;
... ...
@@ -240,7 +291,7 @@ index 26bb9a5..9fe6a6d 100644
240 291
  
241 292
      wi->glog = cf->glog;
242 293
  
243
-@@ -249,24 +308,63 @@ reconnect_timeout_handler(rtpp_log_t log, struct rtpp_timeout_handler *th)
294
+@@ -249,24 +311,70 @@ reconnect_timeout_handler(rtpp_log_t log, struct rtpp_timeout_handler *th)
244 295
      }
245 296
  }
246 297
  
... ...
@@ -255,7 +306,7 @@ index 26bb9a5..9fe6a6d 100644
255 306
 +    xmlrpc_env_init(&env);
256 307
 +
257 308
 +    /* Get the dialog-Info: */
258
-+    result = xmlrpc_client_call(&env, wi->xmlrpc_server,
309
++    result = xmlrpc_client_call(&env, wi->param,
259 310
 +                                "dlg_terminate_dlg", "(s)",
260 311
 +                                wi->call_id);
261 312
 +    if (env.fault_occurred) {
... ...
@@ -284,12 +335,19 @@ index 26bb9a5..9fe6a6d 100644
284 335
 -        reconnect_timeout_handler(wi->glog, wi->th);
285 336
 -
286 337
 -        /* If connect fails, no notification will be sent */
338
++    if (wi->rtp_timeout_type > 0) {
339
++	switch (wi->rtp_timeout_type) {
287 340
 +#ifdef ENABLE_XMLRPC
288
-+    if (wi->xmlrpc_server_len > 0) {
289
-+	rtpp_log_write(RTPP_LOG_INFO, wi->glog, "Using XML-RPC-Timeout handler (%s)", wi->xmlrpc_server);
290
-+	result = do_xmlrpc_timeout_notification(wi->glog, wi);
291
-+    } else {
341
++		case RTP_TIMEOUT_TYPE_KAMAILIO_XMLRPC:
342
++			rtpp_log_write(RTPP_LOG_INFO, wi->glog, "Using XML-RPC-Timeout handler (%s)", wi->param);
343
++			result = do_xmlrpc_timeout_notification(wi->glog, wi);
344
++			break;
292 345
 +#endif
346
++		default:
347
++			rtpp_log_write(RTPP_LOG_ERR, wi->glog, "Invalid/unsupported timeout handler type (%d)", wi->rtp_timeout_type);
348
++			break;
349
++	}
350
++    } else {
293 351
          if (wi->th->connected == 0) {
294 352
 -            rtpp_log_write(RTPP_LOG_ERR, wi->glog, "unable to send timeout notification");
295 353
 -            return;
... ...
@@ -316,6 +374,21 @@ index 26bb9a5..9fe6a6d 100644
316 374
  
317 375
      if (result < 0) {
318 376
          wi->th->connected = 0;
377
+diff --git a/rtpp_notify.h b/rtpp_notify.h
378
+index 10077a4..3f411cb 100644
379
+--- a/rtpp_notify.h
380
+@@ -31,6 +31,10 @@
381
+ #include "rtpp_defines.h"
382
+ #include "rtpp_session.h"
383
+ 
384
++#define RTP_TIMEOUT_TYPE_NATIVE 0
385
++#define RTP_TIMEOUT_TYPE_KAMAILIO_XMLRPC 1
386
++#define RTP_TIMEOUT_TYPE_MAX 1
387
++
388
+ int rtpp_notify_schedule(struct cfg *, struct rtpp_session *);
389
+ int rtpp_notify_init(void);
390
+ 
319 391
 diff --git a/rtpp_session.c b/rtpp_session.c
320 392
 index 9962cac..b84cdf3 100644
321 393
 --- a/rtpp_session.c
... ...
@@ -335,3 +408,15 @@ index 9962cac..b84cdf3 100644
335 408
      if (sp->timeout_data.notify_tag != NULL)
336 409
  	free(sp->timeout_data.notify_tag);
337 410
      hash_table_remove(cf, sp);
411
+diff --git a/rtpp_session.h b/rtpp_session.h
412
+index 07aa794..9022f12 100644
413
+--- a/rtpp_session.h
414
+@@ -38,6 +38,7 @@
415
+ 
416
+ struct rtpp_timeout_data {
417
+     char *notify_tag;
418
++    int rtp_timeout_type;
419
+     struct rtpp_timeout_handler *handler;
420
+ };
421
+ 
338 422
deleted file mode 100644
339 423
Binary files a/modules_k/rtpproxy/test/rtpproxy.tar.gz and /dev/null differ