This commit is contained in:
Anthony Minessale 2012-12-21 14:22:25 -06:00
parent d6af3a1fdd
commit eb81042a6f
9 changed files with 1267 additions and 2066 deletions

View File

@ -147,7 +147,7 @@ endif
lib_LTLIBRARIES = libfreeswitch.la lib_LTLIBRARIES = libfreeswitch.la
libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(AM_CFLAGS) libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(AM_CFLAGS)
libfreeswitch_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS) $(PLATFORM_CORE_LDFLAGS) libfreeswitch_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS) $(PLATFORM_CORE_LDFLAGS)
libfreeswitch_la_LIBADD = $(CORE_LIBS) $(PLATFORM_CORE_LIBS) libfreeswitch_la_LIBADD = $(CORE_LIBS) $(PLATFORM_CORE_LIBS) libs/sofia-sip/libsofia-sip-ua/sdp/.libs/libsdp.a libs/sofia-sip/libsofia-sip-ua/su/.libs/libsu.a
libfreeswitch_la_DEPENDENCIES = $(BUILT_SOURCES) libfreeswitch_la_DEPENDENCIES = $(BUILT_SOURCES)
if HAVE_ODBC if HAVE_ODBC

View File

@ -44,8 +44,6 @@ typedef enum {
DTMF_NONE DTMF_NONE
} switch_core_media_dtmf_t; } switch_core_media_dtmf_t;
typedef enum { typedef enum {
SM_NDLB_ALLOW_BAD_IANANAME = (1 << 0), SM_NDLB_ALLOW_BAD_IANANAME = (1 << 0),
SM_NDLB_ALLOW_NONDUP_SDP = (1 << 1), SM_NDLB_ALLOW_NONDUP_SDP = (1 << 1),
@ -65,39 +63,78 @@ typedef enum {
SCMF_T38_PASSTHRU, SCMF_T38_PASSTHRU,
SCMF_LIBERAL_DTMF, SCMF_LIBERAL_DTMF,
SCMF_SUPPRESS_CNG, SCMF_SUPPRESS_CNG,
SCMF_DISABLE_RTP_AUTOADJ,
SCMF_PASS_RFC2833,
SCMF_AUTOFLUSH,
SCMF_REWRITE_TIMESTAMPS,
SCMF_MAX SCMF_MAX
} switch_core_media_flag_t; } switch_core_media_flag_t;
struct switch_media_handle_s; struct switch_media_handle_s;
typedef enum { typedef enum {
STYPE_INTVAL, STUN_FLAG_SET = (1 << 0),
STYPE_UINTVAL, STUN_FLAG_PING = (1 << 1),
STYPE_CHARVAL, STUN_FLAG_FUNNY = (1 << 2)
} scm_type_t; } STUNFLAGS;
typedef enum { typedef enum {
SCM_INBOUND_CODEC_STRING, VAD_IN = (1 << 0),
SCM_OUTBOUND_CODEC_STRING, VAD_OUT = (1 << 1)
SCM_AUTO_RTP_BUGS, } switch_core_media_vflag_t;
SCM_MANUAL_RTP_BUGS,
SCM_MAX
} scm_param_t;
#define switch_media_get_param_int(_h, _p) *(int *)switch_media_get_param(_h, _p) typedef struct switch_core_media_params_s {
#define switch_media_get_param_uint(_h, _p) *(uint32_t *)switch_media_get_param(_h, _p) uint32_t rtp_timeout_sec;
#define switch_media_get_param_char(_h, _p) (char *)switch_media_get_param(_h, _p) uint32_t rtp_hold_timeout_sec;
uint32_t dtmf_delay;
uint32_t codec_flags;
int reinvite;
switch_core_media_NDLB_t ndlb;
switch_rtp_bug_flag_t auto_rtp_bugs;
char *inbound_codec_string;
char *outbound_codec_string;
char *timer_name;
char *remote_sdp_str;
char *early_sdp;
char *local_sdp_str;
char *last_sdp_str;
char *stun_ip;
switch_port_t stun_port;
uint32_t stun_flags;
char *jb_msec;
switch_core_media_vflag_t vflags;
switch_rtp_bug_flag_t manual_rtp_bugs;
switch_rtp_bug_flag_t manual_video_rtp_bugs;
char *rtcp_audio_interval_msec;
char *rtcp_video_interval_msec;
char *extrtpip;
char *rtpip;
char *remote_ip;
int remote_port;
char *extsipip;
char *local_network;
} switch_core_media_params_t;
SWITCH_DECLARE(switch_status_t) switch_media_handle_create(switch_media_handle_t **smhp, switch_core_session_t *session, switch_core_media_params_t *params);
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_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_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(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_DECLARE(void) switch_media_handle_set_media_flag(switch_media_handle_t *smh, switch_core_media_flag_t flag); SWITCH_DECLARE(void) switch_media_handle_set_media_flag(switch_media_handle_t *smh, switch_core_media_flag_t flag);
SWITCH_DECLARE(void) switch_media_handle_clear_media_flag(switch_media_handle_t *smh, switch_core_media_flag_t flag); SWITCH_DECLARE(void) switch_media_handle_clear_media_flag(switch_media_handle_t *smh, switch_core_media_flag_t flag);
SWITCH_DECLARE(int32_t) switch_media_handle_test_media_flag(switch_media_handle_t *smh, switch_core_media_flag_t flag); SWITCH_DECLARE(int32_t) switch_media_handle_test_media_flag(switch_media_handle_t *smh, switch_core_media_flag_t flag);
@ -113,8 +150,6 @@ SWITCH_DECLARE(void) switch_core_session_get_recovery_crypto_key(switch_core_ses
SWITCH_DECLARE(void) switch_core_media_set_rtp_session(switch_core_session_t *session, switch_media_type_t type, switch_rtp_t *rtp_session); SWITCH_DECLARE(void) switch_core_media_set_rtp_session(switch_core_session_t *session, switch_media_type_t type, switch_rtp_t *rtp_session);
SWITCH_DECLARE(void) switch_media_set_param(switch_media_handle_t *smh, scm_param_t param, ...);
SWITCH_DECLARE(void *) switch_media_get_param(switch_media_handle_t *smh, scm_param_t param);
SWITCH_DECLARE(const char *)switch_core_media_get_codec_string(switch_core_session_t *session); SWITCH_DECLARE(const char *)switch_core_media_get_codec_string(switch_core_session_t *session);
SWITCH_DECLARE(void) switch_core_media_parse_rtp_bugs(switch_rtp_bug_flag_t *flag_pole, const char *str); SWITCH_DECLARE(void) switch_core_media_parse_rtp_bugs(switch_rtp_bug_flag_t *flag_pole, const char *str);
SWITCH_DECLARE(switch_t38_options_t *) switch_core_media_process_udptl(switch_core_session_t *session, sdp_session_t *sdp, sdp_media_t *m); SWITCH_DECLARE(switch_t38_options_t *) switch_core_media_process_udptl(switch_core_session_t *session, sdp_session_t *sdp, sdp_media_t *m);
@ -126,6 +161,14 @@ SWITCH_DECLARE(void) switch_core_media_pass_zrtp_hash2(switch_core_session_t *al
SWITCH_DECLARE(int) switch_core_media_toggle_hold(switch_core_session_t *session, int sendonly); SWITCH_DECLARE(int) switch_core_media_toggle_hold(switch_core_session_t *session, int sendonly);
SWITCH_DECLARE(void) switch_core_media_copy_t38_options(switch_t38_options_t *t38_options, switch_core_session_t *session); SWITCH_DECLARE(void) switch_core_media_copy_t38_options(switch_t38_options_t *t38_options, switch_core_session_t *session);
SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *session, const char *r_sdp, uint8_t *proceed, int reinvite, int codec_flags, switch_payload_t default_te); SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *session, const char *r_sdp, uint8_t *proceed, int reinvite, int codec_flags, switch_payload_t default_te);
SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_codec(switch_core_session_t *session, int force);
SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_t *session, int force, uint32_t codec_flags);
SWITCH_DECLARE(void) switch_core_media_check_video_codecs(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session_t *session, switch_frame_t **frame,
switch_io_flag_t flags, int stream_id, switch_media_type_t type);
SWITCH_DECLARE(switch_status_t) switch_core_media_write_frame(switch_core_session_t *session,
switch_frame_t *frame, switch_io_flag_t flags, int stream_id, switch_media_type_t type);
SWITCH_DECLARE(int) switch_core_media_check_nat(switch_media_handle_t *smh, const char *network_ip);
SWITCH_END_EXTERN_C SWITCH_END_EXTERN_C
#endif #endif

View File

@ -1288,6 +1288,8 @@ typedef enum {
CF_PROTO_HOLD, //TFLAG_SIP_HOLD CF_PROTO_HOLD, //TFLAG_SIP_HOLD
CF_HOLD_LOCK, CF_HOLD_LOCK,
CF_VIDEO_POSSIBLE,//TFLAG_VIDEO CF_VIDEO_POSSIBLE,//TFLAG_VIDEO
CF_NOTIMER_DURING_BRIDGE,
CF_PASS_RFC2833,
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */ /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
/* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */ /* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */
CF_FLAG_MAX CF_FLAG_MAX

View File

@ -944,15 +944,13 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
static switch_status_t sofia_read_video_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id) static switch_status_t sofia_read_video_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
{ {
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session); private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
uint32_t sanity = 1000;
switch_assert(tech_pvt != NULL); switch_assert(tech_pvt != NULL);
if (sofia_test_flag(tech_pvt, TFLAG_HUP)) { if (sofia_test_flag(tech_pvt, TFLAG_HUP)) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
#if 0
while (!(tech_pvt->video_read_codec.implementation && switch_rtp_ready(tech_pvt->video_rtp_session) && !switch_channel_test_flag(channel, CF_REQ_MEDIA))) { while (!(tech_pvt->video_read_codec.implementation && switch_rtp_ready(tech_pvt->video_rtp_session) && !switch_channel_test_flag(channel, CF_REQ_MEDIA))) {
switch_ivr_parse_all_messages(tech_pvt->session); switch_ivr_parse_all_messages(tech_pvt->session);
@ -963,59 +961,19 @@ static switch_status_t sofia_read_video_frame(switch_core_session_t *session, sw
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} }
} }
#endif
tech_pvt->video_read_frame.datalen = 0;
if (sofia_test_flag(tech_pvt, TFLAG_IO)) { return switch_core_media_read_frame(session, frame, flags, stream_id, SWITCH_MEDIA_TYPE_VIDEO);
switch_status_t status;
if (!sofia_test_flag(tech_pvt, TFLAG_RTP)) {
return SWITCH_STATUS_GENERR;
}
switch_assert(tech_pvt->rtp_session != NULL);
tech_pvt->video_read_frame.datalen = 0;
while (sofia_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->video_read_frame.datalen == 0) {
tech_pvt->video_read_frame.flags = SFF_NONE;
status = switch_rtp_zerocopy_read_frame(tech_pvt->video_rtp_session, &tech_pvt->video_read_frame, flags);
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
if (status == SWITCH_STATUS_TIMEOUT) {
if (sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
sofia_media_toggle_hold(tech_pvt, 0);
sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
switch_channel_clear_flag(channel, CF_LEG_HOLDING);
}
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_MEDIA_TIMEOUT);
}
return status;
}
if (tech_pvt->video_read_frame.datalen > 0) {
break;
}
}
}
if (tech_pvt->video_read_frame.datalen == 0) {
*frame = NULL;
return SWITCH_STATUS_GENERR;
}
*frame = &tech_pvt->video_read_frame;
return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t sofia_write_video_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id) static switch_status_t sofia_write_video_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
{ {
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session); private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
int wrote = 0;
switch_assert(tech_pvt != NULL); switch_assert(tech_pvt != NULL);
#if 0
while (!(tech_pvt->video_read_codec.implementation && switch_rtp_ready(tech_pvt->video_rtp_session))) { while (!(tech_pvt->video_read_codec.implementation && switch_rtp_ready(tech_pvt->video_rtp_session))) {
if (switch_channel_ready(channel)) { if (switch_channel_ready(channel)) {
switch_yield(10000); switch_yield(10000);
@ -1023,6 +981,7 @@ static switch_status_t sofia_write_video_frame(switch_core_session_t *session, s
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} }
} }
#endif
if (sofia_test_flag(tech_pvt, TFLAG_HUP)) { if (sofia_test_flag(tech_pvt, TFLAG_HUP)) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
@ -1036,11 +995,8 @@ static switch_status_t sofia_write_video_frame(switch_core_session_t *session, s
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
if (!switch_test_flag(frame, SFF_CNG)) { return switch_core_media_write_frame(session, frame, flags, stream_id, SWITCH_MEDIA_TYPE_VIDEO);
wrote = switch_rtp_write_frame(tech_pvt->video_rtp_session, frame);
}
return wrote > 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_GENERR;
} }
static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id) static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
@ -1105,7 +1061,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
if (status == SWITCH_STATUS_TIMEOUT) { if (status == SWITCH_STATUS_TIMEOUT) {
if (sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) { if (sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
sofia_media_toggle_hold(tech_pvt, 0); switch_core_media_toggle_hold(session, 0);
sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD); sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
switch_channel_clear_flag(channel, CF_LEG_HOLDING); switch_channel_clear_flag(channel, CF_LEG_HOLDING);
} }
@ -1274,7 +1230,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
tech_pvt->codec_ms = codec_ms; tech_pvt->codec_ms = codec_ms;
} }
if (sofia_media_tech_set_codec(tech_pvt, 2) != SWITCH_STATUS_SUCCESS) { if (switch_core_media_set_codec(tech_pvt->session, 2, tech_pvt->profile->codec_flags) != SWITCH_STATUS_SUCCESS) {
*frame = NULL; *frame = NULL;
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} }
@ -1906,7 +1862,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
tech_pvt->video_rm_encoding = NULL; tech_pvt->video_rm_encoding = NULL;
switch_channel_clear_flag(tech_pvt->channel, CF_VIDEO_POSSIBLE); switch_channel_clear_flag(tech_pvt->channel, CF_VIDEO_POSSIBLE);
sofia_media_tech_prepare_codecs(tech_pvt); sofia_media_tech_prepare_codecs(tech_pvt);
sofia_media_check_video_codecs(tech_pvt); switch_core_media_check_video_codecs(tech_pvt->session);
sofia_media_set_local_sdp(tech_pvt, NULL, 0, NULL, 1); sofia_media_set_local_sdp(tech_pvt, NULL, 0, NULL, 1);
sofia_set_pflag(tech_pvt->profile, PFLAG_RENEG_ON_REINVITE); sofia_set_pflag(tech_pvt->profile, PFLAG_RENEG_ON_REINVITE);
sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA); sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA);
@ -2446,7 +2402,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
{ {
if (msg->numeric_arg) { if (msg->numeric_arg) {
sofia_media_toggle_hold(tech_pvt, 1); switch_core_media_toggle_hold(session, 1);
} else { } else {
sofia_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD); sofia_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);

View File

@ -199,9 +199,7 @@ typedef enum {
PFLAG_AUTH_ALL, PFLAG_AUTH_ALL,
PFLAG_FULL_ID, PFLAG_FULL_ID,
PFLAG_MULTIREG_CONTACT, PFLAG_MULTIREG_CONTACT,
PFLAG_PASS_RFC2833,
PFLAG_DISABLE_TRANSCODING, PFLAG_DISABLE_TRANSCODING,
PFLAG_REWRITE_TIMESTAMPS,
PFLAG_RUNNING, PFLAG_RUNNING,
PFLAG_RESPAWN, PFLAG_RESPAWN,
PFLAG_MULTIREG, PFLAG_MULTIREG,
@ -218,10 +216,6 @@ typedef enum {
PFLAG_AGGRESSIVE_NAT_DETECTION, PFLAG_AGGRESSIVE_NAT_DETECTION,
PFLAG_RECIEVED_IN_NAT_REG_CONTACT, PFLAG_RECIEVED_IN_NAT_REG_CONTACT,
PFLAG_3PCC, PFLAG_3PCC,
PFLAG_DISABLE_RTP_AUTOADJ,
PFLAG_FUNNY_STUN,
PFLAG_STUN_ENABLED,
PFLAG_STUN_AUTO_DISABLE,
PFLAG_3PCC_PROXY, PFLAG_3PCC_PROXY,
PFLAG_CALLID_AS_UUID, PFLAG_CALLID_AS_UUID,
PFLAG_UUID_AS_CALLID, PFLAG_UUID_AS_CALLID,
@ -230,7 +224,6 @@ typedef enum {
PFLAG_DISABLE_SRV, PFLAG_DISABLE_SRV,
PFLAG_DISABLE_SRV503, PFLAG_DISABLE_SRV503,
PFLAG_DISABLE_NAPTR, PFLAG_DISABLE_NAPTR,
PFLAG_AUTOFLUSH,
PFLAG_NAT_OPTIONS_PING, PFLAG_NAT_OPTIONS_PING,
PFLAG_ALL_REG_OPTIONS_PING, PFLAG_ALL_REG_OPTIONS_PING,
PFLAG_MESSAGE_QUERY_ON_REGISTER, PFLAG_MESSAGE_QUERY_ON_REGISTER,
@ -282,12 +275,6 @@ typedef enum {
PFLAG_NDLB_EXPIRES_IN_REGISTER_RESPONSE = (1 << 6) PFLAG_NDLB_EXPIRES_IN_REGISTER_RESPONSE = (1 << 6)
} sofia_NDLB_t; } sofia_NDLB_t;
typedef enum {
STUN_FLAG_SET = (1 << 0),
STUN_FLAG_PING = (1 << 1),
STUN_FLAG_FUNNY = (1 << 2)
} STUNFLAGS;
typedef enum { typedef enum {
TFLAG_IO, TFLAG_IO,
TFLAG_CHANGE_MEDIA, TFLAG_CHANGE_MEDIA,
@ -299,9 +286,6 @@ typedef enum {
TFLAG_BYE, TFLAG_BYE,
TFLAG_ANS, TFLAG_ANS,
TFLAG_EARLY_MEDIA, TFLAG_EARLY_MEDIA,
TFLAG_VAD_IN,
TFLAG_VAD_OUT,
TFLAG_VAD,
TFLAG_3PCC, TFLAG_3PCC,
TFLAG_READY, TFLAG_READY,
TFLAG_REINVITE, TFLAG_REINVITE,
@ -326,7 +310,6 @@ typedef enum {
TFLAG_T38_PASSTHRU, TFLAG_T38_PASSTHRU,
TFLAG_RECOVERED, TFLAG_RECOVERED,
TFLAG_AUTOFLUSH_DURING_BRIDGE, TFLAG_AUTOFLUSH_DURING_BRIDGE,
TFLAG_NOTIMER_DURING_BRIDGE,
TFLAG_JB_PAUSED, TFLAG_JB_PAUSED,
TFLAG_3PCC_INVITE, TFLAG_3PCC_INVITE,
TFLAG_NOREPLY, TFLAG_NOREPLY,
@ -575,9 +558,6 @@ struct sofia_profile {
char *presence_hosts; char *presence_hosts;
char *presence_privacy; char *presence_privacy;
char *challenge_realm; char *challenge_realm;
char *rtcp_audio_interval_msec;
char *rtcp_video_interval_msec;
char *jb_msec;
char *pnp_prov_url; char *pnp_prov_url;
char *pnp_notify_profile; char *pnp_notify_profile;
sofia_cid_type_t cid_type; sofia_cid_type_t cid_type;
@ -603,7 +583,6 @@ struct sofia_profile {
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
su_root_t *s_root; su_root_t *s_root;
sip_alias_node_t *aliases; sip_alias_node_t *aliases;
switch_payload_t te;
switch_payload_t cng_pt; switch_payload_t cng_pt;
uint32_t codec_flags; uint32_t codec_flags;
switch_mutex_t *ireg_mutex; switch_mutex_t *ireg_mutex;
@ -684,6 +663,7 @@ struct sofia_profile {
uint32_t rtp_digit_delay; uint32_t rtp_digit_delay;
switch_queue_t *event_queue; switch_queue_t *event_queue;
switch_thread_t *thread; switch_thread_t *thread;
switch_core_media_vflag_t vflags;
}; };
struct private_object { struct private_object {
@ -695,6 +675,7 @@ struct private_object {
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_media_handle_t *media_handle;
switch_core_media_params_t *mparams;
switch_frame_t read_frame; switch_frame_t read_frame;
char *codec_order[SWITCH_MAX_CODECS]; char *codec_order[SWITCH_MAX_CODECS];
@ -710,17 +691,9 @@ struct private_object {
switch_caller_profile_t *caller_profile; switch_caller_profile_t *caller_profile;
uint32_t timestamp_send; uint32_t timestamp_send;
switch_rtp_t *rtp_session; switch_rtp_t *rtp_session;
uint32_t ssrc;
uint32_t video_ssrc; uint32_t video_ssrc;
sofia_profile_t *profile; sofia_profile_t *profile;
char *local_sdp_audio_ip;
switch_port_t local_sdp_audio_port;
char *remote_sdp_audio_ip;
switch_port_t remote_sdp_audio_port;
char *adv_sdp_audio_ip;
switch_port_t adv_sdp_audio_port;
char *proxy_sdp_audio_ip;
switch_port_t proxy_sdp_audio_port;
char *reply_contact; char *reply_contact;
char *from_uri; char *from_uri;
char *to_uri; char *to_uri;
@ -738,10 +711,6 @@ struct private_object {
char *iananame; char *iananame;
char *rm_fmtp; char *rm_fmtp;
char *fmtp_out; char *fmtp_out;
char *remote_sdp_str;
char *early_sdp;
char *local_sdp_str;
char *last_sdp_str;
char *dest; char *dest;
char *dest_to; char *dest_to;
char *key; char *key;
@ -757,16 +726,12 @@ struct private_object {
char *local_url; char *local_url;
char *gateway_name; char *gateway_name;
char *record_route; char *record_route;
char *extrtpip;
char *stun_ip;
char *route_uri; char *route_uri;
char *x_freeswitch_support_remote; char *x_freeswitch_support_remote;
char *x_freeswitch_support_local; char *x_freeswitch_support_local;
char *last_sent_callee_id_name; char *last_sent_callee_id_name;
char *last_sent_callee_id_number; char *last_sent_callee_id_number;
char *rtpip;
switch_port_t stun_port;
uint32_t stun_flags;
unsigned long rm_rate; unsigned long rm_rate;
switch_payload_t pt; switch_payload_t pt;
switch_mutex_t *flag_mutex; switch_mutex_t *flag_mutex;
@ -795,16 +760,12 @@ struct private_object {
switch_payload_t video_pt; switch_payload_t video_pt;
unsigned long video_rm_rate; unsigned long video_rm_rate;
uint32_t video_codec_ms; uint32_t video_codec_ms;
char *remote_sdp_video_ip;
switch_port_t remote_sdp_video_port;
char *video_rm_fmtp; char *video_rm_fmtp;
switch_payload_t video_agreed_pt; switch_payload_t video_agreed_pt;
char *video_fmtp_out; char *video_fmtp_out;
uint32_t video_count; uint32_t video_count;
switch_core_media_dtmf_t dtmf_type; switch_core_media_dtmf_t dtmf_type;
int q850_cause; int q850_cause;
char *remote_ip;
int remote_port;
int got_bye; int got_bye;
int hold_laps; int hold_laps;
switch_thread_id_t locker; switch_thread_id_t locker;
@ -1012,8 +973,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot);
void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now); void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now);
void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now); void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now);
void sofia_reg_unregister(sofia_profile_t *profile); void sofia_reg_unregister(sofia_profile_t *profile);
switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_object_t *tech_pvt, char **ip, switch_port_t *port,
const char *sourceip, switch_memory_pool_t *pool);
void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp); void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp);
switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status); switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status);
@ -1033,7 +993,6 @@ char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char
switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile, switch_mutex_t *mutex, char *sql, switch_core_db_callback_func_t callback, switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile, switch_mutex_t *mutex, char *sql, switch_core_db_callback_func_t callback,
void *pdata); void *pdata);
char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex, char *sql, char *resbuf, size_t len); char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex, char *sql, char *resbuf, size_t len);
void sofia_media_check_video_codecs(private_object_t *tech_pvt);
void sofia_glue_del_profile(sofia_profile_t *profile); void sofia_glue_del_profile(sofia_profile_t *profile);
switch_status_t sofia_glue_add_profile(char *key, sofia_profile_t *profile); switch_status_t sofia_glue_add_profile(char *key, sofia_profile_t *profile);
@ -1106,18 +1065,17 @@ char *sofia_glue_find_parameter_value(switch_core_session_t *session, const char
char *sofia_glue_create_via(switch_core_session_t *session, const char *ip, switch_port_t port, sofia_transport_t transport); char *sofia_glue_create_via(switch_core_session_t *session, const char *ip, switch_port_t port, sofia_transport_t transport);
char *sofia_glue_create_external_via(switch_core_session_t *session, sofia_profile_t *profile, sofia_transport_t transport); char *sofia_glue_create_external_via(switch_core_session_t *session, sofia_profile_t *profile, sofia_transport_t transport);
char *sofia_glue_strip_uri(const char *str); char *sofia_glue_strip_uri(const char *str);
int sofia_glue_check_nat(sofia_profile_t *profile, const char *network_ip);
int sofia_glue_transport_has_tls(const sofia_transport_t tp); int sofia_glue_transport_has_tls(const sofia_transport_t tp);
const char *sofia_glue_get_unknown_header(sip_t const *sip, const char *name); const char *sofia_glue_get_unknown_header(sip_t const *sip, const char *name);
switch_status_t sofia_media_build_crypto(private_object_t *tech_pvt, int index, switch_rtp_crypto_key_type_t type, switch_rtp_crypto_direction_t direction); switch_status_t sofia_media_build_crypto(private_object_t *tech_pvt, int index, switch_rtp_crypto_key_type_t type, switch_rtp_crypto_direction_t direction);
void sofia_media_tech_patch_sdp(private_object_t *tech_pvt); void sofia_media_tech_patch_sdp(private_object_t *tech_pvt);
switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt, const char *sdp_str);
void sofia_presence_event_thread_start(void); void sofia_presence_event_thread_start(void);
void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id, int reboot); void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id, int reboot);
void sofia_reg_check_call_id(sofia_profile_t *profile, const char *call_id); void sofia_reg_check_call_id(sofia_profile_t *profile, const char *call_id);
void sofia_reg_check_sync(sofia_profile_t *profile); void sofia_reg_check_sync(sofia_profile_t *profile);
switch_status_t sofia_glue_tech_choose_video_port(private_object_t *tech_pvt, int force);
switch_status_t sofia_media_tech_set_video_codec(private_object_t *tech_pvt, int force);
char *sofia_glue_get_register_host(const char *uri); char *sofia_glue_get_register_host(const char *uri);
const char *sofia_glue_strip_proto(const char *uri); const char *sofia_glue_strip_proto(const char *uri);
void sofia_glue_del_gateway(sofia_gateway_t *gp); void sofia_glue_del_gateway(sofia_gateway_t *gp);
@ -1126,9 +1084,7 @@ void sofia_glue_del_every_gateway(sofia_profile_t *profile);
void sofia_reg_send_reboot(sofia_profile_t *profile, const char *callid, const char *user, const char *host, const char *contact, const char *user_agent, void sofia_reg_send_reboot(sofia_profile_t *profile, const char *callid, const char *user, const char *host, const char *contact, const char *user_agent,
const char *network_ip); const char *network_ip);
void sofia_glue_restart_all_profiles(void); void sofia_glue_restart_all_profiles(void);
int sofia_media_toggle_hold(private_object_t *tech_pvt, int sendonly);
const char *sofia_state_string(int state); const char *sofia_state_string(int state);
switch_status_t sofia_media_tech_set_codec(private_object_t *tech_pvt, int force);
void sofia_wait_for_reply(struct private_object *tech_pvt, nua_event_t event, uint32_t timeout); void sofia_wait_for_reply(struct private_object *tech_pvt, nua_event_t event, uint32_t timeout);
void sofia_glue_set_udptl_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *t38_options, int insist); void sofia_glue_set_udptl_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *t38_options, int insist);
@ -1175,8 +1131,6 @@ switch_status_t sip_dig_function(_In_opt_z_ const char *cmd, _In_opt_ switch_cor
const char *sofia_gateway_status_name(sofia_gateway_status_t status); const char *sofia_gateway_status_name(sofia_gateway_status_t status);
void sofia_reg_fire_custom_gateway_state_event(sofia_gateway_t *gateway, int status, const char *phrase); void sofia_reg_fire_custom_gateway_state_event(sofia_gateway_t *gateway, int status, const char *phrase);
uint32_t sofia_reg_reg_count(sofia_profile_t *profile, const char *user, const char *host); uint32_t sofia_reg_reg_count(sofia_profile_t *profile, const char *user, const char *host);
void sofia_media_copy_t38_options(switch_t38_options_t *t38_options, switch_core_session_t *session);
switch_t38_options_t *sofia_media_extract_t38_options(switch_core_session_t *session, const char *r_sdp);
char *sofia_media_get_multipart(switch_core_session_t *session, const char *prefix, const char *sdp, char **mp_type); char *sofia_media_get_multipart(switch_core_session_t *session, const char *prefix, const char *sdp, char **mp_type);
int sofia_glue_tech_simplify(private_object_t *tech_pvt); int sofia_glue_tech_simplify(private_object_t *tech_pvt);
switch_console_callback_match_t *sofia_reg_find_reg_url_multi(sofia_profile_t *profile, const char *user, const char *host); switch_console_callback_match_t *sofia_reg_find_reg_url_multi(sofia_profile_t *profile, const char *user, const char *host);

View File

@ -3920,27 +3920,13 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
} else if (!strcasecmp(var, "aggressive-nat-detection") && switch_true(val)) { } else if (!strcasecmp(var, "aggressive-nat-detection") && switch_true(val)) {
sofia_set_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION); sofia_set_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION);
} else if (!strcasecmp(var, "disable-rtp-auto-adjust") && switch_true(val)) { } else if (!strcasecmp(var, "disable-rtp-auto-adjust") && switch_true(val)) {
sofia_set_pflag(profile, PFLAG_DISABLE_RTP_AUTOADJ); if (switch_true(val)) {
sofia_set_media_flag(profile, SCMF_DISABLE_RTP_AUTOADJ);
} else {
sofia_clear_media_flag(profile, SCMF_DISABLE_RTP_AUTOADJ);
}
} else if (!strcasecmp(var, "NDLB-support-asterisk-missing-srtp-auth") && switch_true(val)) { } else if (!strcasecmp(var, "NDLB-support-asterisk-missing-srtp-auth") && switch_true(val)) {
profile->ndlb |= SM_NDLB_DISABLE_SRTP_AUTH; profile->ndlb |= SM_NDLB_DISABLE_SRTP_AUTH;
} else if (!strcasecmp(var, "NDLB-funny-stun")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_FUNNY_STUN);
} else {
sofia_clear_pflag(profile, PFLAG_FUNNY_STUN);
}
} else if (!strcasecmp(var, "stun-enabled")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_STUN_ENABLED);
} else {
sofia_clear_pflag(profile, PFLAG_STUN_ENABLED);
}
} else if (!strcasecmp(var, "stun-auto-disable")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_STUN_AUTO_DISABLE);
} else {
sofia_clear_pflag(profile, PFLAG_STUN_AUTO_DISABLE);
}
} else if (!strcasecmp(var, "user-agent-filter")) { } else if (!strcasecmp(var, "user-agent-filter")) {
profile->user_agent_filter = switch_core_strdup(profile->pool, val); profile->user_agent_filter = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "max-registrations-per-extension")) { } else if (!strcasecmp(var, "max-registrations-per-extension")) {
@ -3958,12 +3944,11 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
} }
} else if (!strcasecmp(var, "vad")) { } else if (!strcasecmp(var, "vad")) {
if (!strcasecmp(val, "in")) { if (!strcasecmp(val, "in")) {
sofia_set_flag(profile, TFLAG_VAD_IN); profile->vflags |= VAD_IN;
} else if (!strcasecmp(val, "out")) { } else if (!strcasecmp(val, "out")) {
sofia_set_flag(profile, TFLAG_VAD_OUT); profile->vflags |= VAD_OUT;
} else if (!strcasecmp(val, "both")) { } else if (!strcasecmp(val, "both")) {
sofia_set_flag(profile, TFLAG_VAD_IN); profile->vflags |= VAD_OUT | VAD_IN;
sofia_set_flag(profile, TFLAG_VAD_OUT);
} else if (strcasecmp(val, "none")) { } else if (strcasecmp(val, "none")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid option %s for VAD\n", val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid option %s for VAD\n", val);
} }
@ -5235,7 +5220,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
switch_channel_clear_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_REQ); switch_channel_clear_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_REQ);
switch_channel_set_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_FAIL); switch_channel_set_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_FAIL);
} else if (status == 200 && sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU) && has_t38 && sip->sip_payload && sip->sip_payload->pl_data) { } else if (status == 200 && sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU) && has_t38 && sip->sip_payload && sip->sip_payload->pl_data) {
switch_t38_options_t *t38_options = sofia_media_extract_t38_options(session, sip->sip_payload->pl_data); switch_t38_options_t *t38_options = switch_core_media_extract_t38_options(session, sip->sip_payload->pl_data);
if (!t38_options) { if (!t38_options) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Could not parse T.38 options from sdp.\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Could not parse T.38 options from sdp.\n");
@ -5274,7 +5259,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
} }
} }
sofia_media_copy_t38_options(t38_options, other_session); switch_core_media_copy_t38_options(t38_options, other_session);
} }
} }
@ -5450,7 +5435,7 @@ void *SWITCH_THREAD_FUNC media_on_hold_thread_run(switch_thread_t *thread, void
switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_AUTOADJ); switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
} }
sofia_media_toggle_hold(tech_pvt, 1); switch_core_media_toggle_hold(session, 1);
} }
switch_core_session_rwunlock(other_session); switch_core_session_rwunlock(other_session);
} }

View File

@ -279,12 +279,22 @@ 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); tech_pvt->mparams->ndlb = tech_pvt->profile->ndlb;
switch_media_handle_set_ndlb(tech_pvt->media_handle, tech_pvt->profile->ndlb); tech_pvt->mparams->inbound_codec_string = profile->inbound_codec_string;
tech_pvt->mparams->outbound_codec_string = profile->outbound_codec_string;
tech_pvt->mparams->auto_rtp_bugs = profile->auto_rtp_bugs;
tech_pvt->mparams->timer_name = profile->timer_name;
tech_pvt->mparams->vflags = profile->vflags;
tech_pvt->mparams->manual_rtp_bugs = profile->manual_rtp_bugs;
tech_pvt->mparams->manual_video_rtp_bugs = profile->manual_video_rtp_bugs;
tech_pvt->mparams->extsipip = profile->extsipip;
tech_pvt->mparams->local_network = profile->local_network;
switch_media_handle_create(&tech_pvt->media_handle, session, &tech_pvt->mparams);
switch_media_handle_set_media_flags(tech_pvt->media_handle, tech_pvt->profile->media_flags); switch_media_handle_set_media_flags(tech_pvt->media_handle, tech_pvt->profile->media_flags);
switch_media_set_param(tech_pvt->media_handle, SCM_INBOUND_CODEC_STRING, profile->inbound_codec_string);
switch_media_set_param(tech_pvt->media_handle, SCM_OUTBOUND_CODEC_STRING, profile->inbound_codec_string);
switch_core_session_set_private(session, tech_pvt); switch_core_session_set_private(session, tech_pvt);
@ -295,100 +305,6 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
} }
switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_object_t *tech_pvt, char **ip, switch_port_t *port,
const char *sourceip, switch_memory_pool_t *pool)
{
char *error = "";
switch_status_t status = SWITCH_STATUS_FALSE;
int x;
switch_port_t myport = *port;
const char *var;
int funny = 0;
switch_port_t stun_port = SWITCH_STUN_DEFAULT_PORT;
char *stun_ip = NULL;
if (!sourceip) {
return status;
}
if (!strncasecmp(sourceip, "host:", 5)) {
status = (*ip = switch_stun_host_lookup(sourceip + 5, pool)) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
} else if (!strncasecmp(sourceip, "stun:", 5)) {
char *p;
if (!sofia_test_pflag(profile, PFLAG_STUN_ENABLED)) {
*ip = switch_core_strdup(pool, tech_pvt->rtpip);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Trying to use STUN but its disabled!\n");
goto out;
}
stun_ip = strdup(sourceip + 5);
if ((p = strchr(stun_ip, ':'))) {
int iport;
*p++ = '\0';
iport = atoi(p);
if (iport > 0 && iport < 0xFFFF) {
stun_port = (switch_port_t) iport;
}
}
if (zstr(stun_ip)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "STUN Failed! NO STUN SERVER\n");
goto out;
}
for (x = 0; x < 5; x++) {
if (sofia_test_pflag(profile, PFLAG_FUNNY_STUN) ||
(tech_pvt && (var = switch_channel_get_variable(tech_pvt->channel, "funny_stun")) && switch_true(var))) {
error = "funny";
funny++;
}
if ((status = switch_stun_lookup(ip, port, stun_ip, stun_port, &error, pool)) != SWITCH_STATUS_SUCCESS) {
switch_yield(100000);
} else {
break;
}
}
if (status != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "STUN Failed! %s:%d [%s]\n", stun_ip, stun_port, error);
goto out;
}
if (!*ip) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "STUN Failed! No IP returned\n");
goto out;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "STUN Success [%s]:[%d]\n", *ip, *port);
status = SWITCH_STATUS_SUCCESS;
if (tech_pvt) {
if (myport == *port && !strcmp(*ip, tech_pvt->rtpip)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "STUN Not Required ip and port match. [%s]:[%d]\n", *ip, *port);
if (sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE)) {
sofia_clear_pflag(profile, PFLAG_STUN_ENABLED);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "STUN completely disabled.\n");
}
} else {
tech_pvt->stun_ip = switch_core_session_strdup(tech_pvt->session, stun_ip);
tech_pvt->stun_port = stun_port;
tech_pvt->stun_flags |= STUN_FLAG_SET;
if (funny) {
tech_pvt->stun_flags |= STUN_FLAG_FUNNY;
}
}
}
} else {
*ip = (char *) sourceip;
status = SWITCH_STATUS_SUCCESS;
}
out:
switch_safe_free(stun_ip);
return status;
}
const char *sofia_glue_get_unknown_header(sip_t const *sip, const char *name) const char *sofia_glue_get_unknown_header(sip_t const *sip, const char *name)
{ {
sip_unknown_t *un; sip_unknown_t *un;
@ -472,69 +388,6 @@ switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt, int forc
} }
switch_status_t sofia_glue_tech_choose_video_port(private_object_t *tech_pvt, int force)
{
char *lookup_rtpip = tech_pvt->rtpip; /* Pointer to externally looked up address */
switch_port_t sdp_port; /* The external port to be sent in the SDP */
const char *use_ip = NULL; /* The external IP to be sent in the SDP */
/* Don't do anything if we're in proxy mode or if a (remote) port already has been found */
if (!force) {
if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) ||
switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA) || tech_pvt->adv_sdp_video_port) {
return SWITCH_STATUS_SUCCESS;
}
}
/* Release the local sdp port */
if (tech_pvt->local_sdp_video_port) {
switch_rtp_release_port(tech_pvt->rtpip, tech_pvt->local_sdp_video_port);
}
/* Request a local port from the core's allocator */
if (!(tech_pvt->local_sdp_video_port = switch_rtp_request_port(tech_pvt->rtpip))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_CRIT, "No RTP ports available!\n");
return SWITCH_STATUS_FALSE;
}
sdp_port = tech_pvt->local_sdp_video_port;
/* Check if NAT is detected */
if (!zstr(tech_pvt->remote_ip) && sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
/* Yes, map the port through switch_nat */
switch_nat_add_mapping(tech_pvt->local_sdp_video_port, SWITCH_NAT_UDP, &sdp_port, SWITCH_FALSE);
/* Find an IP address to use */
if (!(use_ip = switch_channel_get_variable(tech_pvt->channel, "rtp_adv_video_ip"))
&& !zstr(tech_pvt->profile->extrtpip)) {
use_ip = tech_pvt->profile->extrtpip;
}
if (use_ip) {
if (sofia_glue_ext_address_lookup(tech_pvt->profile, tech_pvt, &lookup_rtpip, &sdp_port,
use_ip, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
/* Address lookup was required and fail (external ip was "host:..." or "stun:...") */
return SWITCH_STATUS_FALSE;
} else {
/* Address properly resolved, use it as external ip */
use_ip = lookup_rtpip;
}
} else {
/* No external ip found, use the profile's rtp ip */
use_ip = tech_pvt->rtpip;
}
} else {
/* No NAT traversal required, use the profile's rtp ip */
use_ip = tech_pvt->rtpip;
}
tech_pvt->adv_sdp_video_port = sdp_port;
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
switch_channel_set_variable_printf(tech_pvt->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, "%d", sdp_port);
return SWITCH_STATUS_SUCCESS;
}
sofia_transport_t sofia_glue_str2transport(const char *str) sofia_transport_t sofia_glue_str2transport(const char *str)
{ {
if (!strncasecmp(str, "udp", 3)) { if (!strncasecmp(str, "udp", 3)) {
@ -726,14 +579,7 @@ char *sofia_glue_strip_uri(const char *str)
return r; return r;
} }
int sofia_glue_check_nat(sofia_profile_t *profile, const char *network_ip)
{
switch_assert(network_ip);
return (profile->extsipip &&
!switch_check_network_list_ip(network_ip, "loopback.auto") &&
!switch_check_network_list_ip(network_ip, profile->local_network));
}
int sofia_glue_transport_has_tls(const sofia_transport_t tp) int sofia_glue_transport_has_tls(const sofia_transport_t tp)
{ {
@ -825,172 +671,6 @@ char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char
return new_uri; return new_uri;
} }
#define RA_PTR_LEN 512
switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt, const char *sdp_str)
{
const char *err;
char rip[RA_PTR_LEN] = "";
char rp[RA_PTR_LEN] = "";
char rvp[RA_PTR_LEN] = "";
char *p, *ip_ptr = NULL, *port_ptr = NULL, *vid_port_ptr = NULL, *pe;
int x;
const char *val;
switch_status_t status = SWITCH_STATUS_FALSE;
if (zstr(sdp_str)) {
sdp_str = tech_pvt->remote_sdp_str;
}
if (zstr(sdp_str)) {
goto end;
}
if ((p = (char *) switch_stristr("c=IN IP4 ", sdp_str)) || (p = (char *) switch_stristr("c=IN IP6 ", sdp_str))) {
ip_ptr = p + 9;
}
if ((p = (char *) switch_stristr("m=audio ", sdp_str))) {
port_ptr = p + 8;
}
if ((p = (char *) switch_stristr("m=image ", sdp_str))) {
char *tmp = p + 8;
if (tmp && atoi(tmp)) {
port_ptr = tmp;
}
}
if ((p = (char *) switch_stristr("m=video ", sdp_str))) {
vid_port_ptr = p + 8;
}
if (!(ip_ptr && port_ptr)) {
goto end;
}
p = ip_ptr;
pe = p + strlen(p);
x = 0;
while (x < sizeof(rip) - 1 && p && *p && ((*p >= '0' && *p <= '9') || *p == '.' || *p == ':' || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F'))) {
rip[x++] = *p;
p++;
if (p >= pe) {
goto end;
}
}
p = port_ptr;
x = 0;
while (x < sizeof(rp) - 1 && p && *p && (*p >= '0' && *p <= '9')) {
rp[x++] = *p;
p++;
if (p >= pe) {
goto end;
}
}
p = vid_port_ptr;
x = 0;
while (x < sizeof(rvp) - 1 && p && *p && (*p >= '0' && *p <= '9')) {
rvp[x++] = *p;
p++;
if (p >= pe) {
goto end;
}
}
if (!(*rip && *rp)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "invalid SDP\n");
goto end;
}
tech_pvt->remote_sdp_audio_ip = switch_core_session_strdup(tech_pvt->session, rip);
tech_pvt->remote_sdp_audio_port = (switch_port_t) atoi(rp);
if (*rvp) {
tech_pvt->remote_sdp_video_ip = switch_core_session_strdup(tech_pvt->session, rip);
tech_pvt->remote_sdp_video_port = (switch_port_t) atoi(rvp);
}
if (tech_pvt->remote_sdp_video_ip && tech_pvt->remote_sdp_video_port) {
if (!strcmp(tech_pvt->remote_sdp_video_ip, rip) && atoi(rvp) == tech_pvt->remote_sdp_video_port) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Remote video address:port [%s:%d] has not changed.\n",
tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port);
} else {
switch_channel_set_flag(tech_pvt->channel, CF_VIDEO_POSSIBLE);
switch_channel_set_flag(tech_pvt->channel, CF_VIDEO);
if (switch_rtp_ready(tech_pvt->video_rtp_session)) {
const char *rport = NULL;
switch_port_t remote_rtcp_port = 0;
if ((rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_video_rtcp_port"))) {
remote_rtcp_port = (switch_port_t)atoi(rport);
}
if (switch_rtp_set_remote_address(tech_pvt->video_rtp_session, tech_pvt->remote_sdp_video_ip,
tech_pvt->remote_sdp_video_port, remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "VIDEO RTP REPORTS ERROR: [%s]\n", err);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "VIDEO RTP CHANGING DEST TO: [%s:%d]\n",
tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port);
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))) {
/* Reactivate the NAT buster flag. */
switch_rtp_set_flag(tech_pvt->video_rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
}
if (sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_TIMING)) {
tech_pvt->check_frames = 0;
}
}
}
}
}
if (switch_rtp_ready(tech_pvt->rtp_session)) {
char *remote_host = switch_rtp_get_remote_host(tech_pvt->rtp_session);
switch_port_t remote_port = switch_rtp_get_remote_port(tech_pvt->rtp_session);
const char *rport = NULL;
switch_port_t remote_rtcp_port = 0;
if (remote_host && remote_port && !strcmp(remote_host, tech_pvt->remote_sdp_audio_ip) && remote_port == tech_pvt->remote_sdp_audio_port) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Remote address:port [%s:%d] has not changed.\n",
tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port);
switch_goto_status(SWITCH_STATUS_BREAK, end);
}
if ((rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_audio_rtcp_port"))) {
remote_rtcp_port = (switch_port_t)atoi(rport);
}
if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port, remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err);
status = SWITCH_STATUS_GENERR;
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "AUDIO RTP CHANGING DEST TO: [%s:%d]\n",
tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port);
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))) {
/* Reactivate the NAT buster flag. */
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
}
if (sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_TIMING)) {
tech_pvt->check_frames = 0;
}
status = SWITCH_STATUS_SUCCESS;
}
}
end:
return status;
}
char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix) char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix)
{ {
char *extra_headers = NULL; char *extra_headers = NULL;
@ -1159,7 +839,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
cid_name = caller_profile->caller_id_name; cid_name = caller_profile->caller_id_name;
cid_num = caller_profile->caller_id_number; cid_num = caller_profile->caller_id_number;
sofia_media_tech_prepare_codecs(tech_pvt); sofia_media_tech_prepare_codecs(tech_pvt);
sofia_media_check_video_codecs(tech_pvt); switch_core_media_check_video_codecs(tech_pvt->session);
check_decode(cid_name, session); check_decode(cid_name, session);
check_decode(cid_num, session); check_decode(cid_num, session);
@ -2416,7 +2096,7 @@ int sofia_recover_callback(switch_core_session_t *session)
tech_pvt->pt = tech_pvt->agreed_pt = (switch_payload_t)atoi(tmp); tech_pvt->pt = tech_pvt->agreed_pt = (switch_payload_t)atoi(tmp);
} }
sofia_media_tech_set_codec(tech_pvt, 1); switch_core_media_set_codec(tech_pvt->session, 1, tech_pvt->profile->codec_flags);
tech_pvt->adv_sdp_audio_ip = tech_pvt->extrtpip = (char *) ip; tech_pvt->adv_sdp_audio_ip = tech_pvt->extrtpip = (char *) ip;
tech_pvt->adv_sdp_audio_port = tech_pvt->local_sdp_audio_port = (switch_port_t)atoi(port); tech_pvt->adv_sdp_audio_port = tech_pvt->local_sdp_audio_port = (switch_port_t)atoi(port);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff