diff options
Diffstat (limited to 'src/writer.c')
-rw-r--r-- | src/writer.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/writer.c b/src/writer.c index 6322a00..c8689f0 100644 --- a/src/writer.c +++ b/src/writer.c @@ -31,12 +31,14 @@ #include <sys/stat.h> #include <fcntl.h> +#include <time.h> + #include "writer.h" #include "datatypes.h" #include "log.h" -int writer_init(writer_t* writer, const char* name_format, const char* output_dir, int length, int offset) +int writer_init(writer_t* writer, const char* name_format, const char* output_dir, int interval, int offset) { if(!writer) return -1; @@ -53,8 +55,8 @@ int writer_init(writer_t* writer, const char* name_format, const char* output_di } writer->name_format_ = name_format; writer->output_dir_ = output_dir; - writer->length_ = length; - writer->offset_ = offset; + writer->interval_ = interval * GST_MSECOND; + writer->offset_ = offset * GST_MSECOND; return 0; } @@ -72,7 +74,12 @@ static gpointer writer_thread_func(gpointer data) if(GST_CLOCK_EARLY == ret) continue; - log_printf(NOTICE, "just woke up"); + struct timespec now; + clock_gettime(CLOCK_REALTIME, &now); + + struct tm now_bd; + localtime_r(&(now.tv_sec), &now_bd); + log_printf(NOTICE, "it's now: %d:%d:%d on %d.%d.%d", now_bd.tm_hour, now_bd.tm_min, now_bd.tm_sec, now_bd.tm_mday, now_bd.tm_mon+1, now_bd.tm_year+1900); } log_printf(NOTICE, "writer thread stopped"); @@ -84,7 +91,7 @@ int writer_start(writer_t* writer) if(!writer) return; - writer->clock_id_ = gst_clock_new_periodic_id(writer->clock_, 0, writer->length_*GST_SECOND); + writer->clock_id_ = gst_clock_new_periodic_id(writer->clock_, 0, writer->interval_); writer->thread_ = g_thread_create(writer_thread_func, writer, TRUE, NULL); if(!writer->thread_) { log_printf(ERROR, "writer thread could not be started"); |