mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-06-16 22:01:11 +00:00
Can save videostream to file in debug mode
This commit is contained in:
@@ -117,12 +117,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);
|
conn = new NvConnection(host, this, streamConfig);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -184,6 +184,7 @@ public class Limelight implements NvConnectionListener {
|
|||||||
boolean tests = true;
|
boolean tests = true;
|
||||||
String mapping = null;
|
String mapping = null;
|
||||||
String audio = "hw:0,0";
|
String audio = "hw:0,0";
|
||||||
|
String video = null;
|
||||||
Level debug = Level.SEVERE;
|
Level debug = Level.SEVERE;
|
||||||
|
|
||||||
for (int i = 0; i < args.length - 1; i++) {
|
for (int i = 0; i < args.length - 1; i++) {
|
||||||
@@ -223,6 +224,14 @@ public class Limelight implements NvConnectionListener {
|
|||||||
refresh = 60;
|
refresh = 60;
|
||||||
} 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")) {
|
||||||
@@ -260,7 +269,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
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
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.DecodeUnit;
|
||||||
import com.limelight.nvstream.av.video.VideoDecoderRenderer;
|
import com.limelight.nvstream.av.video.VideoDecoderRenderer;
|
||||||
|
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.
|
||||||
@@ -11,6 +17,17 @@ public class FakeVideoRenderer implements VideoDecoderRenderer {
|
|||||||
|
|
||||||
private int dataSize;
|
private int dataSize;
|
||||||
private long last;
|
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
|
@Override
|
||||||
public void setup(int width, int height, int redrawRate, Object renderTarget, int drFlags) {
|
public void setup(int width, int height, int redrawRate, Object renderTarget, int drFlags) {
|
||||||
@@ -24,6 +41,12 @@ public class FakeVideoRenderer implements VideoDecoderRenderer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
|
try {
|
||||||
|
if (out!=null)
|
||||||
|
out.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
LimeLog.severe(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -40,6 +63,16 @@ public class FakeVideoRenderer implements VideoDecoderRenderer {
|
|||||||
}
|
}
|
||||||
dataSize += decodeUnit.getDataLength();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user