rtpmux: fix PROP_TIMESTAMP_OFFSET range problems

It could not set the offset for the full guint32 range.
This commit is contained in:
Havard Graff 2016-05-06 16:06:53 +02:00 committed by Olivier Crête
parent 7ad7266163
commit c7579d31a6
2 changed files with 25 additions and 19 deletions

View file

@ -124,7 +124,6 @@ gst_rtp_mux_class_init (GstRTPMuxClass * klass)
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass; gstelement_class = (GstElementClass *) klass;
gst_element_class_add_static_pad_template (gstelement_class, &src_factory); gst_element_class_add_static_pad_template (gstelement_class, &src_factory);
gst_element_class_add_static_pad_template (gstelement_class, &sink_factory); gst_element_class_add_static_pad_template (gstelement_class, &sink_factory);
@ -138,21 +137,25 @@ gst_rtp_mux_class_init (GstRTPMuxClass * klass)
klass->src_event = gst_rtp_mux_src_event_real; klass->src_event = gst_rtp_mux_src_event_real;
g_object_class_install_property (G_OBJECT_CLASS (klass), g_object_class_install_property (gobject_class, PROP_TIMESTAMP_OFFSET,
PROP_TIMESTAMP_OFFSET, g_param_spec_int ("timestamp-offset", g_param_spec_int64 ("timestamp-offset", "Timestamp Offset",
"Timestamp Offset", "Offset to add to all outgoing timestamps (-1 = random)",
"Offset to add to all outgoing timestamps (-1 = random)", -1, -1, G_MAXUINT32, DEFAULT_TIMESTAMP_OFFSET,
G_MAXINT, DEFAULT_TIMESTAMP_OFFSET,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SEQNUM_OFFSET,
g_object_class_install_property (gobject_class, PROP_SEQNUM_OFFSET,
g_param_spec_int ("seqnum-offset", "Sequence number Offset", g_param_spec_int ("seqnum-offset", "Sequence number Offset",
"Offset to add to all outgoing seqnum (-1 = random)", -1, G_MAXINT, "Offset to add to all outgoing seqnum (-1 = random)",
DEFAULT_SEQNUM_OFFSET, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); -1, G_MAXUINT16, DEFAULT_SEQNUM_OFFSET,
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SEQNUM, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_SEQNUM,
g_param_spec_uint ("seqnum", "Sequence number", g_param_spec_uint ("seqnum", "Sequence number",
"The RTP sequence number of the last processed packet", "The RTP sequence number of the last processed packet",
0, G_MAXUINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); 0, G_MAXUINT, 0,
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SSRC, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_SSRC,
g_param_spec_uint ("ssrc", "SSRC", g_param_spec_uint ("ssrc", "SSRC",
"The SSRC of the packets (default == random)", "The SSRC of the packets (default == random)",
0, G_MAXUINT, DEFAULT_SSRC, 0, G_MAXUINT, DEFAULT_SSRC,
@ -351,8 +354,10 @@ gst_rtp_mux_readjust_rtp_timestamp_locked (GstRTPMux * rtp_mux,
ts = gst_rtp_buffer_get_timestamp (rtpbuffer) - sink_ts_base + ts = gst_rtp_buffer_get_timestamp (rtpbuffer) - sink_ts_base +
rtp_mux->ts_base; rtp_mux->ts_base;
GST_LOG_OBJECT (rtp_mux, "Re-adjusting RTP ts %u to %u", GST_LOG_OBJECT (rtp_mux,
gst_rtp_buffer_get_timestamp (rtpbuffer), ts); "Re-adjusting RTP ts %u to %u (sink_ts_base = %u, rtp_mux->ts_base=%u)",
gst_rtp_buffer_get_timestamp (rtpbuffer),
ts, sink_ts_base, rtp_mux->ts_base);
gst_rtp_buffer_set_timestamp (rtpbuffer, ts); gst_rtp_buffer_set_timestamp (rtpbuffer, ts);
} }
@ -810,7 +815,7 @@ gst_rtp_mux_get_property (GObject * object,
GST_OBJECT_LOCK (rtp_mux); GST_OBJECT_LOCK (rtp_mux);
switch (prop_id) { switch (prop_id) {
case PROP_TIMESTAMP_OFFSET: case PROP_TIMESTAMP_OFFSET:
g_value_set_int (value, rtp_mux->ts_offset); g_value_set_int64 (value, rtp_mux->ts_offset);
break; break;
case PROP_SEQNUM_OFFSET: case PROP_SEQNUM_OFFSET:
g_value_set_int (value, rtp_mux->seqnum_offset); g_value_set_int (value, rtp_mux->seqnum_offset);
@ -838,7 +843,7 @@ gst_rtp_mux_set_property (GObject * object,
switch (prop_id) { switch (prop_id) {
case PROP_TIMESTAMP_OFFSET: case PROP_TIMESTAMP_OFFSET:
rtp_mux->ts_offset = g_value_get_int (value); rtp_mux->ts_offset = g_value_get_int64 (value);
break; break;
case PROP_SEQNUM_OFFSET: case PROP_SEQNUM_OFFSET:
rtp_mux->seqnum_offset = g_value_get_int (value); rtp_mux->seqnum_offset = g_value_get_int (value);

View file

@ -43,7 +43,7 @@ typedef struct _GstRTPMuxClass GstRTPMuxClass;
typedef struct typedef struct
{ {
gboolean have_timestamp_offset; gboolean have_timestamp_offset;
guint timestamp_offset; guint32 timestamp_offset;
GstSegment segment; GstSegment segment;
@ -66,8 +66,9 @@ struct _GstRTPMux
guint32 ts_base; guint32 ts_base;
guint16 seqnum_base; guint16 seqnum_base;
gint32 ts_offset; gint64 ts_offset;
gint16 seqnum_offset; gint seqnum_offset;
guint16 seqnum; /* protected by object lock */ guint16 seqnum; /* protected by object lock */
guint ssrc; guint ssrc;
guint current_ssrc; guint current_ssrc;