summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/options.c7
-rw-r--r--src/options.h1
-rw-r--r--src/rharchive.c33
3 files changed, 29 insertions, 12 deletions
diff --git a/src/options.c b/src/options.c
index 49b53c1..f4a101b 100644
--- a/src/options.c
+++ b/src/options.c
@@ -196,6 +196,7 @@ int options_parse(options_t* opt, int argc, char* argv[])
PARSE_STRING_PARAM("-P","--write-pid", opt->pid_file_)
PARSE_STRING_LIST("-L","--log", opt->log_targets_)
PARSE_BOOL_PARAM("-U", "--debug", opt->debug_)
+ PARSE_STRING_PARAM("-s","--source", opt->src_bin_desc_)
else
return i;
}
@@ -233,6 +234,7 @@ void options_default(options_t* opt)
opt->pid_file_ = NULL;
string_list_init(&opt->log_targets_);
opt->debug_ = 0;
+ opt->src_bin_desc_ = NULL;
}
void options_clear(options_t* opt)
@@ -251,6 +253,8 @@ void options_clear(options_t* opt)
if(opt->pid_file_)
free(opt->pid_file_);
string_list_clear(&opt->log_targets_);
+ if(opt->src_bin_desc_)
+ free(opt->src_bin_desc_);
}
void options_print_usage()
@@ -266,6 +270,8 @@ void options_print_usage()
printf(" [-L|--log] <target>:<level>[,<param1>[,<param2>..]]\n");
printf(" add a log target, can be invoked several times\n");
printf(" [-U|--debug] don't daemonize and log to stdout with maximum log level\n");
+ printf(" [-s|--source] <description> a gstreamer pipeline-style description which will be used\n");
+ printf(" as data source, see gst-launch man-page for syntax\n");
}
void options_print_version()
@@ -288,4 +294,5 @@ void options_print(options_t* opt)
printf("log_targets: \n");
string_list_print(&opt->log_targets_, " '", "'\n");
printf("debug: %s\n", !opt->debug_ ? "false" : "true");
+ printf("src_bin_desc: >>%s<<\n", opt->src_bin_desc_);
}
diff --git a/src/options.h b/src/options.h
index 5a4b33a..22013d5 100644
--- a/src/options.h
+++ b/src/options.h
@@ -40,6 +40,7 @@ struct options_struct {
char* pid_file_;
string_list_t log_targets_;
int debug_;
+ char* src_bin_desc_;
};
typedef struct options_struct options_t;
diff --git a/src/rharchive.c b/src/rharchive.c
index 5893c37..a2ff037 100644
--- a/src/rharchive.c
+++ b/src/rharchive.c
@@ -85,29 +85,38 @@ int main_loop(options_t* opt)
GMainLoop *loop;
- GstElement *pipeline, *source, *encoder, *muxer, *sink;
+ GstElement *pipeline, *source, *writer;
GstBus *bus;
loop = g_main_loop_new(NULL, FALSE);
pipeline = gst_pipeline_new("rharchive");
- source = gst_element_factory_make("audiotestsrc", "raw-source");
- encoder = gst_element_factory_make("vorbisenc", "encoder");
- muxer = gst_element_factory_make("oggmux", "muxer");
- sink = gst_element_factory_make("filesink", "sink");
-
- if(!pipeline || !source || !encoder || !muxer || !sink) {
- log_printf(ERROR, "One element could not be created. Exiting.");
+ if(!pipeline) {
+ log_printf(ERROR, "the pipeline object could not be created. Exiting.");
return -1;
}
- g_object_set(G_OBJECT(sink), "location", "output.ogg", NULL);
-
bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
gst_bus_add_watch(bus, bus_call, loop);
gst_object_unref(bus);
- gst_bin_add_many(GST_BIN(pipeline), source, encoder, muxer, sink, NULL);
- gst_element_link_many(source, encoder, muxer, sink, NULL);
+
+ writer = gst_element_factory_make("filesink", "writer");
+ if(!writer) {
+ log_printf(ERROR, "the writer object could not be created. Exiting.");
+ return -1;
+ }
+ g_object_set(G_OBJECT(writer), "location", "output.ogg", NULL);
+
+ GError *error = NULL;
+ source = gst_parse_bin_from_description(opt->src_bin_desc_, TRUE, &error);
+ if(error) {
+ log_printf(ERROR, "Source Bin Description Parser Error: %s", error->message);
+ g_error_free(error);
+ return -1;
+ }
+
+ gst_bin_add_many(GST_BIN(pipeline), source, writer, NULL);
+ gst_element_link_many(source, writer, NULL);
log_printf(INFO, "Set State: Paused");
gst_element_set_state(pipeline, GST_STATE_PAUSED);