[gst-devel] [PATCH 1/3] gstreamer-0.8.9-gstfakesink.patch
Thomas Vander Stichele
thomas at apestaart.org
Mon Jun 13 06:20:53 CEST 2005
Hi,
> [this patch is relative to gstreamer-0.8.9]
please put patches in bugzilla ! they get lost on the mailing list.
> This patch addresses two race conditions in Gst-Pads and Gst-Elements
> encountered in thread-based scenarios of GStreamer applications.
I assume this note is actually for the second patch you sent.
> This is a utility patch to the Fakesink plug-in. It enables applications
> to
> register for and receive the keyframes of a MPEG file - the file offset
> and corresponding timestamp of the keyframes are passed onto to the
> application. Given that information is present to some applications
> a-priori,
> applications can directly seek onto the exact keyframes without the
> decoder's
> help.
three things:
- the GST_BUFFER_KEY_UNIT flag is deprecated; there's no point in adding
code that uses it
- the functionality you want is already possible in two ways: using
PadProbes, or using handoff signals, and then checking for the flag you
want on the buffer
- rcvd_keyframe is a really bad signal name; you should choose either
rcvd_kfrm or received_keyframe. My money is on the latter :)
Thomas
>
> The patch creates a new signal 'rcvd_keyframe' and lets application
> register
> for that. When the fakesink receives the decoded raw video data and
> detects
> a keyframe it invokes the registered handlers of application passing the
> file offset and corresponding timestamp information for the keyframe.
> --
> diff -Naur gstreamer-0.8.9/gst/elements/gstfakesink.c
> gstreamer-0.8.9-ipvr/gst/elements/gstfakesink.c
> --- gstreamer-0.8.9/gst/elements/gstfakesink.c 2004-11-10
> 16:17:14.000000000 +0530
> +++ gstreamer-0.8.9-ipvr/gst/elements/gstfakesink.c 2005-04-25
> 13:01:15.466110280 +0530
> @@ -62,6 +62,17 @@
> ARG_LAST_MESSAGE
> };
>
> +enum
> +{
> + SIGNAL_HANDLE_KEYFRAME_FAKESINK,
> + LAST_SIGNAL_FAKESINK
> +};
> +typedef struct _VID_KEYFRAME_FAKESINK {
> + guint64 offset;
> + gint64 timestamp;
> +} VID_KEYFRAME_FAKESINK;
> +static guint gst_fakesink_pad_signals[LAST_SIGNAL_FAKESINK] = { 0 };
> +
> GstStaticPadTemplate fakesink_sink_template = GST_STATIC_PAD_TEMPLATE
> ("sink%d",
> GST_PAD_SINK,
> GST_PAD_REQUEST,
> @@ -177,6 +188,12 @@
> gstelement_class->set_clock = GST_DEBUG_FUNCPTR
> (gst_fakesink_set_clock);
> gstelement_class->change_state =
> GST_DEBUG_FUNCPTR (gst_fakesink_change_state);
> +
> + gst_fakesink_pad_signals[SIGNAL_HANDLE_KEYFRAME_FAKESINK] =
> + g_signal_new("rcvd_keyframe", G_TYPE_FROM_CLASS(klass),
> + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(GstFakeSinkClass,
> rcvd_keyframe),
> + NULL, NULL, gst_marshal_VOID__OBJECT_POINTER,
> + G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
> }
>
> static void
> @@ -320,6 +337,15 @@
>
> fakesink = GST_FAKESINK (GST_OBJECT_PARENT (pad));
>
> + if (GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_KEY_UNIT)) {
> + VID_KEYFRAME_FAKESINK tmp;
> + tmp.offset = GST_BUFFER_OFFSET(buf);
> + tmp.timestamp = GST_BUFFER_TIMESTAMP(buf);
> + g_signal_emit(G_OBJECT(fakesink),
> + gst_fakesink_pad_signals[SIGNAL_HANDLE_KEYFRAME_FAKESINK], 0,
> + "fakesink", (void *)&tmp);
> + }
> +
> if (GST_IS_EVENT (buf)) {
> GstEvent *event = GST_EVENT (buf);
>
> diff -Naur gstreamer-0.8.9/gst/elements/gstfakesink.h
> gstreamer-0.8.9-ipvr/gst/elements/gstfakesink.h
> --- gstreamer-0.8.9/gst/elements/gstfakesink.h 2004-03-30
> 14:36:32.000000000 +0530
> +++ gstreamer-0.8.9-ipvr/gst/elements/gstfakesink.h 2005-04-25
> 13:01:33.095430216 +0530
> @@ -71,6 +71,7 @@
>
> /* signals */
> void (*handoff) (GstElement *element, GstBuffer *buf, GstPad *pad);
> + void (*rcvd_keyframe) (GstElement *fs, const char *name, void
> *vid_keyframe);
> };
>
> GType gst_fakesink_get_type(void);
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
> a projector? How fast can you ride your desk chair down the office luge track?
> If you want to score the big prize, get to know the little guy.
> Play to win an NEC 61" plasma display: http://www.necitguy.com/?r
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Dave/Dina : future TV today ! - http://www.davedina.org/
<-*- thomas (dot) apestaart (dot) org -*->
You, the only sense the world has ever made
<-*- thomas (at) apestaart (dot) org -*->
URGent, best radio on the net - 24/7 ! - http://urgent.fm/
More information about the gstreamer-devel
mailing list