How to display RTSP Stream using QT? I already used LibVlc-QT for display, but i didn't get control over stream after using this library. So I don't want to use LibVlC QT.
-
Hi,
I want to display RTSP stream using QT. I am using DSS for as a streaming server. Now I want to display that stream on Qt. -
Thanks tomasz3dk,
You mean to replace Qt with GStreamer to display the streaming video?
or to use GStreamer instead of DSS for streaming? -
I got sample code to play RTSP stream using Gstreamer. Here is the code:
#include <gst/gst.h>
int main(int argc, char *argv[])
{
GstElement *pipeline;
GstBus *bus;
GstMessage *msg;/* Initialize GStreamer */
gst_init (&argc, &argv);/* Build the pipeline */
pipeline = gst_parse_launch ("playbin2 uri=rtsp://172.19.91.21/channel.sdp", NULL);/* Start playing */
gst_element_set_state (pipeline, GST_STATE_PLAYING);/* Wait until error or EOS */
bus = gst_element_get_bus (pipeline);
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);/* Free resources */
if (msg != NULL)
gst_message_unref (msg);
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
return 0;
}But using this code, I can not display my stream data on Qt GUI.
I have created GUI using Qt and now i want to display this RTSP stream on that Qt's GUI. So I feel this code is not useful to do that. -
On which platform plugin are you running this code (eglfs, xcb,) ? Also there are Qt bindings for gstreamer, that you can use in your project: Qt gstreamer.
-
I am using ubuntu trusty image on iMX6 Board (Nitrogen 6 Max). I am trying to build and code using QtGstreamer library. Will post here once I done with it.
Thanks tomaz3dk. -
So finally I am able to display live RTSP Stream on QT's surface(Qt Widgets). Here is the sample code:
// Sample code to play rtsp stream on qt widgets int main(int argc, char *argv[]) { gst_init (&argc, &argv); QApplication app(argc, argv); app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ())); // prepare the pipeline GstElement *pipeline = gst_parse_launch ("playbin uri=rtsp://172.19.91.21/channel.sdp", NULL); // prepare the ui QWidget window; window.setWindowTitle("MyWidget"); window.resize(640, 480); window.show(); WId xwinid = window.winId(); //this is the call to overlay the gstreamer's output to the Qt Widgets... gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (pipeline), xwinid); // run the pipeline GstStateChangeReturn sret = gst_element_set_state (pipeline, GST_STATE_PLAYING); if (sret == GST_STATE_CHANGE_FAILURE) { gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (pipeline); // Exit application QTimer::singleShot(0, QApplication::activeWindow(), SLOT(quit())); } int ret = app.exec(); window.hide(); gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (pipeline); return ret; }
Thanks tomaz3dk.
-
oops.. Sorry for the name.
Actually I am developing my application for Ubuntu and right now no plan to port on other platform. But If I face any problem I will post here.. :D
Thanks tomasz3dk :)