videotest.pro
main.cpp
capture.h
capture.cpp
The Capture class is a subclass of QLabel only because I intended to include a signal which is emitted each time a frame arrives. The approach is based on the gst_app_sink plugin. With the caps "video/x-raw, format=RGB, bpp=8" and the correct dimension the data can be safely mapped to a QImage with QImage::Format_RGB888 format. The whole code of getting the data from the gstBuffer in newSample() is very different from the approach in gstreamer-0.10. I find the way of gstreamer-1.0 pretty tedious. Several problems remain here:
- The mutex might be not optimally designed since its a producer newSample() and a consumer getFrame()
- The QImage construction should be done with const data since the data is not intended to get changed
- A serious problem is that the data of the QImage must remain valid also if the image is used from the Display class. This is not given here since the lifetime of the GstBuffer is unknown
display.h
display.cpp
The Display class is a subclassed QLabel. For the testing purpose it is sufficient to display the QLabel widget only. In a real applications this widget can be included in a QMainWindow or QDialog easily. The paintEvent is overwritten to enable the rendering of the pixmap. I don't know why the paintEvent occurs frequently enough without doing nothing. There is no explicit update() or repaint() slot executed.
Your post helped me a lot, thanks!
ReplyDelete(It would be great if gstreamer 1.0 docs mentioned somewhere that signal handlers should now return GST_FLOW_OK, yep)