Gstreamer playbin integration in QT application

arnaud tonda arnaud.tonda at gmail.com
Fri Jul 22 05:49:21 PDT 2011


Hi everybody,

I don't know if it's the right place but i try.

after writing a C standalone code using playbin2 gstreamer elements, i
started integration on a QT c++ source Application.

i have a lot of windows and one is dedicated to video rendering.
I want to use gstxoverlay.

firstly i tried to use the gstreamer sample code shown on gstxoverlay Api.

with videotestsrc and xvimagesrc :

######################################
  GstElement *pipeline = gst_pipeline_new ("xvoverlay");

GstElement *src = gst_element_factory_make ("videotestsrc", NULL);

GstElement *sink = gst_element_factory_make ("xvimagesink", NULL);

gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);

gst_element_link (src, sink);

        gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(sink), windowId );

bus = gst_pipeline_get_bus (GST_PIPELINE(pipeline));

gst_bus_add_watch(bus, (GstBusFunc)bus_callback, NULL);

gst_object_unref(bus);

gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);
######################################

here i have what i expected, videotest is displayed on the right window
without problem.

secondly i tried to use playbin2 and the problem is there.

i get the video-sink element of playbin2 but before pipeline is playing
video-sink is null.
if i overload video-sink with a xvimagesink element video-sink is not null,
and i can use gst_x_overlay_set_xwindow_id on this.
but it result on a fullscreen video.... i think something is wrong but i
don't understand what....

######################################

playbin = gst_element_factory_make("playbin2","playbin");

GstElement *videosink = gst_element_factory_make("xvimagesink",
"videosink");

g_object_set(G_OBJECT(playbin), "video-sink", videosink, NULL);

g_object_set(G_OBJECT(playbin),"uri","file:///root/test.mkv",NULL);
g_object_set(G_OBJECT(playbin),"flags",0x00000013,NULL);

//2 - We add a message Handler
bus = gst_pipeline_get_bus (GST_PIPELINE(playbin));
gst_bus_add_watch(bus, (GstBusFunc)bus_callback, NULL);
gst_object_unref(bus);

g_signal_connect(G_OBJECT(playbin),"video-changed",G_CALLBACK(on_video_changed),this);
g_signal_connect(G_OBJECT(playbin),"pad-added",G_CALLBACK(on_pad_added),this);
g_signal_connect(G_OBJECT(playbin),"deep-notify::source",(GCallback)on_video_sink_notify,this);

        GstElement *videosink2 = 0;
        g_object_get(playbin, "video-sink", &videosink2, NULL);

    if (videosink2 && GST_IS_X_OVERLAY(videosink2) )
    {
     cout << "videosink and overlay are OK" << endl;
        gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(videosink), windowId );
    }
    else
    {
     if(!videosink)
     cout << "videosink is NULL" << endl;
     else
     cout << "overlay is NULL" << endl;
    }

gst_element_set_state(GST_ELEMENT(playbin), GST_STATE_PLAYING);

######################################

any idea? what is wrong?

One other thing :

the gst_bus_add_watch did not work. the attached callback is never called.
Has it work on the standalone C source code i think it is due to the QT
event loop but i can't confirm.
am i right?

Best regards

-- 
Arnaud Tonda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20110722/07d1530b/attachment.htm>


More information about the gstreamer-devel mailing list