*fps_n = gst_value_get_fraction_numerator (framerate);
*fps_d = gst_value_get_fraction_denominator (framerate);
- if (!strcmp (mimetype, "video/x-raw-yuv")) {
+ if (!strcmp (mimetype, "video/x-vaapi-sharing")) {
+ fourcc = V4L2_PIX_FMT_NV21;
+ outsize = GST_ROUND_UP_4 (*w) * GST_ROUND_UP_2 (*h);
+ outsize += (GST_ROUND_UP_4 (*w) * *h) / 2;
+ } else if (!strcmp (mimetype, "video/x-raw-yuv")) {
gst_structure_get_fourcc (structure, "format", &fourcc);
switch (fourcc) {
#define DEFAULT_DEBUG_FLAGS 0
#define C_FLAGS(v) ((guint) v)
+
+static const char* surface_string =
+ "video/x-vaapi-sharing, "
+ "type = vaapi, "
+ "width = (int) [ 1, MAX ], "
+ "height = (int) [ 1, MAX ], "
+ "framerate = (fraction) [ 0, MAX ]";
+
+
GType
gst_camera_input_sensor_get_type (void)
{
}
}
+ GstStructure * structure = gst_structure_from_string(surface_string, NULL);
+ gst_caps_append_structure (ret, structure);
+
v4l2camsrc->probed_caps = gst_caps_ref (ret);
GST_INFO_OBJECT(v4l2camsrc, "use GST_DEBUG >= 5 for probed caps");
gst_caps_append_structure (caps, structure);
}
}
+ structure = gst_structure_from_string(surface_string, NULL);
+ gst_caps_append_structure (caps, structure);
}
return gst_caps_ref (caps);
#define GST_TYPE_V4L2CAMSRC_BUFFER (gst_v4l2camsrc_buffer_get_type())
#define GST_IS_V4L2CAMSRC_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2CAMSRC_BUFFER))
-#define GST_V4L2CAMSRC_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4L2CAMSRC_BUFFER, GstCameraBuffer))
+#define GST_V4L2CAMSRC_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4L2CAMSRC_BUFFER, GstV4l2Buffer))
/* Local functions */
static gboolean
pool->num_live_buffers--;
if (pool->running) {
+ if (pool->is_vaapi_sharing && buffer->gbuffer)
+ GST_BUFFER_DATA(buffer) = GST_BUFFER_DATA(buffer->gbuffer);
if (ioctl (pool->video_fd, VIDIOC_QBUF, vbuffer) < 0) {
GST_WARNING ("could not requeue buffer %p %d", buffer, index);
} else {
if (buffer->gbuffer) {
/* It was allocated with gst_pad_alloc_buffer */
/* FIXME temporal fix for double free error */
- //gst_buffer_unref (buffer->gbuffer);
+ if (pool->is_vaapi_sharing)
+ gst_buffer_unref (buffer->gbuffer);
buffer->gbuffer = NULL;
} else {
/* It was allocated with posix_memalign */
pool->running = FALSE;
pool->num_live_buffers = 0;
pool->data_cond = g_cond_new ();
+ pool->is_vaapi_sharing = FALSE;
}
/*
if (pool->video_fd < 0)
goto dup_failed;
+ GstStructure *structure = gst_caps_get_structure (caps, 0);
+ if (structure && gst_structure_has_name(structure, "video/x-vaapi-sharing"))
+ pool->is_vaapi_sharing = TRUE;
pool->buffer_count = v4l2camsrc->num_buffers;
pool->buffers = g_new0 (GstV4l2Buffer *, pool->buffer_count);
g_mutex_lock (pool->lock);
pool->running = FALSE;
+ pool->is_vaapi_sharing = FALSE;
g_mutex_unlock (pool->lock);
GST_DEBUG ("destroy pool");
/* this will requeue */
gst_buffer_unref (pool_buffer);
} else {
+ if (v4l2camsrc->pool->is_vaapi_sharing)
+ GST_BUFFER_DATA(pool_buffer) = (GST_V4L2CAMSRC_BUFFER(pool_buffer))->gbuffer;
*buf = pool_buffer;
}