mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-31 08:47:13 +00:00
72 lines
2.2 KiB
Java
72 lines
2.2 KiB
Java
package com.limelight.binding.video;
|
|
|
|
import android.os.SystemClock;
|
|
|
|
class VideoStats {
|
|
|
|
long decoderTimeMs;
|
|
long totalTimeMs;
|
|
int totalFrames;
|
|
int totalFramesReceived;
|
|
int totalFramesRendered;
|
|
int frameLossEvents;
|
|
int framesLost;
|
|
long measurementStartTimestamp;
|
|
|
|
void add(VideoStats other) {
|
|
this.decoderTimeMs += other.decoderTimeMs;
|
|
this.totalTimeMs += other.totalTimeMs;
|
|
this.totalFrames += other.totalFrames;
|
|
this.totalFramesReceived += other.totalFramesReceived;
|
|
this.totalFramesRendered += other.totalFramesRendered;
|
|
this.frameLossEvents += other.frameLossEvents;
|
|
this.framesLost += other.framesLost;
|
|
|
|
if (this.measurementStartTimestamp == 0) {
|
|
this.measurementStartTimestamp = other.measurementStartTimestamp;
|
|
}
|
|
|
|
assert other.measurementStartTimestamp >= this.measurementStartTimestamp;
|
|
}
|
|
|
|
void copy(VideoStats other) {
|
|
this.decoderTimeMs = other.decoderTimeMs;
|
|
this.totalTimeMs = other.totalTimeMs;
|
|
this.totalFrames = other.totalFrames;
|
|
this.totalFramesReceived = other.totalFramesReceived;
|
|
this.totalFramesRendered = other.totalFramesRendered;
|
|
this.frameLossEvents = other.frameLossEvents;
|
|
this.framesLost = other.framesLost;
|
|
this.measurementStartTimestamp = other.measurementStartTimestamp;
|
|
}
|
|
|
|
void clear() {
|
|
this.decoderTimeMs = 0;
|
|
this.totalTimeMs = 0;
|
|
this.totalFrames = 0;
|
|
this.totalFramesReceived = 0;
|
|
this.totalFramesRendered = 0;
|
|
this.frameLossEvents = 0;
|
|
this.framesLost = 0;
|
|
this.measurementStartTimestamp = 0;
|
|
}
|
|
|
|
VideoStatsFps getFps() {
|
|
float elapsed = (SystemClock.uptimeMillis() - this.measurementStartTimestamp) / (float) 1000;
|
|
|
|
VideoStatsFps fps = new VideoStatsFps();
|
|
if (elapsed > 0) {
|
|
fps.totalFps = this.totalFrames / elapsed;
|
|
fps.receivedFps = this.totalFramesReceived / elapsed;
|
|
fps.renderedFps = this.totalFramesRendered / elapsed;
|
|
}
|
|
return fps;
|
|
}
|
|
}
|
|
|
|
class VideoStatsFps {
|
|
|
|
float totalFps;
|
|
float receivedFps;
|
|
float renderedFps;
|
|
} |