@@ -459,6 +459,7 @@ room-<unique room ID>: {
459
459
{ // Participant #1
460
460
"id" : <unique numeric ID of the participant>,
461
461
"display" : "<display name of the participant, if any; optional>",
462
+ "metadata" : <valid json object of metadata, if any; optional>,
462
463
"publisher" : "<true|false, whether user is an active publisher in the room>",
463
464
"talking" : <true|false, whether user is talking or not (only if audio levels are used)>
464
465
},
@@ -494,7 +495,8 @@ room-<unique room ID>: {
494
495
"room" : <unique ID of the room to join>,
495
496
"id" : <unique ID to register for the publisher; optional, will be chosen by the plugin if missing>,
496
497
"display" : "<display name for the publisher; optional>",
497
- "token" : "<invitation token, in case the room has an ACL; optional>"
498
+ "token" : "<invitation token, in case the room has an ACL; optional>",
499
+ "metadata" : <valid json object with metadata; optional>
498
500
}
499
501
\endverbatim
500
502
*
@@ -523,6 +525,7 @@ room-<unique room ID>: {
523
525
{
524
526
"id" : <unique ID of active publisher #1>,
525
527
"display" : "<display name of active publisher #1, if any>",
528
+ "metadata" : <valid json object of metadata, if any>,
526
529
"dummy" : <true if this participant is a dummy publisher>,
527
530
"streams" : [
528
531
{
@@ -546,7 +549,8 @@ room-<unique room ID>: {
546
549
"attendees" : [ // Only present when notify_joining is set to TRUE for rooms
547
550
{
548
551
"id" : <unique ID of attendee #1>,
549
- "display" : "<display name of attendee #1, if any>"
552
+ "display" : "<display name of attendee #1, if any>",
553
+ "metadata" : <valid json object of metadata, if any>
550
554
},
551
555
// Other attendees
552
556
]
@@ -576,7 +580,8 @@ room-<unique room ID>: {
576
580
"room" : <room ID>,
577
581
"joining" : {
578
582
"id" : <unique ID of the new participant>,
579
- "display" : "<display name of the new participant, if any>"
583
+ "display" : "<display name of the new participant, if any>",
584
+ "metadata" : <valid json object of metadata, if any>
580
585
}
581
586
}
582
587
\endverbatim
@@ -601,6 +606,7 @@ room-<unique room ID>: {
601
606
"record" : <true|false, whether this publisher should be recorded or not; optional>,
602
607
"filename" : "<if recording, the base path/file to use for the recording files; optional>",
603
608
"display" : "<display name to use in the room; optional>",
609
+ "metadata" : <valid json object of metadata; optional>,
604
610
"audio_level_average" : "<if provided, overrides the room audio_level_average for this user; optional>",
605
611
"audio_active_packets" : "<if provided, overrides the room audio_active_packets for this user; optional>",
606
612
"descriptions" : [ // Optional
@@ -668,6 +674,7 @@ room-<unique room ID>: {
668
674
{
669
675
"id" : <unique ID of the new publisher>,
670
676
"display" : "<display name of the new publisher, if any>",
677
+ "metadata" : <valid json object of metadata, if any>,
671
678
"dummy" : <true if this participant is a dummy publisher>,
672
679
"streams" : [
673
680
{
@@ -740,6 +747,7 @@ room-<unique room ID>: {
740
747
"record" : <true|false, whether this publisher should be recorded or not; optional>,
741
748
"filename" : "<if recording, the base path/file to use for the recording files; optional>",
742
749
"display" : "<new display name to use in the room; optional>",
750
+ "metadata" : <new metadata json object; optional>,
743
751
"audio_active_packets" : "<new audio_active_packets to overwrite in the room one; optional>",
744
752
"audio_level_average" : "<new audio_level_average to overwrite the room one; optional>",
745
753
"streams" : [
@@ -1648,6 +1656,7 @@ room-<unique room ID>: {
1648
1656
"id" : <unique ID of the remote publisher>,
1649
1657
"secret" : "<password required to edit the room, mandatory if configured in the room>",
1650
1658
"display" : "<new display name for the remote publisher; optional>",
1659
+ "metadata" : <new valid json object of metadata; optional>,
1651
1660
"streams" : [
1652
1661
{
1653
1662
// Same syntax as add_remote_publisher: only needs to
@@ -2014,6 +2023,7 @@ static struct janus_json_parameter publish_parameters[] = {
2014
2023
{"record", JANUS_JSON_BOOL, 0},
2015
2024
{"filename", JSON_STRING, 0},
2016
2025
{"display", JSON_STRING, 0},
2026
+ {"metadata", JSON_OBJECT, 0},
2017
2027
{"secret", JSON_STRING, 0},
2018
2028
{"audio_level_averge", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE},
2019
2029
{"audio_active_packets", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE},
@@ -2088,7 +2098,8 @@ static struct janus_json_parameter stop_rtp_forward_parameters[] = {
2088
2098
{"stream_id", JSON_INTEGER, JANUS_JSON_PARAM_REQUIRED | JANUS_JSON_PARAM_POSITIVE}
2089
2099
};
2090
2100
static struct janus_json_parameter publisher_parameters[] = {
2091
- {"display", JSON_STRING, 0}
2101
+ {"display", JSON_STRING, 0},
2102
+ {"metadata", JSON_OBJECT, 0}
2092
2103
};
2093
2104
static struct janus_json_parameter configure_stream_parameters[] = {
2094
2105
{"mid", JANUS_JSON_STRING, 0},
@@ -2196,10 +2207,12 @@ static struct janus_json_parameter remote_publisher_parameters[] = {
2196
2207
{"iface", JANUS_JSON_STRING, 0},
2197
2208
{"port", JANUS_JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE},
2198
2209
{"streams", JANUS_JSON_ARRAY, JANUS_JSON_PARAM_REQUIRED},
2210
+ {"metadata", JSON_OBJECT, 0}
2199
2211
};
2200
2212
static struct janus_json_parameter remote_publisher_update_parameters[] = {
2201
2213
{"secret", JSON_STRING, 0},
2202
2214
{"display", JANUS_JSON_STRING, 0},
2215
+ {"metadata", JSON_OBJECT, 0},
2203
2216
{"streams", JANUS_JSON_ARRAY, JANUS_JSON_PARAM_REQUIRED}
2204
2217
};
2205
2218
static struct janus_json_parameter remote_publisher_stream_parameters[] = {
@@ -2432,6 +2445,7 @@ typedef struct janus_videoroom_publisher {
2432
2445
gboolean kicked; /* Whether this participant has been kicked */
2433
2446
gboolean e2ee; /* If media from this publisher is end-to-end encrypted */
2434
2447
janus_mutex mutex; /* Mutex to lock this instance */
2448
+ json_t *metadata;
2435
2449
volatile gint destroyed;
2436
2450
janus_refcount ref;
2437
2451
} janus_videoroom_publisher;
@@ -2760,6 +2774,8 @@ static void janus_videoroom_publisher_free(const janus_refcount *p_ref) {
2760
2774
g_free(p->user_id_str);
2761
2775
g_free(p->display);
2762
2776
g_free(p->recording_base);
2777
+ if(p->metadata != NULL)
2778
+ json_decref(p->metadata);
2763
2779
/* Get rid of all the streams */
2764
2780
g_list_free_full(p->streams, (GDestroyNotify)(janus_videoroom_publisher_stream_destroy));
2765
2781
g_hash_table_unref(p->streams_byid);
@@ -4260,6 +4276,8 @@ static void janus_videoroom_notify_about_publisher(janus_videoroom_publisher *p,
4260
4276
json_object_set_new(pl, "id", string_ids ? json_string(p->user_id_str) : json_integer(p->user_id));
4261
4277
if(p->display)
4262
4278
json_object_set_new(pl, "display", json_string(p->display));
4279
+ if(p->metadata)
4280
+ json_object_set_new(pl, "metadata", json_deep_copy(p->metadata));
4263
4281
/* Add proper info on all the streams */
4264
4282
gboolean audio_added = FALSE, video_added = FALSE;
4265
4283
json_t *media = json_array();
@@ -4333,6 +4351,8 @@ static void janus_videoroom_notify_about_publisher(janus_videoroom_publisher *p,
4333
4351
json_object_set_new(info, "id", string_ids ? json_string(p->user_id_str) : json_integer(p->user_id));
4334
4352
if(p->display)
4335
4353
json_object_set_new(info, "display", json_string(p->display));
4354
+ if(p->metadata)
4355
+ json_object_set_new(info, "metadata", json_deep_copy(p->metadata));
4336
4356
json_t *media = json_array();
4337
4357
GList *temp = p->streams;
4338
4358
while(temp) {
@@ -4377,6 +4397,9 @@ static void janus_videoroom_participant_joining(janus_videoroom_publisher *p) {
4377
4397
if (p->display) {
4378
4398
json_object_set_new(user, "display", json_string(p->display));
4379
4399
}
4400
+ if (p->metadata) {
4401
+ json_object_set_new(user, "metadata", json_deep_copy(p->metadata));
4402
+ }
4380
4403
json_object_set_new(event, "videoroom", json_string("event"));
4381
4404
json_object_set_new(event, "room", string_ids ? json_string(p->room_id_str) : json_integer(p->room_id));
4382
4405
json_object_set_new(event, "joining", user);
@@ -4414,6 +4437,8 @@ static void janus_videoroom_leave_or_unpublish(janus_videoroom_publisher *partic
4414
4437
json_object_set_new(event, "room", string_ids ? json_string(participant->room_id_str) : json_integer(participant->room_id));
4415
4438
if(participant->display)
4416
4439
json_object_set_new(event, "display", json_string(participant->display));
4440
+ if(participant->metadata)
4441
+ json_object_set_new(event, "metadata", json_deep_copy(participant->metadata));
4417
4442
json_object_set_new(event, is_leaving ? (kicked ? "kicked" : "leaving") : "unpublished",
4418
4443
string_ids ? json_string(participant->user_id_str) : json_integer(participant->user_id));
4419
4444
janus_videoroom_notify_participants(participant, event, FALSE);
@@ -4425,6 +4450,8 @@ static void janus_videoroom_leave_or_unpublish(janus_videoroom_publisher *partic
4425
4450
json_object_set_new(info, "id", string_ids ? json_string(participant->user_id_str) : json_integer(participant->user_id));
4426
4451
if(participant->display)
4427
4452
json_object_set_new(info, "display", json_string(participant->display));
4453
+ if(participant->metadata)
4454
+ json_object_set_new(info, "metadata", json_deep_copy(participant->metadata));
4428
4455
gateway->notify_event(&janus_videoroom_plugin, NULL, info);
4429
4456
}
4430
4457
if(is_leaving) {
@@ -4536,6 +4563,8 @@ json_t *janus_videoroom_query_session(janus_plugin_session *handle) {
4536
4563
json_object_set_new(info, "private_id", json_integer(participant->pvt_id));
4537
4564
if(participant->display)
4538
4565
json_object_set_new(info, "display", json_string(participant->display));
4566
+ if(participant->metadata)
4567
+ json_object_set_new(info, "metadata", json_deep_copy(participant->metadata));
4539
4568
/* TODO Fix the summary of viewers, since everything is stream based now */
4540
4569
//~ if(participant->subscribers)
4541
4570
//~ json_object_set_new(info, "viewers", json_integer(g_slist_length(participant->subscribers)));
@@ -6850,6 +6879,8 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
6850
6879
json_object_set_new(pl, "id", string_ids ? json_string(p->user_id_str) : json_integer(p->user_id));
6851
6880
if(p->display)
6852
6881
json_object_set_new(pl, "display", json_string(p->display));
6882
+ if(p->metadata)
6883
+ json_object_set_new(pl, "metadata", json_deep_copy(p->metadata));
6853
6884
if(p->dummy)
6854
6885
json_object_set_new(pl, "dummy", json_true());
6855
6886
if(p->remote)
@@ -6933,6 +6964,8 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
6933
6964
json_object_set_new(pl, "publisher_id", string_ids ? json_string(p->user_id_str) : json_integer(p->user_id));
6934
6965
if(p->display)
6935
6966
json_object_set_new(pl, "display", json_string(p->display));
6967
+ if(p->metadata)
6968
+ json_object_set_new(pl, "metadata", json_deep_copy(p->metadata));
6936
6969
json_t *flist = json_array();
6937
6970
/* Iterate on all media streams to see what's being forwarded */
6938
6971
janus_videoroom_publisher_stream *ps = NULL;
@@ -7579,6 +7612,7 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
7579
7612
char user_id_num[30], *user_id_str = NULL;
7580
7613
gboolean user_id_allocated = FALSE;
7581
7614
json_t *id = json_object_get(root, "id");
7615
+ json_t *metadata = json_object_get(root, "metadata");
7582
7616
if(id) {
7583
7617
if(!string_ids) {
7584
7618
user_id = json_integer_value(id);
@@ -7709,6 +7743,7 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
7709
7743
publisher->remote_ssrc_offset = janus_random_uint32();
7710
7744
publisher->remote_fd = fd;
7711
7745
publisher->remote_rtcp_fd = rtcp_fd;
7746
+ publisher->metadata = metadata ? json_deep_copy(metadata) : NULL;
7712
7747
pipe(publisher->pipefd);
7713
7748
janus_mutex_init(&publisher->subscribers_mutex);
7714
7749
janus_mutex_init(&publisher->own_subscriptions_mutex);
@@ -7973,14 +8008,22 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
7973
8008
goto prepare_response;
7974
8009
}
7975
8010
janus_refcount_increase(&publisher->ref);
7976
- /* Check if there's a new display, new streams, or changes to existing ones */
8011
+ /* Check if there's a new display, new metadata, new streams, or changes to existing ones */
7977
8012
json_t *display = json_object_get(root, "display");
7978
8013
if(display) {
7979
8014
char *old_display = publisher->display;
7980
8015
char *new_display = g_strdup(json_string_value(display));
7981
8016
publisher->display = new_display;
7982
8017
g_free(old_display);
7983
8018
}
8019
+ json_t *metadata = json_object_get(root, "metadata");
8020
+ if(metadata) {
8021
+ json_t *old_metadata = publisher->metadata;
8022
+ json_t *new_metadata = json_deep_copy(metadata);
8023
+ publisher->metadata = new_metadata;
8024
+ if(old_metadata)
8025
+ json_decref(old_metadata);
8026
+ }
7984
8027
janus_mutex_lock(&publisher->streams_mutex);
7985
8028
janus_videoroom_publisher_stream *ps = NULL;
7986
8029
int changes = FALSE;
@@ -9447,6 +9490,7 @@ static void *janus_videoroom_handler(void *data) {
9447
9490
}
9448
9491
}
9449
9492
json_t *display = json_object_get(root, "display");
9493
+ json_t *metadata= json_object_get(root, "metadata");
9450
9494
const char *display_text = display ? json_string_value(display) : NULL;
9451
9495
guint64 user_id = 0;
9452
9496
char user_id_num[30], *user_id_str = NULL;
@@ -9524,6 +9568,7 @@ static void *janus_videoroom_handler(void *data) {
9524
9568
publisher->user_id = user_id;
9525
9569
publisher->user_id_str = user_id_str ? g_strdup(user_id_str) : NULL;
9526
9570
publisher->display = display_text ? g_strdup(display_text) : NULL;
9571
+ publisher->metadata = NULL;
9527
9572
publisher->recording_active = FALSE;
9528
9573
publisher->recording_base = NULL;
9529
9574
publisher->firefox = FALSE;
@@ -9629,6 +9674,11 @@ static void *janus_videoroom_handler(void *data) {
9629
9674
JANUS_LOG(LOG_VERB, "Setting user audio_level_average: %d (room %s, user %s)\n",
9630
9675
publisher->user_audio_level_average, publisher->room_id_str, publisher->user_id_str);
9631
9676
}
9677
+ if(metadata) {
9678
+ publisher->metadata = json_deep_copy(metadata);
9679
+ JANUS_LOG(LOG_VERB, "Setting metadata: (room %s, user %s)\n",
9680
+ publisher->room_id_str, publisher->user_id_str);
9681
+ }
9632
9682
/* Done */
9633
9683
janus_mutex_lock(&session->mutex);
9634
9684
/* Make sure the session has not been destroyed in the meanwhile */
@@ -9676,6 +9726,8 @@ static void *janus_videoroom_handler(void *data) {
9676
9726
json_object_set_new(pl, "id", string_ids ? json_string(p->user_id_str) : json_integer(p->user_id));
9677
9727
if(p->display)
9678
9728
json_object_set_new(pl, "display", json_string(p->display));
9729
+ if(p->metadata)
9730
+ json_object_set_new(pl, "metadata", json_deep_copy(p->metadata));
9679
9731
if(p->dummy)
9680
9732
json_object_set_new(pl, "dummy", json_true());
9681
9733
/* Add proper info on all the streams */
@@ -10527,6 +10579,7 @@ static void *janus_videoroom_handler(void *data) {
10527
10579
json_t *record = json_object_get(root, "record");
10528
10580
json_t *recfile = json_object_get(root, "filename");
10529
10581
json_t *display = json_object_get(root, "display");
10582
+ json_t *metadata = json_object_get(root, "metadata");
10530
10583
json_t *update = json_object_get(root, "update");
10531
10584
json_t *user_audio_active_packets = json_object_get(root, "audio_active_packets");
10532
10585
json_t *user_audio_level_average = json_object_get(root, "audio_level_average");
@@ -10822,6 +10875,26 @@ static void *janus_videoroom_handler(void *data) {
10822
10875
g_free(old_display);
10823
10876
janus_mutex_unlock(&participant->room->mutex);
10824
10877
}
10878
+ if(metadata) {
10879
+ janus_mutex_lock(&participant->room->mutex);
10880
+ json_t *old_metadata = participant->metadata;
10881
+ json_t *new_metadata = json_deep_copy(metadata);
10882
+ participant->metadata = new_metadata;
10883
+ if(old_metadata != NULL) {
10884
+ /* The metadata changed, notify this */
10885
+ json_t *metadata_event = json_object();
10886
+ json_object_set_new(metadata_event, "videoroom", json_string("event"));
10887
+ json_object_set_new(metadata_event, "id", string_ids ?
10888
+ json_string(participant->user_id_str) : json_integer(participant->user_id));
10889
+ json_object_set_new(metadata_event, "metadata", json_deep_copy(participant->metadata));
10890
+ if(participant->room && !g_atomic_int_get(&participant->room->destroyed)) {
10891
+ janus_videoroom_notify_participants(participant, metadata_event, FALSE);
10892
+ }
10893
+ json_decref(metadata_event);
10894
+ json_decref(old_metadata);
10895
+ }
10896
+ janus_mutex_unlock(&participant->room->mutex);
10897
+ }
10825
10898
/* Are we updating the description? */
10826
10899
if(descriptions != NULL && json_array_size(descriptions) > 0 && json_string_value(json_object_get(msg->jsep, "sdp")) == NULL) {
10827
10900
/* We only do this here if this is an SDP-less configure: in case
0 commit comments