rtpsession: possible deadlock while reading network properties
A simple program that listens to the a network stream and monitors for qos and RTP statistics.
$ gst-launch-1.0 videotestsrc ! x264enc ! h264parse ! rtph264pay ! rtpsink uri=rtp://0.0.0.0:5004
The listening PoC application polls RTP stats every second from rtpsession with a timer
201 g_object_get(element, "stats", &stats, NULL);
202 g_return_val_if_fail (stats != NULL, TRUE);
203
204 GST_DEBUG ("Statistics: %" GST_PTR_FORMAT ": %" GST_PTR_FORMAT,
205 element, stats);
206
207 stats_arr = g_value_get_boxed (gst_structure_get_value (stats, "source-stats"));
208 no_bitrate = TRUE;
209 for (i = 0; i < stats_arr->n_values; i++) {
210 guint bitrate = 0u;
211 guint jitter= 0u;
212 gint lost = 0;
213 GstStructure *tmp_source_stats;
214
215 tmp_source_stats = g_value_dup_boxed (&stats_arr->values[i]);
216 gst_structure_get (tmp_source_stats,
217 "bitrate", G_TYPE_UINT64, &bitrate,
218 "jitter", G_TYPE_UINT, &jitter,
219 "packets-lost", G_TYPE_INT, &lost,
220 NULL);
221
222 if (bitrate == 0u) continue;
223
224 no_bitrate = FALSE;
225 if (lost - previous_lost > 0u) {
226 GST_INFO("%u: bitrate %u.", i, bitrate);
227 GST_INFO("%u: jitter %u.", i, jitter);
228 GST_INFO("%u: packets lost %d.", i, lost);
229
230 previous_lost = lost;
231 }
232 }
233 if (no_bitrate) GST_WARNING("No bitrate detected.");
This code is fine.
However, from the moment packets-received or bytes-received is added to the gst_structure_get, stopping the sender results in a hard lockup of the machine. Not reading any of those two arguments is fine.