initial commit of xv support work

This commit is contained in:
Dodji Seketeli 2007-07-21 12:08:39 +02:00 committed by Dodji Seketeli
parent 95fadbd402
commit 50a64c84e1
8 changed files with 919 additions and 9 deletions

View File

@ -3,22 +3,29 @@ INCLUDES = \
@KDRIVE_CFLAGS@ \
-I$(srcdir)/../../../exa
noinst_LIBRARIES = libxephyr.a libxephyr-hostx.a
noinst_LIBRARIES = libxephyr-hostx.a libxephyr-hostxv.a libxephyr.a
bin_PROGRAMS = Xephyr
libxephyr_hostx_a_SOURCES = \
hostx.c \
hostx.h
libxephyr_hostx_a_INCLUDES = @XEPHYR_INCS@
libxephyr_hostxv_a_SOURCES= \
ephyrhostvideo.c \
ephyrhostvideo.h
libxephyr_a_SOURCES = \
ephyr.c \
ephyr_draw.c \
ephyrvideo.c \
os.c \
hostx.h \
ephyr.h
libxephyr_hostx_a_SOURCES = \
hostx.c \
hostx.h
libxephyr_hostx_a_INCLUDES = @XEPHYR_INCS@
hostx.h \
ephyr.h \
ephyrlog.h
Xephyr_SOURCES = \
ephyrinit.c
@ -26,6 +33,7 @@ Xephyr_SOURCES = \
Xephyr_LDADD = \
libxephyr.a \
libxephyr-hostx.a \
libxephyr-hostxv.a \
../../../exa/libexa.la \
@KDRIVE_LIBS@ \
@XEPHYR_LIBS@
@ -33,6 +41,7 @@ Xephyr_LDADD = \
Xephyr_DEPENDENCIES = \
libxephyr.a \
libxephyr-hostx.a \
libxephyr-hostxv.a \
@KDRIVE_LOCAL_LIBS@
relink:

View File

@ -194,4 +194,8 @@ ephyrDrawDisable(ScreenPtr pScreen);
void
ephyrDrawFini(ScreenPtr pScreen);
/*ephyvideo.c*/
Bool ephyrInitVideo(ScreenPtr pScreen) ;
#endif

View File

@ -0,0 +1,234 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
*
* Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of OpenedHand Ltd not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. OpenedHand Ltd makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors:
* Dodji Seketeli <dodji@openedhand.com>
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include <X11/Xlib.h>
#include <X11/extensions/Xvlib.h>
#include "hostx.h"
#include "ephyrhostvideo.h"
#include "ephyrlog.h"
#ifndef TRUE
#define TRUE 1
#endif /*TRUE*/
#ifndef FALSE
#define FALSE 0
#endif /*FALSE*/
struct _EphyrHostXVAdaptorArray {
XvAdaptorInfo *adaptors ;
unsigned int nb_adaptors ;
};
Bool
EphyrHostXVQueryAdaptors (EphyrHostXVAdaptorArray **a_adaptors)
{
EphyrHostXVAdaptorArray *result=NULL ;
int ret=0 ;
Bool is_ok=FALSE ;
EPHYR_RETURN_VAL_IF_FAIL (a_adaptors, FALSE) ;
EPHYR_LOG ("enter\n") ;
result = Xcalloc (sizeof (EphyrHostXVAdaptorArray)) ;
if (!result)
goto out ;
ret = XvQueryAdaptors (hostx_get_display (),
DefaultRootWindow (hostx_get_display),
&result->nb_adaptors,
&result->adaptors) ;
if (ret != Success) {
EPHYR_LOG_ERROR ("failed to query host adaptors: %d\n", ret) ;
goto out ;
}
is_ok = TRUE ;
out:
EPHYR_LOG ("leave\n") ;
return is_ok ;
}
void
EphyrHostXVAdaptorArrayDelete (EphyrHostXVAdaptorArray *a_adaptors)
{
if (!a_adaptors)
return ;
if (a_adaptors->adaptors) {
XvFreeAdaptorInfo (a_adaptors->adaptors) ;
a_adaptors->adaptors = NULL ;
a_adaptors->nb_adaptors = 0 ;
}
XFree (a_adaptors) ;
}
int
EphyrHostXVAdaptorArrayGetSize (const EphyrHostXVAdaptorArray *a_this)
{
EPHYR_RETURN_VAL_IF_FAIL (a_this, -1) ;
return a_this->nb_adaptors ;
}
EphyrHostXVAdaptor*
EphyrHostXVAdaptorArrayAt (const EphyrHostXVAdaptorArray *a_this,
int a_index)
{
EPHYR_RETURN_VAL_IF_FAIL (a_this, NULL) ;
if (a_index >= a_this->nb_adaptors)
return NULL ;
return (EphyrHostXVAdaptor*)&a_this->adaptors[a_index] ;
}
char
EphyrHostXVAdaptorGetType (const EphyrHostXVAdaptor *a_this)
{
EPHYR_RETURN_VAL_IF_FAIL (a_this, -1) ;
return ((XvAdaptorInfo*)a_this)->type ;
}
const char*
EphyrHostXVAdaptorGetName (const EphyrHostXVAdaptor *a_this)
{
EPHYR_RETURN_VAL_IF_FAIL (a_this, NULL) ;
return ((XvAdaptorInfo*)a_this)->name ;
}
const EphyrHostVideoFormat*
EphyrHostXVAdaptorGetVideoFormats (const EphyrHostXVAdaptor *a_this,
int *a_nb_formats)
{
EPHYR_RETURN_VAL_IF_FAIL (a_this, NULL) ;
if (a_nb_formats)
*a_nb_formats = ((XvAdaptorInfo*)a_this)->num_formats ;
return (EphyrHostVideoFormat*) ((XvAdaptorInfo*)a_this)->formats ;
}
int
EphyrHostXVAdaptorGetNbPorts (const EphyrHostXVAdaptor *a_this)
{
EPHYR_RETURN_VAL_IF_FAIL (a_this, -1) ;
return ((XvAdaptorInfo*)a_this)->num_ports ;
}
int
EphyrHostXVAdaptorGetFirstPortID (const EphyrHostXVAdaptor *a_this)
{
EPHYR_RETURN_VAL_IF_FAIL (a_this, -1) ;
return ((XvAdaptorInfo*)a_this)->base_id ;
}
Bool
EphyrHostXVQueryEncodings (int a_port_id,
EphyrHostEncoding **a_encodings,
unsigned int *a_num_encodings)
{
int ret = 0 ;
EPHYR_RETURN_VAL_IF_FAIL (a_encodings && a_num_encodings, FALSE) ;
ret = XvQueryEncodings (hostx_get_display (),
a_port_id,
a_num_encodings,
(XvEncodingInfo**)a_encodings) ;
if (ret == Success)
return TRUE ;
return FALSE ;
}
void
EphyrHostEncodingsDelete (EphyrHostEncoding *a_encodings,
int a_num_encodings)
{
int i=0 ;
if (!a_encodings)
return ;
for (i=0; i < a_num_encodings; i++) {
if (a_encodings[i].name) {
xfree (a_encodings[i].name) ;
a_encodings[i].name = NULL ;
}
}
xfree (a_encodings) ;
}
void
EphyrHostAttributesDelete (EphyrHostAttribute *a_attributes,
int a_num_attributes)
{
int i=0 ;
if (!a_attributes)
return ;
for (i=0; i < a_num_attributes; i++) {
if (a_attributes[i].name) {
xfree (a_attributes[i].name) ;
a_attributes[i].name = NULL ;
}
}
xfree (a_attributes) ;
}
Bool
EphyrHostXVQueryPortAttributes (int a_port_id,
EphyrHostAttribute **a_attributes,
int *a_num_attributes)
{
XvAttribute *attributes=NULL ;
int num_attributes=0 ;
EPHYR_RETURN_VAL_IF_FAIL (a_attributes && a_num_attributes, FALSE) ;
attributes = XvQueryPortAttributes (hostx_get_display (), a_port_id, &num_attributes) ;
*a_attributes = (EphyrHostAttribute*)attributes ;
return TRUE ;
}
Bool
EphyrHostXVQueryImageFormats (int a_port_id,
EphyrHostImageFormat **a_formats,
int *a_num_format)
{
XvImageFormatValues *result=NULL ;
EPHYR_RETURN_VAL_IF_FAIL (a_formats && a_num_format, FALSE) ;
result = XvListImageFormats (hostx_get_display (), a_port_id, a_num_format) ;
*a_formats = (EphyrHostImageFormat*) result ;
return TRUE ;
}

View File

@ -0,0 +1,139 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
*
* Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of OpenedHand Ltd not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. OpenedHand Ltd makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors:
* Dodji Seketeli <dodji@openedhand.com>
*/
#ifndef __EPHYRHOSTVIDEO_H__
#define __EPHYRHOSTVIDEO_H__
typedef void* EphyrHostXVAdaptor ;
typedef struct _EphyrHostXVAdaptorArray EphyrHostXVAdaptorArray ;
typedef struct _EphyrHostVideoFormat {
char depth ;
unsigned long visual_id;
} EphyrHostVideoFormat ;
typedef struct _EphyrHostRational {
int numerator ;
int denominator ;
} EphyrHostRational;
typedef struct _EphyrHostEncoding {
int id ;
char *name ;
unsigned short width, height ;
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 */
int byte_order; /* LSBFirst, MSBFirst */
char guid[16]; /* Globally Unique IDentifier */
int bits_per_pixel;
int format; /* XvPacked, XvPlanar */
int num_planes;
/* for RGB formats only */
int depth;
unsigned int red_mask;
unsigned int green_mask;
unsigned int blue_mask;
/* for YUV formats only */
unsigned int y_sample_bits;
unsigned int u_sample_bits;
unsigned int v_sample_bits;
unsigned int horz_y_period;
unsigned int horz_u_period;
unsigned int horz_v_period;
unsigned int vert_y_period;
unsigned int vert_u_period;
unsigned int vert_v_period;
char component_order[32]; /* eg. UYVY */
int scanline_order; /* XvTopToBottom, XvBottomToTop */
} EphyrHostImageFormat ;
/*
* 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) ;
/*
* host adaptor
*/
char EphyrHostXVAdaptorGetType (const EphyrHostXVAdaptor *a_this) ;
const char* EphyrHostXVAdaptorGetName (const EphyrHostXVAdaptor *a_this) ;
const EphyrHostVideoFormat* EphyrHostXVAdaptorGetNbVideoFormats
(const EphyrHostXVAdaptor *a_this) ;
const EphyrHostVideoFormat* EphyrHostXVAdaptorGetVideoFormats
(const EphyrHostXVAdaptor *a_this,
int *a_nb_formats) ;
int EphyrHostXVAdaptorGetNbPorts (const EphyrHostXVAdaptor *a_this) ;
int EphyrHostXVAdaptorGetFirstPortID (const EphyrHostXVAdaptor *a_this) ;
/*
* encoding
*/
Bool EphyrHostXVQueryEncodings (int a_port_id,
EphyrHostEncoding **a_encodings,
unsigned int *a_num_encodings) ;
void EphyrHostEncodingsDelete (EphyrHostEncoding *a_encodings,
int a_num_encodings) ;
/*
* attribute
*/
Bool EphyrHostXVQueryPortAttributes (int a_port_id,
EphyrHostAttribute **a_attributes,
int *a_num_attributes) ;
void EphyrHostAttributesDelete (EphyrHostAttribute *a_attributes,
int a_num_attributes) ;
/*
* image format
*/
Bool EphyrHostXVQueryImageFormats (int a_port_id,
EphyrHostImageFormat **a_formats,
int *a_num_format) ;
#endif /*__EPHYRHOSTVIDEO_H__*/

View File

@ -0,0 +1,67 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
*
* Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of OpenedHand Ltd not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. OpenedHand Ltd makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors:
* Dodji Seketeli <dodji@openedhand.com>
*/
#ifndef __EPHYRLOG_H__
#define __EPHYRLOG_H__
#include <assert.h>
#include "os.h"
#ifdef NDEBUG
/*we are not in debug mode*/
#define EPHYR_LOG
#define EPHYR_LOG_ERROR
#endif /*NDEBUG*/
#define ERROR_LOG_LEVEL 3
#define INFO_LOG_LEVEL 4
#ifndef EPHYR_LOG
#define EPHYR_LOG(...) \
LogMessageVerb(X_NOTICE, INFO_LOG_LEVEL, "in %s:%d:%s: ",\
__FILE__, __LINE__, __func__) ; \
LogMessageVerb(X_NOTICE, INFO_LOG_LEVEL, __VA_ARGS__)
#endif /*nomadik_log*/
#ifndef EPHYR_LOG_ERROR
#define EPHYR_LOG_ERROR(...) \
LogMessageVerb(X_NOTICE, ERROR_LOG_LEVEL, "Error:in %s:%d:%s: ",\
__FILE__, __LINE__, __func__) ; \
LogMessageVerb(X_NOTICE, ERROR_LOG_LEVEL, __VA_ARGS__)
#endif /*EPHYR_LOG_ERROR*/
#ifndef EPHYR_RETURN_IF_FAIL
#define EPHYR_RETURN_IF_FAIL(cond) \
if (!(cond)) {EPHYR_LOG_ERROR("condition %s failed\n", #cond);return;}
#endif /*nomadik_return_if_fail*/
#ifndef EPHYR_RETURN_VAL_IF_FAIL
#define EPHYR_RETURN_VAL_IF_FAIL(cond,val) \
if (!(cond)) {EPHYR_LOG_ERROR("condition %s failed\n", #cond);return val;}
#endif /*nomadik_return_val_if_fail*/
#endif /*__EPHYRLOG_H__*/

View File

@ -0,0 +1,448 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
*
* Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of OpenedHand Ltd not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. OpenedHand Ltd makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors:
* Dodji Seketeli <dodji@openedhand.com>
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include <string.h>
#include <X11/extensions/Xv.h>
#include "ephyrlog.h"
#include "kdrive.h"
#include "kxv.h"
#include "ephyr.h"
#include "hostx.h"
#include "ephyrhostvideo.h"
struct _EphyrXVPriv {
EphyrHostXVAdaptorArray *host_adaptors ;
KdVideoAdaptorPtr adaptors ;
int num_adaptors ;
};
typedef struct _EphyrXVPriv EphyrXVPriv ;
static EphyrXVPriv* EphyrXVPrivNew (void) ;
static void EphyrXVPrivDelete (EphyrXVPriv *a_this) ;
static Bool EphyrXVPrivQueryHostAdaptors (EphyrXVPriv *a_this) ;
static Bool EphyrXVPrivSetAdaptorsHooks (EphyrXVPriv *a_this) ;
static void EphyrStopVideo (KdScreenInfo *a_info,
pointer a_xv_priv,
Bool a_exit);
static int EphyrSetPortAttribute (KdScreenInfo *a_info,
Atom a_attr_name,
int a_attr_value,
pointer a_xv_priv);
static int EphyrGetPortAttribute (KdScreenInfo *a_screen_info,
Atom a_attr_name,
int *a_attr_value,
pointer a_xv_priv);
static void EphyrQueryBestSize (KdScreenInfo *a_info,
Bool a_motion,
short a_src_w,
short a_src_h,
short a_drw_w,
short a_drw_h,
unsigned int *a_prefered_w,
unsigned int *a_prefered_h,
pointer a_xv_priv);
static int EphyrPutImage (KdScreenInfo *a_info,
DrawablePtr a_drawable,
short a_src_x,
short a_src_y,
short a_drw_x,
short a_drw_y,
short a_src_w,
short a_src_h,
short a_drw_w,
short a_drw_h,
int a_id,
unsigned char *a_buf,
short a_width,
short a_height,
Bool a_sync,
RegionPtr a_clipping_region,
pointer a_xv_priv);
static int EphyrQueryImageAttributes (KdScreenInfo *a_info,
int a_id,
unsigned short *a_w,
unsigned short *a_h,
int *a_pitches,
int *a_offsets);
Bool
ephyrInitVideo (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
EphyrXVPriv *xv_priv = NULL ;
KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL;
KdVideoAdaptorPtr newAdaptor = NULL;
int num_adaptors=0;
EPHYR_LOG ("enter\n") ;
if (screen->fb[0].bitsPerPixel == 8) {
EPHYR_LOG_ERROR ("8 bits depth not supported\n") ;
return FALSE ;
}
xv_priv = EphyrXVPrivNew () ;
if (!xv_priv) {
EPHYR_LOG_ERROR ("failed to create xv_priv\n") ;
return FALSE ;
}
/*
* TODO:
* queried host adaptors, now get xv_priv->adaptors and.
* add it to those already existing.
*/
num_adaptors = KdXVListGenericAdaptors (screen, &adaptors);
if (newAdaptor) {
if (!num_adaptors) {
num_adaptors = 1;
adaptors = &newAdaptor;
} else {
newAdaptors = xalloc ((num_adaptors + 1) * sizeof(KdVideoAdaptorPtr*));
if (newAdaptors) {
memcpy (newAdaptors,
adaptors,
num_adaptors * sizeof(KdVideoAdaptorPtr));
newAdaptors[num_adaptors] = newAdaptor;
adaptors = newAdaptors;
num_adaptors++;
}
}
}
if (num_adaptors) {
KdXVScreenInit (pScreen, adaptors, num_adaptors);
} else {
EPHYR_LOG_ERROR ("XVideo not initialised\n") ;
}
if (newAdaptors)
xfree (newAdaptors);
return TRUE;
}
static EphyrXVPriv*
EphyrXVPrivNew (void)
{
EphyrXVPriv *xv_priv=NULL ;
EPHYR_LOG ("enter\n") ;
xv_priv = xcalloc (1, sizeof (EphyrXVPriv)) ;
if (!xv_priv) {
EPHYR_LOG_ERROR ("failed to create EphyrXVPriv\n") ;
goto error ;
}
if (!EphyrXVPrivQueryHostAdaptors (xv_priv)) {
EPHYR_LOG_ERROR ("failed to query the host x for xv properties\n") ;
goto error ;
}
if (EphyrXVPrivSetAdaptorsHooks (xv_priv)) {
EPHYR_LOG_ERROR ("failed to set xv_priv hooks\n") ;
goto error ;
}
EPHYR_LOG ("leave\n") ;
return xv_priv ;
error:
if (xv_priv) {
EphyrXVPrivDelete (xv_priv) ;
xv_priv = NULL ;
}
return NULL ;
}
static void
EphyrXVPrivDelete (EphyrXVPriv *a_this)
{
EPHYR_LOG ("enter\n") ;
if (!a_this)
return ;
if (a_this->host_adaptors) {
EphyrHostXVAdaptorArrayDelete (a_this->host_adaptors) ;
a_this->host_adaptors = NULL ;
}
if (a_this->adaptors) {
xfree (a_this->adaptors) ;
a_this->adaptors = NULL ;
}
xfree (a_this) ;
EPHYR_LOG ("leave\n") ;
}
static KdVideoEncodingPtr
videoEncodingDup (EphyrHostEncoding *a_encodings,
int a_num_encodings)
{
KdVideoEncodingPtr result = NULL ;
int i=0 ;
EPHYR_RETURN_VAL_IF_FAIL (a_encodings && a_num_encodings, NULL) ;
result = xcalloc (a_num_encodings, sizeof (KdVideoEncodingRec)) ;
for (i=0 ; i < a_num_encodings; i++) {
result[i].id = a_encodings[i].id ;
result[i].name = strdup (a_encodings[i].name) ;
result[i].width = a_encodings[i].width ;
result[i].height = a_encodings[i].height ;
result[i].rate.numerator = a_encodings[i].rate.numerator ;
result[i].rate.denominator = a_encodings[i].rate.denominator ;
}
return result ;
}
static KdAttributePtr
portAttributesDup (EphyrHostAttribute *a_encodings,
int a_num_encodings)
{
int i=0 ;
KdAttributePtr result=NULL ;
EPHYR_RETURN_VAL_IF_FAIL (a_encodings && a_num_encodings, NULL) ;
result = xcalloc (a_num_encodings, 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) ;
}
return result ;
}
static Bool
EphyrXVPrivQueryHostAdaptors (EphyrXVPriv *a_this)
{
EphyrHostXVAdaptor *cur_host_adaptor=NULL ;
EphyrHostVideoFormat *video_formats=NULL ;
EphyrHostEncoding *encodings=NULL ;
EphyrHostAttribute *attributes=NULL ;
EphyrHostImageFormat *image_formats=NULL ;
int num_video_formats=0, base_port_id=0, num_attributes=0, num_formats=0, res=0, i=0 ;
unsigned num_encodings=0 ;
Bool is_ok = FALSE ;
EPHYR_RETURN_VAL_IF_FAIL (a_this, FALSE) ;
if (!EphyrHostXVQueryAdaptors (&a_this->host_adaptors) || !a_this->host_adaptors) {
EPHYR_LOG_ERROR ("failed to query host adaptors: %d\n", res) ;
goto out ;
}
a_this->num_adaptors = EphyrHostXVAdaptorArrayGetSize (a_this->host_adaptors) ;
if (a_this->num_adaptors < 0) {
EPHYR_LOG_ERROR ("failed to get number of host adaptors\n") ;
goto out ;
}
/*
* copy what we can from adaptors into a_this->adaptors
*/
a_this->adaptors = xcalloc (a_this->num_adaptors, sizeof (KdVideoAdaptorRec)) ;
if (!a_this->host_adaptors) {
EPHYR_LOG_ERROR ("failed to create internal adaptors\n") ;
goto out ;
}
for (i=0; i < a_this->num_adaptors; i++) {
int j=0 ;
cur_host_adaptor = EphyrHostXVAdaptorArrayAt (a_this->host_adaptors, i) ;
if (!cur_host_adaptor)
continue ;
a_this->adaptors[i].type = EphyrHostXVAdaptorGetType (cur_host_adaptor) ;
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)) ;
a_this->adaptors[i].name = "Xephyr Video Overlay";
base_port_id = EphyrHostXVAdaptorGetFirstPortID (cur_host_adaptor) ;
if (base_port_id < 0) {
EPHYR_LOG_ERROR ("failed to get port id for adaptor %d\n", i) ;
continue ;
}
if (!EphyrHostXVQueryEncodings (base_port_id, &encodings, &num_encodings)) {
EPHYR_LOG_ERROR ("failed to get encodings for port port id %d, adaptors %d\n",
base_port_id, i) ;
continue ;
}
a_this->adaptors[i].nEncodings = num_encodings ;
a_this->adaptors[i].pEncodings = videoEncodingDup (encodings, num_encodings) ;
video_formats = (EphyrHostVideoFormat*)
EphyrHostXVAdaptorGetVideoFormats (cur_host_adaptor, &num_video_formats);
a_this->adaptors[i].pFormats = (KdVideoFormatPtr) video_formats ;
a_this->adaptors[i].nFormats = num_video_formats ;
a_this->adaptors[i].nPorts = EphyrHostXVAdaptorGetNbPorts (cur_host_adaptor) ;
a_this->adaptors[i].pPortPrivates = xcalloc (a_this->adaptors[i].nPorts,
sizeof (DevUnion)) ;
for (j=0; j < a_this->adaptors[i].nPorts; j++) {
a_this->adaptors[i].pPortPrivates[j].ptr = a_this ;
}
if (!EphyrHostXVQueryPortAttributes (base_port_id,
&attributes,
&num_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 ;
if (!EphyrHostXVQueryImageFormats (base_port_id, &image_formats, &num_formats)) {
EPHYR_LOG_ERROR ("failed to get image formats for adaptor %d\n", i) ;
continue ;
}
a_this->adaptors[i].pImages = (KdImagePtr) image_formats ;
}
is_ok = TRUE ;
out:
if (encodings) {
EphyrHostEncodingsDelete (encodings, num_encodings) ;
encodings = NULL ;
}
if (attributes) {
EphyrHostAttributesDelete (attributes, num_attributes) ;
attributes = NULL ;
}
if (image_formats) {
xfree (image_formats) ;
image_formats = NULL ;
}
return is_ok ;
}
static Bool
EphyrXVPrivSetAdaptorsHooks (EphyrXVPriv *a_this)
{
int i=0 ;
EPHYR_RETURN_VAL_IF_FAIL (a_this, FALSE) ;
for (i=0; i < a_this->num_adaptors; i++) {
a_this->adaptors[i].StopVideo = EphyrStopVideo ;
a_this->adaptors[i].SetPortAttribute = EphyrSetPortAttribute ;
a_this->adaptors[i].GetPortAttribute = EphyrGetPortAttribute ;
a_this->adaptors[i].QueryBestSize = EphyrQueryBestSize ;
a_this->adaptors[i].PutImage = EphyrPutImage;
a_this->adaptors[i].QueryImageAttributes = EphyrQueryImageAttributes ;
}
return TRUE ;
}
static void
EphyrStopVideo (KdScreenInfo *a_info, pointer a_xv_priv, Bool a_exit)
{
EPHYR_LOG ("enter\n") ;
EPHYR_LOG ("leave\n") ;
}
static int
EphyrSetPortAttribute (KdScreenInfo *a_info,
Atom a_attr_name,
int a_attr_value,
pointer a_xv_priv)
{
EPHYR_LOG ("enter\n") ;
return 0 ;
EPHYR_LOG ("leave\n") ;
}
static int
EphyrGetPortAttribute (KdScreenInfo *a_screen_info,
Atom a_attr_name,
int *a_attr_value,
pointer a_xv_priv)
{
EPHYR_LOG ("enter\n") ;
return 0 ;
EPHYR_LOG ("leave\n") ;
}
static void
EphyrQueryBestSize (KdScreenInfo *a_info,
Bool a_motion,
short a_src_w,
short a_src_h,
short a_drw_w,
short a_drw_h,
unsigned int *a_prefered_w,
unsigned int *a_prefered_h,
pointer a_xv_priv)
{
}
static int
EphyrPutImage (KdScreenInfo *a_info,
DrawablePtr a_drawable,
short a_src_x,
short a_src_y,
short a_drw_x,
short a_drw_y,
short a_src_w,
short a_src_h,
short a_drw_w,
short a_drw_h,
int a_id,
unsigned char *a_buf,
short a_width,
short a_height,
Bool a_sync,
RegionPtr a_clipping_region,
pointer a_xv_priv)
{
EPHYR_LOG ("enter\n") ;
return 0 ;
EPHYR_LOG ("leave\n") ;
}
static int
EphyrQueryImageAttributes (KdScreenInfo *a_info,
int a_id,
unsigned short *a_w,
unsigned short *a_h,
int *a_pitches,
int *a_offsets)
{
EPHYR_LOG ("enter\n") ;
return 0 ;
EPHYR_LOG ("leave\n") ;
}

View File

@ -956,3 +956,9 @@ hostx_get_event(EphyrHostXEvent *ev)
return 0;
}
void*
hostx_get_display(void)
{
return HostX.dpy ;
}

View File

@ -172,4 +172,7 @@ hostx_load_keymap(void);
int
hostx_get_event(EphyrHostXEvent *ev);
void*
hostx_get_display(void) ;
#endif