mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 09:25:49 +00:00
Require 2 intervals of 15% frame loss or one of 30% frame loss to trigger the poor connection warning
This commit is contained in:
parent
40fa4ef3c8
commit
9220fcb8e8
@ -40,12 +40,14 @@ static int disconnectPending;
|
|||||||
static int intervalGoodFrameCount;
|
static int intervalGoodFrameCount;
|
||||||
static int intervalTotalFrameCount;
|
static int intervalTotalFrameCount;
|
||||||
static uint64_t intervalStartTimeMs;
|
static uint64_t intervalStartTimeMs;
|
||||||
|
static int lastIntervalLossPercentage;
|
||||||
static int lastConnectionStatusUpdate;
|
static int lastConnectionStatusUpdate;
|
||||||
|
|
||||||
static int idrFrameRequired;
|
static int idrFrameRequired;
|
||||||
static LINKED_BLOCKING_QUEUE invalidReferenceFrameTuples;
|
static LINKED_BLOCKING_QUEUE invalidReferenceFrameTuples;
|
||||||
|
|
||||||
#define CONN_POOR_LOSS_RATE 15
|
#define CONN_IMMEDIATE_POOR_LOSS_RATE 30
|
||||||
|
#define CONN_CONSECUTIVE_POOR_LOSS_RATE 15
|
||||||
#define CONN_OKAY_LOSS_RATE 5
|
#define CONN_OKAY_LOSS_RATE 5
|
||||||
#define CONN_STATUS_SAMPLE_PERIOD 3000
|
#define CONN_STATUS_SAMPLE_PERIOD 3000
|
||||||
|
|
||||||
@ -202,6 +204,7 @@ int initializeControlStream(void) {
|
|||||||
intervalGoodFrameCount = 0;
|
intervalGoodFrameCount = 0;
|
||||||
intervalTotalFrameCount = 0;
|
intervalTotalFrameCount = 0;
|
||||||
intervalStartTimeMs = 0;
|
intervalStartTimeMs = 0;
|
||||||
|
lastIntervalLossPercentage = 0;
|
||||||
lastConnectionStatusUpdate = CONN_STATUS_OKAY;
|
lastConnectionStatusUpdate = CONN_STATUS_OKAY;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -279,7 +282,11 @@ void connectionSawFrame(int frameIndex) {
|
|||||||
if (intervalTotalFrameCount != 0) {
|
if (intervalTotalFrameCount != 0) {
|
||||||
// Notify the client of connection status changes based on frame loss rate
|
// Notify the client of connection status changes based on frame loss rate
|
||||||
int frameLossPercent = 100 - (intervalGoodFrameCount * 100) / intervalTotalFrameCount;
|
int frameLossPercent = 100 - (intervalGoodFrameCount * 100) / intervalTotalFrameCount;
|
||||||
if (frameLossPercent >= CONN_POOR_LOSS_RATE && lastConnectionStatusUpdate != CONN_STATUS_POOR) {
|
if (lastConnectionStatusUpdate != CONN_STATUS_POOR &&
|
||||||
|
(frameLossPercent >= CONN_IMMEDIATE_POOR_LOSS_RATE ||
|
||||||
|
(frameLossPercent >= CONN_CONSECUTIVE_POOR_LOSS_RATE && lastIntervalLossPercentage >= CONN_CONSECUTIVE_POOR_LOSS_RATE))) {
|
||||||
|
// We require 2 consecutive intervals above CONN_CONSECUTIVE_POOR_LOSS_RATE or a single
|
||||||
|
// interval above CONN_IMMEDIATE_POOR_LOSS_RATE to notify of a poor connection.
|
||||||
ListenerCallbacks.connectionStatusUpdate(CONN_STATUS_POOR);
|
ListenerCallbacks.connectionStatusUpdate(CONN_STATUS_POOR);
|
||||||
lastConnectionStatusUpdate = CONN_STATUS_POOR;
|
lastConnectionStatusUpdate = CONN_STATUS_POOR;
|
||||||
}
|
}
|
||||||
@ -287,6 +294,8 @@ void connectionSawFrame(int frameIndex) {
|
|||||||
ListenerCallbacks.connectionStatusUpdate(CONN_STATUS_OKAY);
|
ListenerCallbacks.connectionStatusUpdate(CONN_STATUS_OKAY);
|
||||||
lastConnectionStatusUpdate = CONN_STATUS_OKAY;
|
lastConnectionStatusUpdate = CONN_STATUS_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastIntervalLossPercentage = frameLossPercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset interval
|
// Reset interval
|
||||||
|
Loading…
x
Reference in New Issue
Block a user