mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-02-16 10:30:47 +00:00
Meassure bitrate of video and audio streams
This commit is contained in:
@@ -7,13 +7,25 @@ import com.limelight.nvstream.av.audio.AudioRenderer;
|
||||
* @author Iwan Timmer
|
||||
*/
|
||||
public class FakeAudioRenderer implements AudioRenderer {
|
||||
|
||||
private int dataSize;
|
||||
private long last;
|
||||
|
||||
@Override
|
||||
public void streamInitialized(int channelCount, int sampleRate) {
|
||||
System.out.println("Fake " + channelCount + " channel " + sampleRate + " samplerate audio output");
|
||||
last = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playDecodedAudio(byte[] audioData, int offset, int length) {
|
||||
if (System.currentTimeMillis()>last+2000) {
|
||||
int bitrate = (dataSize/2)/1024;
|
||||
System.out.println("Audio " + bitrate + "kB/s");
|
||||
dataSize = 0;
|
||||
last = System.currentTimeMillis();
|
||||
}
|
||||
dataSize += length;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,13 +8,18 @@ import com.limelight.nvstream.av.video.VideoDecoderRenderer;
|
||||
* @author Iwan Timmer
|
||||
*/
|
||||
public class FakeVideoRenderer implements VideoDecoderRenderer {
|
||||
|
||||
private int dataSize;
|
||||
private long last;
|
||||
|
||||
@Override
|
||||
public void setup(int width, int height, int redrawRate, Object renderTarget, int drFlags) {
|
||||
System.out.println("Fake " + width + "x" + height + " " + redrawRate + "fps video output");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
last = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,6 +32,14 @@ public class FakeVideoRenderer implements VideoDecoderRenderer {
|
||||
|
||||
@Override
|
||||
public boolean submitDecodeUnit(DecodeUnit decodeUnit) {
|
||||
if (System.currentTimeMillis()>last+2000) {
|
||||
int bitrate = (dataSize/2)/1024;
|
||||
System.out.println("Video " + bitrate + "kB/s");
|
||||
dataSize = 0;
|
||||
last = System.currentTimeMillis();
|
||||
}
|
||||
dataSize += decodeUnit.getDataLength();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user