Use two sockets for video and control

The socket used the device-to-computer direction to stream the video and
the computer-to-device direction to send control events.

Some features, like copy-paste from device to computer, require to send
non-video data from the device to the computer.

To make them possible, use two sockets:
 - one for streaming the video from the device to the client;
 - one for control/events in both directions.
This commit is contained in:
Romain Vimont
2019-05-28 21:03:54 +02:00
parent 69360c7407
commit ec71a3f66a
7 changed files with 81 additions and 49 deletions

View File

@@ -300,15 +300,13 @@ scrcpy(const struct scrcpy_options *options) {
goto end;
}
socket_t device_socket = server.device_socket;
char device_name[DEVICE_NAME_FIELD_LENGTH];
struct size frame_size;
// screenrecord does not send frames when the screen content does not
// change therefore, we transmit the screen size before the video stream,
// to be able to init the window immediately
if (!device_read_info(device_socket, device_name, &frame_size)) {
if (!device_read_info(server.video_socket, device_name, &frame_size)) {
goto end;
}
@@ -344,7 +342,7 @@ scrcpy(const struct scrcpy_options *options) {
av_log_set_callback(av_log_callback);
stream_init(&stream, device_socket, dec, rec);
stream_init(&stream, server.video_socket, dec, rec);
// now we consumed the header values, the socket receives the video stream
// start the stream
@@ -355,7 +353,7 @@ scrcpy(const struct scrcpy_options *options) {
if (display) {
if (control) {
if (!controller_init(&controller, device_socket)) {
if (!controller_init(&controller, server.control_socket)) {
goto end;
}