]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7656 not quite reporting when it was video or not
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 16 Jun 2015 16:54:43 +0000 (11:54 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 16 Jun 2015 16:55:00 +0000 (11:55 -0500)
src/mod/formats/mod_local_stream/mod_local_stream.c

index 46122a2424e85279016a7f3838ce53655271859c..caba6b00738ecc730b67b0fa622d6f183e4a44bd 100644 (file)
@@ -101,6 +101,7 @@ struct local_stream_source {
        int32_t chime_max_counter;
        switch_file_handle_t chime_fh;
        switch_queue_t *video_q;
+       int has_video;
 };
 
 typedef struct local_stream_source local_stream_source_t;
@@ -230,7 +231,6 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
                        while (RUNNING && !source->stopped) {
                                int is_open;
                                switch_file_handle_t *use_fh = &fh;
-                               int has_video = 0;
 
                                switch_core_timer_next(&timer);
                                olen = source->samples;
@@ -282,17 +282,14 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
                                        }
                                }
 
-                               has_video = 0;
 
                                if (is_open) {
-                                       
                                        if (switch_core_file_has_video(use_fh)) {
                                                switch_frame_t vid_frame = { 0 };
 
-                                               has_video = 1;
-
                                                if (switch_core_file_read_video(use_fh, &vid_frame, SVR_FLUSH) == SWITCH_STATUS_SUCCESS) {
                                                        if (vid_frame.img) {
+                                                               source->has_video = 1;
                                                                switch_queue_push(source->video_q, vid_frame.img);
                                                        }
                                                }
@@ -343,10 +340,11 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
 
                                        } else {
                                                uint32_t bused = 0;
-                                               
+
                                                switch_mutex_lock(source->mutex);
                                                for (cp = source->context_list; cp && RUNNING; cp = cp->next) {
-                                                       if (has_video) {
+                                                       
+                                                       if (source->has_video) {
                                                                switch_set_flag(cp->handle, SWITCH_FILE_FLAG_VIDEO);
                                                        } else {
                                                                switch_clear_flag(cp->handle, SWITCH_FILE_FLAG_VIDEO);
@@ -579,6 +577,10 @@ static switch_status_t local_stream_file_open(switch_file_handle_t *handle, cons
                goto end;
        }
 
+       if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO) && !source->has_video) {
+               switch_clear_flag(handle, SWITCH_FILE_FLAG_VIDEO);
+       }
+
        context->source = source;
        context->file = handle->file;
        context->func = handle->func;