h264 and drm statistics in http

This commit is contained in:
Maxim Devaev
2024-03-30 17:31:05 +02:00
parent 4ec3f11935
commit a9e0cb49e9
3 changed files with 34 additions and 2 deletions

View File

@@ -476,12 +476,23 @@ static void _http_callback_state(struct evhttp_request *request, void *v_server)
enc_quality enc_quality
); );
# ifdef WITH_V4P
if (stream->drm != NULL) {
_A_EVBUFFER_ADD_PRINTF(buf,
" \"drm\": {\"live\": %s, \"fps\": %u},",
us_bool_to_string(atomic_load(&stream->run->http->drm_live)),
us_fpsi_get(stream->run->http->drm_fpsi, NULL)
);
}
# endif
if (stream->h264_sink != NULL) { if (stream->h264_sink != NULL) {
_A_EVBUFFER_ADD_PRINTF(buf, _A_EVBUFFER_ADD_PRINTF(buf,
" \"h264\": {\"bitrate\": %u, \"gop\": %u, \"online\": %s},", " \"h264\": {\"bitrate\": %u, \"gop\": %u, \"online\": %s, \"fps\": %u},",
stream->h264_bitrate, stream->h264_bitrate,
stream->h264_gop, stream->h264_gop,
us_bool_to_string(atomic_load(&stream->run->http->h264_online)) us_bool_to_string(atomic_load(&stream->run->http->h264_online)),
us_fpsi_get(stream->run->http->h264_fpsi, NULL)
); );
} }

View File

@@ -97,7 +97,12 @@ static void _stream_check_suicide(us_stream_s *stream);
us_stream_s *us_stream_init(us_capture_s *cap, us_encoder_s *enc) { us_stream_s *us_stream_init(us_capture_s *cap, us_encoder_s *enc) {
us_stream_http_s *http; us_stream_http_s *http;
US_CALLOC(http, 1); US_CALLOC(http, 1);
# ifdef WITH_V4P
atomic_init(&http->drm_live, false);
http->drm_fpsi = us_fpsi_init("DRM", false);
# endif
atomic_init(&http->h264_online, false); atomic_init(&http->h264_online, false);
http->h264_fpsi = us_fpsi_init("H264", false);
US_RING_INIT_WITH_ITEMS(http->jpeg_ring, 4, us_frame_init); US_RING_INIT_WITH_ITEMS(http->jpeg_ring, 4, us_frame_init);
atomic_init(&http->has_clients, false); atomic_init(&http->has_clients, false);
atomic_init(&http->snapshot_requested, 0); atomic_init(&http->snapshot_requested, 0);
@@ -127,6 +132,10 @@ us_stream_s *us_stream_init(us_capture_s *cap, us_encoder_s *enc) {
void us_stream_destroy(us_stream_s *stream) { void us_stream_destroy(us_stream_s *stream) {
us_fpsi_destroy(stream->run->http->captured_fpsi); us_fpsi_destroy(stream->run->http->captured_fpsi);
US_RING_DELETE_WITH_ITEMS(stream->run->http->jpeg_ring, us_frame_destroy); US_RING_DELETE_WITH_ITEMS(stream->run->http->jpeg_ring, us_frame_destroy);
us_fpsi_destroy(stream->run->http->h264_fpsi);
# ifdef WITH_V4P
us_fpsi_destroy(stream->run->http->drm_fpsi);
# endif
us_blank_destroy(stream->run->blank); us_blank_destroy(stream->run->blank);
free(stream->run->http); free(stream->run->http);
free(stream->run); free(stream->run);
@@ -450,16 +459,20 @@ static void *_drm_thread(void *v_ctx) {
if (stream->drm->run->opened == 0) { if (stream->drm->run->opened == 0) {
CHECK(us_drm_expose_dma(stream->drm, hw)); CHECK(us_drm_expose_dma(stream->drm, hw));
prev_hw = hw; prev_hw = hw;
atomic_store(&stream->run->http->drm_live, true);
us_fpsi_bump(stream->run->http->drm_fpsi, NULL);
continue; continue;
} }
CHECK(us_drm_expose_stub(stream->drm, stream->drm->run->opened, ctx->stream->cap)); CHECK(us_drm_expose_stub(stream->drm, stream->drm->run->opened, ctx->stream->cap));
us_fpsi_bump(stream->run->http->drm_fpsi, NULL);
us_capture_hwbuf_decref(hw); us_capture_hwbuf_decref(hw);
SLOWDOWN; SLOWDOWN;
} }
close: close:
atomic_store(&stream->run->http->drm_live, false);
us_drm_close(stream->drm); us_drm_close(stream->drm);
US_DELETE(prev_hw, us_capture_hwbuf_decref); US_DELETE(prev_hw, us_capture_hwbuf_decref);
SLOWDOWN; SLOWDOWN;
@@ -587,6 +600,7 @@ static void _stream_drm_ensure_no_signal(us_stream_s *stream) {
if (us_drm_ensure_no_signal(stream->drm) < 0) { if (us_drm_ensure_no_signal(stream->drm) < 0) {
goto close; goto close;
} }
us_fpsi_bump(stream->run->http->drm_fpsi, NULL);
return; return;
close: close:
us_drm_close(stream->drm); us_drm_close(stream->drm);
@@ -637,6 +651,7 @@ static void _stream_encode_expose_h264(us_stream_s *stream, const us_frame_s *fr
} }
done: done:
atomic_store(&run->http->h264_online, online); atomic_store(&run->http->h264_online, online);
us_fpsi_bump(run->http->h264_fpsi, NULL);
} }
static void _stream_check_suicide(us_stream_s *stream) { static void _stream_check_suicide(us_stream_s *stream) {

View File

@@ -43,7 +43,13 @@
typedef struct { typedef struct {
# ifdef WITH_V4P
atomic_bool drm_live;
us_fpsi_s *drm_fpsi;
# endif
atomic_bool h264_online; atomic_bool h264_online;
us_fpsi_s *h264_fpsi;
us_ring_s *jpeg_ring; us_ring_s *jpeg_ring;
atomic_bool has_clients; atomic_bool has_clients;