From ed6d46e156c52efd7d4bb92f36f653591ae00cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 16 May 2012 13:46:57 +0200 Subject: [PATCH] video: Rename gst_video_codec_frame_set_hook() to gst_video_codec_frame_set_user_data() And also add a getter and allow to set NULL user_data but still call the passed destroy notify. --- docs/libs/gst-plugins-base-libs-sections.txt | 3 +- gst-libs/gst/video/gstvideoutils.c | 45 +++++++++++++------- gst-libs/gst/video/gstvideoutils.h | 15 ++++--- win32/common/libgstvideo.def | 3 +- 4 files changed, 42 insertions(+), 24 deletions(-) diff --git a/docs/libs/gst-plugins-base-libs-sections.txt b/docs/libs/gst-plugins-base-libs-sections.txt index ec9fecb3cc..c2e90336a6 100644 --- a/docs/libs/gst-plugins-base-libs-sections.txt +++ b/docs/libs/gst-plugins-base-libs-sections.txt @@ -2240,7 +2240,8 @@ GST_VIDEO_CODEC_FRAME_UNSET_FORCE_KEYFRAME_HEADERS GST_VIDEO_CODEC_FRAME_UNSET_SYNC_POINT gst_video_codec_frame_ref gst_video_codec_frame_unref -gst_video_codec_frame_set_hook +gst_video_codec_frame_set_user_data +gst_video_codec_frame_get_user_data GstVideoCodecState gst_video_codec_state_ref gst_video_codec_state_unref diff --git a/gst-libs/gst/video/gstvideoutils.c b/gst-libs/gst/video/gstvideoutils.c index a47a6ef917..4e22ff43b3 100644 --- a/gst-libs/gst/video/gstvideoutils.c +++ b/gst-libs/gst/video/gstvideoutils.c @@ -49,33 +49,48 @@ _gst_video_codec_frame_free (GstVideoCodecFrame * frame) g_list_foreach (frame->events, (GFunc) gst_event_unref, NULL); g_list_free (frame->events); - if (frame->coder_hook_destroy_notify && frame->coder_hook) - frame->coder_hook_destroy_notify (frame->coder_hook); + if (frame->user_data_destroy_notify) + frame->user_data_destroy_notify (frame->user_data); g_slice_free (GstVideoCodecFrame, frame); } /** - * gst_video_codec_frame_set_hook: + * gst_video_codec_frame_set_user_data: * @frame: a #GstVideoCodecFrame - * @hook: private data - * @notify: (closure hook): a #GDestroyNotify + * @user_data: private data + * @notify: (closure user_data): a #GDestroyNotify * - * Sets the #GDestroyNotify that will be called (along with the @hook) when - * the frame is freed. + * Sets @user_data on the frame and the #GDestroyNotify that will be called when + * the frame is freed. Allows to attach private data by the subclass to frames. * - * If a @hook was previously set, then the previous set @notify will be called - * before the @hook is replaced. + * If a @user_data was previously set, then the previous set @notify will be called + * before the @user_data is replaced. */ void -gst_video_codec_frame_set_hook (GstVideoCodecFrame * frame, void *hook, - GDestroyNotify notify) +gst_video_codec_frame_set_user_data (GstVideoCodecFrame * frame, + gpointer user_data, GDestroyNotify notify) { - if (frame->coder_hook_destroy_notify && frame->coder_hook) - frame->coder_hook_destroy_notify (frame->coder_hook); + if (frame->user_data_destroy_notify) + frame->user_data_destroy_notify (frame->user_data); - frame->coder_hook = hook; - frame->coder_hook_destroy_notify = notify; + frame->user_data = user_data; + frame->user_data_destroy_notify = notify; +} + +/** + * gst_video_codec_frame_get_user_data: + * @frame: a #GstVideoCodecFrame + * + * Gets private data set on the frame by the subclass via + * gst_video_codec_frame_set_user_data() previously. + * + * Returns: (transfer none): The previously set user_data + */ +gpointer +gst_video_codec_frame_get_user_data (GstVideoCodecFrame * frame) +{ + return frame->user_data; } /** diff --git a/gst-libs/gst/video/gstvideoutils.h b/gst-libs/gst/video/gstvideoutils.h index d0d7a2c783..eb332554f2 100644 --- a/gst-libs/gst/video/gstvideoutils.h +++ b/gst-libs/gst/video/gstvideoutils.h @@ -236,14 +236,14 @@ struct _GstVideoCodecFrame GstClockTime deadline; /* D */ + /*< private >*/ + /* Events that should be pushed downstream *before* * the next output_buffer */ GList *events; /* ED */ - /*< private >*/ - - void *coder_hook; - GDestroyNotify coder_hook_destroy_notify; + gpointer user_data; + GDestroyNotify user_data_destroy_notify; void *padding[GST_PADDING_LARGE]; }; @@ -261,9 +261,10 @@ GType gst_video_codec_frame_get_type (void); GstVideoCodecFrame *gst_video_codec_frame_ref (GstVideoCodecFrame * frame); void gst_video_codec_frame_unref (GstVideoCodecFrame * frame); -void gst_video_codec_frame_set_hook (GstVideoCodecFrame *frame, - void *hook, - GDestroyNotify notify); +void gst_video_codec_frame_set_user_data (GstVideoCodecFrame *frame, + gpointer user_data, + GDestroyNotify notify); +gpointer gst_video_codec_frame_get_user_data (GstVideoCodecFrame *frame); G_END_DECLS diff --git a/win32/common/libgstvideo.def b/win32/common/libgstvideo.def index f479927d06..cc9e1d37cf 100644 --- a/win32/common/libgstvideo.def +++ b/win32/common/libgstvideo.def @@ -50,8 +50,9 @@ EXPORTS gst_video_calculate_display_ratio gst_video_chroma_site_get_type gst_video_codec_frame_get_type + gst_video_codec_frame_get_user_data gst_video_codec_frame_ref - gst_video_codec_frame_set_hook + gst_video_codec_frame_set_user_data gst_video_codec_frame_unref gst_video_codec_state_get_type gst_video_codec_state_ref