To connect Gstreamer with Qt in order to play a gstreamer video in the Qt Widget

Posted by raggio on Stack Overflow See other posts from Stack Overflow or by raggio
Published on 2010-02-12T07:03:50Z Indexed on 2010/03/30 4:23 UTC
Read the original article Hit count: 1064

Filed under:
|
|

I tried using phonon to play the video but could not succeed. Off-late came to know through the Qt forums that even the latest version of Qt does not support phonon. Thats when i started using Gstreamer.Any suggestions as to how to connect the Gstreamer window with the Qt widget?My aim is to play a video using Gstreamer on the Qt widget.So how do i link the gstreamer window and the Qt widget?

I am successful in getting the Id of the widget through winid(). Further with the help of Gregory Pakosz, I have added the below 2 lines of code in my application -

QApplication::syncX();
gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(sink), widget->winId());

However am not able to link the Qt widget with the gstreamer video window.

This is what my sample code would look like :-

int main(int argc, char *argv[])
{
printf("winid=%d\n", w.winId());
    gst_init (NULL,NULL);
    /* create a new bin to hold the elements */
    bin = gst_pipeline_new ("pipeline");

      /* create a disk reader */
  filesrc = gst_element_factory_make ("filesrc", "disk_source");
  g_assert (filesrc);



  g_object_set (G_OBJECT (filesrc), "location", "PATH_TO_THE_EXECUTABLE", NULL);

  demux = gst_element_factory_make ("mpegtsdemux", "demuxer");
  if (!demux) {
    g_print ("could not find plugin \"mpegtsmux\"");
    return -1;
  }

  vdecoder = gst_element_factory_make ("mpeg2dec", "decode");
  if (!vdecoder) {
    g_print ("could not find plugin \"mpeg2dec\"");
    return -1;
  }

  videosink = gst_element_factory_make ("xvimagesink", "play_video");
  g_assert (videosink);


  /* add objects to the main pipeline */

  gst_bin_add_many (GST_BIN (bin), filesrc, demux, vdecoder, videosink, NULL);


  /* link the elements */
  gst_element_link_many (filesrc, demux, vdecoder, videosink, NULL);

    gst_element_set_state(videosink, GST_STATE_READY);

    QApplication::syncX();
    gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(videosink), w.winId());



  /* start playing */
  gst_element_set_state (bin, GST_STATE_PLAYING);

}

Could you explain more in detail about the usage of gst_x_overlay_set_xwindow_id() wrt my context?

Could i get any hint as to how i can integrate gstreamer under Qt? Please help me solve this problem

© Stack Overflow or respective owner

Related posts about qt4

Related posts about qt