SWITCH_DECLARE(const char *) switch_core_media_crypto_type2str(switch_rtp_crypto_key_type_t type);
SWITCH_DECLARE(int) switch_core_media_crypto_keylen(switch_rtp_crypto_key_type_t type);
SWITCH_DECLARE(char *) switch_core_media_filter_sdp(const char *sdp, const char *cmd, const char *arg);
-
+SWITCH_DECLARE(char *) switch_core_media_process_sdp_filter(const char *sdp, const char *cmd_buf, switch_core_session_t *session);
SWITCH_END_EXTERN_C
#endif
/* For Emacs:
int is_dup_sdp = 0;
switch_event_t *s_event = NULL;
char *p;
+ char *patched_sdp = NULL;
tl_gets(tags,
NUTAG_CALLSTATE_REF(ss_state),
tech_pvt->mparams.last_sdp_str = NULL;
}
+ if (r_sdp && (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA))) {
+ const char *var;
+
+ if ((var = switch_channel_get_variable(channel, "bypass_media_sdp_filter"))) {
+ if ((patched_sdp = switch_core_media_process_sdp_filter(r_sdp, var, session))) {
+ r_sdp = patched_sdp;
+ }
+ }
+ }
+
if ((channel && (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA))) ||
(sofia_test_flag(profile, TFLAG_INB_NOMEDIA) || sofia_test_flag(profile, TFLAG_PROXY_MEDIA))) {
done:
+ switch_safe_free(patched_sdp);
if ((enum nua_callstate) ss_state == nua_callstate_ready && channel && session && tech_pvt) {
sofia_set_flag(tech_pvt, TFLAG_SIMPLIFY);
SWITCH_DECLARE(switch_status_t) switch_channel_pass_sdp(switch_channel_t *from_channel, switch_channel_t *to_channel, const char *sdp)
{
+ switch_status_t status = SWITCH_STATUS_FALSE;
char *use_sdp = (char *) sdp;
char *patched_sdp = NULL;
- switch_status_t status = SWITCH_STATUS_FALSE;
if (!switch_channel_get_variable(to_channel, SWITCH_B_SDP_VARIABLE)) {
const char *var;
if ((var = switch_channel_get_variable(from_channel, "bypass_media_sdp_filter"))) {
- char *cmd = switch_core_session_strdup(from_channel->session, var);
- int argc = 0;
- char *argv[50];
- int x = 0;
-
- argc = switch_split(cmd, '|', argv);
-
- for (x = 0; x < argc; x++) {
- char *command = argv[x];
- char *arg = strchr(command, '(');
-
- if (arg) {
- char *e = switch_find_end_paren(arg, '(', ')');
- *arg++ = '\0';
- if (e) *e = '\0';
- }
-
- if (zstr(command) || zstr(arg)) {
- switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(from_channel), SWITCH_LOG_WARNING, "%s SDP FILTER PARSE ERROR\n", from_channel->name);
- } else {
- char *tmp_sdp = NULL;
-
- if (patched_sdp) {
- tmp_sdp = switch_core_media_filter_sdp(patched_sdp, command, arg);
- } else {
- tmp_sdp = switch_core_media_filter_sdp(use_sdp, command, arg);
- }
-
-
- switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(from_channel), SWITCH_LOG_DEBUG,
- "Filter command %s(%s)\nFROM:\n==========\n%s\nTO:\n==========\n%s\n\n",
- command, arg, patched_sdp ? patched_sdp : use_sdp, tmp_sdp);
-
- if (tmp_sdp) {
- switch_safe_free(patched_sdp);
- patched_sdp = use_sdp = tmp_sdp;
- }
- }
+ if ((patched_sdp = switch_core_media_process_sdp_filter(use_sdp, var, from_channel->session))) {
+ use_sdp = patched_sdp;
}
- }
- switch_channel_set_variable(to_channel, SWITCH_B_SDP_VARIABLE, use_sdp);
+ switch_channel_set_variable(to_channel, SWITCH_B_SDP_VARIABLE, use_sdp);
+ }
}
switch_safe_free(patched_sdp);
return new_sdp;
}
+SWITCH_DECLARE(char *) switch_core_media_process_sdp_filter(const char *sdp, const char *cmd_buf, switch_core_session_t *session)
+{
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ char *cmd = switch_core_session_strdup(session, cmd_buf);
+ int argc = 0;
+ char *argv[50];
+ int x = 0;
+ char *use_sdp = (char *) sdp;
+ char *patched_sdp = NULL;
+
+ argc = switch_split(cmd, '|', argv);
+
+ for (x = 0; x < argc; x++) {
+ char *command = argv[x];
+ char *arg = strchr(command, '(');
+
+ if (arg) {
+ char *e = switch_find_end_paren(arg, '(', ')');
+ *arg++ = '\0';
+ if (e) *e = '\0';
+ }
+
+ if (zstr(command) || zstr(arg)) {
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_WARNING, "%s SDP FILTER PARSE ERROR\n", switch_channel_get_name(channel));
+ } else {
+ char *tmp_sdp = NULL;
+
+ if (patched_sdp) {
+ tmp_sdp = switch_core_media_filter_sdp(patched_sdp, command, arg);
+ } else {
+ tmp_sdp = switch_core_media_filter_sdp(use_sdp, command, arg);
+ }
+
+
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG,
+ "%s Filter command %s(%s)\nFROM:\n==========\n%s\nTO:\n==========\n%s\n\n",
+ switch_channel_get_name(channel),
+ command, arg, patched_sdp ? patched_sdp : use_sdp, tmp_sdp);
+
+
+ if (tmp_sdp) {
+ switch_safe_free(patched_sdp);
+ patched_sdp = use_sdp = tmp_sdp;
+ }
+ }
+ }
+ return patched_sdp;
+
+}
/* For Emacs:
* Local Variables: