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.
This commit is contained in:
Sebastian Dröge 2012-05-16 13:46:57 +02:00
parent c1bc70300d
commit ed6d46e156
4 changed files with 42 additions and 24 deletions

View file

@ -2240,7 +2240,8 @@ GST_VIDEO_CODEC_FRAME_UNSET_FORCE_KEYFRAME_HEADERS
GST_VIDEO_CODEC_FRAME_UNSET_SYNC_POINT GST_VIDEO_CODEC_FRAME_UNSET_SYNC_POINT
gst_video_codec_frame_ref gst_video_codec_frame_ref
gst_video_codec_frame_unref 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 GstVideoCodecState
gst_video_codec_state_ref gst_video_codec_state_ref
gst_video_codec_state_unref gst_video_codec_state_unref

View file

@ -49,33 +49,48 @@ _gst_video_codec_frame_free (GstVideoCodecFrame * frame)
g_list_foreach (frame->events, (GFunc) gst_event_unref, NULL); g_list_foreach (frame->events, (GFunc) gst_event_unref, NULL);
g_list_free (frame->events); g_list_free (frame->events);
if (frame->coder_hook_destroy_notify && frame->coder_hook) if (frame->user_data_destroy_notify)
frame->coder_hook_destroy_notify (frame->coder_hook); frame->user_data_destroy_notify (frame->user_data);
g_slice_free (GstVideoCodecFrame, frame); g_slice_free (GstVideoCodecFrame, frame);
} }
/** /**
* gst_video_codec_frame_set_hook: * gst_video_codec_frame_set_user_data:
* @frame: a #GstVideoCodecFrame * @frame: a #GstVideoCodecFrame
* @hook: private data * @user_data: private data
* @notify: (closure hook): a #GDestroyNotify * @notify: (closure user_data): a #GDestroyNotify
* *
* Sets the #GDestroyNotify that will be called (along with the @hook) when * Sets @user_data on the frame and the #GDestroyNotify that will be called when
* the frame is freed. * 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 * If a @user_data was previously set, then the previous set @notify will be called
* before the @hook is replaced. * before the @user_data is replaced.
*/ */
void void
gst_video_codec_frame_set_hook (GstVideoCodecFrame * frame, void *hook, gst_video_codec_frame_set_user_data (GstVideoCodecFrame * frame,
GDestroyNotify notify) gpointer user_data, GDestroyNotify notify)
{ {
if (frame->coder_hook_destroy_notify && frame->coder_hook) if (frame->user_data_destroy_notify)
frame->coder_hook_destroy_notify (frame->coder_hook); frame->user_data_destroy_notify (frame->user_data);
frame->coder_hook = hook; frame->user_data = user_data;
frame->coder_hook_destroy_notify = notify; 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;
} }
/** /**

View file

@ -236,14 +236,14 @@ struct _GstVideoCodecFrame
GstClockTime deadline; /* D */ GstClockTime deadline; /* D */
/*< private >*/
/* Events that should be pushed downstream *before* /* Events that should be pushed downstream *before*
* the next output_buffer */ * the next output_buffer */
GList *events; /* ED */ GList *events; /* ED */
/*< private >*/ gpointer user_data;
GDestroyNotify user_data_destroy_notify;
void *coder_hook;
GDestroyNotify coder_hook_destroy_notify;
void *padding[GST_PADDING_LARGE]; 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); GstVideoCodecFrame *gst_video_codec_frame_ref (GstVideoCodecFrame * frame);
void gst_video_codec_frame_unref (GstVideoCodecFrame * frame); void gst_video_codec_frame_unref (GstVideoCodecFrame * frame);
void gst_video_codec_frame_set_hook (GstVideoCodecFrame *frame, void gst_video_codec_frame_set_user_data (GstVideoCodecFrame *frame,
void *hook, gpointer user_data,
GDestroyNotify notify); GDestroyNotify notify);
gpointer gst_video_codec_frame_get_user_data (GstVideoCodecFrame *frame);
G_END_DECLS G_END_DECLS

View file

@ -50,8 +50,9 @@ EXPORTS
gst_video_calculate_display_ratio gst_video_calculate_display_ratio
gst_video_chroma_site_get_type gst_video_chroma_site_get_type
gst_video_codec_frame_get_type gst_video_codec_frame_get_type
gst_video_codec_frame_get_user_data
gst_video_codec_frame_ref 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_frame_unref
gst_video_codec_state_get_type gst_video_codec_state_get_type
gst_video_codec_state_ref gst_video_codec_state_ref