if (split[0] && sscanf (split[0], "%u", &ssrc) && split[1]
&& g_str_has_prefix (split[1], "cname:")) {
- SsrcMapItem ssrc_item;
-
- ssrc_item.media_idx = i;
- ssrc_item.ssrc = ssrc;
- g_array_append_val (item->remote_ssrcmap, ssrc_item);
-
- /* Must be done aftrer the value has been appended because
- * a weak ref cannot be moved. */
- g_weak_ref_init (&g_array_index (item->remote_ssrcmap, SsrcMapItem,
- item->remote_ssrcmap->len - 1).rtpjitterbuffer, NULL);
+ g_ptr_array_add (item->remote_ssrcmap, ssrcmap_item_new (ssrc, i));
}
g_strfreev (split);
}
media_idx = session_id;
for (i = 0; i < stream->remote_ssrcmap->len; i++) {
- SsrcMapItem *item =
- &g_array_index (stream->remote_ssrcmap, SsrcMapItem, i);
+ SsrcMapItem *item = g_ptr_array_index (stream->remote_ssrcmap, i);
if (item->ssrc == ssrc) {
media_idx = item->media_idx;
found_ssrc = TRUE;
WEBRTC_TRANSCEIVER (trans)->do_nack, NULL);
for (i = 0; i < trans->stream->remote_ssrcmap->len; i++) {
- SsrcMapItem *item =
- &g_array_index (trans->stream->remote_ssrcmap, SsrcMapItem, i);
+ SsrcMapItem *item = g_ptr_array_index (trans->stream->remote_ssrcmap, i);
if (item->ssrc == ssrc) {
g_weak_ref_set (&item->rtpjitterbuffer, jitterbuffer);
gst_structure_get (source_stats, "have-sr", G_TYPE_BOOLEAN, &have_sr, NULL);
for (i = 0; i < stream->remote_ssrcmap->len; i++) {
- SsrcMapItem *item =
- &g_array_index (stream->remote_ssrcmap, SsrcMapItem, i);
+ SsrcMapItem *item = g_ptr_array_index (stream->remote_ssrcmap, i);
if (item->ssrc == ssrc) {
GObject *jb = g_weak_ref_get (&item->rtpjitterbuffer);
TransportStream *stream = TRANSPORT_STREAM (object);
g_array_free (stream->ptmap, TRUE);
- g_array_free (stream->remote_ssrcmap, TRUE);
+ g_ptr_array_free (stream->remote_ssrcmap, TRUE);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
if (item->caps)
gst_caps_unref (item->caps);
}
+
+SsrcMapItem *
+ssrcmap_item_new (guint32 ssrc, guint media_idx)
+{
+ SsrcMapItem *ssrc_item = g_slice_new (SsrcMapItem);
+
+ ssrc_item->media_idx = media_idx;
+ ssrc_item->ssrc = ssrc;
+ g_weak_ref_init (&ssrc_item->rtpjitterbuffer, NULL);
+
+ return ssrc_item;
+}
+
static void
-clear_ssrcmap_item (SsrcMapItem * item)
+ssrcmap_item_free (SsrcMapItem * item)
{
g_weak_ref_clear (&item->rtpjitterbuffer);
+ g_slice_free (SsrcMapItem, item);
}
static void
{
stream->ptmap = g_array_new (FALSE, TRUE, sizeof (PtMapItem));
g_array_set_clear_func (stream->ptmap, (GDestroyNotify) clear_ptmap_item);
- stream->remote_ssrcmap = g_array_new (FALSE, TRUE, sizeof (SsrcMapItem));
- g_array_set_clear_func (stream->remote_ssrcmap,
- (GDestroyNotify) clear_ssrcmap_item);
+ stream->remote_ssrcmap = g_ptr_array_new_with_free_func (
+ (GDestroyNotify) ssrcmap_item_free);
}
TransportStream *
GWeakRef rtpjitterbuffer; /* for stats */
} SsrcMapItem;
+SsrcMapItem * ssrcmap_item_new (guint32 ssrc,
+ guint media_idx);
+
struct _TransportStream
{
GstObject parent;
GstWebRTCDTLSTransport *transport;
GArray *ptmap; /* array of PtMapItem's */
- GArray *remote_ssrcmap; /* array of SsrcMapItem's */
+ GPtrArray *remote_ssrcmap; /* array of SsrcMapItem's */
gboolean output_connected; /* whether receive bin is connected to rtpbin */
GstElement *rtxsend;