Media Management (Sponsored By Front Logic)

This modification makes it possible to change the media path of session in the switch on-the-fly and from the dialplan.
It adds some API interface calls usable from a remote client such as mod_event_socket or the test console.

1) media [off] <uuid>

   Turns on/off the media on the call described by <uuid>
   The media will be redirected as desiered either into the switch or point to point.

2) hold [off] <uuid>

   Turns on/off endpoint specific hold state on the session described by <uuid>

3) broadcast <uuid> "<path>[ <timer_name>]" or "speak:<tts_engine>|<tts_voice>|<text>[|<timer_name>]" [both]

   A message will be sent to the call described by uuid instructing it to play the file or speak the text indicated.

   If the 'both' option is specified both ends of the call will hear the message otherwise just the uuid specified
   will hear the message.

   During playback when only one side is hearing the message the other end will hear silence.

   If media is not flowing across the switch when the message is broadcasted, the media will be directed to the
   switch for the duration of the call and then returned to it's previous state.


Also the no_media=true option in the dialplan before a bridge makes it possible to place a call while proxying the session
description from one endpoint to the other and establishing an immidiate point-to-point media connection with no media
on the switch.

<action application="set" data="no_media=true"/>
<action application="bridge" data="sofia/mydomain.com/myid@myhost.com"/>


*NOTE* when connecting two outbound legs by using the "originate" api command with an extension that has no_media=true enabled,
the media for the first leg will be engaged with the switch until the second leg has answered and the other session description
is available to establish a point to point connection at which time point-to-point mode will be enabled.

*NOTE* it is reccommended you rebuild FreeSWITCH with "make sure" as there have been some changes to the core.



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3245 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2006-10-31 21:38:06 +00:00
parent 1e4ad3c5ae
commit 9ab2b1db57
11 changed files with 815 additions and 106 deletions

View File

@@ -44,6 +44,9 @@ static switch_api_interface_t load_api_interface;
static switch_api_interface_t reload_api_interface;
static switch_api_interface_t kill_api_interface;
static switch_api_interface_t originate_api_interface;
static switch_api_interface_t media_api_interface;
static switch_api_interface_t hold_api_interface;
static switch_api_interface_t broadcast_api_interface;
static switch_status_t status_function(char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
{
@@ -235,6 +238,97 @@ static switch_status_t transfer_function(char *cmd, switch_core_session_t *isess
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t uuid_media_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{
char *argv[4] = {0};
int argc = 0;
switch_status_t status = SWITCH_STATUS_FALSE;
if (isession) {
return status;
}
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
if (argc < 1) {
stream->write_function(stream, "USAGE: %s\n", media_api_interface.syntax);
} else {
if (!strcmp(argv[0], "off")) {
status = switch_ivr_nomedia(argv[1], SMF_REBRIDGE);
} else {
status = switch_ivr_media(argv[0], SMF_REBRIDGE);
}
}
if (status == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "+OK Success\n");
} else {
stream->write_function(stream, "-ERR Operation Failed\n");
}
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t uuid_broadcast_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{
char *argv[4] = {0};
int argc = 0;
switch_status_t status = SWITCH_STATUS_FALSE;
if (isession) {
return status;
}
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
if (argc < 2) {
stream->write_function(stream, "USAGE: %s\n", broadcast_api_interface.syntax);
} else {
switch_media_flag_t flags = SMF_NONE;
if (argv[2] && !strcmp(argv[2], "both")) {
flags |= SMF_ECHO_BRIDGED;
}
status = switch_ivr_broadcast(argv[0], argv[1], flags);
stream->write_function(stream, "+OK Message Sent\n");
}
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t uuid_hold_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{
char *argv[4] = {0};
int argc = 0;
switch_status_t status = SWITCH_STATUS_FALSE;
if (isession) {
return status;
}
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
if (argc < 1) {
stream->write_function(stream, "USAGE: %s\n", hold_api_interface.syntax);
} else {
if (!strcmp(argv[0], "off")) {
status = switch_ivr_unhold_uuid(argv[1]);
} else {
status = switch_ivr_hold_uuid(argv[0]);
}
}
if (status == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "+OK Success\n");
} else {
stream->write_function(stream, "-ERR Operation Failed\n");
}
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t uuid_bridge_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{
char *argv[4] = {0};
@@ -535,12 +629,36 @@ static switch_api_interface_t ctl_api_interface = {
/*.next */ &help_api_interface
};
static switch_api_interface_t media_api_interface = {
/*.interface_name */ "media",
/*.desc */ "media",
/*.function */ uuid_media_function,
/*.syntax */ "<uuid>",
/*.next */ &ctl_api_interface
};
static switch_api_interface_t hold_api_interface = {
/*.interface_name */ "hold",
/*.desc */ "hold",
/*.function */ uuid_hold_function,
/*.syntax */ "<uuid>",
/*.next */ &media_api_interface
};
static switch_api_interface_t broadcast_api_interface = {
/*.interface_name */ "broadcast",
/*.desc */ "broadcast",
/*.function */ uuid_broadcast_function,
/*.syntax */ "<uuid> <path> [both]",
/*.next */ &hold_api_interface
};
static switch_api_interface_t uuid_bridge_api_interface = {
/*.interface_name */ "uuid_bridge",
/*.desc */ "uuid_bridge",
/*.function */ uuid_bridge_function,
/*.syntax */ "<uuid> <other_uuid>",
/*.next */ &ctl_api_interface
/*.next */ &broadcast_api_interface
};
static switch_api_interface_t status_api_interface = {