<br><br><div class="gmail_quote">On Wed, Oct 28, 2009 at 12:12 AM, Gabriel Duarte <span dir="ltr"><<a href="mailto:confusosk8@gmail.com">confusosk8@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
sorry, I sent the wrong code, this is the right:<div><div></div><div class="h5"><div><br></div><div> #include <gst/gst.h><div>#include <glib.h></div><div><br></div><div><br></div><div>static gboolean</div><div>
cb_print_position (GstElement *pipeline)</div><div>{</div><div> GstFormat fmt = GST_FORMAT_TIME;</div><div> gint64 pos, len;</div><div><br></div><div> if (gst_element_query_position (pipeline, &fmt, &pos)</div>
<div> && gst_element_query_duration (pipeline, &fmt, &len)) {</div><div> g_print ("Time: %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT "\r",</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> GST_TIME_ARGS (pos), GST_TIME_ARGS (len));</div>
<div> }</div><div><br></div><div> /* call me again */</div><div> return TRUE;</div><div>}</div><div><br></div><div><br></div><div><br></div><div>static gboolean</div><div>bus_call (GstBus *bus,</div><div> GstMessage *msg,</div>
<div> gpointer data)</div><div>{</div><div> GMainLoop *loop = (GMainLoop *) data;</div><div><br></div><div> switch (GST_MESSAGE_TYPE (msg)) {</div><div><br></div><div> case GST_MESSAGE_EOS:</div><div> g_print ("End of stream\n");</div>
<div> g_main_loop_quit (loop);</div><div> break;</div><div><br></div><div> case GST_MESSAGE_ERROR: {</div><div> gchar *debug;</div><div> GError *error;</div><div><br></div><div> gst_message_parse_error (msg, &error, &debug);</div>
<div> g_free (debug);</div><div><br></div><div> g_printerr ("Error: %s\n", error->message);</div><div> g_error_free (error);</div><div><br></div><div> g_main_loop_quit (loop);</div><div> break;</div>
<div> }</div><div> default:</div><div> break;</div><div> }</div><div><br></div><div> return TRUE;</div><div>}</div><div><br></div><div><br></div><div>static void</div><div>on_pad_added (GstElement *element,</div>
<div> GstPad *pad,</div><div> gpointer data)</div><div>{</div><div> GstPad *sinkpad;</div><div> GstElement *decoder = (GstElement *) data;</div><div><br></div><div> /* We can now link this pad with the vorbis-decoder sink pad */</div>
<div> g_print ("Dynamic pad created, linking demuxer/decoder\n");</div><div><br></div><div> sinkpad = gst_element_get_static_pad (decoder, "sink");</div><div><br></div><div> gst_pad_link (pad, sinkpad);</div>
<div><br></div><div> gst_object_unref (sinkpad);</div><div>}</div><div><br></div><div><br></div><div><br></div><div>int</div><div>main (int argc,</div><div> char *argv[])</div><div>{</div><div> GMainLoop *loop;</div>
<div><br></div><div> GstElement *pipeline, *source, *demuxer, *decoder, *sink;</div><div> GstBus *bus;</div><div><br></div><div> /* Initialisation */</div><div> gst_init (&argc, &argv);</div><div><br></div><div>
loop = g_main_loop_new (NULL, FALSE);</div><div><br></div><div><br></div><div> /* Check input arguments */</div><div>/* if (argc != 2) {</div><div> g_printerr ("Usage: %s <Ogg/Vorbis filename>\n", argv[0]);</div>
<div> return -1;</div><div> }*/</div><div><br></div><div>/*gst-launch-0.10 dv1394src num-buffers=8192 ! dvdemux ! dvdec ! xvimagesink sync=false*/</div><div> /* Create gstreamer elements */</div><div> pipeline = gst_pipeline_new ("DV_FIREWIRE");</div>
<div> source = gst_element_factory_make ("dv1394src", "dv1394src");</div><div> demuxer = gst_element_factory_make ("dvdemux", "dvdemux");</div><div> decoder = gst_element_factory_make ("dvdec", "dvdec");</div>
<div> sink = gst_element_factory_make ("ximagesink", "ximagesink");</div><div><br></div><div> if (!pipeline || !source || !demuxer || !decoder || !sink) {</div><div> g_printerr ("One element could not be created. Exiting.\n");</div>
<div> return -1;</div><div> }</div><div><br></div><div> /* Set up the pipeline */</div><div><br></div><div> /* we set the input filename to the source element */</div><div> /*g_object_set (G_OBJECT (sink), "sync", FALSE, NULL);*/</div>
<div><br></div><div> /* we add a message handler */</div><div> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));</div><div> gst_bus_add_watch (bus, bus_call, loop);</div><div> gst_object_unref (bus);</div><div><br>
</div><div> /* we add all elements into the pipeline */</div><div> /* file-source | ogg-demuxer | vorbis-decoder | converter | alsa-output */</div><div> gst_bin_add_many (GST_BIN (pipeline), source, demuxer, decoder, sink, NULL);</div>
<div><br></div><div> /* we link the elements together */</div><div> /* file-source -> ogg-demuxer ~> vorbis-decoder -> converter -> alsa-output */</div><div> /* gst_element_link (source, demuxer);*/</div><div>
gst_element_link_many (source, demuxer, decoder, sink, NULL);</div><div> g_signal_connect (demuxer, "pad-added", G_CALLBACK (on_pad_added), decoder);</div><div><br></div><div> /* note that the demuxer will be linked to the decoder dynamically.</div>
<div> The reason is that Ogg may contain various streams (for example</div><div> audio and video). The source pad(s) will be created at run time,</div><div> by the demuxer when it detects the amount and nature of streams.</div>
<div> Therefore we connect a callback function which will be executed</div><div> when the "pad-added" is emitted.*/</div><div><br></div><div><br></div><div> /* Set the pipeline to "playing" state*/</div>
<div> g_print ("Now playing: %s\n", argv[1]);</div><div> gst_element_set_state (pipeline, GST_STATE_PLAYING);</div><div><br></div><div><br></div><div> /* Iterate */</div><div> g_print ("Running...\n");</div>
<div> g_timeout_add (200, (GSourceFunc) cb_print_position, pipeline);</div><div> g_main_loop_run (loop);</div><div><br></div><div><br></div><div> /* Out of the main loop, clean up nicely */</div><div> g_print ("Returned, stopping playback\n");</div>
<div> gst_element_set_state (pipeline, GST_STATE_NULL);</div><div><br></div><div> g_print ("Deleting pipeline\n");</div><div> gst_object_unref (GST_OBJECT (pipeline));</div><div> printf("THE END\n");</div>
<div> return 0;</div><div>}</div><div><br></div><div><br><div class="gmail_quote">On Tue, Oct 27, 2009 at 8:24 PM, Gabriel Duarte <span dir="ltr"><<a href="mailto:confusosk8@gmail.com" target="_blank">confusosk8@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>hello all, I'm trying to convert this pipeline to C, but I'm having problems....</div><div><br></div><div>
<br></div><div>gst-launch-0.10 dv1394src num-buffers=8192 ! dvdemux ! dvdec ! xvimagesink sync=false</div>
<div><br></div><div><br></div><div>I've wrote this code:</div><div><br></div><div><br></div><div><span style="font-family:'Times New Roman';font-size:medium"><pre>#include <string.h> /* for memset () */
#include <gst/gst.h>
static void
cb_handoff (GstElement *fakesrc,
         GstBuffer *buffer,
         GstPad *pad,
         gpointer user_data)
{
static gboolean white = FALSE;
/* this makes the image black/white */
memset (GST_BUFFER_DATA (buffer), white ? 0xff : 0x0,
         GST_BUFFER_SIZE (buffer));
white = !white;
}
gint
main (gint argc,
gchar *argv[])
{
GstElement *pipeline, *fakesrc, *flt, *conv, *videosink;
GMainLoop *loop;
/* init GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* setup pipeline */
pipeline = gst_pipeline_new ("pipeline");
fakesrc = gst_element_factory_make ("fakesrc", "source");
flt = gst_element_factory_make ("capsfilter", "flt");
conv = gst_element_factory_make ("ffmpegcolorspace", "conv");
videosink = gst_element_factory_make ("xvimagesink", "videosink");
/* setup */
g_object_set (G_OBJECT (flt), "caps",
                gst_caps_new_simple ("video/x-raw-rgb",
                                 "width", G_TYPE_INT, 384,
                                 "height", G_TYPE_INT, 288,
                                 "framerate", GST_TYPE_FRACTION, 1, 1,
                                 "bpp", G_TYPE_INT, 16,
                                 "depth", G_TYPE_INT, 16,
                                 "endianness", G_TYPE_INT, G_BYTE_ORDER,
                                 NULL), NULL);
gst_bin_add_many (GST_BIN (pipeline), fakesrc, flt, conv, videosink, NULL);
gst_element_link_many (fakesrc, flt, conv, videosink, NULL);
/* setup fake source */
g_object_set (G_OBJECT (fakesrc),
                "signal-handoffs", TRUE,
                "sizemax", 384 * 288 * 2,
                "sizetype", 2, NULL);
g_signal_connect (fakesrc, "handoff", G_CALLBACK (cb_handoff), NULL);
/* play */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_main_loop_run (loop);
/* clean up */
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}</pre><pre><br></pre><pre><br></pre><pre>Any ideas???</pre><pre>Best regards :D</pre></span></div><div><br></div><div><br></div>
<div><br></div><br clear="all"><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>
</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" 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>
</div></div>
</div></div></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>