gst_buffer_pool_config_get_params
gst_buffer_pool_config_set_params
+gst_buffer_pool_config_validate_params
gst_buffer_pool_config_get_allocator
gst_buffer_pool_config_set_allocator
return TRUE;
}
+/**
+ * gst_buffer_pool_config_validate_params:
+ * @config: (transfer none): a #GstBufferPool configuration
+ * @caps: (transfer none): the excepted caps of buffers
+ * @size: the expected size of each buffer, not including prefix and padding
+ * @min_buffers: the expected minimum amount of buffers to allocate.
+ * @max_buffers: the expect maximum amount of buffers to allocate or 0 for unlimited.
+ *
+ * Validate that changes made to @config are still valid in the context of the
+ * expected parameters. This function is a helper that can be used to validate
+ * changes made by a pool to a config when gst_buffer_pool_set_config()
+ * returns %FALSE. This expects that @caps and @size haven't changed, and that
+ * @min_buffers aren't lower then what we initially expected. This does not check
+ * if options or allocator parameters.
+ *
+ * Since: 1.4
+ *
+ * Returns: %TRUE, if the parameters are valid in this context.
+ */
+gboolean
+gst_buffer_pool_config_validate_params (GstStructure * config, GstCaps * caps,
+ guint size, guint min_buffers, G_GNUC_UNUSED guint max_buffers)
+{
+ GstCaps *newcaps;
+ guint newsize, newmin;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (config != NULL, FALSE);
+
+ gst_buffer_pool_config_get_params (config, &newcaps, &newsize, &newmin, NULL);
+
+ if (gst_caps_is_equal (caps, newcaps) && (size == newsize)
+ && (newmin >= min_buffers))
+ ret = TRUE;
+
+ return ret;
+}
+
static GstFlowReturn
default_acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer,
GstBufferPoolAcquireParams * params)
void gst_buffer_pool_config_add_option (GstStructure *config, const gchar *option);
const gchar * gst_buffer_pool_config_get_option (GstStructure *config, guint index);
gboolean gst_buffer_pool_config_has_option (GstStructure *config, const gchar *option);
+gboolean gst_buffer_pool_config_validate_params (GstStructure *config, GstCaps *caps,
+ guint size, guint min_buffers, guint max_buffers);
/* buffer management */
GstFlowReturn gst_buffer_pool_acquire_buffer (GstBufferPool *pool, GstBuffer **buffer,
GST_END_TEST;
+GST_START_TEST (test_pool_config_validate)
+{
+ GstBufferPool *pool = create_pool (5, 4, 30);
+ GstStructure *config = gst_buffer_pool_get_config (pool);
+ GstCaps *caps = gst_caps_new_empty_simple ("test/data");
+
+ fail_unless (gst_buffer_pool_config_validate_params (config, caps, 5, 4, 0));
+ fail_unless (gst_buffer_pool_config_validate_params (config, caps, 5, 2, 0));
+ fail_if (gst_buffer_pool_config_validate_params (config, caps, 5, 6, 0));
+ fail_if (gst_buffer_pool_config_validate_params (config, caps, 4, 4, 0));
+
+ gst_caps_unref (caps);
+ caps = gst_caps_new_empty_simple ("test/data2");
+ fail_if (gst_buffer_pool_config_validate_params (config, caps, 5, 4, 0));
+
+ gst_caps_unref (caps);
+ gst_structure_free (config);
+ gst_object_unref (pool);
+}
+
+GST_END_TEST;
+
static Suite *
gst_buffer_pool_suite (void)
{
tcase_add_test (tc_chain, test_inactive_pool_returns_flushing);
tcase_add_test (tc_chain, test_buffer_modify_discard);
tcase_add_test (tc_chain, test_pool_activation_and_config);
+ tcase_add_test (tc_chain, test_pool_config_validate);
return s;
}
gst_buffer_pool_config_n_options
gst_buffer_pool_config_set_allocator
gst_buffer_pool_config_set_params
+ gst_buffer_pool_config_validate_params
gst_buffer_pool_get_config
gst_buffer_pool_get_options
gst_buffer_pool_get_type