Hi Cai,<div><br></div><div><br></div><div>Thanks for you response, I Will try out your suggestion of using the filtered link.</div><div><br></div><div>Sorry there was some typoerror in my code what I shared. </div><div><br>
</div><div>I did initialized the 'resmux' as capasity filter and used the conv not conv1.</div><div><br></div><div>The cocde works for me for mp3 playback in its original settings.</div><div><br></div><div><br></div>
<div> resample = gst_element_factory_make ("audioresample", "audio-resample");</div><div><div> conv = gst_element_factory_make ("audioconvert", "converter1");</div>
<div><font class="Apple-style-span" color="#FF0000"><span class="Apple-tab-span" style="white-space:pre">        </span>resmux = gst_element_factory_make ("capsfilter", "filter");</font></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 (!musicPlayer.playPipeline || !source || !sink ||</div><div> !resample || !resmux || !caps || !conv)</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", filePath, 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><font class="Apple-style-span" color="#FF0000"> if (!demuxer || !decoder || !conv)</font></div><div> {</div><div> g_print ("NO MEM Exiting.\n");</div><div> return 1;</div>
<div> }</div><div><br></div></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(80, 0, 80); ">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>
</span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(80, 0, 80); "><br></span></div><div><div class="gmail_quote">On Thu, Jan 13, 2011 at 7:16 AM, Cai Yuanqing [via GStreamer-devel] <span dir="ltr"><<a href="/user/SendEmail.jtp?type=node&node=3215225&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">
        
                
                 Hi Suresh:
<br> Your application have a little problem. :-)
<br><div><div></div><div><br><br>On 01/12/2011 08:41 PM, Jesu Anuroop Suresh wrote:
</div></div><div><div><div></div><div><div><div class='shrinkable-quote'><br>> Hi Sean,
<br>>
<br>> Yes, what I was trying is to resample the decoded mp3 data 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 work with
<br>> audioresample with the caps filter 'resmux'. This code does 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 ("audio-player");
<br>> source = gst_element_factory_make ("filesrc", "file-source");
<br>> sink = gst_element_factory_make ("alsasink", "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, 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>> }
</div></div></div>resmux is not initialized yet,here maybe some random value,you'd better
</div>remove it from check list.
</div><div><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", "id3-demuxer");
<br>> decoder = gst_element_factory_make ("mad", "mp3-decoder");
<br>>
<br>> if (!demuxer || !decoder || !conv1)
<br></div>conv1 ? dose it should be conv?
<br><div><br>> {
<br>> g_print ("NO MEM Exiting.\n");
<br>> return 1;
<br>> }
<br>>
<br></div><div>> g_object_set (G_OBJECT (resmux), "caps", caps, NULL);
<br>> gst_caps_unref (caps);
<br>>
<br></div>as I said before,resmux haven't initialized ,that's not quite right.
<br>and I suggest you to remove these two lines.
<br><div><br>> /* file-source -> demuxer -> decoder -> alsa-output */
<br>> gst_bin_add_many (GST_BIN (musicPlayer.playPipeline),
<br>> source, demuxer, decoder, conv, resample,
<br>> resmux,sink, NULL);
<br>>
<br>> gst_element_link (source, demuxer);
<br>> gst_element_link_many (decoder, conv, resample,resmux,sink, NULL);
<br></div>You can use gst_element_link_filtered to link resample and sink with
<br>caps instead of this way.
<br>something like:
<br><div> gst_element_link (source, demuxer);
<br></div> 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 alsa-sink");
<br> }
<br><br><div><div><div><div class='shrinkable-quote'><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>> 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>> 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, 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>>
</div></div>I attached my modified source code ,you can try it.
</div>Hope it helps.
</div><br>Thanks.
<br><br><br>--
<br>B.R
<br><br>Cai Yuanqing
<br><br><br>------------------------------------------------------------------------------
<br><div>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=3215098&i=0" 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></div><div><br><img> <strong>test.c</strong> (6K) <a href="http://attachment/3215098/0/test.c" target="_blank" rel="nofollow" link="external">Download Attachment</a></div>
        
        <br>
        <br>
        <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-tp3213586p3215098.html?by-user=t" target="_blank" rel="nofollow" link="external">http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3215098.html</a><div>
<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-tp3213586p3215225.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>