]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10454: [mod_av] Regression in video file seek #resolve
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 30 Jun 2017 16:28:49 +0000 (11:28 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 30 Jun 2017 16:28:49 +0000 (11:28 -0500)
src/mod/applications/mod_av/avformat.c

index e598e756f41c9321429c3c04cd58415ae56d8f14..4b84aea4504e82896f9c09568709727d25fc6d9e 100644 (file)
@@ -1570,9 +1570,18 @@ static void *SWITCH_THREAD_FUNC file_read_thread_run(switch_thread_t *thread, vo
                        context->seek_ts = -2;
 
                        if (context->has_video) {
+                               void *pop;
+                               
                                context->video_st.next_pts = 0;
                                context->video_start_time = 0;
                                avcodec_flush_buffers(context->video_st.st->codec);
+                               
+                               while(switch_queue_trypop(context->eh.video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+                                       switch_image_t *img;
+                                       if (!pop) break;
+                                       img = (switch_image_t *) pop;
+                                       switch_img_free(&img);
+                               }
                        }
                }
 
@@ -2427,7 +2436,7 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
                return SWITCH_STATUS_FALSE;
        }
 
-       if (context->read_paused) {
+       if (context->read_paused || context->seek_ts == -2) {
                int sanity = 10;
 
                if (context->seek_ts == -2) { // just seeked, try read a new img
@@ -2596,8 +2605,13 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
                }
                context->vid_ready = 1;
        }
-       if (!frame->img) context->closed = 1;
-       return frame->img ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
+
+       if ((flags & SVR_BLOCK)) {
+               if (!frame->img) context->closed = 1;
+               return frame->img ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
+       } else {
+               return frame->img ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_BREAK;
+       }
 }
 #endif