mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-17 14:11:35 +00:00
Minor video stats improvements
This commit is contained in:
@@ -34,6 +34,7 @@ static int lastFrameNumber;
|
|||||||
static int activeVideoFormat;
|
static int activeVideoFormat;
|
||||||
static video_stats_t currentVideoStats;
|
static video_stats_t currentVideoStats;
|
||||||
static video_stats_t lastVideoStats;
|
static video_stats_t lastVideoStats;
|
||||||
|
static NSLock* videoStatsLock;
|
||||||
|
|
||||||
#define OUTPUT_BUS 0
|
#define OUTPUT_BUS 0
|
||||||
|
|
||||||
@@ -73,12 +74,15 @@ void DrCleanup(void)
|
|||||||
-(BOOL) getVideoStats:(video_stats_t*)stats
|
-(BOOL) getVideoStats:(video_stats_t*)stats
|
||||||
{
|
{
|
||||||
// We return lastVideoStats because it is a complete 1 second window
|
// We return lastVideoStats because it is a complete 1 second window
|
||||||
|
[videoStatsLock lock];
|
||||||
if (lastVideoStats.endTime != 0) {
|
if (lastVideoStats.endTime != 0) {
|
||||||
memcpy(stats, &lastVideoStats, sizeof(*stats));
|
memcpy(stats, &lastVideoStats, sizeof(*stats));
|
||||||
|
[videoStatsLock unlock];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No stats yet
|
// No stats yet
|
||||||
|
[videoStatsLock unlock];
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +119,9 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit)
|
|||||||
else {
|
else {
|
||||||
// Flip stats roughly every second
|
// Flip stats roughly every second
|
||||||
if (now - currentVideoStats.startTime > 1.0f) {
|
if (now - currentVideoStats.startTime > 1.0f) {
|
||||||
|
[videoStatsLock lock];
|
||||||
lastVideoStats = currentVideoStats;
|
lastVideoStats = currentVideoStats;
|
||||||
|
[videoStatsLock unlock];
|
||||||
|
|
||||||
memset(¤tVideoStats, 0, sizeof(currentVideoStats));
|
memset(¤tVideoStats, 0, sizeof(currentVideoStats));
|
||||||
currentVideoStats.startTime = now;
|
currentVideoStats.startTime = now;
|
||||||
@@ -386,6 +392,10 @@ void ClConnectionStatusUpdate(int status)
|
|||||||
initLock = [[NSLock alloc] init];
|
initLock = [[NSLock alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (videoStatsLock == nil) {
|
||||||
|
videoStatsLock = [[NSLock alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
strncpy(_hostString,
|
strncpy(_hostString,
|
||||||
[config.host cStringUsingEncoding:NSUTF8StringEncoding],
|
[config.host cStringUsingEncoding:NSUTF8StringEncoding],
|
||||||
sizeof(_hostString));
|
sizeof(_hostString));
|
||||||
|
|||||||
@@ -142,12 +142,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
float interval = stats.endTime - stats.startTime;
|
float interval = stats.endTime - stats.startTime;
|
||||||
return [NSString stringWithFormat:@"Video stream: %dx%d %.2f FPS (Codec: %@)\nIncoming frame rate from network: %.2f FPS\nFrames dropped by your network connection: %.2f%%\n",
|
return [NSString stringWithFormat:@"Video stream: %dx%d %.2f FPS (Codec: %@)\nFrames dropped by your network connection: %.2f%%\n",
|
||||||
_config.width,
|
_config.width,
|
||||||
_config.height,
|
_config.height,
|
||||||
stats.totalFrames / interval,
|
stats.totalFrames / interval,
|
||||||
[_connection getActiveCodecName],
|
[_connection getActiveCodecName],
|
||||||
stats.receivedFrames / interval,
|
|
||||||
stats.networkDroppedFrames / interval];
|
stats.networkDroppedFrames / interval];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user