[MeeGo-touch-dev] gstreamer is not rendering video in MApplicationWindow.
Armin Berres
armin.berres at basyskom.de
Mon Jan 3 08:47:00 PST 2011
On 01/03/2011 05:39 PM, john pratss wrote:
> Hi,
>
>
> Gstreamer is not rendering videos in an MApplicationWindow. I have passed the
> window ID of the MApplicationWindow. I have given the code which I am trying
> as below.
> Any pointers on this.
I did not look at the gstreamer code but try to replace
"WId xwinid = mAppWnd->winId();"
with
"WId xwinid = mAppWnd->viewport->effectiveWinId();"
This makes sure you use the winId of the viewport if a special one has
been set (like a QGLWidget) or the next toplevel window if no native
window has been set as viewport.
Cheers,
Armin
>
> Cheers,
> John
>
> #include <gst/gst.h>
> #include <gst/interfaces/xoverlay.h>
> #include <QDebug>
> #include <QApplication>
> #include <QTimer>
> #include <QWidget>
> #include <MApplicationWindow>
> #include <MApplication>
>
> #define DEFAULT_VIDEOSINK "xvimagesink"
> /* slightly convoluted way to find a working video sink that's not a bin,
> * one could use autovideosink from gst-plugins-good instead
> */
> static GstElement *
> find_video_sink (void)
> {
> GstStateChangeReturn sret;
> GstElement *sink;
>
> if ((sink = gst_element_factory_make ("xvimagesink", NULL))) {
> sret = gst_element_set_state (sink, GST_STATE_READY);
> if (sret == GST_STATE_CHANGE_SUCCESS)
> return sink;
>
> gst_element_set_state (sink, GST_STATE_NULL);
> }
> gst_object_unref (sink);
>
> if ((sink = gst_element_factory_make ("ximagesink", NULL))) {
> sret = gst_element_set_state (sink, GST_STATE_READY);
> if (sret == GST_STATE_CHANGE_SUCCESS)
> return sink;
>
> gst_element_set_state (sink, GST_STATE_NULL);
> }
> gst_object_unref (sink);
>
> if (strcmp (DEFAULT_VIDEOSINK, "xvimagesink") == 0 ||
> strcmp (DEFAULT_VIDEOSINK, "ximagesink") == 0)
> return NULL;
>
> if ((sink = gst_element_factory_make (DEFAULT_VIDEOSINK, NULL))) {
> if (GST_IS_BIN (sink)) {
> gst_object_unref (sink);
> return NULL;
> }
>
> sret = gst_element_set_state (sink, GST_STATE_READY);
> if (sret == GST_STATE_CHANGE_SUCCESS)
> return sink;
>
> gst_element_set_state (sink, GST_STATE_NULL);
> }
> gst_object_unref (sink);
> return NULL;
> }
>
> int main(int argc, char *argv[])
> {
> if (!g_thread_supported ())
> g_thread_init (NULL);
>
> gst_init (&argc, &argv);
> MApplication app(argc, argv);
> app.setOrganizationName("sample");
>
> MApplicationWindow *mAppWnd = new MApplicationWindow();
>
> app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ()));
>
> /* prepare the pipeline */
>
> GstElement *pipeline = gst_pipeline_new ("xvoverlay");
> GstElement *src = gst_element_factory_make ("videotestsrc", NULL);
> GstElement *sink = find_video_sink ();
>
> if (sink == NULL)
> g_error ("Couldn't find a working video sink.");
>
> gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
> gst_element_link (src, sink);
>
> /* prepare the ui */
>
> /*QWidget window;
> window.resize(320, 240);
> window.setWindowTitle("GstXOverlay Qt demo");
> window.show();
> WId xwinid = window.winId();*/
> WId xwinid = mAppWnd->winId();
> mAppWnd->show();
>
> gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), 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;
> }
>
>
>
>
> _______________________________________________
> MeeGo-touch-dev mailing list
> MeeGo-touch-dev at meego.com
> http://lists.meego.com/listinfo/meego-touch-dev
--
Armin Berres
basysKom GmbH
Robert-Bosch-Str. 7 | 64293 Darmstadt | Germany
Tel: +49 6151 3968753 | Fax: -736 |
armin.berres at basyskom.de | www.basyskom.de
Handelsregister: Darmstadt HRB 9352
Geschäftsführung: Eva Brucherseifer
More information about the MeeGo-touch-dev
mailing list