}
+#define FILTER_CODECS_SYNTAX "<codec string>"
+SWITCH_STANDARD_APP(filter_codecs_function)
+{
+ const char *r_sdp;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+
+
+ r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
+
+ if (data && r_sdp) {
+ switch_core_media_merge_sdp_codec_string(session, r_sdp, SDP_TYPE_REQUEST, data);
+ switch_channel_set_variable(channel, "filter_codec_string", data);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Incomplete data\n");
+ }
+}
+
#define HEARTBEAT_SYNTAX "[0|<seconds>]"
SWITCH_STANDARD_APP(heartbeat_function)
SWITCH_ADD_APP(app_interface, "enable_heartbeat", "Enable Media Heartbeat", "Enable Media Heartbeat",
heartbeat_function, HEARTBEAT_SYNTAX, SAF_SUPPORT_NOMEDIA);
+ SWITCH_ADD_APP(app_interface, "filter_codecs", "Filter Codecs", "Filter Codecs", filter_codecs_function, FILTER_CODECS_SYNTAX, SAF_SUPPORT_NOMEDIA);
+
SWITCH_ADD_APP(app_interface, "enable_keepalive", "Enable Keepalive", "Enable Keepalive",
keepalive_function, KEEPALIVE_SYNTAX, SAF_SUPPORT_NOMEDIA);
}
-static void check_stream_changes(switch_core_session_t *session, switch_sdp_type_t sdp_type)
+static void check_stream_changes(switch_core_session_t *session, const char *r_sdp, switch_sdp_type_t sdp_type)
{
switch_core_session_t *other_session = NULL;
switch_core_session_message_t *msg;
if (other_session) {
switch_channel_set_flag(other_session->channel, CF_PROCESSING_STREAM_CHANGE);
switch_channel_set_flag(session->channel, CF_AWAITING_STREAM_CHANGE);
+
+ if (sdp_type == SDP_TYPE_REQUEST && r_sdp) {
+ const char *filter_codec_string = switch_channel_get_variable(session->channel, "filter_codec_string");
+
+ switch_core_media_merge_sdp_codec_string(session, r_sdp, sdp_type, filter_codec_string);
+ }
+ switch_core_session_check_outgoing_crypto(other_session);
+
msg = switch_core_session_alloc(other_session, sizeof(*msg));
msg->message_id = SWITCH_MESSAGE_INDICATE_MEDIA_RENEG;
msg->string_arg = switch_core_session_sprintf(other_session, "=%s", switch_channel_get_variable(session->channel, "ep_codec_string"));
if (other_session) {
if (sdp_type == SDP_TYPE_RESPONSE && switch_channel_test_flag(session->channel, CF_PROCESSING_STREAM_CHANGE)) {
+ switch_channel_clear_flag(session->channel, CF_PROCESSING_STREAM_CHANGE);
+
if (switch_channel_test_flag(other_session->channel, CF_AWAITING_STREAM_CHANGE)) {
+ uint8_t proceed = 1;
+ const char *sdp_in, *other_ep;
+
+ if ((other_ep = switch_channel_get_variable(session->channel, "ep_codec_string"))) {
+ switch_channel_set_variable(other_session->channel, "codec_string", other_ep);
+ }
+
+ sdp_in = switch_channel_get_variable(other_session->channel, SWITCH_R_SDP_VARIABLE);
+ switch_core_media_negotiate_sdp(other_session, sdp_in, &proceed, SDP_TYPE_REQUEST);
+ switch_core_media_activate_rtp(other_session);
msg = switch_core_session_alloc(other_session, sizeof(*msg));
msg->message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
msg->from = __FILE__;
-
+
+ switch_channel_set_flag(other_session->channel, CF_AWAITING_STREAM_CHANGE);
switch_core_session_queue_message(other_session, msg);
}
-
- switch_channel_clear_flag(session->channel, CF_PROCESSING_STREAM_CHANGE);
}
switch_core_session_rwunlock(other_session);
memset(near_matches, 0, sizeof(near_matches[0]) * MAX_MATCHES);
switch_channel_set_variable(session->channel, "video_possible", "true");
+ switch_channel_set_flag(session->channel, CF_VIDEO_POSSIBLE);
switch_channel_set_flag(session->channel, CF_VIDEO_SDP_RECVD);
connection = sdp->sdp_connection;
smh->mparams->cng_pt = cng_pt;
smh->mparams->cng_rate = cng_rate;
- check_stream_changes(session, sdp_type);
+ check_stream_changes(session, r_sdp, sdp_type);
return match || vmatch || tmatch || fmatch;
}
switch_core_media_set_local_sdp(session, buf, SWITCH_TRUE);
- check_stream_changes(session, sdp_type);
+ check_stream_changes(session, NULL, sdp_type);
switch_safe_free(buf);
}
//?
SWITCH_DECLARE(void) switch_core_media_set_sdp_codec_string(switch_core_session_t *session, const char *r_sdp, switch_sdp_type_t sdp_type)
{
+ switch_core_media_merge_sdp_codec_string(session, r_sdp, sdp_type, switch_core_media_get_codec_string(session));
+}
+
+SWITCH_DECLARE(void) switch_core_media_merge_sdp_codec_string(switch_core_session_t *session, const char *r_sdp,
+ switch_sdp_type_t sdp_type, const char *codec_string)
+{
+
+
+
sdp_parser_t *parser;
sdp_session_t *sdp;
switch_media_handle_t *smh;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Setting NULL SDP is invalid\n");
return;
}
+
+ if (zstr(codec_string)) {
+ codec_string = switch_core_media_get_codec_string(session);
+ }
+
if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
if ((sdp = sdp_session(parser))) {
- switch_core_media_set_r_sdp_codec_string(session, switch_core_media_get_codec_string(session), sdp, sdp_type);
+ switch_core_media_set_r_sdp_codec_string(session, codec_string, sdp, sdp_type);
}
sdp_parser_free(parser);