kmssink: Add display-width/height properties

This is to be used with gst_video_overlay_set_render_rectangle()
so the application can calculate a rectangle that fits inside
the display. The property changes are notify in a way that you
can watch either notify::display-width or notify::display-height
and both will be up-to-data when this is called back. Before the
element is started, the size will be 0x0.

https://bugzilla.gnome.org/show_bug.cgi?id=784599
This commit is contained in:
Nicolas Dufresne 2017-12-01 11:59:01 -05:00
parent b24bb73101
commit 737067e793

View file

@ -86,6 +86,8 @@ enum
PROP_PLANE_ID, PROP_PLANE_ID,
PROP_FORCE_MODESETTING, PROP_FORCE_MODESETTING,
PROP_CAN_SCALE, PROP_CAN_SCALE,
PROP_DISPLAY_WIDTH,
PROP_DISPLAY_HEIGHT,
PROP_N PROP_N
}; };
@ -659,8 +661,12 @@ retry_find_plane:
self->render_rect.x = 0; self->render_rect.x = 0;
self->render_rect.y = 0; self->render_rect.y = 0;
GST_OBJECT_LOCK (self);
self->hdisplay = self->render_rect.w = crtc->mode.hdisplay; self->hdisplay = self->render_rect.w = crtc->mode.hdisplay;
self->vdisplay = self->render_rect.h = crtc->mode.vdisplay; self->vdisplay = self->render_rect.h = crtc->mode.vdisplay;
GST_OBJECT_UNLOCK (self);
self->buffer_id = crtc->buffer_id; self->buffer_id = crtc->buffer_id;
self->mm_width = conn->mmWidth; self->mm_width = conn->mmWidth;
@ -673,6 +679,9 @@ retry_find_plane:
gst_poll_add_fd (self->poll, &self->pollfd); gst_poll_add_fd (self->poll, &self->pollfd);
gst_poll_fd_ctl_read (self->poll, &self->pollfd, TRUE); gst_poll_fd_ctl_read (self->poll, &self->pollfd, TRUE);
g_object_notify_by_pspec (G_OBJECT (self), g_properties[PROP_DISPLAY_WIDTH]);
g_object_notify_by_pspec (G_OBJECT (self), g_properties[PROP_DISPLAY_HEIGHT]);
ret = TRUE; ret = TRUE;
bail: bail:
@ -785,6 +794,14 @@ gst_kms_sink_stop (GstBaseSink * bsink)
self->fd = -1; self->fd = -1;
} }
GST_OBJECT_LOCK (bsink);
self->hdisplay = 0;
self->vdisplay = 0;
GST_OBJECT_UNLOCK (bsink);
g_object_notify_by_pspec (G_OBJECT (self), g_properties[PROP_DISPLAY_WIDTH]);
g_object_notify_by_pspec (G_OBJECT (self), g_properties[PROP_DISPLAY_HEIGHT]);
return TRUE; return TRUE;
} }
@ -1596,6 +1613,16 @@ gst_kms_sink_get_property (GObject * object, guint prop_id,
case PROP_CAN_SCALE: case PROP_CAN_SCALE:
g_value_set_boolean (value, sink->can_scale); g_value_set_boolean (value, sink->can_scale);
break; break;
case PROP_DISPLAY_WIDTH:
GST_OBJECT_LOCK (sink);
g_value_set_int (value, sink->hdisplay);
GST_OBJECT_UNLOCK (sink);
break;
case PROP_DISPLAY_HEIGHT:
GST_OBJECT_LOCK (sink);
g_value_set_int (value, sink->vdisplay);
GST_OBJECT_UNLOCK (sink);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -1728,6 +1755,30 @@ gst_kms_sink_class_init (GstKMSSinkClass * klass)
"User can tell kmssink if the driver can support scale", TRUE, "User can tell kmssink if the driver can support scale", TRUE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT);
/**
* kmssink:display-width
*
* Actual width of the display. This is read only and only available in
* PAUSED and PLAYING state. It's meant to be used with
* gst_video_overlay_set_render_rectangle() function.
*/
g_properties[PROP_DISPLAY_WIDTH] =
g_param_spec_int ("display-width", "Display Width",
"Width of the display surface in pixels", 0, G_MAXINT, 0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* kmssink:display-height
*
* Actual height of the display. This is read only and only available in
* PAUSED and PLAYING state. It's meant to be used with
* gst_video_overlay_set_render_rectangle() function.
*/
g_properties[PROP_DISPLAY_HEIGHT] =
g_param_spec_int ("display-height", "Display Height",
"Height of the display surface in pixels", 0, G_MAXINT, 0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, PROP_N, g_properties); g_object_class_install_properties (gobject_class, PROP_N, g_properties);
} }