diff options
author | Christian Pointner <equinox@helsinki.at> | 2011-02-20 02:12:24 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2011-02-20 02:12:24 (GMT) |
commit | 14e6a00caae8edd1022bb2c5a2c4dde1b1bc0b5a (patch) | |
tree | ece14c8e5d457aa6c4653d39a89e02c5d0f30242 /src/writer.c | |
parent | 88fafd10a4a260631c3de6b18720601b9cfafba1 (diff) |
switching to appsrc for writer element
Diffstat (limited to 'src/writer.c')
-rw-r--r-- | src/writer.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/writer.c b/src/writer.c index 1697262..ead0168 100644 --- a/src/writer.c +++ b/src/writer.c @@ -26,6 +26,7 @@ */ #include <gst/gst.h> +#include <gst/app/gstappsink.h> #include "writer.h" @@ -37,12 +38,11 @@ int writer_init(writer_t* writer, const char* name_format, const char* output_di if(!writer) return -1; - writer->sink_ = gst_element_factory_make("filesink", "writer"); + writer->sink_ = gst_element_factory_make("appsink", "writer"); if(!writer->sink_) { log_printf(ERROR, "the writer object could not be created. Exiting."); return -1; } - g_object_set(G_OBJECT(writer->sink_), "location", "output.ogg", NULL); writer->name_format_ = name_format; writer->output_dir_ = output_dir; writer->length_ = length; @@ -51,18 +51,43 @@ int writer_init(writer_t* writer, const char* name_format, const char* output_di return 0; } -void writer_start(writer_t* writer) +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) { + break; + } + log_printf(DEBUG, "got buffer of size %d", buf->size); + } + + log_printf(NOTICE, "writer thread stopped"); + return NULL; +} + +int writer_start(writer_t* writer) { if(!writer) return; - // nothing yet + 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; - - // nothing yet + + if(writer->thread_) { + log_printf(NOTICE, "waiting for writer thread to stop"); + g_thread_join(writer->thread_); + } } |