diff options
-rw-r--r-- | README | 1 | ||||
-rwxr-xr-x | src/configure | 4 | ||||
-rw-r--r-- | src/rharchive.c | 4 | ||||
-rw-r--r-- | src/writer.c | 37 | ||||
-rw-r--r-- | src/writer.h | 3 |
5 files changed, 38 insertions, 11 deletions
@@ -14,6 +14,7 @@ Linux core: build-essential libgstreamer0.10-dev + libgstreamer-plugins-base0.10-dev pkg-config if you want to rebuild the manpage: diff --git a/src/configure b/src/configure index ef6e03a..ecb9cb2 100755 --- a/src/configure +++ b/src/configure @@ -91,8 +91,8 @@ if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then exit 1 fi -CFLAGS="$CFLAGS $(pkg-config --cflags gstreamer-0.10)" -LDFLAGS="$LDFLAGS $(pkg-config --libs gstreamer-0.10)" +CFLAGS="$CFLAGS $(pkg-config --cflags gstreamer-0.10 gstreamer-app-0.10)" +LDFLAGS="$LDFLAGS $(pkg-config --libs gstreamer-0.10 gstreamer-app-0.10)" rm -f include.mk rm -f config.h diff --git a/src/rharchive.c b/src/rharchive.c index da64ad4..39ee0bc 100644 --- a/src/rharchive.c +++ b/src/rharchive.c @@ -123,11 +123,11 @@ int main_loop(options_t* opt) signal_start(loop); writer_start(&writer); g_main_loop_run(loop); - writer_stop(&writer); signal_stop(); - log_printf(INFO, "Stopping pipeline"); + log_printf(NOTICE, "Stopping pipeline"); gst_element_set_state (pipeline, GST_STATE_NULL); + writer_stop(&writer); gst_object_unref(GST_OBJECT(pipeline)); return 0; 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_); + } } diff --git a/src/writer.h b/src/writer.h index 8081644..7ef5c26 100644 --- a/src/writer.h +++ b/src/writer.h @@ -32,6 +32,7 @@ struct writer_struct { GstElement* sink_; + GThread* thread_; const char* name_format_; const char* output_dir_; int length_; @@ -40,7 +41,7 @@ struct writer_struct { typedef struct writer_struct writer_t; int writer_init(writer_t* writer, const char* name_format, const char* output_dir, int length, int offset); -void writer_start(writer_t* writer); +int writer_start(writer_t* writer); void writer_stop(writer_t* writer); #endif |