<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Hi,</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span>If I see the Qt Wrapper for QGst::BufferPtr::create, it is actually creating a new buffer and allocating it also, if I underand from the description. I need to uderstand how to release the memory after pushing it to the downstream element.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br><span></span></div><pre class="fragment"><a href=""
name="l00025"></a>00025 BufferPtr Buffer::create(uint size)
<a href="" name="l00026"></a>00026 {
<a href="" name="l00027"></a>00027 <span class="keywordflow">return</span> <a class="code" href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/qt-gstreamer/html/classQGlib_1_1RefPointer.html#a686e44f803afc1551ad0ab04ac620d39">BufferPtr::wrap</a>(gst_buffer_try_new_and_alloc(size), <span class="keyword">false</span>);
<a href="" name="l00028"></a>00028 }<br><br>Regards<br>Trinadh<br></pre> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <hr size="1"> <font face="Arial" size="2"> <b><span style="font-weight:bold;">From:</span></b> Angel Martin <amartin@vicomtech.org><br> <b><span style="font-weight: bold;">To:</span></b> trinadh Pala <me_wavelet@yahoo.co.uk>; Discussion of the development of and with GStreamer <gstreamer-devel@lists.freedesktop.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Tuesday, 25 June 2013, 16:21<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: how to release the GstBuffer memory<br> </font> </div> <div class="y_msg_container"><br>Hi,<br><br>Here you will find the proper way:<br><br><a
href="http://users.design.ucla.edu/~acolubri/test/gstreamer/appsrc_filesink.c" target="_blank">http://users.design.ucla.edu/~acolubri/test/gstreamer/appsrc_filesink.c</a><br>/* used to inject a new buffer into the pipeline */<br>static void<br>inject_new_buffer_into_pipeline (ProgramData * data)<br>{<br> guint size;<br> gpointer raw_buffer;<br> GstBuffer *app_buffer;<br> GstElement *source;<br><br> size = 80 * 60 * 4; // 80x60 pixels, 32 bpp.<br> g_print ("Pushing a buffer of size %d\n", size);<br><br> // Allocating the memory for the buffer.<br> raw_buffer = g_malloc0 (size);<br><br> app_buffer = gst_app_buffer_new (raw_buffer, size, g_free, raw_buffer);<br><br> /* newer basesrc will set caps for use automatically but it does not really<br> * hurt to set it on the buffer again */<br> gst_buffer_set_caps (app_buffer, gst_caps_from_string (video_caps));<br><br> /* get source
an push new buffer */<br> source = gst_bin_get_by_name (GST_BIN (data->sink), "testsource");<br> gst_app_src_push_buffer (GST_APP_SRC (source), app_buffer);<br>}<br><br>2013/6/25 trinadh Pala <<a ymailto="mailto:me_wavelet@yahoo.co.uk" href="mailto:me_wavelet@yahoo.co.uk">me_wavelet@yahoo.co.uk</a>>:<br>> Hello,<br>><br>> I am writing an application using QtGstreamer library.<br>><br>> I am implemeting a media player application. i am using Appsource for<br>> linking the source. The data is available in a char *buffer.<br>><br>> I created a buffer using QGst::Buffer::create(size).<br>> // pBuf has the Transport stream data char *pBuf<br>> // This piece of code is in a loop.<br>><br>> QGst::BufferPtr m_buffer;<br>> m_buffer=QGst::Buffer::create(buf_size);<br>><br>> quint8 *m_data_ptr=m_buffer->data();<br>><br>>
memcpy(m_data_ptr,pBuf,buf_size);<br>><br>> if(this->m_player->m_pipeline);<br>><br>> ret = this->m_player->m_appsrc.pushBuffer(m_buffer);<br>><br>> if (!m_buffer.isNull())<br>> {<br>> if (ret != QGst::FlowOk)<br>> {<br>> /* some error, stop sending data */<br>> qDebug("some error");<br>> }<br>> else<br>> {<br>> qDebug("pushed a buffer successfully");<br>><br>>
}<br>> }<br>><br>><br>> The method works, i am able to display the video. However, I did not know<br>> how to release the buffer created. so the application leaks memory. How to<br>> release the Buffer, after pushBuffer. Please help.<br>><br>> Thanks and regards<br>> Trinadh<br>><br>> _______________________________________________<br>> gstreamer-devel mailing list<br>> <a ymailto="mailto:gstreamer-devel@lists.freedesktop.org" href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>> <a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>><br>_______________________________________________<br>gstreamer-devel mailing list<br><a ymailto="mailto:gstreamer-devel@lists.freedesktop.org"
href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br><a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br><br><br></div> </div> </div> </div></body></html>