Hi,<br>
<br>
I m trying to play MPEG TS using gstreamer pipeline. <br>
This is the pipeline which i have used to playback the file. It works fine.<br>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Kate, the KDE Advanced Text Editor">
<pre>gst-launch -v filesrc location=/root/GStremerDir/gstreamer-0.10.13/ed24p_00.ts ! ffdemux_mpegts ! ffdec_mpeg2video ! queue ! videoscale ! ffmpegcolorspace ! xvimagesink </pre><br>
Same thing i tried to do using the code but it doesnt play.<br>
my code is like..<br>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Kate, the KDE Advanced Text Editor">
<pre><span style="color: rgb(0, 128, 0);">#include<stdio.h></span>
<span style="color: rgb(0, 128, 0);">#define SOURCE "filesrc"</span>
<span style="color: rgb(0, 128, 0);">#define VSINK "xvimagesink"</span>
<span style="color: rgb(0, 128, 0);">#define ASINK "alsasink"</span>
<span style="color: rgb(0, 128, 0);">#include <stdlib.h></span>
<span style="color: rgb(0, 128, 0);">#include <glib.h></span>
<span style="color: rgb(128, 128, 128);"><i>//#include <gtk/gtk.h></i></span>
<span style="color: rgb(0, 128, 0);">#include <gst/gst.h></span>
<span style="color: rgb(0, 128, 0);">#include <string.h></span>
<span style="color: rgb(128, 0, 0);">const</span> gchar * location = <span style="color: rgb(221, 0, 0);">"file:///root/GStremerDir/ed24p_00.ts"</span>;
<span style="color: rgb(128, 0, 0);">static</span> GList *seekable_pads = NULL;
<span style="color: rgb(128, 0, 0);">static</span> GList *rate_pads = NULL;
<span style="color: rgb(128, 0, 0);">static</span> GstElement *pipeline;
<span style="color: rgb(128, 0, 0);">static</span> GList *seekable_elements = NULL;
<b>typedef</b> <b>struct</b>
{
        <span style="color: rgb(128, 0, 0);">const</span> gchar *padname;
        GstPad *target;
        GstElement *bin;
}
dyn_link;
<span style="color: rgb(128, 0, 0);">static</span> gboolean
bus_call (GstBus *bus,
         GstMessage *msg,
         gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
<b>switch</b> (GST_MESSAGE_TYPE (msg)) {
<b>case</b> GST_MESSAGE_EOS:
g_print (<span style="color: rgb(221, 0, 0);">"End-of-stream</span><span style="color: rgb(255, 0, 255);">\n</span><span style="color: rgb(221, 0, 0);">"</span>);
g_main_loop_quit (loop);
<b>break</b>;
<b>case</b> GST_MESSAGE_ERROR: {
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
g_print (<span style="color: rgb(221, 0, 0);">"Error: %s</span><span style="color: rgb(255, 0, 255);">\n</span><span style="color: rgb(221, 0, 0);">"</span>, err->message);
g_error_free (err);
g_main_loop_quit (loop);
<b>break</b>;
}
<b>default</b>:
<b>break</b>;
}
}
<span style="color: rgb(128, 0, 0);">static</span> GstElement *
gst_element_factory_make_or_warn (gchar * type, gchar * name)
{
        GstElement *element = gst_element_factory_make (type, name);
        
        <b>if</b> (!element) {
        g_warning (<span style="color: rgb(221, 0, 0);">"Failed to create element %s of type %s"</span>, name, type);
        }
        
        <b>return</b> element;
}
<span style="color: rgb(128, 0, 0);">static</span> <span style="color: rgb(128, 0, 0);">void</span> dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data)
{
        gchar *padname;
        dyn_link *connect = (dyn_link *) data;
        
        padname = gst_pad_get_name (newpad);
        
        <b>if</b> (connect->padname == NULL || !strcmp (padname, connect->padname)) {
        <b>if</b> (connect->bin)
        gst_bin_add (GST_BIN (pipeline), connect->bin);
        gst_pad_link (newpad, connect->target);
        
        seekable_pads = g_list_prepend (seekable_pads, newpad);
        rate_pads = g_list_prepend (rate_pads, newpad);
        }
        g_free (padname);
}
<span style="color: rgb(128, 0, 0);">static</span> <span style="color: rgb(128, 0, 0);">void</span> setup_dynamic_link (GstElement * element, <span style="color: rgb(128, 0, 0);">const</span> gchar * padname,
GstPad * target, GstElement * bin)
{
        dyn_link *connect;
        
        connect = g_new0 (dyn_link, <span style="color: rgb(0, 0, 255);">1</span>);
        connect->padname = g_strdup (padname);
        connect->target = target;
        connect->bin = bin;
        
        g_signal_connect (G_OBJECT (element), <span style="color: rgb(221, 0, 0);">"pad-added"</span>, G_CALLBACK (dynamic_link),
        connect);
}
<span style="color: rgb(128, 0, 0);">int</span> main(<span style="color: rgb(128, 0, 0);">int</span> argc,<span style="color: rgb(128, 0, 0);">char</span> *argv[])
{
        <span style="color: rgb(128, 0, 0);">static</span> GstElement *bin;        
        GstBus *bus;
        GMainLoop *loop;
        GstElement *pipeline, *audio_bin, *video_bin;
        GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter;
        GstElement *audiosink, *videosink;
        GstElement *a_queue, *v_queue, *v_scale;
        GstPad *seekable;
        GstPad *pad;
        
        gst_init (&argc, &argv);
        loop = g_main_loop_new (NULL, FALSE);
        <b>if</b> (argc != <span style="color: rgb(0, 0, 255);">2</span>)
        {
                g_print (<span style="color: rgb(221, 0, 0);">"Usage: %s <AVI file></span><span style="color: rgb(255, 0, 255);">\n</span><span style="color: rgb(221, 0, 0);">"</span>, argv[<span style="color: rgb(0, 0, 255);">
0</span>]);
                <b>return</b> -<span style="color: rgb(0, 0, 255);">1</span>;
        }
        pipeline = gst_pipeline_new (<span style="color: rgb(221, 0, 0);">"app"</span>);
        
        src = gst_element_factory_make_or_warn (SOURCE, <span style="color: rgb(221, 0, 0);">"src"</span>);
        g_object_set (G_OBJECT (src), <span style="color: rgb(221, 0, 0);">"location"</span>, argv[<span style="color: rgb(0, 0, 255);">1</span>], NULL);
        
        <span style="color: rgb(128, 128, 128);"><i>//demux = gst_element_factory_make_or_warn ("mpegdemux", "demux");</i></span>
        demux = gst_element_factory_make_or_warn (<span style="color: rgb(221, 0, 0);">"ffdemux_mpegts"</span>, <span style="color: rgb(221, 0, 0);">"demux"</span>);
        
        gst_bin_add (GST_BIN (pipeline), src);
        gst_bin_add (GST_BIN (pipeline), demux);
        gst_element_link (src, demux);
        
        audio_bin = gst_bin_new (<span style="color: rgb(221, 0, 0);">"a_decoder_bin"</span>);
        a_decoder = gst_element_factory_make_or_warn (<span style="color: rgb(221, 0, 0);">"mad"</span>, <span style="color: rgb(221, 0, 0);">"a_dec"</span>);
        a_queue = gst_element_factory_make_or_warn (<span style="color: rgb(221, 0, 0);">"queue"</span>, <span style="color: rgb(221, 0, 0);">"a_queue"</span>);
        audiosink = gst_element_factory_make_or_warn (ASINK, <span style="color: rgb(221, 0, 0);">"a_sink"</span>);
        gst_bin_add (GST_BIN (audio_bin), a_decoder);
        gst_bin_add (GST_BIN (audio_bin), a_queue);
        gst_bin_add (GST_BIN (audio_bin), audiosink);
        
        gst_element_link (a_decoder, a_queue);
        gst_element_link (a_queue, audiosink);
        
        gst_bin_add (GST_BIN (pipeline), audio_bin);
        
        pad = gst_element_get_pad (a_decoder, <span style="color: rgb(221, 0, 0);">"sink"</span>);
        gst_element_add_pad (audio_bin, gst_ghost_pad_new (<span style="color: rgb(221, 0, 0);">"sink"</span>, pad));
        gst_object_unref (pad);
        
        setup_dynamic_link (demux, <span style="color: rgb(221, 0, 0);">"audio_c0"</span>, gst_element_get_pad (audio_bin,
                <span style="color: rgb(221, 0, 0);">"sink"</span>), NULL);
        
        video_bin = gst_bin_new (<span style="color: rgb(221, 0, 0);">"v_decoder_bin"</span>);
        v_decoder = gst_element_factory_make_or_warn (<span style="color: rgb(221, 0, 0);">"mpeg2dec"</span>, <span style="color: rgb(221, 0, 0);">"v_dec"</span>);
        v_queue = gst_element_factory_make_or_warn (<span style="color: rgb(221, 0, 0);">"queue"</span>, <span style="color: rgb(221, 0, 0);">"v_queue"</span>);
        v_scale = gst_element_factory_make_or_warn (<span style="color: rgb(221, 0, 0);">"videoscale"</span>, <span style="color: rgb(221, 0, 0);">"v_scale"</span>);
        v_filter = gst_element_factory_make_or_warn (<span style="color: rgb(221, 0, 0);">"ffmpegcolorspace"</span>, <span style="color: rgb(221, 0, 0);">"v_filter"</span>);
        videosink = gst_element_factory_make_or_warn (VSINK, <span style="color: rgb(221, 0, 0);">"v_sink"</span>);
        
        gst_bin_add (GST_BIN (video_bin), v_decoder);
        gst_bin_add (GST_BIN (video_bin), v_queue);
        gst_bin_add (GST_BIN (video_bin), v_scale);
        gst_bin_add (GST_BIN (video_bin), v_filter);
        gst_bin_add (GST_BIN (video_bin), videosink);
        
        gst_element_link (v_decoder, v_queue);
        gst_element_link (v_queue, v_scale);
        gst_element_link (v_scale, v_filter);
        gst_element_link (v_filter, videosink);
        
        gst_bin_add (GST_BIN (pipeline), video_bin);
        
        pad = gst_element_get_pad (v_decoder, <span style="color: rgb(221, 0, 0);">"sink"</span>);
        gst_element_add_pad (video_bin, gst_ghost_pad_new (<span style="color: rgb(221, 0, 0);">"sink"</span>, pad));
        gst_object_unref (pad);
        
        setup_dynamic_link (demux, <span style="color: rgb(221, 0, 0);">"video_e0"</span>, gst_element_get_pad (video_bin,
                <span style="color: rgb(221, 0, 0);">"sink"</span>), NULL);
        
        /*seekable = gst_element_get_pad (v_filter, <span style="color: rgb(221, 0, 0);">"src"</span>);
        seekable_pads = g_list_prepend (seekable_pads, seekable);
        rate_pads = g_list_prepend (rate_pads, seekable);
        rate_pads =
        g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, <span style="color: rgb(221, 0, 0);">"sink"</span>));*/
        bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
        gst_bus_add_watch (bus, bus_call, loop);
        
        gst_element_set_state (pipeline, GST_STATE_PLAYING);
        <span style="color: rgb(128, 128, 128);"><i>/* now run */</i></span>
        g_main_loop_run (loop);
        gst_element_set_state (pipeline, GST_STATE_NULL);
        gst_object_unref (GST_OBJECT (pipeline));
        gst_object_unref (bus);
        exit (<span style="color: rgb(0, 0, 255);">0</span>);
}
<span style="color: rgb(0, 128, 0);"></span></pre>Can anyone tell me what can be the cause of this.<br>
<br>
Thanks in advance.<br>