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

View File

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