Commit d508dff5 authored by jehan's avatar jehan Committed by jehan

Add support for sdp media attribute maxptime.

parent ce5ae0c7
......@@ -477,6 +477,7 @@ static void sdp_parse_payload_types(belle_sdp_media_description_t *media_desc, S
payload_type_set_avpf_params(pt, avpf_params);
stream->payloads=bctbx_list_append ( stream->payloads,pt );
stream->ptime=belle_sdp_mime_parameter_get_ptime ( mime_param );
stream->maxptime=belle_sdp_mime_parameter_get_max_ptime ( mime_param );
ms_message ( "Found payload %s/%i fmtp=%s",pt->mime_type,pt->clock_rate,
pt->send_fmtp ? pt->send_fmtp : "" );
}
......
......@@ -420,6 +420,7 @@ static void initiate_outgoing(MSFactory* factory, const SalStreamDescription *lo
result->rtcp_port=remote_answer->rtcp_port;
result->bandwidth=remote_answer->bandwidth;
result->ptime=remote_answer->ptime;
result->maxptime=remote_answer->maxptime;
}else{
result->rtp_port=0;
}
......@@ -475,6 +476,7 @@ static void initiate_incoming(MSFactory *factory, const SalStreamDescription *lo
result->rtcp_port=0; /* rtcp not supported yet*/
result->bandwidth=remote_offer->bandwidth;
result->ptime=remote_offer->ptime;
result->maxptime=remote_offer->maxptime;
result->ttl=remote_offer->ttl;
result->multicast_role = SalMulticastReceiver;
} else {
......@@ -484,6 +486,7 @@ static void initiate_incoming(MSFactory *factory, const SalStreamDescription *lo
result->rtcp_port=local_cap->rtcp_port;
result->bandwidth=local_cap->bandwidth;
result->ptime=local_cap->ptime;
result->maxptime=local_cap->maxptime;
}
if (sal_stream_description_has_srtp(result) == TRUE) {
......
......@@ -259,6 +259,7 @@ typedef struct SalStreamDescription{
MSList *already_assigned_payloads; /**<list of PayloadType offered in the past, used for correct allocation of payload type numbers*/
int bandwidth;
int ptime;
int maxptime;
SalStreamDir dir;
SalSrtpCryptoAlgo crypto[SAL_CRYPTO_ALGO_MAX];
unsigned int crypto_local_tag;
......
......@@ -2080,6 +2080,11 @@ RtpProfile * MediaSessionPrivate::makeProfile (const SalMediaDescription *md, co
pt->normal_bitrate = PayloadTypeHandler::getMinBandwidth(pt->normal_bitrate, bandwidth * 1000);
} else
pt->normal_bitrate = bandwidth * 1000;
if (desc->maxptime > 0) {// follow the same schema for maxptime as for ptime. (I.E add it to fmtp)
ostringstream os;
os << "maxptime=" << desc->maxptime;
payload_type_append_send_fmtp(pt, os.str().c_str());
}
if (desc->ptime > 0)
upPtime = desc->ptime;
if (upPtime > 0) {
......
......@@ -307,6 +307,7 @@ void SalCallOp::sdpProcess () {
if (mResult->streams[i].rtp_port != 0) { // If the stream was accepted
strcpy(mResult->streams[i].rtp_addr, mRemoteMedia->streams[i].rtp_addr);
mResult->streams[i].ptime = mRemoteMedia->streams[i].ptime;
mResult->streams[i].maxptime = mRemoteMedia->streams[i].maxptime;
mResult->streams[i].bandwidth = mRemoteMedia->streams[i].bandwidth;
mResult->streams[i].rtp_port = mRemoteMedia->streams[i].rtp_port;
strcpy(mResult->streams[i].rtcp_addr, mRemoteMedia->streams[i].rtcp_addr);
......
......@@ -570,7 +570,53 @@ end:
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void call_with_maxptime(void) {
LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_create(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
bool_t call_ok;
//to make sure bandwidth for ptime 20 is 80kbits/s
linphone_core_enable_ipv6(marie->lc,FALSE);
linphone_core_enable_ipv6(pauline->lc,FALSE);
linphone_core_manager_start(marie, TRUE);
linphone_core_manager_start(pauline, TRUE);
/*Force marie to play from file: if soundcard is used and it is silient, then vbr mode will drop down the bitrate
Note that a play file is already set by linphone_core_manager_new() (but not used)*/
linphone_core_set_use_files(marie->lc, TRUE);
disable_all_audio_codecs_except_one(marie->lc, "PCMA", 8000);
disable_all_audio_codecs_except_one(pauline->lc, "PCMA", 8000);
LinphoneCallParams *marie_params = linphone_core_create_call_params(marie->lc, NULL);
linphone_call_params_add_custom_sdp_media_attribute(marie_params,LinphoneStreamTypeAudio, "maxptime","40");
LinphoneCallParams *pauline_params = linphone_core_create_call_params(marie->lc, NULL);
linphone_call_params_add_custom_sdp_media_attribute(pauline_params,LinphoneStreamTypeAudio, "maxptime","40");
linphone_core_set_upload_ptime(pauline->lc, 100);
linphone_core_set_upload_ptime(marie->lc, 100);
BC_ASSERT_TRUE((call_ok=call_with_params(pauline,marie,pauline_params,marie_params)));
linphone_call_params_unref(marie_params);
linphone_call_params_unref(pauline_params);
if (!call_ok) goto end;
liblinphone_tester_check_rtcp(marie,pauline);
/*wait a bit that bitstreams are stabilized*/
wait_for_until(marie->lc, pauline->lc, NULL, 0, 2000);
//network-birate = ((codec-birate*ptime/8) + RTP header + UDP header + IP header)*8/ptime;
BC_ASSERT_LOWER(linphone_core_manager_get_mean_audio_up_bw(pauline), 80, int, "%i");
BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_up_bw(pauline), 70, int, "%i"); //without maxptime=40, it should be 67
BC_ASSERT_LOWER(linphone_core_manager_get_mean_audio_up_bw(marie), 80, int, "%i");
BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_up_bw(marie), 70, int, "%i"); //without maxptime=40, it should be 67
end_call(pauline, marie);
end:
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
void disable_all_codecs(const bctbx_list_t* elem, LinphoneCoreManager* call){
......@@ -4953,6 +4999,7 @@ test_t call_tests[] = {
TEST_NO_TAG("Call established with rejected info during re-invite", call_established_with_rejected_info_during_reinvite),
TEST_NO_TAG("Call redirected by callee", call_redirect),
TEST_NO_TAG("Call with specified codec bitrate", call_with_specified_codec_bitrate),
TEST_NO_TAG("Call with maxptime", call_with_maxptime),
TEST_NO_TAG("Call with no audio codec", call_with_no_audio_codec),
TEST_NO_TAG("Call with in-dialog UPDATE request", call_with_in_dialog_update),
TEST_NO_TAG("Call with in-dialog very early call request", call_with_very_early_call_update),
......
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