[gst-devel] Play audio filled in buffer

Akbar Basha akbar.sdl at gmail.com
Wed Jul 16 12:44:39 CEST 2008


For mp3 it works fine.

For wav and raw pcm files  program never get signal handoff.
To play wav file I used dynamic pad and for pcm doesn't need pad.

Is it possible to play binary data using this approach? If so what would be
the decoder elements.

I have looked into appsrc plugin . I ran the example given as part of the
plugin. Audio is not coming.

Thanks,
Akbar


On Sat, Jul 12, 2008 at 3:33 PM, Stefan Kost <ensonic at hora-obscura.de>
wrote:

> hi,
> Akbar Basha schrieb:
>
>> Hi Stefan,
>>
>> Thanks for the response .
>>
>
> Would you please post to the list.
>
>
>> I tried the same. But could not produce the result.
>>
>> Please find the code.
>>
>> static void
>> cb_handoff (GstElement *fakesrc,
>>        GstBuffer  *buffer,
>>         gpointer    user_data)
>> {
>>    /* Clip start and end */
>>
>>  data = (guint8 *) g_malloc (3000);
>>  GST_BUFFER_SIZE (buffer) = 3000;
>>  GST_BUFFER_DATA (buffer) = GST_BUFFER_MALLOCDATA (buffer) = data;
>>    FILE* fp = fopen("vertigo.mp3","rb");
>>  if(fp == NULL)
>>   {
>>    printf( " File is not opened \n");
>>    return;
>>   }
>>  fread(data,3000,1,fp);
>>    fclose(fp);
>>  }
>>
>> gint
>> main (gint   argc,
>>      gchar *argv[])
>> {
>>  GstElement *pipeline, *fakesrc, *flt, *conv, *audiosink;
>>  GMainLoop *loop;
>>
>>  /* init GStreamer */
>>  gst_init (&argc, &argv);
>>  loop = g_main_loop_new (NULL, FALSE);
>>
>>  /* setup pipeline */
>>  pipeline = gst_pipeline_new ("pipeline");
>>  fakesrc = gst_element_factory_make ("fakesrc", "source");
>>  flt = gst_element_factory_make ("capsfilter", "flt");
>>  conv = gst_element_factory_make ("mad", "conv");
>>  audiosink = gst_element_factory_make ("alsasink", "audiosink");
>>
>>  /* setup */
>>  g_object_set (G_OBJECT (flt), "caps",
>>          gst_caps_new_simple("audio/x-raw-int",
>>                "channels", G_TYPE_INT, 2,
>>                "rate", G_TYPE_INT, 32000,
>>               "depth", G_TYPE_INT, 16, NULL), NULL);
>>
>
> This is obviously wrong. You load an mp3 and not raw audio data. The
> capsfilter needs to tell that. But in your case you would not even need one.
>
>
>>  gst_bin_add_many (GST_BIN (pipeline), fakesrc, flt,conv, audiosink,
>> NULL);
>>  gst_element_link_many (fakesrc, flt,conv, audiosink, NULL);
>>
>>  /* setup fake source */
>>  g_object_set (G_OBJECT (fakesrc),"signal-handoffs", TRUE,NULL);
>>
>>  g_signal_connect (fakesrc, "handoff", G_CALLBACK (cb_handoff), NULL);
>>
>>  /* play */
>>  gst_element_set_state (pipeline, GST_STATE_PLAYING);
>>  g_main_loop_run (loop);
>>
>>  /* clean up */
>>  gst_element_set_state (pipeline, GST_STATE_NULL);
>>  gst_object_unref (GST_OBJECT (pipeline));
>>
>>  return 0;
>> }
>>
>> Even if I set using memset . Audio is not coming.
>>
>
> What happens?
>
> Stefan
>
>
>> how to proceed in the case pad is required  i.e for wav files.
>>
>> Regards,
>> Akbar
>>
>> On Wed, Jul 9, 2008 at 11:53 PM, Stefan Kost <ensonic at hora-obscura.de<mailto:
>> ensonic at hora-obscura.de>> wrote:
>>
>>    Akbar Basha schrieb:
>>
>>        Hi,
>>
>>        I would like to play the buffer , which is filled with any audio
>>        file data.
>>        Does gstreamer provides any mechanism to play.
>>
>>
>>    if you have the whole bufer in memory, use a fakesrc with
>>    signal-handoffs=TRUE and connect to handoff signal. In the handoff
>>    signal you put the pointer to your data into the GST_BUFFER_DATA,
>>    set the correct GST_BUFFER_SIZE and clear GST_BUFFER_MALLOC_DATA (if
>>    it was previously set g_free() the previous content).
>>
>>    You should used a capsfilter after fakesrc and set the format of
>>    your sample on the capsfilter caps.
>>
>>    Its sort of a hack, but works fine.
>>
>>    Stefan
>>
>>
>>        Thanks in advance.
>>
>>        Regards,
>>        Akbar
>>
>>
>>
>>  ------------------------------------------------------------------------
>>
>>
>>  -------------------------------------------------------------------------
>>        Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
>>        Studies have shown that voting for your favorite open source
>>        project,
>>        along with a healthy diet, reduces your potential for chronic
>>        lameness
>>        and boredom. Vote Now at
>> http://www.sourceforge.net/community/cca08
>>
>>
>>
>>  ------------------------------------------------------------------------
>>
>>        _______________________________________________
>>        gstreamer-devel mailing list
>>
>>        gstreamer-devel at lists.sourceforge.net
>>        <mailto:gstreamer-devel at lists.sourceforge.net>
>>        https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20080716/6592e048/attachment.htm>


More information about the gstreamer-devel mailing list