Display and control your Android device
Move call to send device name and size
Romain Vimont31a5d0c2bfab
diff --git a/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java b/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.javaindex 40cb088c..ca20c1d8 100644--- a/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java+++ b/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java@@ -46,7 +46,7 @@ public final class DesktopConnection implements Closeable {return localSocket;}- public static DesktopConnection open(Device device, boolean tunnelForward, boolean control) throws IOException {+ public static DesktopConnection open(boolean tunnelForward, boolean control) throws IOException {LocalSocket videoSocket;LocalSocket controlSocket = null;if (tunnelForward) {@@ -78,10 +78,7 @@ public final class DesktopConnection implements Closeable {}}- DesktopConnection connection = new DesktopConnection(videoSocket, controlSocket);- Size videoSize = device.getScreenInfo().getVideoSize();- connection.send(Device.getDeviceName(), videoSize.getWidth(), videoSize.getHeight());- return connection;+ return new DesktopConnection(videoSocket, controlSocket);}public void close() throws IOException {@@ -95,7 +92,7 @@ public final class DesktopConnection implements Closeable {}}- private void send(String deviceName, int width, int height) throws IOException {+ public void sendDeviceMeta(String deviceName, int width, int height) throws IOException {byte[] buffer = new byte[DEVICE_NAME_FIELD_LENGTH + 4];byte[] deviceNameBytes = deviceName.getBytes(StandardCharsets.UTF_8);diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.javaindex 9d7a62e3..6dc0b2c6 100644--- a/server/src/main/java/com/genymobile/scrcpy/Server.java+++ b/server/src/main/java/com/genymobile/scrcpy/Server.java@@ -67,7 +67,9 @@ public final class Server {boolean tunnelForward = options.isTunnelForward();boolean control = options.getControl();- try (DesktopConnection connection = DesktopConnection.open(device, tunnelForward, control)) {+ try (DesktopConnection connection = DesktopConnection.open(tunnelForward, control)) {+ Size videoSize = device.getScreenInfo().getVideoSize();+ connection.sendDeviceMeta(Device.getDeviceName(), videoSize.getWidth(), videoSize.getHeight());ScreenEncoder screenEncoder = new ScreenEncoder(options.getSendFrameMeta(), options.getBitRate(), options.getMaxFps(), codecOptions,options.getEncoderName(), options.getDownsizeOnError());