[285/906] fix gl framerate in gst caps. Consider position in xoverlay. Fix inversion bettween COLS and ROWS, and move windows.

This commit is contained in:
Julien Isorce 2008-12-07 03:25:59 +01:00 committed by Matthew Waters
parent 0d2c7b20fd
commit 4b53383385
3 changed files with 44 additions and 31 deletions

View File

@ -362,6 +362,8 @@ gst_gl_window_new (gint width, gint height)
g_debug ("gl window id: %lld\n", (guint64) priv->internal_win_id); g_debug ("gl window id: %lld\n", (guint64) priv->internal_win_id);
g_debug ("gl window props: x:%d y:%d w:%d h:%d\n", x, y, width, height);
wm_atoms[0] = XInternAtom (priv->device, "WM_DELETE_WINDOW", True); wm_atoms[0] = XInternAtom (priv->device, "WM_DELETE_WINDOW", True);
if (wm_atoms[0] == None) if (wm_atoms[0] == None)
g_debug ("Cannot create WM_DELETE_WINDOW\n"); g_debug ("Cannot create WM_DELETE_WINDOW\n");
@ -428,6 +430,8 @@ gst_gl_window_set_external_window_id (GstGLWindow *window, guint64 id)
priv->parent = (Window) id; priv->parent = (Window) id;
g_debug ("set parent window id: %lld\n", id);
XGetWindowAttributes (priv->disp_send, priv->parent, &attr); XGetWindowAttributes (priv->disp_send, priv->parent, &attr);
XResizeWindow (priv->disp_send, priv->internal_win_id, attr.width, attr.height); XResizeWindow (priv->disp_send, priv->internal_win_id, attr.width, attr.height);
@ -541,13 +545,21 @@ gst_gl_window_draw (GstGLWindow *window)
XWindowAttributes attr_parent; XWindowAttributes attr_parent;
XGetWindowAttributes (priv->disp_send, priv->parent, &attr_parent); XGetWindowAttributes (priv->disp_send, priv->parent, &attr_parent);
if (attr.width != attr_parent.width || attr.height != attr_parent.height) if (attr.x != attr_parent.x || attr.y != attr_parent.y ||
attr.width != attr_parent.width || attr.height != attr_parent.height)
{ {
XResizeWindow (priv->disp_send, priv->internal_win_id, attr_parent.width, attr_parent.height); XMoveResizeWindow (priv->disp_send, priv->internal_win_id, attr_parent.x, attr_parent.y,
attr_parent.width, attr_parent.height);
XSync (priv->disp_send, FALSE); XSync (priv->disp_send, FALSE);
attr.x = attr_parent.x;
attr.y = attr_parent.y;
attr.width = attr_parent.width; attr.width = attr_parent.width;
attr.height = attr_parent.height; attr.height = attr_parent.height;
g_debug ("parent resize: %d, %d, %d, %d\n", attr_parent.x, attr_parent.y,
attr_parent.width, attr_parent.height);
} }
} }
@ -624,8 +636,6 @@ gst_gl_window_run_loop (GstGLWindow *window)
custom_cb (custom_data); custom_cb (custom_data);
} }
g_debug("signal\n");
g_cond_signal (priv->cond_send_message); g_cond_signal (priv->cond_send_message);
} }

View File

@ -244,24 +244,23 @@ gst_gl_upload_transform_caps (GstBaseTransform* bt,
GST_DEBUG ("transform caps %" GST_PTR_FORMAT, caps); GST_DEBUG ("transform caps %" GST_PTR_FORMAT, caps);
framerate_value = gst_structure_get_value (structure, "framerate"); framerate_value = gst_structure_get_value (structure, "framerate");
par_value = gst_structure_get_value (structure, "pixel-aspect-ratio"); par_value = gst_structure_get_value (structure, "pixel-aspect-ratio");
if (direction == GST_PAD_SRC) if (direction == GST_PAD_SRC)
{ {
GstCaps* newothercaps = gst_caps_new_simple ("video/x-raw-rgb", NULL); GstCaps* newothercaps = gst_caps_new_simple ("video/x-raw-rgb", NULL);
newcaps = gst_caps_new_simple ("video/x-raw-yuv", NULL); newcaps = gst_caps_new_simple ("video/x-raw-yuv", NULL);
gst_caps_append(newcaps, newothercaps); gst_caps_append(newcaps, newothercaps);
}
}
else else
newcaps = gst_caps_new_simple ("video/x-raw-gl", NULL); newcaps = gst_caps_new_simple ("video/x-raw-gl", NULL);
structure = gst_structure_copy (gst_caps_get_structure (newcaps, 0)); structure = gst_caps_get_structure (newcaps, 0);
gst_structure_set (structure, gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL); "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
gst_structure_set_value (structure, "framerate", framerate_value); gst_structure_set_value (structure, "framerate", framerate_value);
if (par_value) if (par_value)
@ -270,7 +269,7 @@ gst_gl_upload_transform_caps (GstBaseTransform* bt,
gst_structure_set (structure, "pixel-aspect-ratio", GST_TYPE_FRACTION, gst_structure_set (structure, "pixel-aspect-ratio", GST_TYPE_FRACTION,
1, 1, NULL); 1, 1, NULL);
gst_caps_merge_structure (newcaps, gst_structure_copy (structure)); gst_caps_merge_structure (newcaps, gst_structure_copy (structure));
GST_DEBUG ("new caps %" GST_PTR_FORMAT, newcaps); GST_DEBUG ("new caps %" GST_PTR_FORMAT, newcaps);

View File

@ -1,4 +1,4 @@
/* /*
* GStreamer * GStreamer
* Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com> * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
* *
@ -45,17 +45,22 @@ static gboolean
create_actor (GstGLClutterActor *actor) { create_actor (GstGLClutterActor *actor) {
static gint xpos = 0; static gint xpos = 0;
static gint ypos = 0; static gint ypos = 0;
actor->texture = g_object_new (CLUTTER_GLX_TYPE_TEXTURE_PIXMAP, Display *disp;
actor->texture = g_object_new (CLUTTER_GLX_TYPE_TEXTURE_PIXMAP,
"window", actor->win, "window", actor->win,
"automatic-updates", TRUE, NULL); "automatic-updates", TRUE, NULL);
clutter_container_add_actor (CLUTTER_CONTAINER (actor->stage), actor->texture); clutter_container_add_actor (CLUTTER_CONTAINER (actor->stage), actor->texture);
clutter_actor_set_position (actor->texture, xpos, ypos); clutter_actor_set_position (actor->texture, xpos, ypos);
if (xpos > (ROWS-1)*W) {
disp = clutter_x11_get_default_display ();
XMoveResizeWindow (disp, actor->win, xpos, ypos, W, H);
if (xpos > (COLS-1)*W) {
xpos = 0; xpos = 0;
ypos += H+1; ypos += H+1;
} else } else
xpos += W+1; xpos += W+1;
clutter_actor_show (actor->texture); clutter_actor_show (actor->texture);
return FALSE; return FALSE;
} }
@ -69,7 +74,7 @@ create_window (GstBus * bus, GstMessage * message, gpointer data)
// ignore anything but 'prepare-xwindow-id' element messages // ignore anything but 'prepare-xwindow-id' element messages
if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
return GST_BUS_PASS; return GST_BUS_PASS;
if (!gst_structure_has_name (message->structure, "prepare-xwindow-id")) if (!gst_structure_has_name (message->structure, "prepare-xwindow-id"))
return GST_BUS_PASS; return GST_BUS_PASS;
@ -80,14 +85,14 @@ create_window (GstBus * bus, GstMessage * message, gpointer data)
if (count < N_ACTORS) { if (count < N_ACTORS) {
g_message ("adding actor %d", count); g_message ("adding actor %d", count);
gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (GST_MESSAGE_SRC (message)), gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (GST_MESSAGE_SRC (message)),
actor[count]->win); actor[count]->win);
clutter_threads_add_idle ((GSourceFunc) create_actor, actor[count]); clutter_threads_add_idle ((GSourceFunc) create_actor, actor[count]);
count++; count++;
} }
g_mutex_unlock (mutex); g_mutex_unlock (mutex);
gst_message_unref (message); gst_message_unref (message);
return GST_BUS_DROP; return GST_BUS_DROP;
} }
@ -139,9 +144,9 @@ main (int argc, char *argv[])
} }
stage = clutter_stage_get_default (); stage = clutter_stage_get_default ();
clutter_actor_set_size (CLUTTER_ACTOR (stage), clutter_actor_set_size (CLUTTER_ACTOR (stage),
W*ROWS + (ROWS-1), W*COLS + (COLS-1),
H*COLS + (COLS-1)); H*ROWS + (ROWS-1));
stage_win = clutter_x11_get_stage_window (CLUTTER_STAGE (stage)); stage_win = clutter_x11_get_stage_window (CLUTTER_STAGE (stage));
@ -171,14 +176,13 @@ main (int argc, char *argv[])
tee = gst_element_factory_make ("tee", NULL); tee = gst_element_factory_make ("tee", NULL);
gst_bin_add_many (GST_BIN (pipeline), srcbin, tee, NULL); gst_bin_add_many (GST_BIN (pipeline), srcbin, tee, NULL);
for (i=0; i<N_ACTORS; i++) { for (i=0; i<N_ACTORS; i++) {
queue[i] = gst_element_factory_make ("queue", NULL); queue[i] = gst_element_factory_make ("queue", NULL);
upload[i] = gst_element_factory_make ("glupload", NULL); upload[i] = gst_element_factory_make ("glupload", NULL);
effect[i] = gst_element_factory_make ("gleffects", NULL); effect[i] = gst_element_factory_make ("gleffects", NULL);
sink[i] = gst_element_factory_make ("glimagesink", NULL); sink[i] = gst_element_factory_make ("glimagesink", NULL);
gst_bin_add_many (GST_BIN (pipeline), gst_bin_add_many (GST_BIN (pipeline),
queue[i], upload[i], effect[i], sink[i], NULL); queue[i], upload[i], effect[i], sink[i], NULL);
} }
@ -190,7 +194,7 @@ main (int argc, char *argv[])
if (!ok) if (!ok)
g_error ("Failed to link one or more elements"); g_error ("Failed to link one or more elements");
for (i=0; i<N_ACTORS; i++) { for (i=0; i<N_ACTORS; i++) {
g_message ("setting effect %d on %s", i+1, gst_element_get_name (effect[i])); g_message ("setting effect %d on %s", i+1, gst_element_get_name (effect[i]));
g_object_set (G_OBJECT (effect[i]), "effect", i+1, NULL); g_object_set (G_OBJECT (effect[i]), "effect", i+1, NULL);
@ -208,6 +212,6 @@ main (int argc, char *argv[])
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
g_object_unref (pipeline); g_object_unref (pipeline);
return 0; return 0;
} }