2018-02-08 13:47:31 +01:00
|
|
|
#ifndef SERVER_H
|
|
|
|
#define SERVER_H
|
|
|
|
|
2021-01-08 19:24:51 +01:00
|
|
|
#include "common.h"
|
|
|
|
|
2020-04-02 19:16:33 +02:00
|
|
|
#include <stdatomic.h>
|
2019-03-02 23:52:22 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2021-01-03 14:55:15 +01:00
|
|
|
#include "adb.h"
|
2021-05-09 16:52:22 +02:00
|
|
|
#include "coords.h"
|
2021-10-27 18:43:47 +02:00
|
|
|
#include "options.h"
|
2020-05-24 21:51:40 +02:00
|
|
|
#include "util/log.h"
|
2019-11-24 11:53:00 +01:00
|
|
|
#include "util/net.h"
|
2021-01-31 18:24:35 +01:00
|
|
|
#include "util/thread.h"
|
2018-01-22 11:22:31 +01:00
|
|
|
|
2021-10-30 19:07:35 +02:00
|
|
|
#define DEVICE_NAME_FIELD_LENGTH 64
|
|
|
|
struct server_info {
|
|
|
|
char device_name[DEVICE_NAME_FIELD_LENGTH];
|
|
|
|
struct sc_size frame_size;
|
|
|
|
};
|
|
|
|
|
2019-06-04 23:59:55 +02:00
|
|
|
struct server_params {
|
2021-05-17 09:41:22 +02:00
|
|
|
const char *serial;
|
2020-05-24 21:51:40 +02:00
|
|
|
enum sc_log_level log_level;
|
2019-06-04 23:59:55 +02:00
|
|
|
const char *crop;
|
2020-04-26 15:22:08 +03:00
|
|
|
const char *codec_options;
|
2020-10-12 12:23:06 +03:00
|
|
|
const char *encoder_name;
|
2020-06-19 22:04:06 +02:00
|
|
|
struct sc_port_range port_range;
|
2019-06-04 23:59:55 +02:00
|
|
|
uint16_t max_size;
|
|
|
|
uint32_t bit_rate;
|
2019-11-17 22:07:19 +01:00
|
|
|
uint16_t max_fps;
|
2020-02-16 13:30:36 +02:00
|
|
|
int8_t lock_video_orientation;
|
2019-06-04 21:31:46 +02:00
|
|
|
bool control;
|
2021-01-04 08:16:32 +01:00
|
|
|
uint32_t display_id;
|
2020-05-01 23:49:37 +02:00
|
|
|
bool show_touches;
|
2020-05-02 01:54:48 +02:00
|
|
|
bool stay_awake;
|
2020-05-24 23:27:34 +02:00
|
|
|
bool force_adb_forward;
|
2021-02-21 08:42:04 +08:00
|
|
|
bool power_off_on_close;
|
2019-06-04 23:59:55 +02:00
|
|
|
};
|
|
|
|
|
2021-10-27 23:20:47 +02:00
|
|
|
struct server {
|
|
|
|
char *serial;
|
|
|
|
|
|
|
|
sc_pid process;
|
|
|
|
// alive only between start() and stop()
|
|
|
|
struct sc_process_observer observer;
|
|
|
|
|
|
|
|
sc_socket server_socket; // only used if !tunnel_forward
|
|
|
|
sc_socket video_socket;
|
|
|
|
sc_socket control_socket;
|
|
|
|
uint16_t local_port; // selected from port_range
|
|
|
|
bool tunnel_enabled;
|
|
|
|
bool tunnel_forward; // use "adb forward" instead of "adb reverse"
|
|
|
|
};
|
|
|
|
|
2018-02-08 15:16:27 +01:00
|
|
|
// init default values
|
2021-01-01 16:34:47 +01:00
|
|
|
bool
|
2019-03-02 20:09:56 +01:00
|
|
|
server_init(struct server *server);
|
2018-02-08 15:16:27 +01:00
|
|
|
|
|
|
|
// push, enable tunnel et start the server
|
2019-03-02 23:52:22 +01:00
|
|
|
bool
|
2021-05-17 09:41:22 +02:00
|
|
|
server_start(struct server *server, const struct server_params *params);
|
2018-02-08 15:16:27 +01:00
|
|
|
|
|
|
|
// block until the communication with the server is established
|
2019-05-28 13:41:19 +02:00
|
|
|
bool
|
2021-10-30 19:07:35 +02:00
|
|
|
server_connect_to(struct server *server, struct server_info *info);
|
2018-02-08 15:16:27 +01:00
|
|
|
|
|
|
|
// disconnect and kill the server process
|
2019-03-02 20:09:56 +01:00
|
|
|
void
|
|
|
|
server_stop(struct server *server);
|
2018-02-08 13:47:31 +01:00
|
|
|
|
2018-02-09 12:59:36 +01:00
|
|
|
// close and release sockets
|
2019-03-02 20:09:56 +01:00
|
|
|
void
|
|
|
|
server_destroy(struct server *server);
|
2018-02-09 12:59:36 +01:00
|
|
|
|
2018-02-08 13:47:31 +01:00
|
|
|
#endif
|