]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7500 FS-7499 refactoring while battling chrome
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 27 May 2015 06:15:28 +0000 (01:15 -0500)
committerMichael Jerris <mike@jerris.com>
Thu, 28 May 2015 17:47:34 +0000 (12:47 -0500)
src/mod/applications/mod_conference/mod_conference.c
src/switch_channel.c
src/switch_core_media.c
src/switch_core_session.c
src/switch_rtp.c

index 866afae8bffd7bd810d5201c0f9afe68239e9c96..6608f951f4309f79f8f2b56f0af8686c9de33532 100644 (file)
@@ -2123,31 +2123,31 @@ static void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread
                                }
                        }
                                
-                       if (switch_test_flag(imember->conference, CFLAG_MANAGE_INBOUND_VIDEO_BITRATE) && !imember->managed_kps) {
-                               switch_core_session_message_t msg = { 0 };
-                               int kps;
+                       if (layer) {
+                               if (switch_test_flag(imember->conference, CFLAG_MANAGE_INBOUND_VIDEO_BITRATE) && !imember->managed_kps) {
+                                       switch_core_session_message_t msg = { 0 };
+                                       int kps;
                                
-                               //if (!layer || !switch_test_flag(imember, MFLAG_CAN_BE_SEEN) || imember->avatar_png_img) {
-                               //      kps = switch_calc_bitrate(320, 240, 2, imember->conference->video_fps.fps);
+                                       //if (!layer || !switch_test_flag(imember, MFLAG_CAN_BE_SEEN) || imember->avatar_png_img) {
+                                       //      kps = switch_calc_bitrate(320, 240, 2, imember->conference->video_fps.fps);
                                        
-                               //      switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "%s auto-setting bitrate to %dkps because user's image is not visible\n", 
-                               //                                        switch_channel_get_name(imember->channel), kps);
-                               //} else {
+                                       //      switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "%s auto-setting bitrate to %dkps because user's image is not visible\n", 
+                                       //                                        switch_channel_get_name(imember->channel), kps);
+                                       //} else {
                                        kps = switch_calc_bitrate(layer->screen_w, layer->screen_h, 2, imember->conference->video_fps.fps);
                                
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "%s auto-setting bitrate to %dkps to accomodate %dx%d resolution\n", 
                                                                          switch_channel_get_name(imember->channel), kps, layer->screen_w, layer->screen_h);
                                        //}
 
-                               msg.message_id = SWITCH_MESSAGE_INDICATE_BITRATE_REQ;
-                               msg.numeric_arg = kps * 1024;
-                               msg.from = __FILE__;
+                                       msg.message_id = SWITCH_MESSAGE_INDICATE_BITRATE_REQ;
+                                       msg.numeric_arg = kps * 1024;
+                                       msg.from = __FILE__;
                                
-                               switch_core_session_receive_message(imember->session, &msg);
-                               imember->managed_kps = kps;
-                       }
+                                       switch_core_session_receive_message(imember->session, &msg);
+                                       imember->managed_kps = kps;
+                               }
 
-                       if (layer) {
                                if (layer->cur_img && layer->cur_img != imember->avatar_png_img) {
                                        switch_img_free(&layer->cur_img);
                                }
@@ -4093,11 +4093,6 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe
        switch_assert(conference != NULL);
        switch_assert(member != NULL);
 
-       if (member->session && switch_test_flag(conference, CFLAG_TRANSCODE_VIDEO)) {
-               switch_channel_set_flag(member->channel, CF_VIDEO_DECODED_READ);
-               switch_core_media_gen_key_frame(member->session);
-       }
-
        switch_mutex_lock(conference->mutex);
        switch_mutex_lock(member->audio_in_mutex);
        switch_mutex_lock(member->audio_out_mutex);
@@ -12188,6 +12183,11 @@ SWITCH_STANDARD_APP(conference_function)
        msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
        switch_core_session_receive_message(session, &msg);
 
+       if (switch_test_flag(conference, CFLAG_TRANSCODE_VIDEO)) {
+               switch_channel_set_flag(channel, CF_VIDEO_DECODED_READ);
+               switch_core_media_gen_key_frame(session);
+       }
+       
        /* Chime in the core video thread */
        switch_core_session_set_video_read_callback(session, video_thread_callback, (void *)&member);
 
index 510d0d7a5144132611de9d5b1ba66c947090fe97..60f0ee680249eee3925ff9331de496b5a297c10d 100644 (file)
@@ -1852,13 +1852,12 @@ SWITCH_DECLARE(void) switch_channel_set_flag_value(switch_channel_t *channel, sw
                switch_channel_set_variable(channel, "recovered", "true");
        }
 
-       //if (flag == CF_VIDEO_ECHO) {
-       //      switch_core_session_start_video_thread(channel->session);
-       //}
+       if (flag == CF_VIDEO_ECHO || flag == CF_VIDEO_BLANK || flag == CF_VIDEO_DECODED_READ || flag == CF_VIDEO_PASSIVE) {
+               switch_core_session_start_video_thread(channel->session);
+       }
        
        if (flag == CF_VIDEO_DECODED_READ) {
                switch_core_session_request_video_refresh(channel->session);
-               //switch_core_session_start_video_thread(channel->session);
                if (!switch_core_session_in_video_thread(channel->session)) {
                        switch_channel_wait_for_flag(channel, CF_VIDEO_READY, SWITCH_TRUE, 10000, NULL);
                }
@@ -3442,10 +3441,6 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_
                switch_channel_api_on(channel, SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE);
                switch_channel_api_on(channel, SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE);
 
-               if (switch_channel_test_flag(channel, CF_VIDEO)) {
-                       switch_core_session_start_video_thread(channel->session);
-               }
-
                if (switch_true(switch_channel_get_variable(channel, SWITCH_PASSTHRU_PTIME_MISMATCH_VARIABLE))) {
                        switch_channel_set_flag(channel, CF_PASSTHRU_PTIME_MISMATCH);
                }
@@ -3747,9 +3742,6 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan
        if (!switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
                switch_channel_execute_on(channel, SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE);
                switch_channel_api_on(channel, SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE);
-               if (switch_channel_test_flag(channel, CF_VIDEO)) {
-                       switch_core_session_start_video_thread(channel->session);
-               }
        }
 
        switch_channel_api_on(channel, SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE);
index 5ab93513d2e3a275e594b699d18a31a743bdc035..7a469575d4801d610ad27b5a056e3a483ed9e683 100644 (file)
@@ -216,6 +216,7 @@ struct switch_media_handle_s {
 
 };
 
+static switch_bool_t check_dtls(switch_core_session_t *session);
 
 static switch_srtp_crypto_suite_t SUITES[CRYPTO_INVALID] = {
        { "AEAD_AES_256_GCM_8", AEAD_AES_256_GCM_8, 44},
@@ -3299,7 +3300,7 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_
                if (!smh->mparams->remote_ip) {
                        smh->mparams->remote_ip = engine->cur_payload_map->remote_sdp_ip;
                }
-
+               
                if (engine->remote_rtcp_port) {
                        engine->remote_rtcp_port = engine->cur_payload_map->remote_sdp_port;
                }
@@ -4757,9 +4758,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_file(switch_core_ses
 
        v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];      
 
-       if (!v_engine->media_thread) {
-               return SWITCH_STATUS_FALSE;
-       }
+       switch_core_session_start_video_thread(session);
+
+       //if (!v_engine->media_thread) {
+       //      return SWITCH_STATUS_FALSE;
+       //}
 
        switch_mutex_lock(v_engine->mh.file_mutex);
 
@@ -4776,9 +4779,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_file(switch_core_ses
                smh->video_write_fh = fh;
        }
 
+       if (!fh) switch_channel_video_sync(session->channel);
+       
+       switch_core_session_wake_video_thread(session);
        switch_mutex_unlock(v_engine->mh.file_mutex);
-
-       switch_core_session_start_video_thread(session);
        
        return SWITCH_STATUS_SUCCESS;
 }
@@ -4797,6 +4801,7 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi
        switch_image_t *blank_img = NULL;
        switch_rgb_color_t bgcolor;
        switch_rtp_engine_t *v_engine = NULL;
+       
        const char *var;
 
        if (!(smh = session->media_handle)) {
@@ -4832,13 +4837,13 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi
                int send_blank = 0;
 
                if (!switch_channel_test_flag(channel, CF_VIDEO)) {
-                       if ((++loops % 100) == 0) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Waiting for video......\n");
+                       if ((++loops % 100) == 0) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Waiting for video......\n");
                        switch_yield(20000);
                        continue;
                }
 
-               if (switch_core_session_media_flow(session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) {
-                       do_sleep = (++xloops > 20);
+               if (!smh->video_write_fh && !smh->video_read_fh && switch_core_session_media_flow(session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) {
+                       do_sleep = 1;
                } else {
                        xloops = 0;
                }
@@ -4887,9 +4892,9 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi
 
                if (v_engine->smode == SWITCH_MEDIA_FLOW_SENDONLY) {
                        switch_channel_set_flag(channel, CF_VIDEO_READY);
-               }
+               } else {
 
-               if (!smh->video_write_fh || !switch_channel_test_flag(channel, CF_VIDEO_READY)) {
+                       //if (!smh->video_write_fh || !switch_channel_test_flag(channel, CF_VIDEO_READY)) {
                        status = switch_core_session_read_video_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
 
                        if (!SWITCH_READ_ACCEPTABLE(status)) {
@@ -4897,14 +4902,16 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi
                                continue;
                        }
                        
-                       if (switch_test_flag(read_frame, SFF_CNG)) {
-                               continue;
-                       }
-               }
+                       //if (switch_test_flag(read_frame, SFF_CNG)) {
+                       //      continue;
+                       //}
+                       //}
+
+                       //if (vloops < 300 && (vloops % 100) == 0) {
+                       //                      switch_core_media_gen_key_frame(session);
+                       //switch_core_session_request_video_refresh(session);
+                       //}
 
-               if (vloops < 300 && (vloops % 100) == 0) {
-                       switch_core_media_gen_key_frame(session);
-                       switch_core_session_request_video_refresh(session);
                }
                
                vloops++;
@@ -4921,11 +4928,14 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi
 
                if (switch_channel_test_flag(channel, CF_VIDEO_READY)) {
                        switch_mutex_lock(mh->file_mutex);
-                       if (smh->video_write_fh && 
-                               switch_channel_ready(session->channel) && switch_test_flag(smh->video_write_fh, SWITCH_FILE_OPEN) && 
-                               switch_core_file_read_video(smh->video_write_fh, &fr, SVR_BLOCK) == SWITCH_STATUS_SUCCESS) {
-                               switch_core_session_write_video_frame(session, &fr, SWITCH_IO_FLAG_NONE, 0);
-                               switch_img_free(&fr.img);
+                       if (smh->video_write_fh && switch_channel_ready(session->channel) && switch_test_flag(smh->video_write_fh, SWITCH_FILE_OPEN)) {
+                               switch_status_t wstatus = switch_core_file_read_video(smh->video_write_fh, &fr, SVR_BLOCK|SVR_FLUSH);
+                               if (wstatus == SWITCH_STATUS_SUCCESS) {
+                                       switch_core_session_write_video_frame(session, &fr, SWITCH_IO_FLAG_NONE, 0);
+                                       switch_img_free(&fr.img);
+                               } else if (wstatus != SWITCH_STATUS_BREAK) {
+                                       smh->video_write_fh = NULL;
+                               }
                        } else if (smh->video_read_fh && switch_test_flag(smh->video_read_fh, SWITCH_FILE_OPEN) && read_frame->img) {
                                switch_core_file_write_video(smh->video_read_fh, read_frame);
                        } 
@@ -4933,11 +4943,11 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi
                } else if (switch_channel_test_flag(channel, CF_VIDEO_DECODED_READ)) {
                        send_blank = 1;
                }
-               
+
                if ((send_blank || switch_channel_test_flag(channel, CF_VIDEO_BLANK)) && 
                        !session->video_read_callback && !switch_channel_test_flag(session->channel, CF_BRIDGED)) {
                        fr.img = blank_img;
-                       switch_yield(100000);
+                       switch_yield(10000);
                        switch_core_session_write_video_frame(session, &fr, SWITCH_IO_FLAG_NONE, SWITCH_IO_FLAG_FORCE);
                } else if (read_frame && (switch_channel_test_flag(channel, CF_VIDEO_ECHO))) {
                        switch_core_session_write_video_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0);
@@ -4962,13 +4972,20 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_start_video_thread(switch_co
        switch_rtp_engine_t *v_engine = NULL;
        switch_media_handle_t *smh;
 
+       if (!switch_channel_test_flag(session->channel, CF_VIDEO)) {
+               return SWITCH_STATUS_NOTIMPL;
+       }
+
        if (!(smh = session->media_handle)) {
                return SWITCH_STATUS_FALSE;
        }
 
        v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
 
+       switch_mutex_lock(smh->control_mutex);
+
        if (v_engine->media_thread) {
+               switch_mutex_unlock(smh->control_mutex);
                return SWITCH_STATUS_FALSE;
        }
 
@@ -4989,6 +5006,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_start_video_thread(switch_co
        switch_mutex_init(&smh->write_mutex[SWITCH_MEDIA_TYPE_VIDEO], SWITCH_MUTEX_NESTED, pool);
        switch_thread_create(&v_engine->media_thread, thd_attr, video_helper_thread, &v_engine->mh, switch_core_session_get_pool(session));
 
+       switch_mutex_unlock(smh->control_mutex);
        return SWITCH_STATUS_SUCCESS;
 }
 
@@ -5000,6 +5018,8 @@ SWITCH_DECLARE(void) switch_core_media_start_video_function(switch_core_session_
                return;
        }
 
+       switch_core_session_start_video_thread(session);
+
        switch_mutex_lock(smh->control_mutex);
        if (!smh->video_function_running) {
                smh->video_function = video_function;
@@ -6315,8 +6335,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
                                }
                                
                                switch_rtp_set_payload_map(v_engine->rtp_session, &v_engine->payload_map);
-                               //switch_core_session_start_video_thread(session);
                                switch_channel_set_flag(session->channel, CF_VIDEO);
+                               switch_core_session_start_video_thread(session);
 
                                if ((ssrc = switch_channel_get_variable(session->channel, "rtp_use_video_ssrc"))) {
                                        uint32_t ssrc_ul = (uint32_t) strtoul(ssrc, NULL, 10);
@@ -6372,7 +6392,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
                                                                                          "Invalid rtcp interval spec [%d] must be between 100 and 500000\n", interval);
                                                        interval = 5000;
                                                }
-                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating VIDEO RTCP PORT %d interval %d mux %d\n", remote_port, interval, v_engine->rtcp_mux);
+                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO,
+                                                                                 "Activating VIDEO RTCP PORT %d interval %d mux %d\n", remote_port, interval, v_engine->rtcp_mux);
                                                switch_rtp_activate_rtcp(v_engine->rtp_session, interval, remote_port, v_engine->rtcp_mux > 0);
                                                        
                                        }
@@ -7322,7 +7343,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
        
 
                if (!zstr(a_engine->local_dtls_fingerprint.type)) {
-                       switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fingerprint:%s %s\na=setup:%s\na=mid:audio\n",
+                       switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fingerprint:%s %s\na=setup:%s\n",
                                                        a_engine->local_dtls_fingerprint.type, 
                                                        a_engine->local_dtls_fingerprint.str, get_setup(session));
                }
@@ -8523,7 +8544,7 @@ static int check_engine(switch_rtp_engine_t *engine)
        int flags = 0;
        switch_status_t status;
        
-       if (dtls_state == DS_OFF || dtls_state == DS_READY || dtls_state >= DS_FAIL) return 0;
+       if (dtls_state == DS_READY || dtls_state >= DS_FAIL) return 0;
 
        status = switch_rtp_zerocopy_read_frame(engine->rtp_session, &engine->read_frame, flags);
        
@@ -8534,7 +8555,7 @@ static int check_engine(switch_rtp_engine_t *engine)
        return 1;
 }
 
-static void check_dtls(switch_core_session_t *session)
+static switch_bool_t check_dtls(switch_core_session_t *session)
 {
        switch_media_handle_t *smh;
        switch_rtp_engine_t *a_engine, *v_engine;
@@ -8543,13 +8564,17 @@ static void check_dtls(switch_core_session_t *session)
        switch_assert(session);
 
        if (!(smh = session->media_handle)) {
-               return;
+               return SWITCH_FALSE;
        }
 
        if (switch_channel_down(session->channel)) {
-               return;
+               return SWITCH_FALSE;
        }
 
+       if (!switch_channel_test_flag(session->channel, CF_DTLS)) {
+               return SWITCH_TRUE;
+       }
+       
        a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
        v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
 
@@ -8557,6 +8582,12 @@ static void check_dtls(switch_core_session_t *session)
                if (a_engine->rtp_session) audio_checking = check_engine(a_engine);
                if (v_engine->rtp_session) check_engine(v_engine);
        } while (switch_channel_ready(session->channel) && (audio_checking || video_checking));
+
+       if (!audio_checking && !video_checking) {
+               return SWITCH_TRUE;
+       }
+       
+       return SWITCH_FALSE;
 }
 
 
@@ -8589,9 +8620,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se
                        }
                }
                break;
-
+               
        case SWITCH_MESSAGE_INDICATE_ANSWER:
        case SWITCH_MESSAGE_INDICATE_PROGRESS:
+       case SWITCH_MESSAGE_ANSWER_EVENT:
+       case SWITCH_MESSAGE_PROGRESS_EVENT:
                {
                        check_dtls(session);
                }
@@ -10447,14 +10480,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core
        switch_io_event_hook_video_read_frame_t *ptr;
        uint32_t loops = 0;
        switch_media_handle_t *smh;
-
+               
        switch_assert(session != NULL);
 
        if (!(smh = session->media_handle)) {
                return SWITCH_STATUS_FALSE;
        }
 
-
  top:
 
        loops++;
@@ -10630,6 +10662,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_read_callback(swit
                session->video_read_callback = func;
                session->video_read_user_data = user_data;
        }
+
+       switch_core_session_start_video_thread(session);
        switch_mutex_unlock(smh->control_mutex);
 
        return status;
index 065d27f638fb51b8d95a9b9db3cafc38b08a4084..5c6fb8ec06dc0f6587ce3e7162b336bfff407f60 100644 (file)
@@ -732,6 +732,7 @@ static const char *message_names[] = {
        "DISPLAY",
        "TRANSCODING_NECESSARY",
        "AUDIO_SYNC",
+       "VIDEO_SYNC",
        "REQUEST_IMAGE_MEDIA",
        "UUID_CHANGE",
        "SIMPLIFY",
index f526bf8e54957ef4655bb4863c9bc0024b8b814b..630d843911cab99387ab460509591bcb7afafd80 100644 (file)
@@ -500,24 +500,15 @@ static void switch_rtp_change_ice_dest(switch_rtp_t *rtp_session, switch_rtp_ice
        ice->ice_params->cands[ice->ice_params->chosen[ice->proto]][ice->proto].con_addr = switch_core_strdup(rtp_session->pool, host);
        ice->ice_params->cands[ice->ice_params->chosen[ice->proto]][ice->proto].con_port = port;
        ice->missed_count = 0;
-       
-       switch_sockaddr_info_get(&ice->addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool);
-       
-       if (!is_rtcp || rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
-               switch_rtp_set_remote_address(rtp_session, host, port, 0, SWITCH_FALSE, &err);
-       }
 
-       if (is_rtcp || rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
-               rtp_session->remote_rtcp_port = port;
-               rtp_session->eff_remote_host_str = switch_core_strdup(rtp_session->pool, host);
+       if (is_rtcp) {
+               ice->addr = rtp_session->rtcp_remote_addr;
+       } else {
+               switch_rtp_set_remote_address(rtp_session, host, port, 0, SWITCH_FALSE, &err);
 
                if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
-                       rtp_session->rtcp_remote_addr = rtp_session->remote_addr;
-               } else {
-                       switch_sockaddr_info_get(&rtp_session->rtcp_remote_addr, 
-                                                                        rtp_session->eff_remote_host_str, SWITCH_UNSPEC, rtp_session->remote_rtcp_port, 0, rtp_session->pool);
+                       ice->addr = rtp_session->remote_addr;
                }
-
        }
 
 }
@@ -1048,7 +1039,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
 
                                                        ice = icep[j];
                                                        ok = 1;
-
+                                                       
                                                        if (j != IPR_RTP) {
                                                                break;
                                                        }
@@ -1111,7 +1102,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
        }
 
 
-       //if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
+       //if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] || 1) {
        //      switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "WTF OK %s %d\n", rtp_type(rtp_session), ok);
        //}
        
@@ -1139,9 +1130,6 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
 
                        if (!ice->ready) {
                                ice->ready = 1;
-                               if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
-                                       switch_core_session_video_reinit(rtp_session->session);
-                               }
                        }
 
                        memset(stunbuf, 0, sizeof(stunbuf));
@@ -1172,10 +1160,10 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
                        }
 
                        if (hosts_set) {
-                               switch_sockaddr_info_get(&ice->addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool);
+                               //switch_sockaddr_info_get(&ice->addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool);
                                 
                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_NOTICE,
-                                                                 "Auto Changing stun/%s/dtls port from %s:%u to %s:%u\n", is_rtcp ? "rtcp" : "rtp", 
+                                                                 "Auto Changing %s stun/%s/dtls port from %s:%u to %s:%u\n", rtp_type(rtp_session), is_rtcp ? "rtcp" : "rtp", 
                                                                  host2, port2,
                                                                  host, port);
 
@@ -1215,7 +1203,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
                                }
 
                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_NOTICE,
-                                                                 "Auto Changing stun/%s/dtls port from %s:%u to %s:%u\n", is_rtcp ? "rtcp" : "rtp", 
+                                                                 "Auto Changing %s stun/%s/dtls port from %s:%u to %s:%u\n", rtp_type(rtp_session), is_rtcp ? "rtcp" : "rtp", 
                                                                  host2, port2,
                                                                  host, port);
 
@@ -2210,7 +2198,7 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session)
                        old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->rtcp_remote_addr);
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_CRIT, "%s SEND %s RTCP %s:%d %ld\n", 
                                                          rtp_session_name(rtp_session),
-                                                         rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] ? "video" : "audio", 
+                                                         rtp_type(rtp_session),
                                                          old_host,
                                                          switch_sockaddr_get_port(rtp_session->rtcp_remote_addr),
                                                          rtcp_bytes);
@@ -4143,7 +4131,6 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_sessio
                ice = &rtp_session->ice;                
                rtp_session->flags[SWITCH_RTP_FLAG_PAUSE] = 0;
                rtp_session->flags[SWITCH_RTP_FLAG_MUTE] = 0;
-               switch_core_session_video_reinit(rtp_session->session);
        } else {
                ice = &rtp_session->rtcp_ice;
        }