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 ...@@ -50,6 +50,8 @@ coreapi/help/chatroom
coreapi/help/doc/ coreapi/help/doc/
coreapi/help/helloworld coreapi/help/helloworld
coreapi/help/registration coreapi/help/registration
coreapi/help/realtimetext_receiver
coreapi/help/realtimetext_sender
coreapi/test_ecc coreapi/test_ecc
coreapi/test_lsd coreapi/test_lsd
gtk/version_date.h gtk/version_date.h
......
...@@ -750,8 +750,8 @@ void linphone_call_make_local_media_description(LinphoneCall *call) { ...@@ -750,8 +750,8 @@ void linphone_call_make_local_media_description(LinphoneCall *call) {
/* Deactivate inactive streams. */ /* Deactivate inactive streams. */
for (i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; i++) { for (i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; i++) {
if (md->streams[i].dir == SalStreamInactive) { if (md->streams[i].rtp_port == 0) {
md->streams[i].rtp_port = 0; md->streams[i].dir = SalStreamInactive;
md->streams[i].rtcp_port = 0; md->streams[i].rtcp_port = 0;
if (call->biggestdesc && i < call->biggestdesc->nb_streams) { if (call->biggestdesc && i < call->biggestdesc->nb_streams) {
md->streams[i].proto = call->biggestdesc->streams[i].proto; md->streams[i].proto = call->biggestdesc->streams[i].proto;
...@@ -1022,7 +1022,7 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddr ...@@ -1022,7 +1022,7 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddr
call->main_audio_stream_index = LINPHONE_CALL_STATS_AUDIO; call->main_audio_stream_index = LINPHONE_CALL_STATS_AUDIO;
call->main_video_stream_index = LINPHONE_CALL_STATS_VIDEO; 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->dir=LinphoneCallOutgoing;
call->core=lc; call->core=lc;
...@@ -1088,15 +1088,32 @@ void linphone_call_set_compatible_incoming_call_parameters(LinphoneCall *call, c ...@@ -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 * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op){
LinphoneCall *call = belle_sip_object_new(LinphoneCall); LinphoneCall *call = belle_sip_object_new(LinphoneCall);
SalMediaDescription *md; SalMediaDescription *md;
LinphoneFirewallPolicy fpol; LinphoneFirewallPolicy fpol;
int i; int i;
call->main_audio_stream_index = -1; call->main_audio_stream_index = STREAM_INDEX_UNKNOWN;
call->main_video_stream_index = -1; call->main_video_stream_index = STREAM_INDEX_UNKNOWN;
call->main_text_stream_index = -1; call->main_text_stream_index = STREAM_INDEX_UNKNOWN;
call->dir=LinphoneCallIncoming; call->dir=LinphoneCallIncoming;
sal_op_set_user_pointer(op,call); sal_op_set_user_pointer(op,call);
...@@ -1106,6 +1123,9 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro ...@@ -1106,6 +1123,9 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
linphone_call_incoming_select_ip_version(call); linphone_call_incoming_select_ip_version(call);
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)); 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){ if (lc->sip_conf.ping_with_options){
#ifdef BUILD_UPNP #ifdef BUILD_UPNP
...@@ -1142,7 +1162,6 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro ...@@ -1142,7 +1162,6 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
/*set privacy*/ /*set privacy*/
call->current_params->privacy=(LinphonePrivacyMask)sal_op_get_privacy(call->op); call->current_params->privacy=(LinphonePrivacyMask)sal_op_get_privacy(call->op);
/*set video support */ /*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; call->params->has_video = linphone_core_video_enabled(lc) && lc->video_policy.automatically_accept;
if (md) { if (md) {
// It is licit to receive an INVITE without SDP // It is licit to receive an INVITE without SDP
...@@ -1159,19 +1178,6 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro ...@@ -1159,19 +1178,6 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
md->streams[i].multicast_role = SalMulticastReceiver; 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)); 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) ...@@ -627,11 +627,13 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call)
const struct addrinfo *ai; const struct addrinfo *ai;
IceCheckList *audio_check_list; IceCheckList *audio_check_list;
IceCheckList *video_check_list; IceCheckList *video_check_list;
IceCheckList *text_check_list;
const char *server = linphone_core_get_stun_server(lc); const char *server = linphone_core_get_stun_server(lc);
if ((server == NULL) || (call->ice_session == NULL)) return -1; if ((server == NULL) || (call->ice_session == NULL)) return -1;
audio_check_list = ice_session_check_list(call->ice_session, 0); audio_check_list = ice_session_check_list(call->ice_session, 0);
video_check_list = ice_session_check_list(call->ice_session, 1); 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 (audio_check_list == NULL) return -1;
if (call->af==AF_INET6){ if (call->af==AF_INET6){
...@@ -661,6 +663,12 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call) ...@@ -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); 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; 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); ms_message("ICE: gathering candidate from [%s]",server);
/* Gather local srflx candidates. */ /* Gather local srflx candidates. */
......
...@@ -544,7 +544,7 @@ static bool_t proto_compatible(SalMediaProto local, SalMediaProto remote) { ...@@ -544,7 +544,7 @@ static bool_t proto_compatible(SalMediaProto local, SalMediaProto remote) {
} }
static const SalStreamDescription *find_local_matching_stream(const SalMediaDescription *result, const SalMediaDescription *local_capabilities, const SalStreamDescription *remote_stream){ static const SalStreamDescription *find_local_matching_stream(const SalMediaDescription *result, const SalMediaDescription *local_capabilities, const SalStreamDescription *remote_stream){
int i; int i;
for(i=0;i<SAL_MEDIA_DESCRIPTION_MAX_STREAMS;++i){ for(i=0;i<SAL_MEDIA_DESCRIPTION_MAX_STREAMS;++i){
const SalStreamDescription *ss=&local_capabilities->streams[i]; const SalStreamDescription *ss=&local_capabilities->streams[i];
if (!sal_stream_description_active(ss)) continue; if (!sal_stream_description_active(ss)) continue;
......
...@@ -240,6 +240,8 @@ typedef struct _PortConfig{ ...@@ -240,6 +240,8 @@ typedef struct _PortConfig{
int rtcp_port; int rtcp_port;
}PortConfig; }PortConfig;
#define STREAM_INDEX_UNKNOWN -1
struct _LinphoneCall{ struct _LinphoneCall{
belle_sip_object_t base; belle_sip_object_t base;
void *user_data; void *user_data;
......
...@@ -57,8 +57,10 @@ SalMediaDescription *sal_media_description_new(){ ...@@ -57,8 +57,10 @@ SalMediaDescription *sal_media_description_new(){
SalMediaDescription *md=ms_new0(SalMediaDescription,1); SalMediaDescription *md=ms_new0(SalMediaDescription,1);
int i; int i;
md->refcount=1; 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].dir=SalStreamInactive;
md->streams[i].rtp_port = 0;
md->streams[i].rtcp_port = 0;
} }
return md; return md;
} }
...@@ -86,8 +88,7 @@ void sal_media_description_unref(SalMediaDescription *md){ ...@@ -86,8 +88,7 @@ void sal_media_description_unref(SalMediaDescription *md){
} }
} }
SalStreamDescription *sal_media_description_find_stream(SalMediaDescription *md, SalStreamDescription *sal_media_description_find_stream(SalMediaDescription *md, SalMediaProto proto, SalStreamType type){
SalMediaProto proto, SalStreamType type){
int i; int i;
for(i=0;i<SAL_MEDIA_DESCRIPTION_MAX_STREAMS;++i){ for(i=0;i<SAL_MEDIA_DESCRIPTION_MAX_STREAMS;++i){
SalStreamDescription *ss=&md->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