mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-06-15 21:31:12 +00:00
Fixed all the issues caused by merging
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
package com.limelight;
|
package com.limelight;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
@@ -42,60 +40,6 @@ public class Limelight implements NvConnectionListener {
|
|||||||
this.host = host;
|
this.host = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Extracts native library into current directory. This is required in order for the library to
|
|
||||||
* be found when trying to load it.
|
|
||||||
*/
|
|
||||||
private static void extractNativeLibrary(String libraryName, String targetDirectory) throws IOException {
|
|
||||||
InputStream resource = new Object().getClass().getResourceAsStream("/binlib/"+libraryName);
|
|
||||||
if (resource == null) {
|
|
||||||
throw new FileNotFoundException("Unable to find native library in JAR: "+libraryName);
|
|
||||||
}
|
|
||||||
File destination = new File(targetDirectory+File.separatorChar+libraryName);
|
|
||||||
|
|
||||||
// this will only delete it if it exists, and then create a new file
|
|
||||||
destination.delete();
|
|
||||||
destination.createNewFile();
|
|
||||||
|
|
||||||
//this is the janky java 6 way to copy a file
|
|
||||||
FileOutputStream fos = null;
|
|
||||||
try {
|
|
||||||
fos = new FileOutputStream(destination);
|
|
||||||
int read;
|
|
||||||
byte[] readBuffer = new byte[16384];
|
|
||||||
while ((read = resource.read(readBuffer)) != -1) {
|
|
||||||
fos.write(readBuffer, 0, read);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (fos != null) {
|
|
||||||
fos.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Checks the OS and decides which libraries need to be extracted.
|
|
||||||
*/
|
|
||||||
private static void prepareNativeLibraries() throws IOException {
|
|
||||||
if (!System.getProperty("os.name").contains("Windows")) {
|
|
||||||
// Nothing to do for platforms other than Windows
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need to extract nv_avc_dec's runtime dependencies manually
|
|
||||||
// because the current JRE extracts them with different file names
|
|
||||||
// so they don't load properly.
|
|
||||||
String nativeLibDir = ".";
|
|
||||||
extractNativeLibrary("avfilter-3.dll", nativeLibDir);
|
|
||||||
extractNativeLibrary("avformat-55.dll", nativeLibDir);
|
|
||||||
extractNativeLibrary("avutil-52.dll", nativeLibDir);
|
|
||||||
extractNativeLibrary("postproc-52.dll", nativeLibDir);
|
|
||||||
extractNativeLibrary("pthreadVC2.dll", nativeLibDir);
|
|
||||||
extractNativeLibrary("swresample-0.dll", nativeLibDir);
|
|
||||||
extractNativeLibrary("swscale-2.dll", nativeLibDir);
|
|
||||||
extractNativeLibrary("avcodec-55.dll", nativeLibDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Creates a connection to the host and starts up the stream.
|
* Creates a connection to the host and starts up the stream.
|
||||||
*/
|
*/
|
||||||
@@ -106,7 +50,7 @@ public class Limelight implements NvConnectionListener {
|
|||||||
StreamConfiguration streamConfig = createConfiguration(prefs.getResolution());
|
StreamConfiguration streamConfig = createConfiguration(prefs.getResolution());
|
||||||
|
|
||||||
conn = new NvConnection(host, this, streamConfig);
|
conn = new NvConnection(host, this, streamConfig);
|
||||||
streamFrame.build(conn, streamConfig, prefs.getFullscreen());
|
streamFrame.build(this, conn, streamConfig, prefs.getFullscreen());
|
||||||
conn.start(PlatformBinding.getDeviceName(), streamFrame,
|
conn.start(PlatformBinding.getDeviceName(), streamFrame,
|
||||||
VideoDecoderRenderer.FLAG_PREFER_QUALITY,
|
VideoDecoderRenderer.FLAG_PREFER_QUALITY,
|
||||||
PlatformBinding.getAudioRenderer(),
|
PlatformBinding.getAudioRenderer(),
|
||||||
|
|||||||
@@ -79,14 +79,6 @@ public class JavaxAudioRenderer implements AudioRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The callback for the audio stream being initialized and starting to receive.
|
|
||||||
* @param channelCount the number of channels in the audio
|
|
||||||
* @param sampleRate the sample rate for the audio.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void streamInitialized(int channelCount, int sampleRate) {
|
|
||||||
|
|
||||||
private void createSoundLine(int bufferSize) {
|
private void createSoundLine(int bufferSize) {
|
||||||
AudioFormat audioFormat = new AudioFormat(sampleRate, 16, channelCount, true, true);
|
AudioFormat audioFormat = new AudioFormat(sampleRate, 16, channelCount, true, true);
|
||||||
|
|
||||||
@@ -117,6 +109,11 @@ public class JavaxAudioRenderer implements AudioRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The callback for the audio stream being initialized and starting to receive.
|
||||||
|
* @param channelCount the number of channels in the audio
|
||||||
|
* @param sampleRate the sample rate for the audio.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void streamInitialized(int channelCount, int sampleRate) {
|
public void streamInitialized(int channelCount, int sampleRate) {
|
||||||
this.channelCount = channelCount;
|
this.channelCount = channelCount;
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ public class GamepadConfigFrame extends JFrame {
|
|||||||
for (int i = 0; i < components.length; i++) {
|
for (int i = 0; i < components.length; i++) {
|
||||||
|
|
||||||
Mapping mapping = config.get(components[i]);
|
Mapping mapping = config.get(components[i]);
|
||||||
|
if (mapping == null) {
|
||||||
|
mapping = config.new Mapping(components[i], false, false);
|
||||||
|
}
|
||||||
Box componentBox = createComponentBox(mapping);
|
Box componentBox = createComponentBox(mapping);
|
||||||
|
|
||||||
mainPanel.add(componentBox);
|
mainPanel.add(componentBox);
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ public class StreamFrame extends JFrame {
|
|||||||
private Cursor noCursor;
|
private Cursor noCursor;
|
||||||
private Limelight limelight;
|
private Limelight limelight;
|
||||||
|
|
||||||
private NvConnection conn;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the mouse ie. makes it visible and allowed to move outside the frame.
|
* Frees the mouse ie. makes it visible and allowed to move outside the frame.
|
||||||
*/
|
*/
|
||||||
@@ -68,16 +66,14 @@ public class StreamFrame extends JFrame {
|
|||||||
hideCursor();
|
hideCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(Limelight limelight, NvConnection conn, StreamConfiguration streamConfig, boolean fullscreen) {
|
|
||||||
this.limelight = limelight;
|
|
||||||
/**
|
/**
|
||||||
* Builds the components of this frame with the specified configurations.
|
* Builds the components of this frame with the specified configurations.
|
||||||
* @param conn the connection this frame belongs to
|
* @param conn the connection this frame belongs to
|
||||||
* @param streamConfig the configurations for this frame
|
* @param streamConfig the configurations for this frame
|
||||||
* @param fullscreen if the frame should be made fullscreen
|
* @param fullscreen if the frame should be made fullscreen
|
||||||
*/
|
*/
|
||||||
public void build(NvConnection conn, StreamConfiguration streamConfig, boolean fullscreen) {
|
public void build(Limelight limelight, NvConnection conn, StreamConfiguration streamConfig, boolean fullscreen) {
|
||||||
this.conn = conn;
|
this.limelight = limelight;
|
||||||
|
|
||||||
keyboard = new KeyboardHandler(conn, this);
|
keyboard = new KeyboardHandler(conn, this);
|
||||||
mouse = new MouseHandler(conn, this);
|
mouse = new MouseHandler(conn, this);
|
||||||
|
|||||||
Reference in New Issue
Block a user