ephyr: Remove the host/server split for video encodings.
Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Julien Cristau <jcristau@debian.org>
This commit is contained in:
parent
28a37757e1
commit
1dcc28bcb4
|
@ -43,58 +43,6 @@
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
#endif /*FALSE*/
|
#endif /*FALSE*/
|
||||||
|
|
||||||
Bool
|
|
||||||
ephyrHostXVQueryEncodings(int a_port_id,
|
|
||||||
EphyrHostEncoding ** a_encodings,
|
|
||||||
unsigned int *a_num_encodings)
|
|
||||||
{
|
|
||||||
EphyrHostEncoding *encodings = NULL;
|
|
||||||
xcb_xv_encoding_info_iterator_t encoding_info;
|
|
||||||
xcb_xv_query_encodings_cookie_t cookie;
|
|
||||||
xcb_xv_query_encodings_reply_t *reply;
|
|
||||||
unsigned int num_encodings = 0, i;
|
|
||||||
|
|
||||||
EPHYR_RETURN_VAL_IF_FAIL(a_encodings && a_num_encodings, FALSE);
|
|
||||||
|
|
||||||
cookie = xcb_xv_query_encodings(hostx_get_xcbconn(), a_port_id);
|
|
||||||
reply = xcb_xv_query_encodings_reply(hostx_get_xcbconn(), cookie, NULL);
|
|
||||||
if (!reply)
|
|
||||||
return FALSE;
|
|
||||||
num_encodings = reply->num_encodings;
|
|
||||||
encoding_info = xcb_xv_query_encodings_info_iterator(reply);
|
|
||||||
if (num_encodings) {
|
|
||||||
encodings = calloc(num_encodings, sizeof (EphyrHostEncoding));
|
|
||||||
for (i=0; i<num_encodings; i++, xcb_xv_encoding_info_next(&encoding_info)) {
|
|
||||||
encodings[i].id = encoding_info.data->encoding;
|
|
||||||
encodings[i].name = malloc(encoding_info.data->name_size + 1);
|
|
||||||
memcpy(encodings[i].name, xcb_xv_encoding_info_name(encoding_info.data), encoding_info.data->name_size);
|
|
||||||
encodings[i].name[encoding_info.data->name_size] = '\0';
|
|
||||||
encodings[i].width = encoding_info.data->width;
|
|
||||||
encodings[i].height = encoding_info.data->height;
|
|
||||||
encodings[i].rate.numerator = encoding_info.data->rate.numerator;
|
|
||||||
encodings[i].rate.denominator = encoding_info.data->rate.denominator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(reply);
|
|
||||||
*a_encodings = encodings;
|
|
||||||
*a_num_encodings = num_encodings;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ephyrHostEncodingsDelete(EphyrHostEncoding * a_encodings, int a_num_encodings)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
if (!a_encodings)
|
|
||||||
return;
|
|
||||||
for (i = 0; i < a_num_encodings; i++) {
|
|
||||||
free(a_encodings[i].name);
|
|
||||||
a_encodings[i].name = NULL;
|
|
||||||
}
|
|
||||||
free(a_encodings);
|
|
||||||
}
|
|
||||||
Bool
|
Bool
|
||||||
ephyrHostXVQueryImageFormats(int a_port_id,
|
ephyrHostXVQueryImageFormats(int a_port_id,
|
||||||
EphyrHostImageFormat ** a_formats,
|
EphyrHostImageFormat ** a_formats,
|
||||||
|
|
|
@ -31,18 +31,6 @@
|
||||||
#include <xcb/xv.h>
|
#include <xcb/xv.h>
|
||||||
#include <X11/Xdefs.h>
|
#include <X11/Xdefs.h>
|
||||||
|
|
||||||
typedef struct _EphyrHostRational {
|
|
||||||
int numerator;
|
|
||||||
int denominator;
|
|
||||||
} EphyrHostRational;
|
|
||||||
|
|
||||||
typedef struct _EphyrHostEncoding {
|
|
||||||
int id;
|
|
||||||
char *name;
|
|
||||||
unsigned short width, height;
|
|
||||||
EphyrHostRational rate;
|
|
||||||
} EphyrHostEncoding;
|
|
||||||
|
|
||||||
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 */
|
||||||
|
@ -76,16 +64,6 @@ typedef struct {
|
||||||
unsigned short x1, y1, x2, y2;
|
unsigned short x1, y1, x2, y2;
|
||||||
} EphyrHostBox;
|
} EphyrHostBox;
|
||||||
|
|
||||||
/*
|
|
||||||
* encoding
|
|
||||||
*/
|
|
||||||
Bool ephyrHostXVQueryEncodings(int a_port_id,
|
|
||||||
EphyrHostEncoding ** a_encodings,
|
|
||||||
unsigned int *a_num_encodings);
|
|
||||||
|
|
||||||
void ephyrHostEncodingsDelete(EphyrHostEncoding * a_encodings,
|
|
||||||
int a_num_encodings);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* image format
|
* image format
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -332,24 +332,47 @@ ephyrXVPrivDelete(EphyrXVPriv * a_this)
|
||||||
EPHYR_LOG("leave\n");
|
EPHYR_LOG("leave\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static KdVideoEncodingPtr
|
static Bool
|
||||||
videoEncodingDup(EphyrHostEncoding * a_encodings, int a_num_encodings)
|
translate_video_encodings(KdVideoAdaptorPtr adaptor,
|
||||||
|
xcb_xv_adaptor_info_t *host_adaptor)
|
||||||
{
|
{
|
||||||
KdVideoEncodingPtr result = NULL;
|
xcb_connection_t *conn = hostx_get_xcbconn();
|
||||||
int i = 0;
|
int i;
|
||||||
|
xcb_xv_query_encodings_cookie_t cookie;
|
||||||
|
xcb_xv_query_encodings_reply_t *reply;
|
||||||
|
xcb_xv_encoding_info_iterator_t encoding_it;
|
||||||
|
|
||||||
EPHYR_RETURN_VAL_IF_FAIL(a_encodings && a_num_encodings, NULL);
|
cookie = xcb_xv_query_encodings(conn, host_adaptor->base_id);
|
||||||
|
reply = xcb_xv_query_encodings_reply(conn, cookie, NULL);
|
||||||
|
if (!reply)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
result = calloc(a_num_encodings, sizeof(KdVideoEncodingRec));
|
adaptor->nEncodings = reply->num_encodings;
|
||||||
for (i = 0; i < a_num_encodings; i++) {
|
adaptor->pEncodings = calloc(adaptor->nEncodings,
|
||||||
result[i].id = a_encodings[i].id;
|
sizeof(*adaptor->pEncodings));
|
||||||
result[i].name = strdup(a_encodings[i].name);
|
if (!adaptor->pEncodings) {
|
||||||
result[i].width = a_encodings[i].width;
|
free(reply);
|
||||||
result[i].height = a_encodings[i].height;
|
return FALSE;
|
||||||
result[i].rate.numerator = a_encodings[i].rate.numerator;
|
|
||||||
result[i].rate.denominator = a_encodings[i].rate.denominator;
|
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
|
encoding_it = xcb_xv_query_encodings_info_iterator(reply);
|
||||||
|
for (i = 0; i < adaptor->nEncodings; i++) {
|
||||||
|
xcb_xv_encoding_info_t *encoding_info = encoding_it.data;
|
||||||
|
KdVideoEncodingPtr encoding = &adaptor->pEncodings[i];
|
||||||
|
|
||||||
|
encoding->id = encoding_info->encoding;
|
||||||
|
encoding->name = strndup(xcb_xv_encoding_info_name(encoding_info),
|
||||||
|
encoding_info->name_size);
|
||||||
|
encoding->width = encoding_info->width;
|
||||||
|
encoding->height = encoding_info->height;
|
||||||
|
encoding->rate.numerator = encoding_info->rate.numerator;
|
||||||
|
encoding->rate.denominator = encoding_info->rate.denominator;
|
||||||
|
|
||||||
|
xcb_xv_encoding_info_next(&encoding_it);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(reply);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
|
@ -401,11 +424,9 @@ ephyrXVPrivQueryHostAdaptors(EphyrXVPriv * a_this)
|
||||||
{
|
{
|
||||||
xcb_connection_t *conn = hostx_get_xcbconn();
|
xcb_connection_t *conn = hostx_get_xcbconn();
|
||||||
xcb_screen_t *xscreen = xcb_aux_get_screen(conn, hostx_get_screen());
|
xcb_screen_t *xscreen = xcb_aux_get_screen(conn, hostx_get_screen());
|
||||||
EphyrHostEncoding *encodings = NULL;
|
|
||||||
EphyrHostImageFormat *image_formats = NULL;
|
EphyrHostImageFormat *image_formats = NULL;
|
||||||
int base_port_id = 0,
|
int base_port_id = 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;
|
Bool is_ok = FALSE;
|
||||||
xcb_generic_error_t *e = NULL;
|
xcb_generic_error_t *e = NULL;
|
||||||
xcb_xv_adaptor_info_iterator_t it;
|
xcb_xv_adaptor_info_iterator_t it;
|
||||||
|
@ -472,15 +493,12 @@ ephyrXVPrivQueryHostAdaptors(EphyrXVPriv * a_this)
|
||||||
if (!s_base_port_id)
|
if (!s_base_port_id)
|
||||||
s_base_port_id = base_port_id;
|
s_base_port_id = base_port_id;
|
||||||
|
|
||||||
if (!ephyrHostXVQueryEncodings(base_port_id,
|
if (!translate_video_encodings(&a_this->adaptors[i],
|
||||||
&encodings, &num_encodings)) {
|
cur_host_adaptor)) {
|
||||||
EPHYR_LOG_ERROR("failed to get encodings for port port id %d,"
|
EPHYR_LOG_ERROR("failed to get encodings for port port id %d,"
|
||||||
" adaptors %d\n", base_port_id, i);
|
" adaptors %d\n", base_port_id, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
a_this->adaptors[i].nEncodings = num_encodings;
|
|
||||||
a_this->adaptors[i].pEncodings =
|
|
||||||
videoEncodingDup(encodings, num_encodings);
|
|
||||||
|
|
||||||
a_this->adaptors[i].nFormats = cur_host_adaptor->num_formats;
|
a_this->adaptors[i].nFormats = cur_host_adaptor->num_formats;
|
||||||
a_this->adaptors[i].pFormats =
|
a_this->adaptors[i].pFormats =
|
||||||
|
@ -531,10 +549,6 @@ ephyrXVPrivQueryHostAdaptors(EphyrXVPriv * a_this)
|
||||||
is_ok = TRUE;
|
is_ok = TRUE;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (encodings) {
|
|
||||||
ephyrHostEncodingsDelete(encodings, num_encodings);
|
|
||||||
encodings = NULL;
|
|
||||||
}
|
|
||||||
EPHYR_LOG("leave\n");
|
EPHYR_LOG("leave\n");
|
||||||
return is_ok;
|
return is_ok;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue