mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-07-14 04:51:41 +00:00
Changing codec-profile -> codec-options
This commit is contained in:
parent
c265d6306e
commit
aa42833cbb
6 changed files with 20 additions and 61 deletions
|
@ -153,7 +153,7 @@ Default is 0 (automatic).\n
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "\-\-\codec\-options " 'options'
|
.BI "\-\-\codec\-options " 'options'
|
||||||
'options' is a list of key=value pairs seperated by comma\n
|
options is a list of key=value pairs seperated by comma\n
|
||||||
for the device encoder.\n
|
for the device encoder.\n
|
||||||
For a list of possible codec options:\n
|
For a list of possible codec options:\n
|
||||||
https://developer.android.com/reference/android/media/MediaCodecInfo\n
|
https://developer.android.com/reference/android/media/MediaCodecInfo\n
|
||||||
|
|
|
@ -130,11 +130,12 @@ scrcpy_print_usage(const char *arg0) {
|
||||||
" Set the initial window width.\n"
|
" Set the initial window width.\n"
|
||||||
" Default is 0 (automatic).\n"
|
" Default is 0 (automatic).\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -P, --codec-profile value\n"
|
" --codec-options 'options'\n"
|
||||||
" Request specific encoding codec profile, see AVC profiles at:\n"
|
" 'options' is a list of key=value pairs seperated by comma\n"
|
||||||
" https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel\n"
|
" for the device encoder.\n"
|
||||||
" for valid codec profile values.\n"
|
" For a list of possible codec options:\n"
|
||||||
" Default is 0 (automatic).\n"
|
" https://developer.android.com/reference/android/media/MediaCodecInfo\n"
|
||||||
|
" Currently supported keys: [profile, level].\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Shortcuts:\n"
|
"Shortcuts:\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -374,35 +375,6 @@ parse_record_format(const char *optarg, enum recorder_format *format) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
parse_codec_profile(const char *optarg, uint32_t *codec_profile) {
|
|
||||||
long value;
|
|
||||||
// long may be 32 bits (it is the case on mingw), so do not use more than
|
|
||||||
// 31 bits (long is signed)
|
|
||||||
bool ok = parse_integer_arg(optarg, &value, true, 0, 0x7FFFFFFF, "codec-profile");
|
|
||||||
if (!ok) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (value) {
|
|
||||||
case 0: // Automatic
|
|
||||||
case 0x01: // AVCProfileBaseline
|
|
||||||
case 0x02: // AVCProfileMain
|
|
||||||
case 0x04: // AVCProfileExtended
|
|
||||||
case 0x08: // AVCProfileHigh
|
|
||||||
case 0x10: // AVCProfileHigh10
|
|
||||||
case 0x20: // AVCProfileHigh422
|
|
||||||
case 0x40: // AVCProfileHigh444
|
|
||||||
case 0x10000: // AVCProfileConstrainedBaseline
|
|
||||||
case 0x80000: // AVCProfileConstrainedHigh
|
|
||||||
*codec_profile = (uint32_t) value;
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
LOGE("Invalid codec-profile, Use -h for help");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum recorder_format
|
static enum recorder_format
|
||||||
guess_record_format(const char *filename) {
|
guess_record_format(const char *filename) {
|
||||||
size_t len = strlen(filename);
|
size_t len = strlen(filename);
|
||||||
|
@ -433,6 +405,7 @@ guess_record_format(const char *filename) {
|
||||||
#define OPT_WINDOW_BORDERLESS 1011
|
#define OPT_WINDOW_BORDERLESS 1011
|
||||||
#define OPT_MAX_FPS 1012
|
#define OPT_MAX_FPS 1012
|
||||||
#define OPT_LOCK_VIDEO_ORIENTATION 1013
|
#define OPT_LOCK_VIDEO_ORIENTATION 1013
|
||||||
|
#define OPT_CODEC_OPTIONS 1014
|
||||||
|
|
||||||
bool
|
bool
|
||||||
scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
||||||
|
@ -442,8 +415,7 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
||||||
{"crop", required_argument, NULL, OPT_CROP},
|
{"crop", required_argument, NULL, OPT_CROP},
|
||||||
{"fullscreen", no_argument, NULL, 'f'},
|
{"fullscreen", no_argument, NULL, 'f'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"lock-video-orientation", required_argument, NULL,
|
{"lock-video-orientation", required_argument, NULL, OPT_LOCK_VIDEO_ORIENTATION},
|
||||||
OPT_LOCK_VIDEO_ORIENTATION},
|
|
||||||
{"max-fps", required_argument, NULL, OPT_MAX_FPS},
|
{"max-fps", required_argument, NULL, OPT_MAX_FPS},
|
||||||
{"max-size", required_argument, NULL, 'm'},
|
{"max-size", required_argument, NULL, 'm'},
|
||||||
{"no-control", no_argument, NULL, 'n'},
|
{"no-control", no_argument, NULL, 'n'},
|
||||||
|
@ -452,8 +424,7 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
||||||
{"push-target", required_argument, NULL, OPT_PUSH_TARGET},
|
{"push-target", required_argument, NULL, OPT_PUSH_TARGET},
|
||||||
{"record", required_argument, NULL, 'r'},
|
{"record", required_argument, NULL, 'r'},
|
||||||
{"record-format", required_argument, NULL, OPT_RECORD_FORMAT},
|
{"record-format", required_argument, NULL, OPT_RECORD_FORMAT},
|
||||||
{"render-expired-frames", no_argument, NULL,
|
{"render-expired-frames", no_argument, NULL, OPT_RENDER_EXPIRED_FRAMES},
|
||||||
OPT_RENDER_EXPIRED_FRAMES},
|
|
||||||
{"serial", required_argument, NULL, 's'},
|
{"serial", required_argument, NULL, 's'},
|
||||||
{"show-touches", no_argument, NULL, 't'},
|
{"show-touches", no_argument, NULL, 't'},
|
||||||
{"turn-screen-off", no_argument, NULL, 'S'},
|
{"turn-screen-off", no_argument, NULL, 'S'},
|
||||||
|
@ -464,9 +435,8 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
||||||
{"window-y", required_argument, NULL, OPT_WINDOW_Y},
|
{"window-y", required_argument, NULL, OPT_WINDOW_Y},
|
||||||
{"window-width", required_argument, NULL, OPT_WINDOW_WIDTH},
|
{"window-width", required_argument, NULL, OPT_WINDOW_WIDTH},
|
||||||
{"window-height", required_argument, NULL, OPT_WINDOW_HEIGHT},
|
{"window-height", required_argument, NULL, OPT_WINDOW_HEIGHT},
|
||||||
{"window-borderless", no_argument, NULL,
|
{"window-borderless", no_argument, NULL, OPT_WINDOW_BORDERLESS},
|
||||||
OPT_WINDOW_BORDERLESS},
|
{"codec-options", required_argument, NULL, OPT_CODEC_OPTIONS},
|
||||||
{"codec-profile", required_argument, NULL, 'P'},
|
|
||||||
{NULL, 0, NULL, 0 },
|
{NULL, 0, NULL, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -475,11 +445,7 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
||||||
optind = 0; // reset to start from the first argument in tests
|
optind = 0; // reset to start from the first argument in tests
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
<<<<<<< HEAD
|
while ((c = getopt_long(argc, argv, "b:c:fF:hm:nNp:r:s:StTv:", long_options,
|
||||||
while ((c = getopt_long(argc, argv, "b:c:fF:hm:nNp:r:s:StTv:P:", long_options,
|
|
||||||
=======
|
|
||||||
while ((c = getopt_long(argc, argv, "b:c:fF:hm:nNp:r:s:StTv", long_options,
|
|
||||||
>>>>>>> 1b12204... fixup! Added help and parsing of the codec-profile option
|
|
||||||
NULL)) != -1) {
|
NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'b':
|
case 'b':
|
||||||
|
@ -589,10 +555,8 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
||||||
case OPT_PREFER_TEXT:
|
case OPT_PREFER_TEXT:
|
||||||
opts->prefer_text = true;
|
opts->prefer_text = true;
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case OPT_CODEC_OPTIONS:
|
||||||
if (!parse_codec_profile(optarg, &opts->codec_profile)) {
|
opts->codec_options = optarg;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// getopt prints the error message on stderr
|
// getopt prints the error message on stderr
|
||||||
|
|
|
@ -286,7 +286,7 @@ scrcpy(const struct scrcpy_options *options) {
|
||||||
.max_fps = options->max_fps,
|
.max_fps = options->max_fps,
|
||||||
.lock_video_orientation = options->lock_video_orientation,
|
.lock_video_orientation = options->lock_video_orientation,
|
||||||
.control = options->control,
|
.control = options->control,
|
||||||
.codec_profile = options->codec_profile,
|
.codec_options = options->codec_options,
|
||||||
};
|
};
|
||||||
if (!server_start(&server, options->serial, ¶ms)) {
|
if (!server_start(&server, options->serial, ¶ms)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -15,6 +15,7 @@ struct scrcpy_options {
|
||||||
const char *record_filename;
|
const char *record_filename;
|
||||||
const char *window_title;
|
const char *window_title;
|
||||||
const char *push_target;
|
const char *push_target;
|
||||||
|
const char *codec_options;
|
||||||
enum recorder_format record_format;
|
enum recorder_format record_format;
|
||||||
struct port_range port_range;
|
struct port_range port_range;
|
||||||
uint16_t max_size;
|
uint16_t max_size;
|
||||||
|
@ -34,7 +35,6 @@ struct scrcpy_options {
|
||||||
bool render_expired_frames;
|
bool render_expired_frames;
|
||||||
bool prefer_text;
|
bool prefer_text;
|
||||||
bool window_borderless;
|
bool window_borderless;
|
||||||
uint32_t codec_profile;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SCRCPY_OPTIONS_DEFAULT { \
|
#define SCRCPY_OPTIONS_DEFAULT { \
|
||||||
|
@ -43,6 +43,7 @@ struct scrcpy_options {
|
||||||
.record_filename = NULL, \
|
.record_filename = NULL, \
|
||||||
.window_title = NULL, \
|
.window_title = NULL, \
|
||||||
.push_target = NULL, \
|
.push_target = NULL, \
|
||||||
|
.codec_options = NULL, \
|
||||||
.record_format = RECORDER_FORMAT_AUTO, \
|
.record_format = RECORDER_FORMAT_AUTO, \
|
||||||
.port_range = { \
|
.port_range = { \
|
||||||
.first = DEFAULT_LOCAL_PORT_RANGE_FIRST, \
|
.first = DEFAULT_LOCAL_PORT_RANGE_FIRST, \
|
||||||
|
@ -65,7 +66,6 @@ struct scrcpy_options {
|
||||||
.render_expired_frames = false, \
|
.render_expired_frames = false, \
|
||||||
.prefer_text = false, \
|
.prefer_text = false, \
|
||||||
.window_borderless = false, \
|
.window_borderless = false, \
|
||||||
.codec_profile = 0, \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -234,12 +234,10 @@ execute_server(struct server *server, const struct server_params *params) {
|
||||||
char bit_rate_string[11];
|
char bit_rate_string[11];
|
||||||
char max_fps_string[6];
|
char max_fps_string[6];
|
||||||
char lock_video_orientation_string[3];
|
char lock_video_orientation_string[3];
|
||||||
char codec_profile_string[11];
|
|
||||||
sprintf(max_size_string, "%"PRIu16, params->max_size);
|
sprintf(max_size_string, "%"PRIu16, params->max_size);
|
||||||
sprintf(bit_rate_string, "%"PRIu32, params->bit_rate);
|
sprintf(bit_rate_string, "%"PRIu32, params->bit_rate);
|
||||||
sprintf(max_fps_string, "%"PRIu16, params->max_fps);
|
sprintf(max_fps_string, "%"PRIu16, params->max_fps);
|
||||||
sprintf(lock_video_orientation_string, "%"PRIi8, params->lock_video_orientation);
|
sprintf(lock_video_orientation_string, "%"PRIi8, params->lock_video_orientation);
|
||||||
sprintf(codec_profile_string, "%"PRIu32, params->codec_profile);
|
|
||||||
const char *const cmd[] = {
|
const char *const cmd[] = {
|
||||||
"shell",
|
"shell",
|
||||||
"CLASSPATH=" DEVICE_SERVER_PATH,
|
"CLASSPATH=" DEVICE_SERVER_PATH,
|
||||||
|
@ -256,7 +254,7 @@ execute_server(struct server *server, const struct server_params *params) {
|
||||||
bit_rate_string,
|
bit_rate_string,
|
||||||
max_fps_string,
|
max_fps_string,
|
||||||
lock_video_orientation_string,
|
lock_video_orientation_string,
|
||||||
codec_profile_string,
|
params->codec_options ? params->codec_options : "-",
|
||||||
server->tunnel_forward ? "true" : "false",
|
server->tunnel_forward ? "true" : "false",
|
||||||
params->crop ? params->crop : "-",
|
params->crop ? params->crop : "-",
|
||||||
"true", // always send frame meta (packet boundaries + timestamp)
|
"true", // always send frame meta (packet boundaries + timestamp)
|
||||||
|
@ -330,7 +328,6 @@ bool
|
||||||
server_start(struct server *server, const char *serial,
|
server_start(struct server *server, const char *serial,
|
||||||
const struct server_params *params) {
|
const struct server_params *params) {
|
||||||
server->port_range = params->port_range;
|
server->port_range = params->port_range;
|
||||||
server->codec_profile = params->codec_profile;
|
|
||||||
|
|
||||||
if (serial) {
|
if (serial) {
|
||||||
server->serial = SDL_strdup(serial);
|
server->serial = SDL_strdup(serial);
|
||||||
|
|
|
@ -19,7 +19,6 @@ struct server {
|
||||||
uint16_t local_port; // selected from port_range
|
uint16_t local_port; // selected from port_range
|
||||||
bool tunnel_enabled;
|
bool tunnel_enabled;
|
||||||
bool tunnel_forward; // use "adb forward" instead of "adb reverse"
|
bool tunnel_forward; // use "adb forward" instead of "adb reverse"
|
||||||
uint32_t codec_profile;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SERVER_INITIALIZER { \
|
#define SERVER_INITIALIZER { \
|
||||||
|
@ -35,7 +34,6 @@ struct server {
|
||||||
.local_port = 0, \
|
.local_port = 0, \
|
||||||
.tunnel_enabled = false, \
|
.tunnel_enabled = false, \
|
||||||
.tunnel_forward = false, \
|
.tunnel_forward = false, \
|
||||||
.codec_profile = 0, \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct server_params {
|
struct server_params {
|
||||||
|
@ -46,7 +44,7 @@ struct server_params {
|
||||||
uint16_t max_fps;
|
uint16_t max_fps;
|
||||||
int8_t lock_video_orientation;
|
int8_t lock_video_orientation;
|
||||||
bool control;
|
bool control;
|
||||||
uint32_t codec_profile;
|
char *codec_options;
|
||||||
};
|
};
|
||||||
|
|
||||||
// init default values
|
// init default values
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue