diff options
Diffstat (limited to 'src/writer.c')
-rw-r--r-- | src/writer.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/writer.c b/src/writer.c index c8689f0..633a34e 100644 --- a/src/writer.c +++ b/src/writer.c @@ -38,6 +38,40 @@ #include "datatypes.h" #include "log.h" +static void init_time_boundaries(writer_t* writer) +{ + if(!writer) + return; + + struct timespec now; + clock_gettime(CLOCK_REALTIME, &now); + + struct tm bd_time; + localtime_r(&(now.tv_sec), &bd_time); + + log_printf(INFO, "it's now: %02d:%02d:%02d on %d.%d.%d", bd_time.tm_hour, bd_time.tm_min, bd_time.tm_sec, bd_time.tm_mday, bd_time.tm_mon+1, bd_time.tm_year+1900); + + strftime(writer->current_.name_, sizeof(writer->current_.name_), writer->name_format_, &bd_time); + log_printf(INFO, "current filename is: %s(.?)", writer->current_.name_); + + + bd_time.tm_sec = 0; + bd_time.tm_min = 0; + + time_t T = mktime(&bd_time); + T+=3600; + + localtime_r(&T, &bd_time); + + log_printf(INFO, "next boundary is at: %02d:%02d:%02d on %d.%d.%d", bd_time.tm_hour, bd_time.tm_min, bd_time.tm_sec, bd_time.tm_mday, bd_time.tm_mon+1, bd_time.tm_year+1900); + + strftime(writer->next_.name_, sizeof(writer->next_.name_), writer->name_format_, &bd_time); + log_printf(INFO, "next filename will be: %s(.?)", writer->next_.name_); + + struct timespec b = { T, 0 }; + writer->next_boundary_ = b; +} + int writer_init(writer_t* writer, const char* name_format, const char* output_dir, int interval, int offset) { if(!writer) @@ -57,10 +91,16 @@ int writer_init(writer_t* writer, const char* name_format, const char* output_di writer->output_dir_ = output_dir; writer->interval_ = interval * GST_MSECOND; writer->offset_ = offset * GST_MSECOND; + init_time_boundaries(writer); return 0; } +static int open_file(file_t* file) +{ + +} + static gpointer writer_thread_func(gpointer data) { writer_t *writer = (writer_t*)data; @@ -79,7 +119,7 @@ static gpointer writer_thread_func(gpointer data) 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(DEBUG, "it's now: %02d:%02d:%02d 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"); |