changeset 1591:5b46490d0435 libavformat

Allow provision of displaynumber, screennumber, x-offset and y-offset parameters to the x11grab device.
author takis
date Fri, 15 Dec 2006 13:19:03 +0000
parents ba2244f38a76
children 11d73c89043a
files x11grab.c
diffstat 1 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/x11grab.c	Wed Dec 13 10:18:38 2006 +0000
+++ b/x11grab.c	Fri Dec 15 13:19:03 2006 +0000
@@ -94,20 +94,33 @@
     int x_off = 0;
     int y_off = 0;
     int use_shm;
-
-    dpy = XOpenDisplay(NULL);
-    if(!dpy) {
-        av_free(st);
-        return AVERROR_IO;
-    }
+    char *param, *offset;
 
     if (!ap->device) {
         av_log(s1, AV_LOG_ERROR, "AVParameters don't specify any device. Use -vd.\n");
         return AVERROR_IO;
     }
 
-    sscanf(ap->device, "x11:%d,%d", &x_off, &y_off);
-    av_log(s1, AV_LOG_INFO, "device: %s -> x: %d y: %d width: %d height: %d\n", ap->device, x_off, y_off, ap->width, ap->height);
+    param = strchr(ap->device, ':');
+    if (!param) {
+        av_free(st);
+        return AVERROR_IO;
+    }
+
+    param = av_strdup(param);
+    offset = strchr(param, '+');
+    if (offset) {
+        sscanf(offset, "%d,%d", &x_off, &y_off);
+        *offset= 0;
+    }
+
+    av_log(s1, AV_LOG_INFO, "device: %s -> display: %s x: %d y: %d width: %d height: %d\n", ap->device, param, x_off, y_off, ap->width, ap->height);
+
+    dpy = XOpenDisplay(param);
+    if(!dpy) {
+        av_log(s1, AV_LOG_ERROR, "Could not open X display.\n");
+        return AVERROR_IO;
+    }
 
     if (!ap || ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
         av_log(s1, AV_LOG_ERROR, "AVParameters don't have any video size. Use -s.\n");