Webstream Rate Update

This commit is contained in:
Mr-DaveDev
2018-11-14 21:29:56 -07:00
committed by Mr-Dave
parent f65fb529d6
commit 1919f22fe5

View File

@@ -44,20 +44,18 @@ static void webu_stream_mjpeg_delay(struct webui_ctx *webui) {
/* The stream rate MUST be less than 1000000000 otherwise undefined behaviour
* will occur with the SLEEP function.
*/
stream_delay = ((time_curr.tv_usec - webui->time_last.tv_usec)*1000) -
((time_curr.tv_sec - webui->time_last.tv_sec)*1000000);
stream_delay = ((time_curr.tv_usec - webui->time_last.tv_usec)*1000) +
((time_curr.tv_sec - webui->time_last.tv_sec)*1000000000);
if (stream_delay < 0) stream_delay = 0;
if (stream_delay > 1000000000 ) stream_delay = 1000000000;
if (webui->cnt->conf.stream_maxrate > 1){
if (webui->cnt->conf.stream_maxrate >= 1){
stream_rate = ( (1000000000 / webui->cnt->conf.stream_maxrate) - stream_delay);
if ((stream_rate > 0) && (stream_rate < 1000000000)){
SLEEP(0,stream_rate);
} else if (stream_rate == 1000000000) {
SLEEP(1,0);
}
} else {
SLEEP(1,0);
}
gettimeofday(&webui->time_last, NULL);