vaapisink: allow a specific view component to be displayed.

If a multiview stream is decoded, multiple view components are submitted
as is downstream. It is the responsibility of the sink element to display
the required view components. By default, always select the frame buffer
that matches the view-id of the very first frame to be displayed.

However, introduce a "view-id" property to allow the selection of a
specific view component of interest to display.
This commit is contained in:
Gwenole Beauchesne 2014-07-28 10:25:26 +02:00
parent a26df804a6
commit aa2fab43bd
2 changed files with 41 additions and 0 deletions

View file

@ -135,6 +135,7 @@ enum {
PROP_USE_REFLECTION,
PROP_ROTATION,
PROP_FORCE_ASPECT_RATIO,
PROP_VIEW_ID,
};
#define DEFAULT_DISPLAY_TYPE GST_VAAPI_DISPLAY_TYPE_ANY
@ -965,6 +966,7 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *src_buffer)
{
GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
GstVaapiVideoMeta *meta;
GstVaapiSurfaceProxy *proxy;
GstVaapiSurface *surface;
GstBuffer *buffer;
guint flags;
@ -974,6 +976,7 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *src_buffer)
GstVaapiRectangle tmp_rect;
#endif
GstFlowReturn ret;
gint32 view_id;
#if GST_CHECK_VERSION(1,0,0)
GstVideoCropMeta * const crop_meta =
@ -998,6 +1001,19 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *src_buffer)
gst_vaapisink_ensure_rotation(sink, TRUE);
proxy = gst_vaapi_video_meta_get_surface_proxy(meta);
if (!proxy)
goto error;
/* Valide view component to display */
view_id = GST_VAAPI_SURFACE_PROXY_VIEW_ID(proxy);
if (G_UNLIKELY(sink->view_id == -1))
sink->view_id = view_id;
else if (sink->view_id != view_id) {
gst_buffer_unref(buffer);
return GST_FLOW_OK;
}
surface = gst_vaapi_video_meta_get_surface(meta);
if (!surface)
goto error;
@ -1142,6 +1158,9 @@ gst_vaapisink_set_property(
case PROP_SYNCHRONOUS:
sink->synchronous = g_value_get_boolean(value);
break;
case PROP_VIEW_ID:
sink->view_id = g_value_get_int(value);
break;
case PROP_USE_GLX:
sink->use_glx = g_value_get_boolean(value);
break;
@ -1183,6 +1202,9 @@ gst_vaapisink_get_property(
case PROP_SYNCHRONOUS:
g_value_set_boolean(value, sink->synchronous);
break;
case PROP_VIEW_ID:
g_value_set_int(value, sink->view_id);
break;
case PROP_USE_GLX:
g_value_set_boolean(value, sink->use_glx);
break;
@ -1350,6 +1372,23 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
"When enabled, scaling will respect original aspect ratio",
TRUE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstVaapiSink:view-id:
*
* When not set to -1, the displayed frame will always be the one
* that matches the view-id of the very first displayed frame. Any
* other number will indicate the desire to display the supplied
* view-id only.
*/
g_object_class_install_property
(object_class,
PROP_VIEW_ID,
g_param_spec_int("view-id",
"View ID",
"ID of the view component of interest to display",
-1, G_MAXINT32, -1,
G_PARAM_READWRITE));
}
static void
@ -1370,6 +1409,7 @@ gst_vaapisink_init(GstVaapiSink *sink)
sink->video_height = 0;
sink->video_par_n = 1;
sink->video_par_d = 1;
sink->view_id = -1;
sink->foreign_window = FALSE;
sink->fullscreen = FALSE;
sink->synchronous = FALSE;

View file

@ -87,6 +87,7 @@ struct _GstVaapiSink {
GstVaapiRotation rotation;
GstVaapiRotation rotation_req;
guint color_standard;
gint32 view_id;
guint foreign_window : 1;
guint fullscreen : 1;
guint synchronous : 1;