How to get pointer to a gstBuffer with QtGSTreamer

George Kiagiadakis kiagiadakis.george at gmail.com
Wed Apr 18 09:55:27 PDT 2012


On Wed, Apr 18, 2012 at 11:42 AM, pfarmer <flacone at gmx.de> wrote:
> So the newBuffer() function looks like this:
>
>    virtual QGst::FlowReturn newBuffer()
>    {
>                bufferPtr = pullBuffer();
>                unsigned char* imageData = static_cast<unsigned char*>(bufferPtr->data());
>                m_image->image.setValue(SbVec2s(resX,resY), bytesPerPixel, imageData );
>        return QGst::FlowOk;
>    }
>
>
>
> Is this good to use?

It should work, yes.

> Is it garanteed that the data in the Buffer stayes untouched during the copy
> process in the image.setValue() function? Or do I have to take special care?

Yes, as long as there is a BufferPtr holding this buffer in the active
scope, the data will stay there, unmodified.
I would recommend you to create the BufferPtr in the scope of this
function, though, so that it gets destroyed when the function returns.
There is no reason to keep a reference to the buffer longer than you
need it.


More information about the gstreamer-devel mailing list