diff options
author | Joshua Colp <jcolp@digium.com> | 2017-08-09 15:39:05 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-08-09 15:39:05 -0500 |
commit | f27710ef5bce3521544dd3e69d6c9904b0c06b3f (patch) | |
tree | 500c30b6d9ba965d625d7adb8048f068820e29cd /res | |
parent | 4873e5ff337fd1dbd13936ce7b86f33738129aa8 (diff) | |
parent | be8cb75dd2e95f73f47d0bf2c1ef50a84d0d4226 (diff) |
Merge "res_rtp_asterisk: Make P2P bridge Asymmetric codec aware" into 15
Diffstat (limited to 'res')
-rw-r--r-- | res/res_pjsip_sdp_rtp.c | 1 | ||||
-rw-r--r-- | res/res_rtp_asterisk.c | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c index 77cd80782..b082b1d89 100644 --- a/res/res_pjsip_sdp_rtp.c +++ b/res/res_pjsip_sdp_rtp.c @@ -202,6 +202,7 @@ static int create_rtp(struct ast_sip_session *session, struct ast_sip_session_me } ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_NAT, session->endpoint->media.rtp.symmetric); + ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_ASYMMETRIC_CODEC, session->endpoint->asymmetric_rtp_codec); if (!session->endpoint->media.rtp.ice_support && (ice = ast_rtp_instance_get_ice(session_media->rtp))) { ice->stop(session_media->rtp); diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index ce899dffe..0f4f6abda 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -313,6 +313,7 @@ struct ast_rtp { void *data; struct ast_rtcp *rtcp; struct ast_rtp *bridged; /*!< Who we are Packet bridged to */ + unsigned int asymmetric_codec; /*!< Indicate if asymmetric send/receive codecs are allowed */ struct ast_rtp_instance *bundled; /*!< The RTP instance we are bundled to */ int stream_num; /*!< Stream num for this RTP instance */ @@ -5110,6 +5111,23 @@ static int bridge_p2p_rtp_write(struct ast_rtp_instance *instance, return -1; } + + ao2_replace(rtp->lastrxformat, payload_type->format); + ao2_replace(bridged->lasttxformat, payload_type->format); + + /* + * If bridged peer has already received rtp, perform the asymmetric codec check + * if that feature has been activated + */ + if (!bridged->asymmetric_codec && bridged->lastrxformat != ast_format_none) { + if (ast_format_cmp(bridged->lasttxformat, bridged->lastrxformat) == AST_FORMAT_CMP_NOT_EQUAL) { + ast_debug(1, "Asymmetric RTP codecs detected (TX: %s, RX: %s) sending frame to core\n", + ast_format_get_name(bridged->lasttxformat), + ast_format_get_name(bridged->lastrxformat)); + return -1; + } + } + /* If the marker bit has been explicitly set turn it on */ if (ast_test_flag(rtp, FLAG_NEED_MARKER_BIT)) { mark = 1; @@ -5809,6 +5827,8 @@ static void ast_rtp_prop_set(struct ast_rtp_instance *instance, enum ast_rtp_pro rtp->rtcp = NULL; } } + } else if (property == AST_RTP_PROPERTY_ASYMMETRIC_CODEC) { + rtp->asymmetric_codec = value; } } |