Merge branch 'nsg-4.3' of ssh://git.sangoma.com/smg_freeswitch into nsg-4.3
This commit is contained in:
commit
5dc8412f44
|
@ -52,6 +52,8 @@ typedef struct {
|
|||
switch_core_session_t *session;
|
||||
switch_codec_t read_codec, write_codec;
|
||||
switch_frame_t read_frame;
|
||||
|
||||
unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
|
||||
} ctdm_private_t;
|
||||
|
||||
static switch_status_t channel_on_init(switch_core_session_t *session);
|
||||
|
@ -101,7 +103,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
*span_name = switch_event_get_header(var_event, kSPAN_NAME);
|
||||
int chan_id;
|
||||
int span_id;
|
||||
|
||||
switch_caller_profile_t *caller_profile;
|
||||
ftdm_span_t *span;
|
||||
ftdm_channel_t *chan;
|
||||
switch_channel_t *channel;
|
||||
|
@ -147,8 +149,14 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
tech_pvt->span_id = span_id;
|
||||
tech_pvt->ftdm_channel = chan;
|
||||
tech_pvt->session = *new_session;
|
||||
tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf);
|
||||
tech_pvt->read_frame.data = tech_pvt->databuf;
|
||||
switch_core_session_set_private(*new_session, tech_pvt);
|
||||
|
||||
|
||||
caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
|
||||
switch_channel_set_caller_profile(channel, caller_profile);
|
||||
|
||||
snprintf(name, sizeof(name), "tdm/%d:%d", span_id, chan_id);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connect outbound channel %s\n", name);
|
||||
switch_channel_set_name(channel, name);
|
||||
|
@ -228,6 +236,8 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
goto fail;
|
||||
}
|
||||
|
||||
switch_channel_mark_answered(channel);
|
||||
|
||||
return SWITCH_CAUSE_SUCCESS;
|
||||
|
||||
fail:
|
||||
|
@ -254,6 +264,9 @@ fail:
|
|||
|
||||
static switch_status_t channel_on_init(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
switch_channel_set_state(channel, CS_CONSUME_MEDIA);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -328,6 +341,7 @@ top:
|
|||
*frame = &tech_pvt->read_frame;
|
||||
tech_pvt->read_frame.datalen = (uint32_t)len;
|
||||
tech_pvt->read_frame.samples = tech_pvt->read_frame.datalen;
|
||||
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
|
||||
|
||||
if (ftdm_channel_get_codec(tech_pvt->ftdm_channel) == FTDM_CODEC_SLIN) {
|
||||
tech_pvt->read_frame.samples /= 2;
|
||||
|
|
|
@ -134,12 +134,13 @@ switch_status_t megaco_activate_termination(mg_termination_t *term)
|
|||
}
|
||||
|
||||
if (zstr(term->uuid)) {
|
||||
if (switch_ivr_originate(NULL, &session, &cause, dialstring, 0, NULL, NULL, NULL, NULL, var_event, 0, NULL) != SWITCH_CAUSE_SUCCESS) {
|
||||
if (switch_ivr_originate(NULL, &session, &cause, dialstring, 0, NULL, NULL, NULL, NULL, var_event, 0, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to instanciate termination [%s]: %s\n", term->name, switch_channel_cause2str(cause));
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto done;
|
||||
}
|
||||
|
||||
term->uuid = switch_core_strdup(term->pool, switch_core_session_get_uuid(session));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Termination [%s] successfully instanciated as [%s] [%s]\n", term->name, dialstring, switch_core_session_get_uuid(session));
|
||||
}
|
||||
|
||||
|
@ -285,6 +286,10 @@ switch_status_t megaco_context_add_termination(mg_context_t *ctx, mg_termination
|
|||
megaco_activate_termination(ctx->terminations[1]);
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Bridging: %s (%s) <> %s (%s)\n",
|
||||
ctx->terminations[0]->name, ctx->terminations[0]->uuid,
|
||||
ctx->terminations[1]->name, ctx->terminations[1]->uuid);
|
||||
|
||||
switch_ivr_uuid_bridge(ctx->terminations[0]->uuid, ctx->terminations[1]->uuid);
|
||||
}
|
||||
|
||||
|
|
|
@ -188,11 +188,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
tech_pvt->dtmf_type = DTMF_2833; /* XXX */
|
||||
|
||||
if (zstr(local_addr) || local_port == 0) {
|
||||
tech_pvt->mode = RTP_SENDONLY;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "The local address and port must be set\n");
|
||||
goto fail;
|
||||
} else if (zstr(remote_addr) || remote_port == 0) {
|
||||
tech_pvt->mode = RTP_SENDRECV;
|
||||
tech_pvt->mode = RTP_RECVONLY;
|
||||
} else {
|
||||
|
||||
tech_pvt->mode = RTP_SENDRECV;
|
||||
}
|
||||
|
||||
switch_core_session_set_private(*new_session, tech_pvt);
|
||||
|
@ -314,7 +315,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||
tech_pvt = switch_core_session_get_private(session);
|
||||
assert(tech_pvt != NULL);
|
||||
|
||||
if (!tech_pvt->rtp_session) {
|
||||
if (!tech_pvt->rtp_session || tech_pvt->mode == RTP_RECVONLY) {
|
||||
goto cng;
|
||||
}
|
||||
|
||||
|
@ -325,6 +326,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||
}
|
||||
|
||||
tech_pvt->read_frame.flags = SFF_NONE;
|
||||
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
|
||||
status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame, flags);
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
||||
|
@ -409,15 +411,27 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
|
|||
{
|
||||
const char *command = switch_event_get_header(event, "command");
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
crtp_private_t *tech_pvt = switch_core_session_get_private(session);
|
||||
|
||||
if (!zstr(command) && !strcasecmp(command, "media_modify")) {
|
||||
/* Compare parameters */
|
||||
if (compare_var(event, channel, kREMOTEADDR) ||
|
||||
compare_var(event, channel, kREMOTEPORT) ||
|
||||
compare_var(event, channel, kLOCALADDR) ||
|
||||
compare_var(event, channel, kLOCALPORT)) {
|
||||
/* We need to reset the rtp session */
|
||||
compare_var(event, channel, kREMOTEPORT)) {
|
||||
char *remote_addr = switch_event_get_header(event, kREMOTEADDR);
|
||||
char *szremote_port = switch_event_get_header(event, kREMOTEADDR);
|
||||
switch_port_t remote_port = !zstr(szremote_port) ? atoi(szremote_port) : 0;
|
||||
const char *err;
|
||||
|
||||
|
||||
switch_channel_set_variable(channel, kREMOTEADDR, remote_addr);
|
||||
switch_channel_set_variable(channel, kREMOTEPORT, szremote_port);
|
||||
|
||||
if (switch_rtp_set_remote_address(tech_pvt->rtp_session, remote_addr, remote_port, 0, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error setting RTP remote address: %s\n", err);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set RTP remote: %s:%d\n", remote_addr, (int)remote_port);
|
||||
tech_pvt->mode = RTP_SENDRECV;
|
||||
}
|
||||
}
|
||||
|
||||
if (compare_var(event, channel, kCODEC) ||
|
||||
|
@ -425,9 +439,17 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
|
|||
compare_var(event, channel, kPT) ||
|
||||
compare_var(event, channel, kRATE)) {
|
||||
/* Reset codec */
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Switching codec not yet implemented\n");
|
||||
}
|
||||
|
||||
if (compare_var(event, channel, kRFC2833PT)) {
|
||||
const char *szpt = switch_channel_get_variable(channel, kRFC2833PT);
|
||||
int pt = !zstr(szpt) ? atoi(szpt) : 0;
|
||||
|
||||
switch_channel_set_variable(channel, kRFC2833PT, szpt);
|
||||
switch_rtp_set_telephony_event(tech_pvt->rtp_session, pt);
|
||||
}
|
||||
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Received unknown command [%s] in event.\n", !command ? "null" : command);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
//#define RTP_DEBUG_WRITE_DELTA
|
||||
//#define DEBUG_MISSED_SEQ
|
||||
|
||||
typedef unsigned long u_long;
|
||||
|
||||
#include <switch.h>
|
||||
#include <switch_stun.h>
|
||||
#include <apr_network_io.h>
|
||||
|
@ -1451,7 +1453,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
|
|||
uint32_t index, switch_rtp_crypto_key_type_t type, unsigned char *key, switch_size_t keylen)
|
||||
{
|
||||
#ifndef ENABLE_SRTP
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "SRTP NOT SUPPORTED IN THIS BUILD!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SRTP NOT SUPPORTED IN THIS BUILD!\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
#else
|
||||
switch_rtp_crypto_key_t *crypto_key;
|
||||
|
@ -1832,6 +1834,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
|
|||
goto end;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (zstr(tx_host)) {
|
||||
*err = "Missing remote host";
|
||||
goto end;
|
||||
|
@ -1841,6 +1844,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
|
|||
*err = "Missing remote port";
|
||||
goto end;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (switch_rtp_create(&rtp_session, payload, samples_per_interval, ms_per_packet, flags, timer_name, err, pool) != SWITCH_STATUS_SUCCESS) {
|
||||
goto end;
|
||||
|
@ -1854,7 +1858,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
|
|||
goto end;
|
||||
}
|
||||
|
||||
if (switch_rtp_set_remote_address(rtp_session, tx_host, tx_port, 0, SWITCH_TRUE, err) != SWITCH_STATUS_SUCCESS) {
|
||||
if (!zstr(tx_host) && switch_rtp_set_remote_address(rtp_session, tx_host, tx_port, 0, SWITCH_TRUE, err) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_mutex_unlock(rtp_session->flag_mutex);
|
||||
rtp_session = NULL;
|
||||
goto end;
|
||||
|
|
Loading…
Reference in New Issue