]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
clean up proxy media mode
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 27 Feb 2013 20:16:00 +0000 (14:16 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 1 Apr 2013 02:27:27 +0000 (21:27 -0500)
src/include/switch_core_media.h
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c
src/switch_core_media.c
src/switch_rtp.c

index ac47236f9dde9b03fd259b8bf32f9ea756a4a1e4..95485e9c1a68eaa9d2668a582139512ce5985280 100644 (file)
@@ -243,7 +243,7 @@ SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_get_stats(switch_core_ses
 
 SWITCH_DECLARE(void) switch_core_media_set_sdp_codec_string(switch_core_session_t *session, const char *r_sdp);
 SWITCH_DECLARE(void) switch_core_media_reset_autofix_timing(switch_core_session_t *session, switch_media_type_t type);
-SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_t *session);
+SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_t *session, switch_core_session_t *o_session);
 SWITCH_DECLARE(switch_status_t) switch_core_media_codec_chosen(switch_core_session_t *session, switch_media_type_t media);
 SWITCH_DECLARE (void) switch_core_media_recover_session(switch_core_session_t *session);
 SWITCH_DECLARE(switch_status_t) switch_core_media_add_ice_acl(switch_core_session_t *session, switch_media_type_t type, const char *acl_name);
index c088e7a940e8e733f9bd477d18e1705adc071a9b..401704241056d6917d2541fc8f7a8d72ed415322 100644 (file)
@@ -4320,7 +4320,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
                        }
                }
 
-               switch_core_media_check_outgoing_proxy(session);
+               switch_core_media_check_outgoing_proxy(nsession, session);
 
        }
 
index 24f91ad51cb35c0c8f7205a08cd4af135a1f23f5..435ad2d0ec0dad5c9690ce7a6528380d9c6b3484 100644 (file)
@@ -6266,7 +6266,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                        }
                break;
        case nua_callstate_ready:
-               if (r_sdp && !is_dup_sdp && switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO) && !sofia_test_flag(tech_pvt, TFLAG_NOSDP_REINVITE)) {
+               if (!switch_channel_test_flag(channel, CF_PROXY_MODE) && !switch_channel_test_flag(channel, CF_PROXY_MEDIA) && 
+                       r_sdp && !is_dup_sdp && switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO) && !sofia_test_flag(tech_pvt, TFLAG_NOSDP_REINVITE)) {
                        /* sdp changed since 18X w sdp, we're supposed to ignore it but we, of course, were pressured into supporting it */
                        uint8_t match = 0;
 
index fc21c395b47e244b37e93288a6a932ebdadc707b..a69628d7ab0186c4786648e8c7bead152b37e2a5 100644 (file)
@@ -4993,6 +4993,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
 
 
                rate = a_engine->codec_params.rm_rate;
+
                if (a_engine->codec_params.adv_channels > 1) {
                        switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%d/%d\n", 
                                                        a_engine->codec_params.agreed_pt, a_engine->codec_params.rm_encoding, rate, a_engine->codec_params.adv_channels);
@@ -5726,7 +5727,7 @@ SWITCH_DECLARE(void) switch_core_media_patch_sdp(switch_core_session_t *session)
                return;
        }
 
-       if (zstr(a_engine->codec_params.local_sdp_ip) || !a_engine->codec_params.local_sdp_port) {
+       if (zstr(a_engine->codec_params.local_sdp_ip) || !a_engine->codec_params.local_sdp_port || switch_channel_test_flag(session->channel, CF_PROXY_MEDIA)) {
                if (switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_AUDIO, 1) != SWITCH_STATUS_SUCCESS) {
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s I/O Error\n",
                                                          switch_channel_get_name(session->channel));
@@ -6919,37 +6920,42 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_codec_chosen(switch_core_sessi
 
 
 //?
-SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_t *session)
+SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_t *session, switch_core_session_t *o_session)
 {
        switch_rtp_engine_t *a_engine, *v_engine;
        switch_media_handle_t *smh;
+       const char *r_sdp = NULL;
 
        switch_assert(session);
 
+       if (!switch_channel_test_flag(o_session->channel, CF_PROXY_MEDIA)) {
+               return;
+       }
+
        if (!(smh = session->media_handle)) {
                return;
        }
+
+       r_sdp = switch_channel_get_variable(o_session->channel, SWITCH_R_SDP_VARIABLE);
        
        a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
        v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
 
+       switch_channel_set_flag(session->channel, CF_PROXY_MEDIA);
+       
        a_engine->codec_params.iananame = switch_core_session_strdup(session, "PROXY");
        a_engine->codec_params.rm_rate = 8000;
+
        a_engine->codec_params.codec_ms = 20;
        
-       if (switch_channel_test_flag(session->channel, CF_PROXY_MEDIA)) {
-               const char *r_sdp = switch_channel_get_variable(session->channel, SWITCH_R_SDP_VARIABLE);
-               
-               if (switch_stristr("m=video", r_sdp)) {
-                       switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_VIDEO, 1);
-                       v_engine->codec_params.rm_encoding = "PROXY-VID";
-                       v_engine->codec_params.rm_rate = 90000;
-                       v_engine->codec_params.codec_ms = 0;
-                       switch_channel_set_flag(session->channel, CF_VIDEO);
-                       switch_channel_set_flag(session->channel, CF_VIDEO_POSSIBLE);
-               }
+       if (switch_stristr("m=video", r_sdp)) {
+               switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_VIDEO, 1);
+               v_engine->codec_params.rm_encoding = "PROXY-VID";
+               v_engine->codec_params.rm_rate = 90000;
+               v_engine->codec_params.codec_ms = 0;
+               switch_channel_set_flag(session->channel, CF_VIDEO);
+               switch_channel_set_flag(session->channel, CF_VIDEO_POSSIBLE);
        }
-
 }
 
 //?
index 8968a3a141ec23ea838154d17b9dbb025dbce9bc..2636c3da7e9dd590f308de8963da3fe5d88eb29f 100644 (file)
@@ -2462,7 +2462,11 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
        }
 
        if (switch_event_create(&fsevent, SWITCH_EVENT_CALL_SECURE) == SWITCH_STATUS_SUCCESS) {
-               switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, "secure_type", "srtp:%s", switch_channel_get_variable(channel, "sip_has_crypto"));
+               if (rtp_session->dtls) {
+                       switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, "secure_type", "srtp:dtls:AES_CM_128_HMAC_SHA1_80");
+               } else {
+                       switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, "secure_type", "srtp:%s", switch_channel_get_variable(channel, "sip_has_crypto"));
+               }
                switch_event_add_header_string(fsevent, SWITCH_STACK_BOTTOM, "caller-unique-id", switch_channel_get_uuid(channel));
                switch_event_fire(&fsevent);
        }