Skip to content

Commit

Permalink
Merge pull request #1 from meetecho/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
groupboard committed Mar 2, 2020
2 parents 29f3589 + 2d3c53e commit 27f9395
Show file tree
Hide file tree
Showing 34 changed files with 2,788 additions and 1,125 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Janus WebRTC Server
===================
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-brightgreen.svg)](COPYING)
[![Build Status](https://travis-ci.org/meetecho/janus-gateway.svg?branch=master)](https://travis-ci.org/meetecho/janus-gateway)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/13265/badge.svg)](https://scan.coverity.com/projects/meetecho-janus-gateway)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/janus-gateway.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:janus-gateway)
Expand Down
5 changes: 5 additions & 0 deletions conf/janus.jcfg.sample.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ general: {
#debug_timestamps = true # Whether to show a timestamp for each log line
#debug_colors = false # Whether colors should be disabled in the log
#debug_locks = true # Whether to enable debugging of locks (very verbose!)
#log_prefix = "[janus] " # In case you want log lines to be prefixed by some
# custom text, you can use the 'log_prefix' property.
# It supports terminal colors, meaning something like
# "[\x1b[32mjanus\x1b[0m] " would show a green "janus"
# string in square brackets (assuming debug_colors=true).

# This is what you configure if you want to launch Janus as a daemon
#daemonize = true # Whether Janus should run as a daemon
Expand Down
4 changes: 4 additions & 0 deletions conf/janus.plugin.audiobridge.jcfg.sample
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ general: {
# .wav --> .wav.tmp until the file is closed
#events = false # Whether events should be sent to event
# handlers (default=true)

# By default, integers are used as a unique ID for both rooms and participants.
# In case you want to use strings instead (e.g., a UUID), set string_ids to true.
#string_ids = true
}

room-1234: {
Expand Down
4 changes: 4 additions & 0 deletions conf/janus.plugin.streaming.jcfg.sample.in
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ general: {
# passed as port for a mountpoint (default=10000-60000)
#events = false # Whether events should be sent to event
# handlers (default=true)

# By default, integers are used as a unique ID for both mountpoints. In case
# you want to use strings instead (e.g., a UUID), set string_ids to true.
#string_ids = true
}

gstreamer-sample: {
Expand Down
4 changes: 4 additions & 0 deletions conf/janus.plugin.textroom.jcfg.sample
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ general: {
# plain (no indentation) or compact (no indentation and no spaces)
#events = false # Whether events should be sent to event
# handlers (default=true)

# By default, integers are used as a unique ID for rooms. In case you
# want to use strings instead (e.g., a UUID), set string_ids to true.
#string_ids = true
}

room-1234: {
Expand Down
4 changes: 4 additions & 0 deletions conf/janus.plugin.videoroom.jcfg.sample
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ general: {
# enforced for RTP forwarding requests too
#events = false # Whether events should be sent to event
# handlers (default=true)

# By default, integers are used as a unique ID for both rooms and participants.
# In case you want to use strings instead (e.g., a UUID), set string_ids to true.
#string_ids = true
}

room-1234: {
Expand Down
4 changes: 3 additions & 1 deletion debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
extern int janus_log_level;
extern gboolean janus_log_timestamps;
extern gboolean janus_log_colors;
extern char *janus_log_global_prefix;

/** @name Janus log colors
*/
Expand Down Expand Up @@ -100,7 +101,8 @@ do { \
snprintf(janus_log_src, sizeof(janus_log_src), \
"[%s:%s:%d] ", __FILE__, __FUNCTION__, __LINE__); \
} \
JANUS_PRINT("%s%s%s" format, \
JANUS_PRINT("%s%s%s%s" format, \
janus_log_global_prefix ? janus_log_global_prefix : "", \
janus_log_ts, \
janus_log_prefix[level | ((int)janus_log_colors << 3)], \
janus_log_src, \
Expand Down
3 changes: 2 additions & 1 deletion dtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ static void janus_dtls_notify_state_change(janus_dtls_srtp *dtls) {
json_object_set_new(info, "stream_id", json_integer(stream->stream_id));
json_object_set_new(info, "component_id", json_integer(component->component_id));
json_object_set_new(info, "retransmissions", json_integer(dtls->retransmissions));
janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, session->session_id, handle->handle_id, handle->opaque_id, info);
janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, JANUS_EVENT_SUBTYPE_WEBRTC_DTLS,
session->session_id, handle->handle_id, handle->opaque_id, info);
}

gboolean janus_is_dtls(char *buf) {
Expand Down
4 changes: 3 additions & 1 deletion events.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ gboolean janus_events_is_enabled(void) {
return eventsenabled;
}

void janus_events_notify_handlers(int type, guint64 session_id, ...) {
void janus_events_notify_handlers(int type, int subtype, guint64 session_id, ...) {
/* This method has a variable list of arguments, depending on the event type */
va_list args;
va_start(args, session_id);
Expand Down Expand Up @@ -133,6 +133,8 @@ void janus_events_notify_handlers(int type, guint64 session_id, ...) {
if(server != NULL)
json_object_set_new(event, "emitter", json_string(server));
json_object_set_new(event, "type", json_integer(type));
if(subtype > 0)
json_object_set_new(event, "subtype", json_integer(subtype));
json_object_set_new(event, "timestamp", json_integer(janus_get_real_time()));
if(type != JANUS_EVENT_TYPE_CORE && type != JANUS_EVENT_TYPE_EXTERNAL) {
/* Core and Admin API originated events don't have a session ID */
Expand Down
3 changes: 2 additions & 1 deletion events.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ gboolean janus_events_is_enabled(void);
* @note According to the type of event to notify, different arguments may
* be required and used in order to prepare the actual object to pass to handlers.
* @param[in] type Type of the event to notify
* @param[in] subtype Subtype of the event to notify, where applicable (0 if not)
* @param[in] session_id Janus session identifier this event refers to */
void janus_events_notify_handlers(int type, guint64 session_id, ...);
void janus_events_notify_handlers(int type, int subtype, guint64 session_id, ...);

/*! \brief Helper method to change the mask of events a handler is interested in
* @note Every time this is called, the mask is resetted, which means that to
Expand Down
41 changes: 41 additions & 0 deletions events/eventhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,47 @@ static janus_eventhandler janus_fake_eventhandler_plugin =
#define JANUS_EVENT_TYPE_ALL (0xffffffff)
///@}

/** @name Subtype of event types Janus could notify
* @details Some events, like JANUS_EVENT_TYPE_WEBRTC, don't have a uniform syntax:
* an event related to a new local candidate looks very different from an event
* related to, e.g., a selected pair or a DTLS state, all of which belong to the
* same category of \c webrtc type events. In order to simplify the management of
* events in strongly typed languages, events can contain a \c subtype property
* as well: this property is optional, because not all event types need this finer
* grain of detail. At the time of writing, subtypes are only available for
* JANUS_EVENT_TYPE_CORE ("core"), JANUS_EVENT_TYPE_WEBRTC ("webrtc") and
* JANUS_EVENT_TYPE_MEDIA ("media") types.
* @note Unlike the type, subtypes are not a mask: as a consequence, you cannot
* filter subtypes using the Event Handler plugin API, only types. Besides,
* there can be overlaps between subtypes related to
*/
///@{
/*! \brief No subtype */
#define JANUS_EVENT_SUBTYPE_NONE 0
/*! \brief Core event subtypes: startup */
#define JANUS_EVENT_SUBTYPE_CORE_STARTUP 1
/*! \brief Core event subtypes: shutdown */
#define JANUS_EVENT_SUBTYPE_CORE_SHUTDOWN 2
/*! \brief WebRTC event subtypes: ICE state */
#define JANUS_EVENT_SUBTYPE_WEBRTC_ICE 1
/*! \brief WebRTC event subtypes: local candidate */
#define JANUS_EVENT_SUBTYPE_WEBRTC_LCAND 2
/*! \brief WebRTC event subtypes: remote candidate */
#define JANUS_EVENT_SUBTYPE_WEBRTC_RCAND 3
/*! \brief WebRTC event subtypes: selected pair */
#define JANUS_EVENT_SUBTYPE_WEBRTC_PAIR 4
/*! \brief WebRTC event subtypes: DTLS state */
#define JANUS_EVENT_SUBTYPE_WEBRTC_DTLS 5
/*! \brief WebRTC event subtypes: PeerConnection state */
#define JANUS_EVENT_SUBTYPE_WEBRTC_STATE 6
/*! \brief Media event subtypes: media state */
#define JANUS_EVENT_SUBTYPE_MEDIA_STATE 1
/*! \brief Media event subtypes: slow link */
#define JANUS_EVENT_SUBTYPE_MEDIA_SLOWLINK 2
/*! \brief Media event subtypes: stats */
#define JANUS_EVENT_SUBTYPE_MEDIA_STATS 3
///@}

#define JANUS_EVENTHANDLER_INIT(...) { \
.init = NULL, \
.destroy = NULL, \
Expand Down
1 change: 1 addition & 0 deletions fuzzers/rtcp_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
int janus_log_level = LOG_NONE;
gboolean janus_log_timestamps = FALSE;
gboolean janus_log_colors = FALSE;
char *janus_log_global_prefix = NULL;
int lock_debug = 0;

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
Expand Down
1 change: 1 addition & 0 deletions fuzzers/rtp_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
int janus_log_level = LOG_NONE;
gboolean janus_log_timestamps = FALSE;
gboolean janus_log_colors = FALSE;
char *janus_log_global_prefix = NULL;
int lock_debug = 0;

/* This is to avoid linking with openSSL */
Expand Down
1 change: 1 addition & 0 deletions fuzzers/sdp_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
int janus_log_level = LOG_NONE;
gboolean janus_log_timestamps = FALSE;
gboolean janus_log_colors = FALSE;
char *janus_log_global_prefix = NULL;
int lock_debug = 0;
int refcount_debug = 0;

Expand Down
7 changes: 6 additions & 1 deletion html/janus.js
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@ function Janus(gatewayCallbacks) {
callbacks = callbacks || {};
// FIXME This method triggers a success even when we fail
callbacks.success = (typeof callbacks.success == "function") ? callbacks.success : Janus.noop;
callbacks.error = (typeof callbacks.error == "function") ? callbacks.error : Janus.noop;
var unload = (callbacks.unload === true);
var notifyDestroyed = true;
if(callbacks.notifyDestroyed !== undefined && callbacks.notifyDestroyed !== null)
Expand Down Expand Up @@ -1261,7 +1262,11 @@ function Janus(gatewayCallbacks) {
callbacks.success(pluginHandle);
},
error: function(textStatus, errorThrown) {
Janus.error(textStatus + ":", errorThrown); // FIXME
Janus.error(textStatus + ":", errorThrown); // FIXME
if(errorThrown === "")
callbacks.error(textStatus + ": Is the server down?");
else
callbacks.error(textStatus + ": " + errorThrown);
}
});
}
Expand Down
12 changes: 6 additions & 6 deletions html/siptest.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h1>Plugin Demo: SIP Gateway (Sofia)
<h1>Plugin Demo: SIP Gateway
<button class="btn btn-default" autocomplete="off" id="start">Start</button>
</h1>
</div>
<div class="container" id="details">
<div class="row">
<div class="col-md-12">
<h3>Demo details</h3>
<p>This demo shows how you can make use of the SIP plugin to interact with a
SIP Proxy (e.g., Kamailio) or PBX (e.g., Asterisk) in order to place or
receive calls to and from other SIP clients. Specifically, it uses the Sofia-based
SIP plugin. Notice the plugin only exchange SIP messages from within the plugin
itself: no SIP is done in JavaScript, except for references to SIP URIs.</p>
<p>This demo shows how you can make use of the SIP plugin to interact with a SIP
Proxy (e.g., Kamailio or OpenSIPS) or PBX (e.g., Asterisk or FreeSwitch) in order to
place or receive calls to and from other SIP clients. Specifically, it uses the
Sofia-based SIP plugin. Notice the plugin only exchange SIP messages from within the
plugin itself: no SIP is done in JavaScript, except for references to SIP URIs.</p>
<p>When started, the demo will allow you to insert a minimum set of information
required to REGISTER the web page as a SIP client at a SIP Proxy or PBX you specify.
This will allow you to call SIP URIs, or receive calls through the SIP Server itself.
Expand Down
31 changes: 20 additions & 11 deletions ice.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ static void janus_ice_notify_media(janus_ice_handle *handle, gboolean video, gbo
json_object_set_new(info, "receiving", up ? json_true() : json_false());
if(!up && no_media_timer > 1)
json_object_set_new(info, "seconds", json_integer(no_media_timer));
janus_events_notify_handlers(JANUS_EVENT_TYPE_MEDIA, session->session_id, handle->handle_id, handle->opaque_id, info);
janus_events_notify_handlers(JANUS_EVENT_TYPE_MEDIA, JANUS_EVENT_SUBTYPE_MEDIA_STATE,
session->session_id, handle->handle_id, handle->opaque_id, info);
}
}

Expand Down Expand Up @@ -690,7 +691,8 @@ void janus_ice_notify_hangup(janus_ice_handle *handle, const char *reason) {
json_object_set_new(info, "connection", json_string("hangup"));
if(reason != NULL)
json_object_set_new(info, "reason", json_string(reason));
janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, session->session_id, handle->handle_id, handle->opaque_id, info);
janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, JANUS_EVENT_SUBTYPE_WEBRTC_STATE,
session->session_id, handle->handle_id, handle->opaque_id, info);
}
}

Expand Down Expand Up @@ -1225,7 +1227,7 @@ gint janus_ice_handle_attach_plugin(void *core_session, janus_ice_handle *handle
}
/* Notify event handlers */
if(janus_events_is_enabled())
janus_events_notify_handlers(JANUS_EVENT_TYPE_HANDLE,
janus_events_notify_handlers(JANUS_EVENT_TYPE_HANDLE, JANUS_EVENT_SUBTYPE_NONE,
session->session_id, handle->handle_id, "attached", plugin->get_package(), handle->opaque_id);
return 0;
}
Expand Down Expand Up @@ -1633,7 +1635,8 @@ janus_slow_link_update(janus_ice_component *component, janus_ice_handle *handle,
json_object_set_new(info, "media", json_string(video ? "video" : "audio"));
json_object_set_new(info, "slow_link", json_string(uplink ? "uplink" : "downlink"));
json_object_set_new(info, "lost_lastsec", json_integer(sl_lost_recently));
janus_events_notify_handlers(JANUS_EVENT_TYPE_MEDIA, session->session_id, handle->handle_id, handle->opaque_id, info);
janus_events_notify_handlers(JANUS_EVENT_TYPE_MEDIA, JANUS_EVENT_SUBTYPE_MEDIA_SLOWLINK,
session->session_id, handle->handle_id, handle->opaque_id, info);
}
}
}
Expand Down Expand Up @@ -1757,7 +1760,8 @@ static void janus_ice_cb_component_state_changed(NiceAgent *agent, guint stream_
json_object_set_new(info, "ice", json_string(janus_get_ice_state_name(state)));
json_object_set_new(info, "stream_id", json_integer(stream_id));
json_object_set_new(info, "component_id", json_integer(component_id));
janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, session->session_id, handle->handle_id, handle->opaque_id, info);
janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, JANUS_EVENT_SUBTYPE_WEBRTC_ICE,
session->session_id, handle->handle_id, handle->opaque_id, info);
}
/* FIXME Even in case the state is 'connected', we wait for the 'new-selected-pair' callback to do anything */
if(state == NICE_COMPONENT_STATE_FAILED) {
Expand Down Expand Up @@ -1889,7 +1893,8 @@ static void janus_ice_cb_new_selected_pair (NiceAgent *agent, guint stream_id, g
#endif
json_object_set_new(info, "stream_id", json_integer(stream_id));
json_object_set_new(info, "component_id", json_integer(component_id));
janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, session->session_id, handle->handle_id, handle->opaque_id, info);
janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, JANUS_EVENT_SUBTYPE_WEBRTC_PAIR,
session->session_id, handle->handle_id, handle->opaque_id, info);
}
/* Have we been here before? (might happen, when trickling) */
if(component->component_connected > 0)
Expand Down Expand Up @@ -3083,7 +3088,8 @@ static int janus_ice_candidate_to_string(janus_ice_handle *handle, NiceCandidate
json_object_set_new(info, "local-candidate", json_string(buffer));
json_object_set_new(info, "stream_id", json_integer(stream->stream_id));
json_object_set_new(info, "component_id", json_integer(component->component_id));
janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, session->session_id, handle->handle_id, handle->opaque_id, info);
janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, JANUS_EVENT_SUBTYPE_WEBRTC_LCAND,
session->session_id, handle->handle_id, handle->opaque_id, info);
}
}
return 0;
Expand Down Expand Up @@ -3833,7 +3839,8 @@ static gboolean janus_ice_outgoing_stats_handle(gpointer user_data) {
json_object_set_new(info, "nacks-sent", json_integer(stream->component->out_stats.audio.nacks));
json_object_set_new(info, "retransmissions-received", json_integer(stream->audio_rtcp_ctx->retransmitted));
}
janus_events_notify_handlers(JANUS_EVENT_TYPE_MEDIA, session->session_id, handle->handle_id, handle->opaque_id, info);
janus_events_notify_handlers(JANUS_EVENT_TYPE_MEDIA, JANUS_EVENT_SUBTYPE_MEDIA_STATS,
session->session_id, handle->handle_id, handle->opaque_id, info);
}
}
/* Do the same for video */
Expand Down Expand Up @@ -3870,7 +3877,8 @@ static gboolean janus_ice_outgoing_stats_handle(gpointer user_data) {
json_object_set_new(info, "nacks-sent", json_integer(stream->component->out_stats.video[vindex].nacks));
json_object_set_new(info, "retransmissions-received", json_integer(stream->video_rtcp_ctx[vindex]->retransmitted));
}
janus_events_notify_handlers(JANUS_EVENT_TYPE_MEDIA, session->session_id, handle->handle_id, handle->opaque_id, info);
janus_events_notify_handlers(JANUS_EVENT_TYPE_MEDIA, JANUS_EVENT_SUBTYPE_MEDIA_STATS,
session->session_id, handle->handle_id, handle->opaque_id, info);
}
}
}
Expand Down Expand Up @@ -3975,7 +3983,7 @@ static gboolean janus_ice_outgoing_traffic_handle(janus_ice_handle *handle, janu
janus_session_notify_event(session, event);
/* Notify event handlers as well */
if(janus_events_is_enabled())
janus_events_notify_handlers(JANUS_EVENT_TYPE_HANDLE,
janus_events_notify_handlers(JANUS_EVENT_TYPE_HANDLE, JANUS_EVENT_SUBTYPE_NONE,
session->session_id, handle->handle_id, "detached",
plugin ? plugin->get_package() : NULL, handle->opaque_id);
return G_SOURCE_REMOVE;
Expand Down Expand Up @@ -4678,6 +4686,7 @@ void janus_ice_dtls_handshake_done(janus_ice_handle *handle, janus_ice_component
if(janus_events_is_enabled()) {
json_t *info = json_object();
json_object_set_new(info, "connection", json_string("webrtcup"));
janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, session->session_id, handle->handle_id, handle->opaque_id, info);
janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, JANUS_EVENT_SUBTYPE_WEBRTC_STATE,
session->session_id, handle->handle_id, handle->opaque_id, info);
}
}
1 change: 1 addition & 0 deletions janus-cfgconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
int janus_log_level = 4;
gboolean janus_log_timestamps = FALSE;
gboolean janus_log_colors = TRUE;
char *janus_log_global_prefix = NULL;
int lock_debug = 0;

/* Main Code */
Expand Down
Loading

0 comments on commit 27f9395

Please sign in to comment.