mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-10-26 05:50:05 +00:00
Merge branch 'debug'
Conflicts: src/com/limelight/Limelight.java src/com/limelight/binding/video/FakeVideoRenderer.java
This commit is contained in:
commit
1d2bdda14b
3 files changed
+84
-6
No files matched your search
@@ -101,12 +101,12 @@ public class Limelight implements NvConnectionListener {
|
|||||||
/*
|
/*
|
||||||
* Creates a connection to the host and starts up the stream.
|
* Creates a connection to the host and starts up the stream.
|
||||||
*/
|
*/
|
||||||
private void startUpFake(StreamConfiguration streamConfig) {
|
private void startUpFake(StreamConfiguration streamConfig, String videoFile) {
|
||||||
conn = new NvConnection(host, this, streamConfig, PlatformBinding.getCryptoProvider());
|
conn = new NvConnection(host, this, streamConfig, PlatformBinding.getCryptoProvider());
|
||||||
conn.start(PlatformBinding.getDeviceName(), null,
|
conn.start(PlatformBinding.getDeviceName(), null,
|
||||||
VideoDecoderRenderer.FLAG_PREFER_QUALITY,
|
VideoDecoderRenderer.FLAG_PREFER_QUALITY,
|
||||||
new FakeAudioRenderer(),
|
new FakeAudioRenderer(),
|
||||||
new FakeVideoRenderer());
|
new FakeVideoRenderer(videoFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,6 +176,7 @@ public class Limelight implements NvConnectionListener {
|
|||||||
boolean tests = true;
|
boolean tests = true;
|
||||||
String mapping = null;
|
String mapping = null;
|
||||||
String audio = "default";
|
String audio = "default";
|
||||||
|
String video = null;
|
||||||
Level debug = Level.SEVERE;
|
Level debug = Level.SEVERE;
|
||||||
|
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 0; i < args.length; i++) {
|
||||||
@@ -256,6 +257,14 @@ public class Limelight implements NvConnectionListener {
|
|||||||
}
|
}
|
||||||
} else if (args[i].equals("-fake")) {
|
} else if (args[i].equals("-fake")) {
|
||||||
fake = true;
|
fake = true;
|
||||||
|
} else if (args[i].equals("-out")) {
|
||||||
|
if (i + 1 < args.length) {
|
||||||
|
video = args[i+1];
|
||||||
|
i++;
|
||||||
|
} else {
|
||||||
|
System.out.println("Syntax error: output file expected after -out");
|
||||||
|
System.exit(3);
|
||||||
|
}
|
||||||
} else if (args[i].equals("-notest")) {
|
} else if (args[i].equals("-notest")) {
|
||||||
tests = false;
|
tests = false;
|
||||||
} else if (args[i].equals("-v")) {
|
} else if (args[i].equals("-v")) {
|
||||||
@@ -314,7 +323,7 @@ public class Limelight implements NvConnectionListener {
|
|||||||
Limelight limelight = new Limelight(host);
|
Limelight limelight = new Limelight(host);
|
||||||
if (!pair)
|
if (!pair)
|
||||||
if (fake)
|
if (fake)
|
||||||
limelight.startUpFake(streamConfig);
|
limelight.startUpFake(streamConfig, video);
|
||||||
else
|
else
|
||||||
limelight.startUp(streamConfig, inputs, mapping, audio, tests);
|
limelight.startUp(streamConfig, inputs, mapping, audio, tests);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -7,13 +7,25 @@ import com.limelight.nvstream.av.audio.AudioRenderer;
|
|||||||
* @author Iwan Timmer
|
* @author Iwan Timmer
|
||||||
*/
|
*/
|
||||||
public class FakeAudioRenderer implements AudioRenderer {
|
public class FakeAudioRenderer implements AudioRenderer {
|
||||||
|
|
||||||
|
private int dataSize;
|
||||||
|
private long last;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void streamInitialized(int channelCount, int sampleRate) {
|
public void streamInitialized(int channelCount, int sampleRate) {
|
||||||
|
System.out.println("Fake " + channelCount + " channel " + sampleRate + " samplerate audio output");
|
||||||
|
last = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playDecodedAudio(byte[] audioData, int offset, int length) {
|
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
|
@Override
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
package com.limelight.binding.video;
|
package com.limelight.binding.video;
|
||||||
|
|
||||||
|
import com.limelight.LimeLog;
|
||||||
|
import com.limelight.nvstream.av.ByteBufferDescriptor;
|
||||||
|
import com.limelight.nvstream.av.DecodeUnit;
|
||||||
import com.limelight.nvstream.av.video.VideoDecoderRenderer;
|
import com.limelight.nvstream.av.video.VideoDecoderRenderer;
|
||||||
import com.limelight.nvstream.av.video.VideoDepacketizer;
|
import com.limelight.nvstream.av.video.VideoDepacketizer;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of a video decoder and renderer.
|
* Implementation of a video decoder and renderer.
|
||||||
@@ -12,18 +19,34 @@ public class FakeVideoRenderer implements VideoDecoderRenderer {
|
|||||||
private Thread thread;
|
private Thread thread;
|
||||||
private boolean running;
|
private boolean running;
|
||||||
|
|
||||||
@Override
|
private int dataSize;
|
||||||
public void setup(int width, int height, int redrawRate, Object renderTarget, int drFlags) {
|
private long last;
|
||||||
|
|
||||||
|
private OutputStream out;
|
||||||
|
|
||||||
|
public FakeVideoRenderer(String videoFile) {
|
||||||
|
try {
|
||||||
|
if (videoFile!=null)
|
||||||
|
out = new FileOutputStream(videoFile);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
LimeLog.severe(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Override
|
||||||
public void start(final VideoDepacketizer depacketizer) {
|
public void start(final VideoDepacketizer depacketizer) {
|
||||||
|
last = System.currentTimeMillis();
|
||||||
thread = new Thread(new Runnable() {
|
thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (running) {
|
while (running) {
|
||||||
try {
|
try {
|
||||||
depacketizer.takeNextDecodeUnit();
|
decodeUnit(depacketizer.takeNextDecodeUnit());
|
||||||
} catch (InterruptedException ex) { }
|
} catch (InterruptedException ex) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,12 +59,46 @@ public class FakeVideoRenderer implements VideoDecoderRenderer {
|
|||||||
public void stop() {
|
public void stop() {
|
||||||
running = false;
|
running = false;
|
||||||
thread.interrupt();
|
thread.interrupt();
|
||||||
|
try {
|
||||||
|
thread.join();
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
LimeLog.severe(ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (out!=null)
|
||||||
|
out.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
LimeLog.severe(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void release() {
|
public void release() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean decodeUnit(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();
|
||||||
|
|
||||||
|
if (out!=null) {
|
||||||
|
try {
|
||||||
|
for (ByteBufferDescriptor buf:decodeUnit.getBufferList())
|
||||||
|
out.write(buf.data, buf.offset, buf.length);
|
||||||
|
} catch (IOException e) {
|
||||||
|
LimeLog.severe(e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCapabilities() {
|
public int getCapabilities() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in new issue
Block a user