summaryrefslogtreecommitdiff
path: root/src/writer.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2011-02-20 05:05:53 (GMT)
committerChristian Pointner <equinox@helsinki.at>2011-02-20 05:05:53 (GMT)
commit6f80905b6b976e1355b8556fc3a1dd6288701593 (patch)
treea8151c8fec21a3b517cac33a4b7326393b62fb5b /src/writer.c
parent14e6a00caae8edd1022bb2c5a2c4dde1b1bc0b5a (diff)
no app sink anymore
tests with clocks
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/writer.c b/src/writer.c
index ead0168..6322a00 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -26,7 +26,10 @@
*/
#include <gst/gst.h>
-#include <gst/app/gstappsink.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include "writer.h"
@@ -38,11 +41,16 @@ int writer_init(writer_t* writer, const char* name_format, const char* output_di
if(!writer)
return -1;
- writer->sink_ = gst_element_factory_make("appsink", "writer");
+ writer->sink_ = gst_element_factory_make("fakesink", "writer");
if(!writer->sink_) {
log_printf(ERROR, "the writer object could not be created. Exiting.");
return -1;
}
+ writer->clock_ = gst_system_clock_obtain();
+ if(!writer->clock_) {
+ log_printf(ERROR, "unable to obtain the system clock");
+ return -1;
+ }
writer->name_format_ = name_format;
writer->output_dir_ = output_dir;
writer->length_ = length;
@@ -55,16 +63,18 @@ static gpointer writer_thread_func(gpointer data)
{
writer_t *writer = (writer_t*)data;
log_printf(NOTICE, "writer thread started");
-
+
GstBuffer* buf = NULL;
for(;;) {
- buf = gst_app_sink_pull_buffer((GstAppSink*)writer->sink_);
- if(!buf) {
+ GstClockReturn ret = gst_clock_id_wait(writer->clock_id_, NULL);
+ if(GST_CLOCK_UNSCHEDULED == ret)
break;
- }
- log_printf(DEBUG, "got buffer of size %d", buf->size);
- }
+ if(GST_CLOCK_EARLY == ret)
+ continue;
+ log_printf(NOTICE, "just woke up");
+ }
+
log_printf(NOTICE, "writer thread stopped");
return NULL;
}
@@ -74,20 +84,23 @@ 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->thread_ = g_thread_create(writer_thread_func, writer, TRUE, NULL);
if(!writer->thread_) {
log_printf(ERROR, "writer thread could not be started");
return -1;
- }
+ }
}
void writer_stop(writer_t* writer)
{
if(!writer)
return;
-
+
+ gst_clock_id_unschedule(writer->clock_id_);
if(writer->thread_) {
log_printf(NOTICE, "waiting for writer thread to stop");
g_thread_join(writer->thread_);
}
+ gst_object_unref(GST_OBJECT(writer->clock_));
}