@@ -2391,9 +2391,11 @@ static void janus_videoroom_publisher_destroy(janus_videoroom_publisher *p) {
2391
2391
GList *temp = p->streams;
2392
2392
while(temp) {
2393
2393
ps = (janus_videoroom_publisher_stream *)temp->data;
2394
+ janus_refcount_increase(&ps->ref);
2394
2395
janus_mutex_lock(&ps->rtp_forwarders_mutex);
2395
2396
if(g_hash_table_size(ps->rtp_forwarders) == 0) {
2396
2397
janus_mutex_unlock(&ps->rtp_forwarders_mutex);
2398
+ janus_refcount_decrease(&ps->ref);
2397
2399
temp = temp->next;
2398
2400
continue;
2399
2401
}
@@ -2410,6 +2412,7 @@ static void janus_videoroom_publisher_destroy(janus_videoroom_publisher *p) {
2410
2412
}
2411
2413
}
2412
2414
janus_mutex_unlock(&ps->rtp_forwarders_mutex);
2415
+ janus_refcount_decrease(&ps->ref);
2413
2416
temp = temp->next;
2414
2417
}
2415
2418
}
@@ -5849,17 +5852,20 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
5849
5852
GList *temp = publisher->streams;
5850
5853
while(temp) {
5851
5854
janus_videoroom_publisher_stream *ps = (janus_videoroom_publisher_stream *)temp->data;
5855
+ janus_refcount_increase(&ps->ref);
5852
5856
janus_mutex_lock(&ps->rtp_forwarders_mutex);
5853
5857
janus_rtp_forwarder *f = g_hash_table_lookup(ps->rtp_forwarders, GUINT_TO_POINTER(stream_id));
5854
5858
if(f != NULL) {
5855
5859
if(f->metadata != NULL) {
5856
5860
/* This belongs to a remotization, ignore */
5857
5861
janus_mutex_unlock(&ps->rtp_forwarders_mutex);
5862
+ janus_refcount_decrease(&ps->ref);
5858
5863
found = FALSE;
5859
5864
break;
5860
5865
}
5861
5866
g_hash_table_remove(ps->rtp_forwarders, GUINT_TO_POINTER(stream_id));
5862
5867
janus_mutex_unlock(&ps->rtp_forwarders_mutex);
5868
+ janus_refcount_decrease(&ps->ref);
5863
5869
/* Found, remove from global index too */
5864
5870
g_hash_table_remove(publisher->rtp_forwarders, GUINT_TO_POINTER(stream_id));
5865
5871
found = TRUE;
@@ -6412,9 +6418,11 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
6412
6418
GList *temp = p->streams;
6413
6419
while(temp) {
6414
6420
ps = (janus_videoroom_publisher_stream *)temp->data;
6421
+ janus_refcount_increase(&ps->ref);
6415
6422
janus_mutex_lock(&ps->rtp_forwarders_mutex);
6416
6423
if(g_hash_table_size(ps->rtp_forwarders) == 0) {
6417
6424
janus_mutex_unlock(&ps->rtp_forwarders_mutex);
6425
+ janus_refcount_decrease(&ps->ref);
6418
6426
temp = temp->next;
6419
6427
continue;
6420
6428
}
@@ -6431,6 +6439,7 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
6431
6439
json_array_append_new(flist, fl);
6432
6440
}
6433
6441
janus_mutex_unlock(&ps->rtp_forwarders_mutex);
6442
+ janus_refcount_decrease(&ps->ref);
6434
6443
temp = temp->next;
6435
6444
}
6436
6445
janus_mutex_unlock(&p->rtp_forwarders_mutex);
@@ -6834,6 +6843,7 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
6834
6843
GList *temp = publisher->streams;
6835
6844
while(temp) {
6836
6845
janus_videoroom_publisher_stream *ps = (janus_videoroom_publisher_stream *)temp->data;
6846
+ janus_refcount_increase(&ps->ref);
6837
6847
janus_mutex_lock(&ps->rtp_forwarders_mutex);
6838
6848
GHashTableIter iter;
6839
6849
gpointer value;
@@ -6849,6 +6859,7 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
6849
6859
}
6850
6860
}
6851
6861
janus_mutex_unlock(&ps->rtp_forwarders_mutex);
6862
+ janus_refcount_decrease(&ps->ref);
6852
6863
temp = temp->next;
6853
6864
}
6854
6865
janus_mutex_unlock(&publisher->rtp_forwarders_mutex);
@@ -7901,9 +7912,13 @@ static void janus_videoroom_incoming_rtp_internal(janus_videoroom_session *sessi
7901
7912
/* Find the stream this packet belongs to */
7902
7913
janus_mutex_lock(&participant->streams_mutex);
7903
7914
janus_videoroom_publisher_stream *ps = g_hash_table_lookup(participant->streams_byid, GINT_TO_POINTER(pkt->mindex));
7915
+ if(ps != NULL)
7916
+ janus_refcount_increase_nodebug(&ps->ref);
7904
7917
janus_mutex_unlock(&participant->streams_mutex);
7905
- if(ps == NULL || ps->disabled) {
7918
+ if(ps == NULL || ps->disabled || g_atomic_int_get(&ps->destroyed) ) {
7906
7919
/* No stream..? */
7920
+ if(ps != NULL)
7921
+ janus_refcount_decrease_nodebug(&ps->ref);
7907
7922
janus_videoroom_publisher_dereference_nodebug(participant);
7908
7923
return;
7909
7924
}
@@ -8140,6 +8155,7 @@ static void janus_videoroom_incoming_rtp_internal(janus_videoroom_session *sessi
8140
8155
}
8141
8156
}
8142
8157
}
8158
+ janus_refcount_decrease_nodebug(&ps->ref);
8143
8159
janus_videoroom_publisher_dereference_nodebug(participant);
8144
8160
}
8145
8161
@@ -8227,9 +8243,13 @@ static void janus_videoroom_incoming_data_internal(janus_videoroom_session *sess
8227
8243
/* Find the stream this packet belongs to */
8228
8244
janus_mutex_lock(&participant->streams_mutex);
8229
8245
janus_videoroom_publisher_stream *ps = g_hash_table_lookup(participant->streams_byid, GINT_TO_POINTER(participant->data_mindex));
8246
+ if(ps != NULL)
8247
+ janus_refcount_increase_nodebug(&ps->ref);
8230
8248
janus_mutex_unlock(&participant->streams_mutex);
8231
- if(ps == NULL || !ps->active || ps->muted) {
8249
+ if(ps == NULL || !ps->active || ps->muted || g_atomic_int_get(&ps->destroyed) ) {
8232
8250
/* No or inactive stream..? */
8251
+ if(ps != NULL)
8252
+ janus_refcount_decrease_nodebug(&ps->ref);
8233
8253
janus_videoroom_publisher_dereference_nodebug(participant);
8234
8254
return;
8235
8255
}
@@ -8288,6 +8308,7 @@ static void janus_videoroom_incoming_data_internal(janus_videoroom_session *sess
8288
8308
janus_mutex_lock_nodebug(&ps->subscribers_mutex);
8289
8309
g_slist_foreach(ps->subscribers, janus_videoroom_relay_data_packet, &pkt);
8290
8310
janus_mutex_unlock_nodebug(&ps->subscribers_mutex);
8311
+ janus_refcount_decrease_nodebug(&ps->ref);
8291
8312
janus_videoroom_publisher_dereference_nodebug(participant);
8292
8313
}
8293
8314
0 commit comments