linphone_call_enable_camera(call,activated);
if ((activated && !linphone_call_params_video_enabled (cp))){
/*update the call to add the video stream*/
- linphone_call_enable_video(call,TRUE);
+ LinphoneCallParams *ncp=linphone_call_params_copy(cp);
+ linphone_call_params_enable_video(ncp,TRUE);
+ linphone_core_update_call(lc,call,ncp);
+ linphone_call_params_destroy (ncp);
linphonec_out("Trying to bring up video stream...\n");
}
}
}
}
-void linphone_call_enable_video(LinphoneCall *call, bool_t enabled)
-{
- LinphoneCore *lc=linphone_call_get_core(call);
- LinphoneCallParams *params=linphone_call_params_copy(linphone_call_get_current_params(call));
-
- linphone_call_params_enable_video(params, enabled);
- if (enabled == TRUE) {
- if (call->ice_session != NULL) {
- /* Defer call update until the ICE candidates gathering process has finished. */
- ms_message("Defer call update to gather ICE candidates");
- call->params = *params;
- update_local_media_description(lc, call);
- linphone_call_init_video_stream(call);
- video_stream_prepare_video(call->videostream);
- linphone_core_gather_ice_candidates(lc, call);
- } else {
- if (linphone_call_get_state(call) == LinphoneCallUpdatedByRemote) {
- linphone_core_accept_call_update(lc, call, params);
- } else {
- linphone_core_update_call(lc, call, params);
- }
- }
- } else {
- if ((call->ice_session != NULL) && (call->videostream != NULL)) {
- ice_session_remove_check_list(call->ice_session, call->videostream->ice_check_list);
- call->videostream->ice_check_list = NULL;
- }
- if (linphone_call_get_state(call) == LinphoneCallUpdatedByRemote) {
- linphone_core_accept_call_update(lc, call, params);
- } else {
- linphone_core_update_call(lc, call, params);
- }
- }
- linphone_call_params_destroy(params);
-}
-
static void linphone_call_destroy(LinphoneCall *obj)
{
if (obj->op!=NULL) {
break;
}
} else if (evt == ORTP_EVENT_ICE_GATHERING_FINISHED) {
- LinphoneCallParams *params;
+ if (evd->info.ice_processing_successful==TRUE) {
+ ice_session_compute_candidates_foundations(call->ice_session);
+ ice_session_eliminate_redundant_candidates(call->ice_session);
+ ice_session_choose_default_candidates(call->ice_session);
+ } else {
+ linphone_call_delete_ice_session(call);
+ }
switch (call->state) {
case LinphoneCallStreamsRunning:
+ linphone_core_start_update_call(call->core, call);
+ break;
case LinphoneCallUpdatedByRemote:
- if (evd->info.ice_processing_successful==TRUE) {
- ice_session_compute_candidates_foundations(call->ice_session);
- ice_session_eliminate_redundant_candidates(call->ice_session);
- ice_session_choose_default_candidates(call->ice_session);
- }
- params = linphone_call_params_copy(linphone_call_get_current_params(call));
- linphone_call_params_enable_video(params, TRUE);
- if (call->state == LinphoneCallStreamsRunning) {
- linphone_core_update_call(call->core, call, params);
- } else { /* LinphoneCallUpdatedByRemote */
- linphone_core_accept_call_update(call->core, call, params);
- }
- linphone_call_params_destroy(params);
+ linphone_core_start_accept_call_update(call->core, call);
break;
case LinphoneCallOutgoingInit:
+ linphone_call_stop_media_streams(call);
+ linphone_core_start_invite(call->core, call, NULL);
+ break;
default:
linphone_call_stop_media_streams(call);
- if (evd->info.ice_processing_successful==TRUE) {
- ice_session_compute_candidates_foundations(call->ice_session);
- ice_session_eliminate_redundant_candidates(call->ice_session);
- ice_session_choose_default_candidates(call->ice_session);
- } else {
- linphone_call_delete_ice_session(call);
- }
- if (call->state==LinphoneCallOutgoingInit) {
- linphone_core_start_invite(call->core,call,NULL);
- } else {
- linphone_core_notify_incoming_call(call->core,call);
- }
+ linphone_core_notify_incoming_call(call->core, call);
break;
}
} else if (evt == ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED) {
- SalMediaDescription *md;
- linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
- sal_call_set_local_media_description(call->op,call->localdesc);
- sal_call_accept(call->op);
- md=sal_call_get_final_media_description(call->op);
- if (md && !sal_media_description_empty(md))
- linphone_core_update_streams (call->core,call,md);
- linphone_call_set_state(call,LinphoneCallStreamsRunning,"Connected (streams running)");
+ linphone_core_start_accept_call_update(call->core, call);
} else if (evt == ORTP_EVENT_ICE_RESTART_NEEDED) {
ice_session_restart(call->ice_session);
ice_session_set_role(call->ice_session, IR_Controlling);
ms_free(tmp);
}
+int linphone_core_start_update_call(LinphoneCore *lc, LinphoneCall *call){
+ const char *subject;
+ call->camera_active=call->params.has_video;
+ update_local_media_description(lc,call);
+ if (call->ice_session != NULL)
+ linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
+
+ if (call->params.in_conference){
+ subject="Conference";
+ }else{
+ subject="Media change";
+ }
+ if (lc->vtable.display_status)
+ lc->vtable.display_status(lc,_("Modifying call parameters..."));
+ sal_call_set_local_media_description (call->op,call->localdesc);
+ return sal_call_update(call->op,subject);
+}
+
/**
* @ingroup call_control
* Updates a running call according to supplied call parameters or parameters changed in the LinphoneCore.
int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params){
int err=0;
if (params!=NULL){
- const char *subject;
- call->params=*params;
- call->camera_active=call->params.has_video;
- update_local_media_description(lc,call);
- if (call->ice_session != NULL)
- linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
-
- if (params->in_conference){
- subject="Conference";
- }else{
- subject="Media change";
+ if ((call->ice_session != NULL) && (call->videostream != NULL) && !params->has_video) {
+ ice_session_remove_check_list(call->ice_session, call->videostream->ice_check_list);
+ call->videostream->ice_check_list = NULL;
+ }
+ if ((call->ice_session != NULL) && ((ice_session_state(call->ice_session) != IS_Completed) || (call->params.has_video != 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 = *params;
+ update_local_media_description(lc, call);
+ if (call->params.has_video) {
+ linphone_call_init_video_stream(call);
+ video_stream_prepare_video(call->videostream);
+ if (linphone_core_gather_ice_candidates(lc,call)<0) {
+ /* Ice candidates gathering failed, proceed with the call anyway. */
+ linphone_call_delete_ice_session(call);
+ } else return err;
+ }
}
- if (lc->vtable.display_status)
- lc->vtable.display_status(lc,_("Modifying call parameters..."));
- sal_call_set_local_media_description (call->op,call->localdesc);
- err=sal_call_update(call->op,subject);
+ err = linphone_core_start_update_call(lc, call);
}else{
#ifdef VIDEO_ENABLED
if (call->videostream!=NULL){
return -1;
}
+int linphone_core_start_accept_call_update(LinphoneCore *lc, LinphoneCall *call){
+ SalMediaDescription *md;
+ if (call->ice_session != NULL) {
+ if (ice_session_nb_losing_pairs(call->ice_session) > 0) {
+ /* Defer the sending of the answer until there are no losing pairs left. */
+ return 0;
+ }
+ linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
+ }
+ sal_call_set_local_media_description(call->op,call->localdesc);
+ sal_call_accept(call->op);
+ md=sal_call_get_final_media_description(call->op);
+ if (md && !sal_media_description_empty(md))
+ linphone_core_update_streams (lc,call,md);
+ linphone_call_set_state(call,LinphoneCallStreamsRunning,"Connected (streams running)");
+ return 0;
+}
+
/**
* @ingroup call_control
* Accept call modifications initiated by other end.
* @return 0 if sucessful, -1 otherwise (actually when this function call is performed outside ot #LinphoneCallUpdatedByRemote state).
**/
int linphone_core_accept_call_update(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params){
- SalMediaDescription *md;
+ bool_t old_has_video = call->params.has_video;
if (call->state!=LinphoneCallUpdatedByRemote){
ms_error("linphone_core_accept_update(): invalid state %s to call this function.",
linphone_call_state_to_string(call->state));
update_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));
- if (ice_session_nb_losing_pairs(call->ice_session) > 0) {
- /* Defer the sending of the answer until there are no losing pairs left. */
- return 0;
+ if (!ice_session_candidates_gathered(call->ice_session)) {
+ if ((call->params.has_video) && (call->params.has_video != old_has_video)) {
+ linphone_call_init_video_stream(call);
+ video_stream_prepare_video(call->videostream);
+ if (linphone_core_gather_ice_candidates(lc,call)<0) {
+ /* Ice candidates gathering failed, proceed with the call anyway. */
+ linphone_call_delete_ice_session(call);
+ } else return 0;
+ }
}
- linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
}
- sal_call_set_local_media_description(call->op,call->localdesc);
- sal_call_accept(call->op);
- md=sal_call_get_final_media_description(call->op);
- if (md && !sal_media_description_empty(md))
- linphone_core_update_streams (lc,call,md);
- linphone_call_set_state(call,LinphoneCallStreamsRunning,"Connected (streams running)");
+ linphone_core_start_accept_call_update(lc, call);
return 0;
}
**/
bool_t linphone_call_echo_limiter_enabled(const LinphoneCall *call);
-/**
- * Enable or disable video for this call.
- * @param call
- * @param enabled
- *
- * @ingroup media_parameters
- */
-void linphone_call_enable_video(LinphoneCall *call, bool_t enabled);
-
/*keep this in sync with mediastreamer2/msvolume.h*/
/**
bool_t linphone_core_inc_invite_pending(LinphoneCore*lc);
-void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call);
-
bool_t linphone_core_in_call(const LinphoneCore *lc);
LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc);
void linphone_core_stop_waiting(LinphoneCore *lc);
int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, LinphoneProxyConfig *dest_proxy);
+int linphone_core_start_update_call(LinphoneCore *lc, LinphoneCall *call);
+int linphone_core_start_accept_call_update(LinphoneCore *lc, LinphoneCall *call);
void linphone_core_start_refered_call(LinphoneCore *lc, LinphoneCall *call);
+void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call);
extern SalCallbacks linphone_sal_callbacks;
void linphone_proxy_config_set_error(LinphoneProxyConfig *cfg, LinphoneReason error);
bool_t linphone_core_rtcp_enabled(const LinphoneCore *lc);
static void video_button_clicked(GtkWidget *button, LinphoneCall *call){
gboolean adding=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button),"adding_video"));
+ LinphoneCore *lc=linphone_call_get_core(call);
+ LinphoneCallParams *params=linphone_call_params_copy(linphone_call_get_current_params(call));
gtk_widget_set_sensitive(button,FALSE);
- linphone_call_enable_video(call,adding);
+ linphone_call_params_enable_video(params,adding);
+ linphone_core_update_call(lc,call,params);
+ linphone_call_params_destroy(params);
}
void linphone_gtk_update_video_button(LinphoneCall *call){
static void on_call_updated_response(GtkWidget *dialog, gint responseid, LinphoneCall *call){
if (linphone_call_get_state(call)==LinphoneCallUpdatedByRemote){
- linphone_call_enable_video(call, responseid==GTK_RESPONSE_YES);
+ LinphoneCore *lc=linphone_call_get_core(call);
+ LinphoneCallParams *params=linphone_call_params_copy(linphone_call_get_current_params(call));
+ linphone_call_params_enable_video(params,responseid==GTK_RESPONSE_YES);
+ linphone_core_accept_call_update(lc,call,params);
+ linphone_call_params_destroy(params);
}
linphone_call_unref(call);
g_source_remove_by_user_data(dialog);