summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-05-28 13:19:00 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-05-28 13:19:00 +0200
commit4af268af035a7e779cf1787185a03e87a5eb982a (patch)
treebf4e5faae7f0dfa1e7c7c7721aa66bd0743ee75b /src
parent8951bdad901c659e5212a68332617ba8544a2a3c (diff)
downloadcmumble-4af268af035a7e779cf1787185a03e87a5eb982a.tar.gz
cmumble-4af268af035a7e779cf1787185a03e87a5eb982a.tar.bz2
cmumble-4af268af035a7e779cf1787185a03e87a5eb982a.zip
Use gst_parse_launch for recording pipeline
Diffstat (limited to 'src')
-rw-r--r--src/cmumble.c47
1 files changed, 11 insertions, 36 deletions
diff --git a/src/cmumble.c b/src/cmumble.c
index d3ade84..acd1064 100644
--- a/src/cmumble.c
+++ b/src/cmumble.c
@@ -389,49 +389,24 @@ setup_playback_gst_pipeline(struct context *ctx)
static int
setup_recording_gst_pipeline(struct context *ctx)
{
- GstElement *pipeline, *src, *cutter, *resample,
- *conv, *capsfilter, *encoder, *sink;
- GstBus *bus;
+ GstElement *pipeline, *cutter, *sink;
+ GError *error = NULL;
GstCaps *caps;
- pipeline = gst_pipeline_new("cmumble-input");
- src = gst_element_factory_make("autoaudiosrc", "audio-input");
- cutter = gst_element_factory_make("cutter", "cutter");
- resample = gst_element_factory_make("audioresample", "resample");
- conv = gst_element_factory_make("audioconvert", "converter");
- capsfilter = gst_element_factory_make("capsfilter", "capsfilter");
- encoder = gst_element_factory_make("celtenc", "celt-encoder");
- sink = gst_element_factory_make("appsink", "output");
-
- if (!pipeline || !src || !cutter || !resample || !conv ||
- !capsfilter || !encoder || !sink) {
- g_printerr("failed to initialize pipeline\n");
+ char *desc = "autoaudiosrc ! cutter name=cutter ! audioresample ! audioconvert ! "
+ "audio/x-raw-int,channels=1,depth=16,rate=48000,signed=TRUE,width=16 ! "
+ "celtenc ! appsink name=sink";
+
+ pipeline = gst_parse_launch(desc, &error);
+ if (error) {
+ g_printerr("Failed to create pipeline: %s\n", error->message);
return -1;
}
-
- bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
- gst_bus_add_watch(bus, bus_call, ctx);
- gst_object_unref(bus);
-
- gst_bin_add_many(GST_BIN(pipeline),
- src, cutter, resample, conv,
- capsfilter, encoder, sink, NULL);
- gst_element_link_many(src, cutter, resample, conv,
- capsfilter, encoder, sink, NULL);
-
+ sink = gst_bin_get_by_name(GST_BIN(pipeline), "sink");
ctx->sink = GST_APP_SINK(sink);
ctx->record_pipeline = pipeline;
- caps = gst_caps_new_simple("audio/x-raw-int",
- "channels", G_TYPE_INT, 1,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 48000,
- "width", G_TYPE_INT, 16,
- "signed", G_TYPE_BOOLEAN, TRUE,
- NULL);
- g_object_set(G_OBJECT(capsfilter), "caps", caps, NULL);
- gst_caps_unref(caps);
-
+ cutter = gst_bin_get_by_name(GST_BIN(pipeline), "cutter");
g_object_set(G_OBJECT(cutter),
"threshold_dB", -45.0, "leaky", TRUE, NULL);