Skip to content

Commit

Permalink
show better latency info
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Oct 16, 2023
1 parent d4023d4 commit 84eadd3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/app/stream/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ typedef struct VIDEO_STATS {
uint32_t totalFrames;
uint32_t receivedFrames;
uint32_t networkDroppedFrames;
uint32_t decodedFrames;
uint32_t submittedFrames;
uint32_t totalReassemblyTime;
uint32_t totalDecodeTime;
uint32_t totalSubmitTime;
unsigned long measurementStartTimestamp;
float totalFps;
float receivedFps;
float decodedFps;
float avgDecoderLatency;
uint32_t rtt, rttVariance;
} VIDEO_STATS;

Expand Down
18 changes: 14 additions & 4 deletions src/app/stream/video/session_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,17 @@ int vdec_delegate_submit(PDECODE_UNIT decodeUnit) {
memcpy(buffer + length, entry->data, entry->length);
length += entry->length;
}
SS4S_VideoFeedResult result = SS4S_PlayerVideoFeed(player, buffer, length, 0);
SS4S_VideoFeedFlags flags = SS4S_VIDEO_FEED_DATA_FRAME_START | SS4S_VIDEO_FEED_DATA_FRAME_END;
if (decodeUnit->frameType == FRAME_TYPE_IDR) {
flags |= SS4S_VIDEO_FEED_DATA_KEYFRAME;
}
SS4S_VideoFeedResult result = SS4S_PlayerVideoFeed(player, buffer, length, flags);
if (result == SS4S_VIDEO_FEED_OK) {
if (vdec_stream_info.width == 0 || vdec_stream_info.height == 0) {
stream_info_parse_size(decodeUnit, &vdec_stream_info);
}
vdec_temp_stats.totalDecodeTime += LiGetMillis() - decodeUnit->enqueueTimeMs;
vdec_temp_stats.decodedFrames++;
vdec_temp_stats.totalSubmitTime += LiGetMillis() - decodeUnit->enqueueTimeMs;
vdec_temp_stats.submittedFrames++;
return DR_OK;
} else if (result == SS4S_VIDEO_FEED_ERROR) {
session_interrupt(session, false, STREAMING_INTERRUPT_DECODER);
Expand All @@ -174,7 +178,13 @@ void vdec_stat_submit(const struct VIDEO_STATS *src, unsigned long now) {
if (delta <= 0) { return; }
dst->totalFps = (float) dst->totalFrames / ((float) delta / 1000);
dst->receivedFps = (float) dst->receivedFrames / ((float) delta / 1000);
dst->decodedFps = (float) dst->decodedFrames / ((float) delta / 1000);
dst->decodedFps = (float) dst->submittedFrames / ((float) delta / 1000);
int latencyUs = 0;
if (SS4S_PlayerGetVideoLatency(player, 0, &latencyUs)) {
dst->avgDecoderLatency = (float) latencyUs / 1000.0f;
} else {
dst->avgDecoderLatency = 0;
}
LiGetEstimatedRttInfo(&dst->rtt, &dst->rttVariance);
app_bus_post(session->app, (bus_actionfunc) streaming_refresh_stats, NULL);
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/ui/streaming/streaming.controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ bool streaming_refresh_stats() {
lv_label_set_text_fmt(controller->stats_items.rtt, "%d ms (var. %d ms)", dst->rtt, dst->rttVariance);
lv_label_set_text_fmt(controller->stats_items.net_fps, "%.2f FPS", dst->receivedFps);

if (dst->decodedFrames) {
if (dst->submittedFrames) {
lv_label_set_text_fmt(controller->stats_items.drop_rate, "%.2f%%",
(float) dst->networkDroppedFrames / (float) dst->totalFrames * 100);
lv_label_set_text_fmt(controller->stats_items.decode_time, "%.2f ms",
(float) dst->totalDecodeTime / (float) dst->decodedFrames);
float avgSubmitTime = (float) dst->totalSubmitTime / (float) dst->submittedFrames;
lv_label_set_text_fmt(controller->stats_items.decode_time, "%.2f ms", avgSubmitTime + dst->avgDecoderLatency);
} else {
lv_label_set_text(controller->stats_items.drop_rate, "-");
lv_label_set_text_fmt(controller->stats_items.decode_time, "-");
Expand Down

0 comments on commit 84eadd3

Please sign in to comment.