diff --git a/src/http.c b/src/http.c index 8f5d62b..474631a 100644 --- a/src/http.c +++ b/src/http.c @@ -168,10 +168,10 @@ static void _http_callback_ping(struct evhttp_request *request, void *v_server) assert(evbuffer_add_printf(buf, "{\"stream\": {\"resolution\":" " {\"width\": %u, \"height\": %u}," - " \"online\": %s}}", + " \"fps\": %u, \"online\": %s}}", (server->fake_width ? server->fake_width : server->run->exposed->width), (server->fake_height ? server->fake_height : server->run->exposed->height), - (server->run->exposed->online ? "true" : "false") + server->run->exposed->fps, (server->run->exposed->online ? "true" : "false") )); ADD_HEADER("Content-Type", "application/json"); evhttp_send_reply(request, HTTP_OK, "OK", buf); @@ -379,6 +379,7 @@ void _expose_new_picture(struct http_server_t *server) { server->run->exposed->picture.size = server->run->stream->picture.size; server->run->exposed->width = server->run->stream->width; server->run->exposed->height = server->run->stream->height; + server->run->exposed->fps = server->run->stream->fps; server->run->exposed->online = true; } @@ -397,6 +398,7 @@ void _expose_blank_picture(struct http_server_t *server) { server->run->exposed->picture.size = BLANK_JPG_SIZE; server->run->exposed->width = BLANK_JPG_WIDTH; server->run->exposed->height = BLANK_JPG_HEIGHT; + server->run->exposed->fps = 0; server->run->exposed->online = false; } } diff --git a/src/http.h b/src/http.h index 0c2a740..9477e03 100644 --- a/src/http.h +++ b/src/http.h @@ -42,6 +42,7 @@ struct exposed_t { struct picture_t picture; unsigned width; unsigned height; + unsigned fps; bool online; }; diff --git a/src/stream.c b/src/stream.c index 9a2747c..d0ac3d7 100644 --- a/src/stream.c +++ b/src/stream.c @@ -197,14 +197,13 @@ void stream_loop(struct stream_t *stream) { } fluency_passed = 0; - if (log_level >= LOG_LEVEL_PERF) { - if ((long long)now != fps_second) { - LOG_PERF("Oldest worker complete, encoding FPS = %u", fps); - fps = 0; - fps_second = (long long)now; - } - ++fps; + if ((long long)now != fps_second) { + LOG_PERF("Oldest worker complete, encoding FPS = %u", fps); + stream->fps = fps; + fps = 0; + fps_second = (long long)now; } + ++fps; long double fluency_delay = _stream_get_fluency_delay(stream->dev, &pool); diff --git a/src/stream.h b/src/stream.h index fb1bab2..9a5ec17 100644 --- a/src/stream.h +++ b/src/stream.h @@ -86,6 +86,7 @@ struct stream_t { struct picture_t picture; unsigned width; unsigned height; + unsigned fps; bool updated; pthread_mutex_t mutex; struct device_t *dev;