GstElement *pipeline;
GstVideoConvertFrameCallback callback;
gpointer user_data;
+ GDestroyNotify destroy_notify;
GMainContext *context;
GstBuffer *buffer;
gulong timeout_id;
GstBuffer *buffer;
GError *error;
gpointer user_data;
+ GDestroyNotify destroy_notify;
GstVideoConvertFrameContext *context;
} GstVideoConvertFrameCallbackContext;
{
ctx->callback (ctx->buffer, ctx->error, ctx->user_data);
+ if (ctx->destroy_notify)
+ ctx->destroy_notify (ctx->user_data);
+
return FALSE;
}
ctx = g_slice_new (GstVideoConvertFrameCallbackContext);
ctx->callback = context->callback;
ctx->user_data = context->user_data;
+ ctx->destroy_notify = context->destroy_notify;
ctx->buffer = buffer;
ctx->error = error;
ctx->context = context;
* @to_caps: the #GstCaps to convert to
* @timeout: the maximum amount of time allowed for the processing.
* @callback: %GstVideoConvertFrameCallback that will be called after conversion.
+ * @destroy_notify: %GDestroyNotify to be called after @user_data is not needed anymore
*
* Converts a raw video buffer into the specified output caps.
*
* %GMainContext, see g_main_context_get_thread_default(). If GLib before 2.22 is used,
* this will always be the global default main context.
*
+ * @destroy_notify will be called after the callback was called and @user_data is not needed
+ * anymore.
+ *
* Since: 0.10.31
*
*/
void
gst_video_convert_frame_async (GstBuffer * buf, const GstCaps * to_caps,
GstClockTime timeout, GstVideoConvertFrameCallback callback,
- gpointer user_data)
+ gpointer user_data, GDestroyNotify destroy_notify)
{
GMainContext *context = NULL;
GError *error = NULL;
g_return_if_fail (buf != NULL);
g_return_if_fail (to_caps != NULL);
g_return_if_fail (GST_BUFFER_CAPS (buf) != NULL);
+ g_return_if_fail (callback != NULL);
#if GLIB_CHECK_VERSION(2,22,0)
context = g_main_context_get_thread_default ();
ctx->buffer = gst_buffer_ref (buf);
ctx->callback = callback;
ctx->user_data = user_data;
+ ctx->destroy_notify = destroy_notify;
ctx->context = g_main_context_ref (context);
ctx->finished = FALSE;
ctx->pipeline = pipeline;
ctx = g_slice_new0 (GstVideoConvertFrameCallbackContext);
ctx->callback = callback;
ctx->user_data = user_data;
+ ctx->destroy_notify = destroy_notify;
ctx->buffer = NULL;
ctx->error = error;
loop = cf_data.loop = g_main_loop_new (NULL, FALSE);
gst_video_convert_frame_async (from_buffer, to_caps, GST_CLOCK_TIME_NONE,
- (GstVideoConvertFrameCallback) convert_frame_async_callback, &cf_data);
+ (GstVideoConvertFrameCallback) convert_frame_async_callback, &cf_data,
+ NULL);
g_main_loop_run (loop);
to_caps =
gst_video_format_new_caps (GST_VIDEO_FORMAT_I420, 240, 320, 25, 1, 1, 2);
gst_video_convert_frame_async (from_buffer, to_caps, GST_CLOCK_TIME_NONE,
- (GstVideoConvertFrameCallback) convert_frame_async_callback, &cf_data);
+ (GstVideoConvertFrameCallback) convert_frame_async_callback, &cf_data,
+ NULL);
g_main_loop_run (loop);
fail_unless (cf_data.buffer != NULL);
fail_unless (gst_caps_can_intersect (to_caps,