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
commit ec71a3f66a
7 changed files with 81 additions and 49 deletions

View file

@ -7,7 +7,7 @@
#include "log.h"
bool
controller_init(struct controller *controller, socket_t video_socket) {
controller_init(struct controller *controller, socket_t control_socket) {
cbuf_init(&controller->queue);
if (!(controller->mutex = SDL_CreateMutex())) {
@ -19,7 +19,7 @@ controller_init(struct controller *controller, socket_t video_socket) {
return false;
}
controller->video_socket = video_socket;
controller->control_socket = control_socket;
controller->stopped = false;
return true;
@ -57,7 +57,7 @@ process_event(struct controller *controller,
if (!length) {
return false;
}
int w = net_send_all(controller->video_socket, serialized_event, length);
int w = net_send_all(controller->control_socket, serialized_event, length);
return w == length;
}