]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7513: fix video switching in conference
authorAnthony Minessale <anthm@freeswitch.org>
Sat, 22 Nov 2014 20:42:22 +0000 (15:42 -0500)
committerMichael Jerris <mike@jerris.com>
Thu, 28 May 2015 17:46:48 +0000 (12:46 -0500)
src/include/switch_core.h
src/mod/applications/mod_conference/mod_conference.c
src/switch_core_media.c
src/switch_core_session.c

index 9492d412208d67ebdf9558a9e201ff470f5c4bc0..de3e5b3ce47ed0eba6bd8f3a0fdd58154084d08d 100644 (file)
@@ -2666,7 +2666,7 @@ SWITCH_DECLARE(int) switch_core_cert_gen_fingerprint(const char *prefix, dtls_fi
 SWITCH_DECLARE(int) switch_core_cert_expand_fingerprint(dtls_fingerprint_t *fp, const char *str);
 SWITCH_DECLARE(int) switch_core_cert_verify(dtls_fingerprint_t *fp);
 SWITCH_DECLARE(switch_status_t) switch_core_session_refresh_video(switch_core_session_t *session);
-
+SWITCH_DECLARE(switch_status_t) switch_core_session_refresh_video_both_ways(switch_core_session_t *session);
 SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait);
 SWITCH_DECLARE(int) switch_stream_system_fork(const char *cmd, switch_stream_handle_t *stream);
 SWITCH_DECLARE(int) switch_stream_system(const char *cmd, switch_stream_handle_t *stream);
index 26dcbe8e7337de1baa469d45610ad7d0959d57eb..a91c32b4359860b70cc97508608dc729279f90bc 100644 (file)
@@ -2260,12 +2260,12 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe
                                switch_channel_clear_flag(channel, CF_VIDEO_PASSIVE);
                        }
                        /* Tell the channel to request a fresh vid frame */
-                       switch_core_session_refresh_video(member->session);
+                       switch_core_session_refresh_video_both_ways(member->session);
 
                        if (conference->video_floor_holder) {
                                switch_mutex_lock(conference->mutex);
                                if (conference->video_floor_holder) {
-                                       switch_core_session_refresh_video(conference->video_floor_holder->session);
+                                       switch_core_session_refresh_video_both_ways(conference->video_floor_holder->session);
                                        // there's already someone hold the floor, tell the core thread start to read video
                                        switch_channel_clear_flag(member->channel, CF_VIDEO_PASSIVE);
                                }
@@ -2488,7 +2488,7 @@ static void conference_set_video_floor_holder(conference_obj_t *conference, conf
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Adding video floor %s\n",
                                                  switch_channel_get_name(member->channel));
                //switch_channel_set_flag(member->channel, CF_VIDEO_PASSIVE);
-               switch_core_session_refresh_video(member->session);
+               switch_core_session_refresh_video_both_ways(member->session);
                conference->video_floor_holder = member;
                member_update_status_field(member);
        } else {
@@ -2514,7 +2514,7 @@ static void conference_set_video_floor_holder(conference_obj_t *conference, conf
 
                switch_channel_set_flag(imember->channel, CF_VIDEO_BREAK);
                switch_core_session_kill_channel(imember->session, SWITCH_SIG_BREAK);
-               switch_core_session_refresh_video(imember->session);
+               switch_core_session_refresh_video_both_ways(imember->session);
        }
 
        switch_set_flag(conference, CFLAG_FLOOR_CHANGE);
@@ -2880,7 +2880,7 @@ static void *SWITCH_THREAD_FUNC conference_video_bridge_thread_run(switch_thread
                   switch_channel_ready(channel_a) && switch_channel_ready(channel_b))  {
 
                if (switch_channel_test_flag(channel_a, CF_VIDEO_REFRESH_REQ)) {
-                       switch_core_session_refresh_video(session_b);
+                       switch_core_session_refresh_video_both_ways(session_b);
                        switch_channel_clear_flag(channel_a, CF_VIDEO_REFRESH_REQ);
                }
 
@@ -3027,7 +3027,7 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr
                switch_mutex_unlock(conference->mutex);
 
                if (want_refresh && session) {
-                       switch_core_session_refresh_video(session);
+                       switch_core_session_refresh_video_both_ways(session);
                        want_refresh = 0;
                }
 
@@ -4335,7 +4335,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
 
                if (switch_channel_test_flag(channel, CF_VIDEO) && !switch_test_flag(member, MFLAG_ACK_VIDEO)) {
                        switch_set_flag_locked(member, MFLAG_ACK_VIDEO);
-                       switch_core_session_refresh_video(member->session);
+                       switch_core_session_refresh_video_both_ways(member->session);
                        conference_set_video_floor_holder(member->conference, member, SWITCH_FALSE);
                }
 
@@ -5203,7 +5203,7 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th
        switch_mutex_lock(conference->mutex);
        if (!conference->record_fh) conference->record_fh = &fh;
        if (conference->video_floor_holder) {
-               switch_core_session_refresh_video(conference->video_floor_holder->session);
+               switch_core_session_refresh_video_both_ways(conference->video_floor_holder->session);
        }
        switch_mutex_unlock(conference->mutex);
 
index 94d6eae804cfaa6fd2b06fdcee95d2127f11beea..f3bb24724e3615314f1ea6705453a57b8e7ea424 100644 (file)
@@ -644,9 +644,8 @@ SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_se
 
        switch_mutex_lock(smh->sdp_mutex);
 
-
        for (pmap = engine->payload_map; pmap && pmap->allocated; pmap = pmap->next) {
-               exists = (!strcasecmp(name, pmap->iananame) && (!pmap->rate || rate == pmap->rate) && (!pmap->ptime || pmap->ptime == ptime));
+               exists = (!strcasecmp(name, pmap->iananame) && pmap->pt == pt && (!pmap->rate || rate == pmap->rate) && (!pmap->ptime || pmap->ptime == ptime));
 
                if (exists) {
                        
@@ -4135,6 +4134,10 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
                                                vmatch = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1;
                                        }
 
+                                       //DFF hack out packetization mode 1 need infrastructure here
+                                       if (switch_stristr("packetization-mode=1", map->rm_fmtp)) {
+                                               vmatch = 0;
+                                       }
 
                                        if (vmatch && (map->rm_rate == imp->samples_per_second)) {
                                                matches[m_idx].imp = imp;
@@ -6984,9 +6987,9 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
                        switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_VIDEO, 0);
                }
 
-               if (switch_channel_test_flag(session->channel, CF_WEBRTC)) {
-                       switch_media_handle_set_media_flag(smh, SCMF_MULTI_ANSWER_VIDEO);
-               }
+               //if (switch_channel_test_flag(session->channel, CF_WEBRTC)) {
+               //      switch_media_handle_set_media_flag(smh, SCMF_MULTI_ANSWER_VIDEO);
+               //}
 
                if ((v_port = v_engine->adv_sdp_port)) {
                        int loops;
@@ -7017,7 +7020,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
                                        if (switch_media_handle_test_media_flag(smh, SCMF_MULTI_ANSWER_VIDEO)) {
                                                switch_mutex_lock(smh->sdp_mutex);
                                                for (pmap = v_engine->cur_payload_map; pmap && pmap->allocated; pmap = pmap->next) {
-                                                       if (pmap->pt != v_engine->cur_payload_map->pt) {
+                                                       if (pmap->pt != v_engine->cur_payload_map->pt && pmap->negotiated) {
                                                                switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", pmap->pt);
                                                        }
                                                }
@@ -9521,13 +9524,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_codec_control(switch_core_sess
                if (!switch_channel_test_flag(session->channel, CF_VIDEO)) {
                        return SWITCH_STATUS_FALSE;
                }
-               
-               if (cmd == SCC_VIDEO_REFRESH) {
-                       switch_core_session_message_t msg = { 0 };
-                       msg.from = __FILE__;
-                       msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ;
-                       switch_core_session_receive_message(session, &msg);
-               }
        }
 
        if (codec) {
index f39f8899bc2e14d5d611ed17111c0afb17abaa9a..0515a2e2050e49372136deb94b79dce4f77f336a 100644 (file)
@@ -3059,6 +3059,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_refresh_video(switch_core_se
                msg.from = __FILE__;
                msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ;
                switch_core_session_receive_message(session, &msg);
+               return SWITCH_STATUS_SUCCESS;
+       }
+
+       return SWITCH_STATUS_FALSE;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_refresh_video_both_ways(switch_core_session_t *session)
+{
+       if (switch_channel_test_flag(session->channel, CF_VIDEO)) {
+               switch_core_session_refresh_video(session);
                switch_core_media_gen_key_frame(session);
                return SWITCH_STATUS_SUCCESS;
        }
@@ -3066,6 +3076,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_refresh_video(switch_core_se
        return SWITCH_STATUS_FALSE;
 }
 
+
 SWITCH_DECLARE(void) switch_core_session_debug_pool(switch_stream_handle_t *stream)
 {
        stream->write_function(stream, "Thread pool: running:%d busy:%d popping:%d\n",