mirror of
https://github.com/pikvm/ustreamer.git
synced 2025-12-24 03:00:01 +00:00
h264 and drm statistics in http
This commit is contained in:
parent
4ec3f11935
commit
a9e0cb49e9
@ -476,12 +476,23 @@ static void _http_callback_state(struct evhttp_request *request, void *v_server)
|
||||
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) {
|
||||
_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_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)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -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_http_s *http;
|
||||
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);
|
||||
http->h264_fpsi = us_fpsi_init("H264", false);
|
||||
US_RING_INIT_WITH_ITEMS(http->jpeg_ring, 4, us_frame_init);
|
||||
atomic_init(&http->has_clients, false);
|
||||
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) {
|
||||
us_fpsi_destroy(stream->run->http->captured_fpsi);
|
||||
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);
|
||||
free(stream->run->http);
|
||||
free(stream->run);
|
||||
@ -450,16 +459,20 @@ static void *_drm_thread(void *v_ctx) {
|
||||
if (stream->drm->run->opened == 0) {
|
||||
CHECK(us_drm_expose_dma(stream->drm, hw));
|
||||
prev_hw = hw;
|
||||
atomic_store(&stream->run->http->drm_live, true);
|
||||
us_fpsi_bump(stream->run->http->drm_fpsi, NULL);
|
||||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
SLOWDOWN;
|
||||
}
|
||||
|
||||
close:
|
||||
atomic_store(&stream->run->http->drm_live, false);
|
||||
us_drm_close(stream->drm);
|
||||
US_DELETE(prev_hw, us_capture_hwbuf_decref);
|
||||
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) {
|
||||
goto close;
|
||||
}
|
||||
us_fpsi_bump(stream->run->http->drm_fpsi, NULL);
|
||||
return;
|
||||
close:
|
||||
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:
|
||||
atomic_store(&run->http->h264_online, online);
|
||||
us_fpsi_bump(run->http->h264_fpsi, NULL);
|
||||
}
|
||||
|
||||
static void _stream_check_suicide(us_stream_s *stream) {
|
||||
|
||||
@ -43,7 +43,13 @@
|
||||
|
||||
|
||||
typedef struct {
|
||||
# ifdef WITH_V4P
|
||||
atomic_bool drm_live;
|
||||
us_fpsi_s *drm_fpsi;
|
||||
# endif
|
||||
|
||||
atomic_bool h264_online;
|
||||
us_fpsi_s *h264_fpsi;
|
||||
|
||||
us_ring_s *jpeg_ring;
|
||||
atomic_bool has_clients;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user