[gst-devel] audioresample

Jesu Anuroop Suresh jesuas at gmail.com
Thu Jan 13 05:21:12 CET 2011


Hi Cai,


Thanks for you response, I Will try out your suggestion of using the
filtered link.

Sorry there was some typoerror in my code what I shared.

I did initialized the 'resmux' as capasity filter and used the conv not
conv1.

The cocde works for me for mp3 playback in its original settings.


        resample = gst_element_factory_make ("audioresample",
"audio-resample");
        conv     = gst_element_factory_make ("audioconvert",  "converter1");
resmux   = gst_element_factory_make ("capsfilter", "filter");

        caps = gst_caps_new_simple ("audio/x-raw-int",
                                     "width", G_TYPE_INT, 16,
                                     "depth", G_TYPE_INT, 16,
                                     "rate",  G_TYPE_INT, 22050,
                                     "channels",G_TYPE_INT, 2, NULL
                                     );

        if (!musicPlayer.playPipeline || !source || !sink ||
            !resample || !resmux || !caps || !conv)
        {
            g_print ("NO MEM Exiting.\n");
            return 1;
        }

        /* we set the input filename to the source element */
        g_object_set (G_OBJECT (source), "location", filePath, NULL);

        demuxer  = gst_element_factory_make ("id3demux", "id3-demuxer");
        decoder  = gst_element_factory_make ("mad", "mp3-decoder");

         if (!demuxer || !decoder || !conv)
         {
                    g_print ("NO MEM Exiting.\n");
                    return 1;
          }

With Warm Regards
Jesu Anuroop Suresh

"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."
"Anyone who has never made a mistake has never tried anything new."

On Thu, Jan 13, 2011 at 7:16 AM, Cai Yuanqing [via GStreamer-devel] <
ml-node+3215098-821959213-203210 at n4.nabble.com<ml-node%2B3215098-821959213-203210 at n4.nabble.com>
> wrote:

>   Hi Suresh:
>      Your application have a little problem. :-)
>
>
> On 01/12/2011 08:41 PM, Jesu Anuroop Suresh wrote:
>
> > Hi Sean,
> >
> > Yes, what I was trying is to resample the decoded mp3 data to the
> > fixed (22KHZ S16LE) formate,
> >
> > no matter what is the input rate using a C application.
> >
> > Thanks for your response.
> >
> > Here is the piece of the code for the same but it does not work  with
> > audioresample with the caps filter 'resmux'. This code does work
> > without the caps filter 'resmux'.
> >
> >         GstElement *source, *demuxer, *decoder, *conv, *sink,
> > *resample, *resmux;
> >         GstCaps *caps;
> >
> >         gst_init(NULL, NULL);
> >
> >         /* Create gstreamer elements */
> >         musicPlayer.playPipeline = gst_pipeline_new ("audio-player");
> >         source   = gst_element_factory_make ("filesrc", "file-source");
> >         sink     = gst_element_factory_make ("alsasink", "audio-output");
>
> >         resample = gst_element_factory_make ("audioresample",
> > "audio-resample");
> >         conv     = gst_element_factory_make ("audioconvert",
> >  "converter1");
> >
> >         caps = gst_caps_new_simple ("audio/x-raw-int",
> >                                      "width", G_TYPE_INT, 16,
> >                                      "depth", G_TYPE_INT, 16,
> >                                      "rate",  G_TYPE_INT, 22050,
> >                                      "channels",G_TYPE_INT, 2, NULL
> >                                      );
> >
> >         if (!musicPlayer.playPipeline || !source || !sink ||
> >             !resample || !resmux || !caps || !conv)
> >         {
> >             g_print ("NO MEM Exiting.\n");
> >             return 1;
> >         }
> resmux is not initialized yet,here maybe some random value,you'd better
> remove it from check list.
>
> >
> >         /* we set the input filename to the source element */
> >         g_object_set (G_OBJECT (source), "location", filePath, NULL);
> >
> >         demuxer  = gst_element_factory_make ("id3demux", "id3-demuxer");
> >         decoder  = gst_element_factory_make ("mad", "mp3-decoder");
> >
> >          if (!demuxer || !decoder || !conv1)
> conv1 ? dose it should be conv?
>
> >          {
> >                     g_print ("NO MEM Exiting.\n");
> >                     return 1;
> >           }
> >
> >          g_object_set (G_OBJECT (resmux), "caps", caps, NULL);
> >          gst_caps_unref (caps);
> >
> as I said before,resmux haven't initialized ,that's not quite right.
> and I suggest you to remove these two lines.
>
> >          /* file-source -> demuxer -> decoder ->  alsa-output */
> >         gst_bin_add_many (GST_BIN (musicPlayer.playPipeline),
> >                          source, demuxer, decoder, conv, resample,
> > resmux,sink, NULL);
> >
> >         gst_element_link (source, demuxer);
> >         gst_element_link_many (decoder, conv, resample,resmux,sink,
> NULL);
> You can use gst_element_link_filtered to link resample and sink with
> caps instead of this way.
> something like:
>      gst_element_link (source, demuxer);
>      gst_element_link_many (decoder, conv, resample, NULL);
>      if ( !gst_element_link_filtered(resample,sink,caps) ){
>          g_printerr("Failed to link elements resample and alsa-sink");
>      }
>
>
> >         g_signal_connect (demuxer, "pad-added", G_CALLBACK
> > (on_pad_added), decoder);
> >
> >         GstBus *bus =
> > gst_pipeline_get_bus(GST_PIPELINE(musicPlayer.playPipeline));
> >         gst_bus_add_watch(bus, bus_call, NULL);
> >         gst_object_unref(bus);
> >
> >         gst_element_set_state(GST_ELEMENT(musicPlayer.playPipeline),
> > GST_STATE_PLAYING);
> >
> >         musicPlayer.playLoop = g_main_loop_new(NULL, FALSE);
> >
> >         g_main_loop_run(musicPlayer.playLoop);
> >
> >         gst_element_set_state(GST_ELEMENT(musicPlayer.playPipeline),
> > GST_STATE_NULL);
> >         gst_object_unref(GST_OBJECT(musicPlayer.playPipeline));
> >
> >
> >
> >
> > With Warm Regards
> > Jesu Anuroop Suresh
> >
> > "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."
> > "Anyone who has never made a mistake has never tried anything new."
> >
> >
> I attached my modified source code ,you can try it.
> Hope it helps.
>
> Thanks.
>
>
> --
> B.R
>
> Cai Yuanqing
>
>
> ------------------------------------------------------------------------------
>
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand
> malware threats, the impact they can have on your business, and how you
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=3215098&i=0>
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
> *test.c* (6K) Download Attachment <http://attachment/3215098/0/test.c>
>
>
> ------------------------------
>  View message @
> http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3215098.html
>
> To unsubscribe from audioresample, click here<http://gstreamer-devel.966125.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3213586&code=amVzdWFzQGdtYWlsLmNvbXwzMjEzNTg2fDcwOTc3MzYyOA==>.
>
>

-- 
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3215225.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20110112/e58f482e/attachment.htm>


More information about the gstreamer-devel mailing list