tests: modernize GstTypeFind functions.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 20 Mar 2013 17:33:23 +0000 (18:33 +0100)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 20 Mar 2013 17:35:01 +0000 (18:35 +0100)
Use the GstTypeFind hooks from GStreamer 1.0. They look safer and
exactly correspond to the expected behaviour.

gst-libs/gst/vaapi/gstcompat.h
tests/codec.c

index 81fa868..8ff3180 100644 (file)
@@ -50,4 +50,13 @@ gst_compat_video_overlay_rectangle_get_pixels_unscaled_raw(
         &width, &height, &stride, flags);
 }
 
+/* GstTypeFind */
+#undef  GstTypeFindPeekFunction
+#define GstTypeFindPeekFunction         GstCompatTypeFindPeekFunction
+#undef  GstTypeFindSuggestFunction
+#define GstTypeFindSuggestFunction      GstCompatTypeFindSuggestFunction
+
+typedef guint8 *(*GstCompatTypeFindPeekFunction)(gpointer, gint64, guint);
+typedef void (*GstCompatTypeFindSuggestFunction)(gpointer, guint, const GstCaps *);
+
 #endif /* GST_COMPAT_H */
index 2a8aca1..fa690f1 100644 (file)
@@ -98,7 +98,7 @@ typedef struct {
     GstTypeFind  type_find;
 } CodecIdentifier;
 
-static guint8 *
+static const guint8 *
 codec_identifier_peek(gpointer data, gint64 offset, guint size)
 {
     CodecIdentifier * const cip = data;
@@ -111,13 +111,13 @@ codec_identifier_peek(gpointer data, gint64 offset, guint size)
 }
 
 static void
-codec_identifier_suggest(gpointer data, guint probability, const GstCaps *caps)
+codec_identifier_suggest(gpointer data, guint probability, GstCaps *caps)
 {
     CodecIdentifier * const cip = data;
 
     if (cip->probability < probability) {
         cip->probability = probability;
-        gst_caps_replace(&cip->caps, (GstCaps *)caps);
+        gst_caps_replace(&cip->caps, caps);
     }
 }
 
@@ -155,8 +155,8 @@ codec_identifier_new(const gchar *filename)
         goto error;
 
     tfp = &cip->type_find;
-    tfp->peek = codec_identifier_peek;
-    tfp->suggest = codec_identifier_suggest;
+    tfp->peek = (GstTypeFindPeekFunction)codec_identifier_peek;
+    tfp->suggest = (GstTypeFindSuggestFunction)codec_identifier_suggest;
     tfp->data = cip;
     return cip;