diff --git a/lib/codeclib.c b/lib/codeclib.c index 5e2082f38..f056c0a90 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -63,6 +63,8 @@ static int ilbc_decoder_input(decoder_t *dec, const str *data, GQueue *out); static const char *dtmf_decoder_init(decoder_t *, const str *, const str *); static int dtmf_decoder_input(decoder_t *dec, const str *data, GQueue *out); +static int format_cmp_ignore(const struct rtp_payload_type *, const struct rtp_payload_type *); + @@ -396,6 +398,7 @@ static codec_def_t __codec_defs[] = { .default_clockrate = 8000, .default_channels = 1, .default_fmtp = "0-15", + .format_cmp = format_cmp_ignore, .codec_type = &codec_type_dtmf, .support_encoding = 1, .support_decoding = 1, @@ -2276,3 +2279,9 @@ static int dtmf_decoder_input(decoder_t *dec, const str *data, GQueue *out) { return 0; } + + + +static int format_cmp_ignore(const struct rtp_payload_type *a, const struct rtp_payload_type *b) { + return 0; +} diff --git a/lib/codeclib.h b/lib/codeclib.h index fef9181c9..94f3c0498 100644 --- a/lib/codeclib.h +++ b/lib/codeclib.h @@ -71,6 +71,7 @@ typedef int packetizer_f(AVPacket *, GString *, str *, encoder_t *); typedef void format_init_f(struct rtp_payload_type *); typedef void set_enc_options_f(encoder_t *, const str *, const str *); typedef void set_dec_options_f(decoder_t *, const str *, const str *); +typedef int format_cmp_f(const struct rtp_payload_type *, const struct rtp_payload_type *); @@ -126,6 +127,7 @@ struct codec_def_s { const int default_bitrate; int default_ptime; const char *default_fmtp; + format_cmp_f * const format_cmp; packetizer_f * const packetizer; const int bits_per_sample; const enum media_type media_type; diff --git a/lib/rtplib.c b/lib/rtplib.c index 1c5c6dec6..037302a46 100644 --- a/lib/rtplib.c +++ b/lib/rtplib.c @@ -145,6 +145,10 @@ const struct rtp_payload_type *rtp_get_rfc_codec(const str *codec) { int rtp_payload_type_cmp(const struct rtp_payload_type *a, const struct rtp_payload_type *b) { if (rtp_payload_type_cmp_nf(a, b)) return 1; + if (a->codec_def && a->codec_def == b->codec_def) { + if (a->codec_def->format_cmp) + return a->codec_def->format_cmp(a, b); + } if (str_cmp_str(&a->format_parameters, &b->format_parameters)) return 1; return 0; diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index 3632f619b..6e9debdef 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -36,10 +36,257 @@ my ($sock_a, $sock_b, $sock_c, $sock_d, $port_a, $port_b, $ssrc, $resp, -# inject DTMF with mismatched codecs +if (0) { + +# GH 1098 + +new_call; + +offer('gh 1098', { + codec => { + mask => ['all'], + transcode => ['G722', 'AMR-WB/16000/1///mode-set--0,1,2;mode-change-period--2;mode-change-capability--2/dtx--1', 'AMR', 'PCMA', 'telephone-event'], + } +}, < ['single-codec'], +}, < { + mask => ['all'], + transcode => ['G722', 'AMR-WB/16000/1///mode-set--0,1,2;mode-change-period--2;mode-change-capability--2/dtx--1', 'AMR', 'PCMA', 'telephone-event'], + } +}, < { + strip => ['all'], + offer => ['PCMA'], + } +}, < { + mask => ['all'], + transcode => ['G722', 'AMR-WB/16000/1///mode-set--0,1,2;mode-change-period--2;mode-change-capability--2/dtx--1', 'AMR', 'PCMA', 'telephone-event'], + } +}, < { + strip => ['all'], + offer => ['PCMA', 'telephone-event'], + } +}, <