Skip to content

Commit

Permalink
Experimental IPv6 support and new Recorder/Playout plugin
Browse files Browse the repository at this point in the history
Added experimental IPv6 support for media;
Added a new plugin to record and then replay WebRTC sessions;
Several fixes on memory leaks, especially in plugins;
Some more fixes scattered across the project
  • Loading branch information
meetecho committed Oct 22, 2014
1 parent f37e9d1 commit 5fa9a30
Show file tree
Hide file tree
Showing 42 changed files with 2,740 additions and 101 deletions.
21 changes: 21 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ html_DATA = README.md
streamdir = $(datadir)/janus/streams
stream_DATA = $(NULL)

recordingsdir = $(datadir)/janus/recordings
recordings_DATA = $(NULL)

%.sample: %.sample.in
$(MKDIR_P) $(@D)
$(AM_V_GEN) sed -e "\
s|[@]confdir[@]|$(confdir)|;\
s|[@]certdir[@]|$(certdir)|;\
s|[@]plugindir[@]|$(plugindir)|;\
s|[@]recordingsdir[@]|$(recordingsdir)|;\
s|[@]streamdir[@]|$(streamdir)|" \
$< > $@ || rm $@

Expand Down Expand Up @@ -146,6 +150,23 @@ conf_DATA += conf/janus.plugin.echotest.cfg.sample
EXTRA_DIST += conf/janus.plugin.echotest.cfg.sample
endif

if ENABLE_PLUGIN_RECORDPLAY
plugin_LTLIBRARIES += plugins/libjanus_recordplay.la
plugins_libjanus_recordplay_la_SOURCES = plugins/janus_recordplay.c
plugins_libjanus_recordplay_la_CFLAGS = $(plugins_cflags)
plugins_libjanus_recordplay_la_LDFLAGS = $(plugins_ldflags)
plugins_libjanus_recordplay_la_LIBADD = $(plugins_libadd)
conf_DATA += conf/janus.plugin.recordplay.cfg.sample
recordings_DATA += \
plugins/recordings/1234.nfo \
plugins/recordings/rec-sample-audio.mjr \
plugins/recordings/rec-sample-video.mjr
EXTRA_DIST += \
conf/janus.plugin.recordplay.cfg.sample.in \
$(recordings_DATA)
CLEANFILES += conf/janus.plugin.recordplay.cfg.sample
endif

if ENABLE_PLUGIN_SIP
plugin_LTLIBRARIES += plugins/libjanus_sip.la
plugins_libjanus_sip_la_SOURCES = plugins/janus_sip.c
Expand Down
2 changes: 2 additions & 0 deletions apierror.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const char *janus_get_api_error(int error) {
return "Invalid element type";
case JANUS_ERROR_SESSION_CONFLICT:
return "Session ID already in use";
case JANUS_ERROR_UNEXPECTED_ANSWER:
return "Unexpected ANSWER (no OFFER)";
default:
return "Unknown error";
}
Expand Down
2 changes: 2 additions & 0 deletions apierror.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
#define JANUS_ERROR_INVALID_ELEMENT_TYPE 467
/*! \brief The ID provided to create a new session is already in use */
#define JANUS_ERROR_SESSION_CONFLICT 468
/*! \brief We got an ANSWER to an OFFER we never made */
#define JANUS_ERROR_UNEXPECTED_ANSWER 469


/*! \brief Helper method to get a string representation of an API error code
Expand Down
8 changes: 5 additions & 3 deletions conf/janus.cfg.sample.in
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ cert_pem = @certdir@/mycert.pem
cert_key = @certdir@/mycert.key


; Media-related stuff: right now, you can only configure the range of
; Media-related stuff: right now, you can only configure whether you want
; to enable IPv6 support (still WIP, so handle with care) and the range of
; ports to use for RTP and RTCP (by default, no range is envisaged).
; If you configure a range in the lines below, remember to uncomment the
; [media] category as well!
; If you change any setting in the lines below, remember to uncomment the
; [media] category as well, which is commented by default!
;[media]
;ipv6 = true
;rtp_port_range = 20000-40000


Expand Down
4 changes: 4 additions & 0 deletions conf/janus.plugin.recordplay.cfg.sample.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
; path = where to place recordings in the file system

[general]
path = @recordingsdir@
9 changes: 8 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ AC_CHECK_PROG([DOT],
AS_IF([test -z "$DOXYGEN" -o -z "$DOT"],
[
AS_IF([test "x$enable_docs" = "xyes"],
[AC_MSG_ERROR([doxygen or dot not found. Docs cannot be built.])])
[AC_MSG_NOTICE([doxygen or dot not found. Docs cannot be built.])])
])
AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" = "xyes"])

Expand Down Expand Up @@ -142,6 +142,12 @@ AC_ARG_ENABLE([plugin-echotest],
[],
[enable_plugin_echotest=yes])

AC_ARG_ENABLE([plugin-recordplay],
[AS_HELP_STRING([--disable-plugin-recordplay],
[Disable record&play plugin])],
[],
[enable_plugin_recordplay=yes])

AC_ARG_ENABLE([plugin-sip],
[AS_HELP_STRING([--disable-plugin-sip],
[Disable sip plugin])],
Expand Down Expand Up @@ -190,6 +196,7 @@ PKG_CHECK_MODULES([OGG],

AM_CONDITIONAL([ENABLE_PLUGIN_AUDIOBRIDGE], [test "x$enable_plugin_audiobridge" = "xyes"])
AM_CONDITIONAL([ENABLE_PLUGIN_ECHOTEST], [test "x$enable_plugin_echotest" = "xyes"])
AM_CONDITIONAL([ENABLE_PLUGIN_RECORDPLAY], [test "x$enable_plugin_recordplay" = "xyes"])
AM_CONDITIONAL([ENABLE_PLUGIN_SIP], [test "x$enable_plugin_sip" = "xyes"])
AM_CONDITIONAL([ENABLE_PLUGIN_STREAMING], [test "x$enable_plugin_streaming" = "xyes"])
AM_CONDITIONAL([ENABLE_PLUGIN_VIDEOCALL], [test "x$enable_plugin_videocall" = "xyes"])
Expand Down
4 changes: 3 additions & 1 deletion dtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ void janus_dtls_srtp_incoming_msg(janus_dtls_srtp *dtls, char *buf, uint16_t len
} else {
/* Something went wrong in either DTLS or SRTP... tell the plugin about it */
janus_dtls_callback(dtls->ssl, SSL_CB_ALERT, 0);
janus_flags_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_CLEANING);
}
}
}
Expand Down Expand Up @@ -509,7 +510,7 @@ void janus_dtls_callback(const SSL *ssl, int where, int ret) {
return;
}
janus_ice_handle *handle = stream->handle;
if(!stream) {
if(!handle) {
JANUS_LOG(LOG_ERR, "No ICE handle related to this alert...\n");
return;
}
Expand All @@ -519,6 +520,7 @@ void janus_dtls_callback(const SSL *ssl, int where, int ret) {
return;
}
JANUS_LOG(LOG_VERB, "[%"SCNu64"] DTLS alert received on stream %"SCNu16", closing...\n", handle->handle_id, stream->stream_id);
janus_flags_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_CLEANING);
if(!janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_ALERT)) {
janus_flags_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_ALERT);
if(handle->iceloop)
Expand Down
3 changes: 2 additions & 1 deletion html/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@
<li><a href="videomcutest.html">Video MCU</a></li>
<li><a href="audiobridgetest.html">Audio Conference</a></li>
<li><a href="voicemailtest.html">Voice Mail</a></li>
<li><a href="recordplaytest.html">Recorder/Playout</a></li>
<li><a href="screensharingtest.html">Screen Sharing</a></li>
<li class="divider"></li>
<li><a href="admin.html">Admin/Monitor</a></li>
<li class="active"><a href="admin.html">Admin/Monitor</a></li>
</ul>
</li>
<li><a href="docs">Documentation</a></li>
Expand Down
1 change: 1 addition & 0 deletions html/audiobridgetest.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<li><a href="videomcutest.html">Video MCU</a></li>
<li class="active"><a href="audiobridgetest.html">Audio Conference</a></li>
<li><a href="voicemailtest.html">Voice Mail</a></li>
<li><a href="recordplaytest.html">Recorder/Playout</a></li>
<li><a href="screensharingtest.html">Screen Sharing</a></li>
<li class="divider"></li>
<li><a href="admin.html">Admin/Monitor</a></li>
Expand Down
1 change: 1 addition & 0 deletions html/demos.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<li><a href="videomcutest.html">Video MCU</a></li>
<li><a href="audiobridgetest.html">Audio Conference</a></li>
<li><a href="voicemailtest.html">Voice Mail</a></li>
<li><a href="recordplaytest.html">Recorder/Playout</a></li>
<li><a href="screensharingtest.html">Screen Sharing</a></li>
<li class="divider"></li>
<li><a href="admin.html">Admin/Monitor</a></li>
Expand Down
1 change: 1 addition & 0 deletions html/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<li><a href="../videomcutest.html">Video MCU</a></li>
<li><a href="../audiobridgetest.html">Audio Conference</a></li>
<li><a href="../voicemailtest.html">Voice Mail</a></li>
<li><a href="../recordplaytest.html">Recorder/Playout</a></li>
<li><a href="../screensharingtest.html">Screen Sharing</a></li>
<li class="divider"></li>
<li><a href="../admin.html">Admin/Monitor</a></li>
Expand Down
1 change: 1 addition & 0 deletions html/echotest.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<li><a href="videomcutest.html">Video MCU</a></li>
<li><a href="audiobridgetest.html">Audio Conference</a></li>
<li><a href="voicemailtest.html">Voice Mail</a></li>
<li><a href="recordplaytest.html">Recorder/Playout</a></li>
<li><a href="screensharingtest.html">Screen Sharing</a></li>
<li class="divider"></li>
<li><a href="admin.html">Admin/Monitor</a></li>
Expand Down
1 change: 1 addition & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<li><a href="videomcutest.html">Video MCU</a></li>
<li><a href="audiobridgetest.html">Audio Conference</a></li>
<li><a href="voicemailtest.html">Voice Mail</a></li>
<li><a href="recordplaytest.html">Recorder/Playout</a></li>
<li><a href="screensharingtest.html">Screen Sharing</a></li>
<li class="divider"></li>
<li><a href="admin.html">Admin/Monitor</a></li>
Expand Down
10 changes: 9 additions & 1 deletion html/janus.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ function Janus(gatewayCallbacks) {
var iceServers = gatewayCallbacks.iceServers;
if(iceServers === undefined || iceServers === null)
iceServers = [{"url": "stun:stun.l.google.com:19302"}];
var ipv6Support = gatewayCallbacks.ipv6;
if(ipv6Support === undefined || ipv6Support === null)
ipv6Support = false;
var maxev = null;
if(gatewayCallbacks.max_poll_events !== undefined && gatewayCallbacks.max_poll_events !== null)
maxev = gatewayCallbacks.max_poll_events;
Expand Down Expand Up @@ -873,6 +876,11 @@ function Janus(gatewayCallbacks) {
var pc_constraints = {
"optional": [{"DtlsSrtpKeyAgreement": true}]
};
if(ipv6Support === true) {
// FIXME This is only supported in Chrome right now
// For support in Firefox track this: https://bugzilla.mozilla.org/show_bug.cgi?id=797262
pc_constraints.optional.push({"googIPv6":true});
}
Janus.log("Creating PeerConnection:");
Janus.log(pc_constraints);
config.pc = new RTCPeerConnection(pc_config, pc_constraints);
Expand Down Expand Up @@ -1168,7 +1176,7 @@ function Janus(gatewayCallbacks) {
}
}
// If we got here, we're not screensharing
if(media.video !== 'screen') {
if(media === null || media === undefined || media.video !== 'screen') {
getUserMedia(
{audio:isAudioSendEnabled(media), video:videoSupport},
function(stream) { pluginHandle.consentDialog(false); streamsDone(handleId, jsep, media, callbacks, stream); },
Expand Down
137 changes: 137 additions & 0 deletions html/recordplaytest.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Janus WebRTC Gateway: Recorder/Playout Demo</title>
<script type="text/javascript" src="jquery.min.js" ></script>
<script type="text/javascript" src="jquery.blockUI.js" ></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/bootbox.min.js"></script>
<script type="text/javascript" src="js/spin.min.js"></script>
<script type="text/javascript" src="janus.js" ></script>
<script type="text/javascript" src="recordplaytest.js"></script>
<link rel="stylesheet" href="css/cerulean/bootstrap.css" type="text/css"/>
<link rel="stylesheet" href="css/demo.css" type="text/css"/>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css"/>
<body>

<a href="https://github.com/meetecho/janus-gateway"><img style="position: absolute; top: 0; left: 0; border: 0; z-index: 1001;" src="https://s3.amazonaws.com/github/ribbons/forkme_left_darkblue_121621.png" alt="Fork me on GitHub"></a>

<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">Janus</a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Home</a></li>
<li class="dropdown active"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Demos <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="demos.html">Index</a></li>
<li class="divider"></li>
<li><a href="echotest.html">Echo Test</a></li>
<li><a href="streamingtest.html">Streaming</a></li>
<li><a href="videocalltest.html">Video Call</a></li>
<li><a href="siptest.html">SIP Gateway</a></li>
<li><a href="videomcutest.html">Video MCU</a></li>
<li><a href="audiobridgetest.html">Audio Conference</a></li>
<li><a href="voicemailtest.html">Voice Mail</a></li>
<li class="active"><a href="recordplaytest.html">Recorder/Playout</a></li>
<li><a href="screensharingtest.html">Screen Sharing</a></li>
<li class="divider"></li>
<li><a href="admin.html">Admin/Monitor</a></li>
</ul>
</li>
<li><a href="docs">Documentation</a></li>
</ul>
<div class="navbar-header navbar-right">
<ul class="nav navbar-nav">
<li><a href="http://groups.google.com/d/forum/meetecho-janus" class="navbar-link"><b>Discuss Janus</b></a></li>
<li><a href="http://www.meetecho.com" class="navbar-link"><img src="meetecho-logo-white.png"/> <b>Meetecho</b></a></li>
</ul>
</div>
</div>
</div>
</nav>

<div class="container">
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h1>Plugin Demo: Recorder/Playout
<button class="btn btn-default" 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 record a WebRTC session, and replay it later. You
can choose to either record a new session (e.g., a videomessage) or watch any of
the recordings that may be available (including those you made yourself).</p>
<p>This application makes use of the integrated recording feature in Janus,
specifically the individual recording of audio and video streams in <code>.mjr</code>
format: these individual recordings are then used for a live broadcasting
of the dumped RTP packets through a sendonly WebRTC PeerConnection
when you choose to replay them. To post-process these recordings in a
more usable format (e.g., <code>.webm</code> for video or <code>.opus</code>
for audio) you can make use of the <code>janus-pp-rec</code> tool that
is available as part of the Janus code.</p>
<p>Press the <code>Start</code> button above to launch the demo.</p>
</div>
</div>
</div>
<div class="container hide" id="recordplay">
<div id="demo">
<div class="col-md-6" id="controls">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Recorder/Playout</h3>
</div>
<div class="panel-body">
<div class="btn-group btn-group-sm">
<button class="btn btn-danger" disabled id="record">Record</button>
<button class="btn btn-success" disabled id="play">Play</button>
<button class="btn btn-primary" disabled id="list">Update <i id="update-list" class="fa fa-refresh"></i></button>
</div>
<br/>
<div class="btn-group btn-group-sm" style="width: 100%">
<div class="btn-group btn-group-sm" style="width: 100%">
<button id="recset" class="btn btn-default dropdown-toggle" data-toggle="dropdown" style="width: 100%">
Recordings list<span class="caret"></span>
</button>
<ul id="recslist" class="dropdown-menu" role="menu">
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6 hide" id="video">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><span id="videotitle">Remote Video</span> <button class="btn-xs btn-danger pull-right" id="stop">Stop</button></h3>
</div>
<div class="panel-body" id="videobox"></div>
</div>
</div>
</div>
</div>
</div>
</div>

<hr>
<div class="footer">
<p>Janus WebRTC Gateway &copy; <a href="http://www.meetecho.com">Meetecho</a> 2014</p>
</div>
</div>

</body>
</html>
Loading

0 comments on commit 5fa9a30

Please sign in to comment.