static switch_status_t mg_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
- mg_termination_t *term = switch_channel_get_private(channel, "_mg_term_");
+ mg_termination_t *term = switch_channel_get_private(channel, PVT_MG_TERM);
//char digit[2] = { dtmf->digit };
if (!term) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find termination structure for session [%s]\n",
}
if (zstr(term->uuid)) {
- switch_channel_t *channel;
+ switch_channel_t *channel;
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;
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));
- channel = switch_core_session_get_channel(session);
- switch_channel_set_private(channel, "_mg_term_", term);
- switch_core_event_hook_add_recv_dtmf(session, mg_on_dtmf);
+ channel = switch_core_session_get_channel(session);
+ switch_channel_set_private(channel, PVT_MG_TERM, term);
+ switch_core_event_hook_add_recv_dtmf(session, mg_on_dtmf);
+
+ switch_core_session_execute_application_async(session, "spandsp_start_fax_detect", "mg_notify cng 120 cng");
}
switch_set_flag(term, MGT_ACTIVE);
return mg_process_cli_cmd(cmd, stream);
}
+SWITCH_STANDARD_APP(mg_notify_function)
+{
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ mg_termination_t *term = switch_channel_get_private(channel, PVT_MG_TERM);
+
+ if (!term) {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "mg_notify called on a non-supported channel.\n");
+ return;
+ }
+
+ if (!strcmp(data, "cng")) {
+ mg_send_t38_cng_notify(term->profile, term->name);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sent CNG notify\n");
+ }
+}
+
static switch_status_t console_complete_hashtable(switch_hash_t *hash, const char *line, const char *cursor, switch_console_callback_match_t **matches)
{
switch_hash_index_t *hi;
SWITCH_MODULE_LOAD_FUNCTION(mod_media_gateway_load)
{
switch_api_interface_t *api_interface;
+ switch_application_interface_t *app_interface;
memset(&megaco_globals, 0, sizeof(megaco_globals));
megaco_globals.pool = pool;
switch_thread_rwlock_create(&megaco_globals.peer_profile_rwlock, pool);
SWITCH_ADD_API(api_interface, "mg", "media_gateway", megaco_function, MEGACO_FUNCTION_SYNTAX);
+ SWITCH_ADD_APP(app_interface, "mg_notify", "<type>", "sends a notify to the mgc", mg_notify_function, "", 0);
switch_console_set_complete("add mg profile ::mg::list_profiles start");
switch_console_set_complete("add mg profile ::mg::list_profiles stop");
va_end(ptr);
}
/*****************************************************************************************************************************/
-
-#if 0
-static switch_status_t mgco_parse_local_sdp(mg_termination_t *term, CmSdpInfoSet *sdp)
-{
- int i;
- CmSdpInfoSet *local_sdp;
- /* Parse the local SDP while copying the important bits over to our local structure,
- * while taking care of editing choose request and replacing them by real values */
-
- if (!term->u.rtp.local_sdp) {
- local_sdp = term->u.rtp.local_sdp = switch_core_alloc(term->context->pool, sizeof *term->u.rtp.local_sdp);
- }
-
- if (sdp->numComp.pres == NOTPRSNT) {
- return SWITCH_STATUS_FALSE;
- }
-
- for (i = 0; i < sdp->numComp.val; i++) {
- CmSdpInfo *s = sdp->info[i];
- int mediaId;
-
- local_sdp->info[i] = switch_core_alloc(term->context->pool, sizeof *(local_sdp->info[i]));
- *(local_sdp->info[i]) = *(sdp->info[i]);
-
- if (s->conn.addrType.pres && s->conn.addrType.val == CM_SDP_ADDR_TYPE_IPV4 &&
- s->conn.netType.type.val == CM_SDP_NET_TYPE_IN &&
- s->conn.u.ip4.addrType.val == CM_SDP_IPV4_IP_UNI) {
-
- if (s->conn.u.ip4.addrType.pres) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Local address: %d.%d.%d.%d\n",
- s->conn.u.ip4.u.uniIp.b[0].val,
- s->conn.u.ip4.u.uniIp.b[1].val,
- s->conn.u.ip4.u.uniIp.b[2].val,
- s->conn.u.ip4.u.uniIp.b[3].val);
-
- /* TODO: Double-check bind address for this profile */
-
- }
- if (s->attrSet.numComp.pres) {
- for (mediaId = 0; mediaId < s->attrSet.numComp.val; mediaId++) {
- CmSdpAttr *a = s->attrSet.attr[mediaId];
- local_sdp->info[i]->attrSet.attr[mediaId] = switch_core_alloc(term->context->pool, sizeof(CmSdpAttr));
- *(local_sdp->info[i]->attrSet.attr[mediaId]) = *a;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Media %p\n", (void*)a);
- }
- }
-
- if (s->mediaDescSet.numComp.pres) {
- for (mediaId = 0; mediaId < s->mediaDescSet.numComp.val; mediaId++) {
- CmSdpMediaDesc *desc = s->mediaDescSet.mediaDesc[mediaId];
- local_sdp->info[i]->mediaDescSet.mediaDesc[mediaId] = switch_core_alloc(term->context->pool, sizeof(CmSdpMediaDesc));
- *(local_sdp->info[i]->mediaDescSet.mediaDesc[mediaId]) = *desc;
-
- if (desc->field.mediaType.val == CM_SDP_MEDIA_AUDIO &&
- desc->field.id.type.val == CM_SDP_VCID_PORT &&
- desc->field.id.u.port.type.val == CM_SDP_PORT_INT &&
- desc->field.id.u.port.u.portInt.port.type.val == CM_SDP_SPEC) {
- int port = desc->field.id.u.port.u.portInt.port.val.val;
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Port: %d\n", port);
-
- }
- }
- }
- }
- }
-
- return SWITCH_STATUS_SUCCESS;
-}
-#endif
/* KAPIL- NOTE : We are using Command mode operation of MEGACO stack, so we will always get command indication instead of transaction */
/* Below API is not useful ... just leaving as it is...*/