Xephyr: use xcb-xv instead of libXv

v2: Massive, conflict-filled rebase.  I think I resolved everything
    right, but this host xv code makes my eyes bleed.  Touch-tested XV
    after the rebase (anholt).

Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net> (v1)
Signed-off-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Julien Cristau 2010-06-20 11:13:26 +01:00 committed by Eric Anholt
parent 3ea75a59d5
commit aea119cd05
4 changed files with 380 additions and 600 deletions

View File

@ -2118,7 +2118,7 @@ if test "$KDRIVE" = yes; then
XEPHYR_REQUIRED_LIBS="x11 >= 1.6 $LIBXEXT xau xdmcp xcb x11-xcb xcb-shape xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms" XEPHYR_REQUIRED_LIBS="x11 >= 1.6 $LIBXEXT xau xdmcp xcb x11-xcb xcb-shape xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms"
if test "x$XV" = xyes; then if test "x$XV" = xyes; then
XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xv" XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xcb-xv"
fi fi
if test "x$DRI" = xyes && test "x$GLX" = xyes; then if test "x$DRI" = xyes && test "x$GLX" = xyes; then
XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS $LIBGL libdrm xcb-glx xcb-xf86dri" XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS $LIBGL libdrm xcb-glx xcb-xf86dri"

File diff suppressed because it is too large Load Diff

View File

@ -28,8 +28,9 @@
#ifndef __EPHYRHOSTVIDEO_H__ #ifndef __EPHYRHOSTVIDEO_H__
#define __EPHYRHOSTVIDEO_H__ #define __EPHYRHOSTVIDEO_H__
typedef void *EphyrHostXVAdaptor;
typedef struct _EphyrHostXVAdaptorArray EphyrHostXVAdaptorArray; typedef struct _EphyrHostXVAdaptorArray EphyrHostXVAdaptorArray;
#include <xcb/xv.h>
#include <X11/Xdefs.h>
typedef struct _EphyrHostVideoFormat { typedef struct _EphyrHostVideoFormat {
char depth; char depth;
@ -48,13 +49,6 @@ typedef struct _EphyrHostEncoding {
EphyrHostRational rate; EphyrHostRational rate;
} EphyrHostEncoding; } EphyrHostEncoding;
typedef struct _EphyrHostAttribute {
int flags;
int min_value;
int max_value;
char *name;
} EphyrHostAttribute;
typedef struct _EphyrHostImageFormat { typedef struct _EphyrHostImageFormat {
int id; /* Unique descriptor for the format */ int id; /* Unique descriptor for the format */
int type; /* XvRGB, XvYUV */ int type; /* XvRGB, XvYUV */
@ -95,32 +89,32 @@ void ephyrHostFree(void *a_pointer);
/* /*
* host adaptor array * host adaptor array
*/ */
Bool ephyrHostXVQueryAdaptors(EphyrHostXVAdaptorArray ** a_adaptors); Bool ephyrHostXVQueryAdaptors(xcb_xv_query_adaptors_reply_t **a_adaptors);
void ephyrHostXVAdaptorArrayDelete(EphyrHostXVAdaptorArray * a_adaptors); void ephyrHostXVAdaptorArrayDelete(xcb_xv_query_adaptors_reply_t *a_adaptors);
int ephyrHostXVAdaptorArrayGetSize(const EphyrHostXVAdaptorArray * a_this); int ephyrHostXVAdaptorArrayGetSize(const xcb_xv_query_adaptors_reply_t *a_this);
EphyrHostXVAdaptor *ephyrHostXVAdaptorArrayAt(const EphyrHostXVAdaptorArray * xcb_xv_adaptor_info_t* ephyrHostXVAdaptorArrayAt(const xcb_xv_query_adaptors_reply_t *a_this,
a_this, int a_index); int a_index);
/* /*
* host adaptor * host adaptor
*/ */
char ephyrHostXVAdaptorGetType(const EphyrHostXVAdaptor * a_this); char ephyrHostXVAdaptorGetType(const xcb_xv_adaptor_info_t *a_this);
const char *ephyrHostXVAdaptorGetName(const EphyrHostXVAdaptor * a_this); char* ephyrHostXVAdaptorGetName(const xcb_xv_adaptor_info_t *a_this);
EphyrHostVideoFormat *ephyrHostXVAdaptorGetVideoFormats EphyrHostVideoFormat *ephyrHostXVAdaptorGetVideoFormats
(const EphyrHostXVAdaptor * a_this, int *a_nb_formats); (const xcb_xv_adaptor_info_t *a_this, int *a_nb_formats);
int ephyrHostXVAdaptorGetNbPorts(const EphyrHostXVAdaptor * a_this); int ephyrHostXVAdaptorGetNbPorts(const xcb_xv_adaptor_info_t *a_this);
int ephyrHostXVAdaptorGetFirstPortID(const EphyrHostXVAdaptor * a_this); int ephyrHostXVAdaptorGetFirstPortID(const xcb_xv_adaptor_info_t *a_this);
Bool ephyrHostXVAdaptorHasPutVideo(const EphyrHostXVAdaptor * a_this, Bool ephyrHostXVAdaptorHasPutVideo(const xcb_xv_adaptor_info_t *a_this,
Bool *a_result); Bool *a_result);
Bool ephyrHostXVAdaptorHasGetVideo(const EphyrHostXVAdaptor * a_this, Bool ephyrHostXVAdaptorHasGetVideo(const xcb_xv_adaptor_info_t *a_this,
Bool *a_result); Bool *a_result);
Bool ephyrHostXVAdaptorHasPutStill(const EphyrHostXVAdaptor * a_this, Bool ephyrHostXVAdaptorHasPutStill(const xcb_xv_adaptor_info_t *a_this,
Bool *a_result); Bool *a_result);
Bool ephyrHostXVAdaptorHasGetStill(const EphyrHostXVAdaptor * a_this, Bool ephyrHostXVAdaptorHasGetStill(const xcb_xv_adaptor_info_t *a_this,
Bool *a_result); Bool *a_result);
Bool ephyrHostXVAdaptorHasPutImage(const EphyrHostXVAdaptor * a_this, Bool ephyrHostXVAdaptorHasPutImage(const xcb_xv_adaptor_info_t *a_this,
Bool *a_result); Bool *a_result);
/* /*
@ -137,10 +131,9 @@ void ephyrHostEncodingsDelete(EphyrHostEncoding * a_encodings,
* attribute * attribute
*/ */
Bool ephyrHostXVQueryPortAttributes(int a_port_id, Bool ephyrHostXVQueryPortAttributes(int a_port_id,
EphyrHostAttribute ** a_attributes, xcb_xv_query_port_attributes_reply_t **a_attributes);
int *a_num_attributes);
void ephyrHostAttributesDelete(EphyrHostAttribute * a_attributes); void ephyrHostAttributesDelete(xcb_xv_query_port_attributes_reply_t *a_attributes);
/* /*
* image format * image format

View File

@ -39,7 +39,7 @@
#include "ephyrhostvideo.h" #include "ephyrhostvideo.h"
struct _EphyrXVPriv { struct _EphyrXVPriv {
EphyrHostXVAdaptorArray *host_adaptors; xcb_xv_query_adaptors_reply_t *host_adaptors;
KdVideoAdaptorPtr adaptors; KdVideoAdaptorPtr adaptors;
int num_adaptors; int num_adaptors;
}; };
@ -381,23 +381,29 @@ videoEncodingDup(EphyrHostEncoding * a_encodings, int a_num_encodings)
} }
static KdAttributePtr static KdAttributePtr
portAttributesDup(EphyrHostAttribute * a_encodings, int a_num_encodings) portAttributesDup(const xcb_xv_query_port_attributes_reply_t *a_encodings)
{ {
int i = 0; int i = 0;
KdAttributePtr result = NULL; KdAttributePtr result = NULL;
xcb_xv_attribute_info_iterator_t it;
EPHYR_RETURN_VAL_IF_FAIL(a_encodings && a_num_encodings, NULL); EPHYR_RETURN_VAL_IF_FAIL(a_encodings, NULL);
result = calloc(a_num_encodings, sizeof(KdAttributeRec)); result = calloc(a_encodings->num_attributes, sizeof(KdAttributeRec));
if (!result) { if (!result) {
EPHYR_LOG_ERROR("failed to allocate attributes\n"); EPHYR_LOG_ERROR("failed to allocate attributes\n");
return NULL; return NULL;
} }
for (i = 0; i < a_num_encodings; i++) { it = xcb_xv_query_port_attributes_attributes_iterator(a_encodings);
result[i].flags = a_encodings[i].flags; for (i = 0;
result[i].min_value = a_encodings[i].min_value; i < a_encodings->num_attributes;
result[i].max_value = a_encodings[i].max_value; xcb_xv_attribute_info_next(&it), i++) {
result[i].name = strdup(a_encodings[i].name); result[i].flags = it.data->flags;
result[i].min_value = it.data->min;
result[i].max_value = it.data->max;
result[i].name = malloc(it.data->size + 1);
memcpy (result[i].name, xcb_xv_attribute_info_name(it.data), it.data->size);
result[i].name[it.data->size] = '\0';
} }
return result; return result;
} }
@ -405,13 +411,13 @@ portAttributesDup(EphyrHostAttribute * a_encodings, int a_num_encodings)
static Bool static Bool
ephyrXVPrivQueryHostAdaptors(EphyrXVPriv * a_this) ephyrXVPrivQueryHostAdaptors(EphyrXVPriv * a_this)
{ {
EphyrHostXVAdaptor *cur_host_adaptor = NULL; xcb_xv_adaptor_info_t *cur_host_adaptor = NULL;
EphyrHostVideoFormat *video_formats = NULL; EphyrHostVideoFormat *video_formats = NULL;
EphyrHostEncoding *encodings = NULL; EphyrHostEncoding *encodings = NULL;
EphyrHostAttribute *attributes = NULL; xcb_xv_query_port_attributes_reply_t *attributes = NULL;
EphyrHostImageFormat *image_formats = NULL; EphyrHostImageFormat *image_formats = NULL;
int num_video_formats = 0, base_port_id = 0, int num_video_formats = 0, base_port_id = 0,
num_attributes = 0, num_formats = 0, i = 0, port_priv_offset = 0; num_formats = 0, i = 0, port_priv_offset = 0;
unsigned num_encodings = 0; unsigned num_encodings = 0;
Bool is_ok = FALSE; Bool is_ok = FALSE;
@ -458,10 +464,8 @@ ephyrXVPrivQueryHostAdaptors(EphyrXVPriv * a_this)
a_this->adaptors[i].type |= XvWindowMask; a_this->adaptors[i].type |= XvWindowMask;
a_this->adaptors[i].flags = a_this->adaptors[i].flags =
VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
if (ephyrHostXVAdaptorGetName(cur_host_adaptor)) a_this->adaptors[i].name = ephyrHostXVAdaptorGetName(cur_host_adaptor);
a_this->adaptors[i].name = if (!a_this->adaptors[i].name)
strdup(ephyrHostXVAdaptorGetName(cur_host_adaptor));
else
a_this->adaptors[i].name = strdup("Xephyr Video Overlay"); a_this->adaptors[i].name = strdup("Xephyr Video Overlay");
base_port_id = ephyrHostXVAdaptorGetFirstPortID(cur_host_adaptor); base_port_id = ephyrHostXVAdaptorGetFirstPortID(cur_host_adaptor);
if (base_port_id < 0) { if (base_port_id < 0) {
@ -504,15 +508,14 @@ ephyrXVPrivQueryHostAdaptors(EphyrXVPriv * a_this)
port_priv->xv_priv = a_this; port_priv->xv_priv = a_this;
a_this->adaptors[i].pPortPrivates[j].ptr = port_priv; a_this->adaptors[i].pPortPrivates[j].ptr = port_priv;
} }
if (!ephyrHostXVQueryPortAttributes(base_port_id, if (!ephyrHostXVQueryPortAttributes(base_port_id, &attributes)) {
&attributes, &num_attributes)) {
EPHYR_LOG_ERROR("failed to get port attribute " EPHYR_LOG_ERROR("failed to get port attribute "
"for adaptor %d\n", i); "for adaptor %d\n", i);
continue; continue;
} }
a_this->adaptors[i].pAttributes = a_this->adaptors[i].pAttributes =
portAttributesDup(attributes, num_attributes); portAttributesDup(attributes);
a_this->adaptors[i].nAttributes = num_attributes; a_this->adaptors[i].nAttributes = attributes->num_attributes;
/*make sure atoms of attrs names are created in xephyr */ /*make sure atoms of attrs names are created in xephyr */
for (j = 0; j < a_this->adaptors[i].nAttributes; j++) { for (j = 0; j < a_this->adaptors[i].nAttributes; j++) {
if (a_this->adaptors[i].pAttributes[j].name) if (a_this->adaptors[i].pAttributes[j].name)
@ -548,7 +551,7 @@ ephyrXVPrivSetAdaptorsHooks(EphyrXVPriv * a_this)
{ {
int i = 0; int i = 0;
Bool has_it = FALSE; Bool has_it = FALSE;
EphyrHostXVAdaptor *cur_host_adaptor = NULL; xcb_xv_adaptor_info_t *cur_host_adaptor = NULL;
EPHYR_RETURN_VAL_IF_FAIL(a_this, FALSE); EPHYR_RETURN_VAL_IF_FAIL(a_this, FALSE);