From 369ebc0a47c16db870a925714f19469b06a4bff0 Mon Sep 17 00:00:00 2001 From: mirkobrankovic82 Date: Tue, 30 Jun 2026 13:19:52 +0200 Subject: [PATCH] Add janus-room-allow-ws-participants channel variable for AudioBridge create Rooms created by mod_janus must set allow_ws_participants at create time so BFF can attach a WebSocket RTP leg to an existing call via rtpws. Co-authored-by: Cursor --- README.md | 1 + api.c | 10 +++++++++- api.h | 3 ++- mod_janus.c | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bb94f45..2cff8fb 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,7 @@ The following channel variables are defined: * janus-room-record - The value is specified in the *create* request to Janus and indicates that the room mix should be recorded (only applicable if janus-use-existing-room is false). The default value is not to record. * janus-room-record-file - This value specifies the file name to which the recording should be written. It is passed in the *create* request to Janus (only applicable if janus-use-existing-room is false and janus-room-record is true). If omitted the default filename will be used. * janus-room-pin - PIN that is used to validate a user entering the room. This value is used to set the PIN for a created room. +* janus-room-allow-ws-participants - When set, the *create* request sets Janus AudioBridge `allow_ws_participants=true`, allowing RTP-over-WebSocket joins later (e.g. BFF `ws-media-session`). Only applicable if janus-use-existing-room is false. Default is not to allow WebSocket media participants. * janus-user-token - The token for the user that should be passed in the *join* request. NB. no method is provided to set the allowed tokens in the *create* room request. Ignored when the server is configured with `hmac-secret`; a signed token is generated instead. * janus-hmac-token-ttl - Per-call lifetime (in seconds) for HMAC-signed tokens generated by mod_janus. Only has an effect when the server is configured with `hmac-secret`. Default is 7200 (2 hours), capped at 86400 (24 hours). Short-lived tokens used for session setup and long-poll requests use a fixed 300s TTL regardless of this value. * janus-user-record - Janus should generate a file containing the audio from the user only. It is specified in the *configure* request. The default value is not to record. diff --git a/api.c b/api.c index 45e3e7f..03ef46f 100644 --- a/api.c +++ b/api.c @@ -824,7 +824,8 @@ janus_id_t apiGetSenderId(server_t *pServer, const janus_id_t serverId, const ch janus_id_t apiCreateRoom(server_t *pServer, const janus_id_t serverId, const janus_id_t senderId, const janus_id_t roomId, const char *pDescription, - switch_bool_t record, const char *pRecordingFile, const char *pPin, const char *pRoomIdStr) { + switch_bool_t record, const char *pRecordingFile, const char *pPin, + switch_bool_t allow_ws_participants, const char *pRoomIdStr) { message_t request, *pResponse = NULL; janus_id_t result = 0; @@ -896,6 +897,13 @@ janus_id_t apiCreateRoom(server_t *pServer, const janus_id_t serverId, } } + if (allow_ws_participants) { + if (cJSON_AddBoolToObject(request.pJsonBody, "allow_ws_participants", cJSON_True) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot create boolean (body.allow_ws_participants)\n"); + goto done; + } + } + if (!(pJsonRequest = encode(request))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot create request\n"); goto done; diff --git a/api.h b/api.h index 0bdd293..88c222b 100644 --- a/api.h +++ b/api.h @@ -67,7 +67,8 @@ switch_status_t apiClaimServerId(server_t *pServer, janus_id_t serverId); janus_id_t apiGetSenderId(server_t *pServer, const janus_id_t serverId, const char *callId); janus_id_t apiCreateRoom(server_t *pServer, const janus_id_t serverId, const janus_id_t senderId, const janus_id_t roomId, const char *pDescription, - switch_bool_t record, const char *pRecordingFile, const char *pPin, const char *pRoomIdStr); + switch_bool_t record, const char *pRecordingFile, const char *pPin, + switch_bool_t allow_ws_participants, const char *pRoomIdStr); switch_status_t apiJoin(server_t *pServer, int hmacTokenTtl, const janus_id_t serverId, const janus_id_t senderId, const janus_id_t roomId, const char *pDisplay, const char *pPin, const char *pToken, const char *callId, const char *pRoomIdStr); diff --git a/mod_janus.c b/mod_janus.c index a4245b7..ec68d6a 100644 --- a/mod_janus.c +++ b/mod_janus.c @@ -797,6 +797,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session) switch_channel_var_true(channel, "janus-room-record"), switch_channel_get_variable(channel, "janus-room-record-file"), switch_channel_get_variable(channel, "janus-room-pin"), + switch_channel_var_true(channel, "janus-room-allow-ws-participants"), tech_pvt->pRoomIdStr) == 0) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to create room\n"); switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);