refactor: separate metrics calculation for legacy and queue pacing
This commit is contained in:
1 parent
91f95f13ae
commit
0a2fdbf0c0
1 file changed
+46
-4
@@ -14,6 +14,7 @@
|
|||||||
#import "HttpManager.h"
|
#import "HttpManager.h"
|
||||||
#import "Plot.h"
|
#import "Plot.h"
|
||||||
#import "Utils.h"
|
#import "Utils.h"
|
||||||
|
#import "DataManager.h"
|
||||||
|
|
||||||
#import "StreamView.h"
|
#import "StreamView.h"
|
||||||
#import "ServerInfoResponse.h"
|
#import "ServerInfoResponse.h"
|
||||||
@@ -187,17 +188,56 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
float interval = stats.endTime - stats.startTime;
|
float interval = stats.endTime - stats.startTime;
|
||||||
|
|
||||||
|
// Check if we're using legacy pacing mode
|
||||||
|
DataManager* dataMan = [[DataManager alloc] init];
|
||||||
|
BOOL isLegacyPacing = [[dataMan getSettings].framePacingMode integerValue] == FramePacingModeLegacy;
|
||||||
|
|
||||||
|
// Calculate FPS differently based on pacing mode
|
||||||
|
float fps;
|
||||||
|
if (isLegacyPacing) {
|
||||||
|
fps = stats.totalFrames / interval;
|
||||||
|
} else {
|
||||||
float scalePlotMetrics = stats.frameDropMetrics.nsamples > 0 ? ((float)stats.frameDropMetrics.nsamples / stats.totalFrames) : 1.0f;
|
float scalePlotMetrics = stats.frameDropMetrics.nsamples > 0 ? ((float)stats.frameDropMetrics.nsamples / stats.totalFrames) : 1.0f;
|
||||||
float fps = (stats.totalFrames - stats.networkDroppedFrames - (stats.frameDropMetrics.total / scalePlotMetrics)) / interval;
|
fps = (stats.totalFrames - stats.networkDroppedFrames - (stats.frameDropMetrics.total / scalePlotMetrics)) / interval;
|
||||||
|
}
|
||||||
|
|
||||||
double avgVideoMbps = [_connection getBwTracker].averageMbps;
|
double avgVideoMbps = [_connection getBwTracker].averageMbps;
|
||||||
double peakVideoMbps = [_connection getBwTracker].peakMbps;
|
double peakVideoMbps = [_connection getBwTracker].peakMbps;
|
||||||
|
|
||||||
if(overlayLevel == 1) return [LocalizationHelper localizedStringForKey:@"FPS: %5.2f Network dropped frames: %.2f%% Network latency: %@",
|
if(overlayLevel == 1) return [LocalizationHelper localizedStringForKey:@"FPS: %5.2f Network dropped frames: %.2f%% Network latency: %@",
|
||||||
stats.totalFrames / interval,
|
fps,
|
||||||
stats.networkDroppedFrames / interval,
|
stats.networkDroppedFrames / interval,
|
||||||
latencyString];
|
latencyString];
|
||||||
else return [LocalizationHelper localizedStringForKey:@"Video stream: %dx%d %.2f FPS (Codec: %@)\n"
|
else {
|
||||||
|
if (isLegacyPacing) {
|
||||||
|
NSString* rendererWithPacing = stats.renderingBackendString;
|
||||||
|
if ([stats.renderingBackendString isEqualToString:@"AVSampleBuffer"]) {
|
||||||
|
rendererWithPacing = @"AVSampleBuffer (Legacy Pacing)";
|
||||||
|
}
|
||||||
|
|
||||||
|
return [LocalizationHelper localizedStringForKey:@"Video stream: %dx%d %.2f FPS (Codec: %@)\n"
|
||||||
|
"Bitrate: %.1f Mbps, Peak: %.1f\n"
|
||||||
|
"%@"
|
||||||
|
"Renderer: %@\n"
|
||||||
|
"Frames dropped by network: %.1f%%\n"
|
||||||
|
"Average network latency: %@",
|
||||||
|
_config.width,
|
||||||
|
_config.height,
|
||||||
|
fps,
|
||||||
|
[_connection getActiveCodecName],
|
||||||
|
avgVideoMbps, peakVideoMbps,
|
||||||
|
hostProcessingString,
|
||||||
|
rendererWithPacing,
|
||||||
|
(stats.networkDroppedFrames / stats.totalFrames) * 100.0,
|
||||||
|
latencyString];
|
||||||
|
} else {
|
||||||
|
NSString* rendererWithPacing = stats.renderingBackendString;
|
||||||
|
if ([stats.renderingBackendString isEqualToString:@"AVSampleBuffer"]) {
|
||||||
|
rendererWithPacing = @"AVSampleBuffer (Queue Pacing)";
|
||||||
|
}
|
||||||
|
|
||||||
|
return [LocalizationHelper localizedStringForKey:@"Video stream: %dx%d %.2f FPS (Codec: %@)\n"
|
||||||
"Bitrate: %.1f Mbps, Peak: %.1f, Frames buffered: %.1f\n"
|
"Bitrate: %.1f Mbps, Peak: %.1f, Frames buffered: %.1f\n"
|
||||||
"%@"
|
"%@"
|
||||||
"Renderer: %@\n"
|
"Renderer: %@\n"
|
||||||
@@ -210,11 +250,13 @@
|
|||||||
[_connection getActiveCodecName],
|
[_connection getActiveCodecName],
|
||||||
avgVideoMbps, peakVideoMbps, stats.frameQueueMetrics.avg,
|
avgVideoMbps, peakVideoMbps, stats.frameQueueMetrics.avg,
|
||||||
hostProcessingString,
|
hostProcessingString,
|
||||||
stats.renderingBackendString,
|
rendererWithPacing,
|
||||||
(stats.networkDroppedFrames / stats.totalFrames) * 100.0,
|
(stats.networkDroppedFrames / stats.totalFrames) * 100.0,
|
||||||
stats.frameDropMetrics.nsamples > 0 ? (stats.frameDropMetrics.total / stats.frameDropMetrics.nsamples) * 100.0 : 0.0f,
|
stats.frameDropMetrics.nsamples > 0 ? (stats.frameDropMetrics.total / stats.frameDropMetrics.nsamples) * 100.0 : 0.0f,
|
||||||
latencyString,
|
latencyString,
|
||||||
stats.decodeMetrics.min, stats.decodeMetrics.max, stats.decodeMetrics.avg];
|
stats.decodeMetrics.min, stats.decodeMetrics.max, stats.decodeMetrics.avg];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
Reference in new issue
Block a user