]> sjero.net Git - linphone/commitdiff
Conference to plain call on unique remaining call.
authorGuillaume Beraudo <guillaume.beraudo@belledonne-communications.com>
Wed, 7 Dec 2011 16:05:57 +0000 (17:05 +0100)
committerGuillaume Beraudo <guillaume.beraudo@belledonne-communications.com>
Wed, 7 Dec 2011 16:05:57 +0000 (17:05 +0100)
coreapi/conference.c
coreapi/linphonecall.c
coreapi/private.h
mediastreamer2

index 4c7b0bffdaa12676e53a7f989f9d185e89b4380b..63f6369e9d4eb5143da3f5690270919dbfc97b86 100644 (file)
@@ -47,9 +47,21 @@ static void remove_local_endpoint(LinphoneConference *ctx){
        }
 }
 
-void linphone_core_conference_check_uninit(LinphoneConference *ctx){
+static int remote_participants_count(LinphoneConference *ctx) {
+       if (!ctx->conf || ctx->conf->nmembers==0) return 0;
+       if (!ctx->local_participant) return ctx->conf->nmembers;
+       return ctx->conf->nmembers -1;
+}
+
+static int convert_conference_to_call(LinphoneCore *lc);
+void linphone_core_conference_check_uninit(LinphoneCore *lc){
+       LinphoneConference *ctx=&lc->conf_ctx;
        if (ctx->conf){
                ms_message("conference_check_uninit(): nmembers=%i",ctx->conf->nmembers);
+               if (remote_participants_count(ctx)==1){
+                       convert_conference_to_call(lc);
+               }
+               if (ctx->conf->nmembers==1)
                if (ctx->conf->nmembers==1 && ctx->local_participant!=NULL){
                        remove_local_endpoint(ctx);
                }
@@ -162,7 +174,7 @@ int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call){
        return 0;
 }
 
-int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call){
+static int remove_from_conference(LinphoneCore *lc, LinphoneCall *call, bool_t active){
        int err=0;
 
        if (!call->current_params.in_conference){
@@ -175,7 +187,64 @@ int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call){
                }
        }
        call->params.in_conference=FALSE;
-       err=linphone_core_pause_call(lc,call);
+
+       char *str=linphone_call_get_remote_address_as_string(call);
+       ms_message("%s will be removed from conference", str);
+       ms_free(str);
+       if (active){
+               // reconnect local audio with this call
+               if (linphone_core_is_in_conference(lc)){
+                       ms_message("Leaving conference for reconnecting with unique call.");
+                       linphone_core_leave_conference(lc);
+               }
+               ms_message("Updating call to actually remove from conference");
+               err=linphone_core_update_call(lc,call,&call->params);
+       } else{
+               ms_message("Pausing call to actually remove from conference");
+               err=linphone_core_pause_call(lc,call);
+       }
+
+       return err;
+}
+
+static int convert_conference_to_call(LinphoneCore *lc){
+       int err=0;
+       MSList *calls=lc->calls;
+
+       if (remote_participants_count(&lc->conf_ctx)!=1){
+               ms_error("No unique call remaining in conference.");
+               return -1;
+       }
+
+       while (calls) {
+               LinphoneCall *rc=(LinphoneCall*)calls->data;
+               calls=calls->next;
+               if (rc->params.in_conference) { // not using current_param
+                       bool_t active_after_removed=linphone_core_is_in_conference(lc);
+                       err=remove_from_conference(lc, rc, active_after_removed);
+                       break;
+               }
+       }
+       return err;
+}
+
+
+int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call){
+       char * str=linphone_call_get_remote_address_as_string(call);
+       ms_message("Removing call %s from the conference", str);
+       ms_free(str);
+       int err=remove_from_conference(lc,call, FALSE);
+       if (err){
+               ms_error("Error removing participant from conference.");
+               return err;
+       }
+
+       if (remote_participants_count(&lc->conf_ctx)==1){
+               ms_message("conference size is 1: need to be converted to plain call");
+               err=convert_conference_to_call(lc);
+       } else {
+               ms_message("the conference need not to be converted as size is %i", remote_participants_count(&lc->conf_ctx));
+       }
        return err;
 }
 
@@ -212,6 +281,7 @@ int linphone_core_add_all_to_conference(LinphoneCore *lc) {
                        linphone_core_add_to_conference(lc, call);
                }
        }
+       linphone_core_enter_conference(lc);
        return 0;
 }
 
index 712d980626f8e3ae46613e760179504da4ceb757..45932f360532363da3a774a55917599812661fb5 100644 (file)
@@ -395,7 +395,7 @@ static void linphone_call_set_terminated(LinphoneCall *call){
        if (ms_list_size(lc->calls)==0)
                linphone_core_notify_all_friends(lc,lc->presence_mode);
 
-       linphone_core_conference_check_uninit(&lc->conf_ctx);
+       linphone_core_conference_check_uninit(lc);
        if (call->ringing_beep){
                linphone_core_stop_dtmf(lc);
                call->ringing_beep=FALSE;
index fda2b449b5f3500fba698f62178f2e3a481fdeeb..3561a4126e0f6d89aaf39f211dc626943979a5a5 100644 (file)
@@ -526,7 +526,7 @@ void _post_configure_audio_stream(AudioStream *st, LinphoneCore *lc, bool_t mute
  */
 void linphone_call_add_to_conf(LinphoneCall *call, bool_t muted);
 void linphone_call_remove_from_conf(LinphoneCall *call);
-void linphone_core_conference_check_uninit(LinphoneConference *ctx);
+void linphone_core_conference_check_uninit(LinphoneCore *lc);
 bool_t linphone_core_sound_resources_available(LinphoneCore *lc);
 
 void __linphone_core_invalidate_registers(LinphoneCore* lc);
index 5190c7f3a0adf18b27d51e59ba3612ac11e266a2..72929edb90d29bbf35cd3b0c9439c32c1764dca2 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 5190c7f3a0adf18b27d51e59ba3612ac11e266a2
+Subproject commit 72929edb90d29bbf35cd3b0c9439c32c1764dca2