[gst-devel] gstreamer output window
Sanjay Gupta
sanjayg417 at gmail.com
Thu Jun 14 09:00:14 CEST 2007
On 6/13/07, bounce bounce <bouncebounce at caramail.com> wrote:
>
> Hi,
>
> I'vealready send a mail on this mailing list because I don't succeed to
> output a video in a Xwindow drawing area with a "playbin" and a
> "directdrawsink" on Windows. And I always do not succed in that.
>
> Well, if we used a "playbin" and play the video, the element will create
> its own internal window and render into it because no Window ID was provided
> by the application or because of an error during the configuration
>
I think you are trying to draw the video frames on your own xwindow. Use the
following code snippet to do so :
--------------
#include <gst/gst.h>
#include <gst/interfaces/xoverlay.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <math.h>
#include <sys/time.h>
GstElement *bin;
static Display *disp;
static Window root, win;
static GC gc;
static gint width = 176, height = 220 ;
static gint disp_width, disp_height;
static void open_display (void)
{
gint screen_num;
disp = XOpenDisplay (NULL);
root = DefaultRootWindow (disp);
screen_num = DefaultScreen (disp);
disp_width = DisplayWidth (disp, screen_num);
disp_height = DisplayHeight (disp, screen_num);
}
static GstBusSyncReply
create_window (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
{
XGCValues values;
const GstStructure *s;
s = gst_message_get_structure (message);
if (!gst_structure_has_name (s, "prepare-xwindow-id")) {
return GST_BUS_PASS;
}
g_print ("Creating our own window\n");
win = XCreateSimpleWindow (disp, root, 0, 0, width, height, 0, 0, 0);
XSetWindowBackgroundPixmap (disp, win, None);
gc = XCreateGC (disp, win, 0, &values);
XMapRaised (disp, win);
XSync (disp, FALSE);
gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (GST_MESSAGE_SRC (message)),
win);
return GST_BUS_DROP;
}
int main (int argc, char *argv[])
{
....
....
open_display ();
bin = gst_element_factory_make ("playbin", "playbin");
g_object_set (G_OBJECT (bin), "uri", argv[1], NULL);
bus = gst_pipeline_get_bus (GST_PIPELINE (bin));
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, bin);
gst_object_unref (bus);
....
....
//close the created display at the end.
XCloseDisplay (disp);
}
//------------------
It should work.
Regards,
Sanjay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20070614/b7862339/attachment.htm>
More information about the gstreamer-devel
mailing list