diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 9b18f01c443890b222dc08af866f960452a2ae71..9f4f248f0455e8d2bee03bd1c548ba77788ee0ea 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -5722,9 +5722,12 @@ const char **linphone_core_get_video_devices(const LinphoneCore *lc) { bctbx_list_t *linphone_core_get_sound_devices_list(const LinphoneCore *lc) { bctbx_list_t *cards_list = NULL; + const char **cards = lc->sound_conf.cards; - for (const char *c = *cards; c; c = *++cards) { - cards_list = bctbx_list_append(cards_list, (char *)c); + if (cards) { + for (const char *c = *cards; c; c = *++cards) { + cards_list = bctbx_list_append(cards_list, bctbx_strdup(c)); + } } return cards_list; } @@ -5733,9 +5736,10 @@ bctbx_list_t *linphone_core_get_video_devices_list(const LinphoneCore *lc) { bctbx_list_t *cards_list = NULL; const char **cards = lc->video_conf.cams; - if (cards) + if (cards) { for (const char *c = *cards; c; c = *++cards) - cards_list = bctbx_list_append(cards_list, (char *)c); + cards_list = bctbx_list_append(cards_list, bctbx_strdup(c)); + } return cards_list; } diff --git a/coreapi/misc.c b/coreapi/misc.c index ed330f1969502d88fb43c4ecac0fe55320083e11..4173fdcebcb6baf0f2310cbd7f4195b6536ea48a 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -1015,7 +1015,7 @@ const char **linphone_core_get_supported_file_formats(LinphoneCore *core) { return core->supported_formats; } -bctbx_list_t *linphone_core_get_supported_file_formats_list(LinphoneCore *core) { +bctbx_list_t *linphone_core_get_supported_file_formats_list(const LinphoneCore *core) { bctbx_list_t *file_formats = NULL; file_formats = bctbx_list_append(file_formats, ms_strdup("wav")); if (ms_factory_lookup_filter_by_id(core->factory, MS_MKV_RECORDER_ID)) { diff --git a/include/linphone/core.h b/include/linphone/core.h index 33f21250b7a49bf586b32e836d038a69a64a9850..373cd80eee035aa7e4a433b299e51c467c20550b 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -5168,7 +5168,7 @@ LINPHONE_PUBLIC const char *linphone_core_get_file_transfer_server(LinphoneCore * @return The supported formats, typically 'wav' and 'mkv'. \bctbx_list{char *} @notnil @tobefreed * @ingroup media_parameters **/ -LINPHONE_PUBLIC bctbx_list_t *linphone_core_get_supported_file_formats_list(LinphoneCore *core); +LINPHONE_PUBLIC bctbx_list_t *linphone_core_get_supported_file_formats_list(const LinphoneCore *core); /** * Returns whether a specific file format is supported. diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 4a135bfa1ff77fcb565b8dae80251f7dfab9e93d..08aeb073ca2e00afd16143be3e8aa377594cf500 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -4708,6 +4708,7 @@ void record_call(const char *filename, bool_t enableVideo, const char *video_cod disable_all_video_codecs_except_one(pauline->lc, video_codec); } else { ms_warning("call_recording(): the H264 payload has not been found. Only sound will be recorded"); + enableVideo = FALSE; } } #endif @@ -4735,11 +4736,14 @@ void record_call(const char *filename, bool_t enableVideo, const char *video_cod ms_message("call_recording(): start recording into %s", filepath); linphone_call_start_recording(callInst); } - if (strcmp(format, "mkv") == 0) { + if (strcmp(format, "mkv") == 0 && enableVideo) { VideoStream *pauline_vstream = (VideoStream *)linphone_call_get_stream(pauline_call, LinphoneStreamTypeVideo); /* make sure that Pauline receives a RTCP FIR (Full Intra Request) requested by Marie's recorder.*/ - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline_vstream->ms_video_stat.counter_rcvd_fir, 1)); + if (BC_ASSERT_PTR_NOT_NULL(pauline_vstream)) { + BC_ASSERT_TRUE( + wait_for(marie->lc, pauline->lc, &pauline_vstream->ms_video_stat.counter_rcvd_fir, 1)); + } } wait_for_until(marie->lc, pauline->lc, &dummy, 1, 5000); linphone_call_stop_recording(callInst); diff --git a/tester/eventapi_tester.c b/tester/eventapi_tester.c index 0b1325668d0dc9b5ad0c4446de739dac85110516..6c7535abf0c8b8c279c734faa8d1737179e313aa 100644 --- a/tester/eventapi_tester.c +++ b/tester/eventapi_tester.c @@ -49,7 +49,7 @@ static void subscribe_test_declined(void) { linphone_content_set_subtype(content, "somexml"); linphone_content_set_buffer(content, (const uint8_t *)subscribe_content, strlen(subscribe_content)); - pauline->decline_subscribe = TRUE; + pauline->subscribe_policy = DenySubscription; lev = linphone_core_subscribe(marie->lc, pauline->identity, "dodo", 600, content); linphone_event_ref(lev); @@ -615,6 +615,52 @@ static void out_of_dialog_notify(void) { linphone_core_manager_destroy(pauline); } +static void subscribe_notify_with_missing_200ok(void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneContent *content; + LinphoneEvent *lev; + int expires = 10; + bctbx_list_t *lcs = bctbx_list_append(NULL, marie->lc); + + lcs = bctbx_list_append(lcs, pauline->lc); + pauline->subscribe_policy = DoNothingWithSubscription; + + lev = linphone_core_create_subscribe(marie->lc, pauline->identity, "dodo", expires); + linphone_event_send_subscribe(lev, NULL); + + BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneSubscriptionOutgoingProgress, 1, 1000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneSubscriptionIncomingReceived, 1, 10000)); + + if (BC_ASSERT_PTR_NOT_NULL(pauline->lev)) { + sal_set_send_error(linphone_core_get_sal(pauline->lc), 1); /*to trash the message without generating error*/ + linphone_event_accept_subscription(pauline->lev); + sal_set_send_error(linphone_core_get_sal(pauline->lc), 0); /*normal behavior*/ + } + + BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneSubscriptionActive, 1, 5000)); + + content = linphone_core_create_content(marie->lc); + linphone_content_set_type(content, "application"); + linphone_content_set_subtype(content, "somexml"); + linphone_content_set_buffer(content, (const uint8_t *)notify_content, strlen(notify_content)); + linphone_event_notify(pauline->lev, content); + + /*make sure marie receives the notify and transitions the subscribption to active state */ + BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneSubscriptionActive, 1, 5000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_NotifyReceived, 1, 5000)); + + linphone_event_terminate(pauline->lev); + linphone_event_unref(lev); + BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneSubscriptionTerminated, 1, 5000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneSubscriptionTerminated, 1, 5000)); + + linphone_content_unref(content); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + bctbx_list_free(lcs); +} + test_t event_tests[] = { TEST_ONE_TAG("Subscribe declined", subscribe_test_declined, "presence"), TEST_ONE_TAG("Subscribe terminated by subscriber", subscribe_test_terminated_by_subscriber, "presence"), @@ -630,12 +676,11 @@ test_t event_tests[] = { subscribe_test_destroy_core_before_event_terminate, "presence", "LeaksMemory"), + TEST_ONE_TAG("Subscribe with missing 200 ok", subscribe_notify_with_missing_200ok, "LeaksMemory"), TEST_ONE_TAG("Publish", publish_test, "presence"), TEST_ONE_TAG("Publish without expires", publish_without_expires, "presence"), TEST_ONE_TAG("Publish without automatic refresh", publish_no_auto_test, "presence"), - TEST_ONE_TAG("Out of dialog notify", out_of_dialog_notify, "presence") - -}; + TEST_ONE_TAG("Out of dialog notify", out_of_dialog_notify, "presence")}; test_suite_t event_test_suite = {"Event", NULL, diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 06cc1dd0f62a6e2853c9c8748643ec61beb51751..978e1bdff9f3725a4c7eab50c8df891c7bbfa858 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -470,13 +470,18 @@ typedef struct _stats { int number_of_LinphoneMagicSearchLdapHaveMoreResults; } stats; +typedef enum _LinphoneCoreManagerSubscribePolicy { + AcceptSubscription, + DenySubscription, + DoNothingWithSubscription +} LinphoneCoreManagerSubscribePolicy; + typedef struct _LinphoneCoreManager { LinphoneCoreCbs *cbs; LinphoneCore *lc; stats stat; LinphoneAddress *identity; LinphoneEvent *lev; - bool_t decline_subscribe; int number_of_bcunit_error_at_creation; char *phone_alias; char *rc_path; @@ -485,8 +490,9 @@ typedef struct _LinphoneCoreManager { char *lime_database_path; char *zrtp_secrets_database_path; char *app_group_id; - bool_t main_core; void *user_info; + bool_t main_core; + LinphoneCoreManagerSubscribePolicy subscribe_policy; } LinphoneCoreManager; typedef struct _LinphoneConferenceServer { diff --git a/tester/tester.c b/tester/tester.c index ab702adce68e177d954a3b2e577193bcf7e60799..fda835067a5bf1645a7f5691c76edbfc85420c9f 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -3523,12 +3523,14 @@ void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, Li break; case LinphoneSubscriptionActive: counters->number_of_LinphoneSubscriptionActive++; - if (linphone_event_get_subscription_dir(lev) == LinphoneSubscriptionIncoming) { - mgr->lev = lev; - if (strcmp(linphone_event_get_name(lev), "conference") == 0) { - // TODO : Get LocalConfEventHandler and call handler->subscribeReceived(lev) - } else { - linphone_event_notify(lev, content); + if (mgr->subscribe_policy == AcceptSubscription) { + if (linphone_event_get_subscription_dir(lev) == LinphoneSubscriptionIncoming) { + mgr->lev = lev; + if (strcmp(linphone_event_get_name(lev), "conference") == 0) { + // TODO : Get LocalConfEventHandler and call handler->subscribeReceived(lev) + } else { + linphone_event_notify(lev, content); + } } } break; @@ -3583,8 +3585,16 @@ void linphone_subscribe_received(LinphoneCore *lc, BCTBX_UNUSED(const char *eventname), BCTBX_UNUSED(const LinphoneContent *content)) { LinphoneCoreManager *mgr = get_manager(lc); - if (!mgr->decline_subscribe) linphone_event_accept_subscription(lev); - else linphone_event_deny_subscription(lev, LinphoneReasonDeclined); + switch (mgr->subscribe_policy) { + case AcceptSubscription: + linphone_event_accept_subscription(lev); + break; + case DenySubscription: + linphone_event_deny_subscription(lev, LinphoneReasonDeclined); + break; + case DoNothingWithSubscription: + break; + } } void linphone_publish_state_changed(LinphoneCore *lc, LinphoneEvent *ev, LinphonePublishState state) {