From card buffer to GstBuffer

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

From card buffer to GstBuffer

BogdanS
Hello hello. One Another question.
I am developing App, that may to play audio from audiocard.

My audiocard periodically puts frame into  unsigned char *outbuf
                                     and size of this frame to  int     outsize

Ok, I am created a pipeline:
pipeline=gst_parse_launch("appsrc name=MySource ! autoaudiosink"

GstBuffer *buffer;

now I want to put data from outbuf to buffer and push it to appsrc. How exactly I do it?

I need to make a new gst_buffer, make a GstMemory, put frame to GstMemory, put GstMemory to buffer, and push buffer? Or something else?

I tried
buffrer= gst_buffer_new_wraped(outbuf,outsize);
gst_app_src_push_buffer(appsrc,buffer);

But every time I have memory exception.

Please help
Reply | Threaded
Open this post in threaded view
|

Re: From card buffer to GstBuffer

Sebastian Dröge-3
On Wed, 2016-08-31 at 04:50 -0700, BogdanS wrote:

> I tried 
> buffrer= gst_buffer_new_wraped(outbuf,outsize);
> gst_app_src_push_buffer(appsrc,buffer);
>
> But every time I have memory exception.

That function takes ownership of the memory you pass it and will call
g_free() on it after its no longer in use.

Your API looks like the outbuf is only valid in the scope of the
function, so you would have to copy it first before putting it into a
GstBuffer or GstMemory.


If you had API that has refcounting or otherwise allows you to notify
the caller about when the memory is not in use anymore, you could use
gst_buffer_new_wrapped_full() without copying but a custom function to
"free" the memory.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (949 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: From card buffer to GstBuffer

BogdanS
>That function takes ownership of the memory you pass it and will call
>g_free() on it after its no longer in use.

>Your API looks like the outbuf is only valid in the scope of the
>function, so you would have to copy it first before putting it into a
>GstBuffer or GstMemory.


>If you had API that has refcounting or otherwise allows you to notify
>the caller about when the memory is not in use anymore, you could use
>gst_buffer_new_wrapped_full() without copying but a custom function to
>"free" the memory.

Firts of all Thank You!

In the end I used:

buffer=gst_buffer_new_allocate(NULL,outsize,NULL);
gst_buffer_fill(buffer,0,outbuf,outsize);
gst_app_src_push_buffer(appsrc,buffer);


Now it's works, but if it is Ok?