I am trying to use gstreamer to play video from a network camera in QWidget.
I am utilizing "mjpeg" stream of the camera.

I am able to successfully play the video in terminal using :
Qt Code:
  1. gst-launch souphttpsrc location=http://169.254.75.39/video2.mjpg timeout=5 ! jpegdec ! xvimagesink
To copy to clipboard, switch view to plain text mode 

The same code I am trying to play in QWidget using this code:
Qt Code:
  1. #include <glib.h>
  2. #include <gst/gst.h>
  3. #include <gst/interfaces/xoverlay.h>
  4.  
  5. #include <QApplication>
  6. #include <QTimer>
  7. #include <QWidget>
  8.  
  9. int main(int argc, char *argv[])
  10. {
  11. if (!g_thread_supported ())
  12. g_thread_init (NULL);
  13.  
  14. gst_init (&argc, &argv);
  15. QApplication app(argc, argv);
  16. app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ()));
  17.  
  18. // prepare the pipeline
  19.  
  20. GstElement *pipeline = gst_pipeline_new ("xvoverlay");
  21. GstElement *src = gst_element_factory_make ("souphttpsrc",NULL);
  22. GstElement *sink = gst_element_factory_make ("xvimagesink", NULL);
  23. gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
  24. gst_element_link (src, sink);
  25. g_object_set (src, "location", "http://169.254.75.39/video2.mjpg", NULL);
  26. // prepare the ui
  27.  
  28. QWidget window;
  29. window.move(0,0);
  30. window.resize(320, 240);
  31. window.show();
  32.  
  33. WId xwinid = window.winId();
  34. gst_x_overlay_set_window_handle (GST_X_OVERLAY (sink), xwinid);
  35.  
  36. // run the pipeline
  37.  
  38. GstStateChangeReturn sret = gst_element_set_state (pipeline,
  39. GST_STATE_PLAYING);
  40. if (sret == GST_STATE_CHANGE_FAILURE) {
  41. gst_element_set_state (pipeline, GST_STATE_NULL);
  42. gst_object_unref (pipeline);
  43. // Exit application
  44. QTimer::singleShot(0, QApplication::activeWindow(), SLOT(quit()));
  45. }
  46.  
  47. int ret = app.exec();
  48.  
  49. window.hide();
  50. gst_element_set_state (pipeline, GST_STATE_NULL);
  51. gst_object_unref (pipeline);
  52.  
  53. return ret;
  54. }
To copy to clipboard, switch view to plain text mode 

When I run the code,all I am getting is a blank QWidget with nothing.

My gstreamer has been correctly setup in QT and I was able to play a sample pattern easily in QWidget.

I guess I am missing the decoder configuration in QT for 'jpegdec'
Can anyone tell how to correctly set it up?
Here is the .pro file content:
Qt Code:
  1. QT += core gui
  2.  
  3. TARGET = streaming
  4. TEMPLATE = app
  5.  
  6.  
  7. SOURCES += main.cpp\
  8. mainwindow.cpp
  9.  
  10. HEADERS += mainwindow.h
  11.  
  12. FORMS += mainwindow.ui
  13.  
  14. CONFIG += link_pkgconfig
  15. PKGCONFIG += gstreamer-0.10\
  16. gstreamer-interfaces-0.10\
  17. gtk+-2.0\
  18.  
  19. QMAKE_CXXFLAGS += -fpermissive
To copy to clipboard, switch view to plain text mode 

P.S. : using ubuntu 12.04