<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 07/17/2013 10:04 AM, stixxy wrote:<br>
</div>
<blockquote cite="mid:1374077088314-4661081.post@n4.nabble.com"
type="cite">
<pre wrap="">i have follow line and i want to compile what is the best solution for a
simple code?
gst-launch-0.10 alsasrc device=hw:0,0 ! audioconvert ! alsasink
device=hw:0,0
</pre>
</blockquote>
<br>
You can create the same pipeline in C with <a
href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstParse.html#gst-parse-launch">gst_parse_launch</a>:<br>
<blockquote><tt>GError* error;<br>
GstElement* pipeline = gst_parse_launch("alsasrc device=hw:0,0 !
audioconvert ! alsasink device=hw:0,0", &error);</tt><tt><br>
</tt><tt>if (error) {</tt><tt><br>
</tt><tt> // print error</tt><tt><br>
</tt><tt>}</tt><tt><br>
</tt><tt>if (pipeline) {</tt><tt><br>
</tt><tt> gst_element_set_state(pipeline, GST_STATE_PLAYING);</tt><tt><br>
</tt><tt>}</tt><br>
</blockquote>
Or you could build it by hand:<br>
<blockquote><tt>GstElement* pipeline = gst_pipeline_new(NULL);</tt><tt><br>
</tt><tt><br>
</tt><tt>GstElement* alsasrc = gst_element_factory_make("alsasrc",
NULL);</tt><tt><br>
</tt><tt>g_object_set(alsasrc, "device", "hw:0,0", NULL);</tt><tt><br>
</tt><tt>gst_bin_add(GST_BIN(pipeline), alsasrc);<br>
</tt><tt></tt><tt><br>
</tt><tt>GstElement* audioconvert =
gst_element_factory_make("audioconvert", NULL);</tt><tt><br>
</tt><tt>gst_bin_add(GST_BIN(pipeline), audioconvert);<br>
</tt><tt>gst_element_link(alsasrc, audioconvert);<br>
</tt><tt></tt><tt><br>
</tt><tt>GstElement* alsasink =
gst_element_factory_make("alsasink", NULL);</tt><tt><br>
</tt><tt>g_object_set(alsasink, "device", "hw:0,0", NULL);</tt><tt><br>
</tt><tt>gst_bin_add(GST_BIN(pipeline), alsasink);</tt><tt><br>
</tt><tt>gst_element_link(audioconvert, alsasink)</tt><tt>;<br>
</tt><tt><br>
</tt><tt>gst_element_set_state(pipeline, GST_STATE_PLAYING);</tt><tt><br>
</tt></blockquote>
</body>
</html>