Hello,
How can I get a pointer to a gstBuffer with QtGSTreamer? I want to combine a 3D rendering library with GStreamer. In order to display some 2D video content in the rendering frame i need the following image data format: RGBRGBRGB... each letter is one byte; which corresponds to the following GStreamer caps: const char *caps = "video/x-raw-rgb, bpp=(int)24, depth=(int)24, endianness=(int)4321, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255"Thus I would like to have something like the following pipeline: SoImage* image(); MySink m_sink(image); const char* location = "C:/Users/Public/Videos/Sample Videos/Wildlife.wmv"; QString pipe1Descr = QString("filesrc location=\"%1\" ! decodebin2 ! ffmpegcolorspace ! " "appsink name=\"mysink\" caps=\"%2\"").arg(location, caps); pipeline1 = QGst::Parse::launch(pipe1Descr).dynamicCast<QGst::Pipeline>(); m_sink.setElement(pipeline1->getElementByName("mysink")); The Apllicationsink may look like this: const int resX = 640; const int resY = 480; const int bytesPerPixel = 3; class MySink : public QGst::Utils::ApplicationSink { public: MySink(SoImage* image) : QGst::Utils::ApplicationSink(), m_image(image) {} protected: virtual QGst::FlowReturn newBuffer() { // Pointer to the above mentioned image data unsigned char* imageDataPtr; // Here should be some casting from the BufferPtr to a native C pointer // And may be some locking mechanism for the buffer in order to be able to copy the whole data // QGst::BufferPtr bufferPtr = pullBuffer(); // The image.setValue function can copy the data to its own memory m_image->image.setValue(SbVec2s(resX,resY), bytesPerPixel, imageDataPtr ); return QGst::FlowOk; } private: SoImage* m_image; }; This is adopted from the appsink-src example. But in there the BufferPtr retunred from pullBuffer() is simple passed to pushbuffer(). m_src->pushBuffer(pullBuffer()). Thus no casting nesessary there. Does the wrap function of the BufferPtr would help in this case? If, then how could I use it? Any help/suggestions on how to achive the functions described in the comments of MySink::newBuffer() would be very appriciated. The 3D rendering library is Coin3D. |
On Tue, Apr 17, 2012 at 12:22 PM, pfarmer <[hidden email]> wrote:
> Hello, > How can I get a pointer to a gstBuffer with QtGSTreamer? > > I want to combine a 3D rendering library with GStreamer. In order to display > some 2D video content in the rendering frame i need the following image data > format: > RGBRGBRGB... each letter is one byte; which corresponds to the following > GStreamer caps: > Why would you want to get a GstBuffer pointer when what you really want is to get the data of the buffer? bufferptr->data() should do that in QtGStreamer. But if you really really want a GstBuffer*, then you can just get it implicitly from a smart pointer: QGst::BufferPtr bufferptr; GstBuffer *b = bufferptr; gst_buffer_ref(b); .... Regards, George _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Thanks
I actualy would like to have the data from the buffer. So that would be ideal: bufferptr->data(). And it works. This was what I was searching for. Simple enough. 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? 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? data() function returns a pointer to quint8. So I have to assume that quint8 is the same as uchar on the machine. Is there a better way for the conversion? |
On Tue, Apr 17, 2012 at 1:51 PM, pfarmer <[hidden email]> wrote:
> Thanks > > I actualy would like to have the data from the buffer. So that would be > ideal: > bufferptr->data(). > > And it works. This was what I was searching for. Simple enough. > > So the newBuffer() function looks like this: > > > > Is this good to use? Sorry, I don't see any code here... > 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? > > data() function returns a pointer to quint8. So I have to assume that quint8 > is the same as uchar on the machine. Is there a better way for the > conversion? Yes, quint8 is a typedef for unsigned char. _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Sorry. Strange. Here again:
Thanks I actualy would like to have the data from the buffer. So that would be ideal: bufferptr->data(). And it works. This was what I was searching for. Simple enough. 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? 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? data() function returns a pointer to quint8. So I have to assume that quint8 is the same as uchar on the machine. Is there a better way for the conversion? |
On Wed, Apr 18, 2012 at 11:42 AM, pfarmer <[hidden email]> 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. _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |