}
-
-static SalMediaDescription *_create_local_media_description(LinphoneCore *lc, LinphoneCall *call, unsigned int session_id, unsigned int session_ver){
+void linphone_call_make_local_media_description(LinphoneCore *lc, LinphoneCall *call){
MSList *l;
PayloadType *pt;
+ SalMediaDescription *old_md=call->localdesc;
int i;
const char *me=linphone_core_get_identity(lc);
LinphoneAddress *addr=linphone_address_new(me);
const char *username=linphone_address_get_username (addr);
SalMediaDescription *md=sal_media_description_new();
+ bool_t keep_srtp_keys=lp_config_get_int(lc->config,"sip","keep_srtp_keys",0);
if (call->ping_time>0) {
linphone_core_adapt_to_network(lc,call->ping_time,&call->params);
}
- md->session_id=session_id;
- md->session_ver=session_ver;
+ md->session_id=(old_md ? old_md->session_id : (rand() & 0xfff));
+ md->session_ver=(old_md ? (old_md->session_ver+1) : (rand() & 0xfff));
md->nstreams=1;
strncpy(md->addr,call->localip,sizeof(md->addr));
strncpy(md->username,username,sizeof(md->username));
pt=payload_type_clone(rtp_profile_get_payload_from_mime(&av_profile,"telephone-event"));
l=ms_list_append(l,pt);
md->streams[0].payloads=l;
-
-
if (call->params.has_video){
md->nstreams++;
for(i=0; i<md->nstreams; i++) {
if (md->streams[i].proto == SalProtoRtpSavp) {
- md->streams[i].crypto[0].tag = 1;
- md->streams[i].crypto[0].algo = AES_128_SHA1_80;
- if (!generate_b64_crypto_key(30, md->streams[i].crypto[0].master_key))
- md->streams[i].crypto[0].algo = 0;
- md->streams[i].crypto[1].tag = 2;
- md->streams[i].crypto[1].algo = AES_128_SHA1_32;
- if (!generate_b64_crypto_key(30, md->streams[i].crypto[1].master_key))
- md->streams[i].crypto[1].algo = 0;
- md->streams[i].crypto[2].algo = 0;
+ if (keep_srtp_keys && old_md && old_md->streams[i].proto==SalProtoRtpSavp){
+ int j;
+ for(j=0;j<SAL_CRYPTO_ALGO_MAX;++j){
+ memcpy(&md->streams[i].crypto[j],&old_md->streams[i].crypto[j],sizeof(SalSrtpCryptoAlgo));
+ }
+ }else{
+ md->streams[i].crypto[0].tag = 1;
+ md->streams[i].crypto[0].algo = AES_128_SHA1_80;
+ if (!generate_b64_crypto_key(30, md->streams[i].crypto[0].master_key))
+ md->streams[i].crypto[0].algo = 0;
+ md->streams[i].crypto[1].tag = 2;
+ md->streams[i].crypto[1].algo = AES_128_SHA1_32;
+ if (!generate_b64_crypto_key(30, md->streams[i].crypto[1].master_key))
+ md->streams[i].crypto[1].algo = 0;
+ md->streams[i].crypto[2].algo = 0;
+ }
}
}
update_media_description_from_stun(md,&call->ac,&call->vc);
linphone_core_update_ice_state_in_call_stats(call);
}
linphone_address_destroy(addr);
- return md;
-}
-
-void update_local_media_description(LinphoneCore *lc, LinphoneCall *call){
- SalMediaDescription *md=call->localdesc;
- if (md== NULL) {
- call->localdesc = create_local_media_description(lc,call);
- } else {
- call->localdesc = _create_local_media_description(lc,call,md->session_id,md->session_ver+1);
- sal_media_description_unref(md);
- }
-}
-
-SalMediaDescription *create_local_media_description(LinphoneCore *lc, LinphoneCall *call){
- unsigned int id=rand() & 0xfff;
- return _create_local_media_description(lc,call,id,id);
+ call->localdesc=md;
+ if (old_md) sal_media_description_unref(old_md);
}
static int find_port_offset(LinphoneCore *lc, SalStreamType type){
ms_warning("Case is MS_VIDEO_DECODER_DECODING_ERRORS");
linphone_call_send_vfu_request(call);
break;
- case MS_VIDEO_DECODER_FIRST_IMAGE_DECODED:
- ms_message("First video frame decoded successfully");
- if (call->nextVideoFrameDecoded._func != NULL)
- call->nextVideoFrameDecoded._func(call, call->nextVideoFrameDecoded._user_data);
- break;
+ case MS_VIDEO_DECODER_FIRST_IMAGE_DECODED:
+ ms_message("First video frame decoded successfully");
+ if (call->nextVideoFrameDecoded._func != NULL)
+ call->nextVideoFrameDecoded._func(call, call->nextVideoFrameDecoded._user_data);
+ break;
default:
ms_warning("Unhandled event %i", event_id);
break;
#endif
void linphone_call_set_next_video_frame_decoded_callback(LinphoneCall *call, LinphoneCallCbFunc cb, void* user_data) {
- call->nextVideoFrameDecoded._func = cb;
- call->nextVideoFrameDecoded._user_data = user_data;
+ call->nextVideoFrameDecoded._func = cb;
+ call->nextVideoFrameDecoded._user_data = user_data;
#ifdef VIDEO_ENABLED
- ms_filter_call_method_noarg(call->videostream->decoder, MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION);
+ ms_filter_call_method_noarg(call->videostream->decoder, MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION);
#endif
}
linphone_call_init_media_streams(call);
if (lc->ringstream==NULL)
audio_stream_prepare_sound(call->audiostream,lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard);
- call->localdesc=create_local_media_description(lc,call);
+ linphone_call_make_local_media_description(lc,call);
if (!lc->sip_conf.sdp_200_ack){
call->media_pending=TRUE;
sal_call_set_local_media_description(call->op,call->localdesc);
bool_t propose_early_media=lp_config_get_int(lc->config,"sip","incoming_calls_early_media",FALSE);
const char *ringback_tone=linphone_core_get_remote_ringback_tone (lc);
- call->localdesc=create_local_media_description(lc,call);
+ linphone_call_make_local_media_description(lc,call);
sal_call_set_local_media_description(call->op,call->localdesc);
md=sal_call_get_final_media_description(call->op);
if (md && sal_media_description_empty(md)){
call->videostream->ice_check_list = NULL;
}
call->params = *params;
- update_local_media_description(lc, call);
+ linphone_call_make_local_media_description(lc, call);
if ((call->ice_session != NULL) && !has_video && call->params.has_video) {
/* Defer call update until the ICE candidates gathering process has finished. */
ms_message("Defer call update to gather ICE candidates");
}
call->params.has_video &= linphone_core_media_description_contains_video_stream(sal_call_get_remote_media_description(call->op));
call->camera_active=call->params.has_video;
- update_local_media_description(lc,call);
+ linphone_call_make_local_media_description(lc,call);
if (call->ice_session != NULL) {
linphone_core_update_ice_from_remote_media_description(call, sal_call_get_remote_media_description(call->op));
#ifdef VIDEO_ENABLED
call->params=*params;
call->params.has_video &= linphone_core_media_description_contains_video_stream(sal_call_get_remote_media_description(call->op));
call->camera_active=call->params.has_video;
- update_local_media_description(lc,call);
+ linphone_call_make_local_media_description(lc,call);
sal_call_set_local_media_description(call->op,call->localdesc);
}
ms_warning("Cannot pause this call, it is not active.");
return -1;
}
- update_local_media_description(lc,call);
+ linphone_call_make_local_media_description(lc,call);
if (call->ice_session != NULL)
linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
if (sal_media_description_has_dir(call->resultdesc,SalStreamSendRecv)){
prevents the participants to hear it while the 200OK comes back.*/
if (call->audiostream) audio_stream_play(call->audiostream, NULL);
- update_local_media_description(lc,the_call);
+ linphone_call_make_local_media_description(lc,the_call);
if (call->ice_session != NULL)
linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
sal_call_set_local_media_description(call->op,call->localdesc);