Skip to content

Commit

Permalink
Move call to send device name and size
Browse files Browse the repository at this point in the history
This will allow to optionally disable it.

PR #2971 <#2971>
  • Loading branch information
rom1v committed Jan 26, 2022
1 parent f289d20 commit 31a5d0c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private static LocalSocket connect(String abstractName) throws IOException {
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) {
Expand Down Expand Up @@ -78,10 +78,7 @@ public static DesktopConnection open(Device device, boolean tunnelForward, boole
}
}

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 {
Expand All @@ -95,7 +92,7 @@ public void close() throws IOException {
}
}

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);
Expand Down
4 changes: 3 additions & 1 deletion server/src/main/java/com/genymobile/scrcpy/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ private static void scrcpy(Options options) throws IOException {
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());

Expand Down

0 comments on commit 31a5d0c

Please sign in to comment.