rtph264pay: change config-interval property type from uint to int

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
This commit is contained in:
Tim-Philipp Müller 2015-11-27 09:03:51 +01:00
parent a400d504ca
commit 3026d1094b
3 changed files with 30 additions and 5 deletions

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

View file

@ -71,7 +71,7 @@ struct _GstRtpH264Pay
GstAdapter *adapter;
guint spspps_interval;
gint spspps_interval;
gboolean send_spspps;
GstClockTime last_spspps;

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