summaryrefslogtreecommitdiffstats
path: root/sys/v4l2/gstv4l2xoverlay.c
diff options
context:
space:
mode:
authorEdgard Lima <edgard.lima@indt.org.br>2006-03-11 22:50:03 +0000
committerEdgard Lima <edgard.lima@indt.org.br>2006-03-11 22:50:03 +0000
commit2dd80106185bf2d5f2d6ec4d7bda679be4a8f704 (patch)
tree1a858c1f07a19f7cfd7074a75395c764e21743a4 /sys/v4l2/gstv4l2xoverlay.c
parent5a72b167bb63996375b840a3bd989cfa6c43671b (diff)
V4L2 ported to 0.10.
Original commit message from CVS: V4L2 ported to 0.10.
Diffstat (limited to 'sys/v4l2/gstv4l2xoverlay.c')
-rw-r--r--sys/v4l2/gstv4l2xoverlay.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/sys/v4l2/gstv4l2xoverlay.c b/sys/v4l2/gstv4l2xoverlay.c
index 2e416b3e..66ea505c 100644
--- a/sys/v4l2/gstv4l2xoverlay.c
+++ b/sys/v4l2/gstv4l2xoverlay.c
@@ -25,7 +25,6 @@
#include <string.h>
#include <gst/gst.h>
-#include <gst/xoverlay/xoverlay.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xv.h>
@@ -59,13 +58,14 @@ gst_v4l2_xoverlay_interface_init (GstXOverlayClass * klass)
"V4L2 XOverlay interface debugging");
}
-void
+static void
gst_v4l2_xoverlay_open (GstV4l2Element * v4l2element)
{
struct stat s;
GstV4l2Xv *v4l2xv;
const gchar *name = g_getenv ("DISPLAY");
- int ver, rel, req, ev, err, anum, i, id = 0, first_id = 0, min;
+ unsigned int ver, rel, req, ev, err, anum;
+ int i, id = 0, first_id = 0, min;
XvAdaptorInfo *ai;
Display *dpy;
@@ -75,6 +75,13 @@ gst_v4l2_xoverlay_open (GstV4l2Element * v4l2element)
return;
}
+ /* First let's check that XVideo extension is available */
+ if (!XQueryExtension (dpy, "XVideo", &i, &i, &i)) {
+ GST_WARNING ("Xv extension not available - no overlay");
+ XCloseDisplay (dpy);
+ return;
+ }
+
/* find port that belongs to this device */
if (XvQueryExtension (dpy, &ver, &rel, &req, &ev, &err) != Success) {
GST_WARNING ("Xv extension not supported - no overlay");
@@ -93,7 +100,7 @@ gst_v4l2_xoverlay_open (GstV4l2Element * v4l2element)
}
min = s.st_rdev & 0xff;
for (i = 0; i < anum; i++) {
- if (!strcmp (ai[i].name, "video4linux")) {
+ if (!strcmp (ai[i].name, "video4linux2")) {
if (first_id == 0)
first_id = ai[i].base_id;
@@ -123,7 +130,7 @@ gst_v4l2_xoverlay_open (GstV4l2Element * v4l2element)
}
}
-void
+static void
gst_v4l2_xoverlay_close (GstV4l2Element * v4l2element)
{
GstV4l2Xv *v4l2xv = v4l2element->xv;
@@ -143,6 +150,20 @@ gst_v4l2_xoverlay_close (GstV4l2Element * v4l2element)
v4l2element->xv = NULL;
}
+void
+gst_v4l2_xoverlay_start (GstV4l2Element * v4l2element)
+{
+ if (v4l2element->xwindow_id) {
+ gst_v4l2_xoverlay_open (v4l2element);
+ }
+}
+
+void
+gst_v4l2_xoverlay_stop (GstV4l2Element * v4l2element)
+{
+ gst_v4l2_xoverlay_close (v4l2element);
+}
+
static gboolean
idle_refresh (gpointer data)
{
@@ -170,12 +191,17 @@ static void
gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay * overlay, XID xwindow_id)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (overlay);
- GstV4l2Xv *v4l2xv = v4l2element->xv;
+ GstV4l2Xv *v4l2xv;
XWindowAttributes attr;
gboolean change = (v4l2element->xwindow_id != xwindow_id);
GST_LOG_OBJECT (v4l2element, "Setting XID to %lx", (gulong) xwindow_id);
+ if (!v4l2element->xv && GST_V4L2_IS_OPEN (v4l2element))
+ gst_v4l2_xoverlay_open (v4l2element);
+
+ v4l2xv = v4l2element->xv;
+
if (v4l2xv)
g_mutex_lock (v4l2xv->mutex);