@@ -1144,7 +1144,7 @@ room-<unique room ID>: {
1144
1144
*
1145
1145
* Once a WebRTC PeerConnection has been established for a subscriber, in
1146
1146
* case you want to update a subscription you have to use the \c subscribe ,
1147
- * \c unsubscribe or \update methods: as the names of the requests suggest, the
1147
+ * \c unsubscribe or \c update methods: as the names of the requests suggest, the
1148
1148
* former allows you to add more streams to subscribe to, the second
1149
1149
* instructs the plugin to remove streams you're currently subscribe to,
1150
1150
* while the latter allows you to perform both operations at the same time.
@@ -1523,8 +1523,8 @@ room-<unique room ID>: {
1523
1523
1524
1524
1525
1525
/* Plugin information */
1526
- #define JANUS_VIDEOROOM_VERSION 9
1527
- #define JANUS_VIDEOROOM_VERSION_STRING "0.0.9 "
1526
+ #define JANUS_VIDEOROOM_VERSION 10
1527
+ #define JANUS_VIDEOROOM_VERSION_STRING "0.0.10 "
1528
1528
#define JANUS_VIDEOROOM_DESCRIPTION "This is a plugin implementing a videoconferencing SFU (Selective Forwarding Unit) for Janus, that is an audio/video router."
1529
1529
#define JANUS_VIDEOROOM_NAME "JANUS VideoRoom plugin"
1530
1530
#define JANUS_VIDEOROOM_AUTHOR "Meetecho s.r.l."
@@ -2633,6 +2633,7 @@ static void janus_videoroom_reqpli(janus_videoroom_publisher_stream *ps, const c
2633
2633
#define JANUS_VIDEOROOM_ERROR_NOT_PUBLISHED 435
2634
2634
#define JANUS_VIDEOROOM_ERROR_ID_EXISTS 436
2635
2635
#define JANUS_VIDEOROOM_ERROR_INVALID_SDP 437
2636
+ #define JANUS_VIDEOROOM_ERROR_INVALID_FEED 438
2636
2637
2637
2638
2638
2639
/* RTP forwarder helpers */
@@ -3198,6 +3199,8 @@ static json_t *janus_videoroom_subscriber_offer(janus_videoroom_subscriber *subs
3198
3199
char *sdp = janus_sdp_write(offer);
3199
3200
janus_sdp_destroy(offer);
3200
3201
json_t *jsep = json_pack("{ssss}", "type", "offer", "sdp", sdp);
3202
+ if(subscriber->e2ee)
3203
+ json_object_set_new(jsep, "e2ee", json_true());
3201
3204
g_free(sdp);
3202
3205
/* Done */
3203
3206
return jsep;
@@ -9260,6 +9263,7 @@ static void *janus_videoroom_handler(void *data) {
9260
9263
gboolean autoupdate = au ? json_is_true(au) : TRUE;
9261
9264
/* Make sure all the feeds we're subscribing to exist */
9262
9265
GList *publishers = NULL;
9266
+ gboolean e2ee = videoroom->require_e2ee, sub_e2ee = FALSE, first = TRUE;
9263
9267
size_t i = 0;
9264
9268
for(i=0; i<json_array_size(feeds); i++) {
9265
9269
json_t *s = json_array_get(feeds, i);
@@ -9328,6 +9332,49 @@ static void *janus_videoroom_handler(void *data) {
9328
9332
janus_refcount_decrease(&videoroom->ref);
9329
9333
goto error;
9330
9334
}
9335
+ sub_e2ee = publisher->e2ee;
9336
+ if(e2ee && !sub_e2ee) {
9337
+ /* Attempt to subscribe to non-end-to-end encrypted
9338
+ * publisher in an end-to-end encrypted subscription */
9339
+ JANUS_LOG(LOG_ERR, "Can't have not end-to-end encrypted feed in this subscription (%s)\n", feed_id_str);
9340
+ error_code = JANUS_VIDEOROOM_ERROR_INVALID_FEED;
9341
+ g_snprintf(error_cause, 512, "Can't have not end-to-end encrypted feed in this subscription (%s)", feed_id_str);
9342
+ janus_mutex_unlock(&videoroom->mutex);
9343
+ /* Unref publishers we may have taken note of so far */
9344
+ while(publishers) {
9345
+ publisher = (janus_videoroom_publisher *)publishers->data;
9346
+ janus_refcount_decrease(&publisher->session->ref);
9347
+ janus_refcount_decrease(&publisher->ref);
9348
+ publishers = g_list_remove(publishers, publisher);
9349
+ }
9350
+ janus_mutex_unlock(&sessions_mutex);
9351
+ janus_refcount_decrease(&videoroom->ref);
9352
+ goto error;
9353
+ } else if(!e2ee && sub_e2ee) {
9354
+ if(first) {
9355
+ /* This subscription will use end-to-end encryption */
9356
+ e2ee = TRUE;
9357
+ } else {
9358
+ /* Attempt to subscribe to end-to-end encrypted
9359
+ * publisher in a non-end-to-end encrypted subscription */
9360
+ JANUS_LOG(LOG_ERR, "Can't have end-to-end encrypted feed in this subscription (%s)\n", feed_id_str);
9361
+ error_code = JANUS_VIDEOROOM_ERROR_INVALID_FEED;
9362
+ g_snprintf(error_cause, 512, "Can't have end-to-end encrypted feed in this subscription (%s)", feed_id_str);
9363
+ janus_mutex_unlock(&videoroom->mutex);
9364
+ /* Unref publishers we may have taken note of so far */
9365
+ while(publishers) {
9366
+ publisher = (janus_videoroom_publisher *)publishers->data;
9367
+ janus_refcount_decrease(&publisher->session->ref);
9368
+ janus_refcount_decrease(&publisher->ref);
9369
+ publishers = g_list_remove(publishers, publisher);
9370
+ }
9371
+ janus_mutex_unlock(&sessions_mutex);
9372
+ janus_refcount_decrease(&videoroom->ref);
9373
+ goto error;
9374
+ }
9375
+ }
9376
+ if(first)
9377
+ first = FALSE;
9331
9378
const char *mid = json_string_value(json_object_get(s, "mid"));
9332
9379
if(mid != NULL) {
9333
9380
/* Check the mid too */
@@ -9429,6 +9476,7 @@ static void *janus_videoroom_handler(void *data) {
9429
9476
subscriber->room_id = videoroom->room_id;
9430
9477
subscriber->room_id_str = videoroom->room_id_str ? g_strdup(videoroom->room_id_str) : NULL;
9431
9478
subscriber->room = videoroom;
9479
+ subscriber->e2ee = e2ee;
9432
9480
videoroom = NULL;
9433
9481
subscriber->pvt_id = pvt_id;
9434
9482
subscriber->use_msid = use_msid;
@@ -10358,6 +10406,21 @@ static void *janus_videoroom_handler(void *data) {
10358
10406
janus_refcount_decrease(&subscriber->ref);
10359
10407
goto error;
10360
10408
}
10409
+ if(publisher->e2ee != subscriber->e2ee) {
10410
+ /* Attempt to mix normal and end-to-end encrypted subscriptions */
10411
+ JANUS_LOG(LOG_ERR, "Can't mix normal and end-to-end encrypted subscriptions\n");
10412
+ error_code = JANUS_VIDEOROOM_ERROR_INVALID_FEED;
10413
+ g_snprintf(error_cause, 512, "Can't mix normal and end-to-end encrypted subscriptions");
10414
+ /* Unref publishers we may have taken note of so far */
10415
+ while(publishers) {
10416
+ publisher = (janus_videoroom_publisher *)publishers->data;
10417
+ janus_refcount_decrease(&publisher->session->ref);
10418
+ janus_refcount_decrease(&publisher->ref);
10419
+ publishers = g_list_remove(publishers, publisher);
10420
+ }
10421
+ janus_refcount_decrease(&subscriber->ref);
10422
+ goto error;
10423
+ }
10361
10424
const char *mid = json_string_value(json_object_get(s, "mid"));
10362
10425
if(mid != NULL) {
10363
10426
/* Check the mid too */
@@ -11261,6 +11324,21 @@ static void *janus_videoroom_handler(void *data) {
11261
11324
janus_refcount_decrease(&subscriber->ref);
11262
11325
goto error;
11263
11326
}
11327
+ if(publisher->e2ee != subscriber->e2ee) {
11328
+ /* Attempt to mix normal and end-to-end encrypted subscriptions */
11329
+ JANUS_LOG(LOG_ERR, "Can't mix normal and end-to-end encrypted subscriptions\n");
11330
+ error_code = JANUS_VIDEOROOM_ERROR_INVALID_FEED;
11331
+ g_snprintf(error_cause, 512, "Can't mix normal and end-to-end encrypted subscriptions");
11332
+ /* Unref publishers we may have taken note of so far */
11333
+ while(publishers) {
11334
+ publisher = (janus_videoroom_publisher *)publishers->data;
11335
+ janus_refcount_decrease(&publisher->session->ref);
11336
+ janus_refcount_decrease(&publisher->ref);
11337
+ publishers = g_list_remove(publishers, publisher);
11338
+ }
11339
+ janus_refcount_decrease(&subscriber->ref);
11340
+ goto error;
11341
+ }
11264
11342
const char *mid = json_string_value(json_object_get(s, "mid"));
11265
11343
/* Check the mid too */
11266
11344
janus_mutex_lock(&publisher->streams_mutex);
@@ -11618,13 +11696,15 @@ static void *janus_videoroom_handler(void *data) {
11618
11696
JANUS_LOG(LOG_ERR, "Unknown SDP type '%s'\n", msg_sdp_type);
11619
11697
error_code = JANUS_VIDEOROOM_ERROR_INVALID_SDP_TYPE;
11620
11698
g_snprintf(error_cause, 512, "Unknown SDP type '%s'", msg_sdp_type);
11699
+ json_decref(event);
11621
11700
goto error;
11622
11701
}
11623
11702
if(session->participant_type != janus_videoroom_p_type_publisher) {
11624
11703
/* We shouldn't be here, we always offer ourselves */
11625
11704
JANUS_LOG(LOG_ERR, "Only publishers send offers\n");
11626
11705
error_code = JANUS_VIDEOROOM_ERROR_INVALID_SDP_TYPE;
11627
11706
g_snprintf(error_cause, 512, "Only publishers send offers");
11707
+ json_decref(event);
11628
11708
goto error;
11629
11709
} else {
11630
11710
/* This is a new publisher, or an updated one */
@@ -11633,18 +11713,23 @@ static void *janus_videoroom_handler(void *data) {
11633
11713
JANUS_LOG(LOG_ERR, "Invalid participant instance\n");
11634
11714
error_code = JANUS_VIDEOROOM_ERROR_UNKNOWN_ERROR;
11635
11715
g_snprintf(error_cause, 512, "Invalid participant instance");
11716
+ json_decref(event);
11636
11717
goto error;
11637
11718
}
11638
11719
janus_videoroom *videoroom = participant->room;
11639
11720
int count = 0;
11640
11721
GHashTableIter iter;
11641
11722
gpointer value;
11642
11723
if(!videoroom) {
11724
+ janus_refcount_decrease(&participant->ref);
11643
11725
error_code = JANUS_VIDEOROOM_ERROR_NO_SUCH_ROOM;
11726
+ json_decref(event);
11644
11727
goto error;
11645
11728
}
11646
11729
if(g_atomic_int_get(&videoroom->destroyed)) {
11730
+ janus_refcount_decrease(&participant->ref);
11647
11731
error_code = JANUS_VIDEOROOM_ERROR_NO_SUCH_ROOM;
11732
+ json_decref(event);
11648
11733
goto error;
11649
11734
}
11650
11735
janus_refcount_increase(&videoroom->ref);
@@ -11660,17 +11745,22 @@ static void *janus_videoroom_handler(void *data) {
11660
11745
if(count == videoroom->max_publishers) {
11661
11746
janus_mutex_unlock(&videoroom->mutex);
11662
11747
janus_refcount_decrease(&videoroom->ref);
11748
+ janus_refcount_decrease(&participant->ref);
11663
11749
JANUS_LOG(LOG_ERR, "Maximum number of publishers (%d) already reached\n", videoroom->max_publishers);
11664
11750
error_code = JANUS_VIDEOROOM_ERROR_PUBLISHERS_FULL;
11665
11751
g_snprintf(error_cause, 512, "Maximum number of publishers (%d) already reached", videoroom->max_publishers);
11752
+ json_decref(event);
11666
11753
goto error;
11667
11754
}
11668
11755
janus_mutex_unlock(&videoroom->mutex);
11669
11756
}
11670
11757
if(videoroom->require_e2ee && !e2ee && !participant->e2ee) {
11758
+ janus_refcount_decrease(&videoroom->ref);
11759
+ janus_refcount_decrease(&participant->ref);
11671
11760
JANUS_LOG(LOG_ERR, "Room requires end-to-end encrypted media\n");
11672
11761
error_code = JANUS_VIDEOROOM_ERROR_UNAUTHORIZED;
11673
11762
g_snprintf(error_cause, 512, "Room requires end-to-end encrypted media");
11763
+ json_decref(event);
11674
11764
goto error;
11675
11765
}
11676
11766
/* Now prepare the SDP to give back */
@@ -11682,10 +11772,12 @@ static void *janus_videoroom_handler(void *data) {
11682
11772
janus_sdp *offer = janus_sdp_parse(msg_sdp, error_str, sizeof(error_str));
11683
11773
if(offer == NULL) {
11684
11774
janus_refcount_decrease(&videoroom->ref);
11775
+ janus_refcount_decrease(&participant->ref);
11685
11776
json_decref(event);
11686
11777
JANUS_LOG(LOG_ERR, "Error parsing offer: %s\n", error_str);
11687
11778
error_code = JANUS_VIDEOROOM_ERROR_INVALID_SDP;
11688
11779
g_snprintf(error_cause, 512, "Error parsing offer: %s", error_str);
11780
+ json_decref(event);
11689
11781
goto error;
11690
11782
}
11691
11783
/* Prepare an answer, by iterating on all m-lines */
0 commit comments