Commit 405ca6ab authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Fix stream indexes computed too late

parent c8f1f3b6
......@@ -50,6 +50,8 @@ coreapi/help/chatroom
coreapi/help/doc/
coreapi/help/helloworld
coreapi/help/registration
coreapi/help/realtimetext_receiver
coreapi/help/realtimetext_sender
coreapi/test_ecc
coreapi/test_lsd
gtk/version_date.h
......
......@@ -750,8 +750,8 @@ void linphone_call_make_local_media_description(LinphoneCall *call) {
/* Deactivate inactive streams. */
for (i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; i++) {
if (md->streams[i].dir == SalStreamInactive) {
md->streams[i].rtp_port = 0;
if (md->streams[i].rtp_port == 0) {
md->streams[i].dir = SalStreamInactive;
md->streams[i].rtcp_port = 0;
if (call->biggestdesc && i < call->biggestdesc->nb_streams) {
md->streams[i].proto = call->biggestdesc->streams[i].proto;
......@@ -1022,7 +1022,7 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddr
call->main_audio_stream_index = LINPHONE_CALL_STATS_AUDIO;
call->main_video_stream_index = LINPHONE_CALL_STATS_VIDEO;
call->main_text_stream_index = params->realtimetext_enabled ? LINPHONE_CALL_STATS_TEXT : -1;
call->main_text_stream_index = params->realtimetext_enabled ? LINPHONE_CALL_STATS_TEXT : STREAM_INDEX_UNKNOWN;
call->dir=LinphoneCallOutgoing;
call->core=lc;
......@@ -1088,15 +1088,32 @@ void linphone_call_set_compatible_incoming_call_parameters(LinphoneCall *call, c
}
static void linphone_call_compute_streams_indexes(LinphoneCall *call, SalMediaDescription *md) {
int i;
for (i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; i++) {
if (!sal_stream_description_active(&md->streams[i])) continue;
if (md->streams[i].type == SalAudio && call->main_audio_stream_index == STREAM_INDEX_UNKNOWN) {
call->main_audio_stream_index = i;
ms_message("audio stream index updated: %i", i);
} else if (md->streams[i].type == SalVideo && call->main_video_stream_index == STREAM_INDEX_UNKNOWN) {
call->main_video_stream_index = i;
ms_message("video stream index updated: %i", i);
} else if (md->streams[i].type == SalText && call->main_text_stream_index == STREAM_INDEX_UNKNOWN) {
call->main_text_stream_index = i;
ms_message("text stream index updated: %i", i);
}
}
}
LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op){
LinphoneCall *call = belle_sip_object_new(LinphoneCall);
SalMediaDescription *md;
LinphoneFirewallPolicy fpol;
int i;
call->main_audio_stream_index = -1;
call->main_video_stream_index = -1;
call->main_text_stream_index = -1;
call->main_audio_stream_index = STREAM_INDEX_UNKNOWN;
call->main_video_stream_index = STREAM_INDEX_UNKNOWN;
call->main_text_stream_index = STREAM_INDEX_UNKNOWN;
call->dir=LinphoneCallIncoming;
sal_op_set_user_pointer(op,call);
......@@ -1107,6 +1124,9 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
sal_op_cnx_ip_to_0000_if_sendonly_enable(op,lp_config_get_default_int(lc->config,"sip","cnx_ip_to_0000_if_sendonly_enabled",0));
md = sal_call_get_remote_media_description(op);
linphone_call_compute_streams_indexes(call, md);
if (lc->sip_conf.ping_with_options){
#ifdef BUILD_UPNP
if (lc->upnp != NULL && linphone_core_get_firewall_policy(lc)==LinphonePolicyUseUpnp &&
......@@ -1142,7 +1162,6 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
/*set privacy*/
call->current_params->privacy=(LinphonePrivacyMask)sal_op_get_privacy(call->op);
/*set video support */
md=sal_call_get_remote_media_description(op);
call->params->has_video = linphone_core_video_enabled(lc) && lc->video_policy.automatically_accept;
if (md) {
// It is licit to receive an INVITE without SDP
......@@ -1159,19 +1178,6 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
md->streams[i].multicast_role = SalMulticastReceiver;
strncpy(call->media_ports[i].multicast_ip,md->streams[i].rtp_addr,sizeof(call->media_ports[i].multicast_ip));
}
if (sal_stream_description_active(&md->streams[i])) {
if (md->streams[i].type == SalAudio) {
call->main_audio_stream_index = i;
ms_message("audio stream index updated: %i", i);
} else if (md->streams[i].type == SalVideo) {
call->main_video_stream_index = i;
ms_message("video stream index updated: %i", i);
} else if (md->streams[i].type == SalText) {
call->main_text_stream_index = i;
ms_message("text stream index updated: %i", i);
}
}
}
}
}
......
......@@ -627,11 +627,13 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call)
const struct addrinfo *ai;
IceCheckList *audio_check_list;
IceCheckList *video_check_list;
IceCheckList *text_check_list;
const char *server = linphone_core_get_stun_server(lc);
if ((server == NULL) || (call->ice_session == NULL)) return -1;
audio_check_list = ice_session_check_list(call->ice_session, 0);
video_check_list = ice_session_check_list(call->ice_session, 1);
text_check_list = ice_session_check_list(call->ice_session, 2);
if (audio_check_list == NULL) return -1;
if (call->af==AF_INET6){
......@@ -661,6 +663,12 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call)
ice_add_local_candidate(video_check_list, "host", local_addr, call->media_ports[call->main_video_stream_index].rtcp_port, 2, NULL);
call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateInProgress;
}
if (call->params->realtimetext_enabled && (text_check_list != NULL)
&& (ice_check_list_state(text_check_list) != ICL_Completed) && (ice_check_list_candidates_gathered(text_check_list) == FALSE)) {
ice_add_local_candidate(text_check_list, "host", local_addr, call->media_ports[call->main_text_stream_index].rtp_port, 1, NULL);
ice_add_local_candidate(text_check_list, "host", local_addr, call->media_ports[call->main_text_stream_index].rtcp_port, 2, NULL);
call->stats[LINPHONE_CALL_STATS_TEXT].ice_state = LinphoneIceStateInProgress;
}
ms_message("ICE: gathering candidate from [%s]",server);
/* Gather local srflx candidates. */
......
......@@ -240,6 +240,8 @@ typedef struct _PortConfig{
int rtcp_port;
}PortConfig;
#define STREAM_INDEX_UNKNOWN -1
struct _LinphoneCall{
belle_sip_object_t base;
void *user_data;
......
......@@ -57,8 +57,10 @@ SalMediaDescription *sal_media_description_new(){
SalMediaDescription *md=ms_new0(SalMediaDescription,1);
int i;
md->refcount=1;
for(i=0;i<SAL_MEDIA_DESCRIPTION_MAX_STREAMS;i++){
for(i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; i++) {
md->streams[i].dir=SalStreamInactive;
md->streams[i].rtp_port = 0;
md->streams[i].rtcp_port = 0;
}
return md;
}
......@@ -86,8 +88,7 @@ void sal_media_description_unref(SalMediaDescription *md){
}
}
SalStreamDescription *sal_media_description_find_stream(SalMediaDescription *md,
SalMediaProto proto, SalStreamType type){
SalStreamDescription *sal_media_description_find_stream(SalMediaDescription *md, SalMediaProto proto, SalStreamType type){
int i;
for(i=0;i<SAL_MEDIA_DESCRIPTION_MAX_STREAMS;++i){
SalStreamDescription *ss=&md->streams[i];
......
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