[gst-devel] [PATCH 1/3] gstreamer-0.8.9-gstfakesink.patch

Pfiffer, AndrewX K andrewx.k.pfiffer at intel.com
Fri Jun 10 13:48:23 CEST 2005


[this patch is relative to gstreamer-0.8.9]
--

This patch was developed as part of ongoing work in support of the
Consumer Electronics Linux Forum (CELF). [ http://www.celinuxforum.org/
]

Signed-off-by: Saikat Sanyal <saikat at alumnux.com>
Signed-off-by: Andrew Pfiffer <andrewx.k.pfiffer at intel.com>

This patch addresses two race conditions in Gst-Pads and Gst-Elements
encountered in thread-based scenarios of GStreamer applications.

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.

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);




More information about the gstreamer-devel mailing list