mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-17 09:12:25 +00:00
FS-6880 #resolve #comment I would think that in real life once the call agreed on a codec it would only offer the negotiated codecs but we can fix this to always filter for good measure. I am not sure what the ramifications are of filtering responses but I think this patch will do so as well.
This commit is contained in:
parent
8e408e9abe
commit
789e1481ed
@ -276,7 +276,7 @@ SWITCH_DECLARE(switch_rtp_crypto_key_type_t) switch_core_media_crypto_str2type(c
|
|||||||
SWITCH_DECLARE(const char *) switch_core_media_crypto_type2str(switch_rtp_crypto_key_type_t type);
|
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(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_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
|
SWITCH_END_EXTERN_C
|
||||||
#endif
|
#endif
|
||||||
/* For Emacs:
|
/* For Emacs:
|
||||||
|
@ -6348,6 +6348,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||||||
int is_dup_sdp = 0;
|
int is_dup_sdp = 0;
|
||||||
switch_event_t *s_event = NULL;
|
switch_event_t *s_event = NULL;
|
||||||
char *p;
|
char *p;
|
||||||
|
char *patched_sdp = NULL;
|
||||||
|
|
||||||
tl_gets(tags,
|
tl_gets(tags,
|
||||||
NUTAG_CALLSTATE_REF(ss_state),
|
NUTAG_CALLSTATE_REF(ss_state),
|
||||||
@ -6373,6 +6374,16 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||||||
tech_pvt->mparams.last_sdp_str = NULL;
|
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))) ||
|
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))) {
|
(sofia_test_flag(profile, TFLAG_INB_NOMEDIA) || sofia_test_flag(profile, TFLAG_PROXY_MEDIA))) {
|
||||||
|
|
||||||
@ -7319,6 +7330,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
|
switch_safe_free(patched_sdp);
|
||||||
|
|
||||||
if ((enum nua_callstate) ss_state == nua_callstate_ready && channel && session && tech_pvt) {
|
if ((enum nua_callstate) ss_state == nua_callstate_ready && channel && session && tech_pvt) {
|
||||||
sofia_set_flag(tech_pvt, TFLAG_SIMPLIFY);
|
sofia_set_flag(tech_pvt, TFLAG_SIMPLIFY);
|
||||||
|
@ -5222,57 +5222,21 @@ SWITCH_DECLARE(switch_status_t) switch_channel_unbind_device_state_handler(switc
|
|||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_channel_pass_sdp(switch_channel_t *from_channel, switch_channel_t *to_channel, const char *sdp)
|
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 *use_sdp = (char *) sdp;
|
||||||
char *patched_sdp = NULL;
|
char *patched_sdp = NULL;
|
||||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
|
||||||
|
|
||||||
if (!switch_channel_get_variable(to_channel, SWITCH_B_SDP_VARIABLE)) {
|
if (!switch_channel_get_variable(to_channel, SWITCH_B_SDP_VARIABLE)) {
|
||||||
const char *var;
|
const char *var;
|
||||||
|
|
||||||
if ((var = switch_channel_get_variable(from_channel, "bypass_media_sdp_filter"))) {
|
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);
|
if ((patched_sdp = switch_core_media_process_sdp_filter(use_sdp, var, from_channel->session))) {
|
||||||
|
use_sdp = patched_sdp;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
switch_safe_free(patched_sdp);
|
||||||
|
@ -9067,7 +9067,56 @@ SWITCH_DECLARE(char *) switch_core_media_filter_sdp(const char *sdp_str, const c
|
|||||||
return new_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:
|
/* For Emacs:
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user