convert rtp flags to arrays

This commit is contained in:
Anthony Minessale 2012-12-18 16:06:29 -06:00
parent 592993ecda
commit 330f68d946
13 changed files with 458 additions and 309 deletions

View File

@ -176,6 +176,8 @@ struct switch_core_session {
plc_state_t *plc; plc_state_t *plc;
uint8_t recur_buffer[SWITCH_RECOMMENDED_BUFFER_SIZE]; uint8_t recur_buffer[SWITCH_RECOMMENDED_BUFFER_SIZE];
switch_size_t recur_buffer_len; switch_size_t recur_buffer_len;
switch_media_handle_t *media_handle;
}; };
struct switch_media_bug { struct switch_media_bug {

View File

@ -143,6 +143,7 @@
#include "switch_pgsql.h" #include "switch_pgsql.h"
#include "switch_json.h" #include "switch_json.h"
#include "switch_limit.h" #include "switch_limit.h"
#include "switch_core_media.h"
#include <libteletone.h> #include <libteletone.h>

View File

@ -29,13 +29,29 @@
* *
*/ */
#ifndef SWITCH_CORE_H #ifndef SWITCH_CORE_MEDIA_H
#define SWITCH_CORE_H #define SWITCH_CORE_MEDIA_H
#include <switch.h> #include <switch.h>
SWITCH_BEGIN_EXTERN_C SWITCH_BEGIN_EXTERN_C
typedef enum {
SM_NDLB_ALLOW_BAD_IANANAME = (1 << 0),
SM_NDLB_ALLOW_NONDUP_SDP = (1 << 1),
SM_NDLB_ALLOW_CRYPTO_IN_AVP = (1 << 2)
} switch_core_media_NDLB_t;
struct switch_media_handle_s;
SWITCH_DECLARE(switch_status_t) switch_media_handle_create(switch_media_handle_t **smhp, switch_core_session_t *session);
SWITCH_DECLARE(switch_media_handle_t *) switch_core_session_get_media_handle(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_core_session_clear_media_handle(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_core_session_media_handle_ready(switch_core_session_t *session);
SWITCH_DECLARE(void) switch_media_handle_set_ndlb(switch_media_handle_t *smh, switch_core_media_NDLB_t flag);
SWITCH_DECLARE(void) switch_media_handle_clear_ndlb(switch_media_handle_t *smh, switch_core_media_NDLB_t flag);
SWITCH_DECLARE(int32_t) switch_media_handle_test_ndlb(switch_media_handle_t *smh, switch_core_media_NDLB_t flag);
SWITCH_END_EXTERN_C SWITCH_END_EXTERN_C
#endif #endif

View File

@ -134,7 +134,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
switch_payload_t payload, switch_payload_t payload,
uint32_t samples_per_interval, uint32_t samples_per_interval,
uint32_t ms_per_packet, 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);
/*! /*!
@ -159,7 +159,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
switch_payload_t payload, switch_payload_t payload,
uint32_t samples_per_interval, uint32_t samples_per_interval,
uint32_t ms_per_packet, 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);
/*! /*!
@ -248,7 +248,9 @@ SWITCH_DECLARE(stfu_instance_t *) switch_rtp_get_jitter_buffer(switch_rtp_t *rtp
\param rtp_session the RTP session \param rtp_session the RTP session
\param flags the flags to set \param flags the flags to set
*/ */
SWITCH_DECLARE(void) switch_rtp_set_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flags); SWITCH_DECLARE(void) switch_rtp_set_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flag);
SWITCH_DECLARE(void) switch_rtp_set_flags(switch_rtp_t *rtp_session, switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID]);
SWITCH_DECLARE(void) switch_rtp_clear_flags(switch_rtp_t *rtp_session, switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID]);
/*! /*!
\brief Test an RTP Flag \brief Test an RTP Flag
@ -263,7 +265,7 @@ SWITCH_DECLARE(uint32_t) switch_rtp_test_flag(switch_rtp_t *rtp_session, switch_
\param rtp_session the RTP session \param rtp_session the RTP session
\param flags the flags to clear \param flags the flags to clear
*/ */
SWITCH_DECLARE(void) switch_rtp_clear_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flags); SWITCH_DECLARE(void) switch_rtp_clear_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flag);
/*! /*!
\brief Retrieve the socket from an existing RTP session \brief Retrieve the socket from an existing RTP session

View File

@ -610,38 +610,39 @@ typedef enum {
</pre> </pre>
*/ */
typedef enum { typedef enum {
SWITCH_RTP_FLAG_NOBLOCK = (1 << 0), SWITCH_RTP_FLAG_NOBLOCK = 0,
SWITCH_RTP_FLAG_IO = (1 << 1), SWITCH_RTP_FLAG_IO,
SWITCH_RTP_FLAG_USE_TIMER = (1 << 2), SWITCH_RTP_FLAG_USE_TIMER,
SWITCH_RTP_FLAG_RTCP_PASSTHRU = (1 << 3), SWITCH_RTP_FLAG_RTCP_PASSTHRU,
SWITCH_RTP_FLAG_SECURE_SEND = (1 << 4), SWITCH_RTP_FLAG_SECURE_SEND,
SWITCH_RTP_FLAG_SECURE_RECV = (1 << 5), SWITCH_RTP_FLAG_SECURE_RECV,
SWITCH_RTP_FLAG_AUTOADJ = (1 << 6), SWITCH_RTP_FLAG_AUTOADJ,
SWITCH_RTP_FLAG_RAW_WRITE = (1 << 7), SWITCH_RTP_FLAG_RAW_WRITE,
SWITCH_RTP_FLAG_GOOGLEHACK = (1 << 8), SWITCH_RTP_FLAG_GOOGLEHACK,
SWITCH_RTP_FLAG_VAD = (1 << 9), SWITCH_RTP_FLAG_VAD,
SWITCH_RTP_FLAG_BREAK = (1 << 10), SWITCH_RTP_FLAG_BREAK,
SWITCH_RTP_FLAG_UDPTL = (1 << 11), SWITCH_RTP_FLAG_UDPTL,
SWITCH_RTP_FLAG_DATAWAIT = (1 << 12), SWITCH_RTP_FLAG_DATAWAIT,
SWITCH_RTP_FLAG_BYTESWAP = (1 << 13), SWITCH_RTP_FLAG_BYTESWAP,
SWITCH_RTP_FLAG_PASS_RFC2833 = (1 << 14), SWITCH_RTP_FLAG_PASS_RFC2833,
SWITCH_RTP_FLAG_AUTO_CNG = (1 << 15), SWITCH_RTP_FLAG_AUTO_CNG,
SWITCH_RTP_FLAG_SECURE_SEND_RESET = (1 << 16), SWITCH_RTP_FLAG_SECURE_SEND_RESET,
SWITCH_RTP_FLAG_SECURE_RECV_RESET = (1 << 17), SWITCH_RTP_FLAG_SECURE_RECV_RESET,
SWITCH_RTP_FLAG_PROXY_MEDIA = (1 << 18), SWITCH_RTP_FLAG_PROXY_MEDIA,
SWITCH_RTP_FLAG_SHUTDOWN = (1 << 19), SWITCH_RTP_FLAG_SHUTDOWN,
SWITCH_RTP_FLAG_FLUSH = (1 << 20), SWITCH_RTP_FLAG_FLUSH,
SWITCH_RTP_FLAG_AUTOFLUSH = (1 << 21), SWITCH_RTP_FLAG_AUTOFLUSH,
SWITCH_RTP_FLAG_STICKY_FLUSH = (1 << 22), SWITCH_RTP_FLAG_STICKY_FLUSH,
SWITCH_ZRTP_FLAG_SECURE_SEND = (1 << 23), SWITCH_ZRTP_FLAG_SECURE_SEND,
SWITCH_ZRTP_FLAG_SECURE_RECV = (1 << 24), SWITCH_ZRTP_FLAG_SECURE_RECV,
SWITCH_ZRTP_FLAG_SECURE_MITM_SEND = (1 << 25), SWITCH_ZRTP_FLAG_SECURE_MITM_SEND,
SWITCH_ZRTP_FLAG_SECURE_MITM_RECV = (1 << 26), SWITCH_ZRTP_FLAG_SECURE_MITM_RECV,
SWITCH_RTP_FLAG_DEBUG_RTP_READ = (1 << 27), SWITCH_RTP_FLAG_DEBUG_RTP_READ,
SWITCH_RTP_FLAG_DEBUG_RTP_WRITE = (1 << 28), SWITCH_RTP_FLAG_DEBUG_RTP_WRITE,
SWITCH_RTP_FLAG_VIDEO = (1 << 29), SWITCH_RTP_FLAG_VIDEO,
SWITCH_RTP_FLAG_ENABLE_RTCP = (1 << 30) SWITCH_RTP_FLAG_ENABLE_RTCP,
/* don't add any more 31 is the limit! gotta chnge to an array to add more */ /* don't add any below this one */
SWITCH_RTP_FLAG_INVALID
} switch_rtp_flag_enum_t; } switch_rtp_flag_enum_t;
typedef uint32_t switch_rtp_flag_t; typedef uint32_t switch_rtp_flag_t;
@ -2125,6 +2126,10 @@ struct switch_media_bug;
struct switch_ivr_digit_stream_parser; struct switch_ivr_digit_stream_parser;
struct sql_queue_manager; struct sql_queue_manager;
struct switch_media_handle_s;
typedef struct switch_media_handle_s switch_media_handle_t;
SWITCH_END_EXTERN_C SWITCH_END_EXTERN_C
#endif #endif
/* For Emacs: /* For Emacs:

View File

@ -742,7 +742,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
sofia_glue_tech_patch_sdp(tech_pvt); sofia_glue_tech_patch_sdp(tech_pvt);
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
} }
@ -761,7 +761,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
sofia_glue_tech_patch_sdp(tech_pvt); sofia_glue_tech_patch_sdp(tech_pvt);
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
} }
@ -850,7 +850,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
} }
sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0); sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
} }
@ -2775,7 +2775,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
sofia_glue_tech_patch_sdp(tech_pvt); sofia_glue_tech_patch_sdp(tech_pvt);
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
status = SWITCH_STATUS_FALSE; status = SWITCH_STATUS_FALSE;
goto end_lock; goto end_lock;
} }
@ -2806,7 +2806,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
goto end_lock; goto end_lock;
} }
sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0); sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
} }
if (tech_pvt->local_sdp_str) { if (tech_pvt->local_sdp_str) {

View File

@ -289,9 +289,6 @@ typedef enum {
PFLAG_NDLB_TO_IN_200_CONTACT = (1 << 0), PFLAG_NDLB_TO_IN_200_CONTACT = (1 << 0),
PFLAG_NDLB_BROKEN_AUTH_HASH = (1 << 1), PFLAG_NDLB_BROKEN_AUTH_HASH = (1 << 1),
PFLAG_NDLB_SENDRECV_IN_SESSION = (1 << 2), PFLAG_NDLB_SENDRECV_IN_SESSION = (1 << 2),
PFLAG_NDLB_ALLOW_BAD_IANANAME = (1 << 3),
PFLAG_NDLB_ALLOW_NONDUP_SDP = (1 << 4),
PFLAG_NDLB_ALLOW_CRYPTO_IN_AVP = (1 << 5),
PFLAG_NDLB_EXPIRES_IN_REGISTER_RESPONSE = (1 << 6) PFLAG_NDLB_EXPIRES_IN_REGISTER_RESPONSE = (1 << 6)
} sofia_NDLB_t; } sofia_NDLB_t;
@ -712,6 +709,8 @@ struct private_object {
switch_payload_t video_recv_pt; switch_payload_t video_recv_pt;
switch_core_session_t *session; switch_core_session_t *session;
switch_channel_t *channel; switch_channel_t *channel;
switch_media_handle_t *media_handle;
switch_frame_t read_frame; switch_frame_t read_frame;
char *codec_order[SWITCH_MAX_CODECS]; char *codec_order[SWITCH_MAX_CODECS];
int codec_order_last; int codec_order_last;
@ -923,7 +922,7 @@ switch_mutex_unlock(obj->flag_mutex);
void sofia_glue_global_standby(switch_bool_t on); void sofia_glue_global_standby(switch_bool_t on);
switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_flag_t myflags); switch_status_t sofia_media_activate_rtp(private_object_t *tech_pvt);
void sofia_glue_deactivate_rtp(private_object_t *tech_pvt); void sofia_glue_deactivate_rtp(private_object_t *tech_pvt);

View File

@ -260,8 +260,8 @@ 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, 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, tech_pvt->read_codec.implementation->samples_per_packet, ptime * 1000,
0, "soft", &err, switch_core_session_get_pool(*new_session)))) { 0, "soft", &err, switch_core_session_get_pool(*new_session)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't setup RTP session: [%s]\n", err); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't setup RTP session: [%s]\n", err);
goto fail; goto fail;
} }
@ -557,20 +557,23 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
case SWITCH_MESSAGE_INDICATE_DEBUG_AUDIO: case SWITCH_MESSAGE_INDICATE_DEBUG_AUDIO:
{ {
if (switch_rtp_ready(tech_pvt->rtp_session) && !zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) { if (switch_rtp_ready(tech_pvt->rtp_session) && !zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) {
int32_t flags = 0; switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID] = {0};
int x = 0;
if (!strcasecmp(msg->string_array_arg[0], "read")) { if (!strcasecmp(msg->string_array_arg[0], "read")) {
flags |= SWITCH_RTP_FLAG_DEBUG_RTP_READ; flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]++;x++;
} else if (!strcasecmp(msg->string_array_arg[0], "write")) { } else if (!strcasecmp(msg->string_array_arg[0], "write")) {
flags |= SWITCH_RTP_FLAG_DEBUG_RTP_WRITE; flags[SWITCH_RTP_FLAG_DEBUG_RTP_WRITE]++;x++;
} else if (!strcasecmp(msg->string_array_arg[0], "both")) { } else if (!strcasecmp(msg->string_array_arg[0], "both")) {
flags |= SWITCH_RTP_FLAG_DEBUG_RTP_READ | SWITCH_RTP_FLAG_DEBUG_RTP_WRITE; flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]++;x++;
flags[SWITCH_RTP_FLAG_DEBUG_RTP_WRITE]++;
} }
if (flags) { if (x) {
if (switch_true(msg->string_array_arg[1])) { if (switch_true(msg->string_array_arg[1])) {
switch_rtp_set_flag(tech_pvt->rtp_session, flags); switch_rtp_set_flags(tech_pvt->rtp_session, flags);
} else { } else {
switch_rtp_clear_flag(tech_pvt->rtp_session, flags); switch_rtp_clear_flags(tech_pvt->rtp_session, flags);
} }
} else { } else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Options\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Options\n");

View File

@ -3606,7 +3606,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
profile->local_network = "localnet.auto"; profile->local_network = "localnet.auto";
sofia_set_flag(profile, TFLAG_ENABLE_SOA); sofia_set_flag(profile, TFLAG_ENABLE_SOA);
sofia_set_pflag(profile, PFLAG_CID_IN_1XX); sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
profile->ndlb |= PFLAG_NDLB_ALLOW_NONDUP_SDP; profile->ndlb |= SM_NDLB_ALLOW_NONDUP_SDP;
profile->te = 101; profile->te = 101;
profile->ireg_seconds = IREG_SECONDS; profile->ireg_seconds = IREG_SECONDS;
profile->paid_type = PAID_DEFAULT; profile->paid_type = PAID_DEFAULT;
@ -4187,9 +4187,9 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
} }
} else if (!strcasecmp(var, "NDLB-allow-bad-iananame")) { } else if (!strcasecmp(var, "NDLB-allow-bad-iananame")) {
if (switch_true(val)) { if (switch_true(val)) {
profile->ndlb |= PFLAG_NDLB_ALLOW_BAD_IANANAME; profile->ndlb |= SM_NDLB_ALLOW_BAD_IANANAME;
} else { } else {
profile->ndlb &= ~PFLAG_NDLB_ALLOW_BAD_IANANAME; profile->ndlb &= ~SM_NDLB_ALLOW_BAD_IANANAME;
} }
} else if (!strcasecmp(var, "NDLB-expires-in-register-response")) { } else if (!strcasecmp(var, "NDLB-expires-in-register-response")) {
if (switch_true(val)) { if (switch_true(val)) {
@ -4199,15 +4199,15 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
} }
} else if (!strcasecmp(var, "NDLB-allow-crypto-in-avp")) { } else if (!strcasecmp(var, "NDLB-allow-crypto-in-avp")) {
if (switch_true(val)) { if (switch_true(val)) {
profile->ndlb |= PFLAG_NDLB_ALLOW_CRYPTO_IN_AVP; profile->ndlb |= SM_NDLB_ALLOW_CRYPTO_IN_AVP;
} else { } else {
profile->ndlb &= ~PFLAG_NDLB_ALLOW_CRYPTO_IN_AVP; profile->ndlb &= ~SM_NDLB_ALLOW_CRYPTO_IN_AVP;
} }
} else if (!strcasecmp(var, "NDLB-allow-nondup-sdp")) { } else if (!strcasecmp(var, "NDLB-allow-nondup-sdp")) {
if (switch_true(val)) { if (switch_true(val)) {
profile->ndlb |= PFLAG_NDLB_ALLOW_NONDUP_SDP; profile->ndlb |= SM_NDLB_ALLOW_NONDUP_SDP;
} else { } else {
profile->ndlb &= ~PFLAG_NDLB_ALLOW_NONDUP_SDP; profile->ndlb &= ~SM_NDLB_ALLOW_NONDUP_SDP;
} }
} else if (!strcasecmp(var, "pass-rfc2833")) { } else if (!strcasecmp(var, "pass-rfc2833")) {
if (switch_true(val)) { if (switch_true(val)) {
@ -5595,7 +5595,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
(sofia_test_flag(profile, TFLAG_INB_NOMEDIA) || sofia_test_flag(profile, TFLAG_PROXY_MEDIA))) { (sofia_test_flag(profile, TFLAG_INB_NOMEDIA) || sofia_test_flag(profile, TFLAG_PROXY_MEDIA))) {
/* This marr in our code brought to you by people who can't read........ */ /* This marr in our code brought to you by people who can't read........ */
if (profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME && r_sdp && (p = (char *) switch_stristr("g729a/8000", r_sdp))) { if (profile->ndlb & SM_NDLB_ALLOW_BAD_IANANAME && r_sdp && (p = (char *) switch_stristr("g729a/8000", r_sdp))) {
p += 4; p += 4;
*p++ = '/'; *p++ = '/';
*p++ = '8'; *p++ = '8';
@ -5643,7 +5643,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
if (r_sdp) { if (r_sdp) {
if (!(profile->ndlb & PFLAG_NDLB_ALLOW_NONDUP_SDP) || (!zstr(tech_pvt->remote_sdp_str) && !strcmp(tech_pvt->remote_sdp_str, r_sdp))) { if (!(profile->ndlb & SM_NDLB_ALLOW_NONDUP_SDP) || (!zstr(tech_pvt->remote_sdp_str) && !strcmp(tech_pvt->remote_sdp_str, r_sdp))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Duplicate SDP\n%s\n", r_sdp); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Duplicate SDP\n%s\n", r_sdp);
is_dup_sdp = 1; is_dup_sdp = 1;
} else { } else {
@ -5744,7 +5744,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
switch_channel_mark_pre_answered(channel); switch_channel_mark_pre_answered(channel);
sofia_set_flag(tech_pvt, TFLAG_SDP); sofia_set_flag(tech_pvt, TFLAG_SDP);
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA) || sofia_test_flag(tech_pvt, TFLAG_REINVITE)) { if (switch_channel_test_flag(channel, CF_PROXY_MEDIA) || sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
goto done; goto done;
} }
} }
@ -6172,7 +6172,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0); sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Reinvite RTP Error!\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Reinvite RTP Error!\n");
is_ok = 0; is_ok = 0;
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
@ -6231,7 +6231,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Processing updated SDP\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Processing updated SDP\n");
sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE); sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error!\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error!\n");
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
goto done; goto done;
@ -6248,7 +6248,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
sofia_clear_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE); sofia_clear_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE);
if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
goto done; goto done;
} }
} }
@ -6285,7 +6285,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
if (match) { if (match) {
sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE); sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error!\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error!\n");
switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RTP ERROR"); switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RTP ERROR");
is_ok = 0; is_ok = 0;
@ -6313,7 +6313,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
tech_pvt->nh = tech_pvt->nh2; tech_pvt->nh = tech_pvt->nh2;
tech_pvt->nh2 = NULL; tech_pvt->nh2 = NULL;
if (sofia_glue_tech_choose_port(tech_pvt, 0) == SWITCH_STATUS_SUCCESS) { if (sofia_glue_tech_choose_port(tech_pvt, 0) == SWITCH_STATUS_SUCCESS) {
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cheater Reinvite RTP Error!\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cheater Reinvite RTP Error!\n");
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
} }
@ -6349,7 +6349,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
switch_channel_mark_answered(channel); switch_channel_mark_answered(channel);
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
goto done; goto done;
} }
} }
@ -6385,7 +6385,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
switch_channel_check_zrtp(channel); switch_channel_check_zrtp(channel);
if (sofia_glue_tech_choose_port(tech_pvt, 0) == SWITCH_STATUS_SUCCESS) { if (sofia_glue_tech_choose_port(tech_pvt, 0) == SWITCH_STATUS_SUCCESS) {
if (sofia_glue_activate_rtp(tech_pvt, 0) == SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) == SWITCH_STATUS_SUCCESS) {
switch_channel_mark_answered(channel); switch_channel_mark_answered(channel);
} else { } else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error!\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error!\n");

View File

@ -973,9 +973,11 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
switch_channel_set_cap(tech_pvt->channel, CC_FS_RTP); switch_channel_set_cap(tech_pvt->channel, CC_FS_RTP);
switch_channel_set_cap(tech_pvt->channel, CC_QUEUEABLE_DTMF_DELAY); switch_channel_set_cap(tech_pvt->channel, CC_QUEUEABLE_DTMF_DELAY);
switch_media_handle_create(&tech_pvt->media_handle, session);
switch_media_handle_set_ndlb(tech_pvt->media_handle, tech_pvt->profile->ndlb);
switch_core_session_set_private(session, tech_pvt); switch_core_session_set_private(session, tech_pvt);
if (channame) { if (channame) {
sofia_glue_set_name(tech_pvt, channame); sofia_glue_set_name(tech_pvt, channame);
} }
@ -1857,7 +1859,7 @@ void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt)
if (switch_channel_media_ready(tech_pvt->channel) && !switch_rtp_ready(tech_pvt->video_rtp_session)) { if (switch_channel_media_ready(tech_pvt->channel) && !switch_rtp_ready(tech_pvt->video_rtp_session)) {
sofia_set_flag(tech_pvt, TFLAG_VIDEO); sofia_set_flag(tech_pvt, TFLAG_VIDEO);
sofia_set_flag(tech_pvt, TFLAG_REINVITE); sofia_set_flag(tech_pvt, TFLAG_REINVITE);
sofia_glue_activate_rtp(tech_pvt, 0); sofia_media_activate_rtp(tech_pvt);
} }
} }
@ -3386,7 +3388,7 @@ void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const cha
for (i = 0; i < num_codecs; i++) { for (i = 0; i < num_codecs; i++) {
const switch_codec_implementation_t *imp = codecs[i]; const switch_codec_implementation_t *imp = codecs[i];
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) { if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
match = (map->rm_pt == imp->ianacode) ? 1 : 0; match = (map->rm_pt == imp->ianacode) ? 1 : 0;
} else { } else {
if (map->rm_encoding) { if (map->rm_encoding) {
@ -3415,7 +3417,7 @@ void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const cha
continue; continue;
} }
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) { if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
match = (map->rm_pt == imp->ianacode) ? 1 : 0; match = (map->rm_pt == imp->ianacode) ? 1 : 0;
} else { } else {
if (map->rm_encoding) { if (map->rm_encoding) {
@ -3453,7 +3455,7 @@ void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const cha
continue; continue;
} }
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) { if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
match = (map->rm_pt == imp->ianacode) ? 1 : 0; match = (map->rm_pt == imp->ianacode) ? 1 : 0;
} else { } else {
if (map->rm_encoding) { if (map->rm_encoding) {
@ -3497,7 +3499,7 @@ switch_status_t sofia_glue_tech_media(private_object_t *tech_pvt, const char *r_
if (sofia_glue_tech_choose_port(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_glue_tech_choose_port(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "EARLY MEDIA"); switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "EARLY MEDIA");
@ -4242,7 +4244,7 @@ int sofia_recover_callback(switch_core_session_t *session)
sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 1); sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 1);
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
goto end; goto end;
} }

View File

@ -664,7 +664,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
} else if (!got_crypto && !strcasecmp(attr->a_name, "crypto") && !zstr(attr->a_value)) { } else if (!got_crypto && !strcasecmp(attr->a_name, "crypto") && !zstr(attr->a_value)) {
int crypto_tag; int crypto_tag;
if (!(tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_CRYPTO_IN_AVP) && if (!(tech_pvt->profile->ndlb & SM_NDLB_ALLOW_CRYPTO_IN_AVP) &&
!switch_true(switch_channel_get_variable(tech_pvt->channel, "sip_allow_crypto_in_avp"))) { !switch_true(switch_channel_get_variable(tech_pvt->channel, "sip_allow_crypto_in_avp"))) {
if (m->m_proto != sdp_proto_srtp) { if (m->m_proto != sdp_proto_srtp) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "a=crypto in RTP/AVP, refer to rfc3711\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "a=crypto in RTP/AVP, refer to rfc3711\n");
@ -770,7 +770,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
} }
for (map = m->m_rtpmaps; map; map = map->rm_next) { for (map = m->m_rtpmaps; map; map = map->rm_next) {
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) { if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
match = (map->rm_pt == tech_pvt->pt) ? 1 : 0; match = (map->rm_pt == tech_pvt->pt) ? 1 : 0;
} else { } else {
match = strcasecmp(switch_str_nil(map->rm_encoding), tech_pvt->iananame) ? 0 : 1; match = strcasecmp(switch_str_nil(map->rm_encoding), tech_pvt->iananame) ? 0 : 1;
@ -882,7 +882,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u:%d:%u]/[%s:%d:%u:%d:%u]\n", switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u:%d:%u]/[%s:%d:%u:%d:%u]\n",
rm_encoding, map->rm_pt, (int) map->rm_rate, codec_ms, map_bit_rate, rm_encoding, map->rm_pt, (int) map->rm_rate, codec_ms, map_bit_rate,
imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000, bit_rate); imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000, bit_rate);
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) { if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
match = (map->rm_pt == imp->ianacode) ? 1 : 0; match = (map->rm_pt == imp->ianacode) ? 1 : 0;
} else { } else {
match = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1; match = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1;
@ -1078,7 +1078,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Video Codec Compare [%s:%d]/[%s:%d]\n", switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Video Codec Compare [%s:%d]/[%s:%d]\n",
rm_encoding, map->rm_pt, imp->iananame, imp->ianacode); rm_encoding, map->rm_pt, imp->iananame, imp->ianacode);
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) { if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
vmatch = (map->rm_pt == imp->ianacode) ? 1 : 0; vmatch = (map->rm_pt == imp->ianacode) ? 1 : 0;
} else { } else {
vmatch = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1; vmatch = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1;
@ -1145,11 +1145,11 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
} }
switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_flag_t myflags) switch_status_t sofia_media_activate_rtp(private_object_t *tech_pvt)
{ {
const char *err = NULL; const char *err = NULL;
const char *val = NULL; const char *val = NULL;
switch_rtp_flag_t flags; switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID] = {0};
switch_status_t status = SWITCH_STATUS_SUCCESS; switch_status_t status = SWITCH_STATUS_SUCCESS;
char tmp[50]; char tmp[50];
uint32_t rtp_timeout_sec = tech_pvt->profile->rtp_timeout_sec; uint32_t rtp_timeout_sec = tech_pvt->profile->rtp_timeout_sec;
@ -1195,16 +1195,15 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
goto end; goto end;
} }
memset(flags, 0, sizeof(flags));
flags[SWITCH_RTP_FLAG_DATAWAIT]++;
if (myflags) { if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) &&
flags = myflags; !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
} else if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) && flags[SWITCH_RTP_FLAG_AUTOADJ]++;
!((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT);
} else {
flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_DATAWAIT);
} }
if (sofia_test_pflag(tech_pvt->profile, PFLAG_PASS_RFC2833) if (sofia_test_pflag(tech_pvt->profile, PFLAG_PASS_RFC2833)
|| ((val = switch_channel_get_variable(tech_pvt->channel, "pass_rfc2833")) && switch_true(val))) { || ((val = switch_channel_get_variable(tech_pvt->channel, "pass_rfc2833")) && switch_true(val))) {
sofia_set_flag(tech_pvt, TFLAG_PASS_RFC2833); sofia_set_flag(tech_pvt, TFLAG_PASS_RFC2833);
@ -1213,28 +1212,28 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTOFLUSH) if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTOFLUSH)
|| ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_autoflush")) && switch_true(val))) { || ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_autoflush")) && switch_true(val))) {
flags |= SWITCH_RTP_FLAG_AUTOFLUSH; flags[SWITCH_RTP_FLAG_AUTOFLUSH]++;
} }
if (!(sofia_test_pflag(tech_pvt->profile, PFLAG_REWRITE_TIMESTAMPS) || if (!(sofia_test_pflag(tech_pvt->profile, PFLAG_REWRITE_TIMESTAMPS) ||
((val = switch_channel_get_variable(tech_pvt->channel, "rtp_rewrite_timestamps")) && switch_true(val)))) { ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_rewrite_timestamps")) && switch_true(val)))) {
flags |= SWITCH_RTP_FLAG_RAW_WRITE; flags[SWITCH_RTP_FLAG_RAW_WRITE]++;
} }
if (sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG)) { if (sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG)) {
tech_pvt->cng_pt = 0; tech_pvt->cng_pt = 0;
} else if (tech_pvt->cng_pt) { } else if (tech_pvt->cng_pt) {
flags |= SWITCH_RTP_FLAG_AUTO_CNG; flags[SWITCH_RTP_FLAG_AUTO_CNG]++;
} }
#if __BYTE_ORDER == __LITTLE_ENDIAN #if __BYTE_ORDER == __LITTLE_ENDIAN
if (!strcasecmp(tech_pvt->read_impl.iananame, "L16")) { if (!strcasecmp(tech_pvt->read_impl.iananame, "L16")) {
flags |= SWITCH_RTP_FLAG_BYTESWAP; flags[SWITCH_RTP_FLAG_BYTESWAP]++;
} }
#endif #endif
if ((flags & SWITCH_RTP_FLAG_BYTESWAP) && (val = switch_channel_get_variable(tech_pvt->channel, "rtp_disable_byteswap")) && switch_true(val)) { if ((flags[SWITCH_RTP_FLAG_BYTESWAP]) && (val = switch_channel_get_variable(tech_pvt->channel, "rtp_disable_byteswap")) && switch_true(val)) {
flags &= ~SWITCH_RTP_FLAG_BYTESWAP; flags[SWITCH_RTP_FLAG_BYTESWAP] = 0;
} }
if (tech_pvt->rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) { if (tech_pvt->rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
@ -1329,11 +1328,13 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) { if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
sofia_glue_tech_proxy_remote_addr(tech_pvt, NULL); sofia_glue_tech_proxy_remote_addr(tech_pvt, NULL);
memset(flags, 0, sizeof(flags));
flags[SWITCH_RTP_FLAG_DATAWAIT]++;
flags[SWITCH_RTP_FLAG_PROXY_MEDIA]++;
if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) && if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) &&
!((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) { !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_PROXY_MEDIA | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT); flags[SWITCH_RTP_FLAG_AUTOADJ]++;
} else {
flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_PROXY_MEDIA | SWITCH_RTP_FLAG_DATAWAIT);
} }
timer_name = NULL; timer_name = NULL;
@ -1365,7 +1366,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
tech_pvt->agreed_pt, tech_pvt->agreed_pt,
tech_pvt->read_impl.samples_per_packet, tech_pvt->read_impl.samples_per_packet,
tech_pvt->codec_ms * 1000, tech_pvt->codec_ms * 1000,
(switch_rtp_flag_t) flags, timer_name, &err, switch_core_session_get_pool(tech_pvt->session)); flags, timer_name, &err, switch_core_session_get_pool(tech_pvt->session));
} }
if (switch_rtp_ready(tech_pvt->rtp_session)) { if (switch_rtp_ready(tech_pvt->rtp_session)) {
@ -1676,11 +1677,13 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) { if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
sofia_glue_tech_proxy_remote_addr(tech_pvt, NULL); sofia_glue_tech_proxy_remote_addr(tech_pvt, NULL);
memset(flags, 0, sizeof(flags));
flags[SWITCH_RTP_FLAG_PROXY_MEDIA]++;
flags[SWITCH_RTP_FLAG_DATAWAIT]++;
if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) && if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) &&
!((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) { !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_PROXY_MEDIA | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT); flags[SWITCH_RTP_FLAG_AUTOADJ]++;
} else {
flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_PROXY_MEDIA | SWITCH_RTP_FLAG_DATAWAIT);
} }
timer_name = NULL; timer_name = NULL;
@ -1714,27 +1717,30 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
sofia_glue_tech_choose_video_port(tech_pvt, 1); sofia_glue_tech_choose_video_port(tech_pvt, 1);
} }
memset(flags, 0, sizeof(flags));
flags[SWITCH_RTP_FLAG_DATAWAIT]++;
flags[SWITCH_RTP_FLAG_RAW_WRITE]++;
if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) && !switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) && if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) && !switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) &&
!((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) { !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE); flags[SWITCH_RTP_FLAG_AUTOADJ]++;
} else {
flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE);
} }
if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) { if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
flags |= SWITCH_RTP_FLAG_PROXY_MEDIA; flags[SWITCH_RTP_FLAG_PROXY_MEDIA]++;
} }
sofia_glue_tech_set_video_codec(tech_pvt, 0); sofia_glue_tech_set_video_codec(tech_pvt, 0);
flags &= ~(SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_NOBLOCK); flags[SWITCH_RTP_FLAG_USE_TIMER] = 0;
flags |= SWITCH_RTP_FLAG_VIDEO; flags[SWITCH_RTP_FLAG_NOBLOCK] = 0;
flags[SWITCH_RTP_FLAG_VIDEO]++;
tech_pvt->video_rtp_session = switch_rtp_new(tech_pvt->local_sdp_audio_ip, tech_pvt->video_rtp_session = switch_rtp_new(tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_video_port, tech_pvt->local_sdp_video_port,
tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_ip,
tech_pvt->remote_sdp_video_port, tech_pvt->remote_sdp_video_port,
tech_pvt->video_agreed_pt, tech_pvt->video_agreed_pt,
1, 90000, (switch_rtp_flag_t) flags, NULL, &err, switch_core_session_get_pool(tech_pvt->session)); 1, 90000, flags, NULL, &err, switch_core_session_get_pool(tech_pvt->session));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "%sVIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n", switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "%sVIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n",
switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA) ? "PROXY " : "", switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA) ? "PROXY " : "",

View File

@ -40,10 +40,85 @@
#include <switch_curl.h> #include <switch_curl.h>
#include <errno.h> #include <errno.h>
typedef enum {
SMH_INIT = (1 << 0),
SMH_READY = (1 << 1)
} smh_flag_t;
struct switch_media_handle_s {
switch_core_session_t *session;
switch_core_media_NDLB_t ndlb;
smh_flag_t flags;
};
SWITCH_DECLARE(switch_status_t) switch_media_handle_create(switch_media_handle_t **smhp, switch_core_session_t *session)
{
switch_status_t status = SWITCH_STATUS_FALSE;
switch_media_handle_t *smh = NULL;
*smhp = NULL;
if ((session->media_handle = switch_core_session_alloc(session, (sizeof(*smh))))) {
*smhp = session->media_handle;
switch_set_flag(session->media_handle, SMH_INIT);
status = SWITCH_STATUS_SUCCESS;
}
return status;
}
SWITCH_DECLARE(void) switch_media_handle_set_ndlb(switch_media_handle_t *smh, switch_core_media_NDLB_t flag)
{
switch_assert(smh);
smh->flags |= flag;
}
SWITCH_DECLARE(void) switch_media_handle_clear_ndlb(switch_media_handle_t *smh, switch_core_media_NDLB_t flag)
{
switch_assert(smh);
smh->flags &= ~flag;
}
SWITCH_DECLARE(int32_t) switch_media_handle_test_ndlb(switch_media_handle_t *smh, switch_core_media_NDLB_t flag)
{
switch_assert(smh);
return (smh->flags & flag);
}
SWITCH_DECLARE(switch_status_t) switch_core_session_media_handle_ready(switch_core_session_t *session)
{
if (session->media_handle && switch_test_flag(session->media_handle, SMH_INIT)) {
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_FALSE;
}
SWITCH_DECLARE(switch_media_handle_t *) switch_core_session_get_media_handle(switch_core_session_t *session)
{
if (switch_core_session_media_handle_ready(session)) {
return session->media_handle;
}
return NULL;
}
SWITCH_DECLARE(switch_status_t) switch_core_session_clear_media_handle(switch_core_session_t *session)
{
if (!session->media_handle) {
return SWITCH_STATUS_FALSE;
}
return SWITCH_STATUS_SUCCESS;
}

File diff suppressed because it is too large Load Diff