sip-lab 1.18.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +1 -1
- package/build_deps.sh +3 -3
- package/package.json +1 -1
- package/prebuilds/linux-x64/sip-lab.node +0 -0
- package/samples/100_calls.js +1 -1
- package/samples/multiple_audio_streams.js +183 -0
- package/src/event_templates.cpp +4 -4
- package/src/pjmedia/src/pjmedia/fax_port.c +1 -1
- package/src/sip.cpp +68 -118
package/binding.gyp
CHANGED
package/build_deps.sh
CHANGED
|
@@ -74,10 +74,10 @@ fi
|
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
cd $START_DIR/3rdParty
|
|
77
|
-
if [[ ! -d
|
|
77
|
+
if [[ ! -d boost_1_66_0 ]]
|
|
78
78
|
then
|
|
79
|
-
wget
|
|
80
|
-
tar xf
|
|
79
|
+
wget https://downloads.sourceforge.net/project/boost/boost/1.66.0/boost_1_66_0.tar.bz2
|
|
80
|
+
tar xf boost_1_66_0.tar.bz2
|
|
81
81
|
fi
|
|
82
82
|
|
|
83
83
|
|
package/package.json
CHANGED
|
Binary file
|
package/samples/100_calls.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This test creates
|
|
1
|
+
// This test creates 100 caller UDP SIP endpoints, 100 callee UDP SIP endpoines and makes one call between them, test dtmf and disconnects.
|
|
2
2
|
|
|
3
3
|
const sip = require ('../index.js')
|
|
4
4
|
const Zeq = require('@mayama/zeq')
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
const sip = require ('../index.js')
|
|
2
|
+
const Zeq = require('@mayama/zeq')
|
|
3
|
+
const m = require('data-matching')
|
|
4
|
+
const sip_msg = require('sip-matching')
|
|
5
|
+
const _ = require('lodash')
|
|
6
|
+
|
|
7
|
+
// here we create our Zeq instance
|
|
8
|
+
var z = new Zeq()
|
|
9
|
+
|
|
10
|
+
// here we are restricting codec to PCMU to avoid having the SDP to become too large
|
|
11
|
+
sip.set_codecs('pcmu/8000/1:128')
|
|
12
|
+
|
|
13
|
+
// here we asking for accumulated DTMF to be reported in case of no more digits after 500 ms
|
|
14
|
+
sip.dtmf_aggregation_on(500)
|
|
15
|
+
|
|
16
|
+
async function test() {
|
|
17
|
+
// here we set our Zeq instance to trap events generated by sip-lab event_source
|
|
18
|
+
z.trap_events(sip.event_source, 'event', (evt) => {
|
|
19
|
+
var e = evt.args[0]
|
|
20
|
+
return e
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
// here we start sip-lab
|
|
24
|
+
console.log(sip.start((data) => { console.log(data)} ))
|
|
25
|
+
|
|
26
|
+
// Here we create the SIP endpoints (transports).
|
|
27
|
+
// Since we don't specify the port, an available port will be allocated.
|
|
28
|
+
// Since we don't specify the type ('udp' or 'tcp' or 'tls'), 'udp' will be used by default.
|
|
29
|
+
const t1 = sip.transport.create({address: "127.0.0.1", type: 'tcp'})
|
|
30
|
+
const t2 = sip.transport.create({address: "127.0.0.1", type: 'tcp'})
|
|
31
|
+
|
|
32
|
+
// here we just print the transports
|
|
33
|
+
console.log("t1", t1)
|
|
34
|
+
console.log("t2", t2)
|
|
35
|
+
|
|
36
|
+
const NUM_AUDIO_STREAMS = 8
|
|
37
|
+
const media = new Array(NUM_AUDIO_STREAMS).fill('audio').join(',')
|
|
38
|
+
|
|
39
|
+
const oc = sip.call.create(t1.id, {from_uri: 'sip:alice@test.com', to_uri: `sip:bob@${t2.address}:${t2.port}`, media: media})
|
|
40
|
+
|
|
41
|
+
// Here we will wait for the call to arrive at t2
|
|
42
|
+
// We will also get a '100 Trying' that is sent by sip-lab automatically
|
|
43
|
+
// We will wait for at most 1000ms. If all events don't arrive within 1000ms, an exception will be thrown and the test will fail due to timeout.
|
|
44
|
+
await z.wait([
|
|
45
|
+
{
|
|
46
|
+
event: "incoming_call",
|
|
47
|
+
call_id: m.collect("call_id"),
|
|
48
|
+
transport_id: t2.id,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
event: 'response',
|
|
52
|
+
call_id: oc.id,
|
|
53
|
+
method: 'INVITE',
|
|
54
|
+
msg: sip_msg({
|
|
55
|
+
$rs: '100',
|
|
56
|
+
$rr: 'Trying',
|
|
57
|
+
'$(hdrcnt(via))': 1,
|
|
58
|
+
'$hdr(call-id)': m.collect('sip_call_id'),
|
|
59
|
+
$fU: 'alice',
|
|
60
|
+
$fd: 'test.com',
|
|
61
|
+
$tU: 'bob',
|
|
62
|
+
'$hdr(l)': '0',
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
65
|
+
], 1000)
|
|
66
|
+
// Details about zeq wait(list_of_events_to_wait_for, timeout_in_ms):
|
|
67
|
+
// The order of events in the list is irrelevant.
|
|
68
|
+
// What matters is that all events arrive within the specified timeout.
|
|
69
|
+
// When specifying events, you can be as detailed or succinct as you need.
|
|
70
|
+
// For example, the above event 'response' is waiting for a SIP '100 Trying' to arrive,
|
|
71
|
+
// but we are specifying things to match just to show that we can be very detailed when performing a match.
|
|
72
|
+
// But it could have been just like this:
|
|
73
|
+
//
|
|
74
|
+
// {
|
|
75
|
+
// event: 'response',
|
|
76
|
+
// call_id: oc.id,
|
|
77
|
+
// method: 'INVITE',
|
|
78
|
+
// msg: sip_msg({
|
|
79
|
+
// $rs: '100',
|
|
80
|
+
// }),
|
|
81
|
+
// }
|
|
82
|
+
// Regarding the function sip_msg() this is a special matching function provided by https://github.com/MayamaTakeshi/sip-matching that makes it
|
|
83
|
+
// easy to match a SIP message using openser/kamailio/opensips pseudo-variables syntax.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
// Here we store data for the incoming call
|
|
87
|
+
// just to organize our code (not really needed)
|
|
88
|
+
const ic = {
|
|
89
|
+
id: z.store.call_id,
|
|
90
|
+
sip_call_id: z.store.sip_call_id,
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Now we answer the call at t2 side and accept all 2 streams
|
|
94
|
+
sip.call.respond(ic.id, {code: 200, reason: 'OK', media: media})
|
|
95
|
+
|
|
96
|
+
// Then we wait for the '200 OK' at the t1 side
|
|
97
|
+
// We will also get event 'media_update' for both sides indicating media streams (RTP) were set up successfully
|
|
98
|
+
await z.wait([
|
|
99
|
+
{
|
|
100
|
+
event: 'response',
|
|
101
|
+
call_id: oc.id,
|
|
102
|
+
method: 'INVITE',
|
|
103
|
+
msg: sip_msg({
|
|
104
|
+
$rs: '200',
|
|
105
|
+
$rr: 'OK',
|
|
106
|
+
'$(hdrcnt(VIA))': 1,
|
|
107
|
+
$fU: 'alice',
|
|
108
|
+
$fd: 'test.com',
|
|
109
|
+
$tU: 'bob',
|
|
110
|
+
'$hdr(content-type)': 'application/sdp',
|
|
111
|
+
$rb: '!{_}a=sendrecv',
|
|
112
|
+
}),
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
event: 'media_update',
|
|
116
|
+
call_id: oc.id,
|
|
117
|
+
status: 'ok',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
event: 'media_update',
|
|
121
|
+
call_id: ic.id,
|
|
122
|
+
status: 'ok',
|
|
123
|
+
},
|
|
124
|
+
], 1000)
|
|
125
|
+
|
|
126
|
+
sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
|
|
127
|
+
|
|
128
|
+
await z.wait(_.chain(_.range(NUM_AUDIO_STREAMS)).map(n => ({
|
|
129
|
+
event: 'dtmf',
|
|
130
|
+
call_id: ic.id,
|
|
131
|
+
digits: '1234',
|
|
132
|
+
mode: 0,
|
|
133
|
+
media_id: n,
|
|
134
|
+
})).value(), 3000)
|
|
135
|
+
|
|
136
|
+
sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1})
|
|
137
|
+
|
|
138
|
+
await z.wait(_.chain(_.range(NUM_AUDIO_STREAMS)).map(n => ({
|
|
139
|
+
event: 'dtmf',
|
|
140
|
+
call_id: oc.id,
|
|
141
|
+
digits: '4321',
|
|
142
|
+
mode: 1,
|
|
143
|
+
media_id: n,
|
|
144
|
+
})).value(), 3000)
|
|
145
|
+
|
|
146
|
+
// now we terminate the call from t1 side
|
|
147
|
+
sip.call.terminate(oc.id)
|
|
148
|
+
|
|
149
|
+
// and wait for termination events
|
|
150
|
+
await z.wait([
|
|
151
|
+
{
|
|
152
|
+
event: 'response',
|
|
153
|
+
call_id: oc.id,
|
|
154
|
+
method: 'BYE',
|
|
155
|
+
msg: sip_msg({
|
|
156
|
+
$rs: '200',
|
|
157
|
+
$rr: 'OK',
|
|
158
|
+
}),
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
event: 'call_ended',
|
|
162
|
+
call_id: oc.id,
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
event: 'call_ended',
|
|
166
|
+
call_id: ic.id,
|
|
167
|
+
},
|
|
168
|
+
], 1000)
|
|
169
|
+
|
|
170
|
+
await z.sleep(100) // wait for any unexpected events
|
|
171
|
+
|
|
172
|
+
console.log("Success")
|
|
173
|
+
|
|
174
|
+
sip.stop()
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
test()
|
|
179
|
+
.catch(e => {
|
|
180
|
+
console.error(e)
|
|
181
|
+
process.exit(1)
|
|
182
|
+
})
|
|
183
|
+
|
package/src/event_templates.cpp
CHANGED
|
@@ -49,7 +49,7 @@ int make_evt_dtmf(char *dest, int size, long call_id, int digits_len,
|
|
|
49
49
|
|
|
50
50
|
int make_evt_call_ended(char *dest, int size, long call_id, int sip_msg_len,
|
|
51
51
|
const char *sip_msg) {
|
|
52
|
-
printf("make_evt_call_ended sip_msg_len=%i sip_msg=%
|
|
52
|
+
printf("make_evt_call_ended sip_msg_len=%i sip_msg=%s\n", sip_msg_len,
|
|
53
53
|
sip_msg);
|
|
54
54
|
if (!sip_msg || sip_msg == (char *)0xc000000000000) {
|
|
55
55
|
// received invalid pointer to sip_msg so do not add the message to the
|
|
@@ -72,8 +72,8 @@ int make_evt_non_dialog_request(char *dest, int size, long transport_id,
|
|
|
72
72
|
long request_id, int sip_msg_len,
|
|
73
73
|
const char *sip_msg) {
|
|
74
74
|
return snprintf(dest, size,
|
|
75
|
-
"{\"event\": \"non_dialog_request\", \"request_id\": %
|
|
76
|
-
"\"transport_id\": %
|
|
75
|
+
"{\"event\": \"non_dialog_request\", \"request_id\": %li, "
|
|
76
|
+
"\"transport_id\": %li}\n%.*s",
|
|
77
77
|
request_id, transport_id, sip_msg_len, sip_msg);
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -85,7 +85,7 @@ int make_evt_internal_error(char *dest, int size, const char *msg) {
|
|
|
85
85
|
int make_evt_reinvite(char *dest, int size, long call_id, int sip_msg_len,
|
|
86
86
|
char *sip_msg) {
|
|
87
87
|
return snprintf(dest, size,
|
|
88
|
-
"{\"event\": \"reinvite\", \"call_id\": %
|
|
88
|
+
"{\"event\": \"reinvite\", \"call_id\": %li}\n%.*s", call_id,
|
|
89
89
|
sip_msg_len, sip_msg);
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -205,7 +205,7 @@ static pj_status_t fax_get_frame(pjmedia_port *this_port,
|
|
|
205
205
|
//printf("ENTER fax_get_frame frame_size=%i\n", frame->size);
|
|
206
206
|
|
|
207
207
|
PJ_ASSERT_RETURN(this_port && frame, PJ_EINVAL);
|
|
208
|
-
char *p = (char*)frame->buf;
|
|
208
|
+
//char *p = (char*)frame->buf; // TODO: remove
|
|
209
209
|
|
|
210
210
|
struct fax_device *fd = (struct fax_device*)this_port;
|
|
211
211
|
pj_lock_acquire(fd->lock);
|
package/src/sip.cpp
CHANGED
|
@@ -223,10 +223,10 @@ bool json_get_and_check_uri(Document &document, const char *param,
|
|
|
223
223
|
return true;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
static pjsip_method info_method = {PJSIP_OTHER_METHOD, {"INFO", 4}};
|
|
227
|
-
static pjsip_method message_method = {PJSIP_OTHER_METHOD, {"MESSAGE", 7}};
|
|
226
|
+
static pjsip_method info_method = {PJSIP_OTHER_METHOD, {(char*)"INFO", 4}};
|
|
227
|
+
static pjsip_method message_method = {PJSIP_OTHER_METHOD, {(char*)"MESSAGE", 7}};
|
|
228
228
|
|
|
229
|
-
static pj_str_t trying_reason = pj_str("Trying");
|
|
229
|
+
static pj_str_t trying_reason = pj_str((char*)"Trying");
|
|
230
230
|
|
|
231
231
|
#define PJW_LOCK() pthread_mutex_lock(&g_mutex)
|
|
232
232
|
#define PJW_UNLOCK() pthread_mutex_unlock(&g_mutex)
|
|
@@ -531,8 +531,8 @@ static void on_dtmf(pjmedia_stream *stream, void *user_data, int digit);
|
|
|
531
531
|
/* Callback for Registration Status */
|
|
532
532
|
static void on_registration_status(pjsip_regc_cbparam *param);
|
|
533
533
|
|
|
534
|
-
static void on_tsx_state_changed(pjsip_inv_session *inv, pjsip_transaction *tsx,
|
|
535
|
-
pjsip_event *e);
|
|
534
|
+
/* static void on_tsx_state_changed(pjsip_inv_session *inv, pjsip_transaction *tsx,
|
|
535
|
+
pjsip_event *e); */
|
|
536
536
|
|
|
537
537
|
static void client_on_evsub_state(pjsip_evsub *sub, pjsip_event *event);
|
|
538
538
|
static void on_client_refresh(pjsip_evsub *sub);
|
|
@@ -935,9 +935,6 @@ static pj_bool_t on_data_read(pj_activesock_t *asock, void *data,
|
|
|
935
935
|
return PJ_FALSE;
|
|
936
936
|
}
|
|
937
937
|
|
|
938
|
-
assert(ud->len >= 0);
|
|
939
|
-
|
|
940
|
-
assert(size >= 0);
|
|
941
938
|
assert(size + ud->len + 1 < MAX_TCP_DATA);
|
|
942
939
|
|
|
943
940
|
memcpy(&ud->buf[ud->len], data, size);
|
|
@@ -971,7 +968,7 @@ static pj_bool_t on_data_read(pj_activesock_t *asock, void *data,
|
|
|
971
968
|
assert(body_len > 0 && body_len < 4096);
|
|
972
969
|
|
|
973
970
|
if(ud->buf+ud->len < sep+4+body_len) {
|
|
974
|
-
printf("tcp data: msg incomplete %i %i\n", ud->buf+ud->len, sep+4+body_len);
|
|
971
|
+
//printf("tcp data: msg incomplete %i %i\n", ud->buf+ud->len, sep+4+body_len);
|
|
975
972
|
*remainder = 0;
|
|
976
973
|
return PJ_TRUE;
|
|
977
974
|
}
|
|
@@ -1101,17 +1098,14 @@ static pj_bool_t on_connect_complete(pj_activesock_t *asock,
|
|
|
1101
1098
|
}
|
|
1102
1099
|
|
|
1103
1100
|
static pj_activesock_t* create_tcp_socket(pjsip_endpoint *sip_endpt, pj_str_t *ipaddr, pj_uint16_t *out_port, MediaEndpoint *media_endpt, Call *call) {
|
|
1104
|
-
pj_ioqueue_key_t **skey;
|
|
1105
1101
|
pj_ioqueue_t *ioqueue = pjsip_endpt_get_ioqueue(sip_endpt);
|
|
1106
1102
|
|
|
1107
1103
|
pj_pool_t *pool = call->inv->dlg->pool;
|
|
1108
1104
|
|
|
1109
|
-
skey = (pj_ioqueue_key_t **)pj_pool_alloc(pool, sizeof(pj_ioqueue_key_t *));
|
|
1110
1105
|
pj_sock_t *sock = (pj_sock_t *)pj_pool_alloc(pool, sizeof(pj_sock_t));
|
|
1111
1106
|
|
|
1112
1107
|
pj_status_t rc;
|
|
1113
|
-
pj_sockaddr_in addr
|
|
1114
|
-
int client_addr_len;
|
|
1108
|
+
pj_sockaddr_in addr;
|
|
1115
1109
|
|
|
1116
1110
|
pj_activesock_t *asock = NULL;
|
|
1117
1111
|
|
|
@@ -1195,8 +1189,6 @@ int __pjw_init() {
|
|
|
1195
1189
|
|
|
1196
1190
|
pj_status_t status;
|
|
1197
1191
|
|
|
1198
|
-
pjmedia_port *conf_port = NULL;
|
|
1199
|
-
|
|
1200
1192
|
status = pj_init();
|
|
1201
1193
|
if (status != PJ_SUCCESS) {
|
|
1202
1194
|
addon_log(L_DBG, "pj_init failed\n");
|
|
@@ -2092,8 +2084,6 @@ int pjw_call_respond(long call_id, const char *json) {
|
|
|
2092
2084
|
|
|
2093
2085
|
pjsip_tx_data *tdata;
|
|
2094
2086
|
|
|
2095
|
-
const pjmedia_sdp_session *local_sdp;
|
|
2096
|
-
|
|
2097
2087
|
Call *call;
|
|
2098
2088
|
|
|
2099
2089
|
char buffer[MAX_JSON_INPUT];
|
|
@@ -2979,7 +2969,7 @@ int call_create(Transport *t, unsigned flags, pjsip_dialog *dlg,
|
|
|
2979
2969
|
pjsip_tx_data *tdata;
|
|
2980
2970
|
status = pjsip_inv_invite(inv, &tdata);
|
|
2981
2971
|
if (status != PJ_SUCCESS) {
|
|
2982
|
-
g_call_ids.remove(call_id, (long
|
|
2972
|
+
g_call_ids.remove(call_id, (long&)call);
|
|
2983
2973
|
close_media(call);
|
|
2984
2974
|
status = pjsip_dlg_terminate(dlg); // ToDo:
|
|
2985
2975
|
set_error("pjsip_inv_invite failed");
|
|
@@ -2987,7 +2977,7 @@ int call_create(Transport *t, unsigned flags, pjsip_dialog *dlg,
|
|
|
2987
2977
|
}
|
|
2988
2978
|
|
|
2989
2979
|
if (!add_headers(dlg->pool, tdata, document)) {
|
|
2990
|
-
g_call_ids.remove(call_id, (long
|
|
2980
|
+
g_call_ids.remove(call_id, (long&)call);
|
|
2991
2981
|
close_media(call); // Todo:
|
|
2992
2982
|
status = pjsip_dlg_terminate(dlg); // ToDo:
|
|
2993
2983
|
return -1;
|
|
@@ -2996,13 +2986,12 @@ int call_create(Transport *t, unsigned flags, pjsip_dialog *dlg,
|
|
|
2996
2986
|
if (!dlg_set_transport_by_t(t, dlg)) {
|
|
2997
2987
|
return -1;
|
|
2998
2988
|
}
|
|
2999
|
-
addon_log(L_DBG, "inv=%
|
|
2989
|
+
addon_log(L_DBG, "inv=%p tdata=%p\n", (void*)inv, (void*)tdata);
|
|
3000
2990
|
|
|
3001
2991
|
status = pjsip_inv_send_msg(inv, tdata);
|
|
3002
2992
|
addon_log(L_DBG, "status=%d\n", status);
|
|
3003
|
-
pj_perror(0, "", status, "");
|
|
3004
2993
|
if (status != PJ_SUCCESS) {
|
|
3005
|
-
g_call_ids.remove(call_id, (long
|
|
2994
|
+
g_call_ids.remove(call_id, (long&)call);
|
|
3006
2995
|
close_media(call); // Todo:
|
|
3007
2996
|
// The below code cannot be called here it will cause seg fault
|
|
3008
2997
|
// status = pjsip_dlg_terminate(dlg); //ToDo:
|
|
@@ -3013,7 +3002,7 @@ int call_create(Transport *t, unsigned flags, pjsip_dialog *dlg,
|
|
|
3013
3002
|
// Without this, on_rx_response will not be called
|
|
3014
3003
|
status = pjsip_dlg_add_usage(dlg, &mod_tester, call);
|
|
3015
3004
|
if (status != PJ_SUCCESS) {
|
|
3016
|
-
g_call_ids.remove(call_id, (long
|
|
3005
|
+
g_call_ids.remove(call_id, (long&)call);
|
|
3017
3006
|
close_media(call); // Todo:
|
|
3018
3007
|
status = pjsip_dlg_terminate(dlg); // ToDo:
|
|
3019
3008
|
set_error("pjsip_dlg_add_usage failed");
|
|
@@ -3110,8 +3099,6 @@ int pjw_call_send_dtmf(long call_id, const char *json) {
|
|
|
3110
3099
|
int mode = 0;
|
|
3111
3100
|
;
|
|
3112
3101
|
|
|
3113
|
-
pj_status_t status;
|
|
3114
|
-
|
|
3115
3102
|
Call *call;
|
|
3116
3103
|
|
|
3117
3104
|
char buffer[MAX_JSON_INPUT];
|
|
@@ -3203,8 +3190,6 @@ int pjw_call_reinvite(long call_id, const char *json) {
|
|
|
3203
3190
|
|
|
3204
3191
|
pj_status_t status;
|
|
3205
3192
|
|
|
3206
|
-
const pjmedia_sdp_session *old_sdp = NULL;
|
|
3207
|
-
|
|
3208
3193
|
pjsip_tx_data *tdata;
|
|
3209
3194
|
// pjmedia_sdp_session *sdp = 0;
|
|
3210
3195
|
|
|
@@ -3431,9 +3416,8 @@ int pjw_call_start_record_wav(long call_id, const char *json) {
|
|
|
3431
3416
|
long val;
|
|
3432
3417
|
Call *call;
|
|
3433
3418
|
pj_status_t status;
|
|
3434
|
-
pjmedia_port *stream_port;
|
|
3435
3419
|
|
|
3436
|
-
unsigned
|
|
3420
|
+
unsigned media_id = 0;
|
|
3437
3421
|
|
|
3438
3422
|
MediaEndpoint *me;
|
|
3439
3423
|
AudioEndpoint *ae;
|
|
@@ -3483,7 +3467,7 @@ int pjw_call_start_record_wav(long call_id, const char *json) {
|
|
|
3483
3467
|
}
|
|
3484
3468
|
}
|
|
3485
3469
|
|
|
3486
|
-
if (media_id >= call->media_count) {
|
|
3470
|
+
if ((int)media_id >= call->media_count) {
|
|
3487
3471
|
set_error("invalid media_id");
|
|
3488
3472
|
goto out;
|
|
3489
3473
|
}
|
|
@@ -3550,8 +3534,6 @@ int pjw_call_start_play_wav(long call_id, const char *json) {
|
|
|
3550
3534
|
|
|
3551
3535
|
long val;
|
|
3552
3536
|
Call *call;
|
|
3553
|
-
pj_status_t status;
|
|
3554
|
-
pjmedia_port *stream_port;
|
|
3555
3537
|
|
|
3556
3538
|
MediaEndpoint *me;
|
|
3557
3539
|
AudioEndpoint *ae;
|
|
@@ -3603,7 +3585,7 @@ int pjw_call_start_play_wav(long call_id, const char *json) {
|
|
|
3603
3585
|
}
|
|
3604
3586
|
}
|
|
3605
3587
|
|
|
3606
|
-
if (media_id >= call->media_count) {
|
|
3588
|
+
if ((int)media_id >= call->media_count) {
|
|
3607
3589
|
set_error("invalid media_id");
|
|
3608
3590
|
goto out;
|
|
3609
3591
|
}
|
|
@@ -3695,15 +3677,12 @@ int pjw_call_stop_play_wav(long call_id, const char *json) {
|
|
|
3695
3677
|
|
|
3696
3678
|
MediaEndpoint *me;
|
|
3697
3679
|
AudioEndpoint *ae;
|
|
3698
|
-
int ae_count;
|
|
3699
3680
|
int res;
|
|
3700
3681
|
|
|
3701
3682
|
unsigned media_id = 0;
|
|
3702
3683
|
|
|
3703
3684
|
char buffer[MAX_JSON_INPUT];
|
|
3704
3685
|
|
|
3705
|
-
const char *valid_params[] = {"media_id", ""};
|
|
3706
|
-
|
|
3707
3686
|
Document document;
|
|
3708
3687
|
|
|
3709
3688
|
if (!g_call_ids.get(call_id, val)) {
|
|
@@ -3730,7 +3709,7 @@ int pjw_call_stop_play_wav(long call_id, const char *json) {
|
|
|
3730
3709
|
} else {
|
|
3731
3710
|
// Stop play wav on specified media_id
|
|
3732
3711
|
|
|
3733
|
-
if (media_id >= call->media_count) {
|
|
3712
|
+
if ((int)media_id >= call->media_count) {
|
|
3734
3713
|
set_error("invalid media_id");
|
|
3735
3714
|
goto out;
|
|
3736
3715
|
}
|
|
@@ -3768,20 +3747,16 @@ int pjw_call_stop_record_wav(long call_id, const char *json) {
|
|
|
3768
3747
|
|
|
3769
3748
|
long val;
|
|
3770
3749
|
Call *call = (Call *)val;
|
|
3771
|
-
pjmedia_port *stream_port;
|
|
3772
3750
|
pj_status_t status;
|
|
3773
3751
|
|
|
3774
3752
|
MediaEndpoint *me;
|
|
3775
3753
|
AudioEndpoint *ae;
|
|
3776
|
-
int ae_count;
|
|
3777
3754
|
int res;
|
|
3778
3755
|
|
|
3779
3756
|
unsigned media_id = 0;
|
|
3780
3757
|
|
|
3781
3758
|
char buffer[MAX_JSON_INPUT];
|
|
3782
3759
|
|
|
3783
|
-
const char *valid_params[] = {"media_id", ""};
|
|
3784
|
-
|
|
3785
3760
|
Document document;
|
|
3786
3761
|
|
|
3787
3762
|
if (!g_call_ids.get(call_id, val)) {
|
|
@@ -3808,7 +3783,7 @@ int pjw_call_stop_record_wav(long call_id, const char *json) {
|
|
|
3808
3783
|
} else {
|
|
3809
3784
|
// Stop record wav on specified media_id
|
|
3810
3785
|
|
|
3811
|
-
if (media_id >= call->media_count) {
|
|
3786
|
+
if ((int)media_id >= call->media_count) {
|
|
3812
3787
|
set_error("invalid media_id");
|
|
3813
3788
|
goto out;
|
|
3814
3789
|
}
|
|
@@ -3847,7 +3822,6 @@ int pjw_call_start_fax(long call_id, const char *json) {
|
|
|
3847
3822
|
long val;
|
|
3848
3823
|
Call *call;
|
|
3849
3824
|
pj_status_t status;
|
|
3850
|
-
pjmedia_port *stream_port;
|
|
3851
3825
|
|
|
3852
3826
|
bool is_sender;
|
|
3853
3827
|
char *file;
|
|
@@ -3903,7 +3877,7 @@ int pjw_call_start_fax(long call_id, const char *json) {
|
|
|
3903
3877
|
}
|
|
3904
3878
|
}
|
|
3905
3879
|
|
|
3906
|
-
if (media_id >= call->media_count) {
|
|
3880
|
+
if ((int)media_id >= call->media_count) {
|
|
3907
3881
|
set_error("invalid media_id");
|
|
3908
3882
|
goto out;
|
|
3909
3883
|
}
|
|
@@ -3973,20 +3947,16 @@ int pjw_call_stop_fax(long call_id, const char *json) {
|
|
|
3973
3947
|
long val;
|
|
3974
3948
|
Call *call;
|
|
3975
3949
|
|
|
3976
|
-
pjmedia_port *stream_port;
|
|
3977
3950
|
pj_status_t status;
|
|
3978
3951
|
|
|
3979
3952
|
MediaEndpoint *me;
|
|
3980
3953
|
AudioEndpoint *ae;
|
|
3981
|
-
int ae_count;
|
|
3982
3954
|
int res;
|
|
3983
3955
|
|
|
3984
3956
|
unsigned media_id = 0;
|
|
3985
3957
|
|
|
3986
3958
|
char buffer[MAX_JSON_INPUT];
|
|
3987
3959
|
|
|
3988
|
-
const char *valid_params[] = {"media_id", ""};
|
|
3989
|
-
|
|
3990
3960
|
Document document;
|
|
3991
3961
|
|
|
3992
3962
|
if (!g_call_ids.get(call_id, val)) {
|
|
@@ -4013,7 +3983,7 @@ int pjw_call_stop_fax(long call_id, const char *json) {
|
|
|
4013
3983
|
} else {
|
|
4014
3984
|
// Stop fax on specified media_id
|
|
4015
3985
|
|
|
4016
|
-
if (media_id >= call->media_count) {
|
|
3986
|
+
if ((int)media_id >= call->media_count) {
|
|
4017
3987
|
set_error("invalid media_id");
|
|
4018
3988
|
goto out;
|
|
4019
3989
|
}
|
|
@@ -4050,8 +4020,6 @@ int pjw_call_get_stream_stat(long call_id, const char *json, char *out_stats) {
|
|
|
4050
4020
|
|
|
4051
4021
|
char buffer[MAX_JSON_INPUT];
|
|
4052
4022
|
|
|
4053
|
-
const char *valid_params[] = {"media_id", ""};
|
|
4054
|
-
|
|
4055
4023
|
Document document;
|
|
4056
4024
|
|
|
4057
4025
|
pj_status_t status;
|
|
@@ -4082,7 +4050,7 @@ int pjw_call_get_stream_stat(long call_id, const char *json, char *out_stats) {
|
|
|
4082
4050
|
goto out;
|
|
4083
4051
|
}
|
|
4084
4052
|
|
|
4085
|
-
if (media_id >= call->media_count) {
|
|
4053
|
+
if ((int)media_id >= call->media_count) {
|
|
4086
4054
|
set_error("invalid media_id");
|
|
4087
4055
|
goto out;
|
|
4088
4056
|
}
|
|
@@ -4142,11 +4110,11 @@ out:
|
|
|
4142
4110
|
bool media_endpoint_present_in_session_media(
|
|
4143
4111
|
MediaEndpoint *me, const pjmedia_sdp_session *local_sdp) {
|
|
4144
4112
|
printf("media_endpoint_present_in_session_media:\n");
|
|
4145
|
-
for (
|
|
4113
|
+
for (unsigned i = 0; i < local_sdp->media_count; i++) {
|
|
4146
4114
|
pjmedia_sdp_media *media = local_sdp->media[i];
|
|
4147
4115
|
printf("port: %d %d\n", me->port, media->desc.port);
|
|
4148
|
-
printf("media: %.*s %.*s\n", me->media.slen, me->media.ptr,
|
|
4149
|
-
media->desc.media.slen, media->desc.media.ptr);
|
|
4116
|
+
printf("media: %.*s %.*s\n", (int)me->media.slen, me->media.ptr,
|
|
4117
|
+
(int)media->desc.media.slen, media->desc.media.ptr);
|
|
4150
4118
|
if (me->port && (me->port == media->desc.port) &&
|
|
4151
4119
|
(pj_strcmp(&me->media, &media->desc.media) == 0) &&
|
|
4152
4120
|
(pj_strcmp(&me->transport, &media->desc.transport) == 0) &&
|
|
@@ -4162,10 +4130,10 @@ bool media_endpoint_present_in_session_media(
|
|
|
4162
4130
|
int find_sdp_media_by_media_endpt(const pjmedia_sdp_session *sdp,
|
|
4163
4131
|
pjmedia_sdp_media **media_out,
|
|
4164
4132
|
MediaEndpoint *me) {
|
|
4165
|
-
printf("find_sdp_media_by_media_endpt %
|
|
4166
|
-
for (int i = 0; i < sdp->media_count; i++) {
|
|
4133
|
+
printf("find_sdp_media_by_media_endpt %p\n", (void*)me);
|
|
4134
|
+
for (unsigned int i = 0; i < sdp->media_count; i++) {
|
|
4167
4135
|
pjmedia_sdp_media *media = sdp->media[i];
|
|
4168
|
-
printf("i=%d me->port=%i media->desc.port=%i me->media=%.*s media->desc.media=%.*s me->transport=%.*s media->desc.transport=%.*s\n", i, me->port, media->desc.port, me->media.slen, me->media.ptr, media->desc.media.slen, media->desc.media.ptr, me->transport.slen, me->transport.ptr, media->desc.transport.slen, media->desc.transport.ptr);
|
|
4136
|
+
printf("i=%d me->port=%i media->desc.port=%i me->media=%.*s media->desc.media=%.*s me->transport=%.*s media->desc.transport=%.*s\n", i, me->port, media->desc.port, (int)me->media.slen, me->media.ptr, (int)media->desc.media.slen, media->desc.media.ptr, (int)me->transport.slen, me->transport.ptr, (int)media->desc.transport.slen, media->desc.transport.ptr);
|
|
4169
4137
|
|
|
4170
4138
|
if ((me->port == media->desc.port) &&
|
|
4171
4139
|
(pj_strcmp(&me->media, &media->desc.media) == 0) &&
|
|
@@ -4181,10 +4149,10 @@ int find_sdp_media_by_media_endpt(const pjmedia_sdp_session *sdp,
|
|
|
4181
4149
|
|
|
4182
4150
|
bool is_media_in_active_media(MediaEndpoint *me, MediaEndpoint **active_media,
|
|
4183
4151
|
unsigned count) {
|
|
4184
|
-
printf("is_media_in_active_media me=%
|
|
4185
|
-
for (
|
|
4152
|
+
printf("is_media_in_active_media me=%p\n", (void*)me);
|
|
4153
|
+
for (unsigned i = 0; i < count; i++) {
|
|
4186
4154
|
MediaEndpoint *current = active_media[i];
|
|
4187
|
-
printf("i=%d current=%
|
|
4155
|
+
printf("i=%d current=%p\n", i, (void*)current);
|
|
4188
4156
|
if (current == me) {
|
|
4189
4157
|
printf("yes\n");
|
|
4190
4158
|
return true;
|
|
@@ -4218,10 +4186,10 @@ void gen_media_json(char *dest, int len, Call *call,
|
|
|
4218
4186
|
if(!me->port) {
|
|
4219
4187
|
switch (me->type) {
|
|
4220
4188
|
case ENDPOINT_TYPE_AUDIO:
|
|
4221
|
-
p += sprintf(p, "{\"type\": \"audio\", \"protocol\": \"%.*s\", \"port\": 0}", me->transport.slen, me->transport.ptr);
|
|
4189
|
+
p += sprintf(p, "{\"type\": \"audio\", \"protocol\": \"%.*s\", \"port\": 0}", (int)me->transport.slen, me->transport.ptr);
|
|
4222
4190
|
break;
|
|
4223
4191
|
case ENDPOINT_TYPE_MRCP:
|
|
4224
|
-
p += sprintf(p, "{\"type\": \"mrcp\", \"protocol\": \"%.*s\", \"port\": 0}", me->transport.slen, me->transport.ptr);
|
|
4192
|
+
p += sprintf(p, "{\"type\": \"mrcp\", \"protocol\": \"%.*s\", \"port\": 0}", (int)me->transport.slen, me->transport.ptr);
|
|
4225
4193
|
break;
|
|
4226
4194
|
default:
|
|
4227
4195
|
p += sprintf(p, "{\"type\": \"unknown\", \"port\": 0}");
|
|
@@ -4231,8 +4199,6 @@ void gen_media_json(char *dest, int len, Call *call,
|
|
|
4231
4199
|
|
|
4232
4200
|
switch (me->type) {
|
|
4233
4201
|
case ENDPOINT_TYPE_AUDIO: {
|
|
4234
|
-
AudioEndpoint *ae = (AudioEndpoint *)me->endpoint.audio;
|
|
4235
|
-
|
|
4236
4202
|
const char *local_mode =
|
|
4237
4203
|
get_media_mode(local_media->attr, local_media->attr_count);
|
|
4238
4204
|
const char *remote_mode =
|
|
@@ -4256,21 +4222,21 @@ void gen_media_json(char *dest, int len, Call *call,
|
|
|
4256
4222
|
"{\"type\": \"audio\", \"protocol\": \"%.*s\", \"local\": {\"addr\": \"%.*s\", "
|
|
4257
4223
|
"\"port\": %d, \"mode\": \"%s\"}, \"remote\": {\"addr\": "
|
|
4258
4224
|
"\"%.*s\", \"port\": %d, \"mode\": \"%s\"}, \"fmt\": [",
|
|
4259
|
-
me->transport.slen, me->transport.ptr,
|
|
4260
|
-
local_addr->slen, local_addr->ptr, local_media->desc.port,
|
|
4261
|
-
local_mode, remote_addr->slen, remote_addr->ptr,
|
|
4225
|
+
(int)me->transport.slen, me->transport.ptr,
|
|
4226
|
+
(int)local_addr->slen, local_addr->ptr, local_media->desc.port,
|
|
4227
|
+
local_mode, (int)remote_addr->slen, remote_addr->ptr,
|
|
4262
4228
|
remote_media->desc.port, remote_mode);
|
|
4263
4229
|
|
|
4264
|
-
for (
|
|
4230
|
+
for (unsigned i = 0; i < local_media->desc.fmt_count; i++) {
|
|
4265
4231
|
if (i > 0)
|
|
4266
4232
|
p += sprintf(p, ",");
|
|
4267
4233
|
pj_str_t *fmt = &local_media->desc.fmt[i];
|
|
4268
4234
|
pjmedia_sdp_attr *attr = pjmedia_sdp_attr_find2(
|
|
4269
4235
|
local_media->attr_count, local_media->attr, "rtpmap", fmt);
|
|
4270
4236
|
if (attr) {
|
|
4271
|
-
p += sprintf(p, "\"%.*s\"", attr->value.slen, attr->value.ptr);
|
|
4237
|
+
p += sprintf(p, "\"%.*s\"", (int)attr->value.slen, attr->value.ptr);
|
|
4272
4238
|
} else {
|
|
4273
|
-
p += sprintf(p, "\"%.*s\"", fmt->slen, fmt->ptr);
|
|
4239
|
+
p += sprintf(p, "\"%.*s\"", (int)fmt->slen, fmt->ptr);
|
|
4274
4240
|
}
|
|
4275
4241
|
}
|
|
4276
4242
|
p += sprintf(p, "]}");
|
|
@@ -4280,7 +4246,7 @@ void gen_media_json(char *dest, int len, Call *call,
|
|
|
4280
4246
|
p += sprintf(p,
|
|
4281
4247
|
"{\"type\": \"mrcp\", \"protocol\": \"%.*s\", \"local\": {\"port\": %d}, "
|
|
4282
4248
|
"\"remote\": {\"port\": %d}}",
|
|
4283
|
-
me->transport.slen, me->transport.ptr,
|
|
4249
|
+
(int)me->transport.slen, me->transport.ptr,
|
|
4284
4250
|
local_sdp->media[idx]->desc.port,
|
|
4285
4251
|
remote_sdp->media[idx]->desc.port);
|
|
4286
4252
|
break;
|
|
@@ -4318,14 +4284,12 @@ bool start_tcp_media(Call *call, MediaEndpoint *me,
|
|
|
4318
4284
|
} else {
|
|
4319
4285
|
remote_addr = &remote_sdp->conn->addr;
|
|
4320
4286
|
}
|
|
4321
|
-
printf("start_tcp_media remote port: %d, remote addr: %.*s\n", remote_media->desc.port, remote_addr->slen, remote_addr->ptr);
|
|
4287
|
+
printf("start_tcp_media remote port: %d, remote addr: %.*s\n", remote_media->desc.port, (int)remote_addr->slen, remote_addr->ptr);
|
|
4322
4288
|
|
|
4323
4289
|
pj_sock_t *sock = (pj_sock_t *)pj_pool_alloc(pool, sizeof(pj_sock_t));
|
|
4324
4290
|
|
|
4325
4291
|
pj_activesock_t *asock = NULL;
|
|
4326
4292
|
|
|
4327
|
-
unsigned allocated_port = 0;
|
|
4328
|
-
|
|
4329
4293
|
AsockUserData *ud = NULL;
|
|
4330
4294
|
|
|
4331
4295
|
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, sock);
|
|
@@ -4628,7 +4592,7 @@ MediaEndpoint *find_media_endpt_by_sdp_media(Call *call,
|
|
|
4628
4592
|
}
|
|
4629
4593
|
}
|
|
4630
4594
|
} else {
|
|
4631
|
-
printf("local_media->desc.media=%.*s\n", local_media->desc.media.slen,
|
|
4595
|
+
printf("local_media->desc.media=%.*s\n", (int)local_media->desc.media.slen,
|
|
4632
4596
|
local_media->desc.media.ptr);
|
|
4633
4597
|
assert(0);
|
|
4634
4598
|
// missing media type support implementation
|
|
@@ -4653,9 +4617,8 @@ static void on_media_update(pjsip_inv_session *inv, pj_status_t status) {
|
|
|
4653
4617
|
"be notified.\n");
|
|
4654
4618
|
return;
|
|
4655
4619
|
}
|
|
4656
|
-
printf("call_id=%
|
|
4620
|
+
printf("call_id=%li\n", call_id);
|
|
4657
4621
|
|
|
4658
|
-
pjmedia_stream_info stream_info;
|
|
4659
4622
|
const pjmedia_sdp_session *local_sdp;
|
|
4660
4623
|
const pjmedia_sdp_session *remote_sdp;
|
|
4661
4624
|
|
|
@@ -4696,11 +4659,8 @@ static void on_media_update(pjsip_inv_session *inv, pj_status_t status) {
|
|
|
4696
4659
|
call->id, b);
|
|
4697
4660
|
|
|
4698
4661
|
// update media endpoint based on sdp media
|
|
4699
|
-
bool in_use_chart[PJMEDIA_MAX_SDP_MEDIA] = {false};
|
|
4700
|
-
MediaEndpoint *active_media[PJMEDIA_MAX_SDP_MEDIA] = {NULL};
|
|
4701
|
-
int active_media_count = 0;
|
|
4702
4662
|
|
|
4703
|
-
for (
|
|
4663
|
+
for (unsigned i = 0; i < local_sdp->media_count; i++) {
|
|
4704
4664
|
MediaEndpoint *me = call->media[i];
|
|
4705
4665
|
if (!local_sdp->media[i]->desc.port) {
|
|
4706
4666
|
close_media_endpoint(call, me);
|
|
@@ -4756,7 +4716,7 @@ static void on_state_changed(pjsip_inv_session *inv, pjsip_event *e) {
|
|
|
4756
4716
|
printf("inv->state=%d\n", inv->state);
|
|
4757
4717
|
|
|
4758
4718
|
if (PJSIP_INV_STATE_DISCONNECTED == inv->state) {
|
|
4759
|
-
addon_log(L_DBG, "call will terminate call=%
|
|
4719
|
+
addon_log(L_DBG, "call will terminate call=%p\n", (void*)call);
|
|
4760
4720
|
pj_status_t status;
|
|
4761
4721
|
|
|
4762
4722
|
long call_id;
|
|
@@ -4830,7 +4790,7 @@ static pjmedia_transport *create_media_transport(const pj_str_t *addr,
|
|
|
4830
4790
|
pjmedia_transport_info tpinfo;
|
|
4831
4791
|
pjmedia_transport_info_init(&tpinfo);
|
|
4832
4792
|
status = pjmedia_transport_get_info(med_transport, &tpinfo);
|
|
4833
|
-
//printf("create_media_transport port=%i created %
|
|
4793
|
+
//printf("create_media_transport port=%i created %p\n", port, (void*)med_transport);
|
|
4834
4794
|
*allocated_port = port;
|
|
4835
4795
|
return med_transport;
|
|
4836
4796
|
} else {
|
|
@@ -5224,7 +5184,7 @@ static pj_bool_t on_rx_request(pjsip_rx_data *rdata) {
|
|
|
5224
5184
|
Transport *transport = (Transport *)val;
|
|
5225
5185
|
call->transport = transport;
|
|
5226
5186
|
} else {
|
|
5227
|
-
printf("could not resolve transport id=%
|
|
5187
|
+
printf("could not resolve transport id=%li\n", transport_id);
|
|
5228
5188
|
exit(1);
|
|
5229
5189
|
}
|
|
5230
5190
|
|
|
@@ -5275,7 +5235,7 @@ static pj_bool_t on_rx_response(pjsip_rx_data *rdata) {
|
|
|
5275
5235
|
long call_id;
|
|
5276
5236
|
|
|
5277
5237
|
if (call) {
|
|
5278
|
-
// addon_log(L_DBG, "call:%
|
|
5238
|
+
// addon_log(L_DBG, "call:%p\n", (void*)call);
|
|
5279
5239
|
if (!g_call_ids.get_id((long)call, call_id)) {
|
|
5280
5240
|
// addon_log(L_DBG, "The call is not present in g_call_ids.\n");
|
|
5281
5241
|
// It means the call terminated and was removed from g_call_ids\n");
|
|
@@ -5320,16 +5280,12 @@ static void on_rx_offer2(pjsip_inv_session *inv,
|
|
|
5320
5280
|
if (g_shutting_down)
|
|
5321
5281
|
return;
|
|
5322
5282
|
|
|
5323
|
-
char evt[2048];
|
|
5324
|
-
|
|
5325
5283
|
Call *call = (Call *)inv->dlg->mod_data[mod_tester.id];
|
|
5326
5284
|
|
|
5327
5285
|
printf("on_rx_offer2 call_id=%d\n", call->id);
|
|
5328
5286
|
|
|
5329
5287
|
pj_status_t status;
|
|
5330
5288
|
|
|
5331
|
-
const pjsip_rx_data *rdata = param->rdata;
|
|
5332
|
-
|
|
5333
5289
|
pjmedia_sdp_neg_state state = pjmedia_sdp_neg_get_state(inv->neg);
|
|
5334
5290
|
printf("neg state: %d\n", state);
|
|
5335
5291
|
if (PJMEDIA_SDP_NEG_STATE_NULL == state ||
|
|
@@ -5851,7 +5807,7 @@ static void build_stream_stat(ostringstream &oss, pjmedia_rtcp_stat *stat,
|
|
|
5851
5807
|
}
|
|
5852
5808
|
|
|
5853
5809
|
void close_media_transport(pjmedia_transport *med_transport) {
|
|
5854
|
-
printf("close_media_transport %
|
|
5810
|
+
printf("close_media_transport %p\n", (void*)med_transport);
|
|
5855
5811
|
pjmedia_transport_info tpinfo;
|
|
5856
5812
|
pjmedia_transport_info_init(&tpinfo);
|
|
5857
5813
|
pj_status_t status = pjmedia_transport_get_info(med_transport, &tpinfo);
|
|
@@ -5886,7 +5842,7 @@ bool has_attribute_mode(MediaEndpoint *me) {
|
|
|
5886
5842
|
}
|
|
5887
5843
|
|
|
5888
5844
|
void remove_mode_attributes(pjmedia_sdp_media *m) {
|
|
5889
|
-
for (
|
|
5845
|
+
for (unsigned i = 0; i < m->attr_count; i++) {
|
|
5890
5846
|
pjmedia_sdp_attr *attr = m->attr[i];
|
|
5891
5847
|
if ((pj_strcmp2(&attr->name, "sendrecv") == 0) ||
|
|
5892
5848
|
(pj_strcmp2(&attr->name, "sendonly") == 0) ||
|
|
@@ -5990,7 +5946,7 @@ bool create_media_endpoint(Call *call, Document &document, Value &descr,
|
|
|
5990
5946
|
}
|
|
5991
5947
|
audio_endpt->med_transport = srtp;
|
|
5992
5948
|
|
|
5993
|
-
status = pjmedia_transport_media_create(audio_endpt->med_transport, dlg->pool,
|
|
5949
|
+
status = pjmedia_transport_media_create(audio_endpt->med_transport, dlg->pool, 0, NULL, 0);
|
|
5994
5950
|
if(status != PJ_SUCCESS) {
|
|
5995
5951
|
set_error("pjmedia_transport_media_create failed");
|
|
5996
5952
|
return false;
|
|
@@ -6295,9 +6251,9 @@ bool process_media(Call *call, pjsip_dialog *dlg, Document &document, bool answe
|
|
|
6295
6251
|
// me was active but it must be deactivated
|
|
6296
6252
|
MediaEndpoint *new_me;
|
|
6297
6253
|
|
|
6298
|
-
if(!create_media_endpoint(call, document, descr, dlg, "0.0.0.0", &new_me))
|
|
6254
|
+
if(!create_media_endpoint(call, document, descr, dlg, (char*)"0.0.0.0", &new_me))
|
|
6299
6255
|
return false;
|
|
6300
|
-
addon_log(L_DBG, "i=%d media port=0 created %
|
|
6256
|
+
addon_log(L_DBG, "i=%d media port=0 created %p\n", i, (void*)me);
|
|
6301
6257
|
|
|
6302
6258
|
pjmedia_sdp_media *media = create_sdp_media(new_me, dlg);
|
|
6303
6259
|
if (!media)
|
|
@@ -6308,7 +6264,7 @@ bool process_media(Call *call, pjsip_dialog *dlg, Document &document, bool answe
|
|
|
6308
6264
|
// me was not active but it is activated now
|
|
6309
6265
|
if (!create_media_endpoint(call, document, descr, dlg, t->address, &me))
|
|
6310
6266
|
return false;
|
|
6311
|
-
addon_log(L_DBG, "i=%d media created %
|
|
6267
|
+
addon_log(L_DBG, "i=%d media created %p\n", i, (void*)me);
|
|
6312
6268
|
call->media[idx] = me;
|
|
6313
6269
|
|
|
6314
6270
|
if (!update_media_fields(me, dlg->pool, descr)) {
|
|
@@ -6335,7 +6291,7 @@ bool process_media(Call *call, pjsip_dialog *dlg, Document &document, bool answe
|
|
|
6335
6291
|
addon_log(L_DBG, "i=%d media not found\n", i);
|
|
6336
6292
|
if (!create_media_endpoint(call, document, descr, dlg, t->address, &me))
|
|
6337
6293
|
return false;
|
|
6338
|
-
addon_log(L_DBG, "i=%d media created %
|
|
6294
|
+
addon_log(L_DBG, "i=%d media created %p\n", i, (void*)me);
|
|
6339
6295
|
call->media[call->media_count++] = me;
|
|
6340
6296
|
in_use_chart[call->media_count - 1] =
|
|
6341
6297
|
true; // added elements must be set as in use
|
|
@@ -6384,7 +6340,7 @@ bool is_media_active(Call *c, MediaEndpoint *me) {
|
|
|
6384
6340
|
}
|
|
6385
6341
|
|
|
6386
6342
|
void close_media_endpoint(Call *call, MediaEndpoint *me) {
|
|
6387
|
-
printf("close_media_endpoint %
|
|
6343
|
+
printf("close_media_endpoint %p\n", (void*)me);
|
|
6388
6344
|
if(!me) return;
|
|
6389
6345
|
|
|
6390
6346
|
if (ENDPOINT_TYPE_AUDIO == me->type) {
|
|
@@ -6421,7 +6377,7 @@ void close_media_endpoint(Call *call, MediaEndpoint *me) {
|
|
|
6421
6377
|
}
|
|
6422
6378
|
|
|
6423
6379
|
void close_media(Call *c) {
|
|
6424
|
-
printf("close_media call_id=%
|
|
6380
|
+
printf("close_media call_id=%li\n", c->id);
|
|
6425
6381
|
for (int i = 0; i < c->media_count; ++i) {
|
|
6426
6382
|
MediaEndpoint *me = c->media[i];
|
|
6427
6383
|
close_media_endpoint(c, me);
|
|
@@ -6989,7 +6945,7 @@ void process_in_dialog_refer(pjsip_dialog *dlg, pjsip_rx_data *rdata) {
|
|
|
6989
6945
|
}
|
|
6990
6946
|
}
|
|
6991
6947
|
|
|
6992
|
-
static void on_tsx_state_changed(pjsip_inv_session *inv, pjsip_transaction *tsx,
|
|
6948
|
+
/* static void on_tsx_state_changed(pjsip_inv_session *inv, pjsip_transaction *tsx,
|
|
6993
6949
|
pjsip_event *e) {
|
|
6994
6950
|
addon_log(L_DBG, "on_tsx_state change method=%.*s.\n", tsx->method.name.slen,
|
|
6995
6951
|
tsx->method.name.ptr);
|
|
@@ -7010,11 +6966,11 @@ static void on_tsx_state_changed(pjsip_inv_session *inv, pjsip_transaction *tsx,
|
|
|
7010
6966
|
printf("call_id=%d\n", call->id);
|
|
7011
6967
|
|
|
7012
6968
|
if (call->inv == NULL) {
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
6969
|
+
// Shouldn't happen. It happens only when we don't terminate the
|
|
6970
|
+
// server subscription caused by REFER after the call has been
|
|
6971
|
+
// transfered (and this call has been disconnected), and we
|
|
6972
|
+
// receive another REFER for this call.
|
|
6973
|
+
//
|
|
7018
6974
|
return;
|
|
7019
6975
|
}
|
|
7020
6976
|
|
|
@@ -7022,9 +6978,9 @@ static void on_tsx_state_changed(pjsip_inv_session *inv, pjsip_transaction *tsx,
|
|
|
7022
6978
|
// Transport *t;
|
|
7023
6979
|
if (tsx->role == PJSIP_ROLE_UAS && tsx->state == PJSIP_TSX_STATE_TRYING) {
|
|
7024
6980
|
if (pjsip_method_cmp(&tsx->method, pjsip_get_refer_method()) == 0) {
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
6981
|
+
//
|
|
6982
|
+
// Incoming REFER request.
|
|
6983
|
+
//
|
|
7028
6984
|
|
|
7029
6985
|
process_in_dialog_refer(call->inv->dlg, e->body.tsx_state.src.rdata);
|
|
7030
6986
|
} else {
|
|
@@ -7053,7 +7009,7 @@ static void on_tsx_state_changed(pjsip_inv_session *inv, pjsip_transaction *tsx,
|
|
|
7053
7009
|
} else {
|
|
7054
7010
|
addon_log(L_DBG, "doing nothiing");
|
|
7055
7011
|
}
|
|
7056
|
-
}
|
|
7012
|
+
} */
|
|
7057
7013
|
|
|
7058
7014
|
int pjw_call_get_info(long call_id, const char *required_info, char *out_info) {
|
|
7059
7015
|
PJW_LOCK();
|
|
@@ -7674,7 +7630,7 @@ int pjw_subscription_create(long transport_id, const char *json,
|
|
|
7674
7630
|
|
|
7675
7631
|
pjsip_evsub_set_mod_data(evsub, mod_tester.id, subscription);
|
|
7676
7632
|
|
|
7677
|
-
printf("subscription=%
|
|
7633
|
+
printf("subscription=%p\n", (void*)subscription);
|
|
7678
7634
|
|
|
7679
7635
|
*out_subscription_id = subscription_id;
|
|
7680
7636
|
out:
|
|
@@ -7790,8 +7746,6 @@ out:
|
|
|
7790
7746
|
}
|
|
7791
7747
|
|
|
7792
7748
|
void process_in_dialog_subscribe(pjsip_dialog *dlg, pjsip_rx_data *rdata) {
|
|
7793
|
-
char evt[2048];
|
|
7794
|
-
|
|
7795
7749
|
return;
|
|
7796
7750
|
}
|
|
7797
7751
|
|
|
@@ -7859,7 +7813,7 @@ pj_status_t tcp_endpoint_send_msg(Call *call, MediaEndpoint *me, char *msg, pj_s
|
|
|
7859
7813
|
send_key = (pj_ioqueue_op_key_t*)pj_pool_alloc(call->inv->pool, sizeof(pj_ioqueue_op_key_t));
|
|
7860
7814
|
char *data = (char*)pj_pool_alloc(call->inv->pool, size);
|
|
7861
7815
|
memcpy(data, msg, size);
|
|
7862
|
-
printf("tcp_endpoint_send_msg send_key %
|
|
7816
|
+
printf("tcp_endpoint_send_msg send_key %p\n", (void*)send_key);
|
|
7863
7817
|
//status = pj_activesock_send(asock, send_key, data, &size, 0);
|
|
7864
7818
|
status = pj_activesock_send(asock, send_key, data, &size, PJ_IOQUEUE_ALWAYS_ASYNC);
|
|
7865
7819
|
if (status != PJ_SUCCESS) {
|
|
@@ -7880,7 +7834,6 @@ pj_status_t call_send_tcp_msg(Call *call, char *msg, pj_ssize_t size) {
|
|
|
7880
7834
|
pj_status_t status;
|
|
7881
7835
|
for (int i = 0; i < call->media_count; i++) {
|
|
7882
7836
|
MediaEndpoint *me = (MediaEndpoint *)call->media[i];
|
|
7883
|
-
pj_activesock_t *asock = NULL;
|
|
7884
7837
|
if (ENDPOINT_TYPE_MRCP == me->type) {
|
|
7885
7838
|
status = tcp_endpoint_send_msg(call, me, msg, size);
|
|
7886
7839
|
if(status != PJ_SUCCESS) {
|
|
@@ -7903,15 +7856,12 @@ int pjw_call_send_tcp_msg(long call_id, const char *json) {
|
|
|
7903
7856
|
long val;
|
|
7904
7857
|
|
|
7905
7858
|
MediaEndpoint *me;
|
|
7906
|
-
MrcpEndpoint *mrcp_endpt;
|
|
7907
7859
|
int res;
|
|
7908
7860
|
|
|
7909
7861
|
unsigned media_id = 0;
|
|
7910
7862
|
|
|
7911
7863
|
char buffer[MAX_JSON_INPUT];
|
|
7912
7864
|
|
|
7913
|
-
const char *valid_params[] = {"msg", "media_id", ""};
|
|
7914
|
-
|
|
7915
7865
|
char *msg;
|
|
7916
7866
|
pj_ssize_t size;
|
|
7917
7867
|
|
|
@@ -7946,7 +7896,7 @@ int pjw_call_send_tcp_msg(long call_id, const char *json) {
|
|
|
7946
7896
|
} else {
|
|
7947
7897
|
// Send msg to specified media_id
|
|
7948
7898
|
|
|
7949
|
-
if (media_id >= call->media_count) {
|
|
7899
|
+
if ((int)media_id >= call->media_count) {
|
|
7950
7900
|
set_error("invalid media_id");
|
|
7951
7901
|
goto out;
|
|
7952
7902
|
}
|