diff --git a/src/include/switch_rtp.h b/src/include/switch_rtp.h index a16c5f6d5a..12f0626ccf 100644 --- a/src/include/switch_rtp.h +++ b/src/include/switch_rtp.h @@ -48,6 +48,8 @@ SWITCH_BEGIN_EXTERN_C //#define SWITCH_RTP_CRYPTO_KEY_32 "AES_CM_128_HMAC_SHA1_32" #define SWITCH_RTP_CRYPTO_KEY_80 "AES_CM_128_HMAC_SHA1_80" +#define SWITCH_RTP_BUNDLE_INTERNAL_PT 21 + typedef struct { switch_rtp_hdr_t header; char body[SWITCH_RTP_MAX_BUF_LEN+4+sizeof(char *)]; @@ -248,6 +250,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session \param timer_name timer interface to use \param err a pointer to resolve error messages \param pool a memory pool to use for the session + \param bundle_port port used by bundled stream locally, for video thread this is the port where it will forward audio (internal bundle port on which audio is listening), and for audio this is the port where it will send RTP (external bundle port where video is listening) \return the new RTP session or NULL on failure */ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host, @@ -257,7 +260,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host, switch_payload_t payload, uint32_t samples_per_interval, uint32_t ms_per_packet, - switch_rtp_flag_t flags[], char *timer_name, const char **err, switch_memory_pool_t *pool); + switch_rtp_flag_t flags[], char *timer_name, const char **err, switch_memory_pool_t *pool, switch_port_t bundle_internal_ports, switch_port_t bundle_external_port); /*! diff --git a/src/mod/applications/mod_esf/mod_esf.c b/src/mod/applications/mod_esf/mod_esf.c index 4ac8e16071..03801961b1 100644 --- a/src/mod/applications/mod_esf/mod_esf.c +++ b/src/mod/applications/mod_esf/mod_esf.c @@ -392,7 +392,7 @@ SWITCH_STANDARD_APP(bcast_function) mcast_port, alert_packet->audio_header.codec, 160, - 20000, flags, "soft", &err, switch_core_session_get_pool(session)); + 20000, flags, "soft", &err, switch_core_session_get_pool(session), 0, 0); if (!switch_rtp_ready(rtp_session)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error\n"); diff --git a/src/mod/applications/mod_oreka/mod_oreka.c b/src/mod/applications/mod_oreka/mod_oreka.c index 4ebf1759d9..cae606a9bf 100644 --- a/src/mod/applications/mod_oreka/mod_oreka.c +++ b/src/mod/applications/mod_oreka/mod_oreka.c @@ -147,7 +147,7 @@ static int oreka_setup_rtp(oreka_session_t *oreka, oreka_stream_type_t type) 0, /* PCMU IANA*/ codec_impl->samples_per_packet, codec_impl->microseconds_per_packet, - flags, NULL, &err, switch_core_session_get_pool(oreka->session)); + flags, NULL, &err, switch_core_session_get_pool(oreka->session), 0, 0); if (!rtp_stream) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create %s RTP stream at %s:%d: %s\n", type_str, globals.local_ipv4_str, rtp_port, err); diff --git a/src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c b/src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c index 506df4c4c8..0eb9eac2fe 100644 --- a/src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c +++ b/src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c @@ -289,7 +289,7 @@ static int sangoma_create_rtp(void *usr_priv, sngtc_codec_request_leg_t *codec_r iana, sess->impl->samples_per_packet, codec_req_leg->ms * 1000, /* microseconds per packet */ - flags, NULL, &err, sesspool); + flags, NULL, &err, sesspool, 0, 0); if (!rtp_session) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to create switch rtp session: %s\n", err); diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 2717190355..8ab56c5da1 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -1266,7 +1266,7 @@ static int activate_audio_rtp(struct private_object *tech_pvt) tech_pvt->transports[LDL_TPORT_RTP].codec_num, tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->samples_per_packet, tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->microseconds_per_packet, - flags, tech_pvt->profile->timer_name, &err, switch_core_session_get_pool(tech_pvt->session)))) { + flags, tech_pvt->profile->timer_name, &err, switch_core_session_get_pool(tech_pvt->session), 0, 0))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); r = 0; @@ -1459,7 +1459,7 @@ static int activate_video_rtp(struct private_object *tech_pvt) tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_num, 1, 90000, - flags, NULL, &err, switch_core_session_get_pool(tech_pvt->session)))) { + flags, NULL, &err, switch_core_session_get_pool(tech_pvt->session), 0, 0))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); r = 0; goto end; diff --git a/src/mod/endpoints/mod_h323/mod_h323.cpp b/src/mod/endpoints/mod_h323/mod_h323.cpp index 3581f0e0b7..c6dc7fc9e9 100644 --- a/src/mod/endpoints/mod_h323/mod_h323.cpp +++ b/src/mod/endpoints/mod_h323/mod_h323.cpp @@ -2200,7 +2200,7 @@ PBoolean FSH323_ExternalRTPChannel::Start() codec->implementation->samples_per_packet, codec->implementation->microseconds_per_packet, flags, timer_name, &err, - switch_core_session_get_pool(m_fsSession)); + switch_core_session_get_pool(m_fsSession), 0, 0); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------------->tech_pvt->rtp_session = %p\n",tech_pvt->rtp_session); m_conn->m_startRTP = true; diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index 86b4730786..dd76626343 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -2064,7 +2064,7 @@ switch_status_t skinny_handle_open_receive_channel_ack_message(listener_t *liste tech_pvt->read_impl.samples_per_packet, tech_pvt->codec_ms * 1000, flags, "soft", &err, - switch_core_session_get_pool(session)); + switch_core_session_get_pool(session), 0, 0); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "AUDIO RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n", switch_channel_get_name(channel), diff --git a/src/mod/endpoints/mod_sofia/rtp.c b/src/mod/endpoints/mod_sofia/rtp.c index 7261b38f1a..c5e9751029 100644 --- a/src/mod/endpoints/mod_sofia/rtp.c +++ b/src/mod/endpoints/mod_sofia/rtp.c @@ -266,7 +266,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi if (!(tech_pvt->rtp_session = switch_rtp_new(local_addr, local_port, remote_addr, remote_port, tech_pvt->agreed_pt, tech_pvt->read_codec.implementation->samples_per_packet, ptime * 1000, - rtp_flags, "soft", &err, switch_core_session_get_pool(*new_session)))) { + rtp_flags, "soft", &err, switch_core_session_get_pool(*new_session), 0, 0))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't setup RTP session: [%s]\n", err); goto fail; } diff --git a/src/switch_core_media.c b/src/switch_core_media.c index e7bce84b43..2b026f03fd 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -8671,7 +8671,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi a_engine->cur_payload_map->pt, a_engine->read_impl.samples_per_packet, a_engine->cur_payload_map->codec_ms * 1000, - flags, timer_name, &err, switch_core_session_get_pool(session)); + flags, timer_name, &err, switch_core_session_get_pool(session), + 0, 0); if (switch_rtp_ready(a_engine->rtp_session)) { switch_rtp_set_payload_map(a_engine->rtp_session, &a_engine->payload_map); @@ -9077,7 +9078,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi t_engine->cur_payload_map->remote_sdp_ip, t_engine->cur_payload_map->remote_sdp_port, t_engine->cur_payload_map->pt, - TEXT_TIMER_SAMPLES, TEXT_TIMER_MS * 1000, flags, NULL, &err, switch_core_session_get_pool(session)); + TEXT_TIMER_SAMPLES, TEXT_TIMER_MS * 1000, flags, NULL, &err, switch_core_session_get_pool(session), + 0, 0); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%sTEXT RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n", @@ -9406,7 +9408,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi v_engine->cur_payload_map->remote_sdp_ip, v_engine->cur_payload_map->remote_sdp_port, v_engine->cur_payload_map->pt, - 1, 90000, flags, NULL, &err, switch_core_session_get_pool(session)); + 1, 90000, flags, NULL, &err, switch_core_session_get_pool(session), + 0, 0); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%sVIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n", diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 98e621882e..2b06c448d4 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -389,7 +389,7 @@ struct switch_rtp { switch_time_t last_write_timestamp; uint32_t flags[SWITCH_RTP_FLAG_INVALID]; switch_memory_pool_t *pool; - switch_sockaddr_t *from_addr, *rtp_from_addr, *rtcp_from_addr; + switch_sockaddr_t *from_addr, *rtp_from_addr, *rtcp_from_addr, *bundle_internal_addr, *bundle_external_addr; char *rx_host; switch_port_t rx_port; switch_rtp_ice_t ice; @@ -2155,7 +2155,7 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session) rtcp_bytes += sizeof(struct switch_rtcp_report_block); rtcp_generate_report_block(rtp_session, rtcp_report_block, nack_dup); rtp_session->rtcp_send_msg.header.count = 1; /* reception report block count */ - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Sending RTCP RR"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_NOTICE, "Sending RTCP RR (ssrc=%u)\n", rtp_session->ssrc); } else { struct switch_rtcp_sender_info *rtcp_sender_info; rtp_session->rtcp_send_msg.header.type = _RTCP_PT_SR; /* Sender report */ @@ -2173,7 +2173,7 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session) rtcp_generate_report_block(rtp_session, rtcp_report_block, nack_dup); rtp_session->rtcp_send_msg.header.count = 1; /* reception report block count */ } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Sending RTCP SR"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_NOTICE, "Sending RTCP SR (ssrc=%u)\n", rtp_session->ssrc); } rtp_session->rtcp_send_msg.header.length = htons((uint16_t)(rtcp_bytes / 4) - 1); @@ -4509,7 +4509,9 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host, switch_payload_t payload, uint32_t samples_per_interval, uint32_t ms_per_packet, - switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID], char *timer_name, const char **err, switch_memory_pool_t *pool) + switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID], char *timer_name, const char **err, switch_memory_pool_t *pool, + switch_port_t bundle_internal_port, + switch_port_t bundle_external_port) { switch_rtp_t *rtp_session = NULL;