9b056f5091
SDL_net is not very suitable for scrcpy. For example, SDLNet_TCP_Accept() is non-blocking, so we have to wrap it by calling many SDL_Net-specific functions to make it blocking. But above all, SDLNet_TCP_Open() is a server socket only when no IP is provided; otherwise, it's a client socket. Therefore, it is not possible to create a server socket bound to localhost, so it accepts connections from anywhere. This is a problem for scrcpy, because on start, the application listens for nearly 1 second until it accepts the first connection, supposedly from the device. If someone on the local network manages to connect to the server socket first, then they can stream arbitrary H.264 video. This may be troublesome, for example during a public presentation ;-) Provide our own simplified API (net.h) instead, implemented for the different platforms.
14 lines
292 B
C
14 lines
292 B
C
#ifndef DEVICE_H
|
|
#define DEVICE_H
|
|
|
|
#include <SDL2/SDL_stdinc.h>
|
|
|
|
#include "common.h"
|
|
#include "net.h"
|
|
|
|
#define DEVICE_NAME_FIELD_LENGTH 64
|
|
|
|
// name must be at least DEVICE_NAME_FIELD_LENGTH bytes
|
|
SDL_bool device_read_info(socket_t device_socket, char *name, struct size *frame_size);
|
|
|
|
#endif
|