diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 568206756..5ed1b3c24 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1035,6 +1035,8 @@ const LinphoneCallParams * linphone_call_get_current_params(LinphoneCall *call){ if (vstream != NULL) { call->current_params.sent_vsize = video_stream_get_sent_video_size(vstream); call->current_params.recv_vsize = video_stream_get_received_video_size(vstream); + call->current_params.sent_fps = video_stream_get_sent_framerate(vstream); + call->current_params.received_fps = video_stream_get_received_framerate(vstream); } #endif @@ -1358,6 +1360,24 @@ MSVideoSize linphone_call_params_get_received_video_size(const LinphoneCallParam return cp->recv_vsize; } +/** + * Gets the framerate of the video that is sent. + * @param[in] cp The call parameters. + * @return the actual sent framerate in frames per seconds, 0 if not available. + */ +float linphone_call_params_get_sent_framerate(const LinphoneCallParams *cp){ + return cp->sent_fps; +} + +/** + * Gets the framerate of the video that is received. + * @param[in] cp The call paramaters for which to get the received framerate. + * @return the actual received framerate in frames per seconds, 0 if not available. + */ +float linphone_call_params_get_received_framerate(const LinphoneCallParams *cp){ + return cp->received_fps; +} + const char * linphone_call_params_get_rtp_profile(const LinphoneCallParams *cp) { return sal_media_proto_to_string(get_proto_from_call_params(cp)); } @@ -2171,6 +2191,7 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna video_stream_enable_adaptive_jittcomp(call->videostream, linphone_core_video_adaptive_jittcomp_enabled(lc)); if (lc->video_conf.preview_vsize.width!=0) video_stream_set_preview_size(call->videostream,lc->video_conf.preview_vsize); + video_stream_set_fps(call->videostream,linphone_core_get_preferred_framerate(lc)); video_stream_set_sent_video_size(call->videostream,linphone_core_get_preferred_video_size(lc)); video_stream_enable_self_view(call->videostream,lc->video_conf.selfview); if (lc->video_window_id!=0) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index ca86c4491..76a75f93c 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1000,6 +1000,8 @@ static void video_config_read(LinphoneCore *lc){ linphone_core_set_preview_video_size_by_name(lc, lp_config_get_string(lc->config,"video","preview_size",NULL)); + + linphone_core_set_preferred_framerate(lc,lp_config_get_float(lc->config,"video","framerate",0)); #ifdef VIDEO_ENABLED #if defined(ANDROID) || defined(__ios) @@ -4802,6 +4804,7 @@ static void toggle_video_preview(LinphoneCore *lc, bool_t val){ video_preview_set_display_filter_name(lc->previewstream,display_filter); if (lc->preview_window_id!=0) video_preview_set_native_window_id(lc->previewstream,lc->preview_window_id); + video_preview_set_fps(lc->previewstream,linphone_core_get_preferred_framerate(lc)); video_preview_start(lc->previewstream,lc->video_conf.device); } }else{ @@ -5405,6 +5408,30 @@ MSVideoSize linphone_core_get_preferred_video_size(LinphoneCore *lc){ return lc->video_conf.vsize; } +/** + * Set the preferred frame rate for video. + * Based on the available bandwidth constraints and network conditions, the video encoder + * remains free to lower the framerate. There is no warranty that the preferred frame rate be the actual framerate. + * used during a call. Default value is 0, which means "use encoder's default fps value". + * @ingroup media_parameters + * @param lc the LinphoneCore + * @param fps the target frame rate in number of frames per seconds. +**/ +void linphone_core_set_preferred_framerate(LinphoneCore *lc, float fps){ + lc->video_conf.fps=fps; + if (linphone_core_ready(lc)) + lp_config_set_float(lc->config,"video","framerate",fps); +} +/** + * Returns the preferred video framerate, previously set by linphone_core_set_preferred_framerate(). + * @param lc the linphone core + * @return frame rate in number of frames per seconds. +**/ +float linphone_core_get_preferred_framerate(LinphoneCore *lc){ + return lc->video_conf.fps; +} + + /** * Ask the core to stream audio from and to files, instead of using the soundcard. **/ diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 443057e98..1a3bd2be3 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -431,6 +431,21 @@ LINPHONE_PUBLIC MSVideoSize linphone_call_params_get_sent_video_size(const Linph */ LINPHONE_PUBLIC MSVideoSize linphone_call_params_get_received_video_size(const LinphoneCallParams *cp); + +/** + * Gets the framerate of the video that is sent. + * @param[in] cp The call parameters. + * @return the actual sent framerate in frames per seconds, 0 if not available. + */ +LINPHONE_PUBLIC float linphone_call_params_get_sent_framerate(const LinphoneCallParams *cp); + +/** + * Gets the framerate of the video that is received. + * @param[in] cp The call paramaters for which to get the received framerate. + * @return the actual received framerate in frames per seconds, 0 if not available. + */ +LINPHONE_PUBLIC float linphone_call_params_get_received_framerate(const LinphoneCallParams *cp); + /** * Gets the RTP profile being used. * @param[in] cp #LinphoneCallParams object @@ -2232,7 +2247,8 @@ LINPHONE_PUBLIC void linphone_core_set_preview_video_size(LinphoneCore *lc, MSVi LINPHONE_PUBLIC void linphone_core_set_preview_video_size_by_name(LinphoneCore *lc, const char *name); LINPHONE_PUBLIC MSVideoSize linphone_core_get_preferred_video_size(LinphoneCore *lc); LINPHONE_PUBLIC void linphone_core_set_preferred_video_size_by_name(LinphoneCore *lc, const char *name); - +LINPHONE_PUBLIC void linphone_core_set_preferred_framerate(LinphoneCore *lc, float fps); +LINPHONE_PUBLIC float linphone_core_get_preferred_framerate(LinphoneCore *lc); LINPHONE_PUBLIC void linphone_core_enable_video_preview(LinphoneCore *lc, bool_t val); LINPHONE_PUBLIC bool_t linphone_core_video_preview_enabled(const LinphoneCore *lc); diff --git a/coreapi/private.h b/coreapi/private.h index ffece9f8a..4722b4849 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -87,6 +87,7 @@ struct _LinphoneCallParams{ PayloadType *video_codec; /*video codec currently in use */ MSVideoSize sent_vsize; /* Size of the video currently being sent */ MSVideoSize recv_vsize; /* Size of the video currently being received */ + float received_fps,sent_fps; int down_bw; int up_bw; int down_ptime; @@ -592,6 +593,7 @@ typedef struct video_config{ const char **cams; MSVideoSize vsize; MSVideoSize preview_vsize; /*is 0,0 if no forced preview size is set, in which case vsize field above is used.*/ + float fps; bool_t capture; bool_t show_local; bool_t display; diff --git a/gtk/incall_view.c b/gtk/incall_view.c index 979330123..a70fb468d 100644 --- a/gtk/incall_view.c +++ b/gtk/incall_view.c @@ -256,10 +256,11 @@ static void _refresh_call_stats(GtkWidget *callstats, LinphoneCall *call){ const LinphoneCallStats *vs=linphone_call_get_video_stats(call); const char *audio_media_connectivity = _("Direct or through server"); const char *video_media_connectivity = _("Direct or through server"); - gboolean has_video=linphone_call_params_video_enabled(linphone_call_get_current_params(call)); - MSVideoSize size_received = linphone_call_params_get_received_video_size(linphone_call_get_current_params(call)); - MSVideoSize size_sent = linphone_call_params_get_sent_video_size(linphone_call_get_current_params(call)); - const char *rtp_profile = linphone_call_params_get_rtp_profile(linphone_call_get_current_params(call)); + const LinphoneCallParams *curparams=linphone_call_get_current_params(call); + gboolean has_video=linphone_call_params_video_enabled(curparams); + MSVideoSize size_received = linphone_call_params_get_received_video_size(curparams); + MSVideoSize size_sent = linphone_call_params_get_sent_video_size(curparams); + const char *rtp_profile = linphone_call_params_get_rtp_profile(curparams); gchar *tmp = g_strdup_printf("%s", rtp_profile); gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"rtp_profile")),tmp); g_free(tmp); @@ -268,8 +269,10 @@ static void _refresh_call_stats(GtkWidget *callstats, LinphoneCall *call){ gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"audio_bandwidth_usage")),tmp); g_free(tmp); if (has_video){ - gchar *size_r=g_strdup_printf(_("%ix%i"),size_received.width,size_received.height); - gchar *size_s=g_strdup_printf(_("%ix%i"),size_sent.width,size_sent.height); + gchar *size_r=g_strdup_printf(_("%ix%i @ %f fps"),size_received.width,size_received.height, + linphone_call_params_get_received_framerate(curparams)); + gchar *size_s=g_strdup_printf(_("%ix%i @ %f fps"),size_sent.width,size_sent.height, + linphone_call_params_get_sent_framerate(curparams)); gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"video_size_recv")),size_r); gtk_label_set_markup(GTK_LABEL(linphone_gtk_get_widget(callstats,"video_size_sent")),size_s); diff --git a/mediastreamer2 b/mediastreamer2 index 522a24e05..e52358830 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 522a24e05697a6fde185492cd7aa18a0cd9fac9a +Subproject commit e5235883089d64b42cbefa8cd3d42f65af3bf67a