how to release the GstBuffer memory

trinadh Pala me_wavelet at yahoo.co.uk
Tue Jun 25 10:38:09 PDT 2013


Hello Angel Martin & all,

I have gone through the program that was in the link below. This program is playing some 300 video frames and after that it stops. So if there is any memory leak, it may not be able to indicate. So I am not sure whether this program has been tested for memory leak. It is not clear to me how the buffer release was implemented. If I call g_free(pointer). or m_buffer->clear in my program after pushing the buffer to the pipeline, the program exits. if I do not use g_free or m_buffer->clear then the program continues to send the ts data to the down stream elemets and decoding happens properly except for the problem of leaking memory. I am stuck with the problem for a couple of day, the application is no use without fixing this memory leak. Please help.

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
>
_______________________________________________
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/ebb870d0/attachment.html>


More information about the gstreamer-devel mailing list