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>
|
|
|
|
|
2022-02-03 22:46:24 +01:00
|
|
|
#include "adb/adb_tunnel.h"
|
2021-05-09 16:52:22 +02:00
|
|
|
#include "coords.h"
|
2021-10-27 18:43:47 +02:00
|
|
|
#include "options.h"
|
2021-11-12 18:50:50 +01:00
|
|
|
#include "util/intr.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-11-12 23:24:12 +01:00
|
|
|
#define SC_DEVICE_NAME_FIELD_LENGTH 64
|
|
|
|
struct sc_server_info {
|
|
|
|
char device_name[SC_DEVICE_NAME_FIELD_LENGTH];
|
2021-10-30 19:07:35 +02:00
|
|
|
};
|
|
|
|
|
2021-11-12 23:24:12 +01:00
|
|
|
struct sc_server_params {
|
2023-02-11 09:52:31 +01:00
|
|
|
uint32_t scid;
|
2022-02-04 20:49:35 +01:00
|
|
|
const char *req_serial;
|
2020-05-24 21:51:40 +02:00
|
|
|
enum sc_log_level log_level;
|
2023-02-20 21:19:36 +01:00
|
|
|
enum sc_codec video_codec;
|
2023-02-18 19:05:43 +01:00
|
|
|
enum sc_codec audio_codec;
|
2023-07-16 17:07:19 +08:00
|
|
|
enum sc_video_source video_source;
|
2023-05-30 21:29:05 +02:00
|
|
|
enum sc_audio_source audio_source;
|
2023-07-22 17:17:05 +08:00
|
|
|
enum sc_camera_facing camera_facing;
|
2019-06-04 23:59:55 +02:00
|
|
|
const char *crop;
|
2023-02-21 21:46:34 +01:00
|
|
|
const char *video_codec_options;
|
2023-02-22 22:48:23 +01:00
|
|
|
const char *audio_codec_options;
|
2023-02-22 22:44:01 +01:00
|
|
|
const char *video_encoder;
|
2023-02-19 20:20:29 +01:00
|
|
|
const char *audio_encoder;
|
2023-07-16 17:07:19 +08:00
|
|
|
const char *camera_id;
|
|
|
|
const char *camera_size;
|
2023-10-26 23:54:34 +02:00
|
|
|
const char *camera_ar;
|
2023-10-27 20:20:19 -04:00
|
|
|
uint16_t camera_fps;
|
2020-06-19 22:04:06 +02:00
|
|
|
struct sc_port_range port_range;
|
2021-11-18 01:02:53 +01:00
|
|
|
uint32_t tunnel_host;
|
|
|
|
uint16_t tunnel_port;
|
2019-06-04 23:59:55 +02:00
|
|
|
uint16_t max_size;
|
2023-02-21 19:56:44 +01:00
|
|
|
uint32_t video_bit_rate;
|
2023-02-18 18:32:43 +01:00
|
|
|
uint32_t audio_bit_rate;
|
2024-09-14 14:32:32 +02:00
|
|
|
const char *max_fps; // float to be parsed by the server
|
2024-11-15 19:17:04 +01:00
|
|
|
const char *angle; // float to be parsed by the server
|
2024-11-03 22:46:21 +01:00
|
|
|
sc_tick screen_off_timeout;
|
Add --capture-orientation
Deprecate --lock-video-orientation in favor of a more general option
--capture-orientation, which supports all possible orientations
(0, 90, 180, 270, flip0, flip90, flip180, flip270), and a "locked" flag
via a '@' prefix.
All the old "locked video orientations" are supported:
- --lock-video-orientation -> --capture-orientation=@
- --lock-video-orientation=0 -> --capture-orientation=@0
- --lock-video-orientation=90 -> --capture-orientation=@90
- --lock-video-orientation=180 -> --capture-orientation=@180
- --lock-video-orientation=270 -> --capture-orientation=@270
In addition, --capture-orientation can rotate/flip the display without
locking, so that it follows the physical device rotation.
For example:
scrcpy --capture-orientation=flip90
always flips and rotates the capture by 90° clockwise.
The arguments are consistent with --display-orientation and
--record-orientation and --orientation (which provide separate
client-side orientation settings).
Refs #4011 <https://github.com/Genymobile/scrcpy/issues/4011>
PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
2024-11-14 20:19:40 +01:00
|
|
|
enum sc_orientation capture_orientation;
|
|
|
|
enum sc_orientation_lock capture_orientation_lock;
|
2019-06-04 21:31:46 +02:00
|
|
|
bool control;
|
2021-01-04 08:16:32 +01:00
|
|
|
uint32_t display_id;
|
2024-10-12 09:23:31 +02:00
|
|
|
const char *new_display;
|
2023-05-07 12:08:50 +02:00
|
|
|
bool video;
|
2023-02-03 16:27:34 +01:00
|
|
|
bool audio;
|
2024-07-16 20:56:18 +02:00
|
|
|
bool audio_dup;
|
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;
|
2021-11-22 08:49:10 +01:00
|
|
|
bool clipboard_autosync;
|
2022-01-15 23:01:14 +01:00
|
|
|
bool downsize_on_error;
|
2021-11-25 22:22:49 +01:00
|
|
|
bool tcpip;
|
|
|
|
const char *tcpip_dst;
|
2022-02-06 18:40:18 +01:00
|
|
|
bool select_usb;
|
|
|
|
bool select_tcpip;
|
2022-02-13 17:17:01 +01:00
|
|
|
bool cleanup;
|
2022-04-23 15:08:30 +02:00
|
|
|
bool power_on;
|
2023-06-05 19:48:21 +02:00
|
|
|
bool kill_adb_on_close;
|
2023-10-27 20:20:19 -04:00
|
|
|
bool camera_high_speed;
|
2024-12-05 21:02:50 +01:00
|
|
|
bool vd_destroy_content;
|
2024-11-16 22:45:38 +01:00
|
|
|
bool vd_system_decorations;
|
2023-10-24 23:54:56 +02:00
|
|
|
uint8_t list;
|
2019-06-04 23:59:55 +02:00
|
|
|
};
|
|
|
|
|
2021-11-12 23:24:12 +01:00
|
|
|
struct sc_server {
|
2021-10-27 23:40:52 +02:00
|
|
|
// The internal allocated strings are copies owned by the server
|
2021-11-12 23:24:12 +01:00
|
|
|
struct sc_server_params params;
|
2022-02-04 20:49:35 +01:00
|
|
|
char *serial;
|
2023-01-27 21:48:54 +01:00
|
|
|
char *device_socket_name;
|
2021-10-27 23:20:47 +02:00
|
|
|
|
2021-10-30 15:33:23 +02:00
|
|
|
sc_thread thread;
|
2021-11-12 23:24:12 +01:00
|
|
|
struct sc_server_info info; // initialized once connected
|
2021-10-27 23:20:47 +02:00
|
|
|
|
2021-10-31 14:56:37 +01:00
|
|
|
sc_mutex mutex;
|
|
|
|
sc_cond cond_stopped;
|
|
|
|
bool stopped;
|
|
|
|
|
2021-11-12 18:50:50 +01:00
|
|
|
struct sc_intr intr;
|
2021-11-12 22:32:29 +01:00
|
|
|
struct sc_adb_tunnel tunnel;
|
2021-11-12 18:50:50 +01:00
|
|
|
|
2021-10-27 23:20:47 +02:00
|
|
|
sc_socket video_socket;
|
2023-02-03 16:50:42 +01:00
|
|
|
sc_socket audio_socket;
|
2021-10-27 23:20:47 +02:00
|
|
|
sc_socket control_socket;
|
2021-10-30 15:33:23 +02:00
|
|
|
|
2021-11-12 23:24:12 +01:00
|
|
|
const struct sc_server_callbacks *cbs;
|
2021-10-30 15:33:23 +02:00
|
|
|
void *cbs_userdata;
|
|
|
|
};
|
|
|
|
|
2021-11-12 23:24:12 +01:00
|
|
|
struct sc_server_callbacks {
|
2021-10-30 15:33:23 +02:00
|
|
|
/**
|
|
|
|
* Called when the server failed to connect
|
|
|
|
*
|
|
|
|
* If it is called, then on_connected() and on_disconnected() will never be
|
|
|
|
* called.
|
|
|
|
*/
|
2021-11-12 23:24:12 +01:00
|
|
|
void (*on_connection_failed)(struct sc_server *server, void *userdata);
|
2021-10-30 15:33:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called on server connection
|
|
|
|
*/
|
2021-11-12 23:24:12 +01:00
|
|
|
void (*on_connected)(struct sc_server *server, void *userdata);
|
2021-10-30 15:33:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called on server disconnection (after it has been connected)
|
|
|
|
*/
|
2021-11-12 23:24:12 +01:00
|
|
|
void (*on_disconnected)(struct sc_server *server, void *userdata);
|
2021-10-27 23:20:47 +02:00
|
|
|
};
|
|
|
|
|
2021-10-27 23:40:52 +02:00
|
|
|
// init the server with the given params
|
2021-01-01 16:34:47 +01:00
|
|
|
bool
|
2021-11-12 23:24:12 +01:00
|
|
|
sc_server_init(struct sc_server *server, const struct sc_server_params *params,
|
|
|
|
const struct sc_server_callbacks *cbs, void *cbs_userdata);
|
2018-02-08 15:16:27 +01:00
|
|
|
|
2021-10-30 15:33:23 +02:00
|
|
|
// start the server asynchronously
|
2019-03-02 23:52:22 +01:00
|
|
|
bool
|
2021-11-12 23:24:12 +01:00
|
|
|
sc_server_start(struct sc_server *server);
|
2018-02-08 15:16:27 +01:00
|
|
|
|
|
|
|
// disconnect and kill the server process
|
2019-03-02 20:09:56 +01:00
|
|
|
void
|
2021-11-12 23:24:12 +01:00
|
|
|
sc_server_stop(struct sc_server *server);
|
2018-02-08 13:47:31 +01:00
|
|
|
|
2023-02-22 18:41:22 +01:00
|
|
|
// join the server thread
|
|
|
|
void
|
|
|
|
sc_server_join(struct sc_server *server);
|
|
|
|
|
2018-02-09 12:59:36 +01:00
|
|
|
// close and release sockets
|
2019-03-02 20:09:56 +01:00
|
|
|
void
|
2021-11-12 23:24:12 +01:00
|
|
|
sc_server_destroy(struct sc_server *server);
|
2018-02-09 12:59:36 +01:00
|
|
|
|
2018-02-08 13:47:31 +01:00
|
|
|
#endif
|