Add --audio-codec-options

Similar to --video-codec-options, but for audio.

PR #3757 <https://github.com/Genymobile/scrcpy/pull/3757>
This commit is contained in:
Romain Vimont
2023-02-22 22:48:23 +01:00
parent 58cf8e5401
commit b03c864c70
12 changed files with 68 additions and 4 deletions

View File

@@ -66,6 +66,7 @@ enum {
OPT_NO_AUDIO,
OPT_AUDIO_BIT_RATE,
OPT_AUDIO_CODEC,
OPT_AUDIO_CODEC_OPTIONS,
};
struct sc_option {
@@ -122,6 +123,18 @@ static const struct sc_option options[] = {
.text = "Select an audio codec (opus or aac).\n"
"Default is opus.",
},
{
.longopt_id = OPT_AUDIO_CODEC_OPTIONS,
.longopt = "audio-codec-options",
.argdesc = "key[:type]=value[,...]",
.text = "Set a list of comma-separated key:type=value options for the "
"device audio encoder.\n"
"The possible values for 'type' are 'int' (default), 'long', "
"'float' and 'string'.\n"
"The list of possible codec options is available in the "
"Android documentation: "
"<https://d.android.com/reference/android/media/MediaFormat>",
},
{
.shortopt = 'b',
.longopt = "video-bit-rate",
@@ -1672,6 +1685,9 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
case OPT_VIDEO_CODEC_OPTIONS:
opts->video_codec_options = optarg;
break;
case OPT_AUDIO_CODEC_OPTIONS:
opts->audio_codec_options = optarg;
break;
case OPT_ENCODER:
LOGW("--encoder is deprecated, use --video-encoder instead.");
// fall through

View File

@@ -8,6 +8,7 @@ const struct scrcpy_options scrcpy_options_default = {
.push_target = NULL,
.render_driver = NULL,
.video_codec_options = NULL,
.audio_codec_options = NULL,
.video_encoder = NULL,
#ifdef HAVE_V4L2
.v4l2_device = NULL,

View File

@@ -96,6 +96,7 @@ struct scrcpy_options {
const char *push_target;
const char *render_driver;
const char *video_codec_options;
const char *audio_codec_options;
const char *video_encoder;
#ifdef HAVE_V4L2
const char *v4l2_device;

View File

@@ -331,6 +331,7 @@ scrcpy(struct scrcpy_options *options) {
.show_touches = options->show_touches,
.stay_awake = options->stay_awake,
.video_codec_options = options->video_codec_options,
.audio_codec_options = options->audio_codec_options,
.video_encoder = options->video_encoder,
.force_adb_forward = options->force_adb_forward,
.power_off_on_close = options->power_off_on_close,

View File

@@ -72,6 +72,7 @@ sc_server_params_destroy(struct sc_server_params *params) {
free((char *) params->req_serial);
free((char *) params->crop);
free((char *) params->video_codec_options);
free((char *) params->audio_codec_options);
free((char *) params->video_encoder);
free((char *) params->tcpip_dst);
}
@@ -96,6 +97,7 @@ sc_server_params_copy(struct sc_server_params *dst,
COPY(req_serial);
COPY(crop);
COPY(video_codec_options);
COPY(audio_codec_options);
COPY(video_encoder);
COPY(tcpip_dst);
#undef COPY
@@ -268,6 +270,9 @@ execute_server(struct sc_server *server,
if (params->video_codec_options) {
ADD_PARAM("video_codec_options=%s", params->video_codec_options);
}
if (params->audio_codec_options) {
ADD_PARAM("audio_codec_options=%s", params->audio_codec_options);
}
if (params->video_encoder) {
ADD_PARAM("video_encoder=%s", params->video_encoder);
}

View File

@@ -29,6 +29,7 @@ struct sc_server_params {
enum sc_codec audio_codec;
const char *crop;
const char *video_codec_options;
const char *audio_codec_options;
const char *video_encoder;
struct sc_port_range port_range;
uint32_t tunnel_host;