]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
wait for video before recording in mod_fsv
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 25 Mar 2010 19:06:18 +0000 (19:06 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 25 Mar 2010 19:06:18 +0000 (19:06 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@17103 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_fsv/mod_fsv.c

index f09cc3909795118449b61e43484ee7ad538847a9..29b26a19e54d4b089eaad7979d1a05ca16eee6af 100644 (file)
@@ -108,17 +108,33 @@ SWITCH_STANDARD_APP(record_fsv_function)
        switch_mutex_t *mutex = NULL;
        switch_codec_t codec, *vid_codec;
        switch_codec_implementation_t read_impl = { 0 };
-       switch_core_session_get_read_impl(session, &read_impl);
+       int count = 0;
 
+       switch_core_session_get_read_impl(session, &read_impl);
        switch_channel_answer(channel);
 
+
+       while (switch_channel_up(channel) && !switch_channel_test_flag(channel, CF_VIDEO)) {
+               switch_yield(10000);
+
+               if (count) count--;
+
+               if (count == 0) {
+                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "%s waiting for video.\n", switch_channel_get_name(channel));
+                       count = 100;
+               }
+       }
+       
+       if (!switch_channel_ready(channel)) {
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s not ready.\n", switch_channel_get_name(channel));
+               return;
+       }
+
        if ((fd = open((char *) data, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR)) < 0) {
                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Error opening file %s\n", (char *) data);
                return;
        }
 
-       switch_channel_answer(channel);
-
        if (switch_core_codec_init(&codec,
                                                           "L16",
                                                           NULL,