This was creating confusion, the term session is reserved for the RTP sessions
... | ... |
@@ -20,11 +20,25 @@ loadmodule "nathelper" |
20 | 20 |
loadmodule "rtp_media_server" |
21 | 21 |
modparam("rtp_media_server", "log_file_name", "/tmp/rms_transfer.log") |
22 | 22 |
modparam("tm", "wt_timer", 1000) |
23 |
-listen=udp:147.75.39.121:5090 |
|
23 |
+listen=udp:0.0.0.0:5090 |
|
24 | 24 |
|
25 | 25 |
event_route[rms:start] { |
26 | 26 |
xnotice("[rms:start] play ...\n"); |
27 |
- rms_play("./voice_files/OSR_us_000_0010_8k.wav", "rms:after_play"); |
|
27 |
+ rms_play("/opt/voice_files/OSR_us_000_0010_8k.wav", "rms:after_play"); |
|
28 |
+}; |
|
29 |
+ |
|
30 |
+event_route[rms:bridge] { |
|
31 |
+ $var(target) = "sip:456@localhost:5069;"; |
|
32 |
+ if (!rms_bridge("$var(target)", "rms:bridged")) { |
|
33 |
+ send_reply("604", "server error"); |
|
34 |
+ xerr("rtp_media_server bridge error!\n"); |
|
35 |
+ exit; |
|
36 |
+ } |
|
37 |
+}; |
|
38 |
+ |
|
39 |
+event_route[rms:play_bridge] { |
|
40 |
+ xnotice("[rms:play_bridge] play ...\n"); |
|
41 |
+ rms_play("/opt/voice_files/Bach_10s_8000.wav", "rms:bridge"); |
|
28 | 42 |
}; |
29 | 43 |
|
30 | 44 |
event_route[rms:after_play] { |
... | ... |
@@ -50,7 +64,11 @@ route { |
50 | 64 |
xnotice("[$rm][$ci]\n"); |
51 | 65 |
if (is_method("INVITE") && !has_totag()) { |
52 | 66 |
fix_nated_contact(); |
53 |
- if ($rU == "888") { |
|
67 |
+ |
|
68 |
+ if ($rU == "456") { |
|
69 |
+ rms_answer("rms:play_bridge"); |
|
70 |
+ exit; |
|
71 |
+ } else if ($rU == "888") { |
|
54 | 72 |
$var(target) = "sip:" + $rU + "@8.8.8.8:5069;"; |
55 | 73 |
if (!rms_bridge("$var(target)", "rms:bridged")) { |
56 | 74 |
send_reply("503", "server error"); |
... | ... |
@@ -64,7 +82,7 @@ route { |
64 | 82 |
exit; |
65 | 83 |
} |
66 | 84 |
} |
67 |
- if(rms_session_check()) |
|
85 |
+ if(rms_dialog_check()) |
|
68 | 86 |
rms_sip_request(); |
69 | 87 |
exit; |
70 | 88 |
} |
... | ... |
@@ -109,7 +109,7 @@ modparam("rtp_media_server", "log_file_name", "/var/log/rms/rms_ortp.log") |
109 | 109 |
<section id="rtp_media_server.f.rms_answer"> |
110 | 110 |
<title><varname>rms_answer</varname> (event_route)</title> |
111 | 111 |
<para> |
112 |
- Create a session and a call leg and call the event_route |
|
112 |
+ Create a call leg : with a SIP dialog and an RTP session call the event_route |
|
113 | 113 |
</para> |
114 | 114 |
<para> |
115 | 115 |
This function can be used from REQUEST_ROUTE, REPLY_ROUTE and FAILURE_ROUTE. |
... | ... |
@@ -191,15 +191,15 @@ route { |
191 | 191 |
t_reply("503", "server error"); |
192 | 192 |
} |
193 | 193 |
} |
194 |
- if(rms_session_check()) // If the dialog is managed by the RMS module, the in-dialog request needs to be handled by it. |
|
194 |
+ if(rms_dialog_check()) // If the dialog is managed by the RMS module, the in-dialog request needs to be handled by it. |
|
195 | 195 |
rms_sip_request(); |
196 | 196 |
... |
197 | 197 |
</programlisting></example> |
198 | 198 |
</section> |
199 | 199 |
|
200 | 200 |
|
201 |
- <section id="rtp_media_server.f.rms_session_check"> |
|
202 |
- <title><varname>rms_session_check</varname> ()</title> |
|
201 |
+ <section id="rtp_media_server.f.rms_dialog_check"> |
|
202 |
+ <title><varname>rms_dialog_check</varname> ()</title> |
|
203 | 203 |
<para> |
204 | 204 |
Returns true if the current SIP message it handled/known by |
205 | 205 |
the RMS module, else it may be handle in any other way by |
... | ... |
@@ -209,11 +209,11 @@ route { |
209 | 209 |
This function can be used from REQUEST_ROUTE, REPLY_ROUTE and FAILURE_ROUTE. |
210 | 210 |
</para> |
211 | 211 |
<example> |
212 |
- <title>rms_session_check usage example</title> |
|
212 |
+ <title>rms_dialog_check usage example</title> |
|
213 | 213 |
<programlisting format="linespecific"> |
214 | 214 |
... |
215 |
- if (rms_session_check()) { |
|
216 |
- xnotice("This session is handled by the RMS module\n"); |
|
215 |
+ if (rms_dialog_check()) { |
|
216 |
+ xnotice("This dialog is handled by the RMS module\n"); |
|
217 | 217 |
rms_sip_request(); |
218 | 218 |
} |
219 | 219 |
... |
... | ... |
@@ -228,7 +228,7 @@ route { |
228 | 228 |
will be suspended until the second leg replies. |
229 | 229 |
</para> |
230 | 230 |
<para> |
231 |
- If the SIP session is not found "481 Call/Transaction Does Not Exist" |
|
231 |
+ If the SIP dialog is not found "481 Call/Transaction Does Not Exist" |
|
232 | 232 |
is returned. |
233 | 233 |
</para> |
234 | 234 |
<para> |
... | ... |
@@ -238,7 +238,7 @@ route { |
238 | 238 |
<title>rms_sip_request usage example</title> |
239 | 239 |
<programlisting format="linespecific"> |
240 | 240 |
... |
241 |
- if (rms_session_check()) { |
|
241 |
+ if (rms_dialog_check()) { |
|
242 | 242 |
rms_sip_request(); |
243 | 243 |
} |
244 | 244 |
... |
245 | 245 |
similarity index 72% |
246 | 246 |
rename from src/modules/rtp_media_server/rms_session_info.c |
247 | 247 |
rename to src/modules/rtp_media_server/rms_dialog_info.c |
... | ... |
@@ -19,10 +19,10 @@ |
19 | 19 |
*/ |
20 | 20 |
|
21 | 21 |
#include "rtp_media_server.h" |
22 |
-extern rms_session_info_t *rms_session_list; |
|
22 |
+extern rms_dialog_info_t *rms_dialog_list; |
|
23 | 23 |
extern int in_rms_process; |
24 | 24 |
|
25 |
-static void rms_action_free(rms_session_info_t *si) |
|
25 |
+static void rms_action_free(rms_dialog_info_t *si) |
|
26 | 26 |
{ |
27 | 27 |
rms_action_t *a, *tmp; |
28 | 28 |
clist_foreach(&si->action, a, next) |
... | ... |
@@ -44,25 +44,25 @@ rms_action_t *rms_action_new(rms_action_type_t t) |
44 | 44 |
return a; |
45 | 45 |
} |
46 | 46 |
|
47 |
-int init_rms_session_list() |
|
47 |
+int init_rms_dialog_list() |
|
48 | 48 |
{ |
49 |
- rms_session_list = shm_malloc(sizeof(rms_session_info_t)); |
|
50 |
- if(!rms_session_list) |
|
49 |
+ rms_dialog_list = shm_malloc(sizeof(rms_dialog_info_t)); |
|
50 |
+ if(!rms_dialog_list) |
|
51 | 51 |
return 0; |
52 |
- clist_init(rms_session_list, next, prev); |
|
52 |
+ clist_init(rms_dialog_list, next, prev); |
|
53 | 53 |
return 1; |
54 | 54 |
} |
55 | 55 |
|
56 |
-rms_session_info_t *rms_session_search(struct sip_msg *msg) // str *from_tag) |
|
56 |
+rms_dialog_info_t *rms_dialog_search(struct sip_msg *msg) // str *from_tag) |
|
57 | 57 |
{ |
58 |
- rms_session_info_t *si; |
|
58 |
+ rms_dialog_info_t *si; |
|
59 | 59 |
str callid = msg->callid->body; |
60 | 60 |
if(parse_from_header(msg) < 0) { |
61 | 61 |
LM_ERR("can not parse from header!\n"); |
62 | 62 |
return NULL; |
63 | 63 |
} |
64 | 64 |
struct to_body *from = get_from(msg); |
65 |
- clist_foreach(rms_session_list, si, next) |
|
65 |
+ clist_foreach(rms_dialog_list, si, next) |
|
66 | 66 |
{ |
67 | 67 |
if(strncmp(callid.s, si->callid.s, callid.len) == 0) { |
68 | 68 |
LM_NOTICE("call-id[%s]tag[%s][%s]\n", si->callid.s, si->local_tag.s, |
... | ... |
@@ -84,37 +84,37 @@ rms_session_info_t *rms_session_search(struct sip_msg *msg) // str *from_tag) |
84 | 84 |
return NULL; |
85 | 85 |
} |
86 | 86 |
|
87 |
-rms_session_info_t *rms_session_search_sync(struct sip_msg *msg) |
|
87 |
+rms_dialog_info_t *rms_dialog_search_sync(struct sip_msg *msg) |
|
88 | 88 |
{ |
89 |
- lock(&session_list_mutex); |
|
90 |
- rms_session_info_t *si = rms_session_search(msg); |
|
91 |
- unlock(&session_list_mutex); |
|
89 |
+ lock(&dialog_list_mutex); |
|
90 |
+ rms_dialog_info_t *si = rms_dialog_search(msg); |
|
91 |
+ unlock(&dialog_list_mutex); |
|
92 | 92 |
return si; |
93 | 93 |
} |
94 | 94 |
|
95 |
-void rms_session_add(rms_session_info_t *si) |
|
95 |
+void rms_dialog_add(rms_dialog_info_t *si) |
|
96 | 96 |
{ |
97 | 97 |
if (in_rms_process) { |
98 |
- clist_append(rms_session_list, si, next, prev); |
|
98 |
+ clist_append(rms_dialog_list, si, next, prev); |
|
99 | 99 |
} else { |
100 |
- lock(&session_list_mutex); |
|
101 |
- clist_append(rms_session_list, si, next, prev); |
|
102 |
- unlock(&session_list_mutex); |
|
100 |
+ lock(&dialog_list_mutex); |
|
101 |
+ clist_append(rms_dialog_list, si, next, prev); |
|
102 |
+ unlock(&dialog_list_mutex); |
|
103 | 103 |
} |
104 | 104 |
} |
105 | 105 |
|
106 |
-void rms_session_rm(rms_session_info_t *si) |
|
106 |
+void rms_dialog_rm(rms_dialog_info_t *si) |
|
107 | 107 |
{ |
108 | 108 |
if (in_rms_process) { |
109 |
- clist_append(rms_session_list, si, next, prev); |
|
109 |
+ clist_append(rms_dialog_list, si, next, prev); |
|
110 | 110 |
} else { |
111 |
- lock(&session_list_mutex); |
|
111 |
+ lock(&dialog_list_mutex); |
|
112 | 112 |
clist_rm(si, next, prev); |
113 |
- unlock(&session_list_mutex); |
|
113 |
+ unlock(&dialog_list_mutex); |
|
114 | 114 |
} |
115 | 115 |
} |
116 | 116 |
|
117 |
-int rms_session_free(rms_session_info_t *si) |
|
117 |
+int rms_dialog_free(rms_dialog_info_t *si) |
|
118 | 118 |
{ |
119 | 119 |
rms_action_free(si); |
120 | 120 |
rms_sdp_info_free(&si->sdp_info_offer); |
... | ... |
@@ -157,16 +157,16 @@ int rms_check_msg(struct sip_msg *msg) |
157 | 157 |
return 1; |
158 | 158 |
} |
159 | 159 |
|
160 |
-rms_session_info_t *rms_session_new_bleg(struct sip_msg *msg) |
|
160 |
+rms_dialog_info_t *rms_dialog_new_bleg(struct sip_msg *msg) |
|
161 | 161 |
{ |
162 | 162 |
if(!rms_check_msg(msg)) |
163 | 163 |
return NULL; |
164 |
- rms_session_info_t *si = shm_malloc(sizeof(rms_session_info_t)); |
|
164 |
+ rms_dialog_info_t *si = shm_malloc(sizeof(rms_dialog_info_t)); |
|
165 | 165 |
if(!si) { |
166 |
- LM_ERR("can not allocate session info !\n"); |
|
166 |
+ LM_ERR("can not allocate dialog info !\n"); |
|
167 | 167 |
goto error; |
168 | 168 |
} |
169 |
- memset(si, 0, sizeof(rms_session_info_t)); |
|
169 |
+ memset(si, 0, sizeof(rms_dialog_info_t)); |
|
170 | 170 |
|
171 | 171 |
if(!rms_str_dup(&si->callid, &msg->callid->body, 1)) { |
172 | 172 |
LM_ERR("can not get callid .\n"); |
... | ... |
@@ -182,23 +182,23 @@ rms_session_info_t *rms_session_new_bleg(struct sip_msg *msg) |
182 | 182 |
clist_init(&si->action, next, prev); |
183 | 183 |
return si; |
184 | 184 |
error: |
185 |
- LM_ERR("can not create session.\n"); |
|
186 |
- rms_session_free(si); |
|
185 |
+ LM_ERR("can not create dialog info.\n"); |
|
186 |
+ rms_dialog_free(si); |
|
187 | 187 |
return NULL; |
188 | 188 |
} |
189 | 189 |
|
190 |
-rms_session_info_t *rms_session_new(struct sip_msg *msg) |
|
190 |
+rms_dialog_info_t *rms_dialog_new(struct sip_msg *msg) |
|
191 | 191 |
{ |
192 | 192 |
struct hdr_field *hdr = NULL; |
193 | 193 |
|
194 | 194 |
if(!rms_check_msg(msg)) |
195 | 195 |
return NULL; |
196 |
- rms_session_info_t *si = shm_malloc(sizeof(rms_session_info_t)); |
|
196 |
+ rms_dialog_info_t *si = shm_malloc(sizeof(rms_dialog_info_t)); |
|
197 | 197 |
if(!si) { |
198 |
- LM_ERR("can not allocate session info !\n"); |
|
198 |
+ LM_ERR("can not allocate dialog info !\n"); |
|
199 | 199 |
goto error; |
200 | 200 |
} |
201 |
- memset(si, 0, sizeof(rms_session_info_t)); |
|
201 |
+ memset(si, 0, sizeof(rms_dialog_info_t)); |
|
202 | 202 |
|
203 | 203 |
if(!rms_str_dup(&si->callid, &msg->callid->body, 1)) { |
204 | 204 |
LM_ERR("can not get callid .\n"); |
... | ... |
@@ -233,19 +233,19 @@ rms_session_info_t *rms_session_new(struct sip_msg *msg) |
233 | 233 |
clist_init(&si->action, next, prev); |
234 | 234 |
return si; |
235 | 235 |
error: |
236 |
- LM_ERR("can not create session.\n"); |
|
237 |
- rms_session_free(si); |
|
236 |
+ LM_ERR("can not create dialog info.\n"); |
|
237 |
+ rms_dialog_free(si); |
|
238 | 238 |
return NULL; |
239 | 239 |
} |
240 | 240 |
|
241 |
-int rms_sessions_dump_f(struct sip_msg *msg, char *param1, char *param2) |
|
241 |
+int rms_dialogs_dump_f(struct sip_msg *msg, char *param1, char *param2) |
|
242 | 242 |
{ |
243 | 243 |
int x = 1; |
244 |
- rms_session_info_t *si; |
|
245 |
- clist_foreach(rms_session_list, si, next) |
|
244 |
+ rms_dialog_info_t *di; |
|
245 |
+ clist_foreach(rms_dialog_list, di, next) |
|
246 | 246 |
{ |
247 | 247 |
LM_INFO("[%d]callid[%s]remote_tag[%s]local_tag[%s]cseq[%d]\n", x, |
248 |
- si->callid.s, si->remote_tag.s, si->local_tag.s, si->cseq); |
|
248 |
+ di->callid.s, di->remote_tag.s, di->local_tag.s, di->cseq); |
|
249 | 249 |
x++; |
250 | 250 |
} |
251 | 251 |
return 1; |
252 | 252 |
similarity index 68% |
253 | 253 |
rename from src/modules/rtp_media_server/rms_session_info.h |
254 | 254 |
rename to src/modules/rtp_media_server/rms_dialog_info.h |
... | ... |
@@ -18,12 +18,12 @@ |
18 | 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | 19 |
*/ |
20 | 20 |
|
21 |
-#ifndef rms_session_info_h |
|
22 |
-#define rms_session_info_h |
|
21 |
+#ifndef rms_dialog_info_h |
|
22 |
+#define rms_dialog_info_h |
|
23 | 23 |
// #include "rtp_media_server.h" |
24 | 24 |
#include "rms_media.h" |
25 | 25 |
//typedef struct rms_action rms_action_t; |
26 |
-typedef struct rms_session_info rms_session_info_t; |
|
26 |
+typedef struct rms_dialog_info rms_dialog_info_t; |
|
27 | 27 |
// struct call_leg_media; |
28 | 28 |
// typedef struct call_leg_media call_leg_media_t; |
29 | 29 |
|
... | ... |
@@ -52,22 +52,22 @@ typedef struct rms_action |
52 | 52 |
str route; |
53 | 53 |
rms_action_type_t type; |
54 | 54 |
rms_tm_info_t tm_info; |
55 |
- struct rms_session_info *si; |
|
55 |
+ struct rms_dialog_info *di; |
|
56 | 56 |
struct cell *cell; |
57 | 57 |
} rms_action_t; |
58 | 58 |
|
59 | 59 |
int rms_check_msg(struct sip_msg *msg); |
60 | 60 |
rms_action_t *rms_action_new(rms_action_type_t t); |
61 |
-int init_rms_session_list(); |
|
62 |
-rms_session_info_t *rms_session_search(struct sip_msg *msg); |
|
63 |
-rms_session_info_t *rms_session_search_sync(struct sip_msg *msg); |
|
64 |
-void rms_session_add(rms_session_info_t *si); |
|
65 |
-void rms_session_rm(rms_session_info_t *si); |
|
66 |
-int rms_session_free(rms_session_info_t *si); |
|
67 |
-rms_session_info_t *rms_session_new(struct sip_msg *msg); |
|
68 |
-rms_session_info_t *rms_session_new_bleg(struct sip_msg *msg); |
|
69 |
-int rms_sessions_dump_f(struct sip_msg *msg, char *param1, char *param2); |
|
70 |
-rms_session_info_t *rms_get_session_list(void); |
|
61 |
+int init_rms_dialog_list(); |
|
62 |
+rms_dialog_info_t *rms_dialog_search(struct sip_msg *msg); |
|
63 |
+rms_dialog_info_t *rms_dialog_search_sync(struct sip_msg *msg); |
|
64 |
+void rms_dialog_add(rms_dialog_info_t *di); |
|
65 |
+void rms_dialog_rm(rms_dialog_info_t *di); |
|
66 |
+int rms_dialog_free(rms_dialog_info_t *di); |
|
67 |
+rms_dialog_info_t *rms_dialog_new(struct sip_msg *msg); |
|
68 |
+rms_dialog_info_t *rms_dialog_new_bleg(struct sip_msg *msg); |
|
69 |
+int rms_dialogs_dump_f(struct sip_msg *msg, char *param1, char *param2); |
|
70 |
+rms_dialog_info_t *rms_get_dialog_list(void); |
|
71 | 71 |
|
72 | 72 |
typedef struct ms_res |
73 | 73 |
{ |
... | ... |
@@ -75,18 +75,18 @@ typedef struct ms_res |
75 | 75 |
RtpProfile *rtp_profile; |
76 | 76 |
} ms_res_t; |
77 | 77 |
|
78 |
-typedef enum rms_session_state { |
|
78 |
+typedef enum rms_dialog_state { |
|
79 | 79 |
RMS_ST_DEFAULT, |
80 | 80 |
RMS_ST_CONNECTING, |
81 | 81 |
RMS_ST_CONNECTED, |
82 | 82 |
RMS_ST_DISCONNECTING, |
83 | 83 |
RMS_ST_DISCONNECTED, |
84 |
-} rms_session_state_t; |
|
84 |
+} rms_dialog_state_t; |
|
85 | 85 |
|
86 |
-typedef struct rms_session_info |
|
86 |
+typedef struct rms_dialog_info |
|
87 | 87 |
{ |
88 |
- struct rms_session_info *next; |
|
89 |
- struct rms_session_info *prev; |
|
88 |
+ struct rms_dialog_info *next; |
|
89 |
+ struct rms_dialog_info *prev; |
|
90 | 90 |
rms_sdp_info_t sdp_info_offer; |
91 | 91 |
rms_sdp_info_t sdp_info_answer; |
92 | 92 |
str callid; |
... | ... |
@@ -101,8 +101,8 @@ typedef struct rms_session_info |
101 | 101 |
ms_res_t ms; |
102 | 102 |
call_leg_media_t media; |
103 | 103 |
rms_action_t action; |
104 |
- rms_session_info_t *bridged_si; |
|
105 |
- rms_session_state_t state; |
|
106 |
-} rms_session_info_t; |
|
104 |
+ rms_dialog_info_t *bridged_di; |
|
105 |
+ rms_dialog_state_t state; |
|
106 |
+} rms_dialog_info_t; |
|
107 | 107 |
|
108 | 108 |
#endif |
... | ... |
@@ -194,7 +194,7 @@ int rms_start_media(call_leg_media_t *m, char *file_name) |
194 | 194 |
m->ms_voidsink = ms_factory_create_filter(m->ms_factory, MS_VOID_SINK_ID); |
195 | 195 |
if(!m->ms_voidsink) |
196 | 196 |
goto error; |
197 |
- LM_INFO("m[%p]call-id[%p]\n", m, m->si->callid.s); |
|
197 |
+ LM_INFO("m[%p]call-id[%p]\n", m, m->di->callid.s); |
|
198 | 198 |
|
199 | 199 |
ms_filter_call_method( |
200 | 200 |
m->ms_player, MS_FILTER_SET_OUTPUT_NCHANNELS, &channels); |
... | ... |
@@ -35,8 +35,6 @@ |
35 | 35 |
#include <ortp/port.h> |
36 | 36 |
|
37 | 37 |
#include "rtp_media_server.h" |
38 |
-// #include "rms_session_info.h" |
|
39 |
-// struct rms_session_info; |
|
40 | 38 |
typedef struct rms_action rms_action_t; |
41 | 39 |
|
42 | 40 |
|
... | ... |
@@ -61,7 +59,7 @@ typedef struct call_leg_media |
61 | 59 |
int local_port; |
62 | 60 |
str remote_ip; |
63 | 61 |
int remote_port; |
64 |
- const struct rms_session_info *si; |
|
62 |
+ const struct rms_dialog_info *di; |
|
65 | 63 |
} call_leg_media_t; |
66 | 64 |
|
67 | 65 |
int create_call_leg_media(call_leg_media_t *m); |
... | ... |
@@ -23,7 +23,7 @@ |
23 | 23 |
|
24 | 24 |
MODULE_VERSION |
25 | 25 |
|
26 |
-rms_session_info_t *rms_session_list; |
|
26 |
+rms_dialog_info_t *rms_dialog_list; |
|
27 | 27 |
static int mod_init(void); |
28 | 28 |
static void mod_destroy(void); |
29 | 29 |
static int child_init(int); |
... | ... |
@@ -35,23 +35,23 @@ static char *rms_answer_default_route = "rms:start"; |
35 | 35 |
int in_rms_process; |
36 | 36 |
rms_t *rms; |
37 | 37 |
|
38 |
-static rms_session_info_t *rms_session_create_leg(rms_session_info_t *si, struct sip_msg *msg); |
|
38 |
+static rms_dialog_info_t *rms_dialog_create_leg(rms_dialog_info_t *di, struct sip_msg *msg); |
|
39 | 39 |
static int fixup_rms_action_play(void **param, int param_no); |
40 | 40 |
static int fixup_rms_bridge(void **param, int param_no); |
41 | 41 |
static int fixup_rms_answer(void **param, int param_no); |
42 |
-static int rms_hangup_call(rms_session_info_t *si); |
|
43 |
-static int rms_bridging_call(rms_session_info_t *si, rms_action_t *a); |
|
44 |
-static int rms_bridged_call(rms_session_info_t *si, rms_action_t *a); |
|
42 |
+static int rms_hangup_call(rms_dialog_info_t *di); |
|
43 |
+static int rms_bridging_call(rms_dialog_info_t *di, rms_action_t *a); |
|
44 |
+static int rms_bridged_call(rms_dialog_info_t *di, rms_action_t *a); |
|
45 | 45 |
|
46 | 46 |
static int rms_answer_f(struct sip_msg *, char *); |
47 | 47 |
static int rms_sip_request_f(struct sip_msg *); |
48 | 48 |
static int rms_action_play_f(struct sip_msg *, str *, str *); |
49 |
-static int rms_session_check_f(struct sip_msg *); |
|
49 |
+static int rms_dialog_check_f(struct sip_msg *); |
|
50 | 50 |
static int rms_hangup_f(struct sip_msg *); |
51 | 51 |
static int rms_bridge_f(struct sip_msg *, char *, char *); |
52 | 52 |
|
53 | 53 |
static int rms_update_media_sockets(struct sip_msg *msg, |
54 |
- rms_session_info_t *si, rms_sdp_info_t *sdp_info); |
|
54 |
+ rms_dialog_info_t *di, rms_sdp_info_t *sdp_info); |
|
55 | 55 |
|
56 | 56 |
static cmd_export_t cmds[] = { |
57 | 57 |
{"rms_answer", (cmd_function)rms_answer_f, 1, fixup_rms_answer, 0, EVENT_ROUTE}, |
... | ... |
@@ -59,12 +59,12 @@ static cmd_export_t cmds[] = { |
59 | 59 |
EVENT_ROUTE}, |
60 | 60 |
{"rms_play", (cmd_function)rms_action_play_f, 2, fixup_rms_action_play, |
61 | 61 |
0, ANY_ROUTE}, |
62 |
- {"rms_session_check", (cmd_function)rms_session_check_f, 0, 0, 0, |
|
62 |
+ {"rms_dialog_check", (cmd_function)rms_dialog_check_f, 0, 0, 0, |
|
63 | 63 |
REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE}, |
64 | 64 |
{"rms_hangup", (cmd_function)rms_hangup_f, 0, 0, 0, EVENT_ROUTE}, |
65 | 65 |
{"rms_bridge", (cmd_function)rms_bridge_f, 2, fixup_rms_bridge, 0, |
66 | 66 |
ANY_ROUTE}, |
67 |
- {"rms_sessions_dump", (cmd_function)rms_sessions_dump_f, 0, 0, 0, |
|
67 |
+ {"rms_dialogs_dump", (cmd_function)rms_dialogs_dump_f, 0, 0, 0, |
|
68 | 68 |
ANY_ROUTE}, |
69 | 69 |
{0, 0, 0, 0, 0, 0}}; |
70 | 70 |
|
... | ... |
@@ -77,7 +77,7 @@ struct module_exports exports = { |
77 | 77 |
0, 0, mod_init, child_init, mod_destroy, |
78 | 78 |
}; |
79 | 79 |
|
80 |
-static void run_action_route(rms_session_info_t *si, char *route) |
|
80 |
+static void run_action_route(rms_dialog_info_t *di, char *route) |
|
81 | 81 |
{ |
82 | 82 |
int rt, backup_rt; |
83 | 83 |
struct run_act_ctx ctx; |
... | ... |
@@ -102,24 +102,24 @@ static void run_action_route(rms_session_info_t *si, char *route) |
102 | 102 |
|
103 | 103 |
{ // set the callid |
104 | 104 |
struct hdr_field callid; |
105 |
- callid.body.s = si->callid.s; |
|
106 |
- callid.body.len = si->callid.len; |
|
105 |
+ callid.body.s = di->callid.s; |
|
106 |
+ callid.body.len = di->callid.len; |
|
107 | 107 |
fmsg->callid = &callid; |
108 | 108 |
} |
109 | 109 |
{ // set the from tag |
110 | 110 |
struct hdr_field from; |
111 | 111 |
struct to_body from_parsed; |
112 | 112 |
from.parsed = &from_parsed; |
113 |
- from_parsed.tag_value.len = si->remote_tag.len; |
|
114 |
- from_parsed.tag_value.s = si->remote_tag.s; |
|
113 |
+ from_parsed.tag_value.len = di->remote_tag.len; |
|
114 |
+ from_parsed.tag_value.s = di->remote_tag.s; |
|
115 | 115 |
fmsg->from = &from; |
116 | 116 |
} |
117 | 117 |
//{ // set the to tag |
118 | 118 |
// struct hdr_field to; |
119 | 119 |
// struct to_body to_parsed; |
120 | 120 |
// to.parsed = &to_parsed; |
121 |
- // to_parsed.tag_value.len = si->local_tag.len; |
|
122 |
- // to_parsed.tag_value.s = si->local_tag.s; |
|
121 |
+ // to_parsed.tag_value.len = di->local_tag.len; |
|
122 |
+ // to_parsed.tag_value.s = di->local_tag.s; |
|
123 | 123 |
// fmsg->to = &to; |
124 | 124 |
//} |
125 | 125 |
|
... | ... |
@@ -172,8 +172,8 @@ static int mod_init(void) |
172 | 172 |
rms->udp_last_port = 50000 + rand() % 10000; |
173 | 173 |
rms_media_init(); |
174 | 174 |
|
175 |
- if(!init_rms_session_list()) { |
|
176 |
- LM_ERR("can't initialize rms_session_list !\n"); |
|
175 |
+ if(!init_rms_dialog_list()) { |
|
176 |
+ LM_ERR("can't initialize rms_dialog_list !\n"); |
|
177 | 177 |
return -1; |
178 | 178 |
} |
179 | 179 |
|
... | ... |
@@ -212,71 +212,71 @@ void rms_signal_handler(int signum) |
212 | 212 |
} |
213 | 213 |
|
214 | 214 |
|
215 |
-static rms_session_info_t *rms_stop(rms_session_info_t *si) |
|
215 |
+static rms_dialog_info_t *rms_stop(rms_dialog_info_t *di) |
|
216 | 216 |
{ |
217 |
- LM_NOTICE("si[%p]\n", si); |
|
218 |
- if(si->bridged_si) { |
|
219 |
- rms_stop_bridge(&si->media, &si->bridged_si->media); |
|
217 |
+ LM_NOTICE("di[%p]\n", di); |
|
218 |
+ if(di->bridged_di) { |
|
219 |
+ rms_stop_bridge(&di->media, &di->bridged_di->media); |
|
220 | 220 |
} else { |
221 |
- rms_stop_media(&si->media); |
|
221 |
+ rms_stop_media(&di->media); |
|
222 | 222 |
} |
223 | 223 |
|
224 |
- rms_session_info_t *tmp = si->prev; |
|
225 |
- si->state = RMS_ST_DISCONNECTED; |
|
224 |
+ rms_dialog_info_t *tmp = di->prev; |
|
225 |
+ di->state = RMS_ST_DISCONNECTED; |
|
226 | 226 |
// keep it for a little while to deal with retransmissions ... |
227 |
- //clist_rm(si, next, prev); |
|
228 |
- //rms_session_free(si); |
|
229 |
- si = tmp; |
|
230 |
- return si; |
|
227 |
+ //clist_rm(di, next, prev); |
|
228 |
+ //rms_dialog_free(di); |
|
229 |
+ di = tmp; |
|
230 |
+ return di; |
|
231 | 231 |
} |
232 | 232 |
|
233 |
-static rms_session_info_t *rms_session_action_check(rms_session_info_t *si) |
|
233 |
+static rms_dialog_info_t *rms_dialog_action_check(rms_dialog_info_t *di) |
|
234 | 234 |
{ |
235 | 235 |
rms_action_t *a; |
236 |
- if (!si) |
|
237 |
- LM_ERR("session NULL\n"); |
|
238 |
- clist_foreach(&si->action, a, next) |
|
236 |
+ if (!di) |
|
237 |
+ LM_ERR("Dialog info NULL\n"); |
|
238 |
+ clist_foreach(&di->action, a, next) |
|
239 | 239 |
{ |
240 | 240 |
if (!a) |
241 |
- LM_ERR("session action NULL\n"); |
|
241 |
+ LM_ERR("dialog action NULL\n"); |
|
242 | 242 |
|
243 | 243 |
if(a->type == RMS_HANGUP) { |
244 |
- LM_INFO("session action RMS_HANGUP [%s]\n", si->callid.s); |
|
245 |
- rms_hangup_call(si); |
|
246 |
- if(si->bridged_si) |
|
247 |
- rms_hangup_call(si->bridged_si); |
|
244 |
+ LM_INFO("dialog action RMS_HANGUP [%s]\n", di->callid.s); |
|
245 |
+ rms_hangup_call(di); |
|
246 |
+ if(di->bridged_di) |
|
247 |
+ rms_hangup_call(di->bridged_di); |
|
248 | 248 |
a->type = RMS_STOP; |
249 |
- return si; |
|
249 |
+ return di; |
|
250 | 250 |
} else if(a->type == RMS_BRIDGING) { |
251 |
- LM_INFO("session action RMS_BRIDGING [%s]\n", si->callid.s); |
|
252 |
- rms_bridging_call(si, a); |
|
251 |
+ LM_INFO("dialog action RMS_BRIDGING [%s]\n", di->callid.s); |
|
252 |
+ rms_bridging_call(di, a); |
|
253 | 253 |
a->type = RMS_NONE; |
254 | 254 |
shm_free(a->param.s); |
255 |
- return si; |
|
255 |
+ return di; |
|
256 | 256 |
} else if(a->type == RMS_BRIDGED) { |
257 |
- LM_INFO("session action RMS_BRIDGED [%s]\n", si->callid.s); |
|
258 |
- LM_INFO("si_1[%p]si_2[%p]\n", si, si->bridged_si); |
|
259 |
- rms_bridged_call(si, a); |
|
257 |
+ LM_INFO("dialog action RMS_BRIDGED [%s]\n", di->callid.s); |
|
258 |
+ LM_INFO("di_1[%p]di_2[%p]\n", di, di->bridged_di); |
|
259 |
+ rms_bridged_call(di, a); |
|
260 | 260 |
a->type = RMS_NONE; |
261 |
- return si; |
|
261 |
+ return di; |
|
262 | 262 |
} else if(a->type == RMS_STOP) { |
263 |
- LM_INFO("session action RMS_STOP [%s][%p|%p]\n", si->callid.s, si, |
|
264 |
- si->prev); |
|
265 |
- //if (si->bridged_si) |
|
266 |
- // rms_stop(si->bridged_si); |
|
267 |
- si = rms_stop(si); |
|
263 |
+ LM_INFO("dialog action RMS_STOP [%s][%p|%p]\n", di->callid.s, di, |
|
264 |
+ di->prev); |
|
265 |
+ //if (di->bridged_di) |
|
266 |
+ // rms_stop(di->bridged_di); |
|
267 |
+ di = rms_stop(di); |
|
268 | 268 |
a->type = RMS_NONE; |
269 |
- // si->state = RMS_SSTATE_DISCONNECTED; |
|
270 |
- return si; |
|
269 |
+ // di->state = RMS_SSTATE_DISCONNECTED; |
|
270 |
+ return di; |
|
271 | 271 |
} else if(a->type == RMS_PLAY) { |
272 |
- LM_INFO("session action RMS_PLAY [%s]\n", si->callid.s); |
|
273 |
- rms_playfile(&si->media, a); |
|
272 |
+ LM_INFO("dialog action RMS_PLAY [%s]\n", di->callid.s); |
|
273 |
+ rms_playfile(&di->media, a); |
|
274 | 274 |
a->type = RMS_NONE; |
275 | 275 |
} else if(a->type == RMS_DONE) { |
276 |
- LM_INFO("session action RMS_DONE [%s][%s]\n", si->callid.s, |
|
276 |
+ LM_INFO("dialog action RMS_DONE [%s][%s]\n", di->callid.s, |
|
277 | 277 |
a->route.s); |
278 | 278 |
if(a->route.s) { |
279 |
- run_action_route(si, a->route.s); |
|
279 |
+ run_action_route(di, a->route.s); |
|
280 | 280 |
rms_action_t *tmp = a->prev; |
281 | 281 |
clist_rm(a, next, prev); |
282 | 282 |
shm_free(a); |
... | ... |
@@ -284,41 +284,41 @@ static rms_session_info_t *rms_session_action_check(rms_session_info_t *si) |
284 | 284 |
} else { |
285 | 285 |
a->type = RMS_HANGUP; |
286 | 286 |
} |
287 |
- return si; |
|
287 |
+ return di; |
|
288 | 288 |
} else if(a->type == RMS_START) { |
289 |
- LM_INFO("session action RMS_START\n"); |
|
290 |
- create_call_leg_media(&si->media); |
|
291 |
- LM_INFO("session action RMS_START [%s]\n", si->callid.s); |
|
289 |
+ LM_INFO("dialog action RMS_START\n"); |
|
290 |
+ create_call_leg_media(&di->media); |
|
291 |
+ LM_INFO("dialog action RMS_START [%s]\n", di->callid.s); |
|
292 | 292 |
rms_action_t *tmp = a->prev; |
293 | 293 |
clist_rm(a, next, prev); |
294 |
- rms_start_media(&si->media, a->param.s); |
|
295 |
- run_action_route(si, a->route.s); |
|
294 |
+ rms_start_media(&di->media, a->param.s); |
|
295 |
+ run_action_route(di, a->route.s); |
|
296 | 296 |
shm_free(a); |
297 | 297 |
a = tmp; |
298 |
- LM_INFO("session action RMS_START[done]\n"); |
|
299 |
- return si; |
|
298 |
+ LM_INFO("dialog action RMS_START[done]\n"); |
|
299 |
+ return di; |
|
300 | 300 |
} |
301 | 301 |
} |
302 |
- return si; |
|
302 |
+ return di; |
|
303 | 303 |
} |
304 | 304 |
|
305 | 305 |
/** |
306 |
- * Most interaction with the session and media streams that are controlled |
|
306 |
+ * Most interaction with the RTP sessions and media streams that are controlled |
|
307 | 307 |
* in this function this is safer in the event where a library is using non shared memory |
308 | 308 |
* all the mediastreamer2 ticker threads are spawned from here. |
309 | 309 |
*/ |
310 |
-static void rms_session_manage_loop() |
|
310 |
+static void rms_dialog_manage_loop() |
|
311 | 311 |
{ |
312 | 312 |
in_rms_process = 1; |
313 | 313 |
while(1) { |
314 |
- lock(&session_list_mutex); |
|
315 |
- rms_session_info_t *si; |
|
316 |
- clist_foreach(rms_session_list, si, next) |
|
314 |
+ lock(&dialog_list_mutex); |
|
315 |
+ rms_dialog_info_t *di; |
|
316 |
+ clist_foreach(rms_dialog_list, di, next) |
|
317 | 317 |
{ |
318 |
- si = rms_session_action_check(si); |
|
319 |
- //LM_INFO("next ... si[%p]\n", si); |
|
318 |
+ di = rms_dialog_action_check(di); |
|
319 |
+ //LM_INFO("next ... si[%p]\n", di); |
|
320 | 320 |
} |
321 |
- unlock(&session_list_mutex); |
|
321 |
+ unlock(&dialog_list_mutex); |
|
322 | 322 |
usleep(10000); |
323 | 323 |
} |
324 | 324 |
} |
... | ... |
@@ -345,7 +345,7 @@ static int child_init(int rank) |
345 | 345 |
if(pid < 0) |
346 | 346 |
return -1; |
347 | 347 |
if(pid == 0) { |
348 |
- rms_session_manage_loop(); |
|
348 |
+ rms_dialog_manage_loop(); |
|
349 | 349 |
return 0; |
350 | 350 |
} |
351 | 351 |
} |
... | ... |
@@ -353,23 +353,23 @@ static int child_init(int rank) |
353 | 353 |
return (rtn); |
354 | 354 |
} |
355 | 355 |
|
356 |
-static int parse_from(struct sip_msg *msg, rms_session_info_t *si) |
|
356 |
+static int parse_from(struct sip_msg *msg, rms_dialog_info_t *di) |
|
357 | 357 |
{ |
358 | 358 |
struct to_body *from = get_from(msg); |
359 | 359 |
LM_DBG("from[%.*s]tag[%.*s]\n", from->uri.len, from->uri.s, |
360 | 360 |
from->tag_value.len, from->tag_value.s); |
361 |
- rms_str_dup(&si->remote_tag, &from->tag_value, 1); |
|
361 |
+ rms_str_dup(&di->remote_tag, &from->tag_value, 1); |
|
362 | 362 |
return 1; |
363 | 363 |
} |
364 | 364 |
|
365 | 365 |
static int rms_sip_reply( |
366 |
- struct cell *cell, rms_session_info_t *si, int code, char *_reason) |
|
366 |
+ struct cell *cell, rms_dialog_info_t *di, int code, char *_reason) |
|
367 | 367 |
{ |
368 |
- if (si->state == RMS_ST_CONNECTED) { |
|
368 |
+ if (di->state == RMS_ST_CONNECTED) { |
|
369 | 369 |
return 1; |
370 | 370 |
} |
371 | 371 |
str reason = str_init(_reason); |
372 |
- if(si->remote_tag.len == 0) { |
|
372 |
+ if(di->remote_tag.len == 0) { |
|
373 | 373 |
LM_ERR("can not find from tag\n"); |
374 | 374 |
return 0; |
375 | 375 |
} |
... | ... |
@@ -379,7 +379,7 @@ static int rms_sip_reply( |
379 | 379 |
|
380 | 380 |
if(cell->uas.request) { |
381 | 381 |
if(!tmb.t_reply_with_body( |
382 |
- cell, code, &reason, NULL, NULL, &si->local_tag)) { |
|
382 |
+ cell, code, &reason, NULL, NULL, &di->local_tag)) { |
|
383 | 383 |
LM_ERR("t_reply error"); |
384 | 384 |
return 0; |
385 | 385 |
} |
... | ... |
@@ -390,28 +390,28 @@ static int rms_sip_reply( |
390 | 390 |
} |
391 | 391 |
|
392 | 392 |
static int rms_answer_call( |
393 |
- struct cell *cell, rms_session_info_t *si, rms_sdp_info_t *sdp_info) |
|
393 |
+ struct cell *cell, rms_dialog_info_t *di, rms_sdp_info_t *sdp_info) |
|
394 | 394 |
{ |
395 | 395 |
char buffer[128]; |
396 | 396 |
str reason = str_init("OK"); |
397 | 397 |
str contact_hdr; |
398 |
- if (si->state == RMS_ST_CONNECTED) { |
|
398 |
+ if (di->state == RMS_ST_CONNECTED) { |
|
399 | 399 |
return 1; |
400 | 400 |
} |
401 | 401 |
|
402 | 402 |
LM_INFO("[%s][%d]\n", sdp_info->new_body.s, sdp_info->udp_local_port); |
403 | 403 |
|
404 |
- if(si->remote_tag.len == 0) { |
|
404 |
+ if(di->remote_tag.len == 0) { |
|
405 | 405 |
LM_ERR("can not find from tag\n"); |
406 | 406 |
return 0; |
407 | 407 |
} |
408 |
- LM_INFO("ip[%s]\n", si->local_ip.s); |
|
409 |
- sdp_info->local_ip.s = si->local_ip.s; |
|
410 |
- sdp_info->local_ip.len = si->local_ip.len; |
|
408 |
+ LM_INFO("ip[%s]\n", di->local_ip.s); |
|
409 |
+ sdp_info->local_ip.s = di->local_ip.s; |
|
410 |
+ sdp_info->local_ip.len = di->local_ip.len; |
|
411 | 411 |
|
412 | 412 |
snprintf(buffer, 128, |
413 | 413 |
"Contact: <sip:rms@%s:%d>\r\nContent-Type: application/sdp\r\n", |
414 |
- si->local_ip.s, si->local_port); |
|
414 |
+ di->local_ip.s, di->local_port); |
|
415 | 415 |
contact_hdr.len = strlen(buffer); |
416 | 416 |
contact_hdr.s = buffer; |
417 | 417 |
|
... | ... |
@@ -420,12 +420,12 @@ static int rms_answer_call( |
420 | 420 |
|
421 | 421 |
if(cell->uas.request) { |
422 | 422 |
if(!tmb.t_reply_with_body(cell, 200, &reason, &sdp_info->new_body, |
423 |
- &contact_hdr, &si->local_tag)) { |
|
423 |
+ &contact_hdr, &di->local_tag)) { |
|
424 | 424 |
LM_ERR("t_reply error"); |
425 | 425 |
return 0; |
426 | 426 |
} |
427 | 427 |
LM_INFO("answered\n"); |
428 |
- si->state = RMS_ST_CONNECTED; |
|
428 |
+ di->state = RMS_ST_CONNECTED; |
|
429 | 429 |
} else { |
430 | 430 |
LM_INFO("no request found\n"); |
431 | 431 |
} |
... | ... |
@@ -447,11 +447,11 @@ static void forward_cb(struct cell *ptrans, int ntype, struct tmcb_params *pcbp) |
447 | 447 |
pcbp->code, reason->len, reason->s); |
448 | 448 |
} |
449 | 449 |
|
450 |
- // rms_answer_call(a->cell, si, sdp_info); |
|
450 |
+ // rms_answer_call(a->cell, di, sdp_info); |
|
451 | 451 |
// if(!cell) cell = tmb.t_gett(); |
452 | 452 |
if(a->cell->uas.request) { |
453 | 453 |
if(!tmb.t_reply_with_body(a->cell, pcbp->code, reason, NULL, NULL, |
454 |
- &a->si->local_tag)) { |
|
454 |
+ &a->di->local_tag)) { |
|
455 | 455 |
LM_ERR("t_reply error"); |
456 | 456 |
return; |
457 | 457 |
} |
... | ... |
@@ -470,11 +470,11 @@ static void bridge_cb(struct cell *ptrans, int ntype, struct tmcb_params *pcbp) |
470 | 470 |
if(ntype == TMCB_ON_FAILURE) { |
471 | 471 |
LM_NOTICE("FAILURE [%d]\n", pcbp->code); |
472 | 472 |
rms_action_t *a = (rms_action_t *)*pcbp->param; |
473 |
- a->si->state = RMS_ST_DISCONNECTED; |
|
473 |
+ a->di->state = RMS_ST_DISCONNECTED; |
|
474 | 474 |
if(a->cell->uas.request) { |
475 | 475 |
str *reason = &pcbp->rpl->first_line.u.reply.reason; |
476 | 476 |
if(!tmb.t_reply_with_body(a->cell, pcbp->code, reason, NULL, NULL, |
477 |
- &a->si->local_tag)) { |
|
477 |
+ &a->di->local_tag)) { |
|
478 | 478 |
LM_ERR("t_reply error"); |
479 | 479 |
return; |
480 | 480 |
} |
... | ... |
@@ -506,37 +506,37 @@ static void bridge_cb(struct cell *ptrans, int ntype, struct tmcb_params *pcbp) |
506 | 506 |
struct to_body *from = get_from(msg); |
507 | 507 |
|
508 | 508 |
rms_action_t *a = (rms_action_t *)*pcbp->param; |
509 |
- rms_session_info_t *bridged_si = a->si; |
|
510 |
- rms_session_info_t *si = bridged_si->bridged_si; |
|
509 |
+ rms_dialog_info_t *bridged_di = a->di; |
|
510 |
+ rms_dialog_info_t *di = bridged_di->bridged_di; |
|
511 | 511 |
|
512 | 512 |
if(to->tag_value.len == 0) { |
513 | 513 |
LM_ERR("not to tag.\n"); |
514 | 514 |
goto error; |
515 | 515 |
} else { |
516 |
- rms_str_dup(&si->remote_tag, &to->tag_value, 1); |
|
516 |
+ rms_str_dup(&di->remote_tag, &to->tag_value, 1); |
|
517 | 517 |
} |
518 | 518 |
|
519 | 519 |
if(from->tag_value.len == 0) { |
520 | 520 |
LM_ERR("not from tag.\n"); |
521 | 521 |
goto error; |
522 | 522 |
} else { |
523 |
- rms_str_dup(&si->local_tag, &from->tag_value, 1); |
|
523 |
+ rms_str_dup(&di->local_tag, &from->tag_value, 1); |
|
524 | 524 |
} |
525 | 525 |
|
526 |
- LM_NOTICE("session updated [%s][%s][%s]\n", si->callid.s, si->remote_tag.s, |
|
527 |
- si->local_tag.s); |
|
526 |
+ LM_NOTICE("dialog updated [%s][%s][%s]\n", di->callid.s, di->remote_tag.s, |
|
527 |
+ di->local_tag.s); |
|
528 | 528 |
if (pcbp->code == 180 || pcbp->code == 183) { |
529 | 529 |
return; // early media not tested/handled properly |
530 | 530 |
} |
531 | 531 |
|
532 |
- rms_sdp_info_t *sdp_info = &si->sdp_info_answer; |
|
532 |
+ rms_sdp_info_t *sdp_info = &di->sdp_info_answer; |
|
533 | 533 |
if(!rms_get_sdp_info(sdp_info, msg)) { |
534 | 534 |
LM_ERR("can not get SDP information\n"); |
535 | 535 |
goto error; |
536 | 536 |
} |
537 |
- si->media.pt = rms_sdp_check_payload(sdp_info); |
|
538 |
- rms_update_media_sockets(pcbp->rpl, si, &si->sdp_info_answer); |
|
539 |
- LM_INFO("[%p][%s:%d]\n", si, sdp_info->local_ip.s, |
|
537 |
+ di->media.pt = rms_sdp_check_payload(sdp_info); |
|
538 |
+ rms_update_media_sockets(pcbp->rpl, di, &di->sdp_info_answer); |
|
539 |
+ LM_INFO("[%p][%s:%d]\n", di, sdp_info->local_ip.s, |
|
540 | 540 |
sdp_info->udp_local_port); |
541 | 541 |
a->type = RMS_BRIDGED; |
542 | 542 |
return; |
... | ... |
@@ -545,27 +545,27 @@ error: |
545 | 545 |
} |
546 | 546 |
|
547 | 547 |
|
548 |
-static int rms_bridged_call(rms_session_info_t *si, rms_action_t *a) |
|
548 |
+static int rms_bridged_call(rms_dialog_info_t *di, rms_action_t *a) |
|
549 | 549 |
{ |
550 |
- rms_sdp_info_t *sdp_info = &si->bridged_si->sdp_info_answer; |
|
551 |
- sdp_info->udp_local_port = si->media.local_port; |
|
552 |
- LM_INFO("[%p][%s:%d]\n", si, sdp_info->local_ip.s, |
|
550 |
+ rms_sdp_info_t *sdp_info = &di->bridged_di->sdp_info_answer; |
|
551 |
+ sdp_info->udp_local_port = di->media.local_port; |
|
552 |
+ LM_INFO("[%p][%s:%d]\n", di, sdp_info->local_ip.s, |
|
553 | 553 |
sdp_info->udp_local_port); |
554 |
- sdp_info->local_ip.s = si->local_ip.s; |
|
555 |
- sdp_info->local_ip.len = si->local_ip.len; |
|
556 |
- |
|
557 |
- rms_sdp_prepare_new_body(sdp_info, si->bridged_si->media.pt->type); |
|
558 |
- rms_answer_call(a->cell, si, sdp_info); |
|
559 |
- LM_NOTICE("si_1[%p] si_2[%p]\n", si, si->bridged_si); |
|
560 |
- create_call_leg_media(&si->media); |
|
561 |
- create_call_leg_media(&si->bridged_si->media); |
|
562 |
- // clist_append(rms_session_list, si, next, prev); |
|
563 |
- rms_bridge(&si->media, &si->bridged_si->media); |
|
554 |
+ sdp_info->local_ip.s = di->local_ip.s; |
|
555 |
+ sdp_info->local_ip.len = di->local_ip.len; |
|
556 |
+ |
|
557 |
+ rms_sdp_prepare_new_body(sdp_info, di->bridged_di->media.pt->type); |
|
558 |
+ rms_answer_call(a->cell, di, sdp_info); |
|
559 |
+ LM_NOTICE("si_1[%p] si_2[%p]\n", di, di->bridged_di); |
|
560 |
+ create_call_leg_media(&di->media); |
|
561 |
+ create_call_leg_media(&di->bridged_di->media); |
|
562 |
+ // clist_append(rms_dialog_list, di, next, prev); |
|
563 |
+ rms_bridge(&di->media, &di->bridged_di->media); |
|
564 | 564 |
return 1; |
565 | 565 |
} |
566 | 566 |
|
567 | 567 |
|
568 |
-static int rms_bridging_call(rms_session_info_t *si, rms_action_t *a) |
|
568 |
+static int rms_bridging_call(rms_dialog_info_t *di, rms_action_t *a) |
|
569 | 569 |
{ |
570 | 570 |
uac_req_t uac_r; |
571 | 571 |
int result; |
... | ... |
@@ -579,39 +579,39 @@ static int rms_bridging_call(rms_session_info_t *si, rms_action_t *a) |
579 | 579 |
result = parse_uri(param_uri->s, param_uri->len, &ruri_t); |
580 | 580 |
LM_INFO("parsed[%.*s][%d]\n", param_uri->len, param_uri->s, result); |
581 | 581 |
char buff[1024]; |
582 |
- si->bridged_si->remote_uri.len = snprintf(buff, 1024, |
|
582 |
+ di->bridged_di->remote_uri.len = snprintf(buff, 1024, |
|
583 | 583 |
"<sip:%.*s@%.*s:%.*s>", ruri_t.user.len, ruri_t.user.s, |
584 | 584 |
ruri_t.host.len, ruri_t.host.s, ruri_t.port.len, ruri_t.port.s); |
585 |
- si->bridged_si->remote_uri.s = rms_char_dup(buff, 1); |
|
586 |
- if(!si->bridged_si->remote_uri.s) { |
|
585 |
+ di->bridged_di->remote_uri.s = rms_char_dup(buff, 1); |
|
586 |
+ if(!di->bridged_di->remote_uri.s) { |
|
587 | 587 |
LM_ERR("can not set remote uri !"); |
588 | 588 |
goto error; |
589 | 589 |
} |
590 | 590 |
|
591 | 591 |
snprintf(buff, 256, "Max-Forwards: 70\r\nContact: " |
592 | 592 |
"<sip:rms@%s:%d>\r\nContent-Type: application/sdp\r\n", |
593 |
- si->local_ip.s, si->local_port); |
|
593 |
+ di->local_ip.s, di->local_port); |
|
594 | 594 |
headers.len = strlen(buff); |
595 | 595 |
headers.s = buff; |
596 |
- LM_INFO("si[%p]call-id[%.*s]cseq[%d]ruri[%d|%s]remote_uri[%s]local_uri[%s]\n", si, |
|
597 |
- si->callid.len, si->callid.s, si->bridged_si->cseq, param_uri->len, param_uri->s, |
|
598 |
- si->bridged_si->remote_uri.s, si->bridged_si->local_uri.s); |
|
596 |
+ LM_INFO("si[%p]call-id[%.*s]cseq[%d]ruri[%d|%s]remote_uri[%s]local_uri[%s]\n", di, |
|
597 |
+ di->callid.len, di->callid.s, di->bridged_di->cseq, param_uri->len, param_uri->s, |
|
598 |
+ di->bridged_di->remote_uri.s, di->bridged_di->local_uri.s); |
|
599 | 599 |
dlg_t *dialog = NULL; |
600 |
- if(tmb.new_dlg_uac(&si->bridged_si->callid, &si->bridged_si->local_tag, |
|
601 |
- si->bridged_si->cseq, &si->bridged_si->local_uri, |
|
602 |
- &si->bridged_si->remote_uri, &dialog) |
|
600 |
+ if(tmb.new_dlg_uac(&di->bridged_di->callid, &di->bridged_di->local_tag, |
|
601 |
+ di->bridged_di->cseq, &di->bridged_di->local_uri, |
|
602 |
+ &di->bridged_di->remote_uri, &dialog) |
|
603 | 603 |
< 0) { |
604 | 604 |
LM_ERR("error in tmb.new_dlg_uac\n"); |
605 | 605 |
goto error; |
606 | 606 |
} |
607 | 607 |
dialog->rem_target.s = param_uri->s; |
608 | 608 |
dialog->rem_target.len = param_uri->len - 1; |
609 |
- rms_sdp_info_t *sdp_info = &si->bridged_si->sdp_info_offer; |
|
609 |
+ rms_sdp_info_t *sdp_info = &di->bridged_di->sdp_info_offer; |
|
610 | 610 |
|
611 | 611 |
set_uac_req(&uac_r, &method_invite, &headers, &sdp_info->new_body, dialog, |
612 | 612 |
TMCB_LOCAL_COMPLETED | TMCB_LOCAL_RESPONSE_IN | TMCB_ON_FAILURE, bridge_cb, a); |
613 | 613 |
result = tmb.t_request_within(&uac_r); |
614 |
- si->bridged_si->cseq = dialog->loc_seq.value; |
|
614 |
+ di->bridged_di->cseq = dialog->loc_seq.value; |
|
615 | 615 |
if(result < 0) { |
616 | 616 |
LM_ERR("error in tmb.t_request\n"); |
617 | 617 |
goto error; |
... | ... |
@@ -620,37 +620,37 @@ static int rms_bridging_call(rms_session_info_t *si, rms_action_t *a) |
620 | 620 |
} |
621 | 621 |
return 1; |
622 | 622 |
error: |
623 |
- rms_sip_reply(a->cell, si, 503, "bridging error"); |
|
624 |
- rms_session_free(si->bridged_si); |
|
623 |
+ rms_sip_reply(a->cell, di, 503, "bridging error"); |
|
624 |
+ rms_dialog_free(di->bridged_di); |
|
625 | 625 |
return -1; |
626 | 626 |
} |
627 | 627 |
|
628 |
-static int rms_hangup_call(rms_session_info_t *si) |
|
628 |
+static int rms_hangup_call(rms_dialog_info_t *di) |
|
629 | 629 |
{ |
630 | 630 |
uac_req_t uac_r; |
631 | 631 |
int result; |
632 | 632 |
str headers = str_init("Max-Forwards: 70" CRLF); |
633 | 633 |
str method_bye = str_init("BYE"); |
634 | 634 |
|
635 |
- LM_INFO("si[%p]callid[%.*s]cseq[%d]remote_uri[%s]local_uri[%s]\n", si, si->callid.len, si->callid.s, |
|
636 |
- si->cseq, si->remote_uri.s, si->local_uri.s); |
|
637 |
- LM_INFO("contact[%.*s]\n", si->contact_uri.len, si->contact_uri.s); |
|
635 |
+ LM_INFO("si[%p]callid[%.*s]cseq[%d]remote_uri[%s]local_uri[%s]\n", di, di->callid.len, di->callid.s, |
|
636 |
+ di->cseq, di->remote_uri.s, di->local_uri.s); |
|
637 |
+ LM_INFO("contact[%.*s]\n", di->contact_uri.len, di->contact_uri.s); |
|
638 | 638 |
dlg_t *dialog = NULL; |
639 | 639 |
|
640 |
- if(tmb.new_dlg_uac(&si->callid, &si->local_tag, si->cseq, &si->local_uri, |
|
641 |
- &si->remote_uri, &dialog) |
|
640 |
+ if(tmb.new_dlg_uac(&di->callid, &di->local_tag, di->cseq, &di->local_uri, |
|
641 |
+ &di->remote_uri, &dialog) |
|
642 | 642 |
< 0) { |
643 | 643 |
LM_ERR("error in tmb.new_dlg_uac\n"); |
644 | 644 |
return -1; |
645 | 645 |
} |
646 |
- dialog->id.rem_tag.s = si->remote_tag.s; |
|
647 |
- dialog->id.rem_tag.len = si->remote_tag.len; |
|
648 |
- dialog->rem_target.s = si->contact_uri.s; |
|
649 |
- dialog->rem_target.len = si->contact_uri.len; |
|
646 |
+ dialog->id.rem_tag.s = di->remote_tag.s; |
|
647 |
+ dialog->id.rem_tag.len = di->remote_tag.len; |
|
648 |
+ dialog->rem_target.s = di->contact_uri.s; |
|
649 |
+ dialog->rem_target.len = di->contact_uri.len; |
|
650 | 650 |
set_uac_req(&uac_r, &method_bye, &headers, NULL, dialog, |
651 | 651 |
TMCB_LOCAL_COMPLETED, NULL, NULL); |
652 | 652 |
result = tmb.t_request_within(&uac_r); |
653 |
- si->cseq = dialog->loc_seq.value; |
|
653 |
+ di->cseq = dialog->loc_seq.value; |
|
654 | 654 |
if(result < 0) { |
655 | 655 |
LM_ERR("error in tmb.t_request\n"); |
656 | 656 |
return -1; |
... | ... |
@@ -662,34 +662,34 @@ static int rms_hangup_call(rms_session_info_t *si) |
662 | 662 |
|
663 | 663 |
|
664 | 664 |
/* |
665 |
- * Create a new session info that will be used for bridging |
|
665 |
+ * Create a new dialog info that will be used for bridging |
|
666 | 666 |
*/ |
667 |
-static rms_session_info_t *rms_session_create_leg(rms_session_info_t *si, struct sip_msg *msg) |
|
667 |
+static rms_dialog_info_t *rms_dialog_create_leg(rms_dialog_info_t *di, struct sip_msg *msg) |
|
668 | 668 |
{ |
669 |
- if(!si) |
|
669 |
+ if(!di) |
|
670 | 670 |
return NULL; |
671 |
- si->bridged_si = rms_session_new_bleg(msg); |
|
672 |
- if(!si->bridged_si) { |
|
673 |
- LM_ERR("can not allocate session info !\n"); |
|
671 |
+ di->bridged_di = rms_dialog_new_bleg(msg); |
|
672 |
+ if(!di->bridged_di) { |
|
673 |
+ LM_ERR("can not allocate dialog info !\n"); |
|
674 | 674 |
goto error; |
675 | 675 |
} |
676 |
- memset(si->bridged_si, 0, sizeof(rms_session_info_t)); |
|
677 |
- si->bridged_si->bridged_si = si; |
|
678 |
- if(!rms_str_dup(&si->bridged_si->callid, &si->callid, 1)) { |
|
676 |
+ memset(di->bridged_di, 0, sizeof(rms_dialog_info_t)); |
|
677 |
+ di->bridged_di->bridged_di = di; |
|
678 |
+ if(!rms_str_dup(&di->bridged_di->callid, &di->callid, 1)) { |
|
679 | 679 |
LM_ERR("can not get callid .\n"); |
680 | 680 |
goto error; |
681 | 681 |
} |
682 |
- if(!rms_str_dup(&si->bridged_si->local_uri, &si->local_uri, 1)) |
|
682 |
+ if(!rms_str_dup(&di->bridged_di->local_uri, &di->local_uri, 1)) |
|
683 | 683 |
goto error; |
684 |
- if(!rms_str_dup(&si->bridged_si->local_ip, &si->local_ip, 1)) |
|
684 |
+ if(!rms_str_dup(&di->bridged_di->local_ip, &di->local_ip, 1)) |
|
685 | 685 |
goto error; |
686 | 686 |
|
687 |
- rms_update_media_sockets(msg, si->bridged_si, &si->bridged_si->sdp_info_offer); |
|
688 |
- rms_sdp_prepare_new_body(&si->bridged_si->sdp_info_offer, si->media.pt->type); |
|
689 |
- clist_init(&si->bridged_si->action, next, prev); |
|
690 |
- return si->bridged_si; |
|
687 |
+ rms_update_media_sockets(msg, di->bridged_di, &di->bridged_di->sdp_info_offer); |
|
688 |
+ rms_sdp_prepare_new_body(&di->bridged_di->sdp_info_offer, di->media.pt->type); |
|
689 |
+ clist_init(&di->bridged_di->action, next, prev); |
|
690 |
+ return di->bridged_di; |
|
691 | 691 |
error: |
692 |
- rms_session_free(si); |
|
692 |
+ rms_dialog_free(di); |
|
693 | 693 |
return NULL; |
694 | 694 |
} |
695 | 695 |
|
... | ... |
@@ -707,20 +707,20 @@ static int rms_get_udp_port(void) |
707 | 707 |
|
708 | 708 |
|
709 | 709 |
// update media IP and port |
710 |
-static int rms_update_media_sockets(struct sip_msg *msg, rms_session_info_t *si, rms_sdp_info_t *sdp_info) |
|
710 |
+static int rms_update_media_sockets(struct sip_msg *msg, rms_dialog_info_t *di, rms_sdp_info_t *sdp_info) |
|
711 | 711 |
{ |
712 |
- call_leg_media_t *m = &si->media; |
|
712 |
+ call_leg_media_t *m = &di->media; |
|
713 | 713 |
if(!m->local_port) |
714 | 714 |
m->local_port = rms_get_udp_port(); |
715 | 715 |
sdp_info->udp_local_port = m->local_port; |
716 |
- sdp_info->local_ip.s = si->local_ip.s; |
|
717 |
- sdp_info->local_ip.len = si->local_ip.len; |
|
718 |
- m->local_ip.s = si->local_ip.s; |
|
719 |
- m->local_ip.len = si->local_ip.len; |
|
716 |
+ sdp_info->local_ip.s = di->local_ip.s; |
|
717 |
+ sdp_info->local_ip.len = di->local_ip.len; |
|
718 |
+ m->local_ip.s = di->local_ip.s; |
|
719 |
+ m->local_ip.len = di->local_ip.len; |
|
720 | 720 |
m->remote_port = sdp_info->remote_port; |
721 | 721 |
m->remote_ip.s = sdp_info->remote_ip.s; |
722 | 722 |
m->remote_ip.len = sdp_info->remote_ip.len; |
723 |
- m->si = si; |
|
723 |
+ m->di = di; |
|
724 | 724 |
|
725 | 725 |
LM_INFO("remote_socket[%s:%d] local_socket[%s:%d]\n", |
726 | 726 |
sdp_info->remote_ip.s, sdp_info->remote_port, m->local_ip.s, |
... | ... |
@@ -742,17 +742,17 @@ static int rms_create_trans(struct sip_msg *msg) |
742 | 742 |
return 1; |
743 | 743 |
} |
744 | 744 |
|
745 |
-static void rms_action_add(rms_session_info_t *si, rms_action_t *a) |
|
745 |
+static void rms_action_add(rms_dialog_info_t *di, rms_action_t *a) |
|
746 | 746 |
{ |
747 |
- a->si = si; |
|
748 |
- clist_append(&si->action, a, next, prev); |
|
747 |
+ a->di = di; |
|
748 |
+ clist_append(&di->action, a, next, prev); |
|
749 | 749 |
} |
750 | 750 |
|
751 |
-static void rms_action_add_sync(rms_session_info_t *si, rms_action_t *a) |
|
751 |
+static void rms_action_add_sync(rms_dialog_info_t *di, rms_action_t *a) |
|
752 | 752 |
{ |
753 |
- lock(&session_list_mutex); |
|
754 |
- rms_action_add(si, a); |
|
755 |
- unlock(&session_list_mutex); |
|
753 |
+ lock(&dialog_list_mutex); |
|
754 |
+ rms_action_add(di, a); |
|
755 |
+ unlock(&dialog_list_mutex); |
|
756 | 756 |
} |
757 | 757 |
|
758 | 758 |
// Called when receiving BYE |
... | ... |
@@ -762,14 +762,14 @@ static int rms_disconnect(struct sip_msg *msg) |
762 | 762 |
if(status < 1) |
763 | 763 |
return status; |
764 | 764 |
|
765 |
- rms_session_info_t *si; |
|
765 |
+ rms_dialog_info_t *di; |
|
766 | 766 |
if(!msg || !msg->callid || !msg->callid->body.s) { |
767 | 767 |
LM_ERR("no callid\n"); |
768 | 768 |
return -1; |
769 | 769 |
} |
770 |
- si = rms_session_search_sync(msg); |
|
771 |
- if(!si) { |
|
772 |
- LM_INFO("session not found ci[%.*s]\n", msg->callid->body.len, |
|
770 |
+ di = rms_dialog_search_sync(msg); |
|
771 |
+ if(!di) { |
|
772 |
+ LM_INFO("dialog not found ci[%.*s]\n", msg->callid->body.len, |
|
773 | 773 |
msg->callid->body.s); |
774 | 774 |
if(!tmb.t_reply(msg, 481, "Call/Transaction Does Not Exist")) { |
775 | 775 |
return -1; |
... | ... |
@@ -779,7 +779,7 @@ static int rms_disconnect(struct sip_msg *msg) |
779 | 779 |
rms_action_t *a = rms_action_new(RMS_STOP); |
780 | 780 |
if(!a) |
781 | 781 |
return -1; |
782 |
- rms_action_add_sync(si, a); |
|
782 |
+ rms_action_add_sync(di, a); |
|
783 | 783 |
if(!tmb.t_reply(msg, 200, "OK")) { |
784 | 784 |
return -1; |
785 | 785 |
} |
... | ... |
@@ -787,9 +787,9 @@ static int rms_disconnect(struct sip_msg *msg) |
787 | 787 |
} |
788 | 788 |
|
789 | 789 |
//static int rms_action_dtmf_f(struct sip_msg *msg, char dtmf, str *route) |
790 |
-// rms_session_info_t *si = |
|
791 |
-// rms_session_search(msg); |
|
792 |
-// if(!si) |
|
790 |
+// rms_dialog_info_t *di = |
|
791 |
+// rms_dialog_search(msg); |
|
792 |
+// if(!di) |
|
793 | 793 |
// return -1; |
794 | 794 |
// rms_playfile(); |
795 | 795 |
// return 0; |
... | ... |
@@ -797,12 +797,12 @@ static int rms_disconnect(struct sip_msg *msg) |
797 | 797 |
|
798 | 798 |
static int rms_action_play_f(struct sip_msg *msg, str *playback_fn, str *route) |
799 | 799 |
{ |
800 |
- rms_session_info_t *si = rms_session_search(msg); |
|
801 |
- if(!si) { |
|
800 |
+ rms_dialog_info_t *di = rms_dialog_search(msg); |
|
801 |
+ if(!di) { |
|
802 | 802 |
return -1; |
803 | 803 |
} |
804 |
- LM_INFO("RTP session [%s:%d]<>[%s:%d]\n", si->media.local_ip.s, |
|
805 |
- si->media.local_port, si->media.remote_ip.s, si->media.remote_port); |
|
804 |
+ LM_INFO("RTP session [%s:%d]<>[%s:%d]\n", di->media.local_ip.s, |
|
805 |
+ di->media.local_port, di->media.remote_ip.s, di->media.remote_port); |
|
806 | 806 |
|
807 | 807 |
rms_action_t *a = rms_action_new(RMS_PLAY); |
808 | 808 |
if(!a) |
... | ... |
@@ -811,7 +811,7 @@ static int rms_action_play_f(struct sip_msg *msg, str *playback_fn, str *route) |
811 | 811 |
a->param.s = playback_fn->s; |
812 | 812 |
a->route.len = route->len; |
813 | 813 |
a->route.s = route->s; |
814 |
- rms_action_add(si, a); |
|
814 |
+ rms_action_add(di, a); |
|
815 | 815 |
return 0; |
816 | 816 |
} |
817 | 817 |
|
... | ... |
@@ -819,14 +819,14 @@ static int rms_bridge_f(struct sip_msg *msg, char *_target, char *_route) |
819 | 819 |
{ |
820 | 820 |
str target = {NULL, 0}; |
821 | 821 |
str route = {NULL, 0}; |
822 |
- rms_session_info_t *si = rms_session_search(msg); |
|
822 |
+ rms_dialog_info_t *di = rms_dialog_search(msg); |
|
823 | 823 |
int status = 1; |
824 | 824 |
|
825 | 825 |
if(!rms_check_msg(msg)) |
826 | 826 |
return -1; |
827 | 827 |
|
828 |
- if (si) { |
|
829 |
- if (si->state == RMS_ST_CONNECTED) { |
|
828 |
+ if (di) { |
|
829 |
+ if (di->state == RMS_ST_CONNECTED) { |
|
830 | 830 |
LM_INFO("already connected, bridging\n"); |
831 | 831 |
} else { |
832 | 832 |
LM_ERR("Can not bridge an existing call leg that is not connected.\n"); |
... | ... |
@@ -836,16 +836,16 @@ static int rms_bridge_f(struct sip_msg *msg, char *_target, char *_route) |
836 | 836 |
status = rms_create_trans(msg); |
837 | 837 |
if(status < 1) |
838 | 838 |
return status; |
839 |
- // create a_leg session |
|
840 |
- si = rms_session_new(msg); |
|
841 |
- if(!si) |
|
839 |
+ // create a_leg dialog |
|
840 |
+ di = rms_dialog_new(msg); |
|
841 |
+ if(!di) |
|
842 | 842 |
return -1; |
843 |
- si->local_port = msg->rcv.dst_port; |
|
843 |
+ di->local_port = msg->rcv.dst_port; |
|
844 | 844 |
} |
845 | 845 |
|
846 | 846 |
// parameter 1 : target URI |
847 | 847 |
if(get_str_fparam(&target, msg, (gparam_p)_target) != 0) { |
848 |
- if (si->state != RMS_ST_CONNECTED) { |
|
848 |
+ if (di->state != RMS_ST_CONNECTED) { |
|
849 | 849 |
LM_ERR("rms_bridge: missing target\n"); |
850 | 850 |
tmb.t_reply(msg, 404, "Not found"); |
851 | 851 |
} |
... | ... |
@@ -859,25 +859,25 @@ static int rms_bridge_f(struct sip_msg *msg, char *_target, char *_route) |
859 | 859 |
|
860 | 860 |
LM_NOTICE("rms_bridge[%s][%d]\n", target.s, target.len); |
861 | 861 |
|
862 |
- if (si->state == RMS_ST_DEFAULT) { |
|
862 |
+ if (di->state == RMS_ST_DEFAULT) { |
|
863 | 863 |
str to_tag; |
864 |
- parse_from(msg, si); |
|
864 |
+ parse_from(msg, di); |
|
865 | 865 |
tmb.t_get_reply_totag(msg, &to_tag); |
866 |
- rms_str_dup(&si->local_tag, &to_tag, 1); |
|
867 |
- LM_INFO("local_uri[%s]local_tag[%s]\n", si->local_uri.s, |
|
868 |
- si->local_tag.s); |
|
869 |
- rms_update_media_sockets(msg, si, &si->sdp_info_offer); |
|
866 |
+ rms_str_dup(&di->local_tag, &to_tag, 1); |
|
867 |
+ LM_INFO("local_uri[%s]local_tag[%s]\n", di->local_uri.s, |
|
868 |
+ di->local_tag.s); |
|
869 |
+ rms_update_media_sockets(msg, di, &di->sdp_info_offer); |
|
870 | 870 |
} |
871 | 871 |
// Prepare the body of the SDP offer for the current Payload type |
872 | 872 |
// Both call legs will have the same offer. |
873 |
- LM_NOTICE("payload[%d]\n", si->media.pt->type); |
|
874 |
- rms_sdp_prepare_new_body(&si->sdp_info_offer, si->media.pt->type); |
|
873 |
+ LM_NOTICE("payload[%d]\n", di->media.pt->type); |
|
874 |
+ rms_sdp_prepare_new_body(&di->sdp_info_offer, di->media.pt->type); |
|
875 | 875 |
|
876 | 876 |
// create b_leg |
877 |
- si->bridged_si = rms_session_create_leg(si, msg); |
|
877 |
+ di->bridged_di = rms_dialog_create_leg(di, msg); |
|
878 | 878 |
|
879 |
- if(!si->bridged_si) { |
|
880 |
- LM_ERR("can not create session b_leg !\n"); |
|
879 |
+ if(!di->bridged_di) { |
|
880 |
+ LM_ERR("can not create dialog b_leg !\n"); |
|
881 | 881 |
goto error; |
882 | 882 |
} |
883 | 883 |
|
... | ... |
@@ -893,7 +893,7 @@ static int rms_bridge_f(struct sip_msg *msg, char *_target, char *_route) |
893 | 893 |
a->route.len = route.len; |
894 | 894 |
a->route.s = route.s; |
895 | 895 |
|
896 |
- if (si->state != RMS_ST_CONNECTED) { // a_leg: suspend transaction |
|
896 |
+ if (di->state != RMS_ST_CONNECTED) { // a_leg: suspend transaction |
|
897 | 897 |
a->cell = tmb.t_gett(); |
898 | 898 |
tmb.t_reply(msg, 100, "Trying"); |
899 | 899 |
if(tmb.t_suspend(msg, &a->tm_info.hash_index, &a->tm_info.label) < 0) { |
... | ... |
@@ -905,17 +905,17 @@ static int rms_bridge_f(struct sip_msg *msg, char *_target, char *_route) |
905 | 905 |
a->cell = NULL; |
906 | 906 |
} |
907 | 907 |
LM_INFO("adding action\n"); |
908 |
- rms_action_add(si, a); |
|
908 |
+ rms_action_add(di, a); |
|
909 | 909 |
|
910 |
- LM_INFO("adding b_leg session\n"); |
|
911 |
- rms_session_add(si->bridged_si); |
|
912 |
- LM_INFO("si_1[%p]si_2[%p]\n", si, si->bridged_si); |
|
913 |
- if (si->state != RMS_ST_CONNECTED) |
|
914 |
- rms_session_add(si); |
|
910 |
+ LM_INFO("adding b_leg dialog\n"); |
|
911 |
+ rms_dialog_add(di->bridged_di); |
|
912 |
+ LM_INFO("di_1[%p]di_2[%p]\n", di, di->bridged_di); |
|
913 |
+ if (di->state != RMS_ST_CONNECTED) |
|
914 |
+ rms_dialog_add(di); |
|
915 | 915 |
return 0; |
916 | 916 |
error: |
917 |
- rms_session_rm(si); |
|
918 |
- rms_session_free(si); |
|
917 |
+ rms_dialog_rm(di); |
|
918 |
+ rms_dialog_free(di); |
|
919 | 919 |
return -1; |
920 | 920 |
} |
921 | 921 |
|
... | ... |
@@ -962,7 +962,7 @@ static int rms_sip_cancel(struct sip_msg *msg, str *callid_s, str *cseq_s) |
962 | 962 |
|
963 | 963 |
|
964 | 964 |
static int rms_sip_forward( |
965 |
- rms_session_info_t *si, struct sip_msg *msg, str *method) |
|
965 |
+ rms_dialog_info_t *di, struct sip_msg *msg, str *method) |
|
966 | 966 |
{ |
967 | 967 |
uac_req_t uac_r; |
968 | 968 |
int result; |
... | ... |
@@ -971,20 +971,20 @@ static int rms_sip_forward( |
971 | 971 |
|
972 | 972 |
if(!rms_create_trans(msg)) |
973 | 973 |
return 0; |
974 |
- si->action.cell = tmb.t_gett(); |
|
975 |
- si->action.si = si; |
|
974 |
+ di->action.cell = tmb.t_gett(); |
|
975 |
+ di->action.di = di; |
|
976 | 976 |
|
977 | 977 |
if (strncmp(method->s, "CANCEL", 6) == 0) { |
978 |
- LM_INFO("[CANCEL][%s][%.*s]\n", si->bridged_si->remote_uri.s, si->remote_tag.len, si->remote_tag.s); |
|
978 |
+ LM_INFO("[CANCEL][%s][%.*s]\n", di->bridged_di->remote_uri.s, di->remote_tag.len, di->remote_tag.s); |
|
979 | 979 |
str cseq; |
980 | 980 |
cseq.s = buff; |
981 |
- cseq.len = snprintf(buff, 1024, "%d", si->bridged_si->cseq); |
|
982 |
- rms_sip_cancel(msg, &si->callid, &cseq); |
|
981 |
+ cseq.len = snprintf(buff, 1024, "%d", di->bridged_di->cseq); |
|
982 |
+ rms_sip_cancel(msg, &di->callid, &cseq); |
|
983 | 983 |
return 1; |
984 | 984 |
} |
985 | 985 |
|
986 | 986 |
if(tmb.t_suspend( |
987 |
- msg, &si->action.tm_info.hash_index, &si->action.tm_info.label) |
|
987 |
+ msg, &di->action.tm_info.hash_index, &di->action.tm_info.label) |
|
988 | 988 |
< 0) { |
989 | 989 |
LM_ERR("t_suspend() failed\n"); |
990 | 990 |
return 0; |
... | ... |
@@ -992,33 +992,33 @@ static int rms_sip_forward( |
992 | 992 |
|
993 | 993 |
snprintf(buff, 256, "Max-Forwards: 70\r\nContact: " |
994 | 994 |
"<sip:rms@%s:%d>\r\nContent-Type: application/sdp\r\n", |
995 |
- si->local_ip.s, si->local_port); |
|
995 |
+ di->local_ip.s, di->local_port); |
|
996 | 996 |
headers.len = strlen(buff); |
997 | 997 |
headers.s = buff; |
998 | 998 |
|
999 |
- LM_INFO("si[%p]callid[%.*s]cseq[%d]ruri[%d|%s]remote_uri[%s]local_uri[%s]\n", si, si->callid.len, |
|
1000 |
- si->callid.s, si->bridged_si->cseq, si->bridged_si->contact_uri.len, |
|
1001 |
- si->bridged_si->contact_uri.s, si->bridged_si->remote_uri.s, |
|
1002 |
- si->bridged_si->local_uri.s); |
|
999 |
+ LM_INFO("di[%p]callid[%.*s]cseq[%d]ruri[%d|%s]remote_uri[%s]local_uri[%s]\n", di, di->callid.len, |
|
1000 |
+ di->callid.s, di->bridged_di->cseq, di->bridged_di->contact_uri.len, |
|
1001 |
+ di->bridged_di->contact_uri.s, di->bridged_di->remote_uri.s, |
|
1002 |
+ di->bridged_di->local_uri.s); |
|
1003 | 1003 |
dlg_t *dialog = NULL; |
1004 | 1004 |
|
1005 |
- if(tmb.new_dlg_uac(&si->bridged_si->callid, &si->bridged_si->local_tag, |
|
1006 |
- si->bridged_si->cseq, &si->bridged_si->local_uri, |
|
1007 |
- &si->bridged_si->remote_uri, &dialog) |
|
1005 |
+ if(tmb.new_dlg_uac(&di->bridged_di->callid, &di->bridged_di->local_tag, |
|
1006 |
+ di->bridged_di->cseq, &di->bridged_di->local_uri, |
|
1007 |
+ &di->bridged_di->remote_uri, &dialog) |
|
1008 | 1008 |
< 0) { |
1009 | 1009 |
LM_ERR("error in tmb.new_dlg_uac\n"); |
1010 | 1010 |
goto error; |
1011 | 1011 |
} |
1012 |
- dialog->id.rem_tag.s = si->bridged_si->remote_tag.s; |
|
1013 |
- dialog->id.rem_tag.len = si->bridged_si->remote_tag.len; |
|
1012 |
+ dialog->id.rem_tag.s = di->bridged_di->remote_tag.s; |
|
1013 |
+ dialog->id.rem_tag.len = di->bridged_di->remote_tag.len; |
|
1014 | 1014 |
|
1015 |
- dialog->rem_target.s = si->bridged_si->contact_uri.s; |
|
1016 |
- dialog->rem_target.len = si->bridged_si->contact_uri.len; |
|
1015 |
+ dialog->rem_target.s = di->bridged_di->contact_uri.s; |
|
1016 |
+ dialog->rem_target.len = di->bridged_di->contact_uri.len; |
|
1017 | 1017 |
|
1018 | 1018 |
set_uac_req(&uac_r, method, &headers, NULL, dialog, |
1019 |
- TMCB_LOCAL_COMPLETED | TMCB_ON_FAILURE, forward_cb, &si->action); |
|
1019 |
+ TMCB_LOCAL_COMPLETED | TMCB_ON_FAILURE, forward_cb, &di->action); |
|
1020 | 1020 |
result = tmb.t_request_within(&uac_r); |
1021 |
- si->bridged_si->cseq = dialog->loc_seq.value; |
|
1021 |
+ di->bridged_di->cseq = dialog->loc_seq.value; |
|
1022 | 1022 |
if(result < 0) { |
1023 | 1023 |
LM_ERR("error in tmb.t_request\n"); |
1024 | 1024 |
goto error; |
... | ... |
@@ -1027,7 +1027,7 @@ static int rms_sip_forward( |
1027 | 1027 |
} |
1028 | 1028 |
return 1; |
1029 | 1029 |
error: |
1030 |
- rms_session_free(si->bridged_si); |
|
1030 |
+ rms_dialog_free(di->bridged_di); |
|
1031 | 1031 |
return -1; |
1032 | 1032 |
} |
1033 | 1033 |
|
... | ... |
@@ -1041,10 +1041,10 @@ static int rms_sip_request_f(struct sip_msg *msg) |
1041 | 1041 |
msg->first_line.u.request.method.s); |
1042 | 1042 |
} |
1043 | 1043 |
str *method = &msg->first_line.u.request.method; |
1044 |
- rms_session_info_t *si = rms_session_search_sync(msg); |
|
1045 |
- if(!si) { |
|
1044 |
+ rms_dialog_info_t *di = rms_dialog_search_sync(msg); |
|
1045 |
+ if(!di) { |
|
1046 | 1046 |
rms_create_trans(msg); |
1047 |
- LM_INFO("session not found ci[%.*s]\n", msg->callid->body.len, |
|
1047 |
+ LM_INFO("dialog not found ci[%.*s]\n", msg->callid->body.len, |
|
1048 | 1048 |
msg->callid->body.s); |
1049 | 1049 |
if(!tmb.t_reply(msg, 481, "Call/Transaction Does Not Exist")) { |
1050 | 1050 |
return -1; |
... | ... |
@@ -1052,14 +1052,14 @@ static int rms_sip_request_f(struct sip_msg *msg) |
1052 | 1052 |
return 1; |
1053 | 1053 |
} |
1054 | 1054 |
|
1055 |
- if(si && strncmp(method->s, "BYE", 3) == 0) { |
|
1056 |
- if(si->state == RMS_ST_CONNECTED) |
|
1057 |
- si->state = RMS_ST_DISCONNECTING; |
|
1055 |
+ if(di && strncmp(method->s, "BYE", 3) == 0) { |
|
1056 |
+ if(di->state == RMS_ST_CONNECTED) |
|
1057 |
+ di->state = RMS_ST_DISCONNECTING; |
|
1058 | 1058 |
rms_action_t *a = rms_action_new(RMS_STOP); |
1059 | 1059 |
if(!a) |
1060 | 1060 |
return -1; |
1061 |
- rms_action_add_sync(si, a); |
|
1062 |
- if(si->bridged_si) { // bridged |
|
1061 |
+ rms_action_add_sync(di, a); |
|
1062 |
+ if(di->bridged_di) { // bridged |
|
1063 | 1063 |
LM_NOTICE("BYE in brigde mode\n"); |
1064 | 1064 |
} else { // connected localy |
1065 | 1065 |
LM_NOTICE("BYE in local mode\n"); |
... | ... |
@@ -1068,14 +1068,14 @@ static int rms_sip_request_f(struct sip_msg *msg) |
1068 | 1068 |
} |
1069 | 1069 |
} |
1070 | 1070 |
|