From eeb36479d5f6eb5697fd8aa16fba6f5dee15cb78 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 9 Oct 2013 15:50:45 +0200 Subject: [PATCH] Deprecate linphone_core_enable_video() and linphone_core_video_enabled(). Introduce linphone_core_enable_video_capture(), linphone_core_enable_video_display(), linphone_core_video_capture_enabled() and linphone_core_video_display_enabled() instead. --- console/linphonec.c | 3 +- coreapi/linphonecore.c | 84 ++++++++++++++++++++++++------------------ coreapi/linphonecore.h | 59 +++++++++++++++++++++++++++++ gtk/main.c | 6 ++- tester/call_tester.c | 18 ++++++--- 5 files changed, 125 insertions(+), 45 deletions(-) diff --git a/console/linphonec.c b/console/linphonec.c index 0b0c3a3f4..6564bcb5b 100644 --- a/console/linphonec.c +++ b/console/linphonec.c @@ -735,7 +735,8 @@ linphonec_init(int argc, char **argv) */ linphonec=linphone_core_new (&linphonec_vtable, configfile_name, factory_configfile_name, NULL); linphone_core_set_zrtp_secrets_file(linphonec,zrtpsecrets); - linphone_core_enable_video(linphonec,vcap_enabled,display_enabled); + linphone_core_enable_video_capture(linphonec, vcap_enabled); + linphone_core_enable_video_display(linphonec, display_enabled); if (display_enabled && window_id != 0) { printf ("Setting window_id: 0x%x\n", window_id); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 48e3d88f1..1a879c4a8 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -956,7 +956,8 @@ static void video_config_read(LinphoneCore *lc){ self_view=lp_config_get_int(lc->config,"video","self_view",1); vpol.automatically_initiate=lp_config_get_int(lc->config,"video","automatically_initiate",1); vpol.automatically_accept=lp_config_get_int(lc->config,"video","automatically_accept",1); - linphone_core_enable_video(lc,capture,display); + linphone_core_enable_video_capture(lc, capture); + linphone_core_enable_video_display(lc, display); linphone_core_enable_video_preview(lc,lp_config_get_int(lc->config,"video","show_local",0)); linphone_core_enable_self_view(lc,self_view); linphone_core_set_video_policy(lc,&vpol); @@ -4597,37 +4598,6 @@ static void toggle_video_preview(LinphoneCore *lc, bool_t val){ #endif } -/** - * Enables video globally. - * - * @ingroup media_parameters - * This function does not have any effect during calls. It just indicates LinphoneCore to - * initiate future calls with video or not. The two boolean parameters indicate in which - * direction video is enabled. Setting both to false disables video entirely. - * - * @param lc The LinphoneCore object - * @param vcap_enabled indicates whether video capture is enabled - * @param display_enabled indicates whether video display should be shown - * -**/ -void linphone_core_enable_video(LinphoneCore *lc, bool_t vcap_enabled, bool_t display_enabled){ -#ifndef VIDEO_ENABLED - if (vcap_enabled || display_enabled) - ms_warning("This version of linphone was built without video support."); -#endif - lc->video_conf.capture=vcap_enabled; - lc->video_conf.display=display_enabled; - if (linphone_core_ready(lc)){ - lp_config_set_int(lc->config,"video","display",lc->video_conf.display); - lp_config_set_int(lc->config,"video","capture",lc->video_conf.capture); - } - /* need to re-apply network bandwidth settings*/ - linphone_core_set_download_bandwidth(lc, - linphone_core_get_download_bandwidth(lc)); - linphone_core_set_upload_bandwidth(lc, - linphone_core_get_upload_bandwidth(lc)); -} - bool_t linphone_core_video_supported(LinphoneCore *lc){ #ifdef VIDEO_ENABLED return TRUE; @@ -4636,14 +4606,56 @@ bool_t linphone_core_video_supported(LinphoneCore *lc){ #endif } -/** - * Returns TRUE if video is enabled, FALSE otherwise. - * @ingroup media_parameters -**/ +void linphone_core_enable_video(LinphoneCore *lc, bool_t vcap_enabled, bool_t display_enabled) { + linphone_core_enable_video_capture(lc, vcap_enabled); + linphone_core_enable_video_display(lc, display_enabled); +} + bool_t linphone_core_video_enabled(LinphoneCore *lc){ return (lc->video_conf.display || lc->video_conf.capture); } +static void reapply_network_bandwidth_settings(LinphoneCore *lc) { + linphone_core_set_download_bandwidth(lc, linphone_core_get_download_bandwidth(lc)); + linphone_core_set_upload_bandwidth(lc, linphone_core_get_upload_bandwidth(lc)); +} + +void linphone_core_enable_video_capture(LinphoneCore *lc, bool_t enable) { +#ifndef VIDEO_ENABLED + if (enable == TRUE) { + ms_warning("Cannot enable video capture, this version of linphone was built without video support."); + } +#endif + lc->video_conf.capture = enable; + if (linphone_core_ready(lc)) { + lp_config_set_int(lc->config, "video", "capture", lc->video_conf.capture); + } + /* Need to re-apply network bandwidth settings. */ + reapply_network_bandwidth_settings(lc); +} + +void linphone_core_enable_video_display(LinphoneCore *lc, bool_t enable) { +#ifndef VIDEO_ENABLED + if (enable == TRUE) { + ms_warning("Cannot enable video display, this version of linphone was built without video support."); + } +#endif + lc->video_conf.display = enable; + if (linphone_core_ready(lc)) { + lp_config_set_int(lc->config, "video", "display", lc->video_conf.display); + } + /* Need to re-apply network bandwidth settings. */ + reapply_network_bandwidth_settings(lc); +} + +bool_t linphone_core_video_capture_enabled(LinphoneCore *lc) { + return lc->video_conf.capture; +} + +bool_t linphone_core_video_display_enabled(LinphoneCore *lc) { + return lc->video_conf.display; +} + /** * Sets the default policy for video. * This policy defines whether: diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index d0b609d19..1421e74aa 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -1715,8 +1715,67 @@ LINPHONE_PUBLIC void linphone_core_remove_call_log(LinphoneCore *lc, LinphoneCal /* video support */ LINPHONE_PUBLIC bool_t linphone_core_video_supported(LinphoneCore *lc); + +/** + * Enables video globally. + * + * This function does not have any effect during calls. It just indicates LinphoneCore to + * initiate future calls with video or not. The two boolean parameters indicate in which + * direction video is enabled. Setting both to false disables video entirely. + * + * @param lc The LinphoneCore object + * @param vcap_enabled indicates whether video capture is enabled + * @param display_enabled indicates whether video display should be shown + * @ingroup media_parameters + * @deprecated Use #linphone_core_enable_video_capture and #linphone_core_enable_video_display instead. +**/ LINPHONE_PUBLIC void linphone_core_enable_video(LinphoneCore *lc, bool_t vcap_enabled, bool_t display_enabled); + +/** + * Returns TRUE if video is enabled, FALSE otherwise. + * @ingroup media_parameters + * @deprecated Use #linphone_core_video_capture_enabled and #linphone_core_video_display_enabled instead. +**/ LINPHONE_PUBLIC bool_t linphone_core_video_enabled(LinphoneCore *lc); + +/** + * Enable or disable video capture. + * + * This function does not have any effect during calls. It just indicates the #LinphoneCore to + * initiate future calls with video capture or not. + * @param[in] lc #LinphoneCore object. + * @param[in] enable TRUE to enable video capture, FALSE to disable it. + * @ingroup media_parameters +**/ +LINPHONE_PUBLIC void linphone_core_enable_video_capture(LinphoneCore *lc, bool_t enable); + +/** + * Enable or disable video display. + * + * This function does not have any effect during calls. It just indicates the #LinphoneCore to + * initiate future calls with video display or not. + * @param[in] lc #LinphoneCore object. + * @param[in] enable TRUE to enable video display, FALSE to disable it. + * @ingroup media_parameters +**/ +LINPHONE_PUBLIC void linphone_core_enable_video_display(LinphoneCore *lc, bool_t enable); + +/** + * Tells whether video capture is enabled. + * @param[in] lc #LinphoneCore object. + * @returns TRUE if video capture is enabled, FALSE if disabled. + * @ingroup media_parameters +**/ +LINPHONE_PUBLIC bool_t linphone_core_video_capture_enabled(LinphoneCore *lc); + +/** + * Tells whether video display is enabled. + * @param[in] lc #LinphoneCore object. + * @returns TRUE if video display is enabled, FALSE if disabled. + * @ingroup media_parameters +**/ +LINPHONE_PUBLIC bool_t linphone_core_video_display_enabled(LinphoneCore *lc); + LINPHONE_PUBLIC void linphone_core_set_video_policy(LinphoneCore *lc, const LinphoneVideoPolicy *policy); LINPHONE_PUBLIC const LinphoneVideoPolicy *linphone_core_get_video_policy(LinphoneCore *lc); diff --git a/gtk/main.c b/gtk/main.c index c14b0c75f..1de976c9e 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -259,7 +259,8 @@ static void linphone_gtk_init_liblinphone(const char *config_file, linphone_core_set_waiting_callback(the_core,linphone_gtk_wait,NULL); linphone_core_set_zrtp_secrets_file(the_core,secrets_file); g_free(secrets_file); - linphone_core_enable_video(the_core,TRUE,TRUE); + linphone_core_enable_video_capture(the_core, TRUE); + linphone_core_enable_video_display(the_core, TRUE); if (no_video) { _linphone_gtk_enable_video(FALSE); linphone_gtk_set_ui_config_int("videoselfview",0); @@ -886,7 +887,8 @@ void linphone_gtk_answer_clicked(GtkWidget *button){ void _linphone_gtk_enable_video(gboolean val){ LinphoneVideoPolicy policy={0}; policy.automatically_initiate=policy.automatically_accept=val; - linphone_core_enable_video(linphone_gtk_get_core(),TRUE,TRUE); + linphone_core_enable_video_capture(linphone_gtk_get_core(), TRUE); + linphone_core_enable_video_display(linphone_gtk_get_core(), TRUE); linphone_core_set_video_policy(linphone_gtk_get_core(),&policy); if (val){ diff --git a/tester/call_tester.c b/tester/call_tester.c index df88321b6..281539d54 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -642,8 +642,10 @@ static bool_t add_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee) LinphoneCall* call_obj; caller_policy.automatically_accept=TRUE; caller_policy.automatically_initiate=TRUE; - linphone_core_enable_video(callee->lc,TRUE,TRUE); - linphone_core_enable_video(caller->lc,TRUE,FALSE); + linphone_core_enable_video_capture(callee->lc, TRUE); + linphone_core_enable_video_display(callee->lc, TRUE); + linphone_core_enable_video_capture(caller->lc, TRUE); + linphone_core_enable_video_display(caller->lc, FALSE); linphone_core_set_video_policy(caller->lc,&caller_policy); stats initial_caller_stat=caller->stat; stats initial_callee_stat=callee->stat; @@ -693,8 +695,10 @@ static void call_with_declined_video(void) { LinphoneCall* marie_call; LinphoneCall* pauline_call; - linphone_core_enable_video(marie->lc,TRUE,TRUE); - linphone_core_enable_video(pauline->lc,TRUE,FALSE); + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, FALSE); caller_params=linphone_core_create_default_call_parameters(marie->lc); linphone_call_params_enable_video(caller_params,TRUE); @@ -724,8 +728,10 @@ static void video_call(void) { LinphoneCall* marie_call; LinphoneCall* pauline_call; - linphone_core_enable_video(marie->lc,TRUE,TRUE); - linphone_core_enable_video(pauline->lc,TRUE,FALSE); + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, FALSE); caller_params=linphone_core_create_default_call_parameters(marie->lc); linphone_call_params_enable_video(caller_params,TRUE);