fix: overlay level hanling

This commit is contained in:
Acaki committed 2025-07-15 02:30:08 +08:00
1 parent 5e4ba088be
commit 8126173128
3 files changed
+31 -24

No files matched your search

+1 -1
View File
@@ -20,6 +20,6 @@
- (void) stopStream; - (void) stopStream;
- (NSString*) getStatsOverlayText; - (NSString*) getStatsOverlayText: (uint16_t) overlayLevel;
@end @end
+26 -22
View File
@@ -154,7 +154,7 @@
return TRUE; return TRUE;
} }
- (NSString*) getStatsOverlayText { - (NSString*) getStatsOverlayText: (uint16_t) overlayLevel {
video_stats_t stats; video_stats_t stats;
if (!_connection) { if (!_connection) {
@@ -168,7 +168,7 @@
uint32_t rtt, variance; uint32_t rtt, variance;
NSString* latencyString; NSString* latencyString;
if (LiGetEstimatedRttInfo(&rtt, &variance)) { if (LiGetEstimatedRttInfo(&rtt, &variance)) {
latencyString = [NSString stringWithFormat:@"%u ms (variance: %u ms)", rtt, variance]; latencyString = [LocalizationHelper localizedStringForKey:@"%u ms (variance: %u ms)", rtt, variance];
} }
else { else {
latencyString = @"N/A"; latencyString = @"N/A";
@@ -176,7 +176,7 @@
NSString* hostProcessingString; NSString* hostProcessingString;
if (stats.framesWithHostProcessingLatency != 0) { if (stats.framesWithHostProcessingLatency != 0) {
hostProcessingString = [NSString stringWithFormat:@"Host processing latency min/max/avg: %.1f/%.1f/%.1f ms\n", hostProcessingString = [LocalizationHelper localizedStringForKey:@"Host processing latency min/max/avg: %.1f/%.1f/%.1f ms\n",
stats.minHostProcessingLatency / 10.f, stats.minHostProcessingLatency / 10.f,
stats.maxHostProcessingLatency / 10.f, stats.maxHostProcessingLatency / 10.f,
(float)stats.totalHostProcessingLatency / stats.framesWithHostProcessingLatency / 10.f]; (float)stats.totalHostProcessingLatency / stats.framesWithHostProcessingLatency / 10.f];
@@ -192,25 +192,29 @@
double avgVideoMbps = [_connection getBwTracker].averageMbps; double avgVideoMbps = [_connection getBwTracker].averageMbps;
double peakVideoMbps = [_connection getBwTracker].peakMbps; double peakVideoMbps = [_connection getBwTracker].peakMbps;
return [NSString stringWithFormat:@"Video stream: %dx%d %.2f FPS (Codec: %@)\n" if(overlayLevel == 1) return [LocalizationHelper localizedStringForKey:@"FPS: %5.2f Network dropped frames: %.2f%% Network latency: %@",
"Bitrate: %.1f Mbps, Peak: %.1f, Renderer: %@\n" stats.totalFrames / interval,
"%@" stats.networkDroppedFrames / interval,
"Frames buffered: %.1f, Present \n" latencyString];
"Frames dropped by network/pacing jitter: %.1f%% / %.1f%%\n" else return [LocalizationHelper localizedStringForKey:@"Video stream: %dx%d %.2f FPS (Codec: %@)\n"
"Average network latency: %@\n" "Bitrate: %.1f Mbps, Peak: %.1f, Renderer: %@\n"
"Decode time: %.2f/%.2f/%.2f ms", "%@"
_config.width, "Frames buffered: %.1f, Present \n"
_config.height, "Frames dropped by network/pacing jitter: %.1f%% / %.1f%%\n"
fps, "Average network latency: %@\n"
[_connection getActiveCodecName], "Decode time: %.2f/%.2f/%.2f ms",
avgVideoMbps, peakVideoMbps, (stats.renderingBackend == RENDER_METAL) ? @"Metal" : @"AVSampleBuffer", _config.width,
hostProcessingString, _config.height,
stats.frameQueueMetrics.avg, fps,
(stats.networkDroppedFrames / stats.totalFrames) * 100.0, [_connection getActiveCodecName],
stats.frameDropMetrics.nsamples > 0 ? (stats.frameDropMetrics.total / stats.frameDropMetrics.nsamples) * 100.0 : 0.0f, avgVideoMbps, peakVideoMbps, (stats.renderingBackend == RENDER_METAL) ? @"Metal" : @"AVSampleBuffer",
latencyString, hostProcessingString,
stats.decodeMetrics.min, stats.decodeMetrics.max, stats.decodeMetrics.avg]; stats.frameQueueMetrics.avg,
(stats.networkDroppedFrames / stats.totalFrames) * 100.0,
stats.frameDropMetrics.nsamples > 0 ? (stats.frameDropMetrics.total / stats.frameDropMetrics.nsamples) * 100.0 : 0.0f,
latencyString,
stats.decodeMetrics.min, stats.decodeMetrics.max, stats.decodeMetrics.avg];
} }
@end @end
@@ -56,6 +56,7 @@
UITapGestureRecognizer *_menuTapGestureRecognizer; UITapGestureRecognizer *_menuTapGestureRecognizer;
UITapGestureRecognizer *_menuDoubleTapGestureRecognizer; UITapGestureRecognizer *_menuDoubleTapGestureRecognizer;
UITapGestureRecognizer *_playPauseTapGestureRecognizer; UITapGestureRecognizer *_playPauseTapGestureRecognizer;
uint16_t overlayLevel;
UILabel *_stageLabel; UILabel *_stageLabel;
UILabel *_tipLabel; UILabel *_tipLabel;
UIActivityIndicatorView *_spinner; UIActivityIndicatorView *_spinner;
@@ -335,6 +336,7 @@
if (reloadSettings) { if (reloadSettings) {
_settings = [[[DataManager alloc] init] getSettings]; //StreamFrameViewController retrieve the settings here. _settings = [[[DataManager alloc] init] getSettings]; //StreamFrameViewController retrieve the settings here.
} }
overlayLevel = _settings.statsOverlayLevel.intValue;
[self configOscLayoutTool]; [self configOscLayoutTool];
[self updateToolboxSpecialEntries]; [self updateToolboxSpecialEntries];
[self configSwipeGestures]; [self configSwipeGestures];
@@ -775,7 +777,8 @@
} }
else [self.view addSubview:_overlayView]; // don't know why but this is necessary for reactivating overlay. else [self.view addSubview:_overlayView]; // don't know why but this is necessary for reactivating overlay.
NSString* overlayText = [self->_streamMan getStatsOverlayText]; NSString* overlayText = [self->_streamMan getStatsOverlayText:overlayLevel];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self updateOverlayText:overlayText]; [self updateOverlayText:overlayText];
}); });