Hi Cai,<div><br></div><div>Thanks for your response.</div><div><br></div><div>Below is the code which works and converts any input stream into 22KHz S16LE.</div><div><br></div><div><br></div><div><div>static gboolean bus_call(GstBus *bus,GstMessage *msg,gpointer data)</div>
<div>{</div><div> GMainLoop *loop = (GMainLoop*)data;</div><div> switch(GST_MESSAGE_TYPE(msg))</div><div> {</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> case GST_MESSAGE_ERROR:</div><div> {</div><div> gchar *debug;</div><div> GError *error;</div>
<div> gst_message_parse_error(msg,&error,&debug);</div><div> g_free(debug);</div><div> g_print("Error: %s\n",error->message);</div><div> g_error_free(error);</div>
<div> g_main_loop_quit(loop);</div><div> break;</div><div> }</div><div> case GST_STATE_CHANGE_READY_TO_NULL:</div><div> default:</div><div> //g_print("Unkown message 0x%x\n",GST_MESSAGE_TYPE(msg));</div>
<div> break;</div><div> }</div><div> return TRUE;</div><div>}</div></div><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>
<div><br></div><div><div>int main(int argc,char *argv[])</div><div>{</div><div> GMainLoop *playerloop;</div><div> GstBus *playerbus;</div><div><br></div><div> GstElement *pipeline,*source, *demuxer, *decoder, *conv, *sink, *resample,*resmux;</div>
<div> GstCaps *caps;</div><div><br></div><div> playerloop = g_main_loop_new(NULL,FALSE);</div><div><br></div><div> gst_init(&argc,&argv);</div><div><br></div><div> /* Create gstreamer elements */</div>
<div> pipeline = gst_pipeline_new ("audio-player");</div><div> source = gst_element_factory_make ("filesrc", "file-source");</div><div> sink = gst_element_factory_make ("alsasink", "audio-output");</div>
<div> resample = gst_element_factory_make ("audioresample", "audio-resample");</div><div> conv = gst_element_factory_make ("audioconvert", "converter1");</div><div> resmux = gst_element_factory_make ("capsfilter", "filter");</div>
<div><br></div><div> caps = gst_caps_new_simple ("audio/x-raw-int",</div><div> "width", G_TYPE_INT, 16,</div><div> "depth", G_TYPE_INT, 16,</div>
<div> "rate", G_TYPE_INT, 22050,</div><div> "channels",G_TYPE_INT, 2, NULL</div><div> );</div><div><br></div>
<div> if (!pipeline || !source || !sink ||</div><div> !resample || !caps || !conv || !resmux )</div><div> {</div><div> g_print ("NO MEM Exiting.\n");</div><div> return 1;</div><div> }</div>
<div><br></div><div> /* we set the input filename to the source element */</div><div> g_object_set (G_OBJECT (source), "location", argv[1], NULL);</div><div><br></div><div> demuxer = gst_element_factory_make ("id3demux", "id3-demuxer");</div>
<div> decoder = gst_element_factory_make ("mad", "mp3-decoder");</div><div><br></div><div> if (!demuxer || !decoder || !conv)</div><div> {</div><div> g_print ("NO MEM Exiting.\n");</div>
<div> return 1;</div><div> }</div><div><br></div><div> g_object_set (G_OBJECT (resmux), "caps", caps, NULL);</div><div> gst_caps_unref (caps);</div></div><div><div> /* file-source -> demuxer -> decoder -> alsa-output */</div>
<div> gst_bin_add_many (GST_BIN (pipeline),</div><div> source, demuxer, decoder, conv, resample, resmux, sink, NULL);</div><div><br></div><div> gst_element_link (source, demuxer);</div><div> gst_element_link_many (decoder, conv, resample,resmux,NULL);</div>
<div><br></div><div> if ( !gst_element_link_filtered(resmux,sink,caps) ){</div><div> g_printerr("Failed to link elements resample and alsa-sink");</div><div> }</div><div><br></div><div> g_signal_connect (demuxer, "pad-added", G_CALLBACK (on_pad_added), decoder);</div>
<div><br></div><div> playerbus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));</div><div> gst_bus_add_watch(playerbus,bus_call,playerloop);</div><div> gst_object_unref(playerbus);</div><div><br></div><div> gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);</div>
<div> g_main_loop_run(playerloop);</div><div><br></div><div> gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);</div><div> gst_object_unref(GST_OBJECT(pipeline));</div><div><br></div><div> g_print("Exit\n");</div>
<div> return 0;</div><div>}</div></div><div><br></div><div><br></div><div><br></div><div><br clear="all">With Warm Regards<br>Jesu Anuroop Suresh <br><br>"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction."<br>
"Anyone who has never made a mistake has never tried anything new."<br><br><br><br><br>
<br><br><div class="gmail_quote">On Mon, Jan 17, 2011 at 7:54 AM, Cai Yuanqing [via GStreamer-devel] <span dir="ltr"><<a href="/user/SendEmail.jtp?type=node&node=3220749&i=0" target="_top" rel="nofollow">[hidden email]</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">
        
                
                 Hi,
<br><br>On 01/13/2011 01:39 PM, Anuroop Jesu wrote:
</div><div class="im"><div><div class='shrinkable-quote'><br>> Hi ,
<br>>
<br>> I Tried the suggestion provided for the by Cai. Thanks for the code Cai.
<br>>
<br>> It works something like this It only allows to playback the 22KHz
<br>> S16LE audio.
<br>>
<br>> What I was trying is to convert the any input format into a 22KHz
<br>> S16LE so I can mux it with other stream of the same property and mux
<br>> multiple streams using alsasink plug:dmix.
</div></div><div class="im">I see what you mean :-)
</div>I tried pipeline like this:
<br></div>gst-launch-0.10 filesrc location=yellow.mp3 ! id3demux ! mad !
<br>audioconvert ! audioresample !
<br><div class="im">'audio/x-raw-int,width=16,depth=16,rate=22050,channels=2,endianness=1234,signed=true'
<br>! alsasink
<br><br>It works well to first decode any type of mp3 files into PCM,and then
<br>re-sample them into
<br>'audio/x-raw-int,width=16,depth=16,rate=22050,channels=2,endianness=1234,signed=true.
<br>So you can playback this stream ,or you can replace 'alsasink' to other
<br>elements:
<br><br>$ file yellow.mp3
<br>yellow.mp3: Audio file with ID3 version 2.3.0, contains: MPEG ADTS,
<br>layer III, v1, 128 kbps, 44.1 kHz, JntStereo
<br><br></div>$ gst-launch-0.10 filesrc location=yellow.mp3 ! id3demux ! mad !
<br>audioconvert ! audioresample !
<br><div class="im">'audio/x-raw-int,width=16,depth=16,rate=22050,channels=2,endianness=1234,signed=true'
<br>! lame ! filesink location=haha.mp3
<br><br>$ file haha.mp3
<br>haha.mp3: MPEG ADTS, layer III, v2, 128 kbps, 22.05 kHz, JntStereo
<br><br><br>The pipeline above turn your stream to encode int a mp3 file with
<br>property as
<br>'audio/x-raw-int,width=16,depth=16,rate=22050,channels=2,endianness=1234,signed=true'.
<br><br>Just add elements behind audioresample and caps in the C code.
<br><br>Hope it helps :-)
<br><br>Thanks.
<br><br><br><br></div><div><br>>
<br><div class="im">> With Warm Regards
<div class='shrinkable-quote'><br>> Jesu Anuroop Suresh
<br>>
<br>> "Any intelligent fool can make things bigger, more complex, and more
<br>> violent. It takes a touch of genius -- and a lot of courage -- to move
<br>> in the opposite direction."
<br>> "Anyone who has never made a mistake has never tried anything new."
<br>>
<br>>
<br>>
<br>>
<br>>
<br>>
</div></div><div><div></div><div class="h5">> On Thu, Jan 13, 2011 at 9:51 AM, Jesu Anuroop Suresh <<a href="http://user/SendEmail.jtp?type=node&node=3220635&i=0" rel="nofollow" target="_blank" link="external">[hidden email]</a>
<div class='shrinkable-quote'><br>> <mailto:<a href="http://user/SendEmail.jtp?type=node&node=3220635&i=1" rel="nofollow" target="_blank" link="external">[hidden email]</a>>> wrote:
<br>>
<br>> Hi Cai,
<br>>
<br>>
<br>> Thanks for you response, I Will try out your suggestion of using
<br>> the filtered link.
<br>>
<br>> Sorry there was some typoerror in my code what I shared.
<br>>
<br>> I did initialized the 'resmux' as capasity filter and used the
<br>> conv not conv1.
<br>>
<br>> The cocde works for me for mp3 playback in its original settings.
<br>>
<br>>
<br>> resample = gst_element_factory_make ("audioresample",
<br>> "audio-resample");
<br>> conv = gst_element_factory_make ("audioconvert",
<br>> "converter1");
<br>> resmux = gst_element_factory_make ("capsfilter", "filter");
<br>>
<br>> caps = gst_caps_new_simple ("audio/x-raw-int",
<br>> "width", G_TYPE_INT, 16,
<br>> "depth", G_TYPE_INT, 16,
<br>> "rate", G_TYPE_INT, 22050,
<br>> "channels",G_TYPE_INT, 2, NULL
<br>> );
<br>>
<br>> if (!musicPlayer.playPipeline || !source || !sink ||
<br>> !resample || !resmux || !caps || !conv)
<br>> {
<br>> g_print ("NO MEM Exiting.\n");
<br>> return 1;
<br>> }
<br>>
<br>> /* we set the input filename to the source element */
<br>> g_object_set (G_OBJECT (source), "location", filePath, NULL);
<br>>
<br>> demuxer = gst_element_factory_make ("id3demux",
<br>> "id3-demuxer");
<br>> decoder = gst_element_factory_make ("mad", "mp3-decoder");
<br>>
<br>> if (!demuxer || !decoder || !conv)
<br>> {
<br>> g_print ("NO MEM Exiting.\n");
<br>> return 1;
<br>> }
<br>>
<br>> With Warm Regards
<br>> Jesu Anuroop Suresh
<br>>
<br>> "Any intelligent fool can make things bigger, more complex, and
<br>> more violent. It takes a touch of genius -- and a lot of courage
<br>> -- to move in the opposite direction."
<br>> "Anyone who has never made a mistake has never tried anything new."
<br>>
<br>> On Thu, Jan 13, 2011 at 7:16 AM, Cai Yuanqing [via
<br>> GStreamer-devel] <[hidden email]
</div></div></div><div><div></div><div class="h5">> <<a href="http://user/SendEmail.jtp?type=node&node=3215225&i=0" rel="nofollow" link="external" target="_blank">http://user/SendEmail.jtp?type=node&node=3215225&i=0</a>>> wrote:
<div class='shrinkable-quote'><br>>
<br>> Hi Suresh:
<br>> Your application have a little problem. :-)
<br>>
<br>>
<br>> On 01/12/2011 08:41 PM, Jesu Anuroop Suresh wrote:
<br>>
<br>> > Hi Sean,
<br>> >
<br>> > Yes, what I was trying is to resample the decoded mp3 data
<br>> to the
<br>> > fixed (22KHZ S16LE) formate,
<br>> >
<br>> > no matter what is the input rate using a C application.
<br>> >
<br>> > Thanks for your response.
<br>> >
<br>> > Here is the piece of the code for the same but it does not
<br>> work with
<br>> > audioresample with the caps filter 'resmux'. This code does
<br>> work
<br>> > without the caps filter 'resmux'.
<br>> >
<br>> > GstElement *source, *demuxer, *decoder, *conv, *sink,
<br>> > *resample, *resmux;
<br>> > GstCaps *caps;
<br>> >
<br>> > gst_init(NULL, NULL);
<br>> >
<br>> > /* Create gstreamer elements */
<br>> > musicPlayer.playPipeline = gst_pipeline_new
<br>> ("audio-player");
<br>> > source = gst_element_factory_make ("filesrc",
<br>> "file-source");
<br>> > sink = gst_element_factory_make ("alsasink",
<br>> "audio-output");
<br>> > resample = gst_element_factory_make ("audioresample",
<br>> > "audio-resample");
<br>> > conv = gst_element_factory_make ("audioconvert",
<br>> > "converter1");
<br>> >
<br>> > caps = gst_caps_new_simple ("audio/x-raw-int",
<br>> > "width", G_TYPE_INT, 16,
<br>> > "depth", G_TYPE_INT, 16,
<br>> > "rate", G_TYPE_INT,
<br>> 22050,
<br>> > "channels",G_TYPE_INT,
<br>> 2, NULL
<br>> > );
<br>> >
<br>> > if (!musicPlayer.playPipeline || !source || !sink ||
<br>> > !resample || !resmux || !caps || !conv)
<br>> > {
<br>> > g_print ("NO MEM Exiting.\n");
<br>> > return 1;
<br>> > }
<br>> resmux is not initialized yet,here maybe some random
<br>> value,you'd better
<br>> remove it from check list.
<br>>
<br>> >
<br>> > /* we set the input filename to the source element */
<br>> > g_object_set (G_OBJECT (source), "location",
<br>> filePath, NULL);
<br>> >
<br>> > demuxer = gst_element_factory_make ("id3demux",
<br>> "id3-demuxer");
<br>> > decoder = gst_element_factory_make ("mad",
<br>> "mp3-decoder");
<br>> >
<br>> > if (!demuxer || !decoder || !conv1)
<br>> conv1 ? dose it should be conv?
<br>>
<br>> > {
<br>> > g_print ("NO MEM Exiting.\n");
<br>> > return 1;
<br>> > }
<br>> >
<br>> > g_object_set (G_OBJECT (resmux), "caps", caps, NULL);
<br>> > gst_caps_unref (caps);
<br>> >
<br>> as I said before,resmux haven't initialized ,that's not quite
<br>> right.
<br>> and I suggest you to remove these two lines.
<br>>
<br>> > /* file-source -> demuxer -> decoder ->
<br>> alsa-output */
<br>> > gst_bin_add_many (GST_BIN (musicPlayer.playPipeline),
<br>> > source, demuxer, decoder, conv,
<br>> resample,
<br>> > resmux,sink, NULL);
<br>> >
<br>> > gst_element_link (source, demuxer);
<br>> > gst_element_link_many (decoder, conv,
<br>> resample,resmux,sink, NULL);
<br>> You can use gst_element_link_filtered to link resample and
<br>> sink with
<br>> caps instead of this way.
<br>> something like:
<br>> gst_element_link (source, demuxer);
<br>> gst_element_link_many (decoder, conv, resample, NULL);
<br>> if ( !gst_element_link_filtered(resample,sink,caps) ){
<br>> g_printerr("Failed to link elements resample and
<br>> alsa-sink");
<br>> }
<br>>
<br>>
<br>> > g_signal_connect (demuxer, "pad-added", G_CALLBACK
<br>> > (on_pad_added), decoder);
<br>> >
<br>> > GstBus *bus =
<br>> > gst_pipeline_get_bus(GST_PIPELINE(musicPlayer.playPipeline));
<br>> > gst_bus_add_watch(bus, bus_call, NULL);
<br>> > gst_object_unref(bus);
<br>> >
<br>> >
<br>> gst_element_set_state(GST_ELEMENT(musicPlayer.playPipeline),
<br>> > GST_STATE_PLAYING);
<br>> >
<br>> > musicPlayer.playLoop = g_main_loop_new(NULL, FALSE);
<br>> >
<br>> > g_main_loop_run(musicPlayer.playLoop);
<br>> >
<br>> >
<br>> gst_element_set_state(GST_ELEMENT(musicPlayer.playPipeline),
<br>> > GST_STATE_NULL);
<br>> > gst_object_unref(GST_OBJECT(musicPlayer.playPipeline));
<br>> >
<br>> >
<br>> >
<br>> >
<br>> > With Warm Regards
<br>> > Jesu Anuroop Suresh
<br>> >
<br>> > "Any intelligent fool can make things bigger, more complex,
<br>> and more
<br>> > violent. It takes a touch of genius -- and a lot of courage
<br>> -- to move
<br>> > in the opposite direction."
<br>> > "Anyone who has never made a mistake has never tried
<br>> anything new."
<br>> >
<br>> >
<br>> I attached my modified source code ,you can try it.
<br>> Hope it helps.
<br>>
<br>> Thanks.
<br>>
<br>>
<br>> --
<br>> B.R
<br>>
<br>> Cai Yuanqing
<br>>
<br>>
<br>> ------------------------------------------------------------------------------
<br>>
<br>> Protect Your Site and Customers from Malware Attacks
<br>> Learn about various malware tactics and how to avoid them.
<br>> Understand
<br>> malware threats, the impact they can have on your business,
<br>> and how you
<br>> can protect your company and customers by using code signing.
<br>> <a href="http://p.sf.net/sfu/oracle-sfdevnl" rel="nofollow" link="external" target="_blank">http://p.sf.net/sfu/oracle-sfdevnl</a><br>> _______________________________________________
<br>> gstreamer-devel mailing list
<br>> [hidden email]
</div></div></div><div class="im">> <<a href="http://user/SendEmail.jtp?type=node&node=3215098&i=0" rel="nofollow" link="external" target="_blank">http://user/SendEmail.jtp?type=node&node=3215098&i=0</a>>
<br></div><div class="im">> <a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" rel="nofollow" link="external" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>
>
<br>>
<br></div>> ------------------------------------------------------------------------
<br><div class="im">> View message @
<br>> <a href="http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3215098.html?by-user=t&by-user=t" rel="nofollow" link="external" target="_blank">http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3215098.html</a><br>
</div>> <<a href="http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3215098.html?by-user=t&by-user=t&by-user=t" rel="nofollow" link="external" target="_blank">http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3215098.html?by-user=t</a>>
<br><div class="im">>
<br>>
<br>> To unsubscribe from audioresample, click here
<br></div><div class="im">> <<a href="http://gstreamer-devel.966125.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3213586&code=amVzdWFzQGdtYWlsLmNvbXwzMjEzNTg2fDcwOTc3MzYyOA==&by-user=t&by-user=t&by-user=t" rel="nofollow" link="external" target="_blank">http://gstreamer-devel.966125.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3213586&code=amVzdWFzQGdtYWlsLmNvbXwzMjEzNTg2fDcwOTc3MzYyOA==&by-user=t</a>>.
<br>>
<br>>
<br>>
<br>>
<br>> ------------------------------------------------------------------------
<br></div><div class="im">> View this message in context: Re: audioresample
<br></div>> <<a href="http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3215225.html?by-user=t&by-user=t" rel="nofollow" link="external" target="_blank">http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3215225.html</a>>
<br><div class="im">>
<br>>
<br>> Sent from the GStreamer-devel mailing list archive
<br></div>> <<a href="http://gstreamer-devel.966125.n4.nabble.com/?by-user=t&by-user=t" rel="nofollow" link="external" target="_blank">http://gstreamer-devel.966125.n4.nabble.com/</a>> at Nabble.com.
<br><div class="im">>
<br>> ------------------------------------------------------------------------------
<br>> Protect Your Site and Customers from Malware Attacks
<br>> Learn about various malware tactics and how to avoid them. Understand
<br>> malware threats, the impact they can have on your business, and
<br>> how you
<br>> can protect your company and customers by using code signing.
<br>> <a href="http://p.sf.net/sfu/oracle-sfdevnl" rel="nofollow" link="external" target="_blank">http://p.sf.net/sfu/oracle-sfdevnl</a><br>> _______________________________________________
<br>> gstreamer-devel mailing list
<br></div>> <a href="http://user/SendEmail.jtp?type=node&node=3220635&i=2" rel="nofollow" target="_blank" link="external">[hidden email]</a>
<br>> <mailto:<a href="http://user/SendEmail.jtp?type=node&node=3220635&i=3" rel="nofollow" target="_blank" link="external">[hidden email]</a>>
<br><div class="im">> <a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" rel="nofollow" link="external" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>>
<br>>
</div></div><div class="im"><br><br>--
<br>B.R
<br><br>Cai Yuanqing
<br><br><br>------------------------------------------------------------------------------
<br>Protect Your Site and Customers from Malware Attacks
<br>Learn about various malware tactics and how to avoid them. Understand
<br>malware threats, the impact they can have on your business, and how you
<br>can protect your company and customers by using code signing.
<br><a href="http://p.sf.net/sfu/oracle-sfdevnl" rel="nofollow" link="external" target="_blank">http://p.sf.net/sfu/oracle-sfdevnl</a><br>_______________________________________________
<br>gstreamer-devel mailing list
<br><a href="http://user/SendEmail.jtp?type=node&node=3220635&i=4" rel="nofollow" target="_blank" link="external">[hidden email]</a>
<br><a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" rel="nofollow" link="external" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>
        
        <br>
        <br>
        </div><hr noshade size="1" color="#cccccc">
        <div style="color:#666666;font:11px tahoma,geneva,helvetica,arial,sans-serif">
                View message @ <a href="http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3220635.html?by-user=t" target="_blank" rel="nofollow" link="external">http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3220635.html</a><div class="im">
<br>
                
                To unsubscribe from audioresample, <a href="http://gstreamer-devel.966125.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3213586&code=amVzdWFzQGdtYWlsLmNvbXwzMjEzNTg2fDcwOTc3MzYyOA==&by-user=t" target="_blank" rel="nofollow" link="external">click here</a>.
        </div></div></blockquote></div><br></div>
<br><hr align="left" width="300">
View this message in context: <a href="http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3220749.html">Re: audioresample</a><br>
Sent from the <a href="http://gstreamer-devel.966125.n4.nabble.com/">GStreamer-devel mailing list archive</a> at Nabble.com.<br>