[gst-devel] Some help needed on buffer management

Sameer Naik sameer at nextbitcpu.com
Mon Dec 19 10:52:03 CET 2005


hi everybody...
i'm currently implementing a transport stream demultiplexer. but im have
a problem managing the buffers in the plugin.

in the plugin i have made two GstAdapter's one for audio PES packets and
one for video PES packets and another GstAdapter where the data received
on the source pad is pushed...

the audio/video data is accumulated in the audio and video adapters
respectively until an entire a/v frame is received..
once received the frame is pushed to the pad...and the data in the
adapter is flushed

so heres what i do to push the new data to the pes adapters

guint8 *data;
GstBuffer *buffer;
GstAdapter *pesPacket 

(pesPacket points to the audio adapter when audio pes packet is received
and to the video adapter when a video pes packet is received )

buffer = gst_buffer_new();
data = (guint8 *)malloc(size);
memcpy(auxdata, dataPtr, size);	
gst_buffer_set_data(buffer, data, size);
gst_adapter_push(pesPacket, buffer);

here dataPtr is the pointer to the data in the main GstAdapter (one
where the data received on the source pad is pushed) and size is the
amount of data i need to store..

i need to store the data because i have to do a gst_adapter_flush on the
main gstadapter...

im not able to unref the buffer after pushing it into the
adapter...doing so gives a segmentation error...

the above code is repeated for every pes packet received...so new memory
is allocated each time and not freed....resulting in i guess memory
problems and my system does not respond...

i would like to know if theres any other better way to store the data in
the adapter or somewhere else...

plz help
thanks in advance

sameer





More information about the gstreamer-devel mailing list