From 5e914efc8c0452647dc33f810dd020f8e93d4f5d Mon Sep 17 00:00:00 2001 From: Dragos Oancea Date: Thu, 11 May 2023 03:55:11 +0300 Subject: [PATCH] [core, mod_opus] bring more fmtp params to core (offer/answer). --- src/include/switch_module_interfaces.h | 10 ++++++++-- src/mod/codecs/mod_opus/mod_opus.c | 3 +++ src/switch_core_media.c | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index 7c54ed67df..ddaaf120a1 100644 --- a/src/include/switch_module_interfaces.h +++ b/src/include/switch_module_interfaces.h @@ -676,8 +676,14 @@ struct switch_codec_fmtp { int bits_per_second; /*! number of microseconds of media in one packet (ptime * 1000) */ int microseconds_per_packet; - /*! stereo */ - int stereo; + /*! maximum ptime in ms */ + int max_ptime; + /*! minimum ptime in ms */ + int min_ptime; + /*! stereo, typically bidirectional */ + int stereo; + /* sender properties (stereo) */ + int sprop_stereo; /*! private data for the codec module to store handle specific info */ void *private_info; diff --git a/src/mod/codecs/mod_opus/mod_opus.c b/src/mod/codecs/mod_opus/mod_opus.c index 1ab7d9fba1..ce364cc3ef 100644 --- a/src/mod/codecs/mod_opus/mod_opus.c +++ b/src/mod/codecs/mod_opus/mod_opus.c @@ -273,10 +273,12 @@ static switch_status_t switch_opus_fmtp_parse(const char *fmtp, switch_codec_fmt if (!strcasecmp(data, "maxptime")) { codec_settings->maxptime = atoi(arg); + codec_fmtp->max_ptime = codec_settings->maxptime; } if (!strcasecmp(data, "minptime")) { codec_settings->minptime = atoi(arg); + codec_fmtp->min_ptime = codec_settings->minptime; } if (!strcasecmp(data, "ptime")) { @@ -291,6 +293,7 @@ static switch_status_t switch_opus_fmtp_parse(const char *fmtp, switch_codec_fmt if (!strcasecmp(data, "sprop-stereo")) { codec_settings->sprop_stereo = atoi(arg); + codec_fmtp->sprop_stereo = codec_settings->sprop_stereo; } if (!strcasecmp(data, "maxaveragebitrate")) { diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 8ed496bda7..60cc3d531c 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -5497,6 +5497,10 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s } else if (!strcasecmp(map->rm_encoding, "opus")) { map_channels = 1; } + + if (codec_fmtp.max_ptime) { + maxptime = codec_fmtp.max_ptime; + } } }