]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7514: drop extra frames
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 5 Mar 2015 21:46:25 +0000 (15:46 -0600)
committerMichael Jerris <mike@jerris.com>
Thu, 28 May 2015 17:47:09 +0000 (12:47 -0500)
src/mod/formats/mod_vlc/mod_vlc.c

index ffcc5f69a4a457b82995a53e418d641bb98d54ca..1aaf003066be25092f91476ce58b74b9d93880f9 100644 (file)
@@ -2345,15 +2345,25 @@ static switch_status_t vlc_read_video_frame(switch_core_session_t *session, swit
        
        switch_img_free(&tech_pvt->read_video_frame.img);
 
-       if (tech_pvt->context->video_queue && switch_queue_pop(tech_pvt->context->video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
-               switch_image_t *img = (switch_image_t *) pop;                   
-               if (!img) return SWITCH_STATUS_FALSE;
+       if (tech_pvt->context->video_queue) {
+               while(switch_queue_size(tech_pvt->context->video_queue) > 1) {
+                       if (switch_queue_trypop(tech_pvt->context->video_queue, &pop) == SWITCH_STATUS_SUCCESS) { 
+                               switch_image_t *img = (switch_image_t *) pop;
+                               switch_img_free(&img);
+                       } else {
+                               break;
+                       }
+               }
+               if (switch_queue_pop(tech_pvt->context->video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+                       switch_image_t *img = (switch_image_t *) pop;                   
+                       if (!img) return SWITCH_STATUS_FALSE;
                
-               tech_pvt->read_video_frame.img = img;
-               *frame = &tech_pvt->read_video_frame;
-               switch_set_flag(*frame, SFF_RAW_RTP);
-               switch_clear_flag(*frame, SFF_CNG);
-               (*frame)->codec = &tech_pvt->video_codec;
+                       tech_pvt->read_video_frame.img = img;
+                       *frame = &tech_pvt->read_video_frame;
+                       switch_set_flag(*frame, SFF_RAW_RTP);
+                       switch_clear_flag(*frame, SFF_CNG);
+                       (*frame)->codec = &tech_pvt->video_codec;
+               }
        } else {
                *frame = &tech_pvt->read_frame;
                tech_pvt->read_frame.codec = &tech_pvt->video_codec;