typefind: remove const from refcounted GstCaps
authorWim Taymans <wim.taymans@collabora.co.uk>
Sat, 10 Mar 2012 08:25:43 +0000 (09:25 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Sat, 10 Mar 2012 08:25:43 +0000 (09:25 +0100)
Having const on refcounted objects require us to make copies instead of simply
taking a ref, don't do that.

gst/gsttypefind.c
gst/gsttypefind.h
libs/gst/base/gsttypefindhelper.c
plugins/elements/gsttypefindelement.c
plugins/elements/gsttypefindelement.h

index 2cfb8d0..24c4730 100644 (file)
@@ -145,8 +145,7 @@ gst_type_find_peek (GstTypeFind * find, gint64 offset, guint size)
  * It is up to the caller of the #GstTypeFindFunction to interpret these values.
  */
 void
-gst_type_find_suggest (GstTypeFind * find, guint probability,
-    const GstCaps * caps)
+gst_type_find_suggest (GstTypeFind * find, guint probability, GstCaps * caps)
 {
   g_return_if_fail (find->suggest != NULL);
   g_return_if_fail (probability <= 100);
index 31a0a2e..9e66b6d 100644 (file)
@@ -80,7 +80,7 @@ struct _GstTypeFind {
 
   void            (* suggest)    (gpointer         data,
                                   guint            probability,
-                                  const GstCaps *  caps);
+                                  GstCaps         *caps);
 
   gpointer         data;
 
@@ -100,7 +100,7 @@ const guint8 *  gst_type_find_peek       (GstTypeFind   * find,
 
 void            gst_type_find_suggest    (GstTypeFind   * find,
                                           guint           probability,
-                                          const GstCaps * caps);
+                                          GstCaps       * caps);
 
 void            gst_type_find_suggest_simple (GstTypeFind * find,
                                               guint         probability,
index 9cefb94..903c96c 100644 (file)
@@ -43,7 +43,7 @@
 /* ********************** typefinding in pull mode ************************ */
 
 static void
-helper_find_suggest (gpointer data, guint probability, const GstCaps * caps);
+helper_find_suggest (gpointer data, guint probability, GstCaps * caps);
 
 typedef struct
 {
@@ -201,7 +201,7 @@ error:
  */
 static void
 helper_find_suggest (gpointer data, GstTypeFindProbability probability,
-    const GstCaps * caps)
+    GstCaps * caps)
 {
   GstTypeFindHelper *helper = (GstTypeFindHelper *) data;
 
@@ -210,9 +210,7 @@ helper_find_suggest (gpointer data, GstTypeFindProbability probability,
       GST_OBJECT_NAME (helper->factory), probability, caps);
 
   if (probability > helper->best_probability) {
-    GstCaps *copy = gst_caps_copy (caps);
-
-    gst_caps_take (&helper->caps, copy);
+    gst_caps_replace (&helper->caps, caps);
     helper->best_probability = probability;
   }
 }
@@ -445,7 +443,7 @@ buf_helper_find_peek (gpointer data, gint64 off, guint size)
  */
 static void
 buf_helper_find_suggest (gpointer data, GstTypeFindProbability probability,
-    const GstCaps * caps)
+    GstCaps * caps)
 {
   GstTypeFindBufHelper *helper = (GstTypeFindBufHelper *) data;
 
@@ -455,10 +453,7 @@ buf_helper_find_suggest (gpointer data, GstTypeFindProbability probability,
 
   /* Note: not >= as we call typefinders in order of rank, highest first */
   if (probability > helper->best_probability) {
-    GstCaps *copy = gst_caps_copy (caps);
-
-    gst_caps_replace (&helper->caps, copy);
-    gst_caps_unref (copy);
+    gst_caps_replace (&helper->caps, caps);
     helper->best_probability = probability;
   }
 }
index 9a99d4c..7db416b 100644 (file)
@@ -175,10 +175,8 @@ static guint gst_type_find_element_signals[LAST_SIGNAL] = { 0 };
 
 static void
 gst_type_find_element_have_type (GstTypeFindElement * typefind,
-    guint probability, const GstCaps * caps)
+    guint probability, GstCaps * caps)
 {
-  GstCaps *copy;
-
   g_assert (caps != NULL);
 
   GST_INFO_OBJECT (typefind, "found caps %" GST_PTR_FORMAT ", probability=%u",
@@ -187,12 +185,10 @@ gst_type_find_element_have_type (GstTypeFindElement * typefind,
   GST_OBJECT_LOCK (typefind);
   if (typefind->caps)
     gst_caps_unref (typefind->caps);
-  typefind->caps = gst_caps_copy (caps);
-  copy = gst_caps_ref (typefind->caps);
+  typefind->caps = gst_caps_ref (caps);
   GST_OBJECT_UNLOCK (typefind);
 
-  gst_pad_push_event (typefind->src, gst_event_new_caps (copy));
-  gst_caps_unref (copy);
+  gst_pad_push_event (typefind->src, gst_event_new_caps (caps));
 }
 
 static void
index 4a36369..0242ec2 100644 (file)
@@ -71,8 +71,8 @@ struct _GstTypeFindElementClass {
 
   /* signals */
   void                         (*have_type)    (GstTypeFindElement *element,
-                                        guint          probability,
-                                        const GstCaps *        caps);
+                                        guint               probability,
+                                        GstCaps            *caps);
 };
 
 GType gst_type_find_element_get_type (void);