Skip to content

Commit

Permalink
Only show decoder latency if available
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Oct 26, 2023
1 parent 1040465 commit e5accae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/app/stream/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ typedef struct VIDEO_INFO {
int width;
int height;
bool has_host_latency;
bool has_decoder_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 @@ -185,6 +185,7 @@ void vdec_stat_submit(const struct VIDEO_STATS *src, unsigned long now) {
int latencyUs = 0;
if (SS4S_PlayerGetVideoLatency(player, 0, &latencyUs)) {
dst->avgDecoderLatency = (float) latencyUs / 1000.0f;
vdec_stream_info.has_decoder_latency = true;
} else {
dst->avgDecoderLatency = 0;
}
Expand Down
9 changes: 7 additions & 2 deletions src/app/ui/streaming/streaming.controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,19 @@ bool streaming_refresh_stats() {
if (dst->submittedFrames) {
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;
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);
if (vdec_stream_info.has_decoder_latency) {
float avgSubmitTime = (float) dst->totalSubmitTime / (float) dst->submittedFrames;
lv_label_set_text_fmt(controller->stats_items.vdec_latency, "avg %.2f ms",
avgSubmitTime + dst->avgDecoderLatency);
} else {
lv_label_set_text_fmt(controller->stats_items.vdec_latency, "not available");
}
} else {
lv_label_set_text(controller->stats_items.drop_rate, "-");
lv_label_set_text_fmt(controller->stats_items.host_latency, "-");
Expand Down

0 comments on commit e5accae

Please sign in to comment.