video: Rename gst_video_codec_frame_set_hook() to gst_video_codec_frame_set_user_data()
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 16 May 2012 11:46:57 +0000 (13:46 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 16 May 2012 12:06:12 +0000 (14:06 +0200)
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
gst-libs/gst/video/gstvideoutils.c
gst-libs/gst/video/gstvideoutils.h
win32/common/libgstvideo.def

index ec9fecb..c2e9033 100644 (file)
@@ -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
index a47a6ef..4e22ff4 100644 (file)
@@ -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;
 }
 
 /**
index d0d7a2c..eb33255 100644 (file)
@@ -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
 
index f479927..cc9e1d3 100644 (file)
@@ -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