Adding to client.

This commit is contained in:
Tzah Mazuz 2020-04-26 15:22:08 +03:00
parent a14840a515
commit 323f2a1bd8
6 changed files with 28 additions and 6 deletions

View file

@ -176,6 +176,14 @@ Set the initial window height.
Default is 0 (automatic).\n
.TP
.BI "\-\-\codec\-options " 'options'
options is a list of key=value:type pairs seperated by comma\n
for the device encoder.\n
type is optional, Integer by default.\n
For a list of possible codec options:\n
developer.android.com/reference/android/media/MediaFormat\n
.SH SHORTCUTS
.TP

View file

@ -158,6 +158,13 @@ scrcpy_print_usage(const char *arg0) {
" Set the initial window width.\n"
" Default is 0 (automatic).\n"
"\n"
" --codec-options 'options'\n"
" 'options' is a list of key=value:type pairs seperated by comma\n"
" for the device encoder.\n"
" 'type' is optional, Integer by default.\n"
" For a list of possible codec options:\n"
" developer.android.com/reference/android/media/MediaFormat\n"
"\n"
"Shortcuts:\n"
"\n"
" " CTRL_OR_CMD "+f\n"
@ -468,18 +475,19 @@ guess_record_format(const char *filename) {
#define OPT_ROTATION 1015
#define OPT_RENDER_DRIVER 1016
#define OPT_NO_MIPMAPS 1017
#define OPT_CODEC_OPTIONS 1018
bool
scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
static const struct option long_options[] = {
{"always-on-top", no_argument, NULL, OPT_ALWAYS_ON_TOP},
{"bit-rate", required_argument, NULL, 'b'},
{"codec-options", required_argument, NULL, OPT_CODEC_OPTIONS},
{"crop", required_argument, NULL, OPT_CROP},
{"display", required_argument, NULL, OPT_DISPLAY_ID},
{"fullscreen", no_argument, NULL, 'f'},
{"help", no_argument, NULL, 'h'},
{"lock-video-orientation", required_argument, NULL,
OPT_LOCK_VIDEO_ORIENTATION},
{"lock-video-orientation", required_argument, NULL, OPT_LOCK_VIDEO_ORIENTATION},
{"max-fps", required_argument, NULL, OPT_MAX_FPS},
{"max-size", required_argument, NULL, 'm'},
{"no-control", no_argument, NULL, 'n'},
@ -490,8 +498,7 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
{"record", required_argument, NULL, 'r'},
{"record-format", required_argument, NULL, OPT_RECORD_FORMAT},
{"render-driver", required_argument, NULL, OPT_RENDER_DRIVER},
{"render-expired-frames", no_argument, NULL,
OPT_RENDER_EXPIRED_FRAMES},
{"render-expired-frames", no_argument, NULL, OPT_RENDER_EXPIRED_FRAMES},
{"rotation", required_argument, NULL, OPT_ROTATION},
{"serial", required_argument, NULL, 's'},
{"show-touches", no_argument, NULL, 't'},
@ -503,8 +510,7 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
{"window-y", required_argument, NULL, OPT_WINDOW_Y},
{"window-width", required_argument, NULL, OPT_WINDOW_WIDTH},
{"window-height", required_argument, NULL, OPT_WINDOW_HEIGHT},
{"window-borderless", no_argument, NULL,
OPT_WINDOW_BORDERLESS},
{"window-borderless", no_argument, NULL, OPT_WINDOW_BORDERLESS},
{NULL, 0, NULL, 0 },
};
@ -639,6 +645,9 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
case OPT_NO_MIPMAPS:
opts->mipmaps = false;
break;
case OPT_CODEC_OPTIONS:
opts->codec_options = optarg;
break;
default:
// getopt prints the error message on stderr
return false;

View file

@ -292,6 +292,7 @@ scrcpy(const struct scrcpy_options *options) {
.lock_video_orientation = options->lock_video_orientation,
.control = options->control,
.display_id = options->display_id,
.codec_options = options->codec_options,
};
if (!server_start(&server, options->serial, &params)) {
return false;

View file

@ -16,6 +16,7 @@ struct scrcpy_options {
const char *window_title;
const char *push_target;
const char *render_driver;
const char *codec_options;
enum recorder_format record_format;
struct port_range port_range;
uint16_t max_size;
@ -47,6 +48,7 @@ struct scrcpy_options {
.window_title = NULL, \
.push_target = NULL, \
.render_driver = NULL, \
.codec_options = NULL, \
.record_format = RECORDER_FORMAT_AUTO, \
.port_range = { \
.first = DEFAULT_LOCAL_PORT_RANGE_FIRST, \

View file

@ -268,6 +268,7 @@ execute_server(struct server *server, const struct server_params *params) {
"true", // always send frame meta (packet boundaries + timestamp)
params->control ? "true" : "false",
display_id_string,
params->codec_options ? params->codec_options : "-",
};
#ifdef SERVER_DEBUGGER
LOGI("Server debugger waiting for a client on device port "

View file

@ -44,6 +44,7 @@ struct server {
struct server_params {
const char *crop;
const char *codec_options;
struct port_range port_range;
uint16_t max_size;
uint32_t bit_rate;