return GST_V4L2CAMSRC_IS_ACTIVE (v4l2camsrc);
}
+static gint caps_cache_cmp(struct cached_gst_caps *a, struct cached_gst_caps *b)
+{
+ int r;
+ r = a->input - b->input;
+ if(r)
+ return r;
+ r = a->mode - b->mode;
+ if(r)
+ return r;
+ return (long)(a->pixelformat) - (long)(b->pixelformat);
+}
+
/*
* gst_v4l2camsrc_v4l2fourcc_to_structure:
*
for (walk = v4l2camsrc->formats; walk; walk = walk->next) {
struct v4l2_fmtdesc *format;
+ GSList *it;
/* FIXME: Introduce own format structure */
format = (struct v4l2_fmtdesc *) walk->data;
+ struct cached_gst_caps *val, key = {
+ .input = v4l2camsrc->input_sensor,
+ .mode = v4l2camsrc->capture_mode,
+ .pixelformat = format->pixelformat
+ };
+
+ it = g_slist_find_custom(v4l2camsrc->caps_cache, &key, (GCompareFunc)caps_cache_cmp);
+ if(it) {
+ val = (struct cached_gst_caps *) it->data;
+ gst_caps_append(ret, gst_caps_ref(val->caps));
+ GST_DEBUG_OBJECT(v4l2camsrc, "Using cached caps for (sensor=%d,mode=%d,format=%0.4s)",
+ val->input,val->mode,(char*)&val->pixelformat);
+ continue;
+ }
+
+ GST_DEBUG_OBJECT(v4l2camsrc, "Now probing for (sensor=%d,mode=%d,format=%0.4s)",
+ key.input,key.mode,(char*)&key.pixelformat);
template = gst_v4l2camsrc_v4l2fourcc_to_structure (format->pixelformat);
if (template) {
tmp = gst_v4l2camsrc_probe_caps_for_format (v4l2camsrc,
format->pixelformat, template);
- if (tmp)
+ if (tmp) {
+ val = malloc(sizeof *val);
+ memcpy(val, &key, sizeof *val);
+ val->caps = gst_caps_ref(tmp);
+ v4l2camsrc->caps_cache = g_slist_prepend(v4l2camsrc->caps_cache, val);
gst_caps_append (ret, tmp);
+ }
gst_structure_free (template);
} else {
v4l2camsrc->probed_caps = gst_caps_ref (ret);
- GST_INFO_OBJECT(v4l2camsrc, "use GST_DEBUG >= 5 for probed caps");
- GST_LOG_OBJECT (v4l2camsrc, "probed caps: %" GST_PTR_FORMAT, ret);
+ GST_INFO_OBJECT (v4l2camsrc, "caps: %" GST_PTR_FORMAT, ret);
return ret;
}
v4l2camsrc->device_mutex = g_mutex_new ();
+ v4l2camsrc->caps_cache = NULL;
+
v4l2camsrc->mfldadvci = gst_v4l2camsrc_mfldadvci_wrapper_load (v4l2camsrc);
v4l2camsrc->input_sensor = GST_CAMERA_INPUT_SENSOR_PRIMARY;
GST_DEBUG ("initialized to commit %s", MFLD_V4L2CAMSRC_VERSION);
}
+static void caps_cache_destroy_value(struct cached_gst_caps *val)
+{
+ if(!val)
+ return;
+ if(val->caps)
+ gst_caps_unref(val->caps);
+ free(val);
+}
static void
gst_v4l2camsrc_dispose (GObject * object)
{
GstMFLDV4l2CamSrc *v4l2camsrc = GST_V4L2CAMSRC (object);
+ if (v4l2camsrc->caps_cache)
+ g_slist_free_full(v4l2camsrc->caps_cache, (GDestroyNotify) caps_cache_destroy_value);
+ v4l2camsrc->caps_cache = NULL;
+
if (v4l2camsrc->formats) {
gst_v4l2camsrc_clear_format_list (v4l2camsrc);
}