提交 b10e7313 authored 作者: David Yat Sin's avatar David Yat Sin

Merge branch 'nsg-4.3' of ssh://git.sangoma.com/smg_freeswitch into nsg-4.3

...@@ -121,7 +121,6 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi ...@@ -121,7 +121,6 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
chan_id = atoi(szchanid); chan_id = atoi(szchanid);
if (ftdm_span_find_by_name(span_name, &span) == FTDM_SUCCESS) { if (ftdm_span_find_by_name(span_name, &span) == FTDM_SUCCESS) {
span_id = ftdm_span_get_id(span); span_id = ftdm_span_get_id(span);
} else { } else {
......
...@@ -185,6 +185,7 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha ...@@ -185,6 +185,7 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha
term->pool = pool; term->pool = pool;
term->type = termtype; term->type = termtype;
term->active_events = NULL; term->active_events = NULL;
term->mg_ctxt = NULL;
term->profile = profile; term->profile = profile;
switch_set_flag(term, MGT_ALLOCATED); switch_set_flag(term, MGT_ALLOCATED);
...@@ -231,6 +232,8 @@ void megaco_termination_destroy(mg_termination_t *term) ...@@ -231,6 +232,8 @@ void megaco_termination_destroy(mg_termination_t *term)
free(term->active_events); free(term->active_events);
term->active_events = NULL; term->active_events = NULL;
} }
term->mg_ctxt = NULL;
switch_clear_flag(term, MGT_ALLOCATED); switch_clear_flag(term, MGT_ALLOCATED);
switch_clear_flag(term, MGT_ACTIVE); switch_clear_flag(term, MGT_ACTIVE);
......
...@@ -15,6 +15,18 @@ ...@@ -15,6 +15,18 @@
#define MG_INACTIVITY_TMR_RESOLUTION 100 /* mit in ito package is experessed in 10ms steps */ #define MG_INACTIVITY_TMR_RESOLUTION 100 /* mit in ito package is experessed in 10ms steps */
/* rtp/avp profiles */
#define MG_RTP_AVP_PROFILE_A_LAW 8
#define MG_RTP_AVP_PROFILE_U_LAW 0
typedef enum{
MG_SDP_NONE,
MG_SDP_LOCAL,
MG_SDP_REMOTE,
}mgco_sdp_types_e;
typedef enum{ typedef enum{
SNG_MG_TPT_NONE, SNG_MG_TPT_NONE,
SNG_MG_TPT_UDP, SNG_MG_TPT_UDP,
...@@ -151,7 +163,7 @@ int sng_mgco_mg_get_status(int elemId, MgMngmt* cfm, megaco_profile_t* mg_cfg, m ...@@ -151,7 +163,7 @@ int sng_mgco_mg_get_status(int elemId, MgMngmt* cfm, megaco_profile_t* mg_cfg, m
switch_status_t mg_is_ito_pkg_req(megaco_profile_t* mg_profile, MgMgcoCommand *cmd); switch_status_t mg_is_ito_pkg_req(megaco_profile_t* mg_profile, MgMgcoCommand *cmd);
switch_status_t mg_send_end_of_axn(SuId suId, MgMgcoTransId* transId, MgMgcoContextId* ctxtId, TknU32* peerId); switch_status_t mg_send_end_of_axn(SuId suId, MgMgcoTransId* transId, MgMgcoContextId* ctxtId, TknU32* peerId);
void mgco_print_sdp(CmSdpInfoSet *sdp); void mgco_handle_sdp(CmSdpInfoSet *sdp,mg_termination_t* term, mgco_sdp_types_e sdp_type);
void mg_util_set_ctxt_string ( MgStr *errTxt, MgMgcoContextId *ctxtId); void mg_util_set_ctxt_string ( MgStr *errTxt, MgMgcoContextId *ctxtId);
switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd, MgMgcoContextId* new_ctxtId); switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd, MgMgcoContextId* new_ctxtId);
switch_status_t handle_mg_subtract_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd); switch_status_t handle_mg_subtract_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd);
......
...@@ -99,6 +99,8 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload) ...@@ -99,6 +99,8 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
term->pool = pool; term->pool = pool;
term->type = MG_TERM_TDM; term->type = MG_TERM_TDM;
term->profile = profile; term->profile = profile;
term->mg_ctxt = NULL;
term->active_events = NULL;
term->name = switch_core_sprintf(pool, "%s%d", prefix, j); term->name = switch_core_sprintf(pool, "%s%d", prefix, j);
term->u.tdm.channel = j; term->u.tdm.channel = j;
term->u.tdm.span_name = switch_core_strdup(pool, channel_prefix); term->u.tdm.span_name = switch_core_strdup(pool, channel_prefix);
......
...@@ -639,7 +639,7 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd) ...@@ -639,7 +639,7 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
MgMgcoNtfyReply* ntfy = &cmd->u.mgCmdCfm[0]->u.ntfy; MgMgcoNtfyReply* ntfy = &cmd->u.mgCmdCfm[0]->u.ntfy;
MgMgcoTermId* term = NULL; MgMgcoTermId* term = NULL;
char term_name[32]; char term_name[32];
memset(&term_name[0], 32, 0x00); memset(&term_name[0], 0x00,32);
strcpy(&term_name[0], "Invalid"); strcpy(&term_name[0], "Invalid");
...@@ -685,7 +685,7 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd) ...@@ -685,7 +685,7 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
MgMgcoSvcChgReply* svc = &cmd->u.mgCmdCfm[0]->u.svc; MgMgcoSvcChgReply* svc = &cmd->u.mgCmdCfm[0]->u.svc;
MgMgcoTermId* term = NULL; MgMgcoTermId* term = NULL;
char term_name[32]; char term_name[32];
memset(&term_name[0], 32, 0x00); memset(&term_name[0], 0x00, 32);
strcpy(&term_name[0], "Invalid"); strcpy(&term_name[0], "Invalid");
......
...@@ -94,6 +94,14 @@ enum { ...@@ -94,6 +94,14 @@ enum {
} mg_termination_flags; } mg_termination_flags;
struct mg_context_s {
uint32_t context_id;
mg_termination_t *terminations[MG_CONTEXT_MAX_TERMS];
megaco_profile_t *profile;
mg_context_t *next;
switch_memory_pool_t *pool;
};
struct mg_termination_s { struct mg_termination_s {
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
mg_termination_type_t type; mg_termination_type_t type;
...@@ -103,6 +111,7 @@ struct mg_termination_s { ...@@ -103,6 +111,7 @@ struct mg_termination_s {
megaco_profile_t *profile; /*!< Parent MG profile */ megaco_profile_t *profile; /*!< Parent MG profile */
MgMgcoReqEvtDesc *active_events; /* !< active megaco events */ MgMgcoReqEvtDesc *active_events; /* !< active megaco events */
mg_termination_t *next; /*!< List for physical terminations */ mg_termination_t *next; /*!< List for physical terminations */
mg_context_t* mg_ctxt;
uint32_t flags; uint32_t flags;
union { union {
...@@ -131,13 +140,7 @@ struct mg_termination_s { ...@@ -131,13 +140,7 @@ struct mg_termination_s {
}; };
struct mg_context_s {
uint32_t context_id;
mg_termination_t *terminations[MG_CONTEXT_MAX_TERMS];
megaco_profile_t *profile;
mg_context_t *next;
switch_memory_pool_t *pool;
};
#define MG_CONTEXT_MODULO 16 #define MG_CONTEXT_MODULO 16
#define MG_MAX_CONTEXTS 32768 #define MG_MAX_CONTEXTS 32768
...@@ -231,6 +234,7 @@ mg_context_t *megaco_choose_context(megaco_profile_t *profile); ...@@ -231,6 +234,7 @@ mg_context_t *megaco_choose_context(megaco_profile_t *profile);
void megaco_release_context(mg_context_t *ctx); void megaco_release_context(mg_context_t *ctx);
switch_status_t megaco_context_sub_termination(mg_context_t *ctx, mg_termination_t *term); switch_status_t megaco_context_sub_termination(mg_context_t *ctx, mg_termination_t *term);
switch_status_t megaco_context_sub_all_termination(mg_context_t *ctx); switch_status_t megaco_context_sub_all_termination(mg_context_t *ctx);
switch_status_t megaco_activate_termination(mg_termination_t *term);
mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const char *prefix); mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const char *prefix);
mg_termination_t *megaco_find_termination(megaco_profile_t *profile, const char *name); mg_termination_t *megaco_find_termination(megaco_profile_t *profile, const char *name);
......
...@@ -315,7 +315,8 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch ...@@ -315,7 +315,8 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
tech_pvt = switch_core_session_get_private(session); tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL); assert(tech_pvt != NULL);
if (!tech_pvt->rtp_session || tech_pvt->mode == RTP_RECVONLY) { if (!tech_pvt->rtp_session || tech_pvt->mode == RTP_SENDONLY) {
switch_yield(20000); /* replace by local timer XXX */
goto cng; goto cng;
} }
...@@ -338,6 +339,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch ...@@ -338,6 +339,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
cng: cng:
*frame = &tech_pvt->read_frame; *frame = &tech_pvt->read_frame;
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
tech_pvt->read_frame.flags |= SFF_CNG; tech_pvt->read_frame.flags |= SFF_CNG;
tech_pvt->read_frame.datalen = 0; tech_pvt->read_frame.datalen = 0;
...@@ -370,8 +372,11 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc ...@@ -370,8 +372,11 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
tech_pvt->timestamp_send += samples; tech_pvt->timestamp_send += samples;
#endif #endif
if (tech_pvt->mode == RTP_RECVONLY) {
switch_rtp_write_frame(tech_pvt->rtp_session, frame); return SWITCH_STATUS_SUCCESS;
}
switch_rtp_write_frame(tech_pvt->rtp_session, frame);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
...@@ -403,7 +408,11 @@ static switch_bool_t compare_var(switch_event_t *event, switch_channel_t *channe ...@@ -403,7 +408,11 @@ static switch_bool_t compare_var(switch_event_t *event, switch_channel_t *channe
{ {
const char *chan_val = switch_channel_get_variable_dup(channel, varname, SWITCH_FALSE, -1); const char *chan_val = switch_channel_get_variable_dup(channel, varname, SWITCH_FALSE, -1);
const char *event_val = switch_event_get_header(event, varname); const char *event_val = switch_event_get_header(event, varname);
if (zstr(chan_val) || zstr(event_val)) {
return 1;
}
return strcasecmp(chan_val, event_val); return strcasecmp(chan_val, event_val);
} }
...@@ -418,7 +427,7 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi ...@@ -418,7 +427,7 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
if (compare_var(event, channel, kREMOTEADDR) || if (compare_var(event, channel, kREMOTEADDR) ||
compare_var(event, channel, kREMOTEPORT)) { compare_var(event, channel, kREMOTEPORT)) {
char *remote_addr = switch_event_get_header(event, kREMOTEADDR); char *remote_addr = switch_event_get_header(event, kREMOTEADDR);
char *szremote_port = switch_event_get_header(event, kREMOTEADDR); char *szremote_port = switch_event_get_header(event, kREMOTEPORT);
switch_port_t remote_port = !zstr(szremote_port) ? atoi(szremote_port) : 0; switch_port_t remote_port = !zstr(szremote_port) ? atoi(szremote_port) : 0;
const char *err; const char *err;
...@@ -453,6 +462,8 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi ...@@ -453,6 +462,8 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
} else { } else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Received unknown command [%s] in event.\n", !command ? "null" : command); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Received unknown command [%s] in event.\n", !command ? "null" : command);
} }
return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg) static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
......
...@@ -4154,8 +4154,8 @@ SWITCH_DECLARE(const char *) switch_channel_get_partner_uuid(switch_channel_t *c ...@@ -4154,8 +4154,8 @@ SWITCH_DECLARE(const char *) switch_channel_get_partner_uuid(switch_channel_t *c
{ {
const char *uuid = NULL; const char *uuid = NULL;
if (!(uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { if (!(uuid = switch_channel_get_variable_dup(channel, SWITCH_SIGNAL_BOND_VARIABLE, SWITCH_FALSE, -1))) {
uuid = switch_channel_get_variable(channel, SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE); uuid = switch_channel_get_variable_dup(channel, SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE, SWITCH_FALSE, -1);
} }
return uuid; return uuid;
......
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
//#define RTP_DEBUG_WRITE_DELTA //#define RTP_DEBUG_WRITE_DELTA
//#define DEBUG_MISSED_SEQ //#define DEBUG_MISSED_SEQ
typedef unsigned long u_long;
#include <switch.h> #include <switch.h>
#include <switch_stun.h> #include <switch_stun.h>
#include <apr_network_io.h> #include <apr_network_io.h>
...@@ -2165,7 +2163,7 @@ SWITCH_DECLARE(uint8_t) switch_rtp_ready(switch_rtp_t *rtp_session) ...@@ -2165,7 +2163,7 @@ SWITCH_DECLARE(uint8_t) switch_rtp_ready(switch_rtp_t *rtp_session)
} }
switch_mutex_lock(rtp_session->flag_mutex); switch_mutex_lock(rtp_session->flag_mutex);
ret = (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) && rtp_session->sock_input && rtp_session->sock_output && rtp_session->remote_addr ret = (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) && rtp_session->sock_input /* && rtp_session->sock_output && rtp_session->remote_addr */
&& rtp_session->ready == 2) ? 1 : 0; && rtp_session->ready == 2) ? 1 : 0;
switch_mutex_unlock(rtp_session->flag_mutex); switch_mutex_unlock(rtp_session->flag_mutex);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论