<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Hi Sangita,<BR>
<BR>
I dont have necessary resources to run this code. But, few quick observations:-<BR>
<BR>
1. In the command line you have not mentioned audio decoder, but in the code you are trying to audio related stuff link. <BR>
Check if this works as per your expectations.<BR>
2. It would be good to check the return values especially for *_get_pad and *_link functions.<BR>
<BR>
BR,<BR>
Pavan.<BR><BR><BR>
<BLOCKQUOTE>
<HR>
Date: Tue, 25 Sep 2007 12:18:19 +0000<BR>From: sangitapithadia@gmail.com<BR>To: gstreamer-devel@lists.sourceforge.net<BR>Subject: [gst-devel] gstreamer problem<BR><BR>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><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><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></BLOCKQUOTE><br /><hr />Download the latest version of Windows Live Messenger NOW! <a href='http://get.live.com/en-ie/messenger/overview' target='_new'>Click here!</a></body>
</html>