summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/writer.c21
-rw-r--r--src/writer.h1
2 files changed, 18 insertions, 4 deletions
diff --git a/src/writer.c b/src/writer.c
index f45422c..f89adfb 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -167,12 +167,25 @@ static int check_boundaries(writer_t* writer)
int ret = open_file(&(writer->next_));
// if(ret) return ret; // TODO: stop writer on open_file error ???
- // - add new file
- // - remove old file
+ // - add new file
+ // - remove old file
- // - calculate next filename and boundary
+ writer->old_ = writer->current_;
+ writer->current_ = writer->next_;
+
+ writer->next_boundary_.tv_sec += 3600;
+ struct tm bd_time;
+ localtime_r(&(writer->next_boundary_.tv_sec), &bd_time);
- // - call post processing script from fd_removed callback
+ ret = compute_filname(&bd_time, "next", &(writer->next_), writer->name_format_, writer->output_dir_, writer->mode_);
+ if(ret) return ret;
+
+
+ // - call post processing script from fd_removed callback
+ if(writer->old_.fd_ > 0)
+ close(writer->old_.fd_);
+ if(writer->old_.path_)
+ free(writer->old_.path_);
}
return 0;
diff --git a/src/writer.h b/src/writer.h
index 1e1b236..93eff85 100644
--- a/src/writer.h
+++ b/src/writer.h
@@ -51,6 +51,7 @@ struct writer_struct {
mode_t mode_;
GstClockTime interval_;
GstClockTime offset_;
+ file_t old_;
file_t current_;
file_t next_;
struct timespec next_boundary_;