[MOVED FROM GST-P-FARSIGHT] Protect the seqnum with object lock in rtpmux

This commit is contained in:
Olivier Crête 2009-02-18 18:14:52 -05:00 committed by Edward Hervey
parent d0c7c0fc6c
commit 7a222b560e
2 changed files with 9 additions and 1 deletions

View file

@ -373,8 +373,10 @@ gst_rtp_mux_chain (GstPad * pad, GstBuffer * buffer)
buffer = gst_buffer_make_writable(buffer); buffer = gst_buffer_make_writable(buffer);
GST_OBJECT_LOCK (rtp_mux);
rtp_mux->seqnum++; rtp_mux->seqnum++;
gst_rtp_buffer_set_seq (buffer, rtp_mux->seqnum); gst_rtp_buffer_set_seq (buffer, rtp_mux->seqnum);
GST_OBJECT_UNLOCK (rtp_mux);
GST_BUFFER_CAPS (buffer) = gst_caps_make_writable(GST_BUFFER_CAPS (buffer)); GST_BUFFER_CAPS (buffer) = gst_caps_make_writable(GST_BUFFER_CAPS (buffer));
structure = gst_caps_get_structure (GST_BUFFER_CAPS (buffer), 0U); structure = gst_caps_get_structure (GST_BUFFER_CAPS (buffer), 0U);
gst_structure_set (structure, "seqnum-base", G_TYPE_UINT, rtp_mux->seqnum_base, NULL); gst_structure_set (structure, "seqnum-base", G_TYPE_UINT, rtp_mux->seqnum_base, NULL);
@ -545,7 +547,9 @@ gst_rtp_mux_get_property (GObject * object,
g_value_set_int (value, rtp_mux->seqnum_offset); g_value_set_int (value, rtp_mux->seqnum_offset);
break; break;
case PROP_SEQNUM: case PROP_SEQNUM:
GST_OBJECT_LOCK (rtp_mux);
g_value_set_uint (value, rtp_mux->seqnum); g_value_set_uint (value, rtp_mux->seqnum);
GST_OBJECT_UNLOCK (rtp_mux);
break; break;
case PROP_SSRC: case PROP_SSRC:
g_value_set_uint (value, rtp_mux->ssrc); g_value_set_uint (value, rtp_mux->ssrc);
@ -583,6 +587,8 @@ gst_rtp_mux_set_property (GObject * object,
static void static void
gst_rtp_mux_ready_to_paused (GstRTPMux * rtp_mux) gst_rtp_mux_ready_to_paused (GstRTPMux * rtp_mux)
{ {
GST_OBJECT_LOCK (rtp_mux);
if (rtp_mux->ssrc == -1) if (rtp_mux->ssrc == -1)
rtp_mux->current_ssrc = g_random_int (); rtp_mux->current_ssrc = g_random_int ();
else else
@ -599,6 +605,8 @@ gst_rtp_mux_ready_to_paused (GstRTPMux * rtp_mux)
else else
rtp_mux->ts_base = rtp_mux->ts_offset; rtp_mux->ts_base = rtp_mux->ts_offset;
GST_DEBUG_OBJECT (rtp_mux, "set clock-base to %u", rtp_mux->ts_base); GST_DEBUG_OBJECT (rtp_mux, "set clock-base to %u", rtp_mux->ts_base);
GST_OBJECT_UNLOCK (rtp_mux);
} }
static GstStateChangeReturn static GstStateChangeReturn

View file

@ -60,7 +60,7 @@ struct _GstRTPMux
gint32 ts_offset; gint32 ts_offset;
gint16 seqnum_offset; gint16 seqnum_offset;
guint16 seqnum; guint16 seqnum; /* protected by object lock */
guint ssrc; guint ssrc;
guint current_ssrc; guint current_ssrc;
}; };