Play audio filled in buffer

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Play audio filled in buffer

Akbar Basha-2
Hi,

I would like to play the buffer , which is filled with any audio file data.
Does gstreamer provides any mechanism to play.

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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Play audio filled in buffer

Ramana_polaka

You can pass external buffer to the GStreamer pipeline with the help of appsrc element.

 

http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/section-data-spoof.html

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Akbar Basha
Sent: Wednesday, July 09, 2008 2:44 PM
To: [hidden email]
Subject: [gst-devel] Play audio filled in buffer

 

Hi,

I would like to play the buffer , which is filled with any audio file data.
Does gstreamer provides any mechanism to play.

Thanks in advance.

Regards,
Akbar

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are not 
to copy, disclose, or distribute this e-mail or its contents to any other person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken 
every reasonable precaution to minimize this risk, but is not liable for any damage 
you may sustain as a result of any virus in this e-mail. You should carry out your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

-------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Play audio filled in buffer

Stefan Sauer
In reply to this post by Akbar Basha-2
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
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


-------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Play audio filled in buffer

Stefan Sauer
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 <[hidden email]
> <mailto:[hidden email]>> 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
>
>         [hidden email]
>         <mailto:[hidden email]>
>         https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>
>


-------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Play audio filled in buffer

Akbar Basha-2
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 <[hidden email]> 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 <[hidden email] <mailto:[hidden email]>> 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

       [hidden email]
       <mailto:[hidden email]>



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Play audio filled in buffer

Akbar Basha-2
In reply to this post by Stefan Sauer
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 7/12/08, Stefan Kost <[hidden email]> 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 <[hidden email] <mailto:[hidden email]>> 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 <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.sourceforge.net/community/cca08" target="_blank">http://www.sourceforge.net/community/cca08


       ------------------------------------------------------------------------

       _______________________________________________
       gstreamer-devel mailing list

       [hidden email]
       <mailto:[hidden email]>
       <a onclick="return top.js.OpenExtLink(window,event,this)" href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel






-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel