Thank you! Is working now!!!<br><br><div class="gmail_quote">On Wed, Oct 28, 2009 at 6:54 AM, Stefan Kost <span dir="ltr"><<a href="mailto:ensonic@hora-obscura.de">ensonic@hora-obscura.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
hi,<br>
<br>
This is wrong<br>
<div class="im">gst_element_link_many (source, demuxer, decoder, sink, NULL);<br>
</div>do<br>
<div class="im">gst_element_link(source, demuxer);<br>
</div>gst_element_link(decoder, sink);<br>
you will link demuxer to decoder in the on_pad_added() callback.<br>
<br>
Stefan<br>
<div class="im"><br>
<br>
><br>
> On Wed, Oct 28, 2009 at 12:12 AM, Gabriel Duarte <<a href="mailto:confusosk8@gmail.com">confusosk8@gmail.com</a><br>
</div><div><div></div><div class="h5">> <mailto:<a href="mailto:confusosk8@gmail.com">confusosk8@gmail.com</a>>> wrote:<br>
><br>
> sorry, I sent the wrong code, this is the right:<br>
><br>
> #include <gst/gst.h><br>
> #include <glib.h><br>
><br>
><br>
> static gboolean<br>
> cb_print_position (GstElement *pipeline)<br>
> {<br>
> GstFormat fmt = GST_FORMAT_TIME;<br>
> gint64 pos, len;<br>
><br>
> if (gst_element_query_position (pipeline, &fmt, &pos)<br>
> && gst_element_query_duration (pipeline, &fmt, &len)) {<br>
> g_print ("Time: %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT "\r",<br>
> GST_TIME_ARGS (pos), GST_TIME_ARGS (len));<br>
> }<br>
><br>
> /* call me again */<br>
> return TRUE;<br>
> }<br>
><br>
><br>
><br>
> static gboolean<br>
> bus_call (GstBus *bus,<br>
> GstMessage *msg,<br>
> gpointer data)<br>
> {<br>
> GMainLoop *loop = (GMainLoop *) data;<br>
><br>
> switch (GST_MESSAGE_TYPE (msg)) {<br>
><br>
> case GST_MESSAGE_EOS:<br>
> g_print ("End of stream\n");<br>
> g_main_loop_quit (loop);<br>
> break;<br>
><br>
> case GST_MESSAGE_ERROR: {<br>
> gchar *debug;<br>
> GError *error;<br>
><br>
> gst_message_parse_error (msg, &error, &debug);<br>
> g_free (debug);<br>
><br>
> g_printerr ("Error: %s\n", error->message);<br>
> g_error_free (error);<br>
><br>
> g_main_loop_quit (loop);<br>
> break;<br>
> }<br>
> default:<br>
> break;<br>
> }<br>
><br>
> return TRUE;<br>
> }<br>
><br>
><br>
> static void<br>
> on_pad_added (GstElement *element,<br>
> GstPad *pad,<br>
> gpointer data)<br>
> {<br>
> GstPad *sinkpad;<br>
> GstElement *decoder = (GstElement *) data;<br>
><br>
> /* We can now link this pad with the vorbis-decoder sink pad */<br>
> g_print ("Dynamic pad created, linking demuxer/decoder\n");<br>
><br>
> sinkpad = gst_element_get_static_pad (decoder, "sink");<br>
><br>
> gst_pad_link (pad, sinkpad);<br>
><br>
> gst_object_unref (sinkpad);<br>
> }<br>
><br>
><br>
><br>
> int<br>
> main (int argc,<br>
> char *argv[])<br>
> {<br>
> GMainLoop *loop;<br>
><br>
> GstElement *pipeline, *source, *demuxer, *decoder, *sink;<br>
> GstBus *bus;<br>
><br>
> /* Initialisation */<br>
> gst_init (&argc, &argv);<br>
><br>
> loop = g_main_loop_new (NULL, FALSE);<br>
><br>
><br>
> /* Check input arguments */<br>
> /* if (argc != 2) {<br>
> g_printerr ("Usage: %s <Ogg/Vorbis filename>\n", argv[0]);<br>
> return -1;<br>
> }*/<br>
><br>
> /*gst-launch-0.10 dv1394src num-buffers=8192 ! dvdemux ! dvdec !<br>
> xvimagesink sync=false*/<br>
> /* Create gstreamer elements */<br>
> pipeline = gst_pipeline_new ("DV_FIREWIRE");<br>
> source = gst_element_factory_make ("dv1394src",<br>
> "dv1394src");<br>
> demuxer = gst_element_factory_make ("dvdemux", "dvdemux");<br>
> decoder = gst_element_factory_make ("dvdec", "dvdec");<br>
> sink = gst_element_factory_make ("ximagesink", "ximagesink");<br>
><br>
> if (!pipeline || !source || !demuxer || !decoder || !sink) {<br>
> g_printerr ("One element could not be created. Exiting.\n");<br>
> return -1;<br>
> }<br>
><br>
> /* Set up the pipeline */<br>
><br>
> /* we set the input filename to the source element */<br>
> /*g_object_set (G_OBJECT (sink), "sync", FALSE, NULL);*/<br>
><br>
> /* we add a message handler */<br>
> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));<br>
> gst_bus_add_watch (bus, bus_call, loop);<br>
> gst_object_unref (bus);<br>
><br>
> /* we add all elements into the pipeline */<br>
> /* file-source | ogg-demuxer | vorbis-decoder | converter |<br>
> alsa-output */<br>
> gst_bin_add_many (GST_BIN (pipeline), source, demuxer, decoder,<br>
> sink, NULL);<br>
><br>
> /* we link the elements together */<br>
> /* file-source -> ogg-demuxer ~> vorbis-decoder -> converter -><br>
> alsa-output */<br>
> /* gst_element_link (source, demuxer);*/<br>
> gst_element_link_many (source, demuxer, decoder, sink, NULL);<br>
> g_signal_connect (demuxer, "pad-added", G_CALLBACK<br>
> (on_pad_added), decoder);<br>
><br>
> /* note that the demuxer will be linked to the decoder dynamically.<br>
> The reason is that Ogg may contain various streams (for example<br>
> audio and video). The source pad(s) will be created at run time,<br>
> by the demuxer when it detects the amount and nature of streams.<br>
> Therefore we connect a callback function which will be executed<br>
> when the "pad-added" is emitted.*/<br>
><br>
><br>
> /* Set the pipeline to "playing" state*/<br>
> g_print ("Now playing: %s\n", argv[1]);<br>
> gst_element_set_state (pipeline, GST_STATE_PLAYING);<br>
><br>
><br>
> /* Iterate */<br>
> g_print ("Running...\n");<br>
> g_timeout_add (200, (GSourceFunc) cb_print_position, pipeline);<br>
> g_main_loop_run (loop);<br>
><br>
><br>
> /* Out of the main loop, clean up nicely */<br>
> g_print ("Returned, stopping playback\n");<br>
> gst_element_set_state (pipeline, GST_STATE_NULL);<br>
><br>
> g_print ("Deleting pipeline\n");<br>
> gst_object_unref (GST_OBJECT (pipeline));<br>
> printf("THE END\n");<br>
> return 0;<br>
> }<br>
><br>
><br>
> On Tue, Oct 27, 2009 at 8:24 PM, Gabriel Duarte<br>
</div></div><div><div></div><div class="h5">> <<a href="mailto:confusosk8@gmail.com">confusosk8@gmail.com</a> <mailto:<a href="mailto:confusosk8@gmail.com">confusosk8@gmail.com</a>>> wrote:<br>
><br>
> hello all, I'm trying to convert this pipeline to C, but I'm<br>
> having problems....<br>
><br>
><br>
> gst-launch-0.10 dv1394src num-buffers=8192 ! dvdemux ! dvdec !<br>
> xvimagesink sync=false<br>
><br>
><br>
> I've wrote this code:<br>
><br>
><br>
> #include <string.h> /* for memset () */<br>
> #include <gst/gst.h><br>
><br>
> static void<br>
> cb_handoff (GstElement *fakesrc,<br>
> GstBuffer *buffer,<br>
> GstPad *pad,<br>
> gpointer user_data)<br>
> {<br>
> static gboolean white = FALSE;<br>
><br>
> /* this makes the image black/white */<br>
> memset (GST_BUFFER_DATA (buffer), white ? 0xff : 0x0,<br>
> GST_BUFFER_SIZE (buffer));<br>
> white = !white;<br>
> }<br>
><br>
> gint<br>
> main (gint argc,<br>
> gchar *argv[])<br>
> {<br>
> GstElement *pipeline, *fakesrc, *flt, *conv, *videosink;<br>
> GMainLoop *loop;<br>
><br>
> /* init GStreamer */<br>
> gst_init (&argc, &argv);<br>
> loop = g_main_loop_new (NULL, FALSE);<br>
><br>
> /* setup pipeline */<br>
> pipeline = gst_pipeline_new ("pipeline");<br>
> fakesrc = gst_element_factory_make ("fakesrc", "source");<br>
> flt = gst_element_factory_make ("capsfilter", "flt");<br>
> conv = gst_element_factory_make ("ffmpegcolorspace", "conv");<br>
> videosink = gst_element_factory_make ("xvimagesink", "videosink");<br>
><br>
> /* setup */<br>
> g_object_set (G_OBJECT (flt), "caps",<br>
> gst_caps_new_simple ("video/x-raw-rgb",<br>
> "width", G_TYPE_INT, 384,<br>
> "height", G_TYPE_INT, 288,<br>
> "framerate", GST_TYPE_FRACTION, 1, 1,<br>
> "bpp", G_TYPE_INT, 16,<br>
> "depth", G_TYPE_INT, 16,<br>
> "endianness", G_TYPE_INT, G_BYTE_ORDER,<br>
> NULL), NULL);<br>
> gst_bin_add_many (GST_BIN (pipeline), fakesrc, flt, conv, videosink, NULL);<br>
> gst_element_link_many (fakesrc, flt, conv, videosink, NULL);<br>
><br>
> /* setup fake source */<br>
> g_object_set (G_OBJECT (fakesrc),<br>
> "signal-handoffs", TRUE,<br>
> "sizemax", 384 * 288 * 2,<br>
> "sizetype", 2, NULL);<br>
> g_signal_connect (fakesrc, "handoff", G_CALLBACK (cb_handoff), NULL);<br>
><br>
> /* play */<br>
> gst_element_set_state (pipeline, GST_STATE_PLAYING);<br>
> g_main_loop_run (loop);<br>
><br>
> /* clean up */<br>
> gst_element_set_state (pipeline, GST_STATE_NULL);<br>
> gst_object_unref (GST_OBJECT (pipeline));<br>
><br>
> return 0;<br>
> }<br>
><br>
><br>
><br>
><br>
><br>
> Any ideas???<br>
><br>
> Best regards :D<br>
><br>
><br>
><br>
><br>
><br>
><br>
> --<br>
> Gabriel Duarte<br>
> Linux User #471185<br>
> Rio de Janeiro - RJ<br>
> <a href="http://kinuxlinux.org/gabriel_duarte" target="_blank">http://kinuxlinux.org/gabriel_duarte</a><br>
><br>
> Phones:<br>
> (55) (21) 9463-7760 /*Mobile*/<br>
> (55) (21) 2464-9302 /*Home*/<br>
> (55) (21) 2529-5080 /*Work*/<br>
><br>
><br>
> -----BEGIN GEEK CODE BLOCK-----<br>
> Version: 3.12<br>
> GCS d- s: a--- C++ UL+++ P L++++ E- W+ N++ o++ K++ w---<br>
> O- M- V- PS++ PE++ Y PGP- t++ 5-- X+++ R tv++ b++ DI+ D++<br>
> G++ e+ h* r+ y++++<br>
> ------END GEEK CODE BLOCK------<br>
><br>
><br>
><br>
><br>
> --<br>
> Gabriel Duarte<br>
> Linux User #471185<br>
> Rio de Janeiro - RJ<br>
> <a href="http://kinuxlinux.org/gabriel_duarte" target="_blank">http://kinuxlinux.org/gabriel_duarte</a><br>
><br>
> Phones:<br>
> (55) (21) 9463-7760 /*Mobile*/<br>
> (55) (21) 2464-9302 /*Home*/<br>
> (55) (21) 2529-5080 /*Work*/<br>
><br>
><br>
<br>
<br>
</div></div>------------------------------------------------------------------------------<br>
Come build with us! The BlackBerry(R) Developer Conference in SF, CA<br>
is the only developer event you need to attend this year. Jumpstart your<br>
developing skills, take BlackBerry mobile applications to market and stay<br>
ahead of the curve. Join us from November 9 - 12, 2009. Register now!<br>
<a href="http://p.sf.net/sfu/devconference" target="_blank">http://p.sf.net/sfu/devconference</a><br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.sourceforge.net">gstreamer-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Gabriel Duarte<br>Linux User #471185<br>Rio de Janeiro - RJ<br><a href="http://kinuxlinux.org/gabriel_duarte">http://kinuxlinux.org/gabriel_duarte</a><br><br>Phones:<br>(55) (21) 9463-7760 /*Mobile*/<br>
(55) (21) 2464-9302 /*Home*/<br>(55) (21) 2529-5080 /*Work*/<br><br><br>-----BEGIN GEEK CODE BLOCK-----<br>Version: 3.12<br>GCS d- s: a--- C++ UL+++ P L++++ E- W+ N++ o++ K++ w--- <br>O- M- V- PS++ PE++ Y PGP- t++ 5-- X+++ R tv++ b++ DI+ D++ <br>
G++ e+ h* r+ y++++ <br>------END GEEK CODE BLOCK------<br>