Skip to content

Commit

Permalink
Better video latency stats
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Oct 26, 2023
1 parent a677fb9 commit 32928f8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/app/stream/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ typedef struct VIDEO_INFO {
const char *format;
int width;
int height;
bool has_host_latency;
} VIDEO_INFO;

typedef struct AUDIO_STATS {
Expand Down
1 change: 1 addition & 0 deletions src/app/stream/video/session_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ int vdec_delegate_submit(PDECODE_UNIT decodeUnit) {

vdec_temp_stats.totalCaptureLatency += decodeUnit->frameHostProcessingLatency;
vdec_temp_stats.totalReassemblyTime += decodeUnit->enqueueTimeMs - decodeUnit->receiveTimeMs;
vdec_stream_info.has_host_latency |= decodeUnit->frameHostProcessingLatency > 0;
size_t length = 0;
for (PLENTRY entry = decodeUnit->bufferList; entry != NULL; entry = entry->next) {
memcpy(buffer + length, entry->data, entry->length);
Expand Down
13 changes: 9 additions & 4 deletions src/app/ui/streaming/streaming.controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,17 @@ bool streaming_refresh_stats() {
lv_label_set_text_fmt(controller->stats_items.drop_rate, "%.2f%%",
(float) dst->networkDroppedFrames / (float) dst->totalFrames * 100);
float avgSubmitTime = (float) dst->totalSubmitTime / (float) dst->submittedFrames;
float avgCapLatency = (float) dst->totalCaptureLatency / (float) dst->submittedFrames;
float totalLatency = avgSubmitTime + avgCapLatency + dst->avgDecoderLatency;
lv_label_set_text_fmt(controller->stats_items.total_latency, "%.2f ms", totalLatency);
if (vdec_stream_info.has_host_latency) {
float avgCapLatency = (float) dst->totalCaptureLatency / (float) dst->submittedFrames / 10.0f;
lv_label_set_text_fmt(controller->stats_items.host_latency, "avg %.2f ms", avgCapLatency);
} else {
lv_label_set_text_fmt(controller->stats_items.host_latency, "not available");
}
lv_label_set_text_fmt(controller->stats_items.vdec_latency, "avg %.2f ms", avgSubmitTime + dst->avgDecoderLatency);
} else {
lv_label_set_text(controller->stats_items.drop_rate, "-");
lv_label_set_text_fmt(controller->stats_items.total_latency, "-");
lv_label_set_text_fmt(controller->stats_items.host_latency, "-");
lv_label_set_text_fmt(controller->stats_items.vdec_latency, "-");
}
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/ui/streaming/streaming.controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ typedef struct {
lv_obj_t *rtt;
lv_obj_t *net_fps;
lv_obj_t *drop_rate;
lv_obj_t *total_latency;
lv_obj_t *host_latency;
lv_obj_t *vdec_latency;
} stats_items;
lv_obj_t *notice, *notice_label;
lv_style_t overlay_button_style;
Expand Down
3 changes: 2 additions & 1 deletion src/app/ui/streaming/streaming.view.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ lv_obj_t *streaming_scene_create(lv_fragment_t *self, lv_obj_t *parent) {
controller->stats_items.rtt = stat_label(stats, "Network RTT");
controller->stats_items.net_fps = stat_label(stats, "Network framerate");
controller->stats_items.drop_rate = stat_label(stats, "Network frame drop");
controller->stats_items.total_latency = stat_label(stats, "Video latency");
controller->stats_items.host_latency = stat_label(stats, "Host processing latency");
controller->stats_items.vdec_latency = stat_label(stats, "Decoder latency");


lv_obj_add_flag(overlay, LV_OBJ_FLAG_HIDDEN);
Expand Down

0 comments on commit 32928f8

Please sign in to comment.