Move call to send device name and size

This will allow to optionally disable it.

PR #2971 <https://github.com/Genymobile/scrcpy/pull/2971>
raw_video_stream
Romain Vimont 2 years ago
parent f289d206ea
commit 31a5d0c2bf

@ -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);

@ -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());

Loading…
Cancel
Save