1 /*
2 liblinphone_tester - liblinphone test suite
3 Copyright (C) 2013 Belledonne Communications SARL
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 #include "linphone/core.h"
23 #include "linphone/lpconfig.h"
24 #include "private.h"
25 #include "liblinphone_tester.h"
26 #include "mediastreamer2/msutils.h"
27 #include "belle-sip/sipstack.h"
28 #include <bctoolbox/defs.h>
29
30 #ifdef _WIN32
31 #define unlink _unlink
32 #ifndef F_OK
33 #define F_OK 00 /*visual studio does not define F_OK*/
34 #endif
35 #endif
36
37 static void srtp_call(void);
38
39 // prototype definition for call_recording()
40 #ifdef __ANDROID__
41 #ifdef HAVE_OPENH264
42 extern void libmsopenh264_init(MSFactory *factory);
43 #endif
44 #endif
45
46
call_state_changed(LinphoneCore * lc,LinphoneCall * call,LinphoneCallState cstate,const char * msg)47 void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg){
48 char* to=linphone_address_as_string(linphone_call_get_call_log(call)->to);
49 char* from=linphone_address_as_string(linphone_call_get_call_log(call)->from);
50 stats* counters;
51 ms_message(" %s call from [%s] to [%s], new state is [%s]" ,linphone_call_get_call_log(call)->dir==LinphoneCallIncoming?"Incoming":"Outgoing"
52 ,from
53 ,to
54 ,linphone_call_state_to_string(cstate));
55 ms_free(to);
56 ms_free(from);
57 counters = get_stats(lc);
58 switch (cstate) {
59 case LinphoneCallIncomingReceived:counters->number_of_LinphoneCallIncomingReceived++;break;
60 case LinphoneCallOutgoingInit :counters->number_of_LinphoneCallOutgoingInit++;break;
61 case LinphoneCallOutgoingProgress :counters->number_of_LinphoneCallOutgoingProgress++;break;
62 case LinphoneCallOutgoingRinging :counters->number_of_LinphoneCallOutgoingRinging++;break;
63 case LinphoneCallOutgoingEarlyMedia :counters->number_of_LinphoneCallOutgoingEarlyMedia++;break;
64 case LinphoneCallConnected :counters->number_of_LinphoneCallConnected++;break;
65 case LinphoneCallStreamsRunning :counters->number_of_LinphoneCallStreamsRunning++;break;
66 case LinphoneCallPausing :counters->number_of_LinphoneCallPausing++;break;
67 case LinphoneCallPaused :counters->number_of_LinphoneCallPaused++;break;
68 case LinphoneCallResuming :counters->number_of_LinphoneCallResuming++;break;
69 case LinphoneCallRefered :counters->number_of_LinphoneCallRefered++;break;
70 case LinphoneCallError :counters->number_of_LinphoneCallError++;break;
71 case LinphoneCallEnd :counters->number_of_LinphoneCallEnd++;break;
72 case LinphoneCallPausedByRemote :counters->number_of_LinphoneCallPausedByRemote++;break;
73 case LinphoneCallUpdatedByRemote :counters->number_of_LinphoneCallUpdatedByRemote++;break;
74 case LinphoneCallIncomingEarlyMedia :counters->number_of_LinphoneCallIncomingEarlyMedia++;break;
75 case LinphoneCallUpdating :counters->number_of_LinphoneCallUpdating++;break;
76 case LinphoneCallReleased :counters->number_of_LinphoneCallReleased++;break;
77 case LinphoneCallEarlyUpdating: counters->number_of_LinphoneCallEarlyUpdating++;break;
78 case LinphoneCallEarlyUpdatedByRemote: counters->number_of_LinphoneCallEarlyUpdatedByRemote++;break;
79 default:
80 BC_FAIL("unexpected event");break;
81 }
82 }
83
rtcp_is_type(const mblk_t * m,rtcp_type_t type)84 static bool_t rtcp_is_type(const mblk_t *m, rtcp_type_t type){
85 const rtcp_common_header_t *ch=rtcp_get_common_header(m);
86 return (ch!=NULL && rtcp_common_header_get_packet_type(ch)==type);
87 }
88
rtcp_received(stats * counters,mblk_t * packet)89 static void rtcp_received(stats* counters, mblk_t *packet) {
90 do{
91 if (rtcp_is_type(packet, RTCP_RTPFB)){
92 if (rtcp_RTPFB_get_type(packet) == RTCP_RTPFB_TMMBR) {
93 counters->number_of_tmmbr_received++;
94 counters->last_tmmbr_value_received = (int)rtcp_RTPFB_tmmbr_get_max_bitrate(packet);
95 }
96 }
97 }while (rtcp_next_packet(packet));
98 rtcp_rewind(packet);
99 }
100
call_stats_updated(LinphoneCore * lc,LinphoneCall * call,const LinphoneCallStats * lstats)101 void call_stats_updated(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *lstats) {
102 stats* counters = get_stats(lc);
103 counters->number_of_LinphoneCallStatsUpdated++;
104 if (lstats->updated & LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE) {
105 counters->number_of_rtcp_received++;
106 if (lstats->rtcp_received_via_mux){
107 counters->number_of_rtcp_received_via_mux++;
108 }
109 rtcp_received(counters, lstats->received_rtcp);
110 }
111 if (lstats->updated & LINPHONE_CALL_STATS_SENT_RTCP_UPDATE ) {
112 counters->number_of_rtcp_sent++;
113 }
114 if (lstats->updated & LINPHONE_CALL_STATS_PERIODICAL_UPDATE ) {
115 int tab_size = sizeof (counters->audio_download_bandwidth)/sizeof(int);
116 int index = (counters->current_bandwidth_index[lstats->type]++) % tab_size;
117 LinphoneCallStats *audio_stats, *video_stats;
118 audio_stats = linphone_call_get_audio_stats(call);
119 video_stats = linphone_call_get_video_stats(call);
120 if (lstats->type == LINPHONE_CALL_STATS_AUDIO) {
121 counters->audio_download_bandwidth[index] = (int)audio_stats->download_bandwidth;
122 counters->audio_upload_bandwidth[index] = (int)audio_stats->upload_bandwidth;
123 } else {
124 counters->video_download_bandwidth[index] = (int)video_stats->download_bandwidth;
125 counters->video_upload_bandwidth[index] = (int)video_stats->upload_bandwidth;
126 }
127 linphone_call_stats_unref(audio_stats);
128 linphone_call_stats_unref(video_stats);
129 }
130
131 }
132
linphone_call_encryption_changed(LinphoneCore * lc,LinphoneCall * call,bool_t on,const char * authentication_token)133 void linphone_call_encryption_changed(LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token) {
134 char* to=linphone_address_as_string(linphone_call_get_call_log(call)->to);
135 char* from=linphone_address_as_string(linphone_call_get_call_log(call)->from);
136 stats* counters;
137 ms_message(" %s call from [%s] to [%s], is now [%s]",linphone_call_get_call_log(call)->dir==LinphoneCallIncoming?"Incoming":"Outgoing"
138 ,from
139 ,to
140 ,(on?"encrypted":"unencrypted"));
141 ms_free(to);
142 ms_free(from);
143 counters = get_stats(lc);
144 if (on)
145 counters->number_of_LinphoneCallEncryptedOn++;
146 else
147 counters->number_of_LinphoneCallEncryptedOff++;
148 }
149
linphone_transfer_state_changed(LinphoneCore * lc,LinphoneCall * transfered,LinphoneCallState new_call_state)150 void linphone_transfer_state_changed(LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state) {
151 char* to=linphone_address_as_string(linphone_call_get_call_log(transfered)->to);
152 char* from=linphone_address_as_string(linphone_call_get_call_log(transfered)->from);
153 stats* counters;
154 ms_message("Transferred call from [%s] to [%s], new state is [%s]",from,to,linphone_call_state_to_string(new_call_state));
155 ms_free(to);
156 ms_free(from);
157
158 counters = get_stats(lc);
159 switch (new_call_state) {
160 case LinphoneCallOutgoingInit :counters->number_of_LinphoneTransferCallOutgoingInit++;break;
161 case LinphoneCallOutgoingProgress :counters->number_of_LinphoneTransferCallOutgoingProgress++;break;
162 case LinphoneCallOutgoingRinging :counters->number_of_LinphoneTransferCallOutgoingRinging++;break;
163 case LinphoneCallOutgoingEarlyMedia :counters->number_of_LinphoneTransferCallOutgoingEarlyMedia++;break;
164 case LinphoneCallConnected :counters->number_of_LinphoneTransferCallConnected++;break;
165 case LinphoneCallStreamsRunning :counters->number_of_LinphoneTransferCallStreamsRunning++;break;
166 case LinphoneCallError :counters->number_of_LinphoneTransferCallError++;break;
167 default:
168 BC_FAIL("unexpected event");break;
169 }
170 }
171
172
linphone_call_iframe_decoded_cb(LinphoneCall * call,void * user_data)173 void linphone_call_iframe_decoded_cb(LinphoneCall *call,void * user_data) {
174 char* to=linphone_address_as_string(linphone_call_get_call_log(call)->to);
175 char* from=linphone_address_as_string(linphone_call_get_call_log(call)->from);
176 stats* counters;
177 LinphoneCore* lc=(LinphoneCore*)user_data;
178 ms_message("call from [%s] to [%s] receive iFrame",from,to);
179 ms_free(to);
180 ms_free(from);
181 counters = (stats*)get_stats(lc);
182 counters->number_of_IframeDecoded++;
183 }
184
liblinphone_tester_check_rtcp(LinphoneCoreManager * caller,LinphoneCoreManager * callee)185 void liblinphone_tester_check_rtcp(LinphoneCoreManager* caller, LinphoneCoreManager* callee) {
186 LinphoneCall *c1,*c2;
187 MSTimeSpec ts;
188 int max_time_to_wait;
189 LinphoneCallStats *audio_stats1, *video_stats1, *audio_stats2, *video_stats2;
190 c1=linphone_core_get_current_call(caller->lc);
191 c2=linphone_core_get_current_call(callee->lc);
192
193 BC_ASSERT_PTR_NOT_NULL(c1);
194 BC_ASSERT_PTR_NOT_NULL(c2);
195
196 if (!c1 || !c2) return;
197 linphone_call_ref(c1);
198 linphone_call_ref(c2);
199 liblinphone_tester_clock_start(&ts);
200 if (linphone_core_rtcp_enabled(caller->lc) && linphone_core_rtcp_enabled(callee->lc))
201 max_time_to_wait = 15000;
202 else
203 max_time_to_wait = 5000;
204
205 do {
206 audio_stats1 = linphone_call_get_audio_stats(c1);
207 video_stats1 = linphone_call_get_video_stats(c1);
208 audio_stats2 = linphone_call_get_audio_stats(c2);
209 video_stats2 = linphone_call_get_video_stats(c2);
210 if (audio_stats1->round_trip_delay > 0.0
211 && audio_stats2->round_trip_delay > 0.0
212 && (!linphone_call_log_video_enabled(linphone_call_get_call_log(c1)) || video_stats1->round_trip_delay>0.0)
213 && (!linphone_call_log_video_enabled(linphone_call_get_call_log(c2)) || video_stats2->round_trip_delay>0.0)) {
214 break;
215
216 }
217 linphone_call_stats_unref(audio_stats1);
218 linphone_call_stats_unref(audio_stats2);
219 if (video_stats1) linphone_call_stats_unref(video_stats1);
220 if (video_stats2) linphone_call_stats_unref(video_stats2);
221 wait_for_until(caller->lc,callee->lc,NULL,0,20); /*just to sleep while iterating*/
222 }while (!liblinphone_tester_clock_elapsed(&ts,max_time_to_wait));
223
224 audio_stats1 = linphone_call_get_audio_stats(c1);
225 video_stats1 = linphone_call_get_video_stats(c1);
226 audio_stats2 = linphone_call_get_audio_stats(c2);
227 video_stats2 = linphone_call_get_video_stats(c2);
228 if (linphone_core_rtcp_enabled(caller->lc) && linphone_core_rtcp_enabled(callee->lc)) {
229 BC_ASSERT_GREATER(caller->stat.number_of_rtcp_received, 1, int, "%i");
230 BC_ASSERT_GREATER(callee->stat.number_of_rtcp_received, 1, int, "%i");
231 BC_ASSERT_GREATER(audio_stats1->round_trip_delay,0.0,float,"%f");
232 BC_ASSERT_GREATER(audio_stats2->round_trip_delay,0.0,float,"%f");
233 if (linphone_call_log_video_enabled(linphone_call_get_call_log(c1))) {
234 BC_ASSERT_GREATER(video_stats1->round_trip_delay,0.0,float,"%f");
235 }
236 if (linphone_call_log_video_enabled(linphone_call_get_call_log(c2))) {
237 BC_ASSERT_GREATER(video_stats2->round_trip_delay,0.0,float,"%f");
238 }
239 } else {
240 if (linphone_core_rtcp_enabled(caller->lc)) {
241 BC_ASSERT_EQUAL(audio_stats1->rtp_stats.sent_rtcp_packets, 0, unsigned long long, "%llu");
242 BC_ASSERT_EQUAL(audio_stats2->rtp_stats.recv_rtcp_packets, 0, unsigned long long, "%llu");
243 if (linphone_call_log_video_enabled(linphone_call_get_call_log(c1))) {
244 BC_ASSERT_EQUAL(video_stats1->rtp_stats.sent_rtcp_packets, 0, unsigned long long, "%llu");
245 }
246 if (linphone_call_log_video_enabled(linphone_call_get_call_log(c2))) {
247 BC_ASSERT_EQUAL(video_stats2->rtp_stats.recv_rtcp_packets, 0, unsigned long long, "%llu");
248 }
249 }
250 if (linphone_core_rtcp_enabled(callee->lc)) {
251 BC_ASSERT_EQUAL(audio_stats2->rtp_stats.sent_rtcp_packets, 0, unsigned long long, "%llu");
252 BC_ASSERT_EQUAL(audio_stats1->rtp_stats.recv_rtcp_packets, 0, unsigned long long, "%llu");
253 if (linphone_call_log_video_enabled(linphone_call_get_call_log(c1))) {
254 BC_ASSERT_EQUAL(video_stats1->rtp_stats.recv_rtcp_packets, 0, unsigned long long, "%llu");
255 }
256 if (linphone_call_log_video_enabled(linphone_call_get_call_log(c2))) {
257 BC_ASSERT_EQUAL(video_stats2->rtp_stats.sent_rtcp_packets, 0, unsigned long long, "%llu");
258 }
259 }
260
261 }
262 linphone_call_unref(c1);
263 linphone_call_unref(c2);
264 }
265
setup_sdp_handling(const LinphoneCallTestParams * params,LinphoneCoreManager * mgr)266 static void setup_sdp_handling(const LinphoneCallTestParams* params, LinphoneCoreManager* mgr ){
267 if( params->sdp_removal ){
268 sal_default_set_sdp_handling(mgr->lc->sal, SalOpSDPSimulateRemove);
269 } else if( params->sdp_simulate_error ){
270 sal_default_set_sdp_handling(mgr->lc->sal, SalOpSDPSimulateError);
271 }
272 }
273
274 /*
275 * CAUTION this function is error prone. you should not use it anymore in new tests.
276 * Creating callee call params before the call is actually received is not the good way
277 * to use the Liblinphone API. Indeed, call params used for receiving calls shall be created by linphone_core_create_call_params() by passing
278 * the call object for which params are to be created.
279 * This function should be used only in test case where the programmer exactly knows the caller params, and then can deduce how
280 * callee params will be set by linphone_core_create_call_params().
281 * This function was developped at a time where the use of the API about incoming params was not yet clarified.
282 * Tests relying on this function are then not testing the correct way to use the api (through linphone_core_create_call_params()), and so
283 * it is not a so good idea to build new tests based on this function.
284 **/
call_with_params2(LinphoneCoreManager * caller_mgr,LinphoneCoreManager * callee_mgr,const LinphoneCallTestParams * caller_test_params,const LinphoneCallTestParams * callee_test_params,bool_t build_callee_params)285 bool_t call_with_params2(LinphoneCoreManager* caller_mgr
286 ,LinphoneCoreManager* callee_mgr
287 , const LinphoneCallTestParams *caller_test_params
288 , const LinphoneCallTestParams *callee_test_params
289 , bool_t build_callee_params) {
290 int retry=0;
291 stats initial_caller=caller_mgr->stat;
292 stats initial_callee=callee_mgr->stat;
293 bool_t result=FALSE;
294 LinphoneCallParams *caller_params = caller_test_params->base;
295 LinphoneCallParams *callee_params = callee_test_params->base;
296 bool_t did_receive_call;
297 LinphoneCall *callee_call=NULL;
298 LinphoneCall *caller_call=NULL;
299
300 /* TODO: This should be handled correctly inside the liblinphone library but meanwhile handle this here. */
301 linphone_core_manager_wait_for_stun_resolution(caller_mgr);
302 linphone_core_manager_wait_for_stun_resolution(callee_mgr);
303
304 setup_sdp_handling(caller_test_params, caller_mgr);
305 setup_sdp_handling(callee_test_params, callee_mgr);
306
307 if (!caller_params){
308 BC_ASSERT_PTR_NOT_NULL((caller_call=linphone_core_invite_address(caller_mgr->lc,callee_mgr->identity)));
309 }else{
310 BC_ASSERT_PTR_NOT_NULL((caller_call=linphone_core_invite_address_with_params(caller_mgr->lc,callee_mgr->identity,caller_params)));
311 }
312
313 BC_ASSERT_PTR_NULL(linphone_call_get_remote_params(caller_call)); /*assert that remote params are NULL when no response is received yet*/
314
315 did_receive_call = wait_for(callee_mgr->lc
316 ,caller_mgr->lc
317 ,&callee_mgr->stat.number_of_LinphoneCallIncomingReceived
318 ,initial_callee.number_of_LinphoneCallIncomingReceived+1);
319 BC_ASSERT_EQUAL(did_receive_call, !callee_test_params->sdp_simulate_error, int, "%d");
320
321 sal_default_set_sdp_handling(caller_mgr->lc->sal, SalOpSDPNormal);
322 sal_default_set_sdp_handling(callee_mgr->lc->sal, SalOpSDPNormal);
323
324 if (!did_receive_call) return 0;
325
326
327 if (linphone_core_get_calls_nb(callee_mgr->lc)<=1)
328 BC_ASSERT_TRUE(linphone_core_inc_invite_pending(callee_mgr->lc));
329 BC_ASSERT_EQUAL(caller_mgr->stat.number_of_LinphoneCallOutgoingProgress,initial_caller.number_of_LinphoneCallOutgoingProgress+1, int, "%d");
330
331
332 while (caller_mgr->stat.number_of_LinphoneCallOutgoingRinging!=(initial_caller.number_of_LinphoneCallOutgoingRinging + 1)
333 && caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia!=(initial_caller.number_of_LinphoneCallOutgoingEarlyMedia +1)
334 && retry++ < 100) {
335 linphone_core_iterate(caller_mgr->lc);
336 linphone_core_iterate(callee_mgr->lc);
337 ms_usleep(20000);
338 }
339
340
341 BC_ASSERT_TRUE((caller_mgr->stat.number_of_LinphoneCallOutgoingRinging==initial_caller.number_of_LinphoneCallOutgoingRinging+1)
342 ||(caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia==initial_caller.number_of_LinphoneCallOutgoingEarlyMedia+1));
343
344
345 if (linphone_core_get_calls_nb(callee_mgr->lc) == 1)
346 BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call_remote_address(callee_mgr->lc)); /*only relevant if one call, otherwise, not always set*/
347 callee_call=linphone_core_get_call_by_remote_address2(callee_mgr->lc,caller_mgr->identity);
348
349 if(!linphone_core_get_current_call(caller_mgr->lc) || (!callee_call && !linphone_core_get_current_call(callee_mgr->lc)) /*for privacy case*/) {
350 return 0;
351 } else if (caller_mgr->identity){
352 LinphoneAddress* callee_from=linphone_address_clone(caller_mgr->identity);
353 linphone_address_set_port(callee_from,0); /*remove port because port is never present in from header*/
354
355 if (linphone_call_params_get_privacy(linphone_call_get_current_params(linphone_core_get_current_call(caller_mgr->lc))) == LinphonePrivacyNone) {
356 /*don't check in case of p asserted id*/
357 if (!lp_config_get_int(callee_mgr->lc->config,"sip","call_logs_use_asserted_id_instead_of_from",0))
358 BC_ASSERT_TRUE(linphone_address_weak_equal(callee_from,linphone_call_get_remote_address(callee_call)));
359 } else {
360 BC_ASSERT_FALSE(linphone_address_weak_equal(callee_from,linphone_call_get_remote_address(linphone_core_get_current_call(callee_mgr->lc))));
361 }
362 linphone_address_unref(callee_from);
363 }
364
365
366 if (callee_params){
367 linphone_call_accept_with_params(callee_call,callee_params);
368 }else if (build_callee_params){
369 LinphoneCallParams *default_params=linphone_core_create_call_params(callee_mgr->lc,callee_call);
370 ms_message("Created default call params with video=%i", linphone_call_params_video_enabled(default_params));
371 linphone_call_accept_with_params(callee_call,default_params);
372 linphone_call_params_unref(default_params);
373 }else if (callee_call) {
374 linphone_call_accept(callee_call);
375 } else {
376 linphone_call_accept(linphone_core_get_current_call(callee_mgr->lc));
377 }
378
379 BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallConnected,initial_callee.number_of_LinphoneCallConnected+1));
380 BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallConnected,initial_caller.number_of_LinphoneCallConnected+1));
381
382 result = wait_for_until(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_caller.number_of_LinphoneCallStreamsRunning+1, 2000)
383 &&
384 wait_for_until(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_callee.number_of_LinphoneCallStreamsRunning+1, 2000);
385
386 if (linphone_core_get_media_encryption(caller_mgr->lc) != LinphoneMediaEncryptionNone
387 || linphone_core_get_media_encryption(callee_mgr->lc) != LinphoneMediaEncryptionNone) {
388 /*wait for encryption to be on, in case of zrtp or dtls, it can take a few seconds*/
389 if ( (linphone_core_get_media_encryption(caller_mgr->lc) == LinphoneMediaEncryptionZRTP)
390 || (linphone_core_get_media_encryption(callee_mgr->lc) == LinphoneMediaEncryptionZRTP) /* if callee is ZRTP, wait for it */
391 || (linphone_core_get_media_encryption(caller_mgr->lc) == LinphoneMediaEncryptionDTLS))
392 wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallEncryptedOn,initial_caller.number_of_LinphoneCallEncryptedOn+1);
393 if ((linphone_core_get_media_encryption(callee_mgr->lc) == LinphoneMediaEncryptionZRTP)
394 || (linphone_core_get_media_encryption(callee_mgr->lc) == LinphoneMediaEncryptionDTLS)
395 || (linphone_core_get_media_encryption(caller_mgr->lc) == LinphoneMediaEncryptionZRTP)
396 || (linphone_core_get_media_encryption(caller_mgr->lc) == LinphoneMediaEncryptionDTLS) /*also take care of caller policy*/ )
397 wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallEncryptedOn,initial_callee.number_of_LinphoneCallEncryptedOn+1);
398
399 /* when caller is encryptionNone but callee is ZRTP, we expect ZRTP to take place */
400 if ((linphone_core_get_media_encryption(caller_mgr->lc) == LinphoneMediaEncryptionNone)
401 && (linphone_core_get_media_encryption(callee_mgr->lc) == LinphoneMediaEncryptionZRTP)
402 && linphone_core_media_encryption_supported(caller_mgr->lc, LinphoneMediaEncryptionZRTP)) {
403 const LinphoneCallParams* call_param = linphone_call_get_current_params(callee_call);
404 BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param), LinphoneMediaEncryptionZRTP, int, "%d");
405 call_param = linphone_call_get_current_params(linphone_core_get_current_call(caller_mgr->lc));
406 BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param), LinphoneMediaEncryptionZRTP, int, "%d");
407 }else { /* otherwise, final status shall stick to caller core parameter */
408 const LinphoneCallParams* call_param = linphone_call_get_current_params(callee_call);
409 BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller_mgr->lc), int, "%d");
410 call_param = linphone_call_get_current_params(linphone_core_get_current_call(caller_mgr->lc));
411 BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller_mgr->lc), int, "%d");
412
413 }
414 }
415 /*wait ice re-invite*/
416 if (linphone_core_get_firewall_policy(caller_mgr->lc) == LinphonePolicyUseIce
417 && linphone_core_get_firewall_policy(callee_mgr->lc) == LinphonePolicyUseIce
418 && !linphone_core_sdp_200_ack_enabled(caller_mgr->lc) /*ice does not work with sdp less invite*/
419 && lp_config_get_int(callee_mgr->lc->config, "sip", "update_call_when_ice_completed", TRUE)
420 && lp_config_get_int(caller_mgr->lc->config, "sip", "update_call_when_ice_completed", TRUE)
421 && linphone_core_get_media_encryption(caller_mgr->lc) != LinphoneMediaEncryptionDTLS /*no ice-reinvite with DTLS*/) {
422 BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_caller.number_of_LinphoneCallStreamsRunning+2));
423 BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_callee.number_of_LinphoneCallStreamsRunning+2));
424
425 } else if (linphone_core_get_firewall_policy(caller_mgr->lc) == LinphonePolicyUseIce) {
426 /* check no ice re-invite received*/
427 BC_ASSERT_FALSE(wait_for_until(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_caller.number_of_LinphoneCallStreamsRunning+2,2000));
428 BC_ASSERT_FALSE(wait_for_until(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_callee.number_of_LinphoneCallStreamsRunning+2,2000));
429
430 }
431 if (linphone_core_get_media_encryption(caller_mgr->lc) == LinphoneMediaEncryptionDTLS ) {
432 if (linphone_core_get_current_call(caller_mgr->lc)->audiostream)
433 BC_ASSERT_TRUE(ms_media_stream_sessions_get_encryption_mandatory(&linphone_core_get_current_call(caller_mgr->lc)->audiostream->ms.sessions));
434 #ifdef VIDEO_ENABLED
435 if (linphone_core_get_current_call(caller_mgr->lc)->videostream && video_stream_started(linphone_core_get_current_call(caller_mgr->lc)->videostream))
436 BC_ASSERT_TRUE(ms_media_stream_sessions_get_encryption_mandatory(&linphone_core_get_current_call(caller_mgr->lc)->videostream->ms.sessions));
437 #endif
438
439 }
440 return result;
441 }
442
443 /*
444 * CAUTION this function is error prone. you should not use it anymore in new tests.
445 * Creating callee call params before the call is actually received is not the good way
446 * to use the Liblinphone API. Indeed, call params used for receiving calls shall be created by linphone_core_create_call_params() by passing
447 * the call object for which params are to be created.
448 * This function should be used only in test case where the programmer exactly knows the caller params, and then can deduce how
449 * callee params will be set by linphone_core_create_call_params().
450 * This function was developped at a time where the use of the API about incoming params was not yet clarified.
451 * Tests relying on this function are then not testing the correct way to use the api (through linphone_core_create_call_params()), and so
452 * it is not a so good idea to build new tests based on this function.
453 **/
call_with_params(LinphoneCoreManager * caller_mgr,LinphoneCoreManager * callee_mgr,const LinphoneCallParams * caller_params,const LinphoneCallParams * callee_params)454 bool_t call_with_params(LinphoneCoreManager* caller_mgr
455 ,LinphoneCoreManager* callee_mgr
456 ,const LinphoneCallParams *caller_params
457 ,const LinphoneCallParams *callee_params){
458 LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0};
459 caller_test_params.base = (LinphoneCallParams*)caller_params;
460 callee_test_params.base = (LinphoneCallParams*)callee_params;
461 return call_with_params2(caller_mgr,callee_mgr,&caller_test_params,&callee_test_params,FALSE);
462 }
463
464 /*
465 * CAUTION this function is error prone. you should not use it anymore in new tests.
466 * Creating callee call params before the call is actually received is not the good way
467 * to use the Liblinphone API. Indeed, call params used for receiving calls shall be created by linphone_core_create_call_params() by passing
468 * the call object for which params are to be created.
469 * This function should be used only in test case where the programmer exactly knows the caller params, and then can deduce how
470 * callee params will be set by linphone_core_create_call_params().
471 * This function was developped at a time where the use of the API about incoming params was not yet clarified.
472 * Tests relying on this function are then not testing the correct way to use the api (through linphone_core_create_call_params()), and so
473 * it is not a so good idea to build new tests based on this function.
474 **/
call_with_test_params(LinphoneCoreManager * caller_mgr,LinphoneCoreManager * callee_mgr,const LinphoneCallTestParams * caller_test_params,const LinphoneCallTestParams * callee_test_params)475 bool_t call_with_test_params(LinphoneCoreManager* caller_mgr
476 ,LinphoneCoreManager* callee_mgr
477 ,const LinphoneCallTestParams *caller_test_params
478 ,const LinphoneCallTestParams *callee_test_params){
479 return call_with_params2(caller_mgr,callee_mgr,caller_test_params,callee_test_params,FALSE);
480 }
481
call_with_caller_params(LinphoneCoreManager * caller_mgr,LinphoneCoreManager * callee_mgr,const LinphoneCallParams * params)482 bool_t call_with_caller_params(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_mgr, const LinphoneCallParams *params) {
483 return call_with_params(caller_mgr,callee_mgr,params,NULL);
484 }
485
call(LinphoneCoreManager * caller_mgr,LinphoneCoreManager * callee_mgr)486 bool_t call(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_mgr){
487 return call_with_params(caller_mgr,callee_mgr,NULL,NULL);
488 }
489
end_call(LinphoneCoreManager * m1,LinphoneCoreManager * m2)490 void end_call(LinphoneCoreManager *m1, LinphoneCoreManager *m2){
491 int previous_count_1 = m1->stat.number_of_LinphoneCallEnd;
492 int previous_count_2 = m2->stat.number_of_LinphoneCallEnd;
493 linphone_core_terminate_all_calls(m1->lc);
494 BC_ASSERT_TRUE(wait_for(m1->lc,m2->lc,&m1->stat.number_of_LinphoneCallEnd,previous_count_1+1));
495 BC_ASSERT_TRUE(wait_for(m1->lc,m2->lc,&m2->stat.number_of_LinphoneCallEnd,previous_count_2+1));
496 BC_ASSERT_TRUE(wait_for(m1->lc,m2->lc,&m1->stat.number_of_LinphoneCallReleased,previous_count_1+1));
497 BC_ASSERT_TRUE(wait_for(m1->lc,m2->lc,&m2->stat.number_of_LinphoneCallReleased,previous_count_2+1));
498 }
499
simple_call_base(bool_t enable_multicast_recv_side)500 void simple_call_base(bool_t enable_multicast_recv_side) {
501 LinphoneCoreManager* marie;
502 LinphoneCoreManager* pauline;
503 const LinphoneAddress *from;
504 LinphoneCall *pauline_call;
505 LinphoneProxyConfig* marie_cfg;
506
507 marie = linphone_core_manager_new( "marie_rc");
508 pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
509
510 /* with the account manager, we might lose the identity */
511 marie_cfg = linphone_core_get_default_proxy_config(marie->lc);
512 {
513 LinphoneAddress* marie_addr = linphone_address_clone(linphone_proxy_config_get_identity_address(marie_cfg));
514 char* marie_tmp_id = NULL;
515 linphone_address_set_display_name(marie_addr, "Super Marie");
516 marie_tmp_id = linphone_address_as_string(marie_addr);
517
518 linphone_proxy_config_edit(marie_cfg);
519 linphone_proxy_config_set_identity(marie_cfg,marie_tmp_id);
520 linphone_proxy_config_done(marie_cfg);
521
522 ms_free(marie_tmp_id);
523 linphone_address_unref(marie_addr);
524 }
525
526 linphone_core_enable_audio_multicast(pauline->lc,enable_multicast_recv_side);
527
528 BC_ASSERT_TRUE(call(marie,pauline));
529 pauline_call=linphone_core_get_current_call(pauline->lc);
530 BC_ASSERT_PTR_NOT_NULL(pauline_call);
531 /*check that display name is correctly propagated in From */
532 if (pauline_call){
533 from=linphone_call_get_remote_address(linphone_core_get_current_call(pauline->lc));
534 BC_ASSERT_PTR_NOT_NULL(from);
535 if (from){
536 const char *dname=linphone_address_get_display_name(from);
537 BC_ASSERT_PTR_NOT_NULL(dname);
538 if (dname){
539 BC_ASSERT_STRING_EQUAL(dname, "Super Marie");
540 }
541 }
542 }
543
544 liblinphone_tester_check_rtcp(marie,pauline);
545 end_call(marie,pauline);
546 linphone_core_manager_destroy(pauline);
547 linphone_core_manager_destroy(marie);
548 }
549
simple_call(void)550 static void simple_call(void) {
551 simple_call_base(FALSE);
552 }
553
554 /*This test is added to reproduce a crash when a call is failed synchronously*/
simple_call_with_no_sip_transport(void)555 static void simple_call_with_no_sip_transport(void){
556 LinphoneCoreManager* marie;
557 LinphoneCoreManager* pauline;
558 LinphoneSipTransports tr={0};
559 LinphoneCall *call;
560
561 marie = linphone_core_manager_new( "marie_rc");
562 pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
563
564 /*disable all transports so that the call will fail synchronously*/
565 linphone_core_set_sip_transports(marie->lc, &tr);
566
567 call = linphone_core_invite_address(marie->lc, pauline->identity);
568 BC_ASSERT_PTR_NULL(call);
569 linphone_core_manager_destroy(pauline);
570 linphone_core_manager_destroy(marie);
571 }
572
simple_call_with_udp(void)573 static void simple_call_with_udp(void) {
574 LinphoneCoreManager* michelle;
575 LinphoneCoreManager* laure;
576 const LinphoneAddress *from;
577 LinphoneCall *laure_call;
578 LinphoneProxyConfig* michelle_cfg;
579
580 michelle = linphone_core_manager_new( "michelle_rc_udp");
581 laure = linphone_core_manager_new("laure_rc_udp");
582
583 /* with the account manager, we might lose the identity */
584 michelle_cfg = linphone_core_get_default_proxy_config(michelle->lc);
585 {
586 LinphoneAddress* michelle_addr = linphone_address_clone(linphone_proxy_config_get_identity_address(michelle_cfg));
587 char* michelle_tmp_id = NULL;
588 linphone_address_set_display_name(michelle_addr, "Super michelle");
589 michelle_tmp_id = linphone_address_as_string(michelle_addr);
590
591 linphone_proxy_config_edit(michelle_cfg);
592 linphone_proxy_config_set_identity(michelle_cfg,michelle_tmp_id);
593 linphone_proxy_config_done(michelle_cfg);
594
595 ms_free(michelle_tmp_id);
596 linphone_address_unref(michelle_addr);
597 }
598
599 BC_ASSERT_TRUE(call(michelle,laure));
600 laure_call=linphone_core_get_current_call(laure->lc);
601 BC_ASSERT_PTR_NOT_NULL(laure_call);
602 /*check that display name is correctly propagated in From */
603 if (laure_call){
604 from=linphone_call_get_remote_address(linphone_core_get_current_call(laure->lc));
605 BC_ASSERT_PTR_NOT_NULL(from);
606 if (from){
607 const char *dname=linphone_address_get_display_name(from);
608 BC_ASSERT_PTR_NOT_NULL(dname);
609 if (dname){
610 BC_ASSERT_STRING_EQUAL(dname, "Super michelle");
611 }
612 }
613 }
614
615 liblinphone_tester_check_rtcp(michelle,laure);
616 end_call(michelle,laure);
617 linphone_core_manager_destroy(laure);
618 linphone_core_manager_destroy(michelle);
619 }
620
automatic_call_termination(void)621 static void automatic_call_termination(void) {
622 LinphoneCoreManager* marie;
623 LinphoneCoreManager* pauline;
624
625 marie = linphone_core_manager_new( "marie_rc");
626 pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
627
628
629 if (!BC_ASSERT_TRUE(call(marie,pauline))) goto end;
630
631 liblinphone_tester_check_rtcp(marie,pauline);
632
633 linphone_core_destroy(pauline->lc);
634 pauline->lc = NULL;
635 /*marie shall receive the BYE*/
636 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallEnd, 1));
637 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallReleased, 1));
638 end:
639 linphone_core_manager_destroy(pauline);
640 linphone_core_manager_destroy(marie);
641 }
642
call_with_timed_out_bye(void)643 static void call_with_timed_out_bye(void) {
644 LinphoneCoreManager* marie;
645 LinphoneCoreManager* pauline;
646 belle_sip_timer_config_t timer_config;
647
648 marie = linphone_core_manager_new( "marie_rc");
649 pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
650
651 BC_ASSERT_TRUE(call(marie,pauline));
652
653 sal_set_send_error(pauline->lc->sal,1500); /*to trash the message without generating error*/
654 timer_config.T1=50; /*to have timer F = 3s*/
655 timer_config.T2=4000;
656 timer_config.T3=0;
657 timer_config.T4=5000;
658
659 belle_sip_stack_set_timer_config(sal_get_stack_impl(pauline->lc->sal),&timer_config);
660 linphone_core_terminate_all_calls(pauline->lc);
661
662 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
663 BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallReleased,1,timer_config.T1*84));
664
665 sal_set_send_error(pauline->lc->sal,0);
666
667 linphone_core_terminate_all_calls(marie->lc);
668 BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1,5000));
669 BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallReleased,1,5000));
670
671 linphone_core_manager_destroy(marie);
672 linphone_core_manager_destroy(pauline);
673 }
674
direct_call_over_ipv6(void)675 static void direct_call_over_ipv6(void){
676 LinphoneCoreManager* marie;
677 LinphoneCoreManager* pauline;
678
679 if (liblinphone_tester_ipv6_available()){
680 LinphoneSipTransports pauline_transports;
681 LinphoneAddress* pauline_dest = linphone_address_new("sip:[::1];transport=tcp");
682 marie = linphone_core_manager_new( "marie_rc");
683 pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
684
685 linphone_core_enable_ipv6(marie->lc,TRUE);
686 linphone_core_enable_ipv6(pauline->lc,TRUE);
687 linphone_core_set_default_proxy_config(marie->lc,NULL);
688 linphone_core_set_default_proxy_config(pauline->lc, NULL);
689
690 linphone_core_get_sip_transports_used(pauline->lc,&pauline_transports);
691 linphone_address_set_port(pauline_dest,pauline_transports.tcp_port);
692 linphone_core_invite_address(marie->lc,pauline_dest);
693
694 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallOutgoingRinging,1));
695 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallIncomingReceived,1));
696 linphone_call_accept(linphone_core_get_current_call(pauline->lc));
697 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,1));
698 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,1));
699
700 liblinphone_tester_check_rtcp(marie,pauline);
701 end_call(marie,pauline);
702 linphone_core_manager_destroy(marie);
703 linphone_core_manager_destroy(pauline);
704 linphone_address_unref(pauline_dest);
705 }else ms_warning("Test skipped, no ipv6 available");
706 }
707
call_outbound_with_multiple_proxy(void)708 static void call_outbound_with_multiple_proxy(void) {
709 LinphoneCoreManager* marie = linphone_core_manager_new2( "marie_rc", FALSE);
710 LinphoneCoreManager* pauline = linphone_core_manager_new2( "pauline_tcp_rc", FALSE);
711
712 LinphoneProxyConfig* lpc = NULL;
713 LinphoneProxyConfig* registered_lpc = linphone_core_create_proxy_config(marie->lc);
714
715 lpc = linphone_core_get_default_proxy_config(marie->lc);
716 linphone_core_set_default_proxy(marie->lc,NULL);
717
718 if (!BC_ASSERT_PTR_NOT_NULL(lpc) || !BC_ASSERT_PTR_NOT_NULL(registered_lpc)) return;
719
720 // create new LPC that will successfully register
721 linphone_proxy_config_set_identity(registered_lpc, linphone_proxy_config_get_identity(lpc));
722 linphone_proxy_config_set_server_addr(registered_lpc, linphone_proxy_config_get_addr(lpc));
723 linphone_proxy_config_set_route(registered_lpc, linphone_proxy_config_get_route(lpc));
724 linphone_proxy_config_enable_register(registered_lpc, TRUE);
725
726 linphone_core_add_proxy_config(marie->lc, registered_lpc);
727 linphone_proxy_config_unref(registered_lpc);
728
729 // set first LPC to unreacheable proxy addr
730 linphone_proxy_config_edit(lpc);
731 linphone_proxy_config_set_server_addr(lpc,"sip:linphone.org:9016;transport=udp");
732 linphone_proxy_config_set_route(lpc, "sip:linphone.org:9016;transport=udp;lr");
733 linphone_proxy_config_done(lpc);
734
735 BC_ASSERT_TRUE(wait_for_until(pauline->lc, NULL, &pauline->stat.number_of_LinphoneRegistrationOk, 1, 10000));
736
737 BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneRegistrationProgress, 2, 200));
738 BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneRegistrationOk, 1, 10000));
739
740 // calling marie should go through the second proxy config
741 BC_ASSERT_TRUE(call(marie, pauline));
742
743 end_call(marie, pauline);
744 linphone_core_manager_destroy(marie);
745 linphone_core_manager_destroy(pauline);
746 }
747
748 #if 0 /* TODO: activate test when the implementation is ready */
749 static void multiple_answers_call(void) {
750 /* Scenario is this: pauline calls marie, which is registered 2 times.
751 Both linphones answer at the same time, and only one should get the
752 call running, the other should be terminated */
753 LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc" );
754 LinphoneCoreManager* marie1 = linphone_core_manager_new( "marie_rc" );
755 LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc" );
756
757 LinphoneCall* call1, *call2;
758
759 bctbx_list_t* lcs = bctbx_list_append(NULL,pauline->lc);
760 lcs = bctbx_list_append(lcs,marie1->lc);
761 lcs = bctbx_list_append(lcs,marie2->lc);
762
763
764 BC_ASSERT_TRUE(wait_for_until(pauline->lc, NULL, &pauline->stat.number_of_LinphoneRegistrationOk, 1, 2000));
765
766 BC_ASSERT_PTR_NOT_NULL( linphone_core_invite_address(pauline->lc, marie1->identity ) );
767
768 BC_ASSERT_TRUE(wait_for_list(lcs,&marie1->stat.number_of_LinphoneCallIncomingReceived, 1, 2000));
769 BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallIncomingReceived, 1, 2000));
770 BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallOutgoingProgress, 1, 2000));
771
772 // marie 1 and 2 answer at the same time
773 call1 = linphone_core_get_current_call(marie1->lc);
774 call2 = linphone_core_get_current_call(marie2->lc);
775
776 BC_ASSERT_PTR_NOT_NULL_FATAL(call1);
777 BC_ASSERT_PTR_NOT_NULL_FATAL(call2);
778
779 BC_ASSERT_EQUAL( linphone_core_accept_call(marie1->lc, call1), 0, int, "%d");
780 BC_ASSERT_EQUAL( linphone_core_accept_call(marie2->lc, call2), 0, int, "%d");
781
782 BC_ASSERT_TRUE( wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1, 2000) );
783 BC_ASSERT_TRUE( wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallStreamsRunning, 1, 2000) );
784 BC_ASSERT_TRUE( wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallEnd, 1, 2000) );
785
786
787 linphone_core_manager_destroy(pauline);
788 linphone_core_manager_destroy(marie1);
789 linphone_core_manager_destroy(marie2);
790 }
791 #endif
792
multiple_answers_call_with_media_relay(void)793 static void multiple_answers_call_with_media_relay(void) {
794
795 /* Scenario is this: pauline calls marie, which is registered 2 times.
796 * Both linphones answer at the same time, and only one should get the
797 * call running, the other should be terminated */
798 LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc" );
799 LinphoneCoreManager* marie1 = linphone_core_manager_new( "marie_rc" );
800 LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc" );
801
802 LinphoneCall* call1, *call2;
803
804 bctbx_list_t* lcs = bctbx_list_append(NULL,pauline->lc);
805 lcs = bctbx_list_append(lcs,marie1->lc);
806 lcs = bctbx_list_append(lcs,marie2->lc);
807
808 linphone_core_set_user_agent(pauline->lc, "Natted Linphone", NULL);
809 linphone_core_set_user_agent(marie1->lc, "Natted Linphone", NULL);
810 linphone_core_set_user_agent(marie2->lc, "Natted Linphone", NULL);
811
812 BC_ASSERT_TRUE(wait_for_until(pauline->lc, NULL, &pauline->stat.number_of_LinphoneRegistrationOk, 1, 2000));
813
814 BC_ASSERT_PTR_NOT_NULL( linphone_core_invite_address(pauline->lc, marie1->identity ) );
815
816 BC_ASSERT_TRUE(wait_for_list(lcs,&marie1->stat.number_of_LinphoneCallIncomingReceived, 1, 2000));
817 BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallIncomingReceived, 1, 2000));
818 BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallOutgoingProgress, 1, 2000));
819
820 // marie 1 and 2 answer at the same time
821 call1 = linphone_core_get_current_call(marie1->lc);
822 call2 = linphone_core_get_current_call(marie2->lc);
823
824 if (BC_ASSERT_PTR_NOT_NULL(call1) && BC_ASSERT_PTR_NOT_NULL(call2)) {
825 BC_ASSERT_EQUAL( linphone_call_accept(call1), 0, int, "%d");
826 ms_sleep(1); /*sleep to make sure that the 200OK of marie1 reaches the server first*/
827 BC_ASSERT_EQUAL( linphone_call_accept(call2), 0, int, "%d");
828
829 BC_ASSERT_TRUE( wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1, 2000) );
830 BC_ASSERT_TRUE( wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallStreamsRunning, 1, 2000) );
831 /*the server will send a bye to marie2, as is 200Ok arrived second*/
832 BC_ASSERT_TRUE( wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallEnd, 1, 4000) );
833
834 end_call(marie1, pauline);
835 }
836
837 linphone_core_manager_destroy(pauline);
838 linphone_core_manager_destroy(marie1);
839 linphone_core_manager_destroy(marie2);
840 bctbx_list_free(lcs);
841 }
842
call_with_specified_codec_bitrate(void)843 static void call_with_specified_codec_bitrate(void) {
844 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
845 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
846 bool_t call_ok;
847 const char * codec = "opus";
848 int rate = 48000;
849 int min_bw=24;
850 int max_bw=50;
851
852 #ifdef __arm__
853 if (ms_factory_get_cpu_count(marie->lc->factory) <2) { /*2 opus codec channel + resampler is too much for a single core*/
854 #ifndef __ANDROID__
855 codec = "speex";
856 rate = 8000;
857 min_bw=20;
858 max_bw=35;
859 #else
860 BC_PASS("Test requires at least a dual core");
861 goto end;
862 #endif
863 }
864 #endif
865 /*Force marie to play from file: if soundcard is used and it is silient, then vbr mode will drop down the bitrate
866 Note that a play file is already set by linphone_core_manager_new() (but not used)*/
867 linphone_core_set_use_files(marie->lc, TRUE);
868
869 if (linphone_core_find_payload_type(marie->lc,codec,rate,-1)==NULL){
870 BC_PASS("opus codec not supported, test skipped.");
871 goto end;
872 }
873
874 disable_all_audio_codecs_except_one(marie->lc,codec,rate);
875 disable_all_audio_codecs_except_one(pauline->lc,codec,rate);
876
877 linphone_core_set_payload_type_bitrate(marie->lc,
878 linphone_core_find_payload_type(marie->lc,codec,rate,-1),
879 max_bw);
880 linphone_core_set_payload_type_bitrate(pauline->lc,
881 linphone_core_find_payload_type(pauline->lc,codec,rate,-1),
882 min_bw);
883
884 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
885 if (!call_ok) goto end;
886 liblinphone_tester_check_rtcp(marie,pauline);
887 /*wait a bit that bitstreams are stabilized*/
888 wait_for_until(marie->lc, pauline->lc, NULL, 0, 2000);
889
890 BC_ASSERT_LOWER(linphone_core_manager_get_mean_audio_down_bw(marie), (int)(min_bw+5+min_bw*.1), int, "%i");
891 BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(marie), 10, int, "%i"); /*check that at least something is received */
892 BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(pauline), (int)(max_bw-5-max_bw*.1), int, "%i");
893
894 end_call(pauline, marie);
895 end:
896 linphone_core_manager_destroy(marie);
897 linphone_core_manager_destroy(pauline);
898 }
899
900
disable_all_codecs(const bctbx_list_t * elem,LinphoneCoreManager * call)901 void disable_all_codecs(const bctbx_list_t* elem, LinphoneCoreManager* call){
902
903 PayloadType *pt;
904
905 for(;elem!=NULL;elem=elem->next){
906 pt=(PayloadType*)elem->data;
907 linphone_core_enable_payload_type(call->lc,pt,FALSE);
908 }
909 }
910 /***
911 Disable all audio codecs , sends an INVITE with RTP port 0 and payload 0.
912 Wait for SIP 488 unacceptable.
913 ***/
call_with_no_audio_codec(void)914 static void call_with_no_audio_codec(void){
915
916 LinphoneCoreManager* callee = linphone_core_manager_new("marie_rc");
917 LinphoneCoreManager* caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc");
918 LinphoneCall* out_call ;
919
920 const bctbx_list_t* elem =linphone_core_get_audio_codecs(caller->lc);
921
922 disable_all_codecs(elem, caller);
923
924
925 out_call = linphone_core_invite_address(caller->lc,callee->identity);
926 linphone_call_ref(out_call);
927 BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallOutgoingInit, 1));
928
929
930 BC_ASSERT_TRUE(wait_for_until(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallError, 1, 6000));
931 BC_ASSERT_EQUAL(linphone_call_get_reason(out_call), LinphoneReasonNotAcceptable, int, "%d");
932 BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallIncomingReceived, 0, int, "%d");
933
934 linphone_call_unref(out_call);
935 linphone_core_manager_destroy(callee);
936 linphone_core_manager_destroy(caller);
937
938 }
939
simple_call_compatibility_mode(void)940 static void simple_call_compatibility_mode(void) {
941 char route[256];
942 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
943 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
944
945 LinphoneCore* lc_marie=marie->lc;
946 LinphoneCore* lc_pauline=pauline->lc;
947 stats* stat_marie=&marie->stat;
948 stats* stat_pauline=&pauline->stat;
949 LinphoneProxyConfig* proxy;
950 const LinphoneAddress* identity;
951 LinphoneAddress* proxy_address;
952 char*tmp;
953 LinphoneSipTransports transport;
954
955 proxy = linphone_core_get_default_proxy_config(lc_marie);
956 BC_ASSERT_PTR_NOT_NULL (proxy);
957 identity = linphone_proxy_config_get_identity_address(proxy);
958
959
960 proxy_address=linphone_address_new(linphone_proxy_config_get_addr(proxy));
961 linphone_address_clean(proxy_address);
962 tmp=linphone_address_as_string_uri_only(proxy_address);
963 linphone_proxy_config_set_server_addr(proxy,tmp);
964 sprintf(route,"sip:%s",test_route);
965 linphone_proxy_config_set_route(proxy,route);
966 ms_free(tmp);
967 linphone_address_unref(proxy_address);
968 linphone_core_get_sip_transports(lc_marie,&transport);
969 transport.udp_port=0;
970 transport.tls_port=0;
971 transport.dtls_port=0;
972 /*only keep tcp*/
973 linphone_core_set_sip_transports(lc_marie,&transport);
974 stat_marie->number_of_LinphoneRegistrationOk=0;
975
976 BC_ASSERT_TRUE (wait_for(lc_marie,lc_marie,&stat_marie->number_of_LinphoneRegistrationOk,1));
977
978 linphone_core_invite_address(lc_marie,pauline->identity);
979
980 BC_ASSERT_TRUE (wait_for(lc_pauline,lc_marie,&stat_pauline->number_of_LinphoneCallIncomingReceived,1));
981 BC_ASSERT_TRUE(linphone_core_inc_invite_pending(lc_pauline));
982 BC_ASSERT_EQUAL(stat_marie->number_of_LinphoneCallOutgoingProgress,1, int, "%d");
983 BC_ASSERT_TRUE(wait_for(lc_pauline,lc_marie,&stat_marie->number_of_LinphoneCallOutgoingRinging,1));
984
985 BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call_remote_address(lc_pauline));
986 if (linphone_core_get_current_call_remote_address(lc_pauline)) {
987 BC_ASSERT_TRUE(linphone_address_weak_equal(identity,linphone_core_get_current_call_remote_address(lc_pauline)));
988
989 linphone_call_accept(linphone_core_get_current_call(lc_pauline));
990
991 BC_ASSERT_TRUE(wait_for(lc_pauline,lc_marie,&stat_pauline->number_of_LinphoneCallConnected,1));
992 BC_ASSERT_TRUE(wait_for(lc_pauline,lc_marie,&stat_marie->number_of_LinphoneCallConnected,1));
993 BC_ASSERT_TRUE(wait_for(lc_pauline,lc_marie,&stat_pauline->number_of_LinphoneCallStreamsRunning,1));
994 BC_ASSERT_TRUE(wait_for(lc_pauline,lc_marie,&stat_marie->number_of_LinphoneCallStreamsRunning,1));
995
996 wait_for(lc_pauline,lc_marie,&stat_marie->number_of_LinphoneCallStreamsRunning,3);
997 end_call(pauline, marie);
998 }
999 linphone_core_manager_destroy(marie);
1000 linphone_core_manager_destroy(pauline);
1001 }
1002
terminate_call_with_error(void)1003 static void terminate_call_with_error(void) {
1004 LinphoneCall* call_callee ;
1005 LinphoneErrorInfo *ei ;
1006 const LinphoneErrorInfo *rei = NULL;
1007 LinphoneCoreManager *callee_mgr = linphone_core_manager_new("marie_rc");
1008 LinphoneCoreManager *caller_mgr = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1009
1010 LinphoneCall* out_call = linphone_core_invite_address(caller_mgr->lc,callee_mgr->identity);
1011
1012 linphone_call_ref(out_call);
1013 ei = linphone_error_info_new();
1014 linphone_error_info_set(ei, NULL, LinphoneReasonNone, 200, "Call refused for security reason", NULL);
1015
1016 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallOutgoingInit,1));
1017 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallIncomingReceived, 1));
1018 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallOutgoingProgress, 1));
1019
1020 call_callee = linphone_core_get_current_call(callee_mgr->lc);
1021 linphone_call_ref(call_callee);
1022 BC_ASSERT_PTR_NOT_NULL(call_callee);
1023
1024 BC_ASSERT_EQUAL( linphone_core_accept_call(callee_mgr->lc,call_callee), 0 , int, "%d");
1025 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallConnected,1));
1026
1027 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallStreamsRunning, 1));
1028 BC_ASSERT_PTR_NOT_NULL(ei);
1029 if (ei){
1030 BC_ASSERT_EQUAL(linphone_error_info_get_protocol_code(ei),200, int, "%d");
1031 BC_ASSERT_PTR_NOT_NULL(linphone_error_info_get_phrase(ei));
1032 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_phrase(ei), "Call refused for security reason");
1033 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_protocol(ei), "SIP");
1034 }
1035 linphone_call_terminate_with_error_info(out_call,ei);
1036 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallEnd,1));
1037 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallReleased,1));
1038
1039 rei = linphone_call_get_error_info(call_callee);
1040 BC_ASSERT_PTR_NOT_NULL(rei);
1041 if (rei){
1042 BC_ASSERT_EQUAL(linphone_error_info_get_protocol_code(rei),200, int, "%d");
1043 BC_ASSERT_PTR_NOT_NULL(linphone_error_info_get_phrase(rei));
1044 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_phrase(rei), "Call refused for security reason");
1045 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_protocol(ei), "SIP");
1046 }
1047
1048 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallReleased,1));
1049
1050 linphone_error_info_unref(ei);
1051 linphone_call_unref(out_call);
1052 linphone_call_unref(call_callee);
1053 linphone_core_manager_destroy(callee_mgr);
1054 linphone_core_manager_destroy(caller_mgr);
1055 }
1056
cancel_call_with_error(void)1057 static void cancel_call_with_error(void) {
1058 LinphoneCall* call_callee ;
1059 LinphoneErrorInfo *ei ;
1060 const LinphoneErrorInfo *rei = NULL;
1061 LinphoneCoreManager *callee_mgr = linphone_core_manager_new("marie_rc");
1062 LinphoneCoreManager *caller_mgr = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1063
1064 LinphoneCall* out_call = linphone_core_invite_address(caller_mgr->lc,callee_mgr->identity);
1065
1066 linphone_call_ref(out_call);
1067 ei = linphone_error_info_new();
1068 linphone_error_info_set(ei, NULL, LinphoneReasonNone, 600, "Call has been cancelled", NULL);
1069
1070 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallOutgoingInit,1));
1071 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallIncomingReceived, 1));
1072 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallOutgoingProgress, 1));
1073
1074 call_callee = linphone_core_get_current_call(callee_mgr->lc);
1075 linphone_call_ref(call_callee);
1076
1077 BC_ASSERT_PTR_NOT_NULL(call_callee);
1078 BC_ASSERT_PTR_NOT_NULL(ei);
1079 if (ei){
1080 BC_ASSERT_EQUAL(linphone_error_info_get_protocol_code(ei),600, int, "%d");
1081 BC_ASSERT_PTR_NOT_NULL(linphone_error_info_get_phrase(ei));
1082 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_phrase(ei), "Call has been cancelled");
1083 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_protocol(ei), "SIP");
1084 }
1085 linphone_call_terminate_with_error_info(out_call,ei);
1086 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallEnd,1));
1087 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallReleased,1));
1088
1089 rei = linphone_call_get_error_info(call_callee);
1090 BC_ASSERT_PTR_NOT_NULL(rei);
1091 if (rei){
1092 BC_ASSERT_EQUAL(linphone_error_info_get_protocol_code(rei),600, int, "%d");
1093 BC_ASSERT_PTR_NOT_NULL(linphone_error_info_get_phrase(rei));
1094 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_phrase(rei), "Call has been cancelled");
1095 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_protocol(rei), "SIP");
1096 }
1097
1098 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallReleased,1));
1099
1100 linphone_error_info_unref(ei);
1101 linphone_call_unref(out_call);
1102 linphone_call_unref(call_callee);
1103 linphone_core_manager_destroy(callee_mgr);
1104 linphone_core_manager_destroy(caller_mgr);
1105 }
1106
cancel_other_device_after_accept(void)1107 static void cancel_other_device_after_accept(void) {
1108 LinphoneCall* call_callee = NULL;
1109 LinphoneCall* call_callee_2 = NULL ;
1110 const LinphoneErrorInfo *rei = NULL;
1111 LinphoneCoreManager *callee_mgr = linphone_core_manager_new("marie_rc");
1112 LinphoneCoreManager *callee_mgr_2 = linphone_core_manager_new("marie_rc");
1113 LinphoneCoreManager *caller_mgr = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1114
1115 LinphoneCall* out_call = linphone_core_invite_address(caller_mgr->lc,callee_mgr->identity);
1116 linphone_call_ref(out_call);
1117
1118 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallOutgoingInit,1));
1119 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallIncomingReceived, 1));
1120 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallOutgoingProgress, 1));
1121 call_callee = linphone_core_get_current_call(callee_mgr->lc);
1122 if (BC_ASSERT_PTR_NOT_NULL(call_callee)) {
1123
1124 linphone_call_ref(call_callee);
1125
1126 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr_2->lc, &callee_mgr_2->stat.number_of_LinphoneCallIncomingReceived, 1));
1127 call_callee_2 = linphone_core_get_current_call(callee_mgr_2->lc);
1128 linphone_call_ref(call_callee_2);
1129 BC_ASSERT_PTR_NOT_NULL(call_callee_2);
1130
1131 BC_ASSERT_EQUAL( linphone_call_accept(call_callee), 0 , int, "%d");
1132 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallConnected,1));
1133 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallStreamsRunning, 1));
1134 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr_2->lc,&callee_mgr_2->stat.number_of_LinphoneCallEnd,1));
1135 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr_2->lc,&callee_mgr_2->stat.number_of_LinphoneCallReleased,1));
1136
1137 rei = linphone_call_get_error_info(call_callee_2);
1138 BC_ASSERT_PTR_NOT_NULL(rei);
1139 if (rei){
1140 BC_ASSERT_EQUAL(linphone_error_info_get_protocol_code(rei),200, int, "%d");
1141 BC_ASSERT_PTR_NOT_NULL(linphone_error_info_get_phrase(rei));
1142 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_phrase(rei), "Call completed elsewhere");
1143 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_protocol(rei), "SIP");
1144 }
1145 }
1146 linphone_call_terminate(out_call);
1147 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallEnd,1));
1148 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallReleased,1));
1149
1150 if (out_call) linphone_call_unref(out_call);
1151 if (call_callee) linphone_call_unref(call_callee);
1152 if (call_callee_2) linphone_call_unref(call_callee_2);
1153 linphone_core_manager_destroy(callee_mgr);
1154 linphone_core_manager_destroy(callee_mgr_2);
1155 linphone_core_manager_destroy(caller_mgr);
1156 }
1157
cancel_other_device_after_decline(void)1158 static void cancel_other_device_after_decline(void) {
1159 LinphoneCall* call_callee = NULL;
1160 LinphoneCall* call_callee_2 = NULL;
1161 const LinphoneErrorInfo *rei = NULL;
1162 LinphoneCoreManager *callee_mgr = linphone_core_manager_new("marie_rc");
1163 LinphoneCoreManager *callee_mgr_2 = linphone_core_manager_new("marie_rc");
1164 LinphoneCoreManager *caller_mgr = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1165
1166 LinphoneCall* out_call = linphone_core_invite_address(caller_mgr->lc,callee_mgr->identity);
1167 linphone_call_ref(out_call);
1168
1169 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallOutgoingInit,1));
1170 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallIncomingReceived, 1));
1171 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallOutgoingProgress, 1));
1172 call_callee = linphone_core_get_current_call(callee_mgr->lc);
1173 if (BC_ASSERT_PTR_NOT_NULL(call_callee)) {
1174 linphone_call_ref(call_callee);
1175
1176 BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr_2->lc, &callee_mgr_2->stat.number_of_LinphoneCallIncomingReceived, 1));
1177 call_callee_2 = linphone_core_get_current_call(callee_mgr_2->lc);
1178 linphone_call_ref(call_callee_2);
1179 BC_ASSERT_PTR_NOT_NULL(call_callee_2);
1180
1181 BC_ASSERT_EQUAL(linphone_call_decline(call_callee, LinphoneReasonDeclined), 0 , int, "%d");
1182 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallEnd,1));
1183 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallReleased, 1));
1184 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr_2->lc,&callee_mgr_2->stat.number_of_LinphoneCallEnd,1));
1185 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr_2->lc,&callee_mgr_2->stat.number_of_LinphoneCallReleased,1));
1186
1187 rei = linphone_call_get_error_info(call_callee_2);
1188 BC_ASSERT_PTR_NOT_NULL(rei);
1189 if (rei){
1190 BC_ASSERT_EQUAL(linphone_error_info_get_protocol_code(rei),600, int, "%d");
1191 BC_ASSERT_PTR_NOT_NULL(linphone_error_info_get_phrase(rei));
1192 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_phrase(rei), "Busy Everywhere");
1193 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_protocol(rei), "SIP");
1194 }
1195 }
1196 if (out_call) linphone_call_unref(out_call);
1197 if (call_callee) linphone_call_unref(call_callee);
1198 if (call_callee_2) linphone_call_unref(call_callee_2);
1199 linphone_core_manager_destroy(callee_mgr);
1200 linphone_core_manager_destroy(callee_mgr_2);
1201 linphone_core_manager_destroy(caller_mgr);
1202 }
1203
cancelled_call(void)1204 static void cancelled_call(void) {
1205 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
1206 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1207
1208 LinphoneCall* out_call = linphone_core_invite_address(pauline->lc,marie->identity);
1209 linphone_call_ref(out_call);
1210 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallOutgoingInit,1));
1211
1212 linphone_call_terminate(out_call);
1213 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
1214 //BC_ASSERT_EQUAL(linphone_call_get_reason(out_call),LinphoneReasonCanceled, int, "%d");
1215 BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallEnd,1, int, "%d");
1216 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallIncomingReceived,0, int, "%d");
1217 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallReleased,1));
1218
1219 linphone_call_unref(out_call);
1220 linphone_core_manager_destroy(marie);
1221 linphone_core_manager_destroy(pauline);
1222 }
1223
disable_all_audio_codecs_except_one(LinphoneCore * lc,const char * mime,int rate)1224 void disable_all_audio_codecs_except_one(LinphoneCore *lc, const char *mime, int rate){
1225 const bctbx_list_t *elem=linphone_core_get_audio_codecs(lc);
1226 PayloadType *pt;
1227
1228 for(;elem!=NULL;elem=elem->next){
1229 pt=(PayloadType*)elem->data;
1230 linphone_core_enable_payload_type(lc,pt,FALSE);
1231 }
1232 pt=linphone_core_find_payload_type(lc,mime,rate,-1);
1233 if (BC_ASSERT_PTR_NOT_NULL(pt)) {
1234 linphone_core_enable_payload_type(lc,pt,TRUE);
1235 }
1236 }
1237
disable_all_video_codecs_except_one(LinphoneCore * lc,const char * mime)1238 void disable_all_video_codecs_except_one(LinphoneCore *lc, const char *mime) {
1239 #ifdef VIDEO_ENABLED
1240 const bctbx_list_t *codecs = linphone_core_get_video_codecs(lc);
1241 const bctbx_list_t *it = NULL;
1242 PayloadType *pt = NULL;
1243
1244 for(it = codecs; it != NULL; it = it->next) {
1245 linphone_core_enable_payload_type(lc, (PayloadType *)it->data, FALSE);
1246 }
1247 pt = linphone_core_find_payload_type(lc, mime, -1, -1);
1248 if (BC_ASSERT_PTR_NOT_NULL(pt)) {
1249 linphone_core_enable_payload_type(lc, pt, TRUE);
1250 }
1251 #endif
1252 }
1253
call_with_dns_time_out(void)1254 static void call_with_dns_time_out(void) {
1255 LinphoneCoreManager* marie = linphone_core_manager_new2( "empty_rc", FALSE);
1256 LinphoneSipTransports transport = {9773,0,0,0};
1257 int i;
1258
1259 linphone_core_set_sip_transports(marie->lc,&transport);
1260 linphone_core_iterate(marie->lc);
1261 sal_set_dns_timeout(marie->lc->sal,0);
1262 linphone_core_invite(marie->lc,"\"t\x8et\x8e\" <sip:toto@toto.com>"); /*just to use non ascii values*/
1263 for(i=0;i<10;i++){
1264 ms_usleep(200000);
1265 linphone_core_iterate(marie->lc);
1266 }
1267 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallOutgoingInit,1, int, "%d");
1268 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallOutgoingProgress,1, int, "%d");
1269 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallError,1, int, "%d");
1270 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallReleased,1, int, "%d");
1271 linphone_core_manager_destroy(marie);
1272 }
1273
early_cancelled_call(void)1274 static void early_cancelled_call(void) {
1275 LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
1276 LinphoneCoreManager* pauline = linphone_core_manager_new2( "empty_rc",FALSE);
1277
1278 LinphoneCall* out_call = linphone_core_invite_address(pauline->lc,marie->identity);
1279
1280 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallOutgoingInit,1));
1281 const char *callID = linphone_call_log_get_call_id(linphone_call_get_call_log(out_call));
1282 BC_ASSERT_PTR_NOT_NULL(callID);
1283 linphone_call_terminate(out_call);
1284
1285 /*since everything is executed in a row, no response can be received from the server, thus the CANCEL cannot be sent.
1286 It will ring at Marie's side.*/
1287
1288 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
1289
1290 BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallEnd,1, int, "%d");
1291
1292 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallIncomingReceived,1));
1293 /* now the CANCEL should have been sent and the the call at marie's side should terminate*/
1294 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
1295
1296 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallReleased,1));
1297
1298 linphone_core_manager_destroy(marie);
1299 linphone_core_manager_destroy(pauline);
1300 }
1301
cancelled_ringing_call(void)1302 static void cancelled_ringing_call(void) {
1303 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
1304 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1305 const bctbx_list_t * call_history;
1306 LinphoneCall* out_call;
1307
1308 char * db_path= bctbx_strdup_printf("%s,%s",bc_tester_get_writable_dir_prefix(),"tmp_call_log.db");
1309 linphone_core_set_call_logs_database_path(marie->lc,db_path);
1310
1311
1312 out_call = linphone_core_invite_address(pauline->lc,marie->identity);
1313 linphone_call_ref(out_call);
1314 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallIncomingReceived,1));
1315
1316 linphone_call_terminate(out_call);
1317 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallReleased,1));
1318 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallReleased,1));
1319 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallEnd,1, int, "%d");
1320 BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallEnd,1, int, "%d");
1321
1322 call_history = linphone_core_get_call_history(marie->lc);
1323 BC_ASSERT_PTR_NOT_NULL(call_history);
1324 BC_ASSERT_EQUAL((int)bctbx_list_size(call_history),1, int,"%i");
1325 BC_ASSERT_EQUAL(linphone_call_log_get_status((LinphoneCallLog*)bctbx_list_get_data(call_history)), LinphoneCallMissed, LinphoneCallStatus, "%i");
1326
1327 linphone_call_unref(out_call);
1328 linphone_core_manager_destroy(marie);
1329 linphone_core_manager_destroy(pauline);
1330 unlink(db_path);
1331 bctbx_free(db_path);
1332
1333 }
1334
early_declined_call(void)1335 static void early_declined_call(void) {
1336 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
1337 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1338 LinphoneCallLog* out_call_log;
1339 LinphoneCall* out_call;
1340
1341 linphone_core_set_max_calls(marie->lc,0);
1342 out_call = linphone_core_invite_address(pauline->lc,marie->identity);
1343 linphone_call_ref(out_call);
1344
1345 /*wait until flexisip transfers the busy...*/
1346 BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallError,1,33000));
1347 BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallError,1, int, "%d");
1348 /* FIXME http://git.linphone.org/mantis/view.php?id=757
1349
1350 BC_ASSERT_EQUAL(linphone_call_get_reason(out_call),LinphoneReasonBusy, int, "%d");
1351 */
1352 if (bctbx_list_size(linphone_core_get_call_logs(pauline->lc))>0) {
1353 BC_ASSERT_PTR_NOT_NULL(out_call_log=(LinphoneCallLog*)(linphone_core_get_call_logs(pauline->lc)->data));
1354 BC_ASSERT_EQUAL(linphone_call_log_get_status(out_call_log),LinphoneCallAborted, int, "%d");
1355 }
1356 linphone_call_unref(out_call);
1357 linphone_core_manager_destroy(marie);
1358 linphone_core_manager_destroy(pauline);
1359 }
1360
call_busy_when_calling_self(void)1361 static void call_busy_when_calling_self(void) {
1362 LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
1363 LinphoneCall *out_call=linphone_core_invite_address(marie->lc,marie->identity);
1364 linphone_call_ref(out_call);
1365
1366 /*wait until flexisip transfers the busy...*/
1367 BC_ASSERT_TRUE(wait_for_until(marie->lc,marie->lc,&marie->stat.number_of_LinphoneCallError,1,33000));
1368 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallError,1, int, "%d");
1369
1370 BC_ASSERT_EQUAL(linphone_call_get_reason(out_call),LinphoneReasonBusy, int, "%d");
1371 linphone_call_unref(out_call);
1372 linphone_core_manager_destroy(marie);
1373 }
1374
call_declined_with_error(void)1375 static void call_declined_with_error(void) {
1376 LinphoneCoreManager* callee_mgr = linphone_core_manager_new("marie_rc");
1377 LinphoneCoreManager* caller_mgr = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1378
1379 LinphoneCall* in_call = NULL;
1380 LinphoneCall* out_call = linphone_core_invite_address(caller_mgr->lc,callee_mgr->identity);
1381 LinphoneFactory* factory = linphone_factory_get();
1382 const LinphoneErrorInfo* rcvd_ei;
1383 const LinphoneErrorInfo* sub_rcvd_ei;
1384
1385 LinphoneErrorInfo *ei = linphone_factory_create_error_info(factory);
1386 LinphoneErrorInfo *reason_ei = linphone_factory_create_error_info(factory);
1387
1388 linphone_error_info_set(ei, "SIP", LinphoneReasonUnknown, 603, "Decline", NULL); //ordre des arguments à vérifier
1389 linphone_error_info_set(reason_ei, "hardware", LinphoneReasonUnknown, 66, "J'ai plus de batterie", NULL);
1390
1391 linphone_error_info_set_sub_error_info(ei, reason_ei);
1392
1393 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallIncomingReceived,1));
1394 BC_ASSERT_PTR_NOT_NULL(in_call=linphone_core_get_current_call(callee_mgr->lc));
1395
1396 linphone_call_ref(out_call);
1397 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallIncomingReceived,1));
1398 BC_ASSERT_PTR_NOT_NULL(in_call=linphone_core_get_current_call(callee_mgr->lc));
1399 if (in_call) {
1400 linphone_call_ref(in_call);
1401 linphone_call_decline_with_error_info(in_call, ei);
1402
1403 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallEnd,1));
1404 BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallEnd,1));
1405
1406 rcvd_ei = linphone_call_get_error_info(out_call);
1407 sub_rcvd_ei = linphone_error_info_get_sub_error_info(rcvd_ei);
1408
1409 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_phrase(rcvd_ei), "Decline");
1410 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_protocol(rcvd_ei), "SIP");
1411 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_phrase(sub_rcvd_ei), "J'ai plus de batterie");
1412 BC_ASSERT_STRING_EQUAL(linphone_error_info_get_protocol(sub_rcvd_ei), "hardware");
1413
1414 BC_ASSERT_EQUAL(linphone_call_get_reason(in_call),LinphoneReasonDeclined, int, "%d");
1415 BC_ASSERT_EQUAL(linphone_call_log_get_status(linphone_call_get_call_log(in_call)),LinphoneCallDeclined, int, "%d");
1416 BC_ASSERT_EQUAL(linphone_call_get_reason(out_call),LinphoneReasonDeclined, int, "%d");
1417 BC_ASSERT_EQUAL(linphone_call_log_get_status(linphone_call_get_call_log(out_call)),LinphoneCallDeclined, int, "%d");
1418
1419
1420 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallReleased,1));
1421 BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallReleased,1));
1422 linphone_call_unref(in_call);
1423 }
1424 linphone_call_unref(out_call);
1425 linphone_error_info_unref(reason_ei);
1426 linphone_error_info_unref(ei);
1427
1428 linphone_core_manager_destroy(callee_mgr);
1429 linphone_core_manager_destroy(caller_mgr);
1430 }
1431
call_declined(void)1432 static void call_declined(void) {
1433 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
1434 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1435
1436 LinphoneCall* in_call;
1437 LinphoneCall* out_call = linphone_core_invite_address(pauline->lc,marie->identity);
1438 linphone_call_ref(out_call);
1439 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallIncomingReceived,1));
1440 BC_ASSERT_PTR_NOT_NULL(in_call=linphone_core_get_current_call(marie->lc));
1441 if (in_call) {
1442 linphone_call_ref(in_call);
1443 linphone_call_terminate(in_call);
1444 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallReleased,1));
1445 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallReleased,1));
1446 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallEnd,1, int, "%d");
1447 BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallEnd,1, int, "%d");
1448 BC_ASSERT_EQUAL(linphone_call_get_reason(in_call),LinphoneReasonDeclined, int, "%d");
1449 BC_ASSERT_EQUAL(linphone_call_log_get_status(linphone_call_get_call_log(in_call)),LinphoneCallDeclined, int, "%d");
1450 BC_ASSERT_EQUAL(linphone_call_get_reason(out_call),LinphoneReasonDeclined, int, "%d");
1451 BC_ASSERT_EQUAL(linphone_call_log_get_status(linphone_call_get_call_log(out_call)),LinphoneCallDeclined, int, "%d");
1452 linphone_call_unref(in_call);
1453 }
1454 linphone_call_unref(out_call);
1455 linphone_core_manager_destroy(marie);
1456 linphone_core_manager_destroy(pauline);
1457 }
1458
call_terminated_by_caller(void)1459 static void call_terminated_by_caller(void) {
1460 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
1461 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1462
1463 BC_ASSERT_TRUE(call(pauline,marie));
1464
1465 end_call(pauline, marie);
1466
1467 linphone_core_manager_destroy(marie);
1468 linphone_core_manager_destroy(pauline);
1469 }
1470
call_with_no_sdp(void)1471 static void call_with_no_sdp(void) {
1472 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
1473 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1474
1475 linphone_core_enable_sdp_200_ack(marie->lc,TRUE);
1476
1477 BC_ASSERT_TRUE(call(marie,pauline));
1478
1479 end_call(pauline, marie);
1480 linphone_core_manager_destroy(marie);
1481 linphone_core_manager_destroy(pauline);
1482 }
1483
call_with_no_sdp_ack_without_sdp(void)1484 static void call_with_no_sdp_ack_without_sdp(void){
1485 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
1486 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1487 LinphoneCall *call;
1488
1489 linphone_core_enable_sdp_200_ack(marie->lc,TRUE);
1490
1491 linphone_core_invite_address(marie->lc,pauline->identity);
1492 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallIncomingReceived,1));
1493 call=linphone_core_get_current_call(pauline->lc);
1494 if (call){
1495 sal_call_set_sdp_handling(call->op, SalOpSDPSimulateError); /*this will have the effect that the SDP received in the ACK will be ignored*/
1496 linphone_call_accept(call);
1497 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallError,1));
1498 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
1499 }
1500 linphone_core_manager_destroy(marie);
1501 linphone_core_manager_destroy(pauline);
1502 }
1503
check_nb_media_starts(LinphoneCoreManager * caller,LinphoneCoreManager * callee,unsigned int caller_nb_media_starts,unsigned int callee_nb_media_starts)1504 int check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManager *callee, unsigned int caller_nb_media_starts, unsigned int callee_nb_media_starts) {
1505 int c1_ret = FALSE, c2_ret = FALSE;
1506 LinphoneCall *c1 = linphone_core_get_current_call(caller->lc);
1507 LinphoneCall *c2 = linphone_core_get_current_call(callee->lc);
1508 BC_ASSERT_PTR_NOT_NULL(c1);
1509 BC_ASSERT_PTR_NOT_NULL(c2);
1510 if (!c1 || !c2) return FALSE;
1511
1512 if (c1) {
1513 c1_ret = c1->nb_media_starts == caller_nb_media_starts;
1514 BC_ASSERT_EQUAL(c1->nb_media_starts, caller_nb_media_starts, unsigned int, "%u");
1515 }
1516 if (c2) {
1517 c2_ret = c2->nb_media_starts == callee_nb_media_starts;
1518 BC_ASSERT_EQUAL(c2->nb_media_starts, callee_nb_media_starts, unsigned int, "%u");
1519 }
1520 return c1_ret && c2_ret;
1521 }
1522
_call_with_ice_base(LinphoneCoreManager * pauline,LinphoneCoreManager * marie,bool_t caller_with_ice,bool_t callee_with_ice,bool_t random_ports,bool_t forced_relay)1523 void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports, bool_t forced_relay) {
1524
1525 linphone_core_set_user_agent(pauline->lc, "Natted Linphone", NULL);
1526 linphone_core_set_user_agent(marie->lc, "Natted Linphone", NULL);
1527
1528 if (callee_with_ice){
1529 linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce);
1530 }
1531 if (caller_with_ice){
1532 linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce);
1533 }
1534
1535 if (random_ports){
1536 linphone_core_set_audio_port(marie->lc,-1);
1537 linphone_core_set_video_port(marie->lc,-1);
1538 linphone_core_set_text_port(marie->lc, -1);
1539 linphone_core_set_audio_port(pauline->lc,-1);
1540 linphone_core_set_video_port(pauline->lc,-1);
1541 linphone_core_set_text_port(pauline->lc, -1);
1542 }
1543
1544 if (forced_relay == TRUE) {
1545 linphone_core_enable_forced_ice_relay(marie->lc, TRUE);
1546 linphone_core_enable_forced_ice_relay(pauline->lc, TRUE);
1547 }
1548
1549 if (!BC_ASSERT_TRUE(call(pauline,marie)))
1550 return;
1551
1552 if (callee_with_ice && caller_with_ice) {
1553 /*wait for the ICE reINVITE to complete*/
1554 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
1555 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
1556
1557 if (forced_relay == TRUE) {
1558 BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateRelayConnection));
1559 } else {
1560 BC_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
1561 }
1562 check_nb_media_starts(pauline, marie, 1, 1);
1563 }
1564
1565 liblinphone_tester_check_rtcp(marie,pauline);
1566 /*then close the call*/
1567 end_call(pauline, marie);
1568 }
1569
_call_with_ice(bool_t caller_with_ice,bool_t callee_with_ice,bool_t random_ports,bool_t forced_relay,bool_t ipv6)1570 static void _call_with_ice(bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports, bool_t forced_relay, bool_t ipv6) {
1571 LinphoneCoreManager* marie = linphone_core_manager_new2("marie_rc", FALSE);
1572 LinphoneCoreManager* pauline = linphone_core_manager_new2(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc", FALSE);
1573 if (ipv6) {
1574 linphone_core_enable_ipv6(marie->lc, TRUE);
1575 linphone_core_enable_ipv6(pauline->lc, TRUE);
1576 }
1577 linphone_core_manager_start(marie, TRUE);
1578 linphone_core_manager_start(pauline, TRUE);
1579 _call_with_ice_base(pauline,marie,caller_with_ice,callee_with_ice,random_ports,forced_relay);
1580 linphone_core_manager_destroy(marie);
1581 linphone_core_manager_destroy(pauline);
1582 }
1583
call_with_ice(void)1584 static void call_with_ice(void){
1585 _call_with_ice(TRUE,TRUE,FALSE,FALSE,FALSE);
1586 }
1587
call_with_ice_ipv6(void)1588 static void call_with_ice_ipv6(void) {
1589 if (liblinphone_tester_ipv6_available()) {
1590 _call_with_ice(TRUE, TRUE, FALSE, FALSE, TRUE);
1591 } else {
1592 ms_warning("Test skipped, no ipv6 available");
1593 }
1594 }
1595
1596 /*ICE is not expected to work in this case, however this should not crash*/
call_with_ice_no_sdp(void)1597 static void call_with_ice_no_sdp(void){
1598 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
1599 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1600
1601 linphone_core_enable_sdp_200_ack(pauline->lc,TRUE);
1602
1603 linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce);
1604
1605 linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce);
1606
1607 BC_ASSERT_TRUE(call(pauline,marie));
1608
1609 liblinphone_tester_check_rtcp(marie,pauline);
1610
1611 end_call(pauline, marie);
1612 linphone_core_manager_destroy(marie);
1613 linphone_core_manager_destroy(pauline);
1614 }
1615
call_with_ice_random_ports(void)1616 static void call_with_ice_random_ports(void){
1617 _call_with_ice(TRUE,TRUE,TRUE,FALSE,FALSE);
1618 }
1619
call_with_ice_forced_relay(void)1620 static void call_with_ice_forced_relay(void) {
1621 _call_with_ice(TRUE, TRUE, TRUE, TRUE, FALSE);
1622 }
1623
ice_to_not_ice(void)1624 static void ice_to_not_ice(void){
1625 _call_with_ice(TRUE,FALSE,FALSE,FALSE,FALSE);
1626 }
1627
not_ice_to_ice(void)1628 static void not_ice_to_ice(void){
1629 _call_with_ice(FALSE,TRUE,FALSE,FALSE,FALSE);
1630 }
1631
ice_added_by_reinvite(void)1632 static void ice_added_by_reinvite(void){
1633 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
1634 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1635 LinphoneNatPolicy *pol;
1636 LinphoneCallParams *params;
1637 LinphoneCall *c;
1638 bool_t call_ok;
1639
1640 lp_config_set_int(linphone_core_get_config(marie->lc), "net", "allow_late_ice", 1);
1641 lp_config_set_int(linphone_core_get_config(pauline->lc), "net", "allow_late_ice", 1);
1642
1643 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
1644 if (!call_ok) goto end;
1645 liblinphone_tester_check_rtcp(marie,pauline);
1646
1647 /*enable ICE on both ends*/
1648 pol = linphone_core_get_nat_policy(marie->lc);
1649 linphone_nat_policy_enable_ice(pol, TRUE);
1650 linphone_nat_policy_enable_stun(pol, TRUE);
1651 linphone_core_set_nat_policy(marie->lc, pol);
1652
1653 pol = linphone_core_get_nat_policy(pauline->lc);
1654 linphone_nat_policy_enable_ice(pol, TRUE);
1655 linphone_nat_policy_enable_stun(pol, TRUE);
1656 linphone_core_set_nat_policy(pauline->lc, pol);
1657
1658 linphone_core_manager_wait_for_stun_resolution(marie);
1659 linphone_core_manager_wait_for_stun_resolution(pauline);
1660
1661 c = linphone_core_get_current_call(marie->lc);
1662 params = linphone_core_create_call_params(marie->lc, c);
1663 linphone_call_update(c, params);
1664 linphone_call_params_unref(params);
1665 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallUpdatedByRemote,1));
1666
1667 /*wait for the ICE reINVITE*/
1668 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3));
1669 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3));
1670 BC_ASSERT_TRUE(check_ice(marie, pauline, LinphoneIceStateHostConnection));
1671
1672 end_call(pauline, marie);
1673
1674 end:
1675 linphone_core_manager_destroy(marie);
1676 linphone_core_manager_destroy(pauline);
1677 }
1678
on_ack_processing(LinphoneCall * call,LinphoneHeaders * ack,bool_t is_received)1679 static void on_ack_processing(LinphoneCall *call, LinphoneHeaders *ack, bool_t is_received){
1680 if (!is_received){
1681 linphone_headers_add(ack, "Coucou", "me voila");
1682 /*We put something in user_data to indicate that we went through this callback*/
1683 linphone_call_set_user_data(call, (void*)1);
1684 }else{
1685 const char *ack_header;
1686 ack_header = linphone_headers_get_value(ack, "Coucou");
1687 BC_ASSERT_PTR_NOT_NULL(ack_header);
1688 if (ack_header){
1689 BC_ASSERT_STRING_EQUAL(ack_header, "me voila");
1690 }
1691 linphone_call_set_user_data(call, (void*)1);
1692 }
1693 }
1694
call_created(LinphoneCore * lc,LinphoneCall * call)1695 static void call_created(LinphoneCore *lc, LinphoneCall *call){
1696 LinphoneCallCbs *cbs = linphone_factory_create_call_cbs(linphone_factory_get());
1697 linphone_call_cbs_set_ack_processing(cbs, on_ack_processing);
1698 linphone_call_add_callbacks(call, cbs);
1699 linphone_call_cbs_unref(cbs);
1700 }
1701
call_with_custom_headers(void)1702 static void call_with_custom_headers(void) {
1703 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
1704 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1705 LinphoneCall *call_marie,*call_pauline;
1706 LinphoneCallParams *params;
1707 const LinphoneCallParams *marie_remote_params;
1708 const char *hvalue;
1709 char *pauline_remote_contact_header,
1710 *pauline_remote_contact,
1711 *marie_remote_contact,
1712 *marie_remote_contact_header;
1713 LinphoneAddress* marie_identity;
1714 char* tmp=linphone_address_as_string_uri_only(marie->identity);
1715 char tmp2[256];
1716 LinphoneCoreCbs *core_cbs = linphone_factory_create_core_cbs(linphone_factory_get());
1717
1718 snprintf(tmp2,sizeof(tmp2),"%s?uriHeader=myUriHeader",tmp);
1719 marie_identity=linphone_address_new(tmp2);
1720 ms_free(tmp);
1721 linphone_address_unref(marie->identity);
1722 marie->identity=marie_identity;
1723
1724 params=linphone_core_create_call_params(marie->lc, NULL);
1725 linphone_call_params_add_custom_header(params,"Weather","bad");
1726 linphone_call_params_add_custom_header(params,"Working","yes");
1727
1728 linphone_core_cbs_set_call_created(core_cbs, call_created);
1729 linphone_core_add_callbacks(marie->lc, core_cbs);
1730 linphone_core_add_callbacks(pauline->lc, core_cbs);
1731
1732 if (!BC_ASSERT_TRUE(call_with_caller_params(pauline,marie,params))) goto end;
1733
1734
1735 call_marie=linphone_core_get_current_call(marie->lc);
1736 call_pauline=linphone_core_get_current_call(pauline->lc);
1737
1738 BC_ASSERT_PTR_NOT_NULL(call_marie);
1739 BC_ASSERT_PTR_NOT_NULL(call_pauline);
1740
1741 marie_remote_params=linphone_call_get_remote_params(call_marie);
1742 hvalue=linphone_call_params_get_custom_header(marie_remote_params,"Weather");
1743 BC_ASSERT_PTR_NOT_NULL(hvalue);
1744 BC_ASSERT_STRING_EQUAL(hvalue,"bad");
1745 hvalue=linphone_call_params_get_custom_header(marie_remote_params,"uriHeader");
1746 BC_ASSERT_PTR_NOT_NULL(hvalue);
1747 BC_ASSERT_STRING_EQUAL(hvalue,"myUriHeader");
1748
1749 // FIXME: we have to strdup because successive calls to get_remote_params erase the returned const char*!!
1750 pauline_remote_contact = ms_strdup(linphone_call_get_remote_contact(call_pauline));
1751 pauline_remote_contact_header = ms_strdup(linphone_call_params_get_custom_header(linphone_call_get_remote_params(call_pauline), "Contact"));
1752
1753 marie_remote_contact = ms_strdup(linphone_call_get_remote_contact(call_marie));
1754 marie_remote_contact_header = ms_strdup(linphone_call_params_get_custom_header(linphone_call_get_remote_params(call_marie), "Contact"));
1755
1756 BC_ASSERT_PTR_NOT_NULL(pauline_remote_contact);
1757 BC_ASSERT_PTR_NOT_NULL(pauline_remote_contact_header);
1758 BC_ASSERT_PTR_NOT_NULL(marie_remote_contact);
1759 BC_ASSERT_PTR_NOT_NULL(marie_remote_contact_header);
1760 BC_ASSERT_STRING_EQUAL(pauline_remote_contact,pauline_remote_contact_header);
1761 BC_ASSERT_STRING_EQUAL(marie_remote_contact,marie_remote_contact_header);
1762
1763
1764 /*we need to wait for the ack to arrive*/
1765 wait_for_until(marie->lc, pauline->lc, NULL, 0, 3000);
1766
1767 BC_ASSERT_TRUE(linphone_call_get_user_data(call_marie) == (void*)1);
1768 BC_ASSERT_TRUE(linphone_call_get_user_data(call_pauline) == (void*)1);
1769
1770 ms_free(pauline_remote_contact);
1771 ms_free(pauline_remote_contact_header);
1772 ms_free(marie_remote_contact);
1773 ms_free(marie_remote_contact_header);
1774
1775 end_call(pauline, marie);
1776
1777 end:
1778 linphone_core_cbs_unref(core_cbs);
1779 linphone_call_params_unref(params);
1780 linphone_core_manager_destroy(marie);
1781 linphone_core_manager_destroy(pauline);
1782 }
1783
call_with_custom_sdp_attributes_cb(LinphoneCore * lc,LinphoneCall * call,LinphoneCallState cstate,const char * message)1784 static void call_with_custom_sdp_attributes_cb(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message) {
1785 if (cstate == LinphoneCallUpdatedByRemote) {
1786 LinphoneCallParams *params;
1787 const LinphoneCallParams *remote_params = linphone_call_get_remote_params(call);
1788 const char *value = linphone_call_params_get_custom_sdp_attribute(remote_params, "weather");
1789 BC_ASSERT_PTR_NOT_NULL(value);
1790 if (value) BC_ASSERT_STRING_EQUAL(value, "sunny");
1791 params = linphone_core_create_call_params(lc, call);
1792 linphone_call_params_clear_custom_sdp_attributes(params);
1793 linphone_call_params_clear_custom_sdp_media_attributes(params, LinphoneStreamTypeAudio);
1794 linphone_call_params_add_custom_sdp_attribute(params, "working", "no");
1795 BC_ASSERT_EQUAL(linphone_call_accept_update(call, params), 0, int, "%i");
1796 linphone_call_params_unref(params);
1797 }
1798 }
1799
call_with_custom_sdp_attributes(void)1800 static void call_with_custom_sdp_attributes(void) {
1801 LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
1802 LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1803 LinphoneCall *call_marie, *call_pauline;
1804 LinphoneCallParams *pauline_params;
1805 const LinphoneCallParams *marie_remote_params;
1806 const LinphoneCallParams *pauline_remote_params;
1807 const char *value;
1808 LinphoneCoreVTable *vtable;
1809
1810 pauline_params = linphone_core_create_call_params(pauline->lc, NULL);
1811 linphone_call_params_add_custom_sdp_attribute(pauline_params, "weather", "bad");
1812 linphone_call_params_add_custom_sdp_attribute(pauline_params, "working", "yes");
1813 linphone_call_params_add_custom_sdp_attribute(pauline_params, "attribute_without_value", NULL); /*cannot be tested yet*/
1814 linphone_call_params_add_custom_sdp_media_attribute(pauline_params, LinphoneStreamTypeAudio, "sleeping", "almost");
1815 BC_ASSERT_TRUE(call_with_caller_params(pauline, marie, pauline_params));
1816 linphone_call_params_unref(pauline_params);
1817
1818 call_marie = linphone_core_get_current_call(marie->lc);
1819 call_pauline = linphone_core_get_current_call(pauline->lc);
1820 BC_ASSERT_PTR_NOT_NULL(call_marie);
1821 BC_ASSERT_PTR_NOT_NULL(call_pauline);
1822
1823 marie_remote_params = linphone_call_get_remote_params(call_marie);
1824 value = linphone_call_params_get_custom_sdp_attribute(marie_remote_params, "weather");
1825 BC_ASSERT_PTR_NOT_NULL(value);
1826 if (value) BC_ASSERT_STRING_EQUAL(value, "bad");
1827 value = linphone_call_params_get_custom_sdp_media_attribute(marie_remote_params, LinphoneStreamTypeAudio, "sleeping");
1828 BC_ASSERT_PTR_NOT_NULL(value);
1829 if (value) BC_ASSERT_STRING_EQUAL(value, "almost");
1830
1831 vtable = linphone_core_v_table_new();
1832 vtable->call_state_changed = call_with_custom_sdp_attributes_cb;
1833 linphone_core_add_listener(marie->lc, vtable);
1834 pauline_params = linphone_core_create_call_params(pauline->lc, call_pauline);
1835 linphone_call_params_clear_custom_sdp_attributes(pauline_params);
1836 linphone_call_params_clear_custom_sdp_media_attributes(pauline_params, LinphoneStreamTypeAudio);
1837 linphone_call_params_add_custom_sdp_attribute(pauline_params, "weather", "sunny");
1838 linphone_call_update(call_pauline, pauline_params);
1839 BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallUpdatedByRemote, 1));
1840 BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallUpdating, 1));
1841 linphone_call_params_unref(pauline_params);
1842 BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2));
1843 pauline_remote_params = linphone_call_get_remote_params(call_pauline);
1844 value = linphone_call_params_get_custom_sdp_attribute(pauline_remote_params, "working");
1845 BC_ASSERT_PTR_NOT_NULL(value);
1846 if (value) BC_ASSERT_STRING_EQUAL(value, "no");
1847
1848 end_call(pauline, marie);
1849
1850 linphone_core_manager_destroy(marie);
1851 linphone_core_manager_destroy(pauline);
1852 }
1853
1854
1855
1856
call_with_custom_header_or_sdp_cb(LinphoneCore * lc,LinphoneCall * call,LinphoneCallState cstate,const char * message)1857 static void call_with_custom_header_or_sdp_cb(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message) {
1858
1859
1860 const char *value;
1861 if (cstate == LinphoneCallOutgoingInit){
1862 LinphoneCallParams *params = linphone_call_params_copy(linphone_call_get_params(call));
1863 linphone_call_params_add_custom_sdp_attribute(params, "working", "maybe");
1864 linphone_call_set_params(call, params);
1865 linphone_call_params_unref(params);
1866
1867 }
1868
1869 else if (cstate == LinphoneCallIncomingReceived){
1870 const LinphoneCallParams *tparams = linphone_call_get_remote_params(call);
1871 LinphoneCallParams *params = linphone_call_params_copy(tparams);
1872 //Check received params
1873 //SDP
1874 value = linphone_call_params_get_custom_sdp_attribute(params, "working");
1875 BC_ASSERT_PTR_NOT_NULL(value);
1876 if (value) BC_ASSERT_STRING_EQUAL(value, "maybe");
1877 //header
1878 value = linphone_call_params_get_custom_header(params, "weather");
1879 BC_ASSERT_PTR_NOT_NULL(value);
1880 if (value) BC_ASSERT_STRING_EQUAL(value, "thunderstorm");
1881 //modify SDP
1882 linphone_call_params_add_custom_sdp_attribute(params, "working", "yes");
1883 linphone_call_set_params(call, params);
1884 linphone_call_params_unref(params);
1885
1886 }
1887
1888
1889
1890 }
1891
call_caller_with_custom_header_or_sdp_attributes(void)1892 static void call_caller_with_custom_header_or_sdp_attributes(void) {
1893 LinphoneCoreManager *callee_mgr = linphone_core_manager_new("marie_rc");
1894 LinphoneCoreManager *caller_mgr = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
1895 LinphoneCall *call_caller = NULL, *call_callee = NULL;
1896 LinphoneCallParams *caller_params; // *callee_params ;
1897
1898 LinphoneCoreVTable *vtable;
1899
1900 LinphoneCallTestParams caller_test_params = {0};
1901 LinphoneCallTestParams callee_test_params = {0};
1902
1903 stats initial_caller=caller_mgr->stat;
1904 stats initial_callee=callee_mgr->stat;
1905 bool_t result=FALSE;
1906 bool_t did_receive_call;
1907
1908 //Create caller params with custom header and custom SDP
1909 caller_params = linphone_core_create_call_params(caller_mgr->lc, NULL);
1910 linphone_call_params_add_custom_header(caller_params, "weather", "thunderstorm");
1911 linphone_call_params_add_custom_sdp_media_attribute(caller_params, LinphoneStreamTypeAudio, "sleeping", "almost");
1912
1913 caller_test_params.base = (LinphoneCallParams*)caller_params;
1914 callee_test_params.base = NULL;
1915
1916 /* TODO: This should be handled correctly inside the liblinphone library but meanwhile handle this here. */
1917 linphone_core_manager_wait_for_stun_resolution(caller_mgr);
1918 linphone_core_manager_wait_for_stun_resolution(callee_mgr);
1919
1920 setup_sdp_handling(&caller_test_params, caller_mgr);
1921 setup_sdp_handling(&callee_test_params, callee_mgr);
1922
1923 // Assign dedicated callback to vtable for caller and callee
1924 vtable = linphone_core_v_table_new();
1925 vtable->call_state_changed = call_with_custom_header_or_sdp_cb;
1926 linphone_core_add_listener(callee_mgr->lc, vtable);
1927 linphone_core_add_listener(caller_mgr->lc, vtable);
1928
1929 //Caller initates the call with INVITE
1930 // caller params not null
1931 BC_ASSERT_PTR_NOT_NULL((call_caller=linphone_core_invite_address_with_params(caller_mgr->lc,callee_mgr->identity,caller_params)));
1932
1933 BC_ASSERT_PTR_NULL(linphone_call_get_remote_params(call_caller)); /*assert that remote params are NULL when no response is received yet*/
1934
1935 // Wait for Incoming received
1936 did_receive_call = wait_for(callee_mgr->lc
1937 ,caller_mgr->lc
1938 ,&callee_mgr->stat.number_of_LinphoneCallIncomingReceived
1939 ,initial_callee.number_of_LinphoneCallIncomingReceived+1);
1940 BC_ASSERT_EQUAL(did_receive_call, !callee_test_params.sdp_simulate_error, int, "%d");
1941
1942 linphone_call_params_unref(caller_params);
1943
1944 sal_default_set_sdp_handling(caller_mgr->lc->sal, SalOpSDPNormal);
1945 sal_default_set_sdp_handling(callee_mgr->lc->sal, SalOpSDPNormal);
1946
1947 // Wait for Outgoing Progress
1948 if (linphone_core_get_calls_nb(callee_mgr->lc)<=1)
1949 BC_ASSERT_TRUE(linphone_core_inc_invite_pending(callee_mgr->lc));
1950 BC_ASSERT_EQUAL(caller_mgr->stat.number_of_LinphoneCallOutgoingProgress,initial_caller.number_of_LinphoneCallOutgoingProgress+1, int, "%d");
1951
1952
1953
1954
1955 LinphoneCallParams *default_params=linphone_core_create_call_params(callee_mgr->lc,call_callee);
1956 ms_message("Created default call params with video=%i", linphone_call_params_video_enabled(default_params));
1957 linphone_core_accept_call_with_params(callee_mgr->lc,call_callee,default_params);
1958 linphone_call_params_unref(default_params);
1959
1960
1961 BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallConnected,initial_callee.number_of_LinphoneCallConnected+1));
1962 BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallConnected,initial_caller.number_of_LinphoneCallConnected+1));
1963
1964 result = wait_for_until(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_caller.number_of_LinphoneCallStreamsRunning+1, 2000)
1965 &&
1966 wait_for_until(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_callee.number_of_LinphoneCallStreamsRunning+1, 2000);
1967 BC_ASSERT_TRUE(result);
1968
1969
1970 caller_params = linphone_core_create_call_params(caller_mgr->lc, call_caller);
1971 linphone_call_params_clear_custom_sdp_attributes(caller_params);
1972 linphone_call_params_clear_custom_sdp_media_attributes(caller_params, LinphoneStreamTypeAudio);
1973 linphone_call_params_add_custom_sdp_attribute(caller_params, "weather", "sunny");
1974 linphone_core_update_call(caller_mgr->lc, call_caller, caller_params);
1975 linphone_call_params_unref(caller_params);
1976
1977
1978 end_call(caller_mgr, callee_mgr);
1979
1980 linphone_core_manager_destroy(callee_mgr);
1981 linphone_core_manager_destroy(caller_mgr);
1982 }
1983
1984
1985
1986
call_callee_with_custom_header_or_sdp_cb(LinphoneCore * lc,LinphoneCall * call,LinphoneCallState cstate,const char * message)1987 static void call_callee_with_custom_header_or_sdp_cb(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message) {
1988
1989
1990 const char *value;
1991 if (cstate == LinphoneCallOutgoingInit){
1992 LinphoneCallParams *params = linphone_call_params_copy(linphone_call_get_params(call));
1993 linphone_call_params_add_custom_sdp_attribute(params, "working", "maybe");
1994 linphone_call_set_params(call, params);
1995 linphone_call_params_unref(params);
1996
1997 }
1998
1999 else if (cstate == LinphoneCallIncomingReceived){
2000 const LinphoneCallParams *tparams = linphone_call_get_remote_params(call);
2001 LinphoneCallParams *params = linphone_call_params_copy(tparams);
2002 value = linphone_call_params_get_custom_sdp_attribute(params, "working");
2003 BC_ASSERT_PTR_NOT_NULL(value);
2004 if (value) BC_ASSERT_STRING_EQUAL(value, "maybe");
2005 linphone_call_set_params(call, params);
2006 linphone_call_params_unref(params);
2007
2008 }
2009
2010 }
2011
2012
call_callee_with_custom_header_or_sdp_attributes(void)2013 static void call_callee_with_custom_header_or_sdp_attributes(void) {
2014 int result;
2015 LinphoneCoreManager *callee_mgr = linphone_core_manager_new("marie_rc");
2016 LinphoneCoreManager *caller_mgr = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2017 LinphoneCall *call_caller = NULL, *call_callee = NULL;
2018 LinphoneCallParams *callee_params, *caller_params ;
2019
2020 LinphoneCoreVTable *vtable;
2021 const char *value;
2022 LinphoneCallTestParams caller_test_params = {0};
2023 LinphoneCallTestParams callee_test_params = {0};
2024
2025 stats initial_caller=caller_mgr->stat;
2026 stats initial_callee=callee_mgr->stat;
2027 bool_t did_receive_call;
2028 const LinphoneCallParams *caller_remote_params;
2029
2030 caller_params = linphone_core_create_call_params(caller_mgr->lc, NULL);
2031
2032
2033 callee_test_params.base = NULL;
2034 caller_test_params.base = NULL;
2035
2036 /* TODO: This should be handled correctly inside the liblinphone library but meanwhile handle this here. */
2037 linphone_core_manager_wait_for_stun_resolution(caller_mgr);
2038 linphone_core_manager_wait_for_stun_resolution(callee_mgr);
2039
2040 setup_sdp_handling(&caller_test_params, caller_mgr);
2041 setup_sdp_handling(&callee_test_params, callee_mgr);
2042
2043 // Assign dedicated callback to vtable for caller and callee
2044 vtable = linphone_core_v_table_new();
2045 vtable->call_state_changed = call_callee_with_custom_header_or_sdp_cb;
2046 linphone_core_add_listener(callee_mgr->lc, vtable);
2047 linphone_core_add_listener(caller_mgr->lc, vtable);
2048
2049 //Caller initates the call with INVITE
2050 // caller params not null
2051 BC_ASSERT_PTR_NOT_NULL((call_caller=linphone_core_invite_address_with_params(caller_mgr->lc,callee_mgr->identity,caller_params)));
2052
2053 BC_ASSERT_PTR_NULL(linphone_call_get_remote_params(call_caller)); /*assert that remote params are NULL when no response is received yet*/
2054
2055 // Wait for Incoming received
2056 did_receive_call = wait_for(callee_mgr->lc
2057 ,caller_mgr->lc
2058 ,&callee_mgr->stat.number_of_LinphoneCallIncomingReceived
2059 ,initial_callee.number_of_LinphoneCallIncomingReceived+1);
2060 BC_ASSERT_EQUAL(did_receive_call, !callee_test_params.sdp_simulate_error, int, "%d");
2061
2062
2063
2064 sal_default_set_sdp_handling(caller_mgr->lc->sal, SalOpSDPNormal);
2065 sal_default_set_sdp_handling(callee_mgr->lc->sal, SalOpSDPNormal);
2066
2067 // Wait for Outgoing Progress
2068 if (linphone_core_get_calls_nb(callee_mgr->lc)<=1)
2069 BC_ASSERT_TRUE(linphone_core_inc_invite_pending(callee_mgr->lc));
2070 BC_ASSERT_EQUAL(caller_mgr->stat.number_of_LinphoneCallOutgoingProgress,initial_caller.number_of_LinphoneCallOutgoingProgress+1, int, "%d");
2071
2072
2073 //Create callee params with custom header and custom SDP
2074
2075
2076 callee_params = linphone_core_create_call_params(callee_mgr->lc,call_callee);
2077 linphone_call_params_add_custom_header(callee_params, "weather", "thunderstorm");
2078 linphone_call_params_add_custom_sdp_media_attribute(callee_params, LinphoneStreamTypeAudio, "sleeping", "almost");
2079 linphone_call_params_add_custom_sdp_attribute(callee_params, "working", "yes");
2080 ms_message("Created default call params with video=%i", linphone_call_params_video_enabled(callee_params));
2081 linphone_core_accept_call_with_params(callee_mgr->lc,call_callee,callee_params);
2082 linphone_call_params_unref(callee_params);
2083
2084
2085 BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallConnected,initial_callee.number_of_LinphoneCallConnected+1));
2086 BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallConnected,initial_caller.number_of_LinphoneCallConnected+1));
2087
2088 result = wait_for_until(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_caller.number_of_LinphoneCallStreamsRunning+1, 2000)
2089 &&
2090 wait_for_until(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_callee.number_of_LinphoneCallStreamsRunning+1, 2000);
2091
2092 BC_ASSERT_TRUE(result);
2093
2094 caller_remote_params = linphone_call_get_remote_params(call_caller);
2095 value = linphone_call_params_get_custom_sdp_attribute(caller_remote_params, "working");
2096 BC_ASSERT_PTR_NOT_NULL(value);
2097 if (value) BC_ASSERT_STRING_EQUAL(value, "yes");
2098 //header
2099 value = linphone_call_params_get_custom_header(caller_remote_params, "weather");
2100 BC_ASSERT_PTR_NOT_NULL(value);
2101 if (value) BC_ASSERT_STRING_EQUAL(value, "thunderstorm");
2102
2103 linphone_call_params_unref(caller_params);
2104 end_call(caller_mgr, callee_mgr);
2105
2106 linphone_core_manager_destroy(callee_mgr);
2107 linphone_core_manager_destroy(caller_mgr);
2108 }
2109
call_paused_resumed_base(bool_t multicast,bool_t with_losses)2110 void call_paused_resumed_base(bool_t multicast, bool_t with_losses) {
2111 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
2112 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2113 LinphoneCall* call_pauline;
2114 const rtp_stats_t * stats;
2115 bool_t call_ok;
2116
2117 linphone_core_enable_audio_multicast(pauline->lc,multicast);
2118
2119 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
2120
2121 if (!call_ok) goto end;
2122
2123 call_pauline = linphone_core_get_current_call(pauline->lc);
2124
2125 wait_for_until(pauline->lc, marie->lc, NULL, 5, 3000);
2126
2127 if (with_losses) {
2128 sal_set_send_error(marie->lc->sal,1500); /*to trash 200ok without generating error*/
2129 }
2130 linphone_call_pause(call_pauline);
2131 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1));
2132
2133 if (with_losses) {
2134 BC_ASSERT_FALSE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1,1000));
2135 sal_set_send_error(marie->lc->sal,0); /*to trash 200ok without generating error*/
2136 }
2137
2138
2139 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1));
2140 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1));
2141
2142 /*stay in pause a little while in order to generate traffic*/
2143 wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000);
2144
2145 linphone_call_resume(call_pauline);
2146
2147 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
2148 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
2149 /*same here: wait a while for a bit of a traffic, we need to receive a RTCP packet*/
2150 wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000);
2151
2152 /*since RTCP streams are reset when call is paused/resumed, there should be no loss at all*/
2153 if (BC_ASSERT_PTR_NOT_NULL(call_pauline->sessions->rtp_session)) {
2154 stats = rtp_session_get_stats(call_pauline->sessions->rtp_session);
2155 BC_ASSERT_EQUAL((int)stats->cum_packet_loss, 0, int, "%d");
2156 }
2157
2158 if (with_losses) {
2159 /* now we want to loose the ack*/
2160 linphone_call_pause(call_pauline);
2161 sal_set_send_error(pauline->lc->sal,1500); /*to trash ACK without generating error*/
2162 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,2));
2163 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,2));
2164 BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,2,1000));
2165 /*now try to resume, it should be OK*/
2166 sal_set_send_error(pauline->lc->sal,0);
2167 linphone_call_resume(call_pauline);
2168 BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3,2000));
2169 BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3,2000));
2170 }
2171
2172
2173 end_call(pauline, marie);
2174 end:
2175 linphone_core_manager_destroy(marie);
2176 linphone_core_manager_destroy(pauline);
2177 }
2178
call_paused_resumed(void)2179 static void call_paused_resumed(void) {
2180 call_paused_resumed_base(FALSE,FALSE);
2181 }
2182
call_paused_resumed_with_sip_packets_losses(void)2183 static void call_paused_resumed_with_sip_packets_losses(void) {
2184 call_paused_resumed_base(FALSE,TRUE);
2185 }
2186
call_paused_by_both(void)2187 static void call_paused_by_both(void) {
2188 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
2189 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2190 LinphoneCall* call_pauline, *call_marie;
2191 const rtp_stats_t * stats;
2192 bctbx_list_t *lcs = NULL;
2193 bool_t call_ok;
2194
2195 lcs = bctbx_list_append(lcs, pauline->lc);
2196 lcs = bctbx_list_append(lcs, marie->lc);
2197 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
2198
2199 if (!call_ok) goto end;
2200
2201 call_pauline = linphone_core_get_current_call(pauline->lc);
2202 call_marie = linphone_core_get_current_call(marie->lc);
2203
2204 wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000);
2205
2206 linphone_call_pause(call_pauline);
2207 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1));
2208 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1));
2209 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1));
2210
2211 /*stay in pause a little while in order to generate traffic*/
2212 wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000);
2213
2214 /*marie pauses the call also*/
2215 linphone_call_pause(call_marie);
2216 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausing,1));
2217 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPaused,1));
2218
2219 wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000);
2220 /*pauline must stay in paused state*/
2221 BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallPaused, 1, int, "%i");
2222 check_media_direction(pauline, call_pauline, lcs, LinphoneMediaDirectionInactive, LinphoneMediaDirectionInvalid);
2223 check_media_direction(marie, call_marie, lcs, LinphoneMediaDirectionInactive, LinphoneMediaDirectionInvalid);
2224
2225 /*now pauline wants to resume*/
2226 linphone_call_resume(call_pauline);
2227 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallResuming,1));
2228 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,1));
2229 /*Marie must stay in paused state*/
2230 wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000);
2231 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallPaused, 1, int, "%i");
2232
2233 /*now marie wants to resume also*/
2234 linphone_call_resume(call_marie);
2235 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallResuming,1));
2236 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
2237 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
2238 /*same here: wait a while for a bit of a traffic, we need to receive a RTCP packet*/
2239 wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000);
2240
2241 /*since RTCP streams are reset when call is paused/resumed, there should be no loss at all*/
2242 stats = rtp_session_get_stats(call_pauline->sessions->rtp_session);
2243 BC_ASSERT_EQUAL((int)stats->cum_packet_loss, 0, int, "%d");
2244
2245 end_call(marie, pauline);
2246
2247 end:
2248 linphone_core_manager_destroy(marie);
2249 linphone_core_manager_destroy(pauline);
2250 bctbx_list_free(lcs);
2251 }
2252
2253 #define CHECK_CURRENT_LOSS_RATE() \
2254 rtcp_count_current = pauline->stat.number_of_rtcp_sent; \
2255 /*wait for an RTCP packet to have an accurate cumulative lost value*/ \
2256 BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_rtcp_sent, rtcp_count_current+1, 10000)); \
2257 stats = rtp_session_get_stats(call_pauline->audiostream->ms.sessions.rtp_session); \
2258 loss_percentage = stats->cum_packet_loss * 100.f / (stats->packet_recv + stats->cum_packet_loss); \
2259 BC_ASSERT_GREATER(loss_percentage, .75f * params.loss_rate, float, "%f"); \
2260 BC_ASSERT_LOWER(loss_percentage , 1.25f * params.loss_rate, float, "%f")
2261
call_paused_resumed_with_loss(void)2262 static void call_paused_resumed_with_loss(void) {
2263 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
2264 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2265 LinphoneCall* call_pauline;
2266 const rtp_stats_t * stats;
2267 float loss_percentage;
2268 int rtcp_count_current;
2269
2270 OrtpNetworkSimulatorParams params={0};
2271 params.enabled=TRUE;
2272 params.loss_rate=20;
2273
2274 BC_ASSERT_TRUE(call(pauline,marie));
2275 call_pauline = linphone_core_get_current_call(pauline->lc);
2276 if (call_pauline){
2277 rtp_session_enable_network_simulation(call_pauline->audiostream->ms.sessions.rtp_session,¶ms);
2278
2279 /*generate some traffic*/
2280 wait_for_until(pauline->lc, marie->lc, NULL, 5, 10000);
2281 CHECK_CURRENT_LOSS_RATE();
2282
2283 /*pause call*/
2284 linphone_call_pause(call_pauline);
2285 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1));
2286 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1));
2287 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1));
2288 /*stay in pause a little while in order to generate traffic*/
2289 wait_for_until(pauline->lc, marie->lc, NULL, 5, 10000);
2290 CHECK_CURRENT_LOSS_RATE();
2291
2292 /*resume*/
2293 linphone_call_resume(call_pauline);
2294 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
2295 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
2296 wait_for_until(pauline->lc, marie->lc, NULL, 5, 10000);
2297
2298 /*since stats are NOT totally reset during pause, the stats->packet_recv is computed from
2299 the start of call. This test ensures that the loss rate is consistent during the entire call.*/
2300 CHECK_CURRENT_LOSS_RATE();
2301 end_call(marie, pauline);
2302 }
2303
2304 linphone_core_manager_destroy(marie);
2305 linphone_core_manager_destroy(pauline);
2306 }
2307
pause_call_1(LinphoneCoreManager * mgr_1,LinphoneCall * call_1,LinphoneCoreManager * mgr_2,LinphoneCall * call_2)2308 bool_t pause_call_1(LinphoneCoreManager* mgr_1,LinphoneCall* call_1,LinphoneCoreManager* mgr_2,LinphoneCall* call_2) {
2309 stats initial_call_stat_1=mgr_1->stat;
2310 stats initial_call_stat_2=mgr_2->stat;
2311 linphone_call_pause(call_1);
2312 BC_ASSERT_TRUE(wait_for(mgr_1->lc,mgr_2->lc,&mgr_1->stat.number_of_LinphoneCallPausing,initial_call_stat_1.number_of_LinphoneCallPausing+1));
2313 BC_ASSERT_TRUE(wait_for(mgr_1->lc,mgr_2->lc,&mgr_1->stat.number_of_LinphoneCallPaused,initial_call_stat_1.number_of_LinphoneCallPaused+1));
2314 BC_ASSERT_TRUE(wait_for(mgr_1->lc,mgr_2->lc,&mgr_2->stat.number_of_LinphoneCallPausedByRemote,initial_call_stat_2.number_of_LinphoneCallPausedByRemote+1));
2315 BC_ASSERT_EQUAL(linphone_call_get_state(call_1),LinphoneCallPaused, int, "%d");
2316 BC_ASSERT_EQUAL(linphone_call_get_state(call_2),LinphoneCallPausedByRemote, int, "%d");
2317 return linphone_call_get_state(call_1) == LinphoneCallPaused && linphone_call_get_state(call_2)==LinphoneCallPausedByRemote;
2318 }
2319 #if 0
2320 void concurrent_paused_resumed_base(void) {
2321 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
2322 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2323 LinphoneCall* call_pauline,call_marie;
2324 const rtp_stats_t * stats;
2325
2326
2327 BC_ASSERT_TRUE(call(pauline,marie));
2328
2329 call_pauline = linphone_core_get_current_call(pauline->lc);
2330 call_marie = linphone_core_get_current_call(marie->lc);
2331
2332 linphone_core_pause_call(pauline->lc,call_pauline);
2333 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1));
2334
2335 linphone_core_pause_call(marie->lc,call_marie);
2336
2337 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1));
2338 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1));
2339
2340 /*stay in pause a little while in order to generate traffic*/
2341 wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000);
2342
2343 linphone_core_resume_call(pauline->lc,call_pauline);
2344
2345 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
2346 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
2347 /*same here: wait a while for a bit of a traffic, we need to receive a RTCP packet*/
2348 wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000);
2349
2350 /*since RTCP streams are reset when call is paused/resumed, there should be no loss at all*/
2351 stats = rtp_session_get_stats(call_pauline->sessions->rtp_session);
2352 BC_ASSERT_EQUAL(stats->cum_packet_loss, 0, int, "%d");
2353
2354
2355 linphone_core_terminate_all_calls(pauline->lc);
2356 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
2357 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
2358
2359
2360 linphone_core_manager_destroy(marie);
2361 linphone_core_manager_destroy(pauline);
2362 }
2363 #endif
call_paused_resumed_from_callee(void)2364 static void call_paused_resumed_from_callee(void) {
2365 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
2366 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2367 LinphoneCall* call_marie;
2368 const rtp_stats_t * stats;
2369 bool_t call_ok;
2370
2371 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
2372 if (!call_ok) goto end;
2373 call_marie = linphone_core_get_current_call(marie->lc);
2374
2375 linphone_call_pause(call_marie);
2376 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausing,1));
2377 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,1));
2378 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPaused,1));
2379
2380 /*stay in pause a little while in order to generate traffic*/
2381 wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000);
2382
2383 linphone_call_resume(call_marie);
2384 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
2385 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
2386 /*same here: wait a while for a bit of a traffic, we need to receive a RTCP packet*/
2387 wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000);
2388
2389 /*since RTCP streams are reset when call is paused/resumed, there should be no loss at all*/
2390 stats = rtp_session_get_stats(call_marie->sessions->rtp_session);
2391 BC_ASSERT_EQUAL((int)stats->cum_packet_loss, 0, int, "%d");
2392
2393 end_call(pauline, marie);
2394 end:
2395 linphone_core_manager_destroy(marie);
2396 linphone_core_manager_destroy(pauline);
2397 }
2398
audio_call_with_ice_no_matching_audio_codecs(void)2399 static void audio_call_with_ice_no_matching_audio_codecs(void) {
2400 LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
2401 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2402 LinphoneCall *out_call;
2403 const bctbx_list_t *logs;
2404 LinphoneCallLog *cl;
2405
2406 linphone_core_enable_payload_type(marie->lc, linphone_core_find_payload_type(marie->lc, "PCMU", 8000, 1), FALSE); /* Disable PCMU */
2407 linphone_core_enable_payload_type(marie->lc, linphone_core_find_payload_type(marie->lc, "PCMA", 8000, 1), TRUE); /* Enable PCMA */
2408 linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce);
2409 linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce);
2410
2411 linphone_core_manager_wait_for_stun_resolution(marie);
2412 linphone_core_manager_wait_for_stun_resolution(pauline);
2413
2414 out_call = linphone_core_invite_address(marie->lc, pauline->identity);
2415 linphone_call_ref(out_call);
2416 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingInit, 1));
2417
2418 /* flexisip will retain the 488 until the "urgent reply" timeout arrives. */
2419 BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallError, 1, 6000));
2420 BC_ASSERT_EQUAL(linphone_call_get_reason(out_call), LinphoneReasonNotAcceptable, int, "%d");
2421 BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallIncomingReceived, 0, int, "%d");
2422
2423 logs = linphone_core_get_call_logs(pauline->lc);
2424
2425 BC_ASSERT_EQUAL((int)bctbx_list_size(logs), 1, int, "%d");
2426 if (logs){
2427 const LinphoneErrorInfo *ei;
2428 cl = (LinphoneCallLog*)logs->data;
2429 BC_ASSERT_EQUAL(linphone_call_log_get_status(cl), LinphoneCallEarlyAborted, int, "%d");
2430 BC_ASSERT_TRUE(linphone_call_log_get_start_date(cl) != 0);
2431 ei = linphone_call_log_get_error_info(cl);
2432 BC_ASSERT_PTR_NOT_NULL(ei);
2433 if (ei){
2434 BC_ASSERT_EQUAL(linphone_error_info_get_reason(ei), LinphoneReasonNotAcceptable, int, "%d");
2435 }
2436 }
2437
2438 linphone_call_unref(out_call);
2439 linphone_core_manager_destroy(marie);
2440 linphone_core_manager_destroy(pauline);
2441 }
2442
_call_with_media_relay(bool_t random_ports)2443 static void _call_with_media_relay(bool_t random_ports) {
2444 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
2445 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2446 bool_t call_ok;
2447
2448 linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL);
2449 linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL);
2450 linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id);
2451 linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id);
2452
2453 if (random_ports){
2454 linphone_core_set_audio_port(marie->lc,-1);
2455 linphone_core_set_video_port(marie->lc,-1);
2456 linphone_core_set_audio_port(pauline->lc,-1);
2457 linphone_core_set_video_port(pauline->lc,-1);
2458 }
2459
2460 BC_ASSERT_TRUE(call_ok=call(pauline,marie));
2461 if (!call_ok) goto end;
2462 liblinphone_tester_check_rtcp(pauline,marie);
2463
2464 #ifdef VIDEO_ENABLED
2465 BC_ASSERT_TRUE(request_video(pauline,marie, TRUE));
2466 liblinphone_tester_check_rtcp(pauline,marie);
2467 #endif
2468 end_call(pauline, marie);
2469 end:
2470 linphone_core_manager_destroy(marie);
2471 linphone_core_manager_destroy(pauline);
2472 }
2473
call_with_media_relay(void)2474 static void call_with_media_relay(void) {
2475 _call_with_media_relay(FALSE);
2476 }
2477
call_with_media_relay_random_ports(void)2478 static void call_with_media_relay_random_ports(void) {
2479 _call_with_media_relay(TRUE);
2480 }
2481
call_with_privacy(void)2482 static void call_with_privacy(void) {
2483 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
2484 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2485 LinphoneCall *c1,*c2;
2486 LinphoneCallParams *params;
2487 LinphoneProxyConfig* pauline_proxy;
2488 params=linphone_core_create_call_params(pauline->lc, NULL);
2489 linphone_call_params_set_privacy(params,LinphonePrivacyId);
2490
2491 BC_ASSERT_TRUE(call_with_caller_params(pauline,marie,params));
2492 linphone_call_params_unref(params);
2493
2494 c1=linphone_core_get_current_call(pauline->lc);
2495 c2=linphone_core_get_current_call(marie->lc);
2496
2497 BC_ASSERT_PTR_NOT_NULL(c1);
2498 BC_ASSERT_PTR_NOT_NULL(c2);
2499 if (c1 && c2){
2500 /*make sure local identity is unchanged*/
2501 BC_ASSERT_TRUE(linphone_address_weak_equal(linphone_call_log_get_from(linphone_call_get_call_log(c1)),pauline->identity));
2502
2503 /*make sure remote identity is hidden*/
2504 BC_ASSERT_FALSE(linphone_address_weak_equal(linphone_call_get_remote_address(c2),pauline->identity));
2505
2506 BC_ASSERT_EQUAL(linphone_call_params_get_privacy(linphone_call_get_current_params(c2)),LinphonePrivacyId, int, "%d");
2507 }
2508
2509 end_call(pauline, marie);
2510
2511 /*test proxy config privacy*/
2512 pauline_proxy = linphone_core_get_default_proxy_config(pauline->lc);
2513 linphone_proxy_config_set_privacy(pauline_proxy,LinphonePrivacyId);
2514
2515 BC_ASSERT_TRUE(call(pauline,marie));
2516
2517 c1=linphone_core_get_current_call(pauline->lc);
2518 c2=linphone_core_get_current_call(marie->lc);
2519
2520 BC_ASSERT_PTR_NOT_NULL(c1);
2521 BC_ASSERT_PTR_NOT_NULL(c2);
2522 if (c1 && c2){
2523
2524 /*make sure remote identity is hidden*/
2525 BC_ASSERT_FALSE(linphone_address_weak_equal(linphone_call_get_remote_address(c2),pauline->identity));
2526
2527 BC_ASSERT_EQUAL(linphone_call_params_get_privacy(linphone_call_get_current_params(c2)),LinphonePrivacyId, int, "%d");
2528 }
2529
2530 end_call(pauline, marie);
2531
2532 linphone_core_manager_destroy(marie);
2533 linphone_core_manager_destroy(pauline);
2534 }
2535
2536 /*this ones makes call with privacy without previous registration*/
call_with_privacy2(void)2537 static void call_with_privacy2(void) {
2538 LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
2539 LinphoneCoreManager* pauline = linphone_core_manager_new2(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc", FALSE);
2540 LinphoneCall *c1,*c2;
2541 LinphoneCallParams *params;
2542 LinphoneProxyConfig* pauline_proxy;
2543 params=linphone_core_create_call_params(pauline->lc, NULL);
2544 linphone_call_params_set_privacy(params,LinphonePrivacyId);
2545
2546 pauline_proxy = linphone_core_get_default_proxy_config(pauline->lc);
2547 linphone_proxy_config_edit(pauline_proxy);
2548 linphone_proxy_config_enable_register(pauline_proxy,FALSE);
2549 linphone_proxy_config_done(pauline_proxy);
2550
2551 BC_ASSERT_TRUE(call_with_caller_params(pauline,marie,params));
2552 linphone_call_params_unref(params);
2553
2554 c1=linphone_core_get_current_call(pauline->lc);
2555 c2=linphone_core_get_current_call(marie->lc);
2556
2557 BC_ASSERT_PTR_NOT_NULL(c1);
2558 BC_ASSERT_PTR_NOT_NULL(c2);
2559
2560 if (c1 && c2){
2561 /*make sure local identity is unchanged*/
2562 BC_ASSERT_TRUE(linphone_address_weak_equal(linphone_call_log_get_from(linphone_call_get_call_log(c1)),pauline->identity));
2563 /*make sure remote identity is hidden*/
2564 BC_ASSERT_FALSE(linphone_address_weak_equal(linphone_call_get_remote_address(c2),pauline->identity));
2565
2566 BC_ASSERT_EQUAL(linphone_call_params_get_privacy(linphone_call_get_current_params(c2)),LinphonePrivacyId, int, "%d");
2567 }
2568
2569 end_call(pauline, marie);
2570
2571 /*test proxy config privacy*/
2572 linphone_proxy_config_set_privacy(pauline_proxy,LinphonePrivacyId);
2573
2574 BC_ASSERT_TRUE(call(pauline,marie));
2575 c1=linphone_core_get_current_call(pauline->lc);
2576 c2=linphone_core_get_current_call(marie->lc);
2577
2578 BC_ASSERT_PTR_NOT_NULL(c1);
2579 BC_ASSERT_PTR_NOT_NULL(c2);
2580
2581 if (c1 && c2){
2582 /*make sure remote identity is hidden*/
2583 BC_ASSERT_FALSE(linphone_address_weak_equal(linphone_call_get_remote_address(c2),pauline->identity));
2584 BC_ASSERT_EQUAL(linphone_call_params_get_privacy(linphone_call_get_current_params(c2)),LinphonePrivacyId, int, "%d");
2585 }
2586 end_call(marie, pauline);
2587
2588 linphone_core_manager_destroy(marie);
2589 linphone_core_manager_destroy(pauline);
2590 }
2591
srtp_call(void)2592 static void srtp_call(void) {
2593 call_base(LinphoneMediaEncryptionSRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE);
2594 }
2595
zrtp_call(void)2596 static void zrtp_call(void) {
2597 call_base(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE);
2598 }
2599
zrtp_sas_call(void)2600 static void zrtp_sas_call(void) {
2601 call_base_with_configfile(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE, "marie_zrtp_b256_rc", "pauline_zrtp_b256_rc");
2602 call_base_with_configfile(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE, "marie_zrtp_b256_rc", "pauline_tcp_rc");
2603 }
2604
zrtp_cipher_call(void)2605 static void zrtp_cipher_call(void) {
2606 call_base_with_configfile(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE, "marie_zrtp_srtpsuite_aes256_rc", "pauline_zrtp_srtpsuite_aes256_rc");
2607 call_base_with_configfile(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE, "marie_zrtp_aes256_rc", "pauline_zrtp_aes256_rc");
2608 call_base_with_configfile(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE, "marie_zrtp_aes256_rc", "pauline_tcp_rc");
2609 }
2610
2611
2612
dtls_srtp_call(void)2613 static void dtls_srtp_call(void) {
2614 call_base(LinphoneMediaEncryptionDTLS,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE);
2615 }
2616
dtls_srtp_call_with_media_realy(void)2617 static void dtls_srtp_call_with_media_realy(void) {
2618 call_base(LinphoneMediaEncryptionDTLS,FALSE,TRUE,LinphonePolicyNoFirewall,FALSE);
2619 }
2620
dtls_srtp_ice_call(void)2621 static void dtls_srtp_ice_call(void) {
2622 call_base(LinphoneMediaEncryptionDTLS,FALSE,FALSE,LinphonePolicyUseIce,FALSE);
2623 }
2624
call_with_declined_srtp(void)2625 static void call_with_declined_srtp(void) {
2626 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
2627 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2628 if (linphone_core_media_encryption_supported(marie->lc,LinphoneMediaEncryptionSRTP)) {
2629 linphone_core_set_media_encryption(pauline->lc,LinphoneMediaEncryptionSRTP);
2630
2631 BC_ASSERT_TRUE(call(pauline,marie));
2632
2633 end_call(marie, pauline);
2634 } else {
2635 ms_warning ("not tested because srtp not available");
2636 }
2637 linphone_core_manager_destroy(marie);
2638 linphone_core_manager_destroy(pauline);
2639 }
2640
call_srtp_paused_and_resumed(void)2641 static void call_srtp_paused_and_resumed(void) {
2642 /*
2643 * This test was made to evidence a bug due to internal usage of current_params while not yet filled by linphone_call_get_current_params().
2644 * As a result it must not use the call() function because it calls linphone_call_get_current_params().
2645 */
2646 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
2647 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2648 const LinphoneCallParams *params;
2649 LinphoneCall *pauline_call;
2650
2651 if (!linphone_core_media_encryption_supported(marie->lc,LinphoneMediaEncryptionSRTP)) goto end;
2652 linphone_core_set_media_encryption(pauline->lc,LinphoneMediaEncryptionSRTP);
2653
2654 linphone_core_invite_address(pauline->lc, marie->identity);
2655
2656 if (!BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallIncomingReceived,1))) goto end;
2657 pauline_call = linphone_core_get_current_call(pauline->lc);
2658 linphone_call_accept(linphone_core_get_current_call(marie->lc));
2659
2660 if (!BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,1))) goto end;
2661 if (!BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,1))) goto end;
2662
2663 linphone_call_pause(pauline_call);
2664
2665 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1));
2666 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1));
2667
2668 linphone_call_resume(pauline_call);
2669 if (!BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2))) goto end;
2670 if (!BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2))) goto end;
2671
2672 /*assert that after pause and resume, SRTP is still being used*/
2673 params = linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc));
2674 BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(params) , LinphoneMediaEncryptionSRTP, int, "%d");
2675 params = linphone_call_get_current_params(linphone_core_get_current_call(marie->lc));
2676 BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(params) , LinphoneMediaEncryptionSRTP, int, "%d");
2677
2678 end_call(pauline, marie);
2679 end:
2680 linphone_core_manager_destroy(marie);
2681 linphone_core_manager_destroy(pauline);
2682 }
2683
on_eof(LinphonePlayer * player)2684 static void on_eof(LinphonePlayer *player){
2685 LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player);
2686 LinphoneCoreManager *marie=(LinphoneCoreManager*)linphone_player_cbs_get_user_data(cbs);
2687 marie->stat.number_of_player_eof++;
2688 }
2689
call_with_file_player(void)2690 static void call_with_file_player(void) {
2691 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
2692 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2693 LinphonePlayer *player;
2694 LinphonePlayerCbs *cbs;
2695 char *hellopath = bc_tester_res("sounds/ahbahouaismaisbon.wav");
2696 char *recordpath = bc_tester_file("record-call_with_file_player.wav");
2697 bool_t call_ok;
2698 int attempts;
2699 double similar=1;
2700 const double threshold = 0.9;
2701
2702 /*this test is actually attempted three times in case of failure, because the audio comparison at the end is very sensitive to
2703 * jitter buffer drifts, which sometimes happen if the machine is unable to run the test in good realtime conditions */
2704 for (attempts=0; attempts<3; attempts++){
2705 reset_counters(&marie->stat);
2706 reset_counters(&pauline->stat);
2707 /*make sure the record file doesn't already exists, otherwise this test will append new samples to it*/
2708 unlink(recordpath);
2709 /*caller uses files instead of soundcard in order to avoid mixing soundcard input with file played using call's player*/
2710 linphone_core_use_files(marie->lc,TRUE);
2711 linphone_core_set_play_file(marie->lc,NULL);
2712
2713 /*callee is recording and plays file*/
2714 linphone_core_use_files(pauline->lc,TRUE);
2715 linphone_core_set_play_file(pauline->lc,NULL);
2716 linphone_core_set_record_file(pauline->lc,recordpath);
2717
2718 BC_ASSERT_TRUE((call_ok=call(marie,pauline)));
2719 if (!call_ok) goto end;
2720 player=linphone_call_get_player(linphone_core_get_current_call(marie->lc));
2721 cbs = linphone_player_get_callbacks(player);
2722 linphone_player_cbs_set_eof_reached(cbs, on_eof);
2723 linphone_player_cbs_set_user_data(cbs, marie);
2724 BC_ASSERT_PTR_NOT_NULL(player);
2725 if (player){
2726 BC_ASSERT_EQUAL(linphone_player_open(player,hellopath),0, int, "%d");
2727 BC_ASSERT_EQUAL(linphone_player_start(player),0, int, "%d");
2728 }
2729 /* This assert should be modified to be at least as long as the WAV file */
2730 BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_player_eof,1,10000));
2731 /*wait one second more for transmission to be fully ended (transmission time + jitter buffer)*/
2732 wait_for_until(pauline->lc,marie->lc,NULL,0,1000);
2733
2734 end_call(marie, pauline);
2735 /*cannot run on iphone simulator because locks main loop beyond permitted time (should run
2736 on another thread) */
2737 BC_ASSERT_EQUAL(ms_audio_diff(hellopath,recordpath,&similar,&audio_cmp_params,NULL,NULL), 0, int, "%d");
2738 if (similar>=threshold)
2739 break;
2740 }
2741 BC_ASSERT_GREATER(similar, threshold, double, "%g");
2742 BC_ASSERT_LOWER(similar, 1.0, double, "%g");
2743 if (similar >= threshold && similar <= 1.0) {
2744 remove(recordpath);
2745 }
2746
2747 end:
2748 linphone_core_manager_destroy(marie);
2749 linphone_core_manager_destroy(pauline);
2750 ms_free(recordpath);
2751 ms_free(hellopath);
2752 }
2753
call_with_mkv_file_player(void)2754 static void call_with_mkv_file_player(void) {
2755 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
2756 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2757 LinphonePlayer *player;
2758 char *hellomkv;
2759 char *hellowav;
2760 char *recordpath;
2761 bool_t call_ok;
2762 #if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(__ANDROID__)
2763 double similar=0.0;
2764 const double threshold = 0.9;
2765 #define DO_AUDIO_CMP
2766 #endif
2767 hellowav = bc_tester_res("sounds/hello8000_mkv_ref.wav");
2768 hellomkv = bc_tester_res("sounds/hello8000.mkv");
2769
2770 if (!linphone_core_file_format_supported(marie->lc,"mkv")){
2771 ms_warning("Test skipped, no mkv support.");
2772 goto end;
2773 }
2774 recordpath = bc_tester_file("record-call_with_mkv_file_player.wav");
2775 /*make sure the record file doesn't already exists, otherwise this test will append new samples to it*/
2776 unlink(recordpath);
2777
2778
2779 /*caller uses files instead of soundcard in order to avoid mixing soundcard input with file played using call's player*/
2780 linphone_core_use_files(marie->lc,TRUE);
2781 linphone_core_set_play_file(marie->lc,NULL);
2782 /*callee is recording and plays file*/
2783 linphone_core_use_files(pauline->lc,TRUE);
2784 linphone_core_set_play_file(pauline->lc,hellowav); /*just to send something but we are not testing what is sent by pauline*/
2785 linphone_core_set_record_file(pauline->lc,recordpath);
2786
2787 BC_ASSERT_TRUE((call_ok=call(marie,pauline)));
2788 if (!call_ok) goto end;
2789 player=linphone_call_get_player(linphone_core_get_current_call(marie->lc));
2790 BC_ASSERT_PTR_NOT_NULL(player);
2791 if (player){
2792 LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player);
2793 linphone_player_cbs_set_eof_reached(cbs, on_eof);
2794 linphone_player_cbs_set_user_data(cbs, marie);
2795 int res = linphone_player_open(player,hellomkv);
2796 //if(!ms_filter_codec_supported("opus")) {
2797 if(!ms_factory_codec_supported(marie->lc->factory, "opus") && !ms_factory_codec_supported(pauline->lc->factory, "opus")){
2798 BC_ASSERT_EQUAL(res, -1, int, "%d");
2799 end_call(marie, pauline);
2800 goto end;
2801 }
2802 BC_ASSERT_EQUAL(res, 0, int, "%d");
2803 BC_ASSERT_EQUAL(linphone_player_start(player),0,int,"%d");
2804 BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_player_eof,1,12000));
2805 linphone_player_close(player);
2806 /*wait for one second more so that last RTP packets can arrive*/
2807 wait_for_until(pauline->lc,marie->lc,NULL,0,1000);
2808 }
2809 end_call(marie, pauline);
2810 #ifdef DO_AUDIO_CMP
2811 BC_ASSERT_EQUAL(ms_audio_diff(hellowav,recordpath,&similar,&audio_cmp_params,NULL,NULL),0,int,"%d");
2812 BC_ASSERT_GREATER(similar,threshold,double,"%f");
2813 BC_ASSERT_LOWER(similar,1.0,double,"%f");
2814 if(similar>threshold && similar<=1.0) {
2815 remove(recordpath);
2816 }
2817 #else
2818 /*inter-correlation process is too much CPU consuming ending in a 20 minutes test on arm...*/
2819 remove(recordpath);
2820 #endif
2821 ms_free(recordpath);
2822
2823 end:
2824 linphone_core_manager_destroy(marie);
2825 linphone_core_manager_destroy(pauline);
2826 ms_free(hellomkv);
2827 ms_free(hellowav);
2828 }
2829
2830
_call_base_with_configfile(LinphoneMediaEncryption mode,bool_t enable_video,bool_t enable_relay,LinphoneFirewallPolicy policy,bool_t enable_tunnel,const char * marie_rc,const char * pauline_rc,bool_t plays_nothing)2831 static void _call_base_with_configfile(LinphoneMediaEncryption mode, bool_t enable_video,bool_t enable_relay,LinphoneFirewallPolicy policy,bool_t enable_tunnel, const char *marie_rc, const char *pauline_rc, bool_t plays_nothing) {
2832 LinphoneCoreManager* marie = linphone_core_manager_new(marie_rc);
2833 LinphoneCoreManager* pauline = linphone_core_manager_new(pauline_rc);
2834 bool_t call_ok;
2835
2836 // important: VP8 has really poor performances with the mire camera, at least
2837 // on iOS - so when ever h264 is available, let's use it instead
2838 if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) {
2839 disable_all_video_codecs_except_one(pauline->lc,"h264");
2840 disable_all_video_codecs_except_one(marie->lc,"h264");
2841 }
2842 linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id);
2843 linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id);
2844
2845 if (plays_nothing){
2846 /*This case was for trying to replicate an issue because
2847 * zrtp_iterate() was only called when packets are received, which
2848 * creates a big problem because no retransmission of HELLO packet will occur
2849 * if the remote sends nothing.
2850 * However it is not possible to forcibly loose the hello packet, even with network simulator.
2851 * If retransmissions fail, this test will fail from time to time*/
2852 linphone_core_use_files(marie->lc, TRUE);
2853 linphone_core_set_play_file(marie->lc, NULL);
2854 linphone_core_set_play_file(pauline->lc, NULL);
2855 linphone_core_set_media_encryption_mandatory(pauline->lc, TRUE);
2856 linphone_core_set_media_encryption_mandatory(marie->lc, TRUE);
2857 }
2858
2859 if (enable_relay) {
2860 linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL);
2861 linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL);
2862 }
2863 if (enable_tunnel) {
2864 int i;
2865 LinphoneTunnelConfig * tunnel_config = linphone_tunnel_config_new();
2866 linphone_tunnel_config_set_host(tunnel_config, "tunnel.linphone.org");
2867 linphone_tunnel_config_set_port(tunnel_config, 443);
2868 linphone_tunnel_add_server(linphone_core_get_tunnel(marie->lc),tunnel_config);
2869 linphone_tunnel_enable_sip(linphone_core_get_tunnel(marie->lc),FALSE);
2870 linphone_tunnel_set_mode(linphone_core_get_tunnel(marie->lc),LinphoneTunnelModeEnable);
2871 for (i=0;i<100;i++) {
2872 if (linphone_tunnel_connected(linphone_core_get_tunnel(marie->lc))) {
2873 linphone_core_iterate(marie->lc);
2874 break;
2875 }
2876 linphone_core_iterate(marie->lc);
2877 ms_usleep(20000);
2878 }
2879 BC_ASSERT_TRUE(linphone_tunnel_connected(linphone_core_get_tunnel(marie->lc)));
2880 linphone_tunnel_config_unref(tunnel_config);
2881 }
2882
2883 if (linphone_core_media_encryption_supported(marie->lc,mode)) {
2884 linphone_core_set_media_encryption(marie->lc,mode);
2885 linphone_core_set_media_encryption(pauline->lc,mode);
2886 if (mode==LinphoneMediaEncryptionDTLS) { /* for DTLS we must access certificates or at least have a directory to store them */
2887 char *path = bc_tester_file("certificates-marie");
2888 marie->lc->user_certificates_path = ms_strdup(path);
2889 bc_free(path);
2890 path = bc_tester_file("certificates-pauline");
2891 pauline->lc->user_certificates_path = ms_strdup(path);
2892 bc_free(path);
2893 belle_sip_mkdir(marie->lc->user_certificates_path);
2894 belle_sip_mkdir(pauline->lc->user_certificates_path);
2895 }
2896
2897 linphone_core_set_firewall_policy(marie->lc,policy);
2898 linphone_core_set_firewall_policy(pauline->lc,policy);
2899
2900 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
2901 if (!call_ok) goto end;
2902 /* if caller set ZRTP or (callee set ZRTP and caller has no encryption requested), ZRTP shall take place, wait for the SAS */
2903 if ((linphone_core_get_media_encryption(pauline->lc) == LinphoneMediaEncryptionZRTP)
2904 || ((linphone_core_get_media_encryption(marie->lc) == LinphoneMediaEncryptionZRTP) && (linphone_core_get_media_encryption(pauline->lc) == LinphoneMediaEncryptionNone))) {
2905 /*wait for SAS*/
2906 int i;
2907 LinphoneCall *pauline_call;
2908 LinphoneCall *marie_call;
2909 const char *pauline_token = NULL;
2910 const char *marie_token = NULL;
2911 for (i=0;i<100;i++) {
2912 pauline_call = linphone_core_get_current_call(pauline->lc);
2913 marie_call = linphone_core_get_current_call(marie->lc);
2914
2915 if (!pauline_call || !marie_call){
2916 /*if one of the two calls was disapeering, don't crash, but report it*/
2917 BC_ASSERT_PTR_NOT_NULL(pauline_call);
2918 BC_ASSERT_PTR_NOT_NULL(marie_call);
2919 break;
2920 }
2921 pauline_token = linphone_call_get_authentication_token(pauline_call);
2922 marie_token = linphone_call_get_authentication_token(marie_call);
2923 if (pauline_token && marie_token) break;
2924 linphone_core_iterate(marie->lc);
2925 linphone_core_iterate(pauline->lc);
2926 ms_usleep(20000);
2927 }
2928 BC_ASSERT_PTR_NOT_NULL(pauline_token);
2929 BC_ASSERT_PTR_NOT_NULL(marie_token);
2930 if (marie_token && pauline_token){
2931 BC_ASSERT_STRING_EQUAL(pauline_token, marie_token);
2932 BC_ASSERT_TRUE(strlen(pauline_token)>0);
2933 BC_ASSERT_TRUE(strlen(marie_token)>0);
2934 }
2935 if (!plays_nothing) liblinphone_tester_check_rtcp(pauline,marie);
2936 }
2937
2938 if (policy == LinphonePolicyUseIce){
2939 BC_ASSERT_TRUE(check_ice(pauline,marie,enable_tunnel?LinphoneIceStateReflexiveConnection:LinphoneIceStateHostConnection));
2940 wait_for_until(marie->lc, pauline->lc, NULL, 0, 2000);/*fixme to workaround a crash*/
2941 }
2942 #ifdef VIDEO_ENABLED
2943 if (enable_video) {
2944 if (linphone_core_video_supported(marie->lc)) {
2945 BC_ASSERT_TRUE(request_video(pauline,marie, TRUE));
2946 if (policy == LinphonePolicyUseIce){
2947 BC_ASSERT_TRUE(check_ice(pauline, marie, enable_tunnel ? LinphoneIceStateReflexiveConnection
2948 : LinphoneIceStateHostConnection));
2949 }
2950 liblinphone_tester_check_rtcp(marie,pauline);
2951
2952 } else {
2953 ms_warning ("not tested because video not available");
2954 }
2955 }
2956 #endif
2957 end_call(marie, pauline);
2958 } else {
2959 ms_warning ("not tested because %s not available", linphone_media_encryption_to_string(mode));
2960 }
2961 end:
2962 linphone_core_manager_destroy(marie);
2963 linphone_core_manager_destroy(pauline);
2964 }
2965
call_base_with_configfile(LinphoneMediaEncryption mode,bool_t enable_video,bool_t enable_relay,LinphoneFirewallPolicy policy,bool_t enable_tunnel,const char * marie_rc,const char * pauline_rc)2966 void call_base_with_configfile(LinphoneMediaEncryption mode, bool_t enable_video,bool_t enable_relay,LinphoneFirewallPolicy policy,bool_t enable_tunnel, const char *marie_rc, const char *pauline_rc){
2967 _call_base_with_configfile(mode, enable_video, enable_relay, policy, enable_tunnel, marie_rc, pauline_rc, FALSE);
2968 }
2969
2970
call_base(LinphoneMediaEncryption mode,bool_t enable_video,bool_t enable_relay,LinphoneFirewallPolicy policy,bool_t enable_tunnel)2971 void call_base(LinphoneMediaEncryption mode, bool_t enable_video,bool_t enable_relay,LinphoneFirewallPolicy policy,bool_t enable_tunnel) {
2972 call_base_with_configfile(mode, enable_video, enable_relay, policy, enable_tunnel, "marie_rc", "pauline_tcp_rc");
2973 }
2974
srtp_ice_call(void)2975 static void srtp_ice_call(void) {
2976 call_base(LinphoneMediaEncryptionSRTP,FALSE,FALSE,LinphonePolicyUseIce,FALSE);
2977 }
2978
zrtp_ice_call(void)2979 static void zrtp_ice_call(void) {
2980 call_base(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyUseIce,FALSE);
2981 }
2982
zrtp_silent_call(void)2983 static void zrtp_silent_call(void) {
2984 _call_base_with_configfile(LinphoneMediaEncryptionZRTP,FALSE,TRUE,LinphonePolicyNoFirewall,FALSE, "marie_rc", "pauline_tcp_rc", TRUE);
2985 }
2986
zrtp_ice_call_with_relay(void)2987 static void zrtp_ice_call_with_relay(void) {
2988 call_base(LinphoneMediaEncryptionZRTP,FALSE,TRUE,LinphonePolicyUseIce,FALSE);
2989 }
2990
dtls_ice_call_with_relay(void)2991 static void dtls_ice_call_with_relay(void) {
2992 call_base(LinphoneMediaEncryptionDTLS,FALSE,TRUE,LinphonePolicyUseIce,FALSE);
2993 }
2994
early_media_call(void)2995 static void early_media_call(void) {
2996 LinphoneCoreManager* marie = linphone_core_manager_new("marie_early_rc");
2997 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2998 bool_t call_ok;
2999
3000 BC_ASSERT_TRUE(call_ok=call(pauline,marie));
3001
3002 if (!call_ok) goto end;
3003 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallIncomingEarlyMedia,1, int, "%d");
3004 BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallOutgoingEarlyMedia,1, int, "%d");
3005
3006 wait_for_until(pauline->lc,marie->lc,NULL,0,1000);
3007
3008 /*added because a bug related to early-media caused the Connected state to be reached two times*/
3009 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallConnected,1, int, "%d");
3010
3011 end_call(pauline, marie);
3012 end:
3013 linphone_core_manager_destroy(marie);
3014 linphone_core_manager_destroy(pauline);
3015 }
3016
early_media_call_with_ice(void)3017 static void early_media_call_with_ice(void) {
3018 LinphoneCoreManager* marie = linphone_core_manager_new("marie_early_rc");
3019 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3020 LinphoneCall *marie_call, *pauline_call;
3021 bctbx_list_t *lcs = NULL;
3022
3023 lcs = bctbx_list_append(lcs, marie->lc);
3024 lcs = bctbx_list_append(lcs, pauline->lc);
3025
3026 /*in this test, pauline has ICE activated, marie not, but marie proposes early media.
3027 * We want to check that ICE processing is not disturbing early media*/
3028 linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce);
3029
3030 pauline_call = linphone_core_invite_address(pauline->lc, marie->identity);
3031
3032 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallIncomingReceived,1,3000));
3033 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallIncomingEarlyMedia,1,3000));
3034 BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallOutgoingEarlyMedia,1,1000));
3035 BC_ASSERT_TRUE(pauline_call->all_muted);
3036
3037 wait_for_until(pauline->lc,marie->lc,NULL,0,1000);
3038
3039 marie_call = linphone_core_get_current_call(marie->lc);
3040
3041 if (!marie_call) goto end;
3042
3043 linphone_call_accept(marie_call);
3044 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallConnected,1,3000));
3045 BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallConnected,1,3000));
3046 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning,1,3000));
3047 BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallStreamsRunning,1,3000));
3048 BC_ASSERT_FALSE(pauline_call->all_muted);
3049
3050 end_call(marie, pauline);
3051 end:
3052 bctbx_list_free(lcs);
3053 linphone_core_manager_destroy(marie);
3054 linphone_core_manager_destroy(pauline);
3055 }
3056
early_media_call_with_ringing_base(bool_t network_change)3057 static void early_media_call_with_ringing_base(bool_t network_change){
3058 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
3059 LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc");
3060 bctbx_list_t* lcs = NULL;
3061 LinphoneCall* marie_call;
3062 LinphoneCallLog *marie_call_log;
3063 uint64_t connected_time=0;
3064 uint64_t ended_time=0;
3065 int dummy=0;
3066
3067 lcs = bctbx_list_append(lcs,marie->lc);
3068 lcs = bctbx_list_append(lcs,pauline->lc);
3069 /*
3070 Marie calls Pauline, and after the call has rung, transitions to an early_media session
3071 */
3072
3073 marie_call = linphone_core_invite_address(marie->lc, pauline->identity);
3074 marie_call_log = linphone_call_get_call_log(marie_call);
3075
3076 BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallIncomingReceived,1,3000));
3077 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallOutgoingRinging,1,1000));
3078
3079 if (linphone_core_inc_invite_pending(pauline->lc)) {
3080 /* send a 183 to initiate the early media */
3081 linphone_call_accept_early_media(linphone_core_get_current_call(pauline->lc));
3082
3083 BC_ASSERT_TRUE( wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallIncomingEarlyMedia,1,2000) );
3084 BC_ASSERT_TRUE( wait_for_list(lcs, &marie->stat.number_of_LinphoneCallOutgoingEarlyMedia,1,2000) );
3085 BC_ASSERT_TRUE(marie_call->all_muted);
3086
3087 liblinphone_tester_check_rtcp(marie, pauline);
3088
3089 /* this is a hack to simulate an incoming OK with a different IP address
3090 * in the 'c' SDP field. */
3091 if (network_change) {
3092 marie_call->localdesc_changed |= SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED;
3093 }
3094
3095 linphone_call_accept(linphone_core_get_current_call(pauline->lc));
3096
3097 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallConnected, 1,1000));
3098 connected_time=ms_get_cur_time_ms();
3099 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning, 1,1000));
3100
3101 BC_ASSERT_PTR_EQUAL(marie_call, linphone_core_get_current_call(marie->lc));
3102 BC_ASSERT_FALSE(marie_call->all_muted);
3103
3104 liblinphone_tester_check_rtcp(marie, pauline);
3105 /*just to have a call duration !=0*/
3106 wait_for_list(lcs,&dummy,1,2000);
3107
3108 end_call(pauline, marie);
3109 ended_time=ms_get_cur_time_ms();
3110 BC_ASSERT_LOWER( labs((long)((linphone_call_log_get_duration(marie_call_log)*1000) - (int64_t)(ended_time - connected_time))), 1000, long, "%ld");
3111 bctbx_list_free(lcs);
3112 }
3113
3114 linphone_core_manager_destroy(marie);
3115 linphone_core_manager_destroy(pauline);
3116 }
3117
early_media_call_with_ringing(void)3118 static void early_media_call_with_ringing(void) {
3119 early_media_call_with_ringing_base(FALSE);
3120 }
3121
early_media_call_with_ringing_and_network_changing(void)3122 static void early_media_call_with_ringing_and_network_changing(void) {
3123 early_media_call_with_ringing_base(TRUE);
3124 }
3125
early_media_call_with_update_base(bool_t media_change)3126 static void early_media_call_with_update_base(bool_t media_change){
3127 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
3128 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3129 bctbx_list_t* lcs = NULL;
3130 LinphoneCall *marie_call, *pauline_call;
3131 LinphoneCallParams *pauline_params;
3132
3133 lcs = bctbx_list_append(lcs,marie->lc);
3134 lcs = bctbx_list_append(lcs,pauline->lc);
3135 if (media_change) {
3136 disable_all_audio_codecs_except_one(marie->lc,"pcmu",-1);
3137 disable_all_audio_codecs_except_one(pauline->lc,"pcmu",-1);
3138 }
3139 /*
3140 Marie calls Pauline, and after the call has rung, transitions to an early_media session
3141 */
3142
3143 marie_call = linphone_core_invite_address(marie->lc, pauline->identity);
3144
3145 BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallIncomingReceived,1,5000));
3146 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallOutgoingRinging,1,5000));
3147
3148 pauline_call = linphone_core_get_current_call(pauline->lc);
3149 if (!pauline_call) goto end;
3150 /* send a 183 to initiate the early media */
3151 linphone_call_accept_early_media(pauline_call);
3152 BC_ASSERT_TRUE( wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallIncomingEarlyMedia,1,1000) );
3153 BC_ASSERT_TRUE( wait_for_list(lcs, &marie->stat.number_of_LinphoneCallOutgoingEarlyMedia,1,5000) );
3154 BC_ASSERT_TRUE(marie_call->all_muted);
3155
3156 pauline_params = linphone_call_params_copy(linphone_call_get_current_params(pauline_call));
3157
3158 if (media_change) {
3159 disable_all_audio_codecs_except_one(marie->lc,"pcma",-1);
3160 disable_all_audio_codecs_except_one(pauline->lc,"pcma",-1);
3161 }
3162 #define UPDATED_SESSION_NAME "nouveau nom de session"
3163
3164 linphone_call_params_set_session_name(pauline_params,UPDATED_SESSION_NAME);
3165 linphone_call_update(pauline_call, pauline_params);
3166 linphone_call_params_unref(pauline_params);
3167 BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallEarlyUpdating,1,2000));
3168 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallEarlyUpdatedByRemote,1,2000));
3169 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallOutgoingEarlyMedia,1,2000));
3170 BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallIncomingEarlyMedia,1,2000));
3171 BC_ASSERT_TRUE(marie_call->all_muted);
3172
3173 /*just to wait 2s*/
3174 liblinphone_tester_check_rtcp(marie, pauline);
3175
3176 BC_ASSERT_STRING_EQUAL( linphone_call_params_get_session_name(linphone_call_get_remote_params(marie_call))
3177 , UPDATED_SESSION_NAME);
3178
3179 linphone_call_accept(linphone_core_get_current_call(pauline->lc));
3180
3181 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallConnected, 1,1000));
3182 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning, 1,1000));
3183 BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallConnected, 1,1000));
3184 BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1,1000));
3185 BC_ASSERT_FALSE(marie_call->all_muted);
3186
3187 liblinphone_tester_check_rtcp(marie, pauline);
3188
3189 end_call(pauline, marie);
3190
3191 end:
3192
3193 bctbx_list_free(lcs);
3194 linphone_core_manager_destroy(marie);
3195 linphone_core_manager_destroy(pauline);
3196 }
3197
early_media_call_with_session_update(void)3198 static void early_media_call_with_session_update(void){
3199 early_media_call_with_update_base(FALSE);
3200 }
3201
early_media_call_with_codec_update(void)3202 static void early_media_call_with_codec_update(void){
3203 early_media_call_with_update_base(TRUE);
3204 }
3205
3206
check_call_state(LinphoneCoreManager * mgr,LinphoneCallState state)3207 static void check_call_state(LinphoneCoreManager* mgr,LinphoneCallState state) {
3208 BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(mgr->lc));
3209 if (linphone_core_get_current_call(mgr->lc))
3210 BC_ASSERT_EQUAL(linphone_call_get_state(linphone_core_get_current_call(mgr->lc)),state, int, "%d");
3211 }
3212
call_established_with_rejected_info(void)3213 static void call_established_with_rejected_info(void) {
3214 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
3215 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3216 LinphoneInfoMessage *im1;
3217 LinphoneInfoMessage *im2;
3218 int dummy=0;
3219 bool_t call_ok=FALSE;
3220
3221 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
3222 if (call_ok){
3223
3224 sal_enable_unconditional_answer(marie->lc->sal,TRUE);
3225 im1 = linphone_core_create_info_message(pauline->lc);
3226 linphone_call_send_info_message(linphone_core_get_current_call(pauline->lc),im1);
3227
3228 wait_for_until(marie->lc,pauline->lc,&dummy,1,1000); /*just to sleep while iterating 1s*/
3229 linphone_info_message_unref(im1);
3230
3231 sal_enable_unconditional_answer(marie->lc->sal,FALSE);
3232
3233 im2 = linphone_core_create_info_message(pauline->lc);
3234 linphone_call_send_info_message(linphone_core_get_current_call(pauline->lc),im2);
3235 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_inforeceived,1));
3236 BC_ASSERT_EQUAL(marie->stat.number_of_inforeceived,1, int, "%d");
3237 linphone_info_message_unref(im2);
3238
3239 check_call_state(pauline,LinphoneCallStreamsRunning);
3240 check_call_state(marie,LinphoneCallStreamsRunning);
3241 end_call(pauline, marie);
3242 }
3243
3244 linphone_core_manager_destroy(marie);
3245 linphone_core_manager_destroy(pauline);
3246 }
3247
call_established_with_complex_rejected_operation(void)3248 static void call_established_with_complex_rejected_operation(void) {
3249 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
3250 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3251 bool_t call_ok=FALSE;
3252 LinphoneCallParams *params;
3253 LinphoneInfoMessage *info;
3254
3255 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
3256 if (call_ok){
3257
3258 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,1));
3259 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,1));
3260
3261 linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMU",8000,1),FALSE); /*disable PCMU*/
3262 linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMA",8000,1),TRUE); /*enable PCMA*/
3263 linphone_core_enable_payload_type(marie->lc,linphone_core_find_payload_type(marie->lc,"PCMU",8000,1),FALSE); /*disable PCMU*/
3264 linphone_core_enable_payload_type(marie->lc,linphone_core_find_payload_type(marie->lc,"PCMA",8000,1),TRUE); /*enable PCMA*/
3265
3266 /*just to authenticate marie*/
3267 info = linphone_core_create_info_message(marie->lc);
3268 linphone_call_send_info_message(linphone_core_get_current_call(marie->lc), info);
3269 linphone_info_message_unref(info);
3270 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_inforeceived,1));
3271 BC_ASSERT_EQUAL(pauline->stat.number_of_inforeceived,1, int, "%d");
3272 /*to give time for 200ok to arrive*/
3273 wait_for_until(marie->lc,pauline->lc,NULL,0,1000);
3274
3275 linphone_call_update(linphone_core_get_current_call(pauline->lc),linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)));
3276
3277 linphone_call_update(linphone_core_get_current_call(marie->lc),linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)));
3278
3279 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
3280 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
3281
3282 BC_ASSERT_EQUAL(linphone_call_get_reason(linphone_core_get_current_call(pauline->lc)),LinphoneReasonTemporarilyUnavailable, int, "%d");
3283 BC_ASSERT_EQUAL(linphone_call_get_reason(linphone_core_get_current_call(pauline->lc)),LinphoneReasonTemporarilyUnavailable, int, "%d");
3284
3285 check_call_state(pauline,LinphoneCallStreamsRunning);
3286 check_call_state(marie,LinphoneCallStreamsRunning);
3287
3288 linphone_call_update(linphone_core_get_current_call(pauline->lc),linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)));
3289 info = linphone_core_create_info_message(marie->lc);
3290 linphone_call_send_info_message(linphone_core_get_current_call(marie->lc), info);
3291 linphone_info_message_unref(info);
3292
3293 params=linphone_core_create_call_params(marie->lc,linphone_core_get_current_call(marie->lc));
3294 sal_enable_pending_trans_checking(marie->lc->sal,FALSE); /*to allow // transactions*/
3295 linphone_core_enable_payload_type(marie->lc,linphone_core_find_payload_type(marie->lc,"PCMU",8000,1),TRUE);
3296 linphone_core_enable_payload_type(marie->lc,linphone_core_find_payload_type(marie->lc,"PCMA",8000,1),FALSE);
3297
3298 linphone_call_update(linphone_core_get_current_call(marie->lc),params);
3299
3300 linphone_call_params_unref(params);
3301
3302 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3));
3303 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3));
3304
3305 BC_ASSERT_EQUAL(linphone_call_get_reason(linphone_core_get_current_call(pauline->lc)),LinphoneReasonTemporarilyUnavailable, int, "%d");
3306 BC_ASSERT_EQUAL(linphone_call_get_reason(linphone_core_get_current_call(pauline->lc)),LinphoneReasonTemporarilyUnavailable, int, "%d");
3307
3308 end_call(pauline, marie);
3309 }
3310
3311 linphone_core_manager_destroy(marie);
3312 linphone_core_manager_destroy(pauline);
3313 }
3314
call_established_with_rejected_info_during_reinvite(void)3315 static void call_established_with_rejected_info_during_reinvite(void) {
3316 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
3317 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3318 bool_t call_ok=FALSE;
3319
3320 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
3321 if (call_ok){
3322 LinphoneInfoMessage *info;
3323 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,1));
3324 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,1));
3325
3326 linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMU",8000,1),FALSE); /*disable PCMU*/
3327 linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMA",8000,1),TRUE); /*enable PCMA*/
3328 linphone_core_enable_payload_type(marie->lc,linphone_core_find_payload_type(marie->lc,"PCMU",8000,1),FALSE); /*disable PCMU*/
3329 linphone_core_enable_payload_type(marie->lc,linphone_core_find_payload_type(marie->lc,"PCMA",8000,1),TRUE); /*enable PCMA*/
3330
3331 /*just to authenticate marie*/
3332 info = linphone_core_create_info_message(marie->lc);
3333 linphone_call_send_info_message(linphone_core_get_current_call(marie->lc), info);
3334 linphone_info_message_unref(info);
3335 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_inforeceived,1));
3336 BC_ASSERT_EQUAL(pauline->stat.number_of_inforeceived,1, int, "%d");
3337 /*to give time for 200ok to arrive*/
3338 wait_for_until(marie->lc,pauline->lc,NULL,0,1000);
3339
3340 //sal_enable_pending_trans_checking(marie->lc->sal,FALSE); /*to allow // transactions*/
3341 info = linphone_core_create_info_message(marie->lc);
3342 linphone_call_send_info_message(linphone_core_get_current_call(marie->lc),info);
3343 linphone_info_message_unref(info);
3344
3345 //sal_set_send_error(marie->lc->sal, -1); /*to avoid 491 pending to be sent*/
3346
3347 linphone_call_update(linphone_core_get_current_call(pauline->lc),linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)));
3348
3349 wait_for_until(pauline->lc,pauline->lc,NULL,0,2000); /*to avoid 491 pending to be sent to early*/
3350
3351 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
3352 end_call(pauline, marie);
3353 }
3354
3355 linphone_core_manager_destroy(marie);
3356 linphone_core_manager_destroy(pauline);
3357 }
3358
3359
call_established_with_rejected_reinvite(void)3360 static void call_established_with_rejected_reinvite(void) {
3361 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
3362 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3363 bool_t call_ok=FALSE;
3364
3365 BC_ASSERT_TRUE(call_ok=call(pauline,marie));
3366 if (call_ok){
3367 linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMU",8000,1),FALSE); /*disable PCMU*/
3368 linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMA",8000,1),TRUE); /*enable PCMA*/
3369
3370 linphone_call_update(linphone_core_get_current_call(pauline->lc),linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)));
3371
3372 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
3373
3374 BC_ASSERT_EQUAL(linphone_call_get_reason(linphone_core_get_current_call(pauline->lc)),LinphoneReasonNotAcceptable, int, "%d");
3375
3376 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning,1, int, "%d");
3377 check_call_state(pauline,LinphoneCallStreamsRunning);
3378 check_call_state(marie,LinphoneCallStreamsRunning);
3379 end_call(pauline, marie);
3380 }
3381
3382 linphone_core_manager_destroy(marie);
3383 linphone_core_manager_destroy(pauline);
3384 }
3385
call_established_with_rejected_incoming_reinvite(void)3386 static void call_established_with_rejected_incoming_reinvite(void) {
3387 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
3388 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3389 bool_t call_ok=FALSE;
3390
3391 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
3392
3393 if (call_ok){
3394
3395 /*wait for ACK to be transmitted before going to reINVITE*/
3396 wait_for_until(marie->lc,pauline->lc,NULL,0,1000);
3397
3398 linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMU",8000,1),FALSE); /*disable PCMU*/
3399 linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMA",8000,1),TRUE); /*enable PCMA*/
3400
3401 linphone_call_update(linphone_core_get_current_call(marie->lc),linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)));
3402
3403 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdating,1));
3404 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
3405
3406 BC_ASSERT_EQUAL(linphone_call_get_reason(linphone_core_get_current_call(marie->lc)),LinphoneReasonNotAcceptable, int, "%d");
3407
3408 BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning,1, int, "%d");
3409 check_call_state(pauline,LinphoneCallStreamsRunning);
3410 check_call_state(marie,LinphoneCallStreamsRunning);
3411 end_call(pauline, marie);
3412 }
3413
3414 linphone_core_manager_destroy(marie);
3415 linphone_core_manager_destroy(pauline);
3416 }
3417
call_redirect(void)3418 static void call_redirect(void){
3419 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
3420 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3421 LinphoneCoreManager* laure = linphone_core_manager_new("laure_rc_udp");
3422 bctbx_list_t* lcs = NULL;
3423 char *laure_url = NULL;
3424 LinphoneCall* marie_call;
3425
3426 lcs = bctbx_list_append(lcs,marie->lc);
3427 lcs = bctbx_list_append(lcs,pauline->lc);
3428 lcs = bctbx_list_append(lcs,laure->lc);
3429 /*
3430 Marie calls Pauline, which will redirect the call to Laure via a 302
3431 */
3432
3433 marie_call = linphone_core_invite_address(marie->lc, pauline->identity);
3434
3435 BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallIncomingReceived,1,6000));
3436
3437 if (linphone_core_get_current_call(pauline->lc)){
3438 laure_url = linphone_address_as_string(laure->identity);
3439 linphone_call_redirect(linphone_core_get_current_call(pauline->lc), laure_url);
3440 ms_free(laure_url);
3441
3442 /* laure should be ringing now */
3443 BC_ASSERT_TRUE(wait_for_list(lcs, &laure->stat.number_of_LinphoneCallIncomingReceived,1,6000));
3444 /* pauline should have ended the call */
3445 BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallEnd,1,1000));
3446 /* the call should still be ringing on marie's side */
3447 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallOutgoingRinging, 1, int, "%i");
3448
3449 linphone_call_accept(linphone_core_get_current_call(laure->lc));
3450
3451 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning, 1,5000));
3452 BC_ASSERT_TRUE(wait_for_list(lcs, &laure->stat.number_of_LinphoneCallStreamsRunning, 1,5000));
3453
3454 BC_ASSERT_PTR_EQUAL(marie_call, linphone_core_get_current_call(marie->lc));
3455
3456 liblinphone_tester_check_rtcp(marie, laure);
3457
3458 end_call(laure, marie);
3459 }
3460
3461 bctbx_list_free(lcs);
3462
3463 linphone_core_manager_destroy(marie);
3464 linphone_core_manager_destroy(pauline);
3465 linphone_core_manager_destroy(laure);
3466
3467 }
3468
call_established_with_rejected_reinvite_with_error_base(bool_t trans_pending)3469 static void call_established_with_rejected_reinvite_with_error_base(bool_t trans_pending) {
3470 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
3471 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3472 bool_t call_ok=TRUE;
3473 int result;
3474
3475 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
3476
3477 if (call_ok){
3478 linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMA",8000,1),TRUE); /*add PCMA*/
3479
3480 if (trans_pending) {
3481 LinphoneInfoMessage * info = linphone_core_create_info_message(pauline->lc);
3482 linphone_call_send_info_message(linphone_core_get_current_call(pauline->lc),info);
3483 linphone_info_message_unref(info);
3484
3485 } else
3486 sal_enable_unconditional_answer(marie->lc->sal,TRUE);
3487
3488 result = linphone_call_update(linphone_core_get_current_call(pauline->lc),linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)));
3489
3490 if (trans_pending)
3491 BC_ASSERT_NOT_EQUAL(result,0, int, "%d");
3492 else
3493 BC_ASSERT_EQUAL(result,0,int, "%d");
3494
3495 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
3496
3497 BC_ASSERT_EQUAL(linphone_call_get_reason(linphone_core_get_current_call(pauline->lc)),LinphoneReasonTemporarilyUnavailable, int, "%d"); /*might be change later*/
3498
3499 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning,1, int, "%d");
3500 check_call_state(pauline,LinphoneCallStreamsRunning);
3501 check_call_state(marie,LinphoneCallStreamsRunning);
3502
3503 if (!trans_pending)
3504 sal_enable_unconditional_answer(marie->lc->sal,FALSE);
3505
3506 end_call(pauline, marie);
3507 }
3508
3509 linphone_core_manager_destroy(marie);
3510 linphone_core_manager_destroy(pauline);
3511 }
3512
call_established_with_rejected_reinvite_with_error(void)3513 static void call_established_with_rejected_reinvite_with_error(void) {
3514 call_established_with_rejected_reinvite_with_error_base(FALSE);
3515 }
3516
call_established_with_rejected_reinvite_with_trans_pending_error(void)3517 static void call_established_with_rejected_reinvite_with_trans_pending_error(void) {
3518 call_established_with_rejected_reinvite_with_error_base(TRUE);
3519 }
3520
call_rejected_because_wrong_credentials_with_params(const char * user_agent,bool_t enable_auth_req_cb)3521 static void call_rejected_because_wrong_credentials_with_params(const char* user_agent,bool_t enable_auth_req_cb) {
3522 LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
3523 LinphoneAuthInfo* good_auth_info=linphone_auth_info_clone(linphone_core_find_auth_info(marie->lc,NULL,linphone_address_get_username(marie->identity),NULL));
3524 LinphoneAuthInfo* wrong_auth_info=linphone_auth_info_clone(good_auth_info);
3525 bool_t result=FALSE;
3526 linphone_auth_info_set_passwd(wrong_auth_info,"passecretdutout");
3527 linphone_auth_info_set_ha1(wrong_auth_info, NULL);
3528 linphone_core_clear_all_auth_info(marie->lc);
3529
3530 if (user_agent) {
3531 linphone_core_set_user_agent(marie->lc,user_agent,NULL);
3532 }
3533 if (!enable_auth_req_cb) {
3534 ((VTableReference*)(marie->lc->vtable_refs->data))->cbs->vtable->auth_info_requested=NULL;
3535 linphone_core_add_auth_info(marie->lc,wrong_auth_info);
3536 }
3537
3538
3539 BC_ASSERT_PTR_NOT_NULL(linphone_core_invite_address(marie->lc,marie->identity));
3540
3541 result=wait_for(marie->lc,marie->lc,&marie->stat.number_of_auth_info_requested,1);
3542
3543 if (enable_auth_req_cb) {
3544 BC_ASSERT_TRUE(result);
3545 /*automatically re-inititae the call*/
3546 linphone_core_add_auth_info(marie->lc,wrong_auth_info);
3547 }
3548
3549 BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphoneCallError,1));
3550 if (enable_auth_req_cb) {
3551 BC_ASSERT_EQUAL(marie->stat.number_of_auth_info_requested,2, int, "%d");
3552 }
3553 /*to make sure unregister will work*/
3554 linphone_core_clear_all_auth_info(marie->lc);
3555 linphone_core_add_auth_info(marie->lc,good_auth_info);
3556 linphone_auth_info_unref(good_auth_info);
3557 linphone_auth_info_unref(wrong_auth_info);
3558 linphone_core_manager_destroy(marie);
3559 }
3560
call_rejected_because_wrong_credentials(void)3561 static void call_rejected_because_wrong_credentials(void) {
3562 call_rejected_because_wrong_credentials_with_params(NULL,TRUE);
3563 }
3564
call_rejected_without_403_because_wrong_credentials(void)3565 static void call_rejected_without_403_because_wrong_credentials(void) {
3566 call_rejected_because_wrong_credentials_with_params("tester-no-403",TRUE);
3567 }
3568
call_rejected_without_403_because_wrong_credentials_no_auth_req_cb(void)3569 static void call_rejected_without_403_because_wrong_credentials_no_auth_req_cb(void) {
3570 call_rejected_because_wrong_credentials_with_params("tester-no-403",FALSE);
3571 }
3572
check_media_direction(LinphoneCoreManager * mgr,LinphoneCall * call,bctbx_list_t * lcs,LinphoneMediaDirection audio_dir,LinphoneMediaDirection video_dir)3573 void check_media_direction(LinphoneCoreManager* mgr, LinphoneCall *call, bctbx_list_t* lcs,LinphoneMediaDirection audio_dir, LinphoneMediaDirection video_dir) {
3574 BC_ASSERT_PTR_NOT_NULL(call);
3575 if (call) {
3576 const LinphoneCallParams *params;
3577 wait_for_list(lcs,NULL,0,5000); /*on some device, it may take 3 to 4s to get audio from mic*/
3578 params = linphone_call_get_current_params(call);
3579 #ifdef VIDEO_ENABLED
3580 if (video_dir != LinphoneMediaDirectionInvalid){
3581 int current_recv_iframe = mgr->stat.number_of_IframeDecoded;
3582 int expected_recv_iframe=0;
3583 LinphoneCallStats *stats = linphone_call_get_video_stats(call);
3584
3585 if (video_dir != LinphoneMediaDirectionInactive){
3586 BC_ASSERT_TRUE(linphone_call_params_video_enabled(params));
3587 BC_ASSERT_EQUAL(linphone_call_params_get_video_direction(params), video_dir, int, "%d");
3588 linphone_call_set_next_video_frame_decoded_callback(call,linphone_call_iframe_decoded_cb,mgr->lc);
3589 linphone_call_send_vfu_request(call);
3590 }
3591 switch (video_dir) {
3592 case LinphoneMediaDirectionInactive:
3593 BC_ASSERT_LOWER((int)stats->upload_bandwidth, 5, int, "%i");
3594 break;
3595 case LinphoneMediaDirectionSendOnly:
3596 expected_recv_iframe = 0;
3597 BC_ASSERT_LOWER((int)stats->download_bandwidth, 5, int, "%i");
3598 break;
3599 case LinphoneMediaDirectionRecvOnly:
3600 BC_ASSERT_LOWER((int)stats->upload_bandwidth, 5, int, "%i");
3601 BCTBX_NO_BREAK; /*intentionally no break*/
3602 case LinphoneMediaDirectionSendRecv:
3603 expected_recv_iframe = 1;
3604 break;
3605 default:
3606 break;
3607 }
3608 linphone_call_stats_unref(stats);
3609 BC_ASSERT_TRUE(wait_for_list(lcs, &mgr->stat.number_of_IframeDecoded,current_recv_iframe + expected_recv_iframe,10000));
3610 }
3611 #endif
3612 if (audio_dir != LinphoneMediaDirectionInvalid){
3613 BC_ASSERT_EQUAL(linphone_call_params_get_audio_direction(params), audio_dir, int, "%d");
3614 switch (audio_dir) {
3615 case LinphoneMediaDirectionInactive:
3616 BC_ASSERT_LOWER(linphone_core_manager_get_mean_audio_up_bw(mgr), 5, int, "%i");
3617 BC_ASSERT_LOWER(linphone_core_manager_get_mean_audio_down_bw(mgr), 5, int, "%i");
3618 break;
3619 case LinphoneMediaDirectionSendOnly:
3620 BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_up_bw(mgr), 70, int, "%i");
3621 break;
3622 case LinphoneMediaDirectionRecvOnly:
3623 BC_ASSERT_LOWER(linphone_core_manager_get_mean_audio_up_bw(mgr), 5, int, "%i");
3624 break;
3625 case LinphoneMediaDirectionSendRecv:
3626 BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(mgr), 70, int, "%i");
3627 BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_up_bw(mgr), 70, int, "%i");
3628 break;
3629 default:
3630 break;
3631 }
3632 }
3633 }
3634
3635 }
3636
record_call(const char * filename,bool_t enableVideo,const char * video_codec)3637 void record_call(const char *filename, bool_t enableVideo, const char *video_codec) {
3638 LinphoneCoreManager *marie = NULL;
3639 LinphoneCoreManager *pauline = NULL;
3640 LinphoneCallParams *marieParams = NULL;
3641 LinphoneCallParams *paulineParams = NULL;
3642 LinphoneCall *callInst = NULL;
3643 const char **formats, *format;
3644 char *filepath;
3645 int dummy=0, i;
3646 bool_t call_succeeded = FALSE;
3647
3648 marie = linphone_core_manager_new("marie_h264_rc");
3649 pauline = linphone_core_manager_new("pauline_h264_rc");
3650
3651 // important: VP8 has really poor performances with the mire camera, at least
3652 // on iOS - so when ever h264 is available, let's use it instead
3653 if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) {
3654 disable_all_video_codecs_except_one(pauline->lc,"h264");
3655 disable_all_video_codecs_except_one(marie->lc,"h264");
3656 }
3657
3658 #if defined(HAVE_OPENH264) && defined(__ANDROID__)
3659 libmsopenh264_init(linphone_core_get_ms_factory(marie->lc));
3660 linphone_core_reload_ms_plugins(marie->lc, NULL);
3661 libmsopenh264_init(linphone_core_get_ms_factory(pauline->lc));
3662 linphone_core_reload_ms_plugins(pauline->lc, NULL);
3663 #endif
3664 marieParams = linphone_core_create_call_params(marie->lc, NULL);
3665 paulineParams = linphone_core_create_call_params(pauline->lc, NULL);
3666
3667 #ifdef VIDEO_ENABLED
3668 linphone_core_set_video_device(pauline->lc, liblinphone_tester_mire_id);
3669 if(enableVideo) {
3670 if(linphone_core_find_payload_type(marie->lc, video_codec, -1, -1)
3671 && linphone_core_find_payload_type(pauline->lc, video_codec, -1, -1)) {
3672 linphone_call_params_enable_video(marieParams, TRUE);
3673 linphone_call_params_enable_video(paulineParams, TRUE);
3674 disable_all_video_codecs_except_one(marie->lc, video_codec);
3675 disable_all_video_codecs_except_one(pauline->lc, video_codec);
3676 } else {
3677 ms_warning("call_recording(): the H264 payload has not been found. Only sound will be recorded");
3678 }
3679 }
3680 #endif
3681
3682 formats = linphone_core_get_supported_file_formats(marie->lc);
3683
3684 for(i=0, format = formats[0]; format != NULL; i++, format = formats[i]) {
3685 char* totalname = ms_strdup_printf("%s.%s", filename, format);
3686 filepath = bc_tester_file(totalname);
3687 ms_free(totalname);
3688 remove(filepath);
3689 linphone_call_params_set_record_file(marieParams, filepath);
3690 BC_ASSERT_TRUE(call_succeeded = call_with_params(marie, pauline, marieParams, paulineParams));
3691 BC_ASSERT_PTR_NOT_NULL(callInst = linphone_core_get_current_call(marie->lc));
3692 if ((call_succeeded == TRUE) && (callInst != NULL)) {
3693 ms_message("call_recording(): start recording into %s", filepath);
3694 linphone_call_start_recording(callInst);
3695 wait_for_until(marie->lc,pauline->lc,&dummy,1,5000);
3696 linphone_call_stop_recording(callInst);
3697 end_call(marie, pauline);
3698 BC_ASSERT_EQUAL(ortp_file_exist(filepath), 0, int, "%d");
3699 }
3700 remove(filepath);
3701 ms_free(filepath);
3702 }
3703 linphone_call_params_unref(paulineParams);
3704 linphone_call_params_unref(marieParams);
3705 linphone_core_manager_destroy(marie);
3706 linphone_core_manager_destroy(pauline);
3707 }
3708
audio_call_recording_test(void)3709 static void audio_call_recording_test(void) {
3710 record_call("recording", FALSE, NULL);
3711 }
3712
call_with_in_dialog_update(void)3713 static void call_with_in_dialog_update(void) {
3714 LinphoneCoreManager* marie;
3715 LinphoneCoreManager* pauline;
3716 LinphoneCallParams *params;
3717 bool_t call_ok;
3718
3719 marie = linphone_core_manager_new( "marie_rc");
3720 pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3721 BC_ASSERT_TRUE(call_ok=call(pauline,marie));
3722 if (!call_ok) goto end;
3723
3724 liblinphone_tester_check_rtcp(marie,pauline);
3725 params=linphone_core_create_call_params(marie->lc,linphone_core_get_current_call(marie->lc));
3726 params->no_user_consent=TRUE;
3727 linphone_call_update(linphone_core_get_current_call(marie->lc),params);
3728 linphone_call_params_unref(params);
3729 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdating,1));
3730 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
3731 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallUpdatedByRemote,1));
3732 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
3733 end_call(marie,pauline);
3734
3735 end:
3736 linphone_core_manager_destroy(marie);
3737 linphone_core_manager_destroy(pauline);
3738 }
call_with_very_early_call_update(void)3739 static void call_with_very_early_call_update(void) {
3740 LinphoneCoreManager* marie;
3741 LinphoneCoreManager* pauline;
3742 LinphoneCallParams *params;
3743
3744 marie = linphone_core_manager_new( "marie_rc");
3745 pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3746 linphone_core_invite_address(marie->lc,pauline->identity);
3747
3748 BC_ASSERT_TRUE (wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallIncomingReceived,1));
3749 BC_ASSERT_TRUE(linphone_core_inc_invite_pending(pauline->lc));
3750 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallOutgoingProgress,1, int, "%d");
3751 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallOutgoingRinging,1));
3752
3753 BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call_remote_address(pauline->lc));
3754 if (linphone_core_get_current_call_remote_address(pauline->lc)) {
3755 linphone_call_accept(linphone_core_get_current_call(pauline->lc));
3756 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,1));
3757 }
3758
3759 if(linphone_core_get_current_call(pauline->lc)) {
3760 params=linphone_core_create_call_params(pauline->lc,linphone_core_get_current_call(pauline->lc));
3761 linphone_call_update(linphone_core_get_current_call(pauline->lc),params);
3762 linphone_call_params_unref(params);
3763 }
3764
3765 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallUpdating,1));
3766 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdatedByRemote,1));
3767 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
3768 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
3769 end_call(marie,pauline);
3770
3771 linphone_core_manager_destroy(marie);
3772 linphone_core_manager_destroy(pauline);
3773 }
3774
3775
call_with_in_dialog_codec_change_base(bool_t no_sdp)3776 static void call_with_in_dialog_codec_change_base(bool_t no_sdp) {
3777 int dummy=0;
3778 LinphoneCoreManager* marie;
3779 LinphoneCoreManager* pauline;
3780 LinphoneCallParams *params;
3781 bool_t call_ok;
3782
3783 marie = linphone_core_manager_new( "marie_rc");
3784 pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3785 BC_ASSERT_TRUE(call_ok=call(pauline,marie));
3786 if (!call_ok) goto end;
3787
3788 liblinphone_tester_check_rtcp(marie,pauline);
3789 params=linphone_core_create_call_params(marie->lc,linphone_core_get_current_call(marie->lc));
3790
3791 linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMU",8000,1),FALSE); /*disable PCMU*/
3792 linphone_core_enable_payload_type(marie->lc,linphone_core_find_payload_type(marie->lc,"PCMU",8000,1),FALSE); /*disable PCMU*/
3793 linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMA",8000,1),TRUE); /*enable PCMA*/
3794 linphone_core_enable_payload_type(marie->lc,linphone_core_find_payload_type(marie->lc,"PCMA",8000,1),TRUE); /*enable PCMA*/
3795 if (no_sdp) {
3796 linphone_core_enable_sdp_200_ack(marie->lc,TRUE);
3797 }
3798 linphone_call_update(linphone_core_get_current_call(marie->lc),params);
3799 linphone_call_params_unref(params);
3800 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdating,1));
3801 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
3802 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallUpdatedByRemote,1));
3803 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
3804 BC_ASSERT_STRING_EQUAL("PCMA",payload_type_get_mime(linphone_call_params_get_used_audio_codec(linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)))));
3805 wait_for_until(marie->lc, pauline->lc, &dummy, 1, 5000);
3806 BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(marie),70,int,"%i");
3807 BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(pauline),70,int,"%i");
3808
3809 end_call(marie,pauline);
3810 end:
3811 linphone_core_manager_destroy(marie);
3812 linphone_core_manager_destroy(pauline);
3813 }
call_with_in_dialog_codec_change(void)3814 static void call_with_in_dialog_codec_change(void) {
3815 call_with_in_dialog_codec_change_base(FALSE);
3816 }
call_with_in_dialog_codec_change_no_sdp(void)3817 static void call_with_in_dialog_codec_change_no_sdp(void) {
3818 call_with_in_dialog_codec_change_base(TRUE);
3819 }
3820
call_with_custom_supported_tags(void)3821 static void call_with_custom_supported_tags(void) {
3822 LinphoneCoreManager* marie;
3823 LinphoneCoreManager* pauline;
3824 const LinphoneCallParams *remote_params;
3825 const char *recv_supported;
3826 LinphoneCall *pauline_call;
3827
3828 marie = linphone_core_manager_new( "marie_rc");
3829 pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3830
3831 linphone_core_add_supported_tag(marie->lc,"pouet-tag");
3832 linphone_core_add_supported_tag(marie->lc,"truc-tag");
3833 linphone_core_add_supported_tag(marie->lc,"machin-tag");
3834
3835 linphone_core_invite_address(marie->lc, pauline->identity);
3836 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingReceived,1));
3837 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingRinging,1));
3838 pauline_call = linphone_core_get_current_call(pauline->lc);
3839 if (!pauline_call) goto end;
3840
3841 remote_params=linphone_call_get_remote_params(pauline_call);
3842 recv_supported=linphone_call_params_get_custom_header(remote_params,"supported");
3843 BC_ASSERT_PTR_NOT_NULL(recv_supported);
3844 if (recv_supported){
3845 BC_ASSERT_PTR_NOT_NULL(strstr(recv_supported,"pouet-tag, truc-tag, machin-tag"));
3846 }
3847
3848 end_call(marie,pauline);
3849 end:
3850 linphone_core_manager_destroy(marie);
3851 linphone_core_manager_destroy(pauline);
3852 }
3853
call_log_from_taken_from_p_asserted_id(void)3854 static void call_log_from_taken_from_p_asserted_id(void) {
3855 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
3856 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3857 LinphoneCall *c1,*c2;
3858 LinphoneCallParams *params;
3859 const char* pauline_asserted_id ="\"Paupauche\" <sip:pauline@super.net>";
3860 LinphoneAddress *pauline_asserted_id_addr = linphone_address_new(pauline_asserted_id);
3861 LpConfig *marie_lp;
3862 bool_t call_ok;
3863
3864 params=linphone_core_create_call_params(pauline->lc, NULL);
3865
3866 linphone_call_params_add_custom_header(params,"P-Asserted-Identity",pauline_asserted_id);
3867 /*fixme, should be able to add several time the same header linphone_call_params_add_custom_header(params,"P-Asserted-Identity","\"Paupauche\" <tel:+12345>");*/
3868
3869 marie_lp = linphone_core_get_config(marie->lc);
3870 lp_config_set_int(marie_lp,"sip","call_logs_use_asserted_id_instead_of_from",1);
3871
3872
3873 BC_ASSERT_TRUE(call_ok=call_with_caller_params(pauline,marie,params));
3874
3875 if (!call_ok) goto end;
3876
3877 c1=linphone_core_get_current_call(pauline->lc);
3878 c2=linphone_core_get_current_call(marie->lc);
3879
3880 BC_ASSERT_PTR_NOT_NULL(c1);
3881 BC_ASSERT_PTR_NOT_NULL(c2);
3882
3883 /*make sure remote identity is hidden*/
3884 BC_ASSERT_TRUE(linphone_address_weak_equal(linphone_call_get_remote_address(c2),pauline_asserted_id_addr));
3885 linphone_address_unref(pauline_asserted_id_addr);
3886 end_call(pauline, marie);
3887 end:
3888 linphone_call_params_unref(params);
3889 linphone_core_manager_destroy(marie);
3890 linphone_core_manager_destroy(pauline);
3891 }
3892
incoming_invite_with_invalid_sdp(void)3893 static void incoming_invite_with_invalid_sdp(void) {
3894 LinphoneCoreManager* caller = linphone_core_manager_new( "pauline_tcp_rc");
3895 LinphoneCoreManager* callee = linphone_core_manager_new( "marie_rc");
3896 LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0};
3897 LinphoneCallLog *cl;
3898 const bctbx_list_t *logs;
3899
3900 callee_test_params.sdp_simulate_error = TRUE;
3901 BC_ASSERT_FALSE(call_with_params2(caller,callee,&caller_test_params, &callee_test_params, FALSE));
3902
3903 BC_ASSERT_PTR_NULL(linphone_core_get_current_call(callee->lc));
3904 BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallError,1, int, "%d");
3905 /*call will be drop before presented to the application, because it is invalid*/
3906 BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallIncomingReceived,0, int, "%d");
3907
3908 logs = linphone_core_get_call_logs(callee->lc);
3909 BC_ASSERT_EQUAL((int)bctbx_list_size(logs), 1, int, "%i");
3910 if (logs){
3911 const LinphoneErrorInfo *ei;
3912 cl = (LinphoneCallLog*)logs->data;
3913 BC_ASSERT_EQUAL(linphone_call_log_get_status(cl), LinphoneCallEarlyAborted, int, "%d");
3914 BC_ASSERT_TRUE(linphone_call_log_get_start_date(cl) != 0);
3915 ei = linphone_call_log_get_error_info(cl);
3916 BC_ASSERT_PTR_NOT_NULL(ei);
3917 if (ei){
3918 BC_ASSERT_EQUAL(linphone_error_info_get_reason(ei), LinphoneReasonNotAcceptable, int, "%d");
3919 }
3920 }
3921
3922 linphone_core_manager_destroy(callee);
3923 linphone_core_manager_destroy(caller);
3924 }
3925
outgoing_invite_with_invalid_sdp(void)3926 static void outgoing_invite_with_invalid_sdp(void) {
3927 LinphoneCoreManager* caller = linphone_core_manager_new( "pauline_tcp_rc");
3928 LinphoneCoreManager* callee = linphone_core_manager_new( "marie_rc");
3929 LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0};
3930
3931 caller_test_params.sdp_simulate_error = TRUE;
3932 BC_ASSERT_FALSE(call_with_params2(caller,callee,&caller_test_params, &callee_test_params, FALSE));
3933
3934 BC_ASSERT_PTR_NULL(linphone_core_get_current_call(callee->lc));
3935 BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallIncomingReceived,1, int, "%d");
3936 BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallError,1, int, "%d");
3937 // actually callee does not receive error, because it just get a BYE from the other part
3938 BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallError,0, int, "%d");
3939 BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallEnd,1, int, "%d");
3940
3941 linphone_core_manager_destroy(callee);
3942 linphone_core_manager_destroy(caller);
3943 }
3944
call_with_paused_no_sdp_on_resume(void)3945 static void call_with_paused_no_sdp_on_resume(void) {
3946 int dummy=0;
3947 LinphoneCoreManager* marie;
3948 LinphoneCoreManager* pauline;
3949 LinphoneCall* call_marie = NULL;
3950 LinphoneCallStats *stats;
3951 bool_t call_ok;
3952
3953 marie = linphone_core_manager_new( "marie_rc");
3954 pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
3955 BC_ASSERT_TRUE(call_ok=call(pauline,marie));
3956 if (!call_ok) goto end;
3957
3958 liblinphone_tester_check_rtcp(marie,pauline);
3959
3960 call_marie = linphone_core_get_current_call(marie->lc);
3961 BC_ASSERT_PTR_NOT_NULL(call_marie);
3962
3963 ms_message("== Call is OK ==");
3964
3965 /* the called party pause the call */
3966 wait_for_until(pauline->lc, marie->lc, NULL, 5, 3000);
3967
3968 linphone_call_pause(call_marie);
3969 ms_message("== Call pausing ==");
3970 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausing,1));
3971 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,1));
3972 BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPaused,1));
3973
3974 /*stay in pause a little while in order to generate traffic*/
3975 wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000);
3976
3977 ms_message("== Call paused, marie call: %p ==", call_marie);
3978
3979 linphone_core_enable_sdp_200_ack(marie->lc,TRUE);
3980
3981 linphone_call_resume(call_marie);
3982
3983 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
3984 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
3985
3986 wait_for_until(marie->lc, pauline->lc, &dummy, 1, 3000);
3987 BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(marie),70,int,"%i");
3988 stats = linphone_call_get_audio_stats(linphone_core_get_current_call(pauline->lc));
3989 BC_ASSERT_TRUE(stats->download_bandwidth>70);
3990 linphone_call_stats_unref(stats);
3991 end_call(marie,pauline);
3992 end:
3993
3994 linphone_core_manager_destroy(marie);
3995 linphone_core_manager_destroy(pauline);
3996 }
3997
early_media_without_sdp_in_200_base(bool_t use_video,bool_t use_ice)3998 void early_media_without_sdp_in_200_base( bool_t use_video, bool_t use_ice ){
3999 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
4000 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
4001 bctbx_list_t* lcs = NULL;
4002 LinphoneCall* marie_call;
4003 LinphoneCallParams* params = NULL;
4004 LinphoneCallLog *marie_call_log;
4005 uint64_t connected_time=0;
4006 uint64_t ended_time=0;
4007 int dummy=0;
4008
4009 lcs = bctbx_list_append(lcs,marie->lc);
4010 lcs = bctbx_list_append(lcs,pauline->lc);
4011 if (use_ice){
4012 linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce);
4013 /* We need RTP symmetric because ICE will put the STUN address in the C line, and no relay is made in this
4014 * scenario.*/
4015 lp_config_set_int(linphone_core_get_config(pauline->lc), "rtp", "symmetric", 1);
4016 }
4017 /*
4018 Marie calls Pauline, and after the call has rung, transitions to an early_media session
4019 */
4020 params = linphone_core_create_call_params(marie->lc, NULL);
4021
4022 if( use_video){
4023
4024 linphone_call_params_enable_video(params, TRUE);
4025
4026 linphone_core_enable_video_capture(pauline->lc, TRUE);
4027 linphone_core_enable_video_display(pauline->lc, TRUE);
4028 linphone_core_enable_video_capture(marie->lc, TRUE);
4029 linphone_core_enable_video_display(marie->lc, FALSE);
4030 }
4031
4032 marie_call = linphone_core_invite_address_with_params(marie->lc, pauline->identity, params);
4033 linphone_call_params_unref(params);
4034 marie_call_log = linphone_call_get_call_log(marie_call);
4035
4036 BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallIncomingReceived,1,3000));
4037 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallOutgoingRinging,1,1000));
4038
4039 if (linphone_core_inc_invite_pending(pauline->lc)) {
4040 LinphoneCall* pauline_call = linphone_core_get_current_call(pauline->lc);
4041
4042 /* send a 183 to initiate the early media */
4043 linphone_call_accept_early_media(pauline_call);
4044
4045 BC_ASSERT_TRUE( wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallIncomingEarlyMedia,1,2000) );
4046 BC_ASSERT_TRUE( wait_for_list(lcs, &marie->stat.number_of_LinphoneCallOutgoingEarlyMedia,1,2000) );
4047
4048 liblinphone_tester_check_rtcp(marie, pauline);
4049
4050 /* will send the 200OK _without_ SDP. We expect the early-media SDP to be used instead */
4051 sal_call_set_sdp_handling(pauline_call->op, SalOpSDPSimulateRemove);
4052 linphone_call_accept(pauline_call);
4053
4054 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallConnected, 1,1000));
4055 connected_time=ms_get_cur_time_ms();
4056 BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning, 1,3000));
4057
4058 BC_ASSERT_PTR_EQUAL(marie_call, linphone_core_get_current_call(marie->lc));
4059
4060 liblinphone_tester_check_rtcp(marie, pauline);
4061 /*just to have a call duration !=0*/
4062 wait_for_list(lcs,&dummy,1,2000);
4063
4064 end_call(pauline, marie);
4065 ended_time=ms_get_cur_time_ms();
4066 BC_ASSERT_LOWER(labs((long)((linphone_call_log_get_duration(marie_call_log)*1000) - (int64_t)(ended_time - connected_time))), 1000, long, "%ld");
4067 }
4068 bctbx_list_free(lcs);
4069 linphone_core_manager_destroy(marie);
4070 linphone_core_manager_destroy(pauline);
4071 }
4072
call_with_early_media_and_no_sdp_in_200(void)4073 static void call_with_early_media_and_no_sdp_in_200(void){
4074 early_media_without_sdp_in_200_base(FALSE, FALSE);
4075 }
4076
call_with_early_media_ice_and_no_sdp_in_200(void)4077 static void call_with_early_media_ice_and_no_sdp_in_200(void){
4078 early_media_without_sdp_in_200_base(FALSE, TRUE);
4079 }
4080
call_with_generic_cn(void)4081 static void call_with_generic_cn(void) {
4082 LinphoneCoreManager* marie;
4083 LinphoneCoreManager* pauline;
4084 LinphoneCall *pauline_call;
4085 char *audio_file_with_silence=bc_tester_res("sounds/ahbahouaismaisbon.wav");
4086 char *recorded_file=bc_tester_file("result.wav");
4087
4088 marie = linphone_core_manager_new( "marie_rc");
4089 pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
4090
4091 remove(recorded_file);
4092
4093 linphone_core_use_files(marie->lc,TRUE);
4094 linphone_core_use_files(pauline->lc,TRUE);
4095 linphone_core_set_play_file(marie->lc, audio_file_with_silence);
4096 /*linphone_core_set_play_file(pauline->lc, NULL);*/
4097 linphone_core_set_record_file(pauline->lc, recorded_file);
4098 linphone_core_enable_generic_comfort_noise(marie->lc, TRUE);
4099 linphone_core_enable_generic_comfort_noise(pauline->lc, TRUE);
4100 BC_ASSERT_TRUE(call(marie,pauline));
4101 pauline_call=linphone_core_get_current_call(pauline->lc);
4102 BC_ASSERT_PTR_NOT_NULL(pauline_call);
4103 if (pauline_call){
4104 const rtp_stats_t *rtps;
4105
4106 wait_for_until(marie->lc, pauline->lc, NULL, 0, 8000);
4107 rtps=rtp_session_get_stats(pauline_call->audiostream->ms.sessions.rtp_session);
4108 BC_ASSERT_TRUE(rtps->packet_recv<=300 && rtps->packet_recv>=200);
4109 }
4110 end_call(marie,pauline);
4111
4112 if (pauline_call){
4113 struct stat stbuf;
4114 int err;
4115
4116 err=stat(recorded_file,&stbuf);
4117 BC_ASSERT_EQUAL(err, 0, int, "%d");
4118 if (err==0){
4119 BC_ASSERT_GREATER(stbuf.st_size,120000,int, "%d");
4120 }
4121 }
4122
4123 linphone_core_manager_destroy(marie);
4124 linphone_core_manager_destroy(pauline);
4125
4126 ms_free(audio_file_with_silence);
4127 bc_free(recorded_file);
4128 }
4129
call_state_changed_2(LinphoneCore * lc,LinphoneCall * call,LinphoneCallState cstate,const char * msg)4130 static void call_state_changed_2(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg){
4131 LinphoneSipTransports sip_tr;
4132 if (cstate==LinphoneCallReleased) {
4133 /*to make sure transport is changed*/
4134 sip_tr.udp_port = 0;
4135 sip_tr.tcp_port = 45876;
4136 sip_tr.tls_port = 0;
4137
4138 linphone_core_set_sip_transports(lc,&sip_tr);
4139 }
4140 }
4141
call_state_changed_3(LinphoneCore * lc,LinphoneCall * call,LinphoneCallState cstate,const char * msg)4142 static void call_state_changed_3(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg){
4143 /*just to check multi listener in such situation*/
4144 char* to=linphone_address_as_string(linphone_call_get_call_log(call)->to);
4145 char* from=linphone_address_as_string(linphone_call_get_call_log(call)->from);
4146 ms_message("Third call listener reports: %s call from [%s] to [%s], new state is [%s]" ,linphone_call_get_call_log(call)->dir==LinphoneCallIncoming?"Incoming":"Outgoing"
4147 ,from
4148 ,to
4149 ,linphone_call_state_to_string(cstate));
4150 ms_free(to);
4151 ms_free(from);
4152 }
4153
call_with_transport_change_base(bool_t succesfull_call)4154 static void call_with_transport_change_base(bool_t succesfull_call) {
4155 LinphoneSipTransports sip_tr;
4156 LinphoneCoreManager* marie;
4157 LinphoneCoreManager* pauline;
4158 LinphoneCoreVTable * v_table;
4159 v_table = linphone_core_v_table_new();
4160 v_table->call_state_changed=call_state_changed_2;
4161 marie = linphone_core_manager_new("marie_rc");
4162 pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
4163 linphone_core_add_listener(marie->lc,v_table);
4164 v_table = linphone_core_v_table_new();
4165 v_table->call_state_changed=call_state_changed_3;
4166 linphone_core_add_listener(marie->lc,v_table);
4167
4168 sip_tr.udp_port = 0;
4169 sip_tr.tcp_port = 45875;
4170 sip_tr.tls_port = 0;
4171 linphone_core_set_sip_transports(marie->lc,&sip_tr);
4172 if (succesfull_call) {
4173 BC_ASSERT_TRUE(call(marie,pauline));
4174 end_call(marie, pauline);
4175 }
4176 else
4177 linphone_core_invite(marie->lc,"nexiste_pas");
4178
4179 if (succesfull_call)
4180 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallEnd,1));
4181 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallReleased,1));
4182 if (succesfull_call) {
4183 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
4184 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallReleased,1));
4185 }
4186 linphone_core_manager_destroy(marie);
4187 linphone_core_manager_destroy(pauline);
4188 }
call_with_transport_change_after_released(void)4189 static void call_with_transport_change_after_released(void) {
4190 call_with_transport_change_base(TRUE);
4191 }
unsucessfull_call_with_transport_change_after_released(void)4192 static void unsucessfull_call_with_transport_change_after_released(void) {
4193 call_with_transport_change_base(FALSE);
4194 }
4195
4196 #if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(__ANDROID__)
completion_cb(void * user_data,int percentage)4197 static void completion_cb(void *user_data, int percentage){
4198 fprintf(stdout,"%i %% completed\r",percentage);
4199 fflush(stdout);
4200 }
4201 #endif
4202
simple_stereo_call(const char * codec_name,int clock_rate,int bitrate_override,bool_t stereo)4203 static void simple_stereo_call(const char *codec_name, int clock_rate, int bitrate_override, bool_t stereo) {
4204 LinphoneCoreManager* marie;
4205 LinphoneCoreManager* pauline;
4206 PayloadType *pt;
4207 char *stereo_file = bc_tester_res("sounds/vrroom.wav");
4208 char *recordpath = bc_tester_file("stereo-record.wav");
4209 bool_t audio_cmp_failed = FALSE;
4210
4211 unlink(recordpath);
4212
4213 marie = linphone_core_manager_new( "marie_rc");
4214 pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
4215
4216 /*make sure we have opus*/
4217 pt = linphone_core_find_payload_type(marie->lc, codec_name, clock_rate, 2);
4218 if (!pt) {
4219 ms_warning("%s not available, stereo with %s not tested.",codec_name, codec_name);
4220 goto end;
4221 }
4222 if (stereo) payload_type_set_recv_fmtp(pt, "stereo=1;sprop-stereo=1");
4223 if (bitrate_override) linphone_core_set_payload_type_bitrate(marie->lc, pt, bitrate_override);
4224 pt = linphone_core_find_payload_type(pauline->lc, codec_name, clock_rate, 2);
4225 if (stereo) payload_type_set_recv_fmtp(pt, "stereo=1;sprop-stereo=1");
4226 if (bitrate_override) linphone_core_set_payload_type_bitrate(pauline->lc, pt, bitrate_override);
4227
4228 disable_all_audio_codecs_except_one(marie->lc, codec_name, clock_rate);
4229 disable_all_audio_codecs_except_one(pauline->lc, codec_name, clock_rate);
4230
4231 linphone_core_set_use_files(marie->lc, TRUE);
4232 linphone_core_set_play_file(marie->lc, stereo_file);
4233 linphone_core_set_use_files(pauline->lc, TRUE);
4234 linphone_core_set_record_file(pauline->lc, recordpath);
4235
4236 /*stereo is supported only without volume control, echo canceller...*/
4237 lp_config_set_string(marie->lc->config,"sound","features","REMOTE_PLAYING");
4238 lp_config_set_string(pauline->lc->config,"sound","features","REMOTE_PLAYING");
4239
4240 if (!BC_ASSERT_TRUE(call(pauline,marie))) goto end;
4241 wait_for_until(marie->lc, pauline->lc, NULL, 0, 6000);
4242 end_call(pauline, marie);
4243
4244
4245 if (clock_rate!=48000) {
4246 ms_warning("Similarity checking not implemented for files not having the same sampling rate");
4247 }else{
4248 #if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(__ANDROID__)
4249 double similar;
4250 double min_threshold = .75f; /*should be above 0.8 in best conditions*/
4251 double max_threshold = 1.f;
4252 if (!stereo){
4253 /*when opus doesn't transmit stereo, the cross correlation is around 0.6 : as expected, it is not as good as in full stereo mode*/
4254 min_threshold = .4f;
4255 max_threshold = .68f;
4256 }
4257 BC_ASSERT_EQUAL(ms_audio_diff(stereo_file, recordpath,&similar,&audio_cmp_params,completion_cb,NULL), 0, int, "%d");
4258 BC_ASSERT_GREATER(similar, min_threshold, double, "%g");
4259 BC_ASSERT_LOWER(similar, max_threshold, double, "%g");
4260 if (similar<min_threshold || similar>max_threshold){
4261 audio_cmp_failed = TRUE;
4262 }
4263 #endif
4264 }
4265 if (!audio_cmp_failed) unlink(recordpath);
4266 end:
4267 linphone_core_manager_destroy(marie);
4268 linphone_core_manager_destroy(pauline);
4269 ms_free(stereo_file);
4270 bc_free(recordpath);
4271 }
4272
simple_stereo_call_l16(void)4273 static void simple_stereo_call_l16(void){
4274 simple_stereo_call("L16", 44100, 0, TRUE);
4275 }
4276
simple_stereo_call_opus(void)4277 static void simple_stereo_call_opus(void){
4278 simple_stereo_call("opus", 48000, 150, TRUE);
4279 }
4280
call_with_complex_late_offering(void)4281 static void call_with_complex_late_offering(void){
4282 LinphoneCallParams *params;
4283 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
4284 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
4285 LinphoneCall* call_pauline;
4286 LinphoneCall* call_marie;
4287 LinphoneVideoPolicy vpol;
4288 bool_t call_ok;
4289
4290 vpol.automatically_initiate = vpol.automatically_accept = TRUE;
4291 linphone_core_enable_video_capture(pauline->lc, TRUE);
4292 linphone_core_enable_video_display(pauline->lc, TRUE);
4293 linphone_core_enable_video_capture(marie->lc, TRUE);
4294 linphone_core_enable_video_display(marie->lc, TRUE);
4295 linphone_core_set_video_policy(pauline->lc, &vpol);
4296 linphone_core_set_video_policy(marie->lc, &vpol);
4297
4298 // important: VP8 has really poor performances with the mire camera, at least
4299 // on iOS - so when ever h264 is available, let's use it instead
4300 if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) {
4301 disable_all_video_codecs_except_one(pauline->lc,"h264");
4302 disable_all_video_codecs_except_one(marie->lc,"h264");
4303 }
4304
4305 linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id);
4306 linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id);
4307
4308 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
4309 if (!call_ok) goto end;
4310
4311 call_pauline = linphone_core_get_current_call(pauline->lc);
4312 call_marie = linphone_core_get_current_call(marie->lc);
4313
4314 //Invite inactive Audio/video (Marie pause Pauline)
4315 ms_message("CONTEXT: Marie sends INVITE with SDP with all streams inactive");
4316 params=linphone_core_create_call_params(marie->lc,call_marie);
4317 linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionInactive);
4318 linphone_call_params_set_video_direction(params,LinphoneMediaDirectionInactive);
4319
4320 linphone_call_update(call_marie ,params);
4321 linphone_call_params_unref(params);
4322
4323 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdating,1));
4324 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,1));
4325 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
4326
4327 //Marie sends INVITE without SDP
4328 ms_message("CONTEXT: Marie sends INVITE without SDP for setting streams in send-only mode");
4329 linphone_core_enable_sdp_200_ack(marie->lc,TRUE);
4330 params=linphone_core_create_call_params(marie->lc,call_marie);
4331 linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendOnly);
4332 linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendOnly);
4333 linphone_call_update(call_marie , params);
4334 linphone_call_params_unref(params);
4335
4336 //Pauline OK with sendonly
4337 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdating,2));
4338 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3));
4339 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,2));
4340
4341 linphone_core_enable_sdp_200_ack(marie->lc,FALSE);
4342
4343 //Pauline pause Marie
4344 ms_message("CONTEXT: Pauline pauses the call");
4345 linphone_call_pause(call_pauline);
4346 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPausing,1));
4347 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPaused,1));
4348 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1));
4349
4350 //Pauline resume Marie
4351 ms_message("CONTEXT: Pauline resumes the call");
4352 wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000);
4353 linphone_call_resume(call_pauline);
4354 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,4));
4355 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallResuming,1));
4356 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,3));
4357
4358 wait_for_until(pauline->lc, marie->lc, NULL, 0, 2000);
4359
4360 //Marie invite inactive Audio/Video
4361 ms_message("CONTEXT: Marie sends INVITE with SDP with all streams inactive");
4362 params=linphone_core_create_call_params(marie->lc,call_marie);
4363 linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionInactive);
4364 linphone_call_params_set_video_direction(params,LinphoneMediaDirectionInactive);
4365
4366 linphone_call_update(call_marie,params);
4367 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdating,3));
4368 linphone_call_params_unref(params);
4369
4370 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,4));
4371 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,5));
4372
4373 //Marie sends INVITE without SDP
4374 ms_message("CONTEXT: Marie sends INVITE without SDP in the purpose of re-enabling streams in sendrecv mode");
4375 linphone_core_enable_sdp_200_ack(marie->lc,TRUE);
4376 params=linphone_core_create_call_params(marie->lc,call_marie);
4377 linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendRecv);
4378 linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendRecv);
4379 linphone_call_update(call_marie,params);
4380 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdating,3));
4381 linphone_call_params_unref(params);
4382 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallUpdatedByRemote,1));
4383 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
4384 BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,5));
4385
4386 linphone_core_enable_sdp_200_ack(marie->lc,FALSE);
4387
4388 end_call(marie,pauline);
4389
4390 end:
4391
4392 linphone_core_manager_destroy(marie);
4393 linphone_core_manager_destroy(pauline);
4394 }
4395
simple_mono_call_opus(void)4396 static void simple_mono_call_opus(void){
4397 /*actually a call where input/output is made with stereo but opus transmits everything as mono*/
4398 simple_stereo_call("opus", 48000, 150, FALSE);
4399 }
4400
4401 /* because SIP ALG (like in android phones) crash when seing a domain name in SDP, we prefer using SIP/TLS for both participants*/
call_with_fqdn_in_sdp(void)4402 static void call_with_fqdn_in_sdp(void) {
4403 bool_t tls_supported = transport_supported(LinphoneTransportTls);
4404 LinphoneCoreManager* marie = linphone_core_manager_new(tls_supported ? "marie_sips_rc" : "marie_rc");
4405 LinphoneCoreManager* pauline = linphone_core_manager_new(tls_supported ? "pauline_rc" : "pauline_tcp_rc");
4406 LpConfig *lp;
4407 bool_t call_ok;
4408
4409 lp = linphone_core_get_config(marie->lc);
4410 lp_config_set_string(lp,"rtp","bind_address","localhost");
4411 lp = linphone_core_get_config(pauline->lc);
4412 lp_config_set_string(lp,"rtp","bind_address","localhost");
4413
4414 BC_ASSERT_TRUE(call_ok=call(marie,pauline));
4415 if (!call_ok) goto end;
4416 liblinphone_tester_check_rtcp(pauline,marie);
4417
4418 #ifdef VIDEO_ENABLED
4419 BC_ASSERT_TRUE(request_video(pauline,marie, TRUE));
4420 liblinphone_tester_check_rtcp(pauline,marie);
4421 #endif
4422 end_call(pauline, marie);
4423 end:
4424 linphone_core_manager_destroy(marie);
4425 linphone_core_manager_destroy(pauline);
4426 }
4427
call_with_rtp_io_mode(void)4428 static void call_with_rtp_io_mode(void) {
4429 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
4430 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
4431 LinphonePlayer *player;
4432 char *hellopath = bc_tester_res("sounds/ahbahouaismaisbon.wav");
4433 char *recordpath = bc_tester_file("record-call_with_rtp_io_mode.wav");
4434 bool_t call_ok;
4435 int attempts;
4436 double similar=1;
4437 const double threshold = 0.85;
4438
4439 /*this test is actually attempted three times in case of failure, because the audio comparison at the end is very sensitive to
4440 * jitter buffer drifts, which sometimes happen if the machine is unable to run the test in good realtime conditions */
4441 for (attempts=0; attempts<3; attempts++){
4442 /* Make sure that the record file doesn't already exists, otherwise this test will append new samples to it. */
4443 unlink(recordpath);
4444 reset_counters(&marie->stat);
4445 reset_counters(&pauline->stat);
4446
4447 /* The caller uses files instead of soundcard in order to avoid mixing soundcard input with file played using call's player. */
4448 linphone_core_use_files(marie->lc, TRUE);
4449 linphone_core_set_play_file(marie->lc, NULL);
4450 linphone_core_set_record_file(marie->lc, recordpath);
4451 linphone_core_use_files(pauline->lc, FALSE);
4452
4453 /* The callee uses the RTP IO mode with the PCMU codec to send back audio to the caller. */
4454 disable_all_audio_codecs_except_one(pauline->lc, "pcmu", -1);
4455 lp_config_set_int(pauline->lc->config, "sound", "rtp_io", 1);
4456 lp_config_set_string(pauline->lc->config, "sound", "rtp_local_addr", linphone_core_ipv6_enabled(pauline->lc) ? "::1" : "127.0.0.1");
4457 lp_config_set_string(pauline->lc->config, "sound", "rtp_remote_addr", linphone_core_ipv6_enabled(pauline->lc) ? "::1" : "127.0.0.1");
4458 lp_config_set_int(pauline->lc->config, "sound", "rtp_local_port", 17076);
4459 lp_config_set_int(pauline->lc->config, "sound", "rtp_remote_port", 17076);
4460 lp_config_set_string(pauline->lc->config, "sound", "rtp_map", "pcmu/8000/1");
4461
4462 BC_ASSERT_TRUE((call_ok = call(marie, pauline)));
4463 if (!call_ok) goto end;
4464 player = linphone_call_get_player(linphone_core_get_current_call(marie->lc));
4465 BC_ASSERT_PTR_NOT_NULL(player);
4466 if (player) {
4467 LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player);
4468 linphone_player_cbs_set_eof_reached(cbs, on_eof);
4469 linphone_player_cbs_set_user_data(cbs, marie);
4470 BC_ASSERT_EQUAL(linphone_player_open(player, hellopath) , 0, int, "%d");
4471 BC_ASSERT_EQUAL(linphone_player_start(player) , 0, int, "%d");
4472 }
4473
4474 /* This assert should be modified to be at least as long as the WAV file */
4475 BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_player_eof, 1, 10000));
4476 /*wait for one second more so that last RTP packets can arrive*/
4477 wait_for_until(pauline->lc,marie->lc,NULL,0,1000);
4478 end_call(pauline,marie);
4479
4480 BC_ASSERT_EQUAL(ms_audio_diff(hellopath, recordpath, &similar, &audio_cmp_params, NULL, NULL), 0, int, "%d");
4481 if (similar>=threshold) break;
4482 }
4483 BC_ASSERT_GREATER(similar, threshold, double, "%g");
4484 BC_ASSERT_LOWER(similar, 1.0, double, "%g");
4485 if (similar >= threshold && similar <= 1.0) {
4486 remove(recordpath);
4487 }
4488
4489 end:
4490 linphone_core_manager_destroy(marie);
4491 linphone_core_manager_destroy(pauline);
4492 ms_free(recordpath);
4493 ms_free(hellopath);
4494 }
4495
generic_nack_received(const OrtpEventData * evd,stats * st)4496 static void generic_nack_received(const OrtpEventData *evd, stats *st) {
4497 if (rtcp_is_RTPFB(evd->packet)) {
4498 switch (rtcp_RTPFB_get_type(evd->packet)) {
4499 case RTCP_RTPFB_NACK:
4500 st->number_of_rtcp_generic_nack++;
4501 break;
4502 default:
4503 break;
4504 }
4505 }
4506 }
4507
call_with_generic_nack_rtcp_feedback(void)4508 static void call_with_generic_nack_rtcp_feedback(void) {
4509 LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
4510 LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
4511 LpConfig *lp;
4512 LinphoneCall *call_marie;
4513 bool_t call_ok;
4514 OrtpNetworkSimulatorParams params = { 0 };
4515
4516 params.enabled = TRUE;
4517 params.loss_rate = 10;
4518 params.consecutive_loss_probability = 0.75;
4519 params.mode = OrtpNetworkSimulatorOutbound;
4520 linphone_core_set_avpf_mode(marie->lc, LinphoneAVPFEnabled);
4521 linphone_core_set_avpf_mode(pauline->lc, LinphoneAVPFEnabled);
4522 lp = linphone_core_get_config(pauline->lc);
4523 lp_config_set_int(lp, "rtp", "rtcp_fb_generic_nack_enabled", 1);
4524
4525
4526 BC_ASSERT_TRUE(call_ok = call(pauline, marie));
4527 if (!call_ok) goto end;
4528 BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1));
4529 BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1));
4530 call_marie = linphone_core_get_current_call(marie->lc);
4531 if (call_marie) {
4532 rtp_session_enable_network_simulation(call_marie->audiostream->ms.sessions.rtp_session, ¶ms);
4533 ortp_ev_dispatcher_connect(media_stream_get_event_dispatcher(&call_marie->audiostream->ms),
4534 ORTP_EVENT_RTCP_PACKET_RECEIVED, RTCP_RTPFB, (OrtpEvDispatcherCb)generic_nack_received, &marie->stat);
4535 }
4536
4537 BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_rtcp_generic_nack, 5, 8000));
4538 end_call(pauline, marie);
4539
4540 end:
4541 linphone_core_manager_destroy(marie);
4542 linphone_core_manager_destroy(pauline);
4543 }
4544
4545 // This is a custom structure used for the tests using custom RTP transport modifier.
4546 // It is only used to count the number of sent and received packets
4547 typedef struct _RtpTransportModifierData {
4548 uint64_t packetSentCount;
4549 uint64_t packetReceivedCount;
4550 MSQueue to_send;
4551 MSQueue to_recv;
4552 } RtpTransportModifierData;
4553
4554 const char *XOR_KEY = "BELLEDONNECOMMUNICATIONS";
4555
4556 // Callback called when a packet is on it's way to be sent
4557 // This is where we can do some changes on it, like encrypt it
rtptm_on_send(RtpTransportModifier * rtptm,mblk_t * msg)4558 static int rtptm_on_send(RtpTransportModifier *rtptm, mblk_t *msg) {
4559 RtpTransportModifierData *data = rtptm->data;
4560 rtp_header_t *rtp = (rtp_header_t*)msg->b_rptr;
4561
4562 if (rtp->version == 0) {
4563 // This is probably a STUN packet, so don't count it (oRTP won't) and don't encrypt it either
4564 return (int)msgdsize(msg);
4565 }
4566 /*ms_message("rtptm_on_send: rtpm=%p seq=%u", rtptm, (int)ntohs(rtp_get_seqnumber(msg)));*/
4567
4568 data->packetSentCount += 1;
4569 ms_queue_put(&data->to_send, dupmsg(msg));
4570 return 0; // Return 0 to drop the packet, it will be injected later
4571 }
4572
4573 // Callback called when a packet is on it's way to be received
4574 // This is where we can do some changes on it, like decrypt it
rtptm_on_receive(RtpTransportModifier * rtptm,mblk_t * msg)4575 static int rtptm_on_receive(RtpTransportModifier *rtptm, mblk_t *msg) {
4576 RtpTransportModifierData *data = rtptm->data;
4577 rtp_header_t *rtp = (rtp_header_t*)msg->b_rptr;
4578
4579 if (rtp->version == 0) {
4580 // This is probably a STUN packet, so don't count it (oRTP won't) and don't decrypt it either
4581 return (int)msgdsize(msg);
4582 }
4583
4584 data->packetReceivedCount += 1;
4585 ms_queue_put(&data->to_recv, dupmsg(msg));
4586 return 0; // Return 0 to drop the packet, it will be injected later
4587 }
4588
rtptm_on_schedule(RtpTransportModifier * rtptm)4589 static void rtptm_on_schedule(RtpTransportModifier *rtptm) {
4590 RtpTransportModifierData *data = rtptm->data;
4591 mblk_t *msg = NULL;
4592
4593 while ((msg = ms_queue_get(&data->to_send)) != NULL) {
4594 int size = 0;
4595 unsigned char *src;
4596 int i = 0;
4597
4598 // Mediastream can create a mblk_t with only the RTP header and setting the b_cont pointer to the actual RTP content buffer
4599 // In this scenario, the result of rtp_get_payload will be 0, and we won't be able to do our XOR encryption on the payload
4600 // The call to msgpullup will trigger a memcpy of the header and the payload in the same buffer in the msg mblk_t
4601 msgpullup(msg, -1);
4602 // Now that the mblk_t buffer directly contains the header and the payload, we can get the size of the payload and a pointer to it's start (we don't encrypt the RTP header)
4603 size = rtp_get_payload(msg, &src);
4604
4605 // Just for fun, let's do a XOR encryption
4606 for (i = 0; i < size; i++) {
4607 src[i] ^= (unsigned char) XOR_KEY[i % strlen(XOR_KEY)];
4608 }
4609
4610 meta_rtp_transport_modifier_inject_packet_to_send(rtptm->transport, rtptm, msg, 0);
4611 }
4612
4613 msg = NULL;
4614 while ((msg = ms_queue_get(&data->to_recv)) != NULL) {
4615 int size = 0;
4616 unsigned char *src;
4617 int i = 0;
4618
4619 // On the receiving side, there is no need for a msgpullup, the mblk_t contains the header and the payload in the same buffer
4620 // We just ask for the size and a pointer to the payload buffer
4621 size = rtp_get_payload(msg, &src);
4622
4623 // Since we did a XOR encryption on the send side, we have to do it again to decrypt the payload
4624 for (i = 0; i < size; i++) {
4625 src[i] ^= (unsigned char) XOR_KEY[i % strlen(XOR_KEY)];
4626 }
4627
4628 meta_rtp_transport_modifier_inject_packet_to_recv(rtptm->transport, rtptm, msg, 0);
4629 }
4630 }
4631
4632 // This callback is called when the transport modifier is being destroyed
4633 // It is a good place to free the resources allocated for the transport modifier
rtptm_destroy(RtpTransportModifier * rtptm)4634 static void rtptm_destroy(RtpTransportModifier *rtptm) {
4635 // Do nothing, we'll free it later because we need to access the RtpTransportModifierData structure after the call is ended
4636 }
4637
4638 // This is the callback called when the state of the call change
call_state_changed_4(LinphoneCore * lc,LinphoneCall * call,LinphoneCallState cstate,const char * msg)4639 static void call_state_changed_4(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg) {
4640 int i = 0;
4641
4642 // To add a custom RTP transport modifier, we have to do it before the call is running, but after the RTP session is created.
4643 if (cstate == LinphoneCallIncomingReceived || cstate == LinphoneCallOutgoingProgress) {
4644 RtpTransport *rtpt = NULL;
4645 RtpTransportModifierData *data = ms_new0(RtpTransportModifierData, 1);
4646 RtpTransportModifier *rtptm = ms_new0(RtpTransportModifier, 1);
4647 ms_queue_init(&data->to_send);
4648 ms_queue_init(&data->to_recv);
4649 rtptm->data = data;
4650 rtptm->t_process_on_send = rtptm_on_send;
4651 rtptm->t_process_on_receive = rtptm_on_receive;
4652 rtptm->t_process_on_schedule = rtptm_on_schedule;
4653 rtptm->t_destroy = rtptm_destroy;
4654
4655 // Here we iterate on each meta rtp transport available
4656 for (i = 0; i < linphone_call_get_stream_count(call); i++) {
4657 MSFormatType type;
4658
4659 rtpt = linphone_call_get_meta_rtp_transport(call, i);
4660
4661 // If we wanted, we also could get the RTCP meta transports like this:
4662 // rtcpt = linphone_call_get_meta_rtcp_transport(call, i);
4663
4664 // If you want to know which stream meta RTP transport is the current one, you can use
4665 type = linphone_call_get_stream_type(call, i);
4666 // Currently there is only MSAudio and MSVideo types, but this could change later
4667 if (type == MSAudio) {
4668 // And now we append our RTP transport modifier to the current list of modifiers
4669 meta_rtp_transport_append_modifier(rtpt, rtptm);
4670 } else if (type == MSVideo) {
4671 // Because the call of this test is audio only, we don't have to append our modifier to the meta RTP transport from the video stream
4672 }
4673 }
4674 // We save the pointer to our RtpTransportModifier in the call user_data to be able to get to it later
4675 call->user_data = rtptm;
4676 }
4677 }
4678
custom_rtp_modifier(bool_t pauseResumeTest,bool_t recordTest)4679 static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) {
4680 // This will initialize two linphone core using information contained in the marie_rc and pauline_rc files and wait for them to be correctly registered
4681 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
4682 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
4683 LinphoneCall* call_pauline = NULL;
4684 LinphoneCall* call_marie = NULL;
4685 const rtp_stats_t * stats;
4686 bool_t call_ok;
4687 LinphoneCoreVTable * v_table;
4688 RtpTransportModifier *rtptm_marie = NULL;
4689 RtpTransportModifier *rtptm_pauline = NULL;
4690 RtpTransportModifierData *data_marie = NULL;
4691 RtpTransportModifierData *data_pauline = NULL;
4692 // The following are only used for the record test
4693 LinphonePlayer *player;
4694 char *hellopath = bc_tester_res("sounds/ahbahouaismaisbon.wav"); // File to be played
4695 char *recordpath = bc_tester_file("record-call_with_file_player.wav"); // File to record the received sound
4696 double similar = 1; // The factor of similarity between the played file and the one recorded
4697 const double threshold = 0.85; // Minimum similarity value to consider the record file equal to the one sent
4698
4699 // We create a new vtable to listen only to the call state changes, in order to plug our RTP Transport Modifier when the call will be established
4700 v_table = linphone_core_v_table_new();
4701 v_table->call_state_changed = call_state_changed_4;
4702 linphone_core_add_listener(pauline->lc,v_table);
4703 v_table = linphone_core_v_table_new();
4704 v_table->call_state_changed = call_state_changed_4;
4705 linphone_core_add_listener(marie->lc,v_table);
4706
4707
4708 if (recordTest) { // When we do the record test, we need a file player to play the content of a sound file
4709 /*make sure the record file doesn't already exists, otherwise this test will append new samples to it*/
4710 unlink(recordpath);
4711
4712 linphone_core_use_files(pauline->lc,TRUE);
4713 linphone_core_set_play_file(pauline->lc,NULL);
4714 linphone_core_set_record_file(pauline->lc,NULL);
4715
4716 /*callee is recording and plays file*/
4717 linphone_core_use_files(marie->lc,TRUE);
4718 linphone_core_set_play_file(marie->lc,NULL);
4719 linphone_core_set_record_file(marie->lc,recordpath);
4720 }
4721
4722 // Now the the call should be running (call state StreamsRunning)
4723 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
4724
4725 if (!call_ok) goto end;
4726
4727 // Ref the call to keep the pointer valid even after the call is release
4728 call_pauline = linphone_call_ref(linphone_core_get_current_call(pauline->lc));
4729 call_marie = linphone_call_ref(linphone_core_get_current_call(marie->lc));
4730
4731 // This is for the pause/resume test, we don't do it in the call record test to be able to check the recorded call matches the file played
4732 if (pauseResumeTest) {
4733 // This only wait for 3 seconds in order to generate traffic for the test
4734 wait_for_until(pauline->lc, marie->lc, NULL, 5, 3000);
4735
4736 linphone_call_pause(call_pauline);
4737 BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallPausing, 1));
4738 BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallPausedByRemote, 1));
4739 BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallPaused, 1));
4740
4741 /*stay in pause a little while in order to generate traffic*/
4742 wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000);
4743
4744 linphone_call_resume(call_pauline);
4745
4746 BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2));
4747 BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2));
4748
4749 /*same here: wait a while for a bit of a traffic, we need to receive a RTCP packet*/
4750 wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000);
4751
4752 /*since RTCP streams are reset when call is paused/resumed, there should be no loss at all*/
4753 stats = rtp_session_get_stats(call_pauline->sessions->rtp_session);
4754 BC_ASSERT_EQUAL((int)stats->cum_packet_loss, 0, int, "%d");
4755
4756 end_call(pauline, marie);
4757 } else if (recordTest) {
4758 player = linphone_call_get_player(call_pauline);
4759 BC_ASSERT_PTR_NOT_NULL(player);
4760 if (player) {
4761 // This will ask pauline to play the file
4762 LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player);
4763 linphone_player_cbs_set_eof_reached(cbs, on_eof);
4764 linphone_player_cbs_set_user_data(cbs, pauline);
4765 BC_ASSERT_EQUAL(linphone_player_open(player, hellopath),0, int, "%d");
4766 BC_ASSERT_EQUAL(linphone_player_start(player), 0, int, "%d");
4767 }
4768 /* This assert should be modified to be at least as long as the WAV file */
4769 BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_player_eof, 1, 10000));
4770 /*wait one second more for transmission to be fully ended (transmission time + jitter buffer)*/
4771 wait_for_until(pauline->lc, marie->lc, NULL, 0, 1000);
4772
4773 end_call(pauline, marie);
4774
4775 // Now we compute a similarity factor between the original file and the one we recorded on the callee side
4776 BC_ASSERT_EQUAL(ms_audio_diff(hellopath, recordpath, &similar, &audio_cmp_params, NULL, NULL), 0, int, "%d");
4777
4778 BC_ASSERT_GREATER(similar, threshold, double, "%g");
4779 BC_ASSERT_LOWER(similar, 1.0, double, "%g");
4780 if (similar >= threshold && similar <= 1.0) {
4781 // If the similarity value is between perfect (1) and our threshold (0.9), then we delete the file used for the record
4782 remove(recordpath);
4783 }
4784 } else {
4785 // This only wait for 3 seconds in order to generate traffic for the test
4786 wait_for_until(pauline->lc, marie->lc, NULL, 5, 3000);
4787
4788 // We termine the call and check the stats to see if the call is correctly ended on both sides
4789 end_call(pauline, marie);
4790 }
4791
4792 // Now we can go fetch our custom structure and check the number of packets sent/received is the same on both sides
4793 rtptm_marie = (RtpTransportModifier *)call_marie->user_data;
4794 rtptm_pauline = (RtpTransportModifier *)call_pauline->user_data;
4795 data_marie = (RtpTransportModifierData *)rtptm_marie->data;
4796 data_pauline = (RtpTransportModifierData *)rtptm_pauline->data;
4797
4798 BC_ASSERT_PTR_NOT_NULL(data_marie);
4799 BC_ASSERT_PTR_NOT_NULL(data_pauline);
4800 ms_message("Marie sent %i RTP packets and received %i (through our modifier)", (int)data_marie->packetSentCount, (int)data_marie->packetReceivedCount);
4801 ms_message("Pauline sent %i RTP packets and received %i (through our modifier)", (int)data_pauline->packetSentCount, (int)data_pauline->packetReceivedCount);
4802 // There will be a few RTP packets sent on marie's side before the call is ended at pauline's request, so we need the threshold
4803 BC_ASSERT_TRUE(data_marie->packetSentCount - data_pauline->packetReceivedCount < 50);
4804 BC_ASSERT_TRUE(data_pauline->packetSentCount - data_marie->packetReceivedCount < 50);
4805 // At this point, we know each packet that has been processed in the send callback of our RTP modifier also go through the recv callback of the remote.
4806
4807 // Now we want to ensure that all sent RTP packets actually go through our RTP transport modifier and thus no packet leave without being processed (by any operation we might want to do on it)
4808 {
4809 LinphoneCallStats *marie_stats = linphone_call_get_audio_stats(call_marie);
4810 LinphoneCallStats *pauline_stats = linphone_call_get_audio_stats(call_pauline);
4811 rtp_stats_t marie_rtp_stats = *linphone_call_stats_get_rtp_stats(marie_stats);
4812 rtp_stats_t pauline_rtp_stats = *linphone_call_stats_get_rtp_stats(pauline_stats);
4813 ms_message("Marie sent %i RTP packets and received %i (for real)", (int)marie_rtp_stats.packet_sent, (int)marie_rtp_stats.packet_recv);
4814 ms_message("Pauline sent %i RTP packets and received %i (for real)", (int)pauline_rtp_stats.packet_sent, (int)pauline_rtp_stats.packet_recv);
4815 BC_ASSERT_EQUAL(data_marie->packetReceivedCount, marie_rtp_stats.packet_recv, unsigned long long, "%llu");
4816 BC_ASSERT_EQUAL(data_marie->packetSentCount, marie_rtp_stats.packet_sent, unsigned long long, "%llu");
4817 // There can be a small difference between the number of packets received in the modifier and the number processed in reception because the processing is asynchronous
4818 BC_ASSERT_TRUE(data_pauline->packetReceivedCount - pauline_rtp_stats.packet_recv < 20);
4819 BC_ASSERT_TRUE(data_pauline->packetSentCount == pauline_rtp_stats.packet_sent);
4820 linphone_call_stats_unref(marie_stats);
4821 linphone_call_stats_unref(pauline_stats);
4822 }
4823
4824 end:
4825 // Since we didn't free the resources of our RTP transport modifier in the rtptm_destroy callback, we'll do it here
4826 if (data_pauline) {
4827 ms_free(data_pauline);
4828 }
4829 ms_free(rtptm_pauline);
4830 if (data_marie) {
4831 ms_free(data_marie);
4832 }
4833 ms_free(rtptm_marie);
4834
4835 // Unref the previously ref calls
4836 if (call_marie) {
4837 linphone_call_unref(call_marie);
4838 }
4839 if (call_pauline) {
4840 linphone_call_unref(call_pauline);
4841 }
4842
4843 // The test is finished, the linphone core are no longer needed, we can safely free them
4844 linphone_core_manager_destroy(marie);
4845 linphone_core_manager_destroy(pauline);
4846
4847 bc_free(recordpath);
4848 bc_free(hellopath);
4849 }
4850
call_with_custom_rtp_modifier(void)4851 static void call_with_custom_rtp_modifier(void) {
4852 custom_rtp_modifier(FALSE, FALSE);
4853 }
4854
call_paused_resumed_with_custom_rtp_modifier(void)4855 static void call_paused_resumed_with_custom_rtp_modifier(void) {
4856 custom_rtp_modifier(TRUE, FALSE);
4857 }
4858
call_record_with_custom_rtp_modifier(void)4859 static void call_record_with_custom_rtp_modifier(void) {
4860 custom_rtp_modifier(FALSE, TRUE);
4861 }
4862
recovered_call_on_network_switch_in_early_state(LinphoneCoreManager * callerMgr)4863 static void recovered_call_on_network_switch_in_early_state(LinphoneCoreManager* callerMgr) {
4864 const LinphoneCallParams *remote_params;
4865 LinphoneCall *incoming_call;
4866
4867 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
4868
4869 linphone_core_invite_address(callerMgr->lc, pauline->identity);
4870 if (!BC_ASSERT_TRUE(wait_for(callerMgr->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingReceived, 1))) goto end;
4871 if (!BC_ASSERT_TRUE(wait_for(callerMgr->lc, pauline->lc, &callerMgr->stat.number_of_LinphoneCallOutgoingRinging, 1))) goto end;
4872
4873 linphone_core_set_network_reachable(callerMgr->lc, FALSE);
4874 wait_for(callerMgr->lc, pauline->lc, &callerMgr->stat.number_of_NetworkReachableFalse, 1);
4875 linphone_core_set_network_reachable(callerMgr->lc, TRUE);
4876 wait_for(callerMgr->lc, pauline->lc, &callerMgr->stat.number_of_NetworkReachableTrue, 2);
4877
4878 BC_ASSERT_TRUE(wait_for(callerMgr->lc, pauline->lc, &callerMgr->stat.number_of_LinphoneCallOutgoingRinging, 2));
4879 incoming_call = linphone_core_get_current_call(pauline->lc);
4880 remote_params = linphone_call_get_remote_params(incoming_call);
4881 BC_ASSERT_PTR_NOT_NULL(remote_params);
4882 if (remote_params != NULL) {
4883 const char *replaces_header = linphone_call_params_get_custom_header(remote_params, "Replaces");
4884 BC_ASSERT_PTR_NOT_NULL(replaces_header);
4885 }
4886 linphone_call_accept(incoming_call);
4887 BC_ASSERT_TRUE(wait_for(callerMgr->lc, pauline->lc, &callerMgr->stat.number_of_LinphoneCallStreamsRunning, 1));
4888 BC_ASSERT_TRUE(wait_for(callerMgr->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1));
4889
4890 linphone_call_terminate(incoming_call);
4891 BC_ASSERT_TRUE(wait_for(callerMgr->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallEnd, 1));
4892 BC_ASSERT_TRUE(wait_for(callerMgr->lc, pauline->lc, &callerMgr->stat.number_of_LinphoneCallReleased, 1));
4893 BC_ASSERT_TRUE(wait_for(callerMgr->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallReleased, 1));
4894 end:
4895
4896 linphone_core_manager_destroy(pauline);
4897 }
recovered_call_on_network_switch_in_early_state_1(void)4898 static void recovered_call_on_network_switch_in_early_state_1(void) {
4899 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
4900 recovered_call_on_network_switch_in_early_state(marie);
4901 linphone_core_manager_destroy(marie);
4902 }
recovered_call_on_network_switch_in_early_state_1_udp(void)4903 static void recovered_call_on_network_switch_in_early_state_1_udp(void) {
4904 LinphoneCoreManager* laure = linphone_core_manager_new("laure_rc_udp");
4905 recovered_call_on_network_switch_in_early_state(laure);
4906 linphone_core_manager_destroy(laure);
4907 }
recovered_call_on_network_switch_in_early_state_2(void)4908 static void recovered_call_on_network_switch_in_early_state_2(void) {
4909 LinphoneCall *incoming_call;
4910 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
4911 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
4912
4913 linphone_core_invite_address(marie->lc, pauline->identity);
4914 if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingReceived, 1))) goto end;
4915 if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingRinging, 1))) goto end;
4916
4917 incoming_call = linphone_core_get_current_call(pauline->lc);
4918 linphone_call_accept(incoming_call);
4919 linphone_core_set_network_reachable(marie->lc, FALSE);
4920 wait_for(marie->lc, pauline->lc, &marie->stat.number_of_NetworkReachableFalse, 1);
4921 linphone_core_set_network_reachable(marie->lc, TRUE);
4922 wait_for(marie->lc, pauline->lc, &marie->stat.number_of_NetworkReachableTrue, 2);
4923
4924 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1));
4925 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1));
4926
4927 linphone_call_terminate(incoming_call);
4928 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallEnd, 1));
4929 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallReleased, 1));
4930 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallReleased, 1));
4931 end:
4932 linphone_core_manager_destroy(marie);
4933 linphone_core_manager_destroy(pauline);
4934 }
4935
recovered_call_on_network_switch_in_early_state_3(void)4936 static void recovered_call_on_network_switch_in_early_state_3(void) {
4937 LinphoneCall *incoming_call;
4938 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
4939 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
4940
4941 linphone_core_invite_address(marie->lc, pauline->identity);
4942 if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingReceived, 1))) goto end;
4943 if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingRinging, 1))) goto end;
4944
4945 linphone_core_set_network_reachable(pauline->lc, FALSE);
4946 wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_NetworkReachableFalse, 1);
4947 linphone_core_set_network_reachable(pauline->lc, TRUE);
4948 wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_NetworkReachableTrue, 2);
4949
4950 wait_for_until(marie->lc, pauline->lc, NULL, 1, 2000);
4951 incoming_call = linphone_core_get_current_call(pauline->lc);
4952 linphone_call_accept(incoming_call);
4953 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1));
4954 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1));
4955
4956 linphone_call_terminate(incoming_call);
4957 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallEnd, 1));
4958 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallReleased, 1));
4959 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallReleased, 1));
4960 end:
4961 linphone_core_manager_destroy(marie);
4962 linphone_core_manager_destroy(pauline);
4963 }
4964
recovered_call_on_network_switch_in_early_state_4(void)4965 static void recovered_call_on_network_switch_in_early_state_4(void) {
4966 LinphoneCall *incoming_call;
4967 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
4968 LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc");
4969
4970 linphone_core_invite_address(marie->lc, pauline->identity);
4971 if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingReceived, 1))) goto end;
4972 if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingRinging, 1))) goto end;
4973
4974 incoming_call = linphone_core_get_current_call(pauline->lc);
4975 linphone_call_accept(incoming_call);
4976 linphone_core_set_network_reachable(pauline->lc, FALSE);
4977 wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_NetworkReachableFalse, 1);
4978 linphone_core_set_network_reachable(pauline->lc, TRUE);
4979 wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_NetworkReachableTrue, 2);
4980
4981 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1));
4982 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1));
4983
4984 BC_ASSERT_TRUE(sal_call_dialog_request_pending(incoming_call->op));
4985 wait_for_until(marie->lc, pauline->lc, NULL, 1, 2000);
4986 BC_ASSERT_FALSE(sal_call_dialog_request_pending(incoming_call->op));
4987 linphone_call_terminate(incoming_call);
4988 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallEnd, 1));
4989 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallReleased, 1));
4990 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallReleased, 1));
4991 end:
4992 linphone_core_manager_destroy(marie);
4993 linphone_core_manager_destroy(pauline);
4994 }
4995
recovered_call_on_network_switch_during_reinvite_1(void)4996 static void recovered_call_on_network_switch_during_reinvite_1(void) {
4997 LinphoneCall *incoming_call;
4998 LinphoneCall *outgoing_call;
4999 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
5000 LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc");
5001
5002 linphone_core_invite_address(marie->lc, pauline->identity);
5003 if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingReceived, 1))) goto end;
5004 if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingRinging, 1))) goto end;
5005
5006 incoming_call = linphone_core_get_current_call(pauline->lc);
5007 linphone_call_accept(incoming_call);
5008 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1));
5009 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1));
5010
5011 outgoing_call = linphone_core_get_current_call(marie->lc);
5012 linphone_call_pause(outgoing_call);
5013 linphone_core_set_network_reachable(marie->lc, FALSE);
5014 wait_for(marie->lc, pauline->lc, &marie->stat.number_of_NetworkReachableFalse, 1);
5015 linphone_core_set_network_reachable(marie->lc, TRUE);
5016 wait_for(marie->lc, pauline->lc, &marie->stat.number_of_NetworkReachableTrue, 2);
5017
5018 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallPaused, 1));
5019 linphone_call_terminate(incoming_call);
5020 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallEnd, 1));
5021 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallReleased, 1));
5022 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallReleased, 1));
5023 end:
5024 linphone_core_manager_destroy(marie);
5025 linphone_core_manager_destroy(pauline);
5026 }
5027
configure_video_policies_for_network_switch(LinphoneCore * marie,LinphoneCore * pauline)5028 static void configure_video_policies_for_network_switch(LinphoneCore *marie, LinphoneCore *pauline) {
5029 LinphoneVideoPolicy policy;
5030 policy.automatically_accept = FALSE;
5031 policy.automatically_initiate = FALSE;
5032
5033 linphone_core_enable_video_capture(marie, TRUE);
5034 linphone_core_enable_video_display(marie, TRUE);
5035 linphone_core_enable_video_capture(pauline, TRUE);
5036 linphone_core_enable_video_display(pauline, TRUE);
5037 linphone_core_set_video_policy(marie, &policy);
5038 linphone_core_set_video_policy(pauline, &policy);
5039 lp_config_set_int(pauline->config, "sip", "defer_update_default", TRUE);
5040 }
5041
recovered_call_on_network_switch_during_reinvite_2(void)5042 static void recovered_call_on_network_switch_during_reinvite_2(void) {
5043 LinphoneCall *incoming_call;
5044 LinphoneCall *outgoing_call;
5045 LinphoneCallParams *params;
5046 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
5047 LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc");
5048
5049 configure_video_policies_for_network_switch(marie->lc, pauline->lc);
5050 linphone_core_invite_address(marie->lc, pauline->identity);
5051 if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingReceived, 1))) goto end;
5052 if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingRinging, 1))) goto end;
5053
5054 incoming_call = linphone_core_get_current_call(pauline->lc);
5055 linphone_call_accept(incoming_call);
5056 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1));
5057 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1));
5058
5059 outgoing_call = linphone_core_get_current_call(marie->lc);
5060 params = linphone_core_create_call_params(marie->lc, outgoing_call);
5061 linphone_call_params_enable_video(params, TRUE);
5062 linphone_call_update(outgoing_call, params);
5063 linphone_call_params_unref(params);
5064 linphone_core_set_network_reachable(marie->lc, FALSE);
5065 wait_for(marie->lc, pauline->lc, &marie->stat.number_of_NetworkReachableFalse, 1);
5066 linphone_core_set_network_reachable(marie->lc, TRUE);
5067 wait_for(marie->lc, pauline->lc, &marie->stat.number_of_NetworkReachableTrue, 2);
5068
5069 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallUpdatedByRemote, 1));
5070 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneRegistrationOk, 2));
5071 wait_for_until(marie->lc, pauline->lc, NULL, 1, 2000);
5072 params = linphone_core_create_call_params(pauline->lc, incoming_call);
5073 linphone_call_params_enable_video(params, TRUE);
5074 linphone_call_accept_update(incoming_call, params);
5075 linphone_call_params_unref(params);
5076
5077 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2));
5078 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2));
5079 wait_for_until(marie->lc, pauline->lc, NULL, 1, 2000);
5080 linphone_call_terminate(incoming_call);
5081 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallEnd, 1));
5082 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallReleased, 1));
5083 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallReleased, 1));
5084 end:
5085 linphone_core_manager_destroy(marie);
5086 linphone_core_manager_destroy(pauline);
5087 }
5088
recovered_call_on_network_switch_during_reinvite_3(void)5089 static void recovered_call_on_network_switch_during_reinvite_3(void) {
5090 LinphoneCall *incoming_call;
5091 LinphoneCall *outgoing_call;
5092 LinphoneCallParams *params;
5093 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
5094 LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc");
5095
5096 configure_video_policies_for_network_switch(marie->lc, pauline->lc);
5097 linphone_core_invite_address(marie->lc, pauline->identity);
5098 if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingReceived, 1))) goto end;
5099 if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingRinging, 1))) goto end;
5100
5101 incoming_call = linphone_core_get_current_call(pauline->lc);
5102 linphone_call_accept(incoming_call);
5103 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1));
5104 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1));
5105
5106 outgoing_call = linphone_core_get_current_call(marie->lc);
5107 params = linphone_core_create_call_params(marie->lc, outgoing_call);
5108 linphone_call_params_enable_video(params, TRUE);
5109 linphone_call_update(outgoing_call, params);
5110 linphone_call_params_unref(params);
5111 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallUpdatedByRemote, 1));
5112
5113 linphone_core_set_network_reachable(pauline->lc, FALSE);
5114 wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_NetworkReachableFalse, 1);
5115 linphone_core_set_network_reachable(pauline->lc, TRUE);
5116 wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_NetworkReachableTrue, 2);
5117 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneRegistrationOk, 2));
5118 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallUpdatedByRemote, 1));
5119 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2));
5120 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2));
5121
5122 params = linphone_core_create_call_params(marie->lc, outgoing_call);
5123 linphone_call_params_enable_video(params, TRUE);
5124 linphone_call_update(outgoing_call, params);
5125 linphone_call_params_unref(params);
5126 wait_for_until(marie->lc, pauline->lc, NULL, 1, 2000);
5127 params = linphone_core_create_call_params(pauline->lc, incoming_call);
5128 linphone_call_params_enable_video(params, TRUE);
5129 linphone_call_accept_update(incoming_call, params);
5130 linphone_call_params_unref(params);
5131
5132 wait_for_until(marie->lc, pauline->lc, NULL, 1, 2000);
5133 linphone_call_terminate(incoming_call);
5134 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallEnd, 1));
5135 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallReleased, 1));
5136 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallReleased, 1));
5137 end:
5138 linphone_core_manager_destroy(marie);
5139 linphone_core_manager_destroy(pauline);
5140 }
5141
recovered_call_on_network_switch_during_reinvite_4(void)5142 static void recovered_call_on_network_switch_during_reinvite_4(void) {
5143 LinphoneCall *incoming_call;
5144 LinphoneCall *outgoing_call;
5145 LinphoneCallParams *params;
5146 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
5147 LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc");
5148
5149 configure_video_policies_for_network_switch(marie->lc, pauline->lc);
5150 linphone_core_invite_address(marie->lc, pauline->identity);
5151 if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingReceived, 1))) goto end;
5152 if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingRinging, 1))) goto end;
5153
5154 incoming_call = linphone_core_get_current_call(pauline->lc);
5155 linphone_call_accept(incoming_call);
5156 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1));
5157 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1));
5158
5159 outgoing_call = linphone_core_get_current_call(marie->lc);
5160 params = linphone_core_create_call_params(marie->lc, outgoing_call);
5161 linphone_call_params_enable_video(params, TRUE);
5162 linphone_call_update(outgoing_call, params);
5163 linphone_call_params_unref(params);
5164 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallUpdatedByRemote, 1));
5165
5166 params = linphone_core_create_call_params(pauline->lc, incoming_call);
5167 linphone_call_params_enable_video(params, TRUE);
5168 linphone_call_accept_update(incoming_call, params);
5169 linphone_call_params_unref(params);
5170 linphone_core_set_network_reachable(pauline->lc, FALSE);
5171 wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_NetworkReachableFalse, 1);
5172 linphone_core_set_network_reachable(pauline->lc, TRUE);
5173 wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_NetworkReachableTrue, 2);
5174 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneRegistrationOk, 2));
5175 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2));
5176 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2));
5177
5178 wait_for_until(marie->lc, pauline->lc, NULL, 1, 2000);
5179 linphone_call_terminate(incoming_call);
5180 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallEnd, 1));
5181 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallReleased, 1));
5182 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallReleased, 1));
5183 end:
5184 linphone_core_manager_destroy(marie);
5185 linphone_core_manager_destroy(pauline);
5186 }
5187
_call_with_network_switch(bool_t use_ice,bool_t with_socket_refresh,bool_t enable_rtt,bool_t caller_pause,bool_t callee_pause)5188 static void _call_with_network_switch(bool_t use_ice, bool_t with_socket_refresh, bool_t enable_rtt, bool_t caller_pause, bool_t callee_pause) {
5189 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
5190 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
5191 LinphoneCallParams *pauline_params = NULL;
5192 LinphoneCall *marie_call = NULL;
5193 LinphoneCall *pauline_call = NULL;
5194 bctbx_list_t *lcs = NULL;
5195 bool_t call_ok;
5196
5197 lcs = bctbx_list_append(lcs, marie->lc);
5198 lcs = bctbx_list_append(lcs, pauline->lc);
5199
5200 if (use_ice){
5201 linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce);
5202 linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce);
5203 linphone_core_manager_wait_for_stun_resolution(marie);
5204 linphone_core_manager_wait_for_stun_resolution(pauline);
5205 }
5206 if (with_socket_refresh){
5207 lp_config_set_int(linphone_core_get_config(marie->lc), "net", "recreate_sockets_when_network_is_up", 1);
5208 lp_config_set_int(linphone_core_get_config(pauline->lc), "net", "recreate_sockets_when_network_is_up", 1);
5209 }
5210 if (enable_rtt) {
5211 pauline_params = linphone_core_create_call_params(pauline->lc, NULL);
5212 linphone_call_params_enable_realtime_text(pauline_params, TRUE);
5213 }
5214
5215 BC_ASSERT_TRUE((call_ok=call_with_params(pauline, marie, pauline_params, NULL)));
5216 if (!call_ok) goto end;
5217
5218 wait_for_until(marie->lc, pauline->lc, NULL, 0, 2000);
5219 if (use_ice) {
5220 /*wait for ICE reINVITE to complete*/
5221 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2));
5222 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2));
5223 BC_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
5224 }
5225
5226 if (caller_pause) {
5227 pauline_call = linphone_core_get_current_call(pauline->lc);
5228 linphone_call_pause(pauline_call);
5229 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallPausedByRemote, 1));
5230 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallPaused, 1));
5231 } else if (callee_pause) {
5232 marie_call = linphone_core_get_current_call(marie->lc);
5233 linphone_call_pause(marie_call);
5234 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallPausedByRemote, 1));
5235 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallPaused, 1));
5236 }
5237
5238 /*marie looses the network and reconnects*/
5239 linphone_core_set_network_reachable(marie->lc, FALSE);
5240 wait_for_until(marie->lc, pauline->lc, NULL, 0, 1000);
5241
5242 /*marie will reconnect and register*/
5243 linphone_core_set_network_reachable(marie->lc, TRUE);
5244 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneRegistrationOk, 2));
5245
5246 if (use_ice){
5247 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallUpdating, 1));
5248 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallUpdatedByRemote, 1));
5249 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 3));
5250 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 3));
5251 /*now comes the ICE reINVITE*/
5252 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallUpdating, 2));
5253 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallUpdatedByRemote, 2));
5254 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 4));
5255 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 4));
5256 }else{
5257 if (caller_pause) {
5258 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallUpdating, 1));
5259 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallPausedByRemote, 2));
5260 linphone_call_resume(pauline_call);
5261 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2));
5262 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2));
5263 } else if (callee_pause) {
5264 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallUpdatedByRemote, 1));
5265 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallPausedByRemote, 2));
5266 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallPaused, 2));
5267 linphone_call_resume(marie_call);
5268 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2));
5269 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2));
5270 } else {
5271 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallUpdating, 1));
5272 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallUpdatedByRemote, 1));
5273 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2));
5274 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2));
5275 }
5276 }
5277
5278 /*check that media is back*/
5279 check_media_direction(marie, linphone_core_get_current_call(marie->lc), lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionInvalid);
5280 liblinphone_tester_check_rtcp(pauline, marie);
5281 if (use_ice) BC_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
5282
5283 /*pauline shall be able to end the call without problem now*/
5284 end_call(pauline, marie);
5285 end:
5286 if (pauline_params) {
5287 linphone_call_params_unref(pauline_params);
5288 }
5289 bctbx_list_free(lcs);
5290 linphone_core_manager_destroy(marie);
5291 linphone_core_manager_destroy(pauline);
5292 }
5293
call_with_network_switch(void)5294 static void call_with_network_switch(void){
5295 _call_with_network_switch(FALSE, FALSE, FALSE, FALSE, FALSE);
5296 }
5297
call_with_network_switch_in_paused_state(void)5298 static void call_with_network_switch_in_paused_state(void) {
5299 _call_with_network_switch(FALSE, FALSE, FALSE, FALSE, TRUE);
5300 }
5301
call_with_network_switch_in_paused_by_remote_state(void)5302 static void call_with_network_switch_in_paused_by_remote_state(void) {
5303 _call_with_network_switch(FALSE, FALSE, FALSE, TRUE, FALSE);
5304 }
5305
call_with_network_switch_and_ice(void)5306 static void call_with_network_switch_and_ice(void){
5307 _call_with_network_switch(TRUE, FALSE, FALSE, FALSE, FALSE);
5308 }
5309
call_with_network_switch_ice_and_rtt(void)5310 static void call_with_network_switch_ice_and_rtt(void) {
5311 _call_with_network_switch(TRUE, FALSE, TRUE, FALSE, FALSE);
5312 }
5313
call_with_network_switch_and_socket_refresh(void)5314 static void call_with_network_switch_and_socket_refresh(void){
5315 _call_with_network_switch(TRUE, TRUE, FALSE, FALSE, FALSE);
5316 }
5317
call_with_network_switch_no_recovery(void)5318 static void call_with_network_switch_no_recovery(void){
5319 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
5320 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
5321 LinphoneCallParams *pauline_params = NULL;
5322 bctbx_list_t *lcs = NULL;
5323 bool_t call_ok;
5324
5325 lcs = bctbx_list_append(lcs, marie->lc);
5326 lcs = bctbx_list_append(lcs, pauline->lc);
5327
5328 linphone_core_set_nortp_timeout(marie->lc, 50000);
5329
5330 BC_ASSERT_TRUE((call_ok=call_with_params(pauline, marie, pauline_params, NULL)));
5331 if (!call_ok) goto end;
5332
5333 wait_for_until(marie->lc, pauline->lc, NULL, 0, 2000);
5334
5335 /*marie looses the network and reconnects*/
5336 linphone_core_set_network_reachable(marie->lc, FALSE);
5337 /*but meanwhile pauline terminates the call.*/
5338 linphone_call_terminate(linphone_core_get_current_call(pauline->lc));
5339 /*
5340 * We have to wait 32 seconds so that the BYE transaction is terminated, and dialog removed.
5341 * This is the condition to receive a 481 when marie sends the reINVITE.*/
5342 wait_for_list(lcs, NULL, 0, 32500);
5343
5344 /*marie will reconnect, register, and send an automatic reINVITE to try to repair the call*/
5345 linphone_core_set_network_reachable(marie->lc, TRUE);
5346 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneRegistrationOk, 2));
5347 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallUpdating, 1));
5348 /*This reINVITE should of course fail, so marie's call should be terminated.*/
5349 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallEnd, 1));
5350
5351 end:
5352 if (pauline_params) {
5353 linphone_call_params_unref(pauline_params);
5354 }
5355 bctbx_list_free(lcs);
5356 linphone_core_manager_destroy(marie);
5357 linphone_core_manager_destroy(pauline);
5358 }
5359
call_with_sip_and_rtp_independant_switches(void)5360 static void call_with_sip_and_rtp_independant_switches(void){
5361 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
5362 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
5363 bctbx_list_t *lcs = NULL;
5364 bool_t call_ok;
5365 bool_t use_ice = TRUE;
5366 bool_t with_socket_refresh = TRUE;
5367
5368 lcs = bctbx_list_append(lcs, marie->lc);
5369 lcs = bctbx_list_append(lcs, pauline->lc);
5370
5371 if (use_ice){
5372 linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce);
5373 linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce);
5374 }
5375 if (with_socket_refresh){
5376 lp_config_set_int(linphone_core_get_config(marie->lc), "net", "recreate_sockets_when_network_is_up", 1);
5377 lp_config_set_int(linphone_core_get_config(pauline->lc), "net", "recreate_sockets_when_network_is_up", 1);
5378 }
5379
5380 linphone_core_set_media_network_reachable(marie->lc, TRUE);
5381
5382 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
5383 if (!call_ok) goto end;
5384
5385 wait_for_until(marie->lc, pauline->lc, NULL, 0, 2000);
5386 if (use_ice) {
5387 /*wait for ICE reINVITE to complete*/
5388 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2));
5389 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2));
5390 BC_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
5391 }
5392 /*marie looses the SIP network and reconnects*/
5393 linphone_core_set_sip_network_reachable(marie->lc, FALSE);
5394 linphone_core_set_media_network_reachable(marie->lc, FALSE);
5395 wait_for_until(marie->lc, pauline->lc, NULL, 0, 1000);
5396
5397 /*marie will reconnect and register*/
5398 linphone_core_set_sip_network_reachable(marie->lc, TRUE);
5399 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneRegistrationOk, 2));
5400 wait_for_until(marie->lc, pauline->lc, NULL, 0, 5000);
5401 /*at this stage, no reINVITE is expected to be send*/
5402 BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallUpdating, 0, int, "%i");
5403
5404 /*now we notify the a reconnection of media network*/
5405 linphone_core_set_media_network_reachable(marie->lc, TRUE);
5406
5407 if (use_ice){
5408 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallUpdating, 1));
5409 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallUpdatedByRemote, 1));
5410 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 3));
5411 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 3));
5412 /*now comes the ICE reINVITE*/
5413 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallUpdating, 2));
5414 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallUpdatedByRemote, 2));
5415 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 4));
5416 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 4));
5417 }else{
5418 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallUpdating, 1));
5419 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallUpdatedByRemote, 1));
5420 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2));
5421 BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2));
5422 }
5423
5424 /*check that media is back*/
5425 check_media_direction(marie, linphone_core_get_current_call(marie->lc), lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionInvalid);
5426 liblinphone_tester_check_rtcp(pauline, marie);
5427 if (use_ice) BC_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
5428
5429 /*pauline shall be able to end the call without problem now*/
5430 end_call(pauline, marie);
5431 end:
5432 bctbx_list_free(lcs);
5433 linphone_core_manager_destroy(marie);
5434 linphone_core_manager_destroy(pauline);
5435 }
5436
5437
5438 #ifdef SQLITE_STORAGE_ENABLED
5439
call_logs_if_no_db_set(void)5440 static void call_logs_if_no_db_set(void) {
5441 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
5442 LinphoneCoreManager* laure = linphone_core_manager_new("laure_call_logs_rc");
5443 BC_ASSERT_TRUE(bctbx_list_size(laure->lc->call_logs) == 10);
5444
5445 BC_ASSERT_TRUE(call(marie, laure));
5446 wait_for_until(marie->lc, laure->lc, NULL, 5, 1000);
5447 end_call(marie, laure);
5448
5449 BC_ASSERT_TRUE(bctbx_list_size(laure->lc->call_logs) == 11);
5450 linphone_core_manager_destroy(marie);
5451 linphone_core_manager_destroy(laure);
5452 }
5453
call_logs_migrate(void)5454 static void call_logs_migrate(void) {
5455 LinphoneCoreManager* laure = linphone_core_manager_new("laure_call_logs_rc");
5456 char *logs_db = bc_tester_file("call_logs.db");
5457 size_t i = 0;
5458 int incoming_count = 0, outgoing_count = 0, missed_count = 0, aborted_count = 0, decline_count = 0, video_enabled_count = 0;
5459
5460 unlink(logs_db);
5461 BC_ASSERT_TRUE(bctbx_list_size(laure->lc->call_logs) == 10);
5462
5463 linphone_core_set_call_logs_database_path(laure->lc, logs_db);
5464 BC_ASSERT_TRUE(linphone_core_get_call_history_size(laure->lc) == 10);
5465
5466 for (; i < bctbx_list_size(laure->lc->call_logs); i++) {
5467 LinphoneCallLog *log = bctbx_list_nth_data(laure->lc->call_logs, (int)i);
5468 LinphoneCallStatus state = linphone_call_log_get_status(log);
5469 LinphoneCallDir direction = linphone_call_log_get_dir(log);
5470
5471 if (state == LinphoneCallAborted) {
5472 aborted_count += 1;
5473 } else if (state == LinphoneCallMissed) {
5474 missed_count += 1;
5475 } else if (state == LinphoneCallDeclined) {
5476 decline_count += 1;
5477 }
5478
5479 if (direction == LinphoneCallOutgoing) {
5480 outgoing_count += 1;
5481 } else {
5482 incoming_count += 1;
5483 }
5484
5485 if (linphone_call_log_video_enabled(log)) {
5486 video_enabled_count += 1;
5487 }
5488 }
5489 BC_ASSERT_TRUE(incoming_count == 5);
5490 BC_ASSERT_TRUE(outgoing_count == 5);
5491 BC_ASSERT_TRUE(missed_count == 1);
5492 BC_ASSERT_TRUE(aborted_count == 3);
5493 BC_ASSERT_TRUE(decline_count == 2);
5494 BC_ASSERT_TRUE(video_enabled_count == 3);
5495
5496 {
5497 LinphoneCallLog *log = linphone_core_get_last_outgoing_call_log(laure->lc);
5498 BC_ASSERT_PTR_NOT_NULL(log);
5499 if (log) {
5500 BC_ASSERT_EQUAL((int)log->start_date_time, 1441738272, int, "%d");
5501 linphone_call_log_unref(log);
5502 log = NULL;
5503 }
5504 }
5505
5506 laure->lc->call_logs = bctbx_list_free_with_data(laure->lc->call_logs, (void (*)(void*))linphone_call_log_unref);
5507 laure->lc->call_logs = call_logs_read_from_config_file(laure->lc);
5508 BC_ASSERT_TRUE(bctbx_list_size(laure->lc->call_logs) == 0);
5509
5510 unlink(logs_db);
5511 ms_free(logs_db);
5512 linphone_core_manager_destroy(laure);
5513 }
5514
call_logs_sqlite_storage(void)5515 static void call_logs_sqlite_storage(void) {
5516 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
5517 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
5518 char *logs_db = bc_tester_file("call_logs.db");
5519 bctbx_list_t *logs = NULL;
5520 LinphoneCallLog *call_log = NULL;
5521 LinphoneAddress *laure = NULL;
5522 time_t user_data_time = time(NULL);
5523 time_t start_time = 0;
5524 unlink(logs_db);
5525
5526 linphone_core_set_call_logs_database_path(marie->lc, logs_db);
5527 BC_ASSERT_TRUE(linphone_core_get_call_history_size(marie->lc) == 0);
5528
5529 BC_ASSERT_TRUE(call(marie, pauline));
5530 wait_for_until(marie->lc, pauline->lc, NULL, 5, 500);
5531 call_log = linphone_call_get_call_log(linphone_core_get_current_call(marie->lc));
5532 start_time = linphone_call_log_get_start_date(call_log);
5533 linphone_call_log_set_user_data(call_log, &user_data_time);
5534 linphone_call_log_set_ref_key(call_log, "ref_key");
5535 end_call(marie, pauline);
5536 BC_ASSERT_TRUE(linphone_core_get_call_history_size(marie->lc) == 1);
5537
5538 logs = linphone_core_get_call_history_for_address(marie->lc, linphone_proxy_config_get_identity_address(linphone_core_get_default_proxy_config(pauline->lc)));
5539 BC_ASSERT_TRUE(bctbx_list_size(logs) == 1);
5540 bctbx_list_free_with_data(logs, (void (*)(void*))linphone_call_log_unref);
5541
5542 laure = linphone_address_new("\"Laure\" <sip:laure@sip.example.org>");
5543 logs = linphone_core_get_call_history_for_address(marie->lc, laure);
5544 BC_ASSERT_TRUE(bctbx_list_size(logs) == 0);
5545 linphone_address_unref(laure);
5546
5547 logs = linphone_core_get_call_history_for_address(marie->lc, linphone_proxy_config_get_identity_address(linphone_core_get_default_proxy_config(pauline->lc)));
5548 if (BC_ASSERT_TRUE(bctbx_list_size(logs) == 1)) {
5549 const char *call_id;
5550 const char *ref_key;
5551 call_log = (LinphoneCallLog *)bctbx_list_get_data(logs);
5552 ref_key = linphone_call_log_get_ref_key(call_log);
5553 BC_ASSERT_EQUAL(linphone_call_log_get_dir(call_log), LinphoneCallOutgoing, int, "%d");
5554 BC_ASSERT_LOWER(linphone_call_log_get_duration(call_log), 2, int, "%d");
5555 BC_ASSERT_TRUE(linphone_address_equal(
5556 linphone_call_log_get_from_address(call_log),
5557 linphone_proxy_config_get_identity_address(linphone_core_get_default_proxy_config(marie->lc))));
5558 BC_ASSERT_TRUE(linphone_address_equal(
5559 linphone_call_log_get_to_address(call_log),
5560 linphone_proxy_config_get_identity_address(linphone_core_get_default_proxy_config(pauline->lc))));
5561 BC_ASSERT_PTR_NOT_NULL(linphone_call_log_get_local_stats(call_log));
5562 BC_ASSERT_GREATER(linphone_call_log_get_quality(call_log), -1, float, "%.1f");
5563 BC_ASSERT_PTR_NOT_NULL(ref_key);
5564 if (ref_key) {
5565 BC_ASSERT_STRING_EQUAL(ref_key, "ref_key");
5566 }
5567 BC_ASSERT_PTR_EQUAL(linphone_call_log_get_user_data(call_log), &user_data_time);
5568
5569 call_id = linphone_call_log_get_call_id(call_log);
5570 BC_ASSERT_PTR_NOT_NULL(call_id);
5571 {
5572 LinphoneCallLog* find_call_log = linphone_core_find_call_log_from_call_id(marie->lc, call_id);
5573 BC_ASSERT_PTR_NOT_NULL(find_call_log);
5574 if (find_call_log) linphone_call_log_unref(find_call_log);
5575 }
5576
5577 BC_ASSERT_TRUE(linphone_address_equal(
5578 linphone_call_log_get_remote_address(call_log),
5579 linphone_proxy_config_get_identity_address(linphone_core_get_default_proxy_config(pauline->lc))));
5580 BC_ASSERT_PTR_NOT_NULL(linphone_call_log_get_remote_stats(call_log));
5581
5582 BC_ASSERT_EQUAL(linphone_call_log_get_start_date(call_log), start_time, unsigned long long, "%llu");
5583 BC_ASSERT_EQUAL(linphone_call_log_get_status(call_log), LinphoneCallSuccess, int, "%d");
5584 }
5585
5586 linphone_core_delete_call_log(marie->lc, (LinphoneCallLog *)bctbx_list_nth_data(logs, 0));
5587 bctbx_list_free_with_data(logs, (void (*)(void*))linphone_call_log_unref);
5588 BC_ASSERT_TRUE(linphone_core_get_call_history_size(marie->lc) == 0);
5589
5590 reset_counters(&marie->stat);
5591 reset_counters(&pauline->stat);
5592 BC_ASSERT_TRUE(call(marie, pauline));
5593 end_call(marie, pauline);
5594
5595 reset_counters(&marie->stat);
5596 reset_counters(&pauline->stat);
5597 BC_ASSERT_TRUE(call(marie, pauline));
5598 end_call(marie, pauline);
5599 BC_ASSERT_TRUE(linphone_core_get_call_history_size(marie->lc) == 2);
5600
5601 linphone_core_delete_call_history(marie->lc);
5602 BC_ASSERT_TRUE(linphone_core_get_call_history_size(marie->lc) == 0);
5603
5604 linphone_core_manager_destroy(marie);
5605 linphone_core_manager_destroy(pauline);
5606 unlink(logs_db);
5607 ms_free(logs_db);
5608 }
5609
5610 #endif
5611
5612
call_with_http_proxy(void)5613 static void call_with_http_proxy(void) {
5614 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
5615 LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_rc");
5616 bool_t call_ok;
5617 LinphoneCall *marie_call;
5618 LinphoneAddress *contact_addr;
5619 struct addrinfo *res=NULL;
5620 struct addrinfo hints = {0};
5621 char ip[NI_MAXHOST];
5622 int err;
5623
5624 if (!transport_supported(LinphoneTransportTls)) {
5625 ms_message("Test skipped because no tls support");
5626 goto end;
5627 }
5628 hints.ai_family = AF_INET;
5629 hints.ai_socktype = SOCK_STREAM;
5630
5631 err = getaddrinfo("sip.linphone.org","8888", &hints, &res);
5632 if (err !=0){
5633 ms_error("call_with_http_proxy(): getaddrinfo() error: %s", gai_strerror(err));
5634 }
5635 BC_ASSERT_PTR_NOT_NULL(res);
5636 if (!res) goto end;
5637
5638 BC_ASSERT_EQUAL(err=bctbx_getnameinfo(res->ai_addr, (socklen_t)res->ai_addrlen, ip, sizeof(ip)-1, NULL, 0, NI_NUMERICHOST), 0, int, "%i");
5639 if (err != 0){
5640 ms_error("call_with_http_proxy(): getnameinfo() error: %s", gai_strerror(err));
5641 goto end;
5642 }
5643
5644 freeaddrinfo(res);
5645
5646 linphone_core_set_http_proxy_host(pauline->lc,"sip.linphone.org");
5647 linphone_core_set_network_reachable(pauline->lc, FALSE); /*to make sure channel is restarted*/
5648 linphone_core_set_network_reachable(pauline->lc, TRUE);
5649
5650 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
5651 if (!call_ok) goto end;
5652
5653 marie_call = linphone_core_get_current_call(marie->lc);
5654 contact_addr = linphone_address_new(linphone_call_get_remote_contact(marie_call));
5655 BC_ASSERT_STRING_EQUAL(linphone_address_get_domain(contact_addr),ip);
5656 linphone_address_unref(contact_addr);
5657 end_call(marie, pauline);
5658 end:
5659 linphone_core_manager_destroy(marie);
5660 linphone_core_manager_destroy(pauline);
5661 }
5662
_call_with_rtcp_mux(bool_t caller_rtcp_mux,bool_t callee_rtcp_mux,bool_t with_ice,bool_t with_ice_reinvite)5663 static void _call_with_rtcp_mux(bool_t caller_rtcp_mux, bool_t callee_rtcp_mux, bool_t with_ice,bool_t with_ice_reinvite){
5664 LinphoneCoreManager * marie = linphone_core_manager_new( "marie_rc");
5665 LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
5666 const LinphoneCallParams *params;
5667 bctbx_list_t *lcs = NULL;
5668
5669 lcs = bctbx_list_append(lcs, marie->lc);
5670 lcs = bctbx_list_append(lcs, pauline->lc);
5671
5672 if (caller_rtcp_mux){
5673 lp_config_set_int(linphone_core_get_config(marie->lc), "rtp", "rtcp_mux", 1);
5674 }
5675 if (callee_rtcp_mux){
5676 lp_config_set_int(linphone_core_get_config(pauline->lc), "rtp", "rtcp_mux", 1);
5677 }
5678 if (with_ice){
5679 linphone_core_set_user_agent(pauline->lc, "Natted Linphone", NULL);
5680 linphone_core_set_user_agent(marie->lc, "Natted Linphone", NULL);
5681 linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce);
5682 linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce);
5683 }
5684 if (!with_ice_reinvite) {
5685 lp_config_set_int(linphone_core_get_config(pauline->lc), "sip", "update_call_when_ice_completed", 0);
5686 lp_config_set_int(linphone_core_get_config(marie->lc), "sip", "update_call_when_ice_completed", 0);
5687 }
5688
5689 if (!BC_ASSERT_TRUE(call(marie,pauline))) goto end;
5690
5691 params = linphone_call_get_remote_params(linphone_core_get_current_call(pauline->lc));
5692 BC_ASSERT_TRUE(caller_rtcp_mux == (linphone_call_params_get_custom_sdp_media_attribute(params, LinphoneStreamTypeAudio, "rtcp-mux") != NULL));
5693 if (caller_rtcp_mux){
5694 params = linphone_call_get_remote_params(linphone_core_get_current_call(marie->lc));
5695 BC_ASSERT_TRUE(callee_rtcp_mux == (linphone_call_params_get_custom_sdp_media_attribute(params, LinphoneStreamTypeAudio, "rtcp-mux") != NULL));
5696 }
5697
5698 if (with_ice){
5699 check_ice(marie, pauline, LinphoneIceStateHostConnection);
5700 }
5701 liblinphone_tester_check_rtcp(marie,pauline);
5702
5703 if (caller_rtcp_mux && callee_rtcp_mux){
5704 BC_ASSERT_EQUAL(marie->stat.number_of_rtcp_received_via_mux, marie->stat.number_of_rtcp_received, int, "%i");
5705
5706 BC_ASSERT_EQUAL(pauline->stat.number_of_rtcp_received_via_mux, pauline->stat.number_of_rtcp_received, int, "%i");
5707
5708 }else{
5709 BC_ASSERT_TRUE(marie->stat.number_of_rtcp_received_via_mux == 0);
5710 BC_ASSERT_TRUE(pauline->stat.number_of_rtcp_received_via_mux == 0);
5711 }
5712
5713 check_media_direction(pauline, linphone_core_get_current_call(pauline->lc), lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionInvalid);
5714 end_call(marie,pauline);
5715
5716 end:
5717 bctbx_list_free(lcs);
5718 linphone_core_manager_destroy(pauline);
5719 linphone_core_manager_destroy(marie);
5720 }
5721
call_with_rtcp_mux(void)5722 static void call_with_rtcp_mux(void){
5723 _call_with_rtcp_mux(TRUE, TRUE, FALSE,TRUE);
5724 }
5725
call_with_rtcp_mux_not_accepted(void)5726 static void call_with_rtcp_mux_not_accepted(void){
5727 _call_with_rtcp_mux(TRUE, FALSE, FALSE,TRUE);
5728 }
5729
call_with_ice_and_rtcp_mux(void)5730 static void call_with_ice_and_rtcp_mux(void){
5731 _call_with_rtcp_mux(TRUE, TRUE, TRUE,TRUE);
5732 }
5733
call_with_ice_and_rtcp_mux_without_reinvite(void)5734 static void call_with_ice_and_rtcp_mux_without_reinvite(void){
5735 _call_with_rtcp_mux(TRUE, TRUE, TRUE,FALSE);
5736 }
5737
call_with_zrtp_configured_calling_base(LinphoneCoreManager * marie,LinphoneCoreManager * pauline)5738 static void call_with_zrtp_configured_calling_base(LinphoneCoreManager *marie, LinphoneCoreManager *pauline) {
5739 if (ms_zrtp_available()) {
5740 bool_t call_ok;
5741
5742 linphone_core_set_media_encryption(pauline->lc, LinphoneMediaEncryptionZRTP);
5743 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
5744
5745 liblinphone_tester_check_rtcp(marie,pauline);
5746
5747 BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)))
5748 , LinphoneMediaEncryptionZRTP, int, "%i");
5749 BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)))
5750 , LinphoneMediaEncryptionZRTP, int, "%i");
5751 end_call(pauline, marie);
5752 } else {
5753 ms_warning("Test skipped, ZRTP not available");
5754 }
5755
5756 }
5757
call_with_zrtp_configured_callee_base(LinphoneCoreManager * marie,LinphoneCoreManager * pauline)5758 static void call_with_zrtp_configured_callee_base(LinphoneCoreManager *marie, LinphoneCoreManager *pauline) {
5759 if (ms_zrtp_available()) {
5760 bool_t call_ok;
5761
5762 linphone_core_set_media_encryption(marie->lc, LinphoneMediaEncryptionZRTP);
5763 BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
5764
5765 liblinphone_tester_check_rtcp(marie,pauline);
5766
5767 BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)))
5768 , LinphoneMediaEncryptionZRTP, int, "%i");
5769 BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)))
5770 , LinphoneMediaEncryptionZRTP, int, "%i");
5771 end_call(pauline, marie);
5772 } else {
5773 ms_warning("Test skipped, ZRTP not available");
5774 }
5775 }
5776
5777
5778 /*
5779 * this test checks the 'dont_default_to_stun_candidates' mode, where the c= line is left to host
5780 * ip instead of stun candidate when ice is enabled*/
call_with_ice_with_default_candidate_not_stun(void)5781 static void call_with_ice_with_default_candidate_not_stun(void){
5782 LinphoneCoreManager * marie = linphone_core_manager_new( "marie_rc");
5783 LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
5784 char localip[LINPHONE_IPADDR_SIZE];
5785 bool_t call_ok;
5786
5787 lp_config_set_int(marie->lc->config, "net", "dont_default_to_stun_candidates", 1);
5788 linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce);
5789 linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce);
5790 linphone_core_get_local_ip(marie->lc, AF_INET, NULL, localip);
5791 call_ok = call(marie, pauline);
5792 if (call_ok){
5793 check_ice(marie, pauline, LinphoneIceStateHostConnection);
5794 BC_ASSERT_STRING_EQUAL(marie->lc->current_call->localdesc->addr, localip);
5795 BC_ASSERT_STRING_EQUAL(pauline->lc->current_call->resultdesc->addr, localip);
5796 BC_ASSERT_STRING_EQUAL(marie->lc->current_call->localdesc->streams[0].rtp_addr, localip);
5797 BC_ASSERT_STRING_EQUAL(pauline->lc->current_call->resultdesc->streams[0].rtp_addr, "");
5798 }
5799 end_call(marie, pauline);
5800 linphone_core_manager_destroy(marie);
5801 linphone_core_manager_destroy(pauline);
5802 }
5803
call_with_ice_without_stun(void)5804 static void call_with_ice_without_stun(void){
5805 LinphoneCoreManager * marie = linphone_core_manager_new( "marie_rc");
5806 LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
5807
5808 linphone_core_set_stun_server(marie->lc, NULL);
5809 linphone_core_set_stun_server(pauline->lc, NULL);
5810 _call_with_ice_base(marie, pauline, TRUE, TRUE, TRUE, FALSE);
5811
5812 linphone_core_manager_destroy(marie);
5813 linphone_core_manager_destroy(pauline);
5814 }
5815
call_with_ice_without_stun2(void)5816 static void call_with_ice_without_stun2(void){
5817 LinphoneCoreManager * marie = linphone_core_manager_new( "marie_rc");
5818 LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
5819
5820 //linphone_core_set_stun_server(marie->lc, NULL);
5821 linphone_core_set_stun_server(pauline->lc, NULL);
5822 _call_with_ice_base(marie, pauline, TRUE, TRUE, TRUE, FALSE);
5823
5824 linphone_core_manager_destroy(marie);
5825 linphone_core_manager_destroy(pauline);
5826 }
5827
call_with_zrtp_configured_calling_side(void)5828 static void call_with_zrtp_configured_calling_side(void) {
5829 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
5830 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
5831
5832 call_with_zrtp_configured_calling_base(marie,pauline);
5833
5834 /* now set other encryptions mode for receiver(marie), we shall always fall back to caller preference: ZRTP */
5835 linphone_core_set_media_encryption(marie->lc, LinphoneMediaEncryptionDTLS);
5836 call_with_zrtp_configured_calling_base(marie,pauline);
5837
5838 linphone_core_set_media_encryption(marie->lc, LinphoneMediaEncryptionSRTP);
5839 call_with_zrtp_configured_calling_base(marie,pauline);
5840
5841
5842 linphone_core_set_media_encryption(marie->lc, LinphoneMediaEncryptionNone);
5843
5844 linphone_core_set_user_agent(pauline->lc, "Natted Linphone", NULL);
5845 linphone_core_set_user_agent(marie->lc, "Natted Linphone", NULL);
5846 call_with_zrtp_configured_calling_base(marie,pauline);
5847
5848 linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce);
5849 linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce);
5850 call_with_zrtp_configured_calling_base(marie,pauline);
5851
5852 linphone_core_manager_destroy(marie);
5853 linphone_core_manager_destroy(pauline);
5854
5855
5856 }
5857
call_with_zrtp_configured_callee_side(void)5858 static void call_with_zrtp_configured_callee_side(void) {
5859 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
5860 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
5861
5862 call_with_zrtp_configured_callee_base(marie,pauline);
5863
5864 linphone_core_set_user_agent(pauline->lc, "Natted Linphone", NULL);
5865 linphone_core_set_user_agent(marie->lc, "Natted Linphone", NULL);
5866 call_with_zrtp_configured_callee_base(marie,pauline);
5867
5868 linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce);
5869 linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce);
5870 call_with_zrtp_configured_callee_base(marie,pauline);
5871
5872 linphone_core_manager_destroy(marie);
5873 linphone_core_manager_destroy(pauline);
5874 }
5875
quick_call(LinphoneCoreManager * m1,LinphoneCoreManager * m2)5876 static bool_t quick_call(LinphoneCoreManager *m1, LinphoneCoreManager *m2){
5877 linphone_core_invite_address(m1->lc, m2->identity);
5878 if (!BC_ASSERT_TRUE(wait_for(m1->lc, m2->lc, &m2->stat.number_of_LinphoneCallIncomingReceived, 1)))
5879 return FALSE;
5880 linphone_call_accept(linphone_core_get_current_call(m2->lc));
5881 if (!BC_ASSERT_TRUE(wait_for(m1->lc, m2->lc, &m2->stat.number_of_LinphoneCallStreamsRunning, 1)))
5882 return FALSE;
5883 if (!BC_ASSERT_TRUE(wait_for(m1->lc, m2->lc, &m1->stat.number_of_LinphoneCallStreamsRunning, 1)))
5884 return FALSE;
5885 return TRUE;
5886 }
5887
call_with_encryption_mandatory(bool_t caller_has_encryption_mandatory)5888 static void call_with_encryption_mandatory(bool_t caller_has_encryption_mandatory){
5889 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
5890 LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
5891 LinphoneCallStats *marie_stats, *pauline_stats;
5892 /*marie doesn't support ZRTP at all*/
5893 marie->lc->zrtp_not_available_simulation=1;
5894
5895 /*pauline requests encryption to be mandatory*/
5896 linphone_core_set_media_encryption(pauline->lc, LinphoneMediaEncryptionZRTP);
5897 linphone_core_set_media_encryption_mandatory(pauline->lc, TRUE);
5898
5899 if (!caller_has_encryption_mandatory){
5900 if (!BC_ASSERT_TRUE(quick_call(marie, pauline))) goto end;
5901 }else{
5902 if (!BC_ASSERT_TRUE(quick_call(pauline, marie))) goto end;
5903 }
5904 wait_for_until(pauline->lc, marie->lc, NULL, 0, 2000);
5905
5906 /*assert that no RTP packets have been sent or received by Pauline*/
5907 /*testing packet_sent doesn't work, because packets dropped by the transport layer are counted as if they were sent.*/
5908 #if 0
5909 BC_ASSERT_EQUAL(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline->lc))->rtp_stats.packet_sent, 0, int, "%i");
5910 #endif
5911 /*however we can trust packet_recv from the other party instead */
5912 marie_stats = linphone_call_get_audio_stats(linphone_core_get_current_call(marie->lc));
5913 pauline_stats = linphone_call_get_audio_stats(linphone_core_get_current_call(pauline->lc));
5914 BC_ASSERT_EQUAL((int)marie_stats->rtp_stats.packet_recv, 0, int, "%i");
5915 BC_ASSERT_EQUAL((int)pauline_stats->rtp_stats.packet_recv, 0, int, "%i");
5916 linphone_call_stats_unref(marie_stats);
5917 linphone_call_stats_unref(pauline_stats);
5918 end_call(marie, pauline);
5919
5920 end:
5921 linphone_core_manager_destroy(marie);
5922 linphone_core_manager_destroy(pauline);
5923 }
5924
call_from_plain_rtp_to_zrtp(void)5925 static void call_from_plain_rtp_to_zrtp(void){
5926 call_with_encryption_mandatory(FALSE);
5927 }
5928
call_from_zrtp_to_plain_rtp(void)5929 static void call_from_zrtp_to_plain_rtp(void){
5930 call_with_encryption_mandatory(TRUE);
5931 }
5932
v6_to_v4_call_without_relay(void)5933 static void v6_to_v4_call_without_relay(void){
5934 LinphoneCoreManager* marie;
5935 LinphoneCoreManager* pauline;
5936 bctbx_list_t *lcs = NULL;
5937
5938 if (liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){
5939 marie = linphone_core_manager_new("marie_rc");
5940 pauline = linphone_core_manager_new2("pauline_tcp_rc", FALSE);
5941
5942 lcs = bctbx_list_append(lcs, marie->lc);
5943 lcs = bctbx_list_append(lcs, pauline->lc);
5944 linphone_core_enable_ipv6(pauline->lc, FALSE);
5945 /*RTP symmetric must be enabled for this test to pass, because the IPv4-only client cannot send by itself to
5946 * the IPv6 address in the SDP*/
5947 lp_config_set_int(linphone_core_get_config(pauline->lc), "rtp", "symmetric", 1);
5948 linphone_core_manager_start(pauline, TRUE);
5949
5950 if (BC_ASSERT_TRUE(call(marie,pauline))){
5951 check_media_direction(marie, linphone_core_get_current_call(marie->lc), lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionInvalid);
5952
5953 liblinphone_tester_check_rtcp(marie,pauline);
5954 end_call(marie,pauline);
5955 }
5956 linphone_core_manager_destroy(marie);
5957 linphone_core_manager_destroy(pauline);
5958 bctbx_list_free(lcs);
5959
5960 }else ms_warning("Test skipped, dual stack not available");
5961 }
5962
v6_call_over_nat_64(void)5963 static void v6_call_over_nat_64(void){
5964 LinphoneCoreManager* marie;
5965 LinphoneCoreManager* pauline;
5966
5967 if (!liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){
5968
5969 marie = linphone_core_manager_new("marie_nat64_rc");
5970 pauline = linphone_core_manager_new("pauline_nat64_rc");
5971
5972 linphone_core_set_user_agent(pauline->lc, "Natted Linphone", NULL);
5973 linphone_core_set_user_agent(marie->lc, "Natted Linphone", NULL);
5974
5975 BC_ASSERT_TRUE(wait_for_until(pauline->lc, NULL, &pauline->stat.number_of_LinphoneRegistrationOk, 1, 2000));
5976 BC_ASSERT_TRUE(wait_for_until(pauline->lc, NULL, &marie->stat.number_of_LinphoneRegistrationOk, 1, 2000));
5977
5978
5979 BC_ASSERT_TRUE(call(marie,pauline));
5980
5981 liblinphone_tester_check_rtcp(marie,pauline);
5982 end_call(marie,pauline);
5983 linphone_core_manager_destroy(marie);
5984 linphone_core_manager_destroy(pauline);
5985
5986 }else ms_warning("Test skipped, no ipv6 nat64 available");
5987 }
5988
call_with_ice_in_ipv4_with_v6_enabled(void)5989 static void call_with_ice_in_ipv4_with_v6_enabled(void) {
5990 LinphoneCoreManager* marie;
5991 LinphoneCoreManager* pauline;
5992
5993 if (liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){
5994 marie = linphone_core_manager_new("marie_v4proxy_rc");
5995 pauline = linphone_core_manager_new("pauline_v4proxy_rc");
5996
5997 _call_with_ice_base(marie,pauline,TRUE,TRUE,TRUE,TRUE);
5998 linphone_core_manager_destroy(marie);
5999 linphone_core_manager_destroy(pauline);
6000 } else ms_warning("Test skipped, need both ipv6 and v4 available");
6001 }
6002
call_with_ice_ipv4_to_ipv6(void)6003 static void call_with_ice_ipv4_to_ipv6(void) {
6004 LinphoneCoreManager* marie;
6005 LinphoneCoreManager* pauline;
6006
6007 if (liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){
6008 marie = linphone_core_manager_new("marie_v4proxy_rc");
6009 pauline = linphone_core_manager_new("pauline_tcp_rc");
6010
6011 _call_with_ice_base(marie,pauline,TRUE,TRUE,TRUE,TRUE);
6012 linphone_core_manager_destroy(marie);
6013 linphone_core_manager_destroy(pauline);
6014 } else ms_warning("Test skipped, need both ipv6 and v4 available");
6015 }
6016
call_with_ice_ipv6_to_ipv4(void)6017 static void call_with_ice_ipv6_to_ipv4(void) {
6018 LinphoneCoreManager* marie;
6019 LinphoneCoreManager* pauline;
6020
6021 if (liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){
6022 marie = linphone_core_manager_new("marie_rc");
6023 pauline = linphone_core_manager_new("pauline_v4proxy_rc");
6024
6025 _call_with_ice_base(marie, pauline,TRUE,TRUE,TRUE,TRUE);
6026 linphone_core_manager_destroy(marie);
6027 linphone_core_manager_destroy(pauline);
6028 } else ms_warning("Test skipped, need both ipv6 and v4 available");
6029 }
6030
call_with_ice_ipv6_to_ipv6(void)6031 static void call_with_ice_ipv6_to_ipv6(void) {
6032 LinphoneCoreManager* marie;
6033 LinphoneCoreManager* pauline;
6034
6035 if (liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){
6036 marie = linphone_core_manager_new("marie_rc");
6037 pauline = linphone_core_manager_new("pauline_tcp_rc");
6038
6039 _call_with_ice_base(marie, pauline,TRUE,TRUE,TRUE,TRUE);
6040 linphone_core_manager_destroy(marie);
6041 linphone_core_manager_destroy(pauline);
6042 } else ms_warning("Test skipped, need both ipv6 and v4 available");
6043 }
6044
my_call_state_changed_cb(LinphoneCore * lc,LinphoneCall * call,LinphoneCallState state,const char * text)6045 static void my_call_state_changed_cb(LinphoneCore *lc, LinphoneCall*call, LinphoneCallState state, const char *text){
6046 if (state == LinphoneCallError){
6047 linphone_core_set_network_reachable(lc, FALSE);
6048 }
6049 }
6050
6051 /*This test simulates a case where a 404 not found is received from server when attempting to make a call,
6052 * and the app decides to immediately shutdown the network reachability*/
call_with_network_reachable_down_in_callback(void)6053 static void call_with_network_reachable_down_in_callback(void){
6054 LinphoneCoreManager* marie;
6055 LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(linphone_factory_get());
6056 LinphoneCall *call;
6057
6058 linphone_core_cbs_set_call_state_changed(cbs, my_call_state_changed_cb);
6059
6060 marie = linphone_core_manager_new("laure_rc_udp");
6061
6062 linphone_core_add_callbacks(marie->lc, cbs);
6063
6064 call = linphone_core_invite(marie->lc, "inexistant_username_xbfuuuf");
6065 BC_ASSERT_PTR_NOT_NULL(call);
6066 BC_ASSERT_TRUE(wait_for(marie->lc, NULL, &marie->stat.number_of_LinphoneCallError, 1));
6067
6068 linphone_core_cbs_unref(cbs);
6069 linphone_core_manager_destroy(marie);
6070 }
6071
recreate_zrtpdb_when_corrupted(void)6072 static void recreate_zrtpdb_when_corrupted(void) {
6073 #ifdef SQLITE_STORAGE_ENABLED
6074 LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
6075 LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc");
6076
6077 if (BC_ASSERT_TRUE(linphone_core_media_encryption_supported(marie->lc,LinphoneMediaEncryptionZRTP))) {
6078 void *db;
6079 const char* db_file;
6080 const char *filepath;
6081 const char *filepath2;
6082 const char *corrupt = "corrupt mwahahahaha";
6083 FILE *f;
6084
6085 remove(bc_tester_file("tmpZIDCacheMarie.sqlite"));
6086 filepath = bc_tester_file("tmpZIDCacheMarie.sqlite");
6087 remove(bc_tester_file("tmpZIDCachePauline.sqlite"));
6088 filepath2 = bc_tester_file("tmpZIDCachePauline.sqlite");
6089 linphone_core_set_media_encryption(marie->lc,LinphoneMediaEncryptionZRTP);
6090 linphone_core_set_media_encryption(pauline->lc,LinphoneMediaEncryptionZRTP);
6091 linphone_core_set_zrtp_secrets_file(marie->lc, filepath);
6092 linphone_core_set_zrtp_secrets_file(pauline->lc, filepath2);
6093
6094 BC_ASSERT_TRUE(call(pauline,marie));
6095 linphone_call_set_authentication_token_verified(linphone_core_get_current_call(marie->lc), TRUE);
6096 linphone_call_set_authentication_token_verified(linphone_core_get_current_call(pauline->lc), TRUE);
6097 BC_ASSERT_TRUE(linphone_call_get_authentication_token_verified(linphone_core_get_current_call(marie->lc)));
6098 BC_ASSERT_TRUE(linphone_call_get_authentication_token_verified(linphone_core_get_current_call(pauline->lc)));
6099 end_call(marie, pauline);
6100
6101 db = linphone_core_get_zrtp_cache_db(marie->lc);
6102 BC_ASSERT_PTR_NOT_NULL(db);
6103
6104 BC_ASSERT_TRUE(call(pauline,marie));
6105 BC_ASSERT_TRUE(linphone_call_get_authentication_token_verified(linphone_core_get_current_call(marie->lc)));
6106 BC_ASSERT_TRUE(linphone_call_get_authentication_token_verified(linphone_core_get_current_call(pauline->lc)));
6107 end_call(marie, pauline);
6108
6109 //Corrupt db file
6110 db_file = linphone_core_get_zrtp_secrets_file(marie->lc);
6111 BC_ASSERT_PTR_NOT_NULL(db_file);
6112
6113 f = fopen(db_file, "wb");
6114 fwrite(corrupt, 1, sizeof(corrupt), f);
6115 fclose(f);
6116
6117 //Simulate relaunch of linphone core marie
6118 linphone_core_set_zrtp_secrets_file(marie->lc, filepath);
6119 db = linphone_core_get_zrtp_cache_db(marie->lc);
6120 BC_ASSERT_PTR_NULL(db);
6121
6122 BC_ASSERT_TRUE(call(pauline,marie));
6123 linphone_call_set_authentication_token_verified(linphone_core_get_current_call(marie->lc), TRUE);
6124 linphone_call_set_authentication_token_verified(linphone_core_get_current_call(pauline->lc), TRUE);
6125 BC_ASSERT_TRUE(linphone_call_get_authentication_token_verified(linphone_core_get_current_call(marie->lc)));
6126 BC_ASSERT_TRUE(linphone_call_get_authentication_token_verified(linphone_core_get_current_call(pauline->lc)));
6127 end_call(marie, pauline);
6128
6129 BC_ASSERT_TRUE(call(pauline,marie));
6130 BC_ASSERT_FALSE(linphone_call_get_authentication_token_verified(linphone_core_get_current_call(marie->lc)));
6131 BC_ASSERT_FALSE(linphone_call_get_authentication_token_verified(linphone_core_get_current_call(pauline->lc)));
6132 end_call(marie, pauline);
6133
6134 //Db file should be recreated after corruption
6135 //Simulate relaunch of linphone core marie
6136 linphone_core_set_zrtp_secrets_file(marie->lc, filepath);
6137
6138 BC_ASSERT_TRUE(call(pauline,marie));
6139 linphone_call_set_authentication_token_verified(linphone_core_get_current_call(marie->lc), TRUE);
6140 linphone_call_set_authentication_token_verified(linphone_core_get_current_call(pauline->lc), TRUE);
6141 BC_ASSERT_TRUE(linphone_call_get_authentication_token_verified(linphone_core_get_current_call(marie->lc)));
6142 BC_ASSERT_TRUE(linphone_call_get_authentication_token_verified(linphone_core_get_current_call(pauline->lc)));
6143 end_call(marie, pauline);
6144
6145 db = linphone_core_get_zrtp_cache_db(marie->lc);
6146 BC_ASSERT_PTR_NOT_NULL(db);
6147 db_file = linphone_core_get_zrtp_secrets_file(marie->lc);
6148 BC_ASSERT_PTR_NOT_NULL(db_file);
6149
6150 BC_ASSERT_TRUE(call(pauline,marie));
6151 BC_ASSERT_TRUE(linphone_call_get_authentication_token_verified(linphone_core_get_current_call(marie->lc)));
6152 BC_ASSERT_TRUE(linphone_call_get_authentication_token_verified(linphone_core_get_current_call(pauline->lc)));
6153 end_call(marie, pauline);
6154 }
6155
6156 linphone_core_manager_destroy(marie);
6157 linphone_core_manager_destroy(pauline);
6158 #endif /* SQLITE_STORAGE_ENABLED */
6159 }
6160
6161 test_t call_tests[] = {
6162 TEST_NO_TAG("Early declined call", early_declined_call),
6163 TEST_NO_TAG("Call declined", call_declined),
6164 TEST_NO_TAG("Call declined with error", call_declined_with_error),
6165 TEST_NO_TAG("Cancelled call", cancelled_call),
6166 TEST_NO_TAG("Early cancelled call", early_cancelled_call),
6167 TEST_NO_TAG("Call with DNS timeout", call_with_dns_time_out),
6168 TEST_NO_TAG("Cancelled ringing call", cancelled_ringing_call),
6169 TEST_NO_TAG("Call busy when calling self", call_busy_when_calling_self),
6170 TEST_NO_TAG("Simple call", simple_call),
6171 TEST_NO_TAG("Simple call with no SIP transport", simple_call_with_no_sip_transport),
6172 TEST_NO_TAG("Simple call with UDP", simple_call_with_udp),
6173 TEST_ONE_TAG("Call terminated automatically by linphone_core_destroy", automatic_call_termination, "LeaksMemory"),
6174 TEST_NO_TAG("Call with http proxy", call_with_http_proxy),
6175 TEST_NO_TAG("Call with timed-out bye", call_with_timed_out_bye),
6176 TEST_NO_TAG("Direct call over IPv6", direct_call_over_ipv6),
6177 TEST_NO_TAG("Call IPv6 to IPv4 without relay", v6_to_v4_call_without_relay),
6178 TEST_NO_TAG("IPv6 call over NAT64", v6_call_over_nat_64),
6179 TEST_ONE_TAG("Call with ICE in IPv4 with IPv6 enabled", call_with_ice_in_ipv4_with_v6_enabled, "ICE"),
6180 TEST_ONE_TAG("Call with ICE IPv4 to IPv6", call_with_ice_ipv4_to_ipv6, "ICE"),
6181 TEST_ONE_TAG("Call with ICE IPv6 to IPv4", call_with_ice_ipv6_to_ipv4, "ICE"),
6182 TEST_ONE_TAG("Call with ICE IPv6 to IPv6", call_with_ice_ipv6_to_ipv6, "ICE"),
6183 TEST_NO_TAG("Outbound call with multiple proxy possible", call_outbound_with_multiple_proxy),
6184 TEST_NO_TAG("Audio call recording", audio_call_recording_test),
6185 #if 0 /* not yet activated because not implemented */
6186 TEST_NO_TAG("Multiple answers to a call", multiple_answers_call),
6187 #endif
6188 TEST_NO_TAG("Multiple answers to a call with media relay", multiple_answers_call_with_media_relay),
6189 TEST_NO_TAG("Call with media relay", call_with_media_relay),
6190 TEST_NO_TAG("Call with media relay (random ports)", call_with_media_relay_random_ports),
6191 TEST_NO_TAG("Simple call compatibility mode", simple_call_compatibility_mode),
6192 TEST_NO_TAG("Early-media call", early_media_call),
6193 TEST_ONE_TAG("Early-media call with ICE", early_media_call_with_ice, "ICE"),
6194 TEST_NO_TAG("Early-media call with ringing", early_media_call_with_ringing),
6195 TEST_NO_TAG("Early-media call with ringing and network changing", early_media_call_with_ringing_and_network_changing),
6196 TEST_NO_TAG("Early-media call with updated media session", early_media_call_with_session_update),
6197 TEST_NO_TAG("Early-media call with updated codec", early_media_call_with_codec_update),
6198 TEST_NO_TAG("Call terminated by caller", call_terminated_by_caller),
6199 TEST_NO_TAG("Call without SDP", call_with_no_sdp),
6200 TEST_NO_TAG("Call without SDP and ACK without SDP", call_with_no_sdp_ack_without_sdp),
6201 TEST_NO_TAG("Call paused resumed", call_paused_resumed),
6202 TEST_NO_TAG("Call paused resumed with sip packets looses", call_paused_resumed_with_sip_packets_losses),
6203 TEST_NO_TAG("Call paused by both parties", call_paused_by_both),
6204 TEST_NO_TAG("Call paused resumed with loss", call_paused_resumed_with_loss),
6205 TEST_NO_TAG("Call paused resumed from callee", call_paused_resumed_from_callee),
6206 TEST_NO_TAG("SRTP call", srtp_call),
6207 TEST_NO_TAG("ZRTP call", zrtp_call),
6208 TEST_NO_TAG("ZRTP silent call", zrtp_silent_call),
6209 TEST_NO_TAG("ZRTP SAS call", zrtp_sas_call),
6210 TEST_NO_TAG("ZRTP Cipher call", zrtp_cipher_call),
6211 TEST_NO_TAG("DTLS SRTP call", dtls_srtp_call),
6212 TEST_NO_TAG("DTLS SRTP call with media relay", dtls_srtp_call_with_media_realy),
6213 TEST_NO_TAG("SRTP call with declined srtp", call_with_declined_srtp),
6214 TEST_NO_TAG("SRTP call paused and resumed", call_srtp_paused_and_resumed),
6215 TEST_NO_TAG("Call with file player", call_with_file_player),
6216 TEST_NO_TAG("Call with mkv file player", call_with_mkv_file_player),
6217 TEST_ONE_TAG("Audio call with ICE no matching audio codecs", audio_call_with_ice_no_matching_audio_codecs, "ICE"),
6218 TEST_ONE_TAG("SRTP ice call", srtp_ice_call, "ICE"),
6219 TEST_ONE_TAG("ZRTP ice call", zrtp_ice_call, "ICE"),
6220 TEST_ONE_TAG("ZRTP ice call with relay", zrtp_ice_call_with_relay, "ICE"),
6221 TEST_ONE_TAG("DTLS SRTP ice call", dtls_srtp_ice_call, "ICE"),
6222 TEST_ONE_TAG("DTLS ice call with relay", dtls_ice_call_with_relay, "ICE"),
6223 TEST_NO_TAG("Call with privacy", call_with_privacy),
6224 TEST_NO_TAG("Call with privacy 2", call_with_privacy2),
6225 TEST_NO_TAG("Call rejected because of wrong credential", call_rejected_because_wrong_credentials),
6226 TEST_NO_TAG("Call rejected without 403 because of wrong credential", call_rejected_without_403_because_wrong_credentials),
6227 TEST_NO_TAG("Call rejected without 403 because of wrong credential and no auth req cb", call_rejected_without_403_because_wrong_credentials_no_auth_req_cb),
6228 TEST_ONE_TAG("Call with ICE", call_with_ice, "ICE"),
6229 TEST_ONE_TAG("Call with ICE IPv6", call_with_ice_ipv6, "ICE"),
6230 TEST_ONE_TAG("Call with ICE without SDP", call_with_ice_no_sdp, "ICE"),
6231 TEST_ONE_TAG("Call with ICE (random ports)", call_with_ice_random_ports, "ICE"),
6232 TEST_ONE_TAG("Call with ICE (forced relay)", call_with_ice_forced_relay, "ICE"),
6233 TEST_ONE_TAG("Call from ICE to not ICE", ice_to_not_ice, "ICE"),
6234 TEST_ONE_TAG("Call from not ICE to ICE", not_ice_to_ice, "ICE"),
6235 TEST_ONE_TAG("Call with ICE added by reINVITE", ice_added_by_reinvite, "ICE"),
6236 TEST_NO_TAG("Call with custom headers", call_with_custom_headers),
6237 TEST_NO_TAG("Call with custom SDP attributes", call_with_custom_sdp_attributes),
6238 TEST_NO_TAG("Call caller with custom header or sdp", call_caller_with_custom_header_or_sdp_attributes),
6239 TEST_NO_TAG("Call callee with custom header or sdp", call_callee_with_custom_header_or_sdp_attributes),
6240 TEST_NO_TAG("Call established with rejected INFO", call_established_with_rejected_info),
6241 TEST_NO_TAG("Call established with rejected RE-INVITE", call_established_with_rejected_reinvite),
6242 TEST_NO_TAG("Call established with rejected incoming RE-INVITE", call_established_with_rejected_incoming_reinvite),
6243 TEST_NO_TAG("Call established with rejected RE-INVITE in error", call_established_with_rejected_reinvite_with_error),
6244 TEST_NO_TAG("Call established with rejected RE-INVITE with trans pending error", call_established_with_rejected_reinvite_with_trans_pending_error),
6245 TEST_NO_TAG("Call established with complex rejected operation", call_established_with_complex_rejected_operation),
6246 TEST_NO_TAG("Call established with rejected info during re-invite", call_established_with_rejected_info_during_reinvite),
6247 TEST_NO_TAG("Call redirected by callee", call_redirect),
6248 TEST_NO_TAG("Call with specified codec bitrate", call_with_specified_codec_bitrate),
6249 TEST_NO_TAG("Call with no audio codec", call_with_no_audio_codec),
6250 TEST_NO_TAG("Call with in-dialog UPDATE request", call_with_in_dialog_update),
6251 TEST_NO_TAG("Call with in-dialog very early call request", call_with_very_early_call_update),
6252 TEST_NO_TAG("Call with in-dialog codec change", call_with_in_dialog_codec_change),
6253 TEST_NO_TAG("Call with in-dialog codec change no sdp", call_with_in_dialog_codec_change_no_sdp),
6254 TEST_NO_TAG("Call with pause no SDP on resume", call_with_paused_no_sdp_on_resume),
6255 TEST_NO_TAG("Call with early media and no SDP in 200 Ok", call_with_early_media_and_no_sdp_in_200),
6256 TEST_ONE_TAG("Call with ICE and no SDP in 200 OK", call_with_early_media_ice_and_no_sdp_in_200, "ICE"),
6257 TEST_NO_TAG("Call with custom supported tags", call_with_custom_supported_tags),
6258 TEST_NO_TAG("Call log from taken from asserted id", call_log_from_taken_from_p_asserted_id),
6259 TEST_NO_TAG("Incoming INVITE with invalid SDP", incoming_invite_with_invalid_sdp),
6260 TEST_NO_TAG("Outgoing INVITE with invalid ACK SDP", outgoing_invite_with_invalid_sdp),
6261 TEST_NO_TAG("Call with generic CN", call_with_generic_cn),
6262 TEST_NO_TAG("Call with transport change after released", call_with_transport_change_after_released),
6263 TEST_NO_TAG("Unsuccessful call with transport change after released", unsucessfull_call_with_transport_change_after_released),
6264 TEST_NO_TAG("Simple stereo call with L16", simple_stereo_call_l16),
6265 TEST_NO_TAG("Simple stereo call with opus", simple_stereo_call_opus),
6266 TEST_NO_TAG("Simple mono call with opus", simple_mono_call_opus),
6267 TEST_NO_TAG("Call with FQDN in SDP", call_with_fqdn_in_sdp),
6268 TEST_NO_TAG("Call with RTP IO mode", call_with_rtp_io_mode),
6269 TEST_NO_TAG("Call with generic NACK RTCP feedback", call_with_generic_nack_rtcp_feedback),
6270 TEST_NO_TAG("Call with complex late offering", call_with_complex_late_offering),
6271 #ifdef SQLITE_STORAGE_ENABLED
6272 TEST_NO_TAG("Call log working if no db set", call_logs_if_no_db_set),
6273 TEST_NO_TAG("Call log storage migration from rc to db", call_logs_migrate),
6274 TEST_NO_TAG("Call log storage in sqlite database", call_logs_sqlite_storage),
6275 #endif
6276 TEST_NO_TAG("Call with custom RTP Modifier", call_with_custom_rtp_modifier),
6277 TEST_NO_TAG("Call paused resumed with custom RTP Modifier", call_paused_resumed_with_custom_rtp_modifier),
6278 TEST_NO_TAG("Call record with custom RTP Modifier", call_record_with_custom_rtp_modifier),
6279 TEST_NO_TAG("Call with network switch", call_with_network_switch),
6280 TEST_NO_TAG("Call with network switch and no recovery possible", call_with_network_switch_no_recovery),
6281 TEST_ONE_TAG("Recovered call on network switch in early state 1", recovered_call_on_network_switch_in_early_state_1, "CallRecovery"),
6282 TEST_ONE_TAG("Recovered call on network switch in early state 1 (udp caller)", recovered_call_on_network_switch_in_early_state_1_udp, "CallRecovery"),
6283 TEST_ONE_TAG("Recovered call on network switch in early state 2", recovered_call_on_network_switch_in_early_state_2, "CallRecovery"),
6284 TEST_ONE_TAG("Recovered call on network switch in early state 3", recovered_call_on_network_switch_in_early_state_3, "CallRecovery"),
6285 TEST_ONE_TAG("Recovered call on network switch in early state 4", recovered_call_on_network_switch_in_early_state_4, "CallRecovery"),
6286 TEST_ONE_TAG("Recovered call on network switch during re-invite 1", recovered_call_on_network_switch_during_reinvite_1, "CallRecovery"),
6287 TEST_ONE_TAG("Recovered call on network switch during re-invite 2", recovered_call_on_network_switch_during_reinvite_2, "CallRecovery"),
6288 TEST_ONE_TAG("Recovered call on network switch during re-invite 3", recovered_call_on_network_switch_during_reinvite_3, "CallRecovery"),
6289 TEST_ONE_TAG("Recovered call on network switch during re-invite 4", recovered_call_on_network_switch_during_reinvite_4, "CallRecovery"),
6290 TEST_ONE_TAG("Call with network switch in paused state", call_with_network_switch_in_paused_state, "CallRecovery"),
6291 TEST_ONE_TAG("Call with network switch in paused by remote state", call_with_network_switch_in_paused_by_remote_state, "CallRecovery"),
6292 TEST_ONE_TAG("Call with network switch and ICE", call_with_network_switch_and_ice, "ICE"),
6293 TEST_ONE_TAG("Call with network switch, ICE and RTT", call_with_network_switch_ice_and_rtt, "ICE"),
6294 TEST_NO_TAG("Call with network switch with socket refresh", call_with_network_switch_and_socket_refresh),
6295 TEST_NO_TAG("Call with SIP and RTP independant switches", call_with_sip_and_rtp_independant_switches),
6296 TEST_NO_TAG("Call with rtcp-mux", call_with_rtcp_mux),
6297 TEST_NO_TAG("Call with rtcp-mux not accepted", call_with_rtcp_mux_not_accepted),
6298 TEST_ONE_TAG("Call with ICE and rtcp-mux", call_with_ice_and_rtcp_mux, "ICE"),
6299 TEST_ONE_TAG("Call with ICE and rtcp-mux without ICE re-invite", call_with_ice_and_rtcp_mux_without_reinvite, "ICE"),
6300 TEST_ONE_TAG("Call with ICE with default candidate not stun", call_with_ice_with_default_candidate_not_stun, "ICE"),
6301 TEST_ONE_TAG("Call with ICE without stun server", call_with_ice_without_stun, "ICE"),
6302 TEST_ONE_TAG("Call with ICE without stun server one side", call_with_ice_without_stun2, "ICE"),
6303 TEST_NO_TAG("Call with ZRTP configured calling side only", call_with_zrtp_configured_calling_side),
6304 TEST_NO_TAG("Call with ZRTP configured receiver side only", call_with_zrtp_configured_callee_side),
6305 TEST_NO_TAG("Call from plain RTP to ZRTP mandatory should be silent", call_from_plain_rtp_to_zrtp),
6306 TEST_NO_TAG("Call ZRTP mandatory to plain RTP should be silent", call_from_zrtp_to_plain_rtp),
6307 TEST_NO_TAG("Call with network reachable down in callback", call_with_network_reachable_down_in_callback),
6308 TEST_NO_TAG("Call terminated with reason", terminate_call_with_error),
6309 TEST_NO_TAG("Call cancelled with reason", cancel_call_with_error),
6310 TEST_NO_TAG("Call accepted, other ringing device receive CANCEL with reason", cancel_other_device_after_accept),
6311 TEST_NO_TAG("Call declined, other ringing device receive CANCEL with reason", cancel_other_device_after_decline),
6312 TEST_NO_TAG("Recreate ZRTP db file when corrupted", recreate_zrtpdb_when_corrupted)
6313 };
6314
6315 test_suite_t call_test_suite = {"Single Call", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
6316 sizeof(call_tests) / sizeof(call_tests[0]), call_tests};
6317