summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2011-04-13 23:02:23 (GMT)
committerChristian Pointner <equinox@helsinki.at>2011-04-13 23:02:23 (GMT)
commit9fdfadf40d3be2f98376556622486c79dfdb809a (patch)
tree51b1afc1710a99cbd9482f04e3a7ea38e9120706 /src
parent161271070b84d12cf175e06de542a04c89e438a6 (diff)
files have a fixed length now (1 hour)
introduced sample interval
Diffstat (limited to 'src')
-rw-r--r--src/options.c12
-rw-r--r--src/options.h2
-rw-r--r--src/rharchive.c4
-rw-r--r--src/writer.c17
-rw-r--r--src/writer.h6
5 files changed, 24 insertions, 17 deletions
diff --git a/src/options.c b/src/options.c
index eddf914..3595866 100644
--- a/src/options.c
+++ b/src/options.c
@@ -199,13 +199,13 @@ int options_parse(options_t* opt, int argc, char* argv[])
PARSE_STRING_PARAM("-s","--source", opt->src_bin_desc_)
PARSE_STRING_PARAM("-d","--output-dir", opt->output_dir_)
PARSE_STRING_PARAM("-f","--name-format", opt->name_format_)
- PARSE_INT_PARAM("-l","--length", opt->length_)
+ PARSE_INT_PARAM("-i","--interval", opt->interval_)
PARSE_INT_PARAM("-o","--offset", opt->offset_)
else
return i;
}
- if(opt->length_ <= 0)
+ if(opt->interval_ <= 0)
return -4;
if(opt->debug_) {
@@ -244,7 +244,7 @@ void options_default(options_t* opt)
opt->src_bin_desc_ = NULL;
opt->output_dir_ = strdup("/srv/archiv");
opt->name_format_ = strdup("%Y-%m-%d-%H00.ogg");
- opt->length_ = 3600;
+ opt->interval_ = 50;
opt->offset_ = 0;
}
@@ -289,8 +289,8 @@ void options_print_usage()
printf(" as data source, see gst-launch man-page for syntax\n");
printf(" [-d|--output-dir] <path> path to the output directory\n");
printf(" [-f|--name-format] <format> the file name format, see manpage of date for the syntax\n");
- printf(" [-l|--length] <value> length of one file in seconds\n");
- printf(" [-o|--offset] <value> time offset for recordings in 0.1s\n");
+ printf(" [-i|--interval] <value> interval for time checks in ms\n");
+ printf(" [-o|--offset] <value> time offset for recordings in ms\n");
}
void options_print_version()
@@ -316,6 +316,6 @@ void options_print(options_t* opt)
printf("src_bin_desc: >>%s<<\n", opt->src_bin_desc_);
printf("output_dir: '%s'\n", opt->output_dir_);
printf("name_format: '%s'\n", opt->name_format_);
- printf("length: %d\n", opt->length_);
+ printf("interval: %d\n", opt->interval_);
printf("offset: %d\n", opt->offset_);
}
diff --git a/src/options.h b/src/options.h
index 666e513..aaad77a 100644
--- a/src/options.h
+++ b/src/options.h
@@ -43,7 +43,7 @@ struct options_struct {
char* src_bin_desc_;
char* output_dir_;
char* name_format_;
- int length_;
+ int interval_;
int offset_;
};
typedef struct options_struct options_t;
diff --git a/src/rharchive.c b/src/rharchive.c
index 699738b..dda75f4 100644
--- a/src/rharchive.c
+++ b/src/rharchive.c
@@ -94,7 +94,7 @@ int main_loop(options_t* opt)
return -1;
}
- int ret = writer_init(&writer, opt->name_format_, opt->output_dir_, opt->length_, opt->offset_);
+ int ret = writer_init(&writer, opt->name_format_, opt->output_dir_, opt->interval_, opt->offset_);
if(ret) {
gst_object_unref(GST_OBJECT(pipeline));
gst_object_unref(GST_OBJECT(loop));
@@ -150,7 +150,7 @@ int main(int argc, char* argv[])
if(ret == -3)
options_print_version();
if(ret == -4)
- fprintf(stderr, "the length must be bigger than 0\n");
+ fprintf(stderr, "the interval must be bigger than 0\n");
if(ret != -2 && ret != -3 && ret != -4)
options_print_usage();
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");
diff --git a/src/writer.h b/src/writer.h
index 5189f50..38df718 100644
--- a/src/writer.h
+++ b/src/writer.h
@@ -37,12 +37,12 @@ struct writer_struct {
GThread* thread_;
const char* name_format_;
const char* output_dir_;
- int length_;
- int offset_;
+ GstClockTime interval_;
+ GstClockTime offset_;
};
typedef struct writer_struct writer_t;
-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);
int writer_start(writer_t* writer);
void writer_stop(writer_t* writer);