Commit aca57708 authored by Mickaël Turnel's avatar Mickaël Turnel

Start video call with worst configuration for preferred vsize

If no bitrate limitation is set by the user or the remote then we'll use the worst configuration for th user preferred size.
It is better to start from a lower quality and to increase it over time than doing the opposite and provoking a congestion.
parent dab4f163
......@@ -825,23 +825,30 @@ static void apply_video_preset(VideoStream *stream, PayloadType *pt) {
static void apply_bitrate_limit(VideoStream *stream, PayloadType *pt) {
MSVideoConfiguration *vconf_list = NULL;
if (stream->ms.target_bitrate<=0) {
stream->ms.target_bitrate = ms_factory_get_expected_bandwidth(stream->ms.factory);
if (stream->ms.target_bitrate <= 0) {
if (stream->ms.target_bitrate <= 0) {
if (pt->normal_bitrate <= 0) {
ms_message("target and payload bitrates not set for stream [%p] using lowest configuration of preferred video size %dx%d",stream,stream->sent_vsize.width, stream->sent_vsize.height);
} else {
stream->ms.target_bitrate=pt->normal_bitrate;
ms_message("target bitrate not set for stream [%p] using payload's bitrate is %i",stream,stream->ms.target_bitrate);
} else {
ms_message("target bitrate not set for stream [%p] using expected bitrate is %i",stream,stream->ms.target_bitrate);
}
}
ms_message("Limiting bitrate of video encoder to %i bits/s for stream [%p]",stream->ms.target_bitrate,stream);
ms_filter_call_method(stream->ms.encoder, MS_VIDEO_ENCODER_GET_CONFIGURATION_LIST, &vconf_list);
if (vconf_list != NULL) {
MSVideoConfiguration vconf = ms_video_find_best_configuration_for_bitrate(vconf_list, stream->ms.target_bitrate, ms_factory_get_cpu_count(stream->ms.factory));
/* Adjust configuration video size to use the user preferred video size if it is lower that the configuration one. */
if ((stream->sent_vsize.height * stream->sent_vsize.width) < (vconf.vsize.height * vconf.vsize.width)) {
vconf.vsize = stream->sent_vsize;
MSVideoConfiguration vconf;
if (stream->ms.target_bitrate > 0) {
vconf = ms_video_find_best_configuration_for_bitrate(vconf_list, stream->ms.target_bitrate, ms_factory_get_cpu_count(stream->ms.factory));
/* Adjust configuration video size to use the user preferred video size if it is lower that the configuration one. */
if ((stream->sent_vsize.height * stream->sent_vsize.width) < (vconf.vsize.height * vconf.vsize.width)) {
vconf.vsize = stream->sent_vsize;
}
} else {
/* We retrieve the lowest configuration for that vsize since the bandwidth estimator will increase quality if possible */
vconf = ms_video_find_worst_configuration_for_size(vconf_list, stream->sent_vsize, ms_factory_get_cpu_count(stream->ms.factory));
stream->ms.target_bitrate = vconf.required_bitrate;
}
ms_filter_call_method(stream->ms.encoder, MS_VIDEO_ENCODER_SET_CONFIGURATION, &vconf);
} else {
......@@ -947,9 +954,8 @@ static int video_stream_start_with_source_and_output(VideoStream *stream, RtpPro
}
apply_video_preset(stream, pt);
if (pt->normal_bitrate>0){
apply_bitrate_limit(stream, pt);
}
apply_bitrate_limit(stream, pt);
if (pt->send_fmtp){
ms_filter_call_method(stream->ms.encoder,MS_FILTER_ADD_FMTP,pt->send_fmtp);
}
......@@ -1281,9 +1287,7 @@ static MSFilter* _video_stream_change_camera(VideoStream *stream, MSWebCam *cam,
ms_filter_call_method(stream->source, MS_FILTER_SET_PIX_FMT, &format);
}
apply_video_preset(stream, pt);
if (pt->normal_bitrate > 0){
apply_bitrate_limit(stream ,pt);
}
apply_bitrate_limit(stream ,pt);
}
configure_video_source(stream);
......
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