Commit fe0b8028 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Fixed outgoing SRTP call without audio + added test

parent 0795ef13
......@@ -1614,7 +1614,7 @@ void MediaSessionPrivate::makeLocalMediaDescription () {
if (sdpMediaAttributes)
md->streams[mainAudioStreamIndex].custom_sdp_attributes = sal_custom_sdp_attribute_clone(sdpMediaAttributes);
md->streams[mainVideoStreamIndex].proto = md->streams[mainAudioStreamIndex].proto;
md->streams[mainVideoStreamIndex].proto = getParams()->getMediaProto();
md->streams[mainVideoStreamIndex].dir = getParams()->getPrivate()->getSalVideoDirection();
md->streams[mainVideoStreamIndex].type = SalVideo;
md->streams[mainVideoStreamIndex].rtcp_mux = rtcpMux;
......@@ -1645,7 +1645,7 @@ void MediaSessionPrivate::makeLocalMediaDescription () {
if (sdpMediaAttributes)
md->streams[mainVideoStreamIndex].custom_sdp_attributes = sal_custom_sdp_attribute_clone(sdpMediaAttributes);
md->streams[mainTextStreamIndex].proto = md->streams[mainAudioStreamIndex].proto;
md->streams[mainTextStreamIndex].proto = getParams()->getMediaProto();
md->streams[mainTextStreamIndex].dir = SalStreamSendRecv;
md->streams[mainTextStreamIndex].type = SalText;
md->streams[mainTextStreamIndex].rtcp_mux = rtcpMux;
......
......@@ -474,6 +474,59 @@ end:
linphone_core_manager_destroy(pauline);
}
static void video_srtp_call_without_audio(void) {
/*
* The purpose of this test is to ensure SRTP is still present in the SDP event if the audio stream is disabled
*/
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
LinphoneCallParams *pauline_params;
const LinphoneCallParams *params;
LinphoneVideoPolicy vpol;
vpol.automatically_accept = TRUE;
vpol.automatically_initiate = TRUE;
if (!linphone_core_media_encryption_supported(marie->lc, LinphoneMediaEncryptionSRTP)) goto end;
linphone_core_set_media_encryption(pauline->lc, LinphoneMediaEncryptionSRTP);
linphone_core_set_video_policy(marie->lc, &vpol);
linphone_core_enable_video_capture(marie->lc, TRUE);
linphone_core_enable_video_display(marie->lc, TRUE);
linphone_core_set_video_policy(pauline->lc, &vpol);
linphone_core_enable_video_capture(pauline->lc, TRUE);
linphone_core_enable_video_display(pauline->lc, TRUE);
pauline_params = linphone_core_create_call_params(pauline->lc, NULL);
linphone_call_params_enable_audio(pauline_params, FALSE);
linphone_call_params_enable_video(pauline_params, TRUE);
BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(pauline_params), LinphoneMediaEncryptionSRTP, int, "%i");
linphone_core_invite_address_with_params(pauline->lc, marie->identity, pauline_params);
linphone_call_params_unref(pauline_params);
if (!BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallIncomingReceived,1))) goto end;
/*assert that SRTP is being used*/
params = linphone_call_get_params(linphone_core_get_current_call(pauline->lc));
BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(params) , LinphoneMediaEncryptionSRTP, int, "%d");
params = linphone_call_get_remote_params(linphone_core_get_current_call(marie->lc));
BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(params) , LinphoneMediaEncryptionSRTP, int, "%d");
linphone_core_accept_call(marie->lc, linphone_core_get_current_call(marie->lc));
wait_for_until(marie->lc, pauline->lc, NULL, 0, 1000);
if (!BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,1))) goto end;
/*assert that SRTP is being used*/
params = linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc));
BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(params) , LinphoneMediaEncryptionSRTP, int, "%d");
params = linphone_call_get_current_params(linphone_core_get_current_call(marie->lc));
BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(params) , LinphoneMediaEncryptionSRTP, int, "%d");
end_call(pauline, marie);
end:
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
test_t call_secure_tests[] = {
TEST_NO_TAG("SRTP call", srtp_call),
TEST_NO_TAG("SRTP call with different crypto suite", srtp_call_with_different_crypto_suite),
......@@ -496,6 +549,7 @@ test_t call_secure_tests[] = {
TEST_NO_TAG("SRTP mandatory called by non SRTP", srtp_mandatory_called_by_non_srtp),
TEST_NO_TAG("SRTP DTLS mandatory called by non SRTP DTLS", srtp_dtls_mandatory_called_by_non_srtp_dtls),
TEST_NO_TAG("ZRTP mandatory called by SRTP", zrtp_mandatory_called_by_srtp),
TEST_NO_TAG("Video SRTP call without audio", video_srtp_call_without_audio),
};
test_suite_t call_secure_test_suite = {"Secure Call", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment