Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions conf/janus.jcfg.sample.in
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,27 @@ media: {
#rtp_port_range_perhandle_override = false
}

# RTP-over-WebSocket support: a core media transport plugins can use to
# exchange binary RTP frames with external clients over WS/WSS (e.g., for
# headless agents joining an AudioBridge room via signaling, then streaming
# media on a separate socket). Disabled by default.
rtpws: {
#enable_rtp_ws = true
#port = 8190
#path = "/rtp-ws"
#public_url = "wss://media.example.com"
#secure = true
#cert_pem = "/path/to/certificate.pem"
#cert_key = "/path/to/key.pem"
#cert_pwd = "secret"
# When true, a client may connect without a "?sid=" query param and bind it
# later over the WebSocket with a {"type":"bind","sid":"..."} control frame
# (browser-first, so the client's connection picks the pod). The peerless
# connection first receives a {"type":"server_info","server-name":"..."}
# frame naming the pod. When false, only the legacy "?sid=" flow is accepted.
#allow_ws_bind = true
}

# NAT-related stuff: specifically, you can configure the STUN/TURN
# servers to use to gather candidates if the gateway is behind a NAT,
# and srflx/relay candidates are needed. In case STUN is not enough and
Expand Down
5 changes: 5 additions & 0 deletions conf/janus.plugin.audiobridge.jcfg.sample
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
# mjrs_dir = "/path/to/" (path to save the mjr files to)
# allow_rtp_participants = true|false (whether participants should be allowed to join
# via plain RTP as well, rather than just WebRTC, default=false)
# allow_ws_participants = true|false (whether participants should be allowed to join
# via WebSocket RTP media, default=false)
# groups = optional, non-hierarchical, array of groups to tag participants, for external forwarding purposes only
#
# The following lines are only needed if you want the mixed audio
Expand Down Expand Up @@ -73,6 +75,9 @@ general: {
# property below, then one will be automatically guessed from the system.
#local_ip = "1.2.3.4"

# WebSocket media for agents is configured in janus.jcfg (rtpws section).
# Rooms must set allow_ws_participants = true to accept media=websocket joins.

}

room-1234: {
Expand Down
6 changes: 6 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ janus_SOURCES = \
rtp.h \
rtpfwd.c \
rtpfwd.h \
rtpws.c \
rtpws.h \
rtpsrtp.h \
sctp.c \
sctp.h \
Expand Down Expand Up @@ -145,6 +147,10 @@ janus_LDADD = \
$(LIBCURL_LDFLAGS) $(LIBCURL_LIBS) \
$(NULL)

if ENABLE_WEBSOCKETS
janus_LDADD += $(WS_MANUAL_LIBS)
endif

dist_man1_MANS = janus.1

bin_PROGRAMS += janus-cfgconv
Expand Down
14 changes: 14 additions & 0 deletions src/ice.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,20 @@ gboolean janus_plugin_session_is_alive(janus_plugin_session *plugin_session) {
}
return (result != NULL);
}

void janus_plugin_session_touch(janus_plugin_session *plugin_session) {
if(!janus_plugin_session_is_alive(plugin_session))
return;
janus_ice_handle *handle = (janus_ice_handle *)plugin_session->gateway_handle;
if(!handle || !handle->session)
return;
janus_session *session = (janus_session *)handle->session;
if(!session || g_atomic_int_get(&session->destroyed) || g_atomic_int_get(&session->timedout))
return;
janus_mutex_lock(&session->mutex);
session->last_activity = janus_get_monotonic_time();
janus_mutex_unlock(&session->mutex);
}
static void janus_plugin_session_dereference(janus_plugin_session *plugin_session) {
if(plugin_session)
janus_refcount_decrease(&plugin_session->ref);
Expand Down
4 changes: 4 additions & 0 deletions src/ice.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ void janus_ice_notify_hangup(janus_ice_handle *handle, const char *reason);
* @param plugin_session The janus_plugin_session instance to validate
* @returns true if the plugin session is valid, false otherwise */
gboolean janus_plugin_session_is_alive(janus_plugin_session *plugin_session);
/*! \brief Refresh the Janus core session activity timer for a plugin session
* @note Used by plugins with non-signaling media (e.g. AudioBridge WebSocket RTP)
* so that \c session_timeout is not hit while RTP is flowing on rtpws */
void janus_plugin_session_touch(janus_plugin_session *plugin_session);


/*! \brief A helper struct for determining when to send NACKs */
Expand Down
48 changes: 48 additions & 0 deletions src/janus.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "ip-utils.h"
#include "rtcp.h"
#include "rtpfwd.h"
#include "rtpws.h"
#include "auth.h"
#include "record.h"
#include "events.h"
Expand Down Expand Up @@ -642,6 +643,7 @@ static janus_callbacks janus_handler_plugin =
.send_remb = janus_plugin_send_remb,
.close_pc = janus_plugin_close_pc,
.end_session = janus_plugin_end_session,
.touch_session = janus_plugin_session_touch,
.events_is_enabled = janus_events_is_enabled,
.notify_event = janus_plugin_notify_event,
.auth_is_signed = janus_plugin_auth_is_signed,
Expand Down Expand Up @@ -4527,6 +4529,7 @@ gint main(int argc, char *argv[]) {
janus_config_category *config_certs = janus_config_get_create(config, NULL, janus_config_type_category, "certificates");
janus_config_category *config_nat = janus_config_get_create(config, NULL, janus_config_type_category, "nat");
janus_config_category *config_media = janus_config_get_create(config, NULL, janus_config_type_category, "media");
janus_config_category *config_rtpws = janus_config_get_create(config, NULL, janus_config_type_category, "rtpws");
janus_config_category *config_transports = janus_config_get_create(config, NULL, janus_config_type_category, "transports");
janus_config_category *config_plugins = janus_config_get_create(config, NULL, janus_config_type_category, "plugins");
janus_config_category *config_events = janus_config_get_create(config, NULL, janus_config_type_category, "events");
Expand Down Expand Up @@ -5546,6 +5549,50 @@ gint main(int argc, char *argv[]) {
exit(1);
}

/* Initialize RTP-over-WebSocket support */
gboolean enable_rtp_ws = FALSE;
item = janus_config_get(config, config_rtpws, janus_config_type_item, "enable_rtp_ws");
if(item && item->value)
enable_rtp_ws = janus_is_true(item->value);
uint16_t rtp_ws_port = 8190;
item = janus_config_get(config, config_rtpws, janus_config_type_item, "port");
if(item && item->value)
janus_string_to_uint16(item->value, &rtp_ws_port);
const char *rtp_ws_path = "/rtp-ws";
item = janus_config_get(config, config_rtpws, janus_config_type_item, "path");
if(item && item->value)
rtp_ws_path = item->value;
const char *rtp_ws_public_url = "";
item = janus_config_get(config, config_rtpws, janus_config_type_item, "public_url");
if(item && item->value)
rtp_ws_public_url = item->value;
gboolean rtp_ws_secure = FALSE;
item = janus_config_get(config, config_rtpws, janus_config_type_item, "secure");
if(item && item->value)
rtp_ws_secure = janus_is_true(item->value);
const char *rtp_ws_cert_pem = NULL, *rtp_ws_cert_key = NULL, *rtp_ws_cert_pwd = NULL;
if(rtp_ws_secure) {
item = janus_config_get(config, config_rtpws, janus_config_type_item, "cert_pem");
if(item && item->value)
rtp_ws_cert_pem = item->value;
item = janus_config_get(config, config_rtpws, janus_config_type_item, "cert_key");
if(item && item->value)
rtp_ws_cert_key = item->value;
item = janus_config_get(config, config_rtpws, janus_config_type_item, "cert_pwd");
if(item && item->value)
rtp_ws_cert_pwd = item->value;
}
gboolean rtp_ws_allow_bind = FALSE;
item = janus_config_get(config, config_rtpws, janus_config_type_item, "allow_ws_bind");
if(item && item->value)
rtp_ws_allow_bind = janus_is_true(item->value);
if(janus_rtp_ws_init(enable_rtp_ws, rtp_ws_port, rtp_ws_path, rtp_ws_public_url,
rtp_ws_secure, rtp_ws_cert_pem, rtp_ws_cert_key, rtp_ws_cert_pwd,
server_name, rtp_ws_allow_bind) < 0) {
janus_options_destroy();
exit(1);
}

/* Sessions */
sessions = g_hash_table_new_full(g_int64_hash, g_int64_equal, (GDestroyNotify)g_free, NULL);
/* Start the sessions timeout watchdog */
Expand Down Expand Up @@ -6099,6 +6146,7 @@ gint main(int argc, char *argv[]) {
janus_sctp_deinit();
#endif
janus_rtp_forwarders_deinit();
janus_rtp_ws_deinit();
janus_auth_deinit();

JANUS_LOG(LOG_INFO, "Closing plugins:\n");
Expand Down
Loading
Loading