mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 19:55:32 +00:00
- Fixing framerate on caps renegotiation. We memorize it on sinkconnect to set fixed caps on renego.
Original commit message from CVS: - Fixing framerate on caps renegotiation. We memorize it on sinkconnect to set fixed caps on renego. - Homogenized indentation. - Removed some comments. - Fixed the caps renegotiation new ximage creation (it was creating a new ximage on every configure event even if window's size has not changed) - Removed pointer coordinates translation in navigation_send_event as we are not doing scaling. videoscale should convert those events is scaling there is.
This commit is contained in:
parent
b48e87becf
commit
ddb4e3ef85
2 changed files with 49 additions and 47 deletions
|
@ -77,28 +77,16 @@ static void
|
||||||
gst_ximagesink_navigation_send_event (GstNavigation *navigation, GstStructure *structure)
|
gst_ximagesink_navigation_send_event (GstNavigation *navigation, GstStructure *structure)
|
||||||
{
|
{
|
||||||
GstXImageSink *ximagesink = GST_XIMAGESINK (navigation);
|
GstXImageSink *ximagesink = GST_XIMAGESINK (navigation);
|
||||||
XWindowAttributes attr;
|
|
||||||
GstEvent *event;
|
GstEvent *event;
|
||||||
double x, y;
|
|
||||||
|
|
||||||
g_mutex_lock (ximagesink->x_lock);
|
|
||||||
XGetWindowAttributes (ximagesink->xcontext->disp,
|
|
||||||
ximagesink->xwindow->win, &attr);
|
|
||||||
g_mutex_unlock (ximagesink->x_lock);
|
|
||||||
|
|
||||||
event = gst_event_new (GST_EVENT_NAVIGATION);
|
event = gst_event_new (GST_EVENT_NAVIGATION);
|
||||||
event->event_data.structure.structure = structure;
|
event->event_data.structure.structure = structure;
|
||||||
if(gst_structure_get_double(structure, "pointer_x", &x)){
|
|
||||||
x *= ximagesink->width;
|
|
||||||
x /= attr.width;
|
|
||||||
gst_structure_set(structure, "pointer_x", G_TYPE_DOUBLE, x, NULL);
|
|
||||||
}
|
|
||||||
if(gst_structure_get_double(structure, "pointer_y", &y)){
|
|
||||||
y *= ximagesink->height;
|
|
||||||
y /= attr.height;
|
|
||||||
gst_structure_set(structure, "pointer_y", G_TYPE_DOUBLE, y, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* We are not converting the pointer coordinates as there's no hardware
|
||||||
|
scaling done here. The only possible scaling is done by videoscale and
|
||||||
|
videoscale will have to catch those events and tranform the coordinates
|
||||||
|
to match the applied scaling */
|
||||||
|
|
||||||
gst_pad_send_event (gst_pad_get_peer (ximagesink->sinkpad), event);
|
gst_pad_send_event (gst_pad_get_peer (ximagesink->sinkpad), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,27 +373,36 @@ gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
|
||||||
e.xconfigure.width, e.xconfigure.height);
|
e.xconfigure.width, e.xconfigure.height);
|
||||||
if ( (ximagesink->xwindow->width != e.xconfigure.width) ||
|
if ( (ximagesink->xwindow->width != e.xconfigure.width) ||
|
||||||
(ximagesink->xwindow->height != e.xconfigure.height) )
|
(ximagesink->xwindow->height != e.xconfigure.height) )
|
||||||
gst_pad_try_set_caps (ximagesink->sinkpad,
|
{
|
||||||
GST_CAPS_NEW ("ximagesink_ximage_caps", "video/x-raw-rgb",
|
gst_pad_try_set_caps (ximagesink->sinkpad,
|
||||||
"bpp", GST_PROPS_INT (ximagesink->xcontext->bpp),
|
GST_CAPS_NEW ("ximagesink_ximage_caps", "video/x-raw-rgb",
|
||||||
"depth", GST_PROPS_INT (ximagesink->xcontext->depth),
|
"bpp", GST_PROPS_INT (ximagesink->xcontext->bpp),
|
||||||
"endianness", GST_PROPS_INT (ximagesink->xcontext->endianness),
|
"depth", GST_PROPS_INT (ximagesink->xcontext->depth),
|
||||||
"red_mask", GST_PROPS_INT (ximagesink->xcontext->visual->red_mask),
|
"endianness", GST_PROPS_INT (ximagesink->xcontext->endianness),
|
||||||
"green_mask", GST_PROPS_INT (ximagesink->xcontext->visual->green_mask),
|
"red_mask", GST_PROPS_INT (ximagesink->xcontext->visual->red_mask),
|
||||||
"blue_mask", GST_PROPS_INT (ximagesink->xcontext->visual->blue_mask),
|
"green_mask", GST_PROPS_INT (ximagesink->xcontext->visual->green_mask),
|
||||||
"width", GST_PROPS_INT (e.xconfigure.width),
|
"blue_mask", GST_PROPS_INT (ximagesink->xcontext->visual->blue_mask),
|
||||||
"height", GST_PROPS_INT (e.xconfigure.height),
|
"width", GST_PROPS_INT (e.xconfigure.width),
|
||||||
"framerate", GST_PROPS_FLOAT (30)));
|
"height", GST_PROPS_INT (e.xconfigure.height),
|
||||||
ximagesink->width = e.xconfigure.width;
|
"framerate", GST_PROPS_FLOAT (ximagesink->framerate)));
|
||||||
ximagesink->height = e.xconfigure.height;
|
|
||||||
if ( (ximagesink->ximage) &&
|
|
||||||
( (ximagesink->width != ximagesink->ximage->width) ||
|
|
||||||
(ximagesink->height != ximagesink->ximage->height) ) ) {
|
|
||||||
/* We renew our ximage only if size changed */
|
|
||||||
gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
|
|
||||||
|
|
||||||
ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
|
/* We should check for _try_set_caps result */
|
||||||
ximagesink->width, ximagesink->height);
|
ximagesink->width = e.xconfigure.width;
|
||||||
|
ximagesink->height = e.xconfigure.height;
|
||||||
|
|
||||||
|
if ( (ximagesink->ximage) &&
|
||||||
|
( (ximagesink->width != ximagesink->ximage->width) ||
|
||||||
|
(ximagesink->height != ximagesink->ximage->height) ) )
|
||||||
|
{
|
||||||
|
/* We renew our ximage only if size changed */
|
||||||
|
gst_ximagesink_ximage_destroy (ximagesink,
|
||||||
|
ximagesink->ximage);
|
||||||
|
|
||||||
|
ximagesink->ximage = gst_ximagesink_ximage_new (
|
||||||
|
ximagesink,
|
||||||
|
ximagesink->width,
|
||||||
|
ximagesink->height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
|
@ -413,8 +410,8 @@ gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
|
||||||
events for interactivity/navigation */
|
events for interactivity/navigation */
|
||||||
GST_DEBUG ("ximagesink pointer moved over window at %d,%d",
|
GST_DEBUG ("ximagesink pointer moved over window at %d,%d",
|
||||||
e.xmotion.x, e.xmotion.y);
|
e.xmotion.x, e.xmotion.y);
|
||||||
gst_navigation_send_mouse_event(GST_NAVIGATION(ximagesink),
|
gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
|
||||||
e.xmotion.x, e.xmotion.y);
|
e.xmotion.x, e.xmotion.y);
|
||||||
break;
|
break;
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
|
@ -422,8 +419,8 @@ gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
|
||||||
events for interactivity/navigation */
|
events for interactivity/navigation */
|
||||||
GST_DEBUG ("ximagesink button %d pressed over window at %d,%d",
|
GST_DEBUG ("ximagesink button %d pressed over window at %d,%d",
|
||||||
e.xbutton.button, e.xbutton.x, e.xbutton.x);
|
e.xbutton.button, e.xbutton.x, e.xbutton.x);
|
||||||
gst_navigation_send_mouse_event(GST_NAVIGATION(ximagesink),
|
gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
|
||||||
e.xmotion.x, e.xmotion.y);
|
e.xmotion.x, e.xmotion.y);
|
||||||
break;
|
break;
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
case KeyRelease:
|
case KeyRelease:
|
||||||
|
@ -431,12 +428,13 @@ gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
|
||||||
events for interactivity/navigation */
|
events for interactivity/navigation */
|
||||||
GST_DEBUG ("ximagesink key %d pressed over window at %d,%d",
|
GST_DEBUG ("ximagesink key %d pressed over window at %d,%d",
|
||||||
e.xkey.keycode, e.xkey.x, e.xkey.x);
|
e.xkey.keycode, e.xkey.x, e.xkey.x);
|
||||||
keysym = XKeycodeToKeysym(ximagesink->xcontext->disp,
|
keysym = XKeycodeToKeysym (ximagesink->xcontext->disp,
|
||||||
e.xkey.keycode, 0);
|
e.xkey.keycode, 0);
|
||||||
gst_navigation_send_key_event (GST_NAVIGATION (ximagesink),
|
gst_navigation_send_key_event (GST_NAVIGATION (ximagesink),
|
||||||
XKeysymToString (keysym));
|
XKeysymToString (keysym));
|
||||||
gst_navigation_send_key_event(GST_NAVIGATION(ximagesink),
|
/* What's that ? */
|
||||||
"unknown");
|
gst_navigation_send_key_event (GST_NAVIGATION (ximagesink),
|
||||||
|
"unknown");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
GST_DEBUG ("ximagesink unhandled X event (%d)", e.type);
|
GST_DEBUG ("ximagesink unhandled X event (%d)", e.type);
|
||||||
|
@ -521,7 +519,6 @@ gst_ximagesink_xcontext_get (GstXImageSink *ximagesink)
|
||||||
}
|
}
|
||||||
#endif /* HAVE_XSHM */
|
#endif /* HAVE_XSHM */
|
||||||
|
|
||||||
/* What the hell is that ? */
|
|
||||||
if (xcontext->endianness == G_LITTLE_ENDIAN && xcontext->depth == 24)
|
if (xcontext->endianness == G_LITTLE_ENDIAN && xcontext->depth == 24)
|
||||||
{
|
{
|
||||||
xcontext->endianness = G_BIG_ENDIAN;
|
xcontext->endianness = G_BIG_ENDIAN;
|
||||||
|
@ -607,6 +604,8 @@ gst_ximagesink_sinkconnect (GstPad *pad, GstCaps *caps)
|
||||||
return GST_PAD_LINK_REFUSED;
|
return GST_PAD_LINK_REFUSED;
|
||||||
if (!gst_caps_get_int (caps, "height", &ximagesink->height))
|
if (!gst_caps_get_int (caps, "height", &ximagesink->height))
|
||||||
return GST_PAD_LINK_REFUSED;
|
return GST_PAD_LINK_REFUSED;
|
||||||
|
if (!gst_caps_get_float (caps, "framerate", &ximagesink->framerate))
|
||||||
|
return GST_PAD_LINK_REFUSED;
|
||||||
|
|
||||||
if (gst_caps_has_fixed_property (caps, "pixel_width"))
|
if (gst_caps_has_fixed_property (caps, "pixel_width"))
|
||||||
gst_caps_get_int (caps, "pixel_width", &ximagesink->pixel_width);
|
gst_caps_get_int (caps, "pixel_width", &ximagesink->pixel_width);
|
||||||
|
@ -941,6 +940,8 @@ gst_ximagesink_init (GstXImageSink *ximagesink)
|
||||||
|
|
||||||
ximagesink->width = ximagesink->height = 0;
|
ximagesink->width = ximagesink->height = 0;
|
||||||
|
|
||||||
|
ximagesink->framerate = 0;
|
||||||
|
|
||||||
ximagesink->x_lock = g_mutex_new ();
|
ximagesink->x_lock = g_mutex_new ();
|
||||||
|
|
||||||
ximagesink->pixel_width = ximagesink->pixel_height = 1;
|
ximagesink->pixel_width = ximagesink->pixel_height = 1;
|
||||||
|
|
|
@ -114,6 +114,7 @@ struct _GstXImageSink {
|
||||||
GstXImage *ximage;
|
GstXImage *ximage;
|
||||||
|
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
gfloat framerate;
|
||||||
GMutex *x_lock;
|
GMutex *x_lock;
|
||||||
|
|
||||||
/* Unused */
|
/* Unused */
|
||||||
|
|
Loading…
Reference in a new issue