how to release the GstBuffer memory
trinadh Pala
me_wavelet at yahoo.co.uk
Tue Jun 25 08:57:21 PDT 2013
Hello Angel Martin
The difference from my code seem to be the g_free method specification in the example code that you sent me.
I am using QtGstreamer library , QGst wrappers.
QGst::Buffer::create(buf_size); Is it not the same? I thought this will create and allocate the memory in one step.
If not, how to rewrite this call below in terms of QGst library.
gst_app_buffer_new (raw_buffer, size, g_free, raw_buffer);
In this code also there is no explicit command to release the memory buffer.
Thanks and regards
Trinadh
________________________________
From: Angel Martin <amartin at vicomtech.org>
To: trinadh Pala <me_wavelet at yahoo.co.uk>; Discussion of the development of and with GStreamer <gstreamer-devel at lists.freedesktop.org>
Sent: Tuesday, 25 June 2013, 16:21
Subject: Re: how to release the GstBuffer memory
Hi,
Here you will find the proper way:
http://users.design.ucla.edu/~acolubri/test/gstreamer/appsrc_filesink.c
/* used to inject a new buffer into the pipeline */
static void
inject_new_buffer_into_pipeline (ProgramData * data)
{
guint size;
gpointer raw_buffer;
GstBuffer *app_buffer;
GstElement *source;
size = 80 * 60 * 4; // 80x60 pixels, 32 bpp.
g_print ("Pushing a buffer of size %d\n", size);
// Allocating the memory for the buffer.
raw_buffer = g_malloc0 (size);
app_buffer = gst_app_buffer_new (raw_buffer, size, g_free, raw_buffer);
/* newer basesrc will set caps for use automatically but it does not really
* hurt to set it on the buffer again */
gst_buffer_set_caps (app_buffer, gst_caps_from_string (video_caps));
/* get source an push new buffer */
source = gst_bin_get_by_name (GST_BIN (data->sink), "testsource");
gst_app_src_push_buffer (GST_APP_SRC (source), app_buffer);
}
2013/6/25 trinadh Pala <me_wavelet at yahoo.co.uk>:
> Hello,
>
> I am writing an application using QtGstreamer library.
>
> I am implemeting a media player application. i am using Appsource for
> linking the source. The data is available in a char *buffer.
>
> I created a buffer using QGst::Buffer::create(size).
> // pBuf has the Transport stream data char *pBuf
> // This piece of code is in a loop.
>
> QGst::BufferPtr m_buffer;
> m_buffer=QGst::Buffer::create(buf_size);
>
> quint8 *m_data_ptr=m_buffer->data();
>
> memcpy(m_data_ptr,pBuf,buf_size);
>
> if(this->m_player->m_pipeline);
>
> ret = this->m_player->m_appsrc.pushBuffer(m_buffer);
>
> if (!m_buffer.isNull())
> {
> if (ret != QGst::FlowOk)
> {
> /* some error, stop sending data */
> qDebug("some error");
> }
> else
> {
> qDebug("pushed a buffer successfully");
>
> }
> }
>
>
> The method works, i am able to display the video. However, I did not know
> how to release the buffer created. so the application leaks memory. How to
> release the Buffer, after pushBuffer. Please help.
>
> Thanks and regards
> Trinadh
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20130625/cd887bd5/attachment-0001.html>
More information about the gstreamer-devel
mailing list