rtph264pay: change config-interval property type from uint to int
authorTim-Philipp Müller <tim@centricular.com>
Fri, 27 Nov 2015 08:03:51 +0000 (09:03 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 27 Nov 2015 12:48:09 +0000 (12:48 +0000)
This way we can use -1 as special value, which is nicer than MAXUINT.
This is backwards compatible even with the GValue API, as shown by
a unit test.

https://bugzilla.gnome.org/show_bug.cgi?id=757892

gst/rtp/gstrtph264pay.c
gst/rtp/gstrtph264pay.h
tests/check/elements/rtp-payloading.c

index ea1aa50..af25e73 100644 (file)
@@ -124,11 +124,11 @@ gst_rtp_h264_pay_class_init (GstRtpH264PayClass * klass)
 
   g_object_class_install_property (G_OBJECT_CLASS (klass),
       PROP_CONFIG_INTERVAL,
-      g_param_spec_uint ("config-interval",
+      g_param_spec_int ("config-interval",
           "SPS PPS Send Interval",
           "Send SPS and PPS Insertion Interval in seconds (sprop parameter sets "
           "will be multiplexed in the data stream when detected.) (0 = disabled)",
-          0, 3600, DEFAULT_CONFIG_INTERVAL,
+          -1, 3600, DEFAULT_CONFIG_INTERVAL,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
       );
 
@@ -1373,7 +1373,7 @@ gst_rtp_h264_pay_set_property (GObject * object, guint prop_id,
       rtph264pay->update_caps = TRUE;
       break;
     case PROP_CONFIG_INTERVAL:
-      rtph264pay->spspps_interval = g_value_get_uint (value);
+      rtph264pay->spspps_interval = g_value_get_int (value);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1394,7 +1394,7 @@ gst_rtp_h264_pay_get_property (GObject * object, guint prop_id,
       g_value_set_string (value, rtph264pay->sprop_parameter_sets);
       break;
     case PROP_CONFIG_INTERVAL:
-      g_value_set_uint (value, rtph264pay->spspps_interval);
+      g_value_set_int (value, rtph264pay->spspps_interval);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
index 44f7af4..c5a5e9f 100644 (file)
@@ -71,7 +71,7 @@ struct _GstRtpH264Pay
 
   GstAdapter *adapter;
 
-  guint spspps_interval;
+  gint spspps_interval;
   gboolean send_spspps;
   GstClockTime last_spspps;
 
index f19306b..3af1d6c 100644 (file)
@@ -615,6 +615,31 @@ GST_START_TEST (rtp_h264)
       rtp_h264_frame_count,
       "video/x-h264,stream-format=(string)byte-stream,alignment=(string)nal",
       "rtph264pay", "rtph264depay", 0, 0, FALSE);
+
+  /* config-interval property used to be of uint type, was changed to int,
+   * make sure old GValue stuff still works */
+  {
+    GValue val = G_VALUE_INIT;
+    GstElement *rtph264pay;
+    GParamSpec *pspec;
+
+
+    rtph264pay = gst_element_factory_make ("rtph264pay", NULL);
+    pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (rtph264pay),
+        "config-interval");
+    fail_unless (pspec->value_type == G_TYPE_INT);
+    g_value_init (&val, G_TYPE_UINT);
+    g_value_set_uint (&val, 10);
+    g_object_set_property (G_OBJECT (rtph264pay), "config-interval", &val);
+    g_value_set_uint (&val, 0);
+    g_object_get_property (G_OBJECT (rtph264pay), "config-interval", &val);
+    fail_unless_equals_int (10, g_value_get_uint (&val));
+    g_object_set (G_OBJECT (rtph264pay), "config-interval", -1, NULL);
+    g_object_get_property (G_OBJECT (rtph264pay), "config-interval", &val);
+    fail_unless (g_value_get_uint (&val) == G_MAXUINT);
+    g_value_unset (&val);
+    gst_object_unref (rtph264pay);
+  }
 }
 
 GST_END_TEST;