diff --git a/lib/amr.c b/lib/amr.c index b5d1c7e61..138b37506 100644 --- a/lib/amr.c +++ b/lib/amr.c @@ -126,7 +126,7 @@ static bool amr_format_parse(struct rtp_codec_format *f, const str *fmtp) { // CRC, no robust-sorting, no interleaving). Parse whatever is present. Absent fields keep their // defaults. if (fmtp && fmtp->len) - codeclib_key_value_parse(fmtp, true, amr_parse_format_cb, f); + codeclib_key_value_parse(fmtp, amr_parse_format_cb, f); return true; } static void amr_set_encdec_options(codec_options_t *opts, codec_def_t *def) { @@ -165,7 +165,7 @@ static void amr_set_enc_codec_options(str *key, str *value, void *data) { static void amr_set_enc_options(encoder_t *enc, const str *codec_opts) { amr_set_encdec_options(&enc->codec_options, enc->def); - codeclib_key_value_parse(codec_opts, true, amr_set_enc_codec_options, enc); + codeclib_key_value_parse(codec_opts, amr_set_enc_codec_options, enc); // if a mode-set was given, pick the highest supported bitrate if (enc->format_options.amr.mode_set) { @@ -195,7 +195,7 @@ static void amr_set_enc_options(encoder_t *enc, const str *codec_opts) { } static void amr_set_dec_options(decoder_t *dec, const str *codec_opts) { amr_set_encdec_options(&dec->codec_options, dec->def); - codeclib_key_value_parse(codec_opts, true, amr_set_dec_codec_options, dec); + codeclib_key_value_parse(codec_opts, amr_set_dec_codec_options, dec); } static int amr_mode_set_cmp(unsigned int a, unsigned int b) { if (a && b) { diff --git a/lib/codeclib.c b/lib/codeclib.c index 6c7481bc9..ce669f166 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -877,7 +877,7 @@ int packetizer_samplestream(AVPacket *pkt, GString *buf, str *input_output, size } -void codeclib_key_value_parse(const str *instr, bool need_value, +void codeclib_key_value_parse(const str *instr, void (*cb)(str *key, str *value, void *data), void *data) { if (!instr || !instr->s) @@ -887,11 +887,8 @@ void codeclib_key_value_parse(const str *instr, bool need_value, str s = *instr; str key, value; while (str_token_sep(&value, &s, ';')) { - if (!str_token(&key, &value, '=')) { - if (need_value) - continue; - value = STR_NULL; - } + if (!str_token(&key, &value, '=')) + continue; // truncate whitespace while (key.len && key.s[0] == ' ') diff --git a/lib/codecmod.h b/lib/codecmod.h index 80bd7466d..eb09fe3ea 100644 --- a/lib/codecmod.h +++ b/lib/codecmod.h @@ -27,7 +27,7 @@ int avc_encoder_input(encoder_t *enc, AVFrame **frame); void avc_encoder_close(encoder_t *enc); int codeclib_set_av_opt_int(encoder_t *enc, const char *opt, int64_t val); -void codeclib_key_value_parse(const str *instr, bool need_value, +void codeclib_key_value_parse(const str *instr, void (*cb)(str *key, str *value, void *data), void *data); diff --git a/lib/evs.c b/lib/evs.c index cae51730c..53292103f 100644 --- a/lib/evs.c +++ b/lib/evs.c @@ -658,7 +658,7 @@ static bool evs_format_parse(struct rtp_codec_format *f, const str *fmtp) { f->parsed.evs.max_bw_recv = EVS_BW_UNSPEC; f->parsed.evs.min_bw_recv = EVS_BW_UNSPEC; - codeclib_key_value_parse(fmtp, true, evs_parse_format_cb, &f->parsed); + codeclib_key_value_parse(fmtp, evs_parse_format_cb, &f->parsed); return true; } static void evs_format_answer(struct rtp_payload_type *p, const struct rtp_payload_type *src) { diff --git a/lib/opus.c b/lib/opus.c index c46575307..13cf14c3f 100644 --- a/lib/opus.c +++ b/lib/opus.c @@ -178,7 +178,7 @@ static const char *libopus_encoder_init(encoder_t *enc, const str *extra_opts) { } struct libopus_encoder_options opts = { .vbr = 1, .complexity = 10, .application = OPUS_APPLICATION_VOIP }; - codeclib_key_value_parse(extra_opts, true, libopus_set_enc_opts, &opts); + codeclib_key_value_parse(extra_opts, libopus_set_enc_opts, &opts); int err; enc->opus = opus_encoder_create(enc->requested_format.clockrate, enc->requested_format.channels, @@ -359,7 +359,7 @@ static void opus_parse_format_cb(str *key, str *token, void *data) { } } static bool opus_format_parse(struct rtp_codec_format *f, const str *fmtp) { - codeclib_key_value_parse(fmtp, true, opus_parse_format_cb, &f->parsed); + codeclib_key_value_parse(fmtp, opus_parse_format_cb, &f->parsed); return true; } static GString *opus_format_print(const struct rtp_payload_type *p) {