]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7753 #resolve
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 1 Jul 2015 19:39:09 +0000 (14:39 -0500)
committerBrian West <brian@freeswitch.org>
Wed, 1 Jul 2015 19:39:30 +0000 (14:39 -0500)
src/mod/formats/mod_local_stream/mod_local_stream.c
src/switch_ivr_bridge.c

index 686f41f6cb272ca43dd6c87102a994a494285f36..0eebaadf481ebeb979854861b4b4acdbe36527ff 100644 (file)
@@ -69,6 +69,7 @@ struct local_stream_context {
        int last_w;
        int last_h;
        int serno;
+       int pop_count;
        switch_image_t *banner_img;
        switch_time_t banner_timeout;
        struct local_stream_context *next;
@@ -814,6 +815,13 @@ static switch_status_t local_stream_file_read_video(switch_file_handle_t *handle
 
  got_img:
 
+       if (context->pop_count > 0) {
+               switch_rgb_color_t bgcolor = { 0 };
+               switch_color_set_rgb(&bgcolor, "#000000");
+               switch_img_fill(frame->img, 0, 0, frame->img->d_w, frame->img->d_h, &bgcolor);
+               context->pop_count--;
+       }
+       
        now = switch_micro_time_now();
 
        if (context->banner_img) {
@@ -826,6 +834,7 @@ static switch_status_t local_stream_file_read_video(switch_file_handle_t *handle
                switch_img_free(&context->banner_img);
                context->banner_timeout = 0;
                context->serno = context->source->serno;
+               context->pop_count = 5;
        }
        
        if (context->source->banner_txt) {
index 5d9bf0be43d0e62e5522308e5e6ddd803b0ccb92..82db7a8297b779aeb0dc17836a256379e531f76f 100644 (file)
@@ -56,7 +56,11 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
        int set_decoded_read = 0, refresh_timer = 0, playing_file = 0;
        switch_frame_t fr = { 0 };
        unsigned char *buf = NULL;
-
+       int send_blank = 0;
+       int refresh_cnt = 300;
+       int blank_cnt = 30;
+       switch_image_t *blank_img = NULL;
+       
        vh->up = 1;
 
        switch_core_session_read_lock(vh->session_a);
@@ -65,7 +69,7 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
        switch_core_session_request_video_refresh(vh->session_a);
        switch_core_session_request_video_refresh(vh->session_b);
 
-       refresh_timer = 5;
+       refresh_timer = refresh_cnt;
 
        while (switch_channel_up_nosig(channel) && switch_channel_up_nosig(b_channel) && vh->up == 1) {
                if (switch_channel_media_up(channel)) {
@@ -81,7 +85,7 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
                                        if (set_decoded_read) {
                                                switch_channel_clear_flag_recursive(channel, CF_VIDEO_DECODED_READ);
                                                set_decoded_read = 0;
-                                               refresh_timer = 5;
+                                               refresh_timer = refresh_cnt;
                                        }
                                }
                        } else {
@@ -89,30 +93,60 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
                                        switch_channel_test_flag(b_channel, CF_VIDEO_DECODED_READ)) {
                                        switch_channel_set_flag_recursive(channel, CF_VIDEO_DECODED_READ);
                                        set_decoded_read = 1;
-                                       refresh_timer = 5;
+                                       refresh_timer = refresh_cnt;
                                }
                        }
-                       
 
+                       if (refresh_timer) {
+                               if (refresh_timer > 0 && (refresh_timer % 100) == 0) {
+                                       switch_core_session_request_video_refresh(vh->session_a);
+                                       switch_core_session_request_video_refresh(vh->session_b);
+                                       switch_core_media_gen_key_frame(vh->session_a);
+                                       switch_core_media_gen_key_frame(vh->session_b);
+                               }
+                               refresh_timer--;
+                       }
+
+                       if (send_blank) {
+                               send_blank--;
+                               fr.img = blank_img;
+                               switch_core_media_gen_key_frame(session);
+                               switch_core_session_write_video_frame(session, &fr, SWITCH_IO_FLAG_NONE, 0);
+                               switch_yield(30000);
+                               continue;
+                       }
+                       
                        if ((fh = switch_core_media_get_video_file(session, SWITCH_RW_WRITE)) && switch_test_flag(fh, SWITCH_FILE_OPEN)) {
                                switch_status_t wstatus;
                                
-                               if (!playing_file) {
-                                       playing_file = 1;
-                               }
-
                                if (!buf) {
-                                       int buflen = SWITCH_RTP_MAX_BUF_LEN;
-
+                                       int buflen = SWITCH_RTP_MAX_BUF_LEN;                                            
                                        buf = switch_core_session_alloc(session, buflen);
                                        fr.packet = buf;
                                        fr.packetlen = buflen;
                                        fr.data = buf + 12;
                                        fr.buflen = buflen - 12;
-                                       switch_core_media_gen_key_frame(session);
                                }
+                               
+                               wstatus = switch_core_file_read_video(fh, &fr, SVR_FLUSH | SVR_BLOCK);
 
-                               wstatus = switch_core_file_read_video(fh, &fr, SVR_BLOCK);
+                               
+                               if (!blank_img && fr.img) {
+                                       switch_rgb_color_t bgcolor = { 0 };
+                                       blank_img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, fr.img->d_w, fr.img->d_h, 1);
+                                       switch_color_set_rgb(&bgcolor, "#000000");
+                                       switch_img_fill(blank_img, 0, 0, blank_img->d_w, blank_img->d_h, &bgcolor);
+                               }
+                               
+                               if (!playing_file) {
+                                       playing_file = 1;
+                                       switch_core_media_gen_key_frame(session);
+                                       send_blank = blank_cnt;
+                                       refresh_timer = refresh_cnt;
+                                       switch_channel_video_sync(channel);
+                                       switch_channel_video_sync(b_channel);
+                                       continue;
+                               }
                                
                                if (wstatus == SWITCH_STATUS_SUCCESS) {
                                        switch_core_session_write_video_frame(session, &fr, SWITCH_IO_FLAG_NONE, 0);
@@ -124,23 +158,15 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
                                continue;
                        }
                        
-
+                       
                        if (playing_file) {
                                playing_file = 0;
-                               switch_core_session_request_video_refresh(vh->session_a);
-                               switch_core_session_request_video_refresh(vh->session_b);
+                               send_blank = blank_cnt;
+                               refresh_timer = refresh_cnt;
                                switch_channel_video_sync(channel);
-                               refresh_timer = 5;
+                               switch_channel_video_sync(b_channel);
                        }
 
-                       if (refresh_timer) {
-                               if (--refresh_timer == 0) {
-                                       switch_core_session_request_video_refresh(vh->session_a);
-                                       switch_core_session_request_video_refresh(vh->session_b);
-                               }
-                       }
-               
-
                        status = switch_core_session_read_video_frame(vh->session_a, &read_frame, SWITCH_IO_FLAG_NONE, 0);
 
                        if (!SWITCH_READ_ACCEPTABLE(status)) {
@@ -150,14 +176,18 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
 
 
                        if (switch_test_flag(read_frame, SFF_CNG)) {
+                               switch_core_session_request_video_refresh(vh->session_a);
                                continue;
                        }
                }
-
+               
                if (switch_channel_test_flag(channel, CF_LEG_HOLDING) || switch_channel_test_flag(b_channel, CF_VIDEO_READ_FILE_ATTACHED)) {
+                       switch_channel_video_sync(channel);
+                       switch_core_session_write_video_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0);
                        continue;
                }
 
+               
                if (switch_channel_media_up(b_channel)) {
                        if (switch_core_session_write_video_frame(vh->session_b, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
                                switch_cond_next();
@@ -166,6 +196,8 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
                }
        }
 
+       switch_img_free(&blank_img);
+       
        if (set_decoded_read) {
                switch_channel_clear_flag_recursive(channel, CF_VIDEO_DECODED_READ);
        }