Created
December 10, 2015 13:14
-
-
Save dotannn/72a83cac2eb42f74da37 to your computer and use it in GitHub Desktop.
Janus Configs (same in both connections)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var iceServers = [ | |
{url:'stun:stun.services.mozilla.com:3478'}]; | |
janus = new Janus( | |
{ | |
server: server, | |
iceServers:iceServers, | |
success: function() { | |
// Attach to streaming plugin | |
janus.attach( | |
{ | |
plugin: "janus.plugin.streaming", | |
success: function(pluginHandle) { | |
streaming = pluginHandle; | |
updateStreamsList(); | |
}, | |
error: function(error) { | |
sAlert.error("Error attaching plugin... " + error); | |
}, | |
onmessage: function(msg, jsep) { | |
var result = msg["result"]; | |
if(result !== null && result !== undefined) { | |
if(result["status"] !== undefined && result["status"] !== null) { | |
var status = result["status"]; | |
// TODO change into callbacks | |
if(status === 'starting') | |
$('#status').removeClass('hide').text("Starting, please wait...").show(); | |
else if(status === 'started') | |
$('#status').removeClass('hide').text("Started").show(); | |
else if(status === 'stopped') | |
stopStream(); | |
} | |
} else if(msg["error"] !== undefined && msg["error"] !== null) { | |
sAlert.error(msg["error"]); | |
stopStream(); | |
return; | |
} | |
if(jsep !== undefined && jsep !== null) { | |
// Answer - Handling SDP | |
streaming.createAnswer( | |
{ | |
jsep: jsep, | |
media: { audioSend: false, videoSend: false }, // We want recvonly audio/video | |
success: function(jsep) { | |
//Got SDP | |
var body = { "request": "start" }; | |
streaming.send({"message": body, "jsep": jsep}); | |
}, | |
error: function(error) { | |
sAlert.error("WebRTC error... " + JSON.stringify(error)); | |
} | |
}); | |
} | |
}, | |
onremotestream: function(stream) { | |
//log.info("Janus Got a remote stream"); | |
// TODO change into callbacks | |
if($('#remotevideo').length === 0) { | |
$('#stream').append('<video controls class="rounded centered hide" id="remotevideo" width="100%" height="" autoplay/>'); | |
} | |
// TODO change into callbacks | |
// Show the stream and hide the spinner when we get a playing event | |
$("#remotevideo").bind("playing", function () { | |
$('#videoplaceholder').hide(); | |
$('#remotevideo').removeClass('hide'); | |
if(spinner !== null && spinner !== undefined) { | |
spinner.stop(); | |
}else{ | |
var target = document.getElementById('streams'); | |
spinner = new Spinner({top:'150px', position:'relative'}).spin(target); | |
} | |
}); | |
attachMediaStream($('#remotevideo').get(0), stream); | |
}, | |
oncleanup: function() { | |
// TODO change into callbacks | |
log.info('Got a cleanup notification :::'); | |
$('#remotevideo').remove(); | |
$('#videoplaceholder').show(); | |
} | |
}); | |
}, | |
error: function(error) { | |
sAlert.error(error, function() {}); | |
}, | |
destroyed: function() { | |
log.info('destroyed'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; General configuration: folders where the configuration and the plugins | |
; can be found, default interface to use, debug/logging level and, if | |
; needed, shared apisecret between application(s) and Janus. | |
[general] | |
configs_folder = /opt/janus/etc/janus ; Configuration files folder | |
plugins_folder = /opt/janus/lib/janus/plugins ; Plugins folder | |
;interface = 1.2.3.4 ; Interface to use (will be used in SDP) | |
debug_level = 4 ; Debug/logging level, valid values are 0-7 | |
;debug_timestamps = yes ; Whether to show a timestamp for each log line | |
;debug_colors = no ; Whether colors should be disabled in the log | |
;api_secret = janusrocks ; String that all Janus requests must contain | |
; to be accepted/authorized by the Janus core. | |
; Useful if you're wrapping all Janus API requests | |
; in your servers (that is, not in the browser, | |
; where you do the things your way) and you | |
; don't want other application to mess with | |
; this Janus instance. | |
;token_auth = yes ; Enable a token based authentication | |
; mechanism to force users to always provide | |
; a valid token in all requests. Useful if | |
; you want to authenticate requests from web | |
; users. For this to work, the Admin API MUST | |
; be enabled, as tokens are added and removed | |
; through messages sent there. | |
; Web server and WebSockets stuff: whether either one should be enabled, | |
; which ports they should use, whether security should be handled directly | |
; or demanded to an external application (e.g., web frontend) and what | |
; should be the base path for the Janus API protocol (plain HTTP only). | |
; You can also specify the threading model to use for the HTTP webserver: | |
; by default this is 'unlimited' (which means a thread per connection, as | |
; specified by the libmicrohttpd documentation), using a number will make | |
; use of a thread pool instead. Since long polls are involved, make sure | |
; you choose a value that doesn't keep new connections waiting. | |
; Please beware that the WebSockets server will only be available if you | |
; built Janus compiling support for it. | |
[webserver] | |
base_path = /janus ; Base path to bind to in the web server (plain HTTP only) | |
threads = unlimited ; unlimited=thread per connection, number=thread pool | |
http = yes ; Whether to enable the plain HTTP interface | |
port = 8088 ; Web server HTTP port | |
https = no ; Whether to enable HTTPS (default=no) | |
;secure_port = 8889 ; Web server HTTPS port, if enabled | |
ws = yes ; Whether to enable the WebSockets interface | |
ws_port = 8188 ; WebSockets server port | |
ws_ssl = no ; Whether to enable secure WebSockets | |
;ws_secure_port = 8989; ; WebSockets server secure port, if enabled | |
; Recent versions of Janus now also support RabbitMQ based messaging as | |
; an alternative "transport" for API requests, responses and notifications. | |
; This is only useful when you're wrapping Janus requests in your server | |
; application, and handling the communication with clients your own way. | |
; At the moment, only a single "application" can be handled at the same | |
; time, meaning that Janus won't implement multiple queues to handle | |
; multiple concurrent "application servers" taking advantage of its | |
; features. Support for this is planned, though (e.g., through some kind | |
; of negotiation to create queues on the fly). Right now, you can only | |
; configure the address of the RabbitMQ server to use, and the queues to | |
; make use of to receive (to-janus) and send (from-janus) messages | |
; from/to an external application. If you're using the same RabbitMQ | |
; server instance for multiple Janus instances, make sure you configure | |
; different queues for each of them (e.g., from-janus-1/to-janus-1 and | |
; from-janus-2/to-janus-2), or otherwise both the instances will make | |
; use of the same queues and messages will get lost. The integration | |
; is disabled by default, so set enable=yes if you want to use it. | |
[rabbitmq] | |
enable = no ; Whether the support must be enabled | |
host = localhost ; The address of the RabbitMQ server | |
;port = 5672 ; The port of the RabbitMQ server (5672 by default) | |
to_janus = to-janus ; Name of the queue for incoming messages | |
from_janus = from-janus ; Name of the queue for outgoing messages | |
; Janus can also expose an admin/monitor endpoint, to allow you to check | |
; which sessions are up, which handles they're managing, their current | |
; status and so on. This provides a useful aid when debugging potential | |
; issues in Janus. The configuration is pretty much the same as the one | |
; already presented above for the webserver stuff, as the API is very | |
; similar: choose the base bath for the admin/monitor endpoint (/admin | |
; by default), ports, threading model, etc. Besides, you can specify | |
; a secret that must be provided in all requests as a crude form of | |
; authorization mechanism, and partial or full source IPs if you want to | |
; limit access basing on IP addresses. For security reasons, this | |
; endpoint is disabled by default, enable it by setting admin_http=yes. | |
[admin] | |
admin_base_path = /admin ; Base path to bind to in the admin/monitor web server (plain HTTP only) | |
admin_threads = unlimited ; unlimited=thread per connection, number=thread pool | |
admin_http = no ; Whether to enable the plain HTTP interface | |
admin_port = 7088 ; Admin/monitor web server HTTP port | |
admin_https = no ; Whether to enable HTTPS (default=no) | |
;admin_secure_port = 7889 ; Admin/monitor web server HTTPS port, if enabled | |
admin_secret = janusoverlord ; String that all Janus requests must contain | |
; to be accepted/authorized by the admin/monitor. | |
;admin_acl = 127.,192.168.0. ; Only allow requests coming from this comma separated list of addresses | |
; Certificate and key to use for DTLS and/or HTTPS/WSS. | |
[certificates] | |
cert_pem = /opt/janus/share/janus/certs/mycert.pem | |
cert_key = /opt/janus/share/janus/certs/mycert.key | |
; Media-related stuff: right now, you can only configure whether you want | |
; to enable IPv6 support (still WIP, so handle with care), the maximum size | |
; of the NACK queue for retransmissions per handle the range of ports to | |
; use for RTP and RTCP (by default, no range is envisaged) and the | |
; starting MTU for DTLS (1472 by default, it adapts automatically). | |
[media] | |
ipv6 = true | |
max_nack_queue = 300 | |
rtp_port_range = 20000-40000 | |
dtls_mtu = 1200 | |
; 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 | |
; this is needed (it shouldn't), you can also configure Janus to use a | |
; TURN server; please notice that this does NOT refer to TURN usage in | |
; browsers, but in the gathering of relay candidates by Janus itself, | |
; e.g., if you want to limit the ports used by a Janus instance on a | |
; private machine. Furthermore, you can choose whether Janus should be | |
; configured to work in ICE-Lite mode (by default it doesn't). Finally, | |
; you can also enable ICE-TCP support (beware that it currently *only* | |
; works if you enable ICE Lite as well), choose which interfaces should | |
; be used for gathering candidates, and enable or disable the | |
; internal libnice debugging, if needed. | |
[nat] | |
stun_server = stun.services.mozilla.com | |
stun_port = 3478 | |
nice_debug = true | |
;ice_lite = true | |
;ice_tcp = true | |
; In case you're deploying Janus on a server which is configured with | |
; a 1:1 NAT (e.g., Amazon EC2), you might want to also specify the public | |
; address of the machine using the setting below. This will result in | |
; all host candidates (which normally have a private IP address) to | |
; be rewritten with the public address provided in the settings. As | |
; such, use the option with caution and only if you know what you're doing. | |
;nat_1_1_mapping = 1.2.3.4 | |
; You can configure a TURN server in two different ways: specifying a | |
; statically configured TURN server, and thus provide the address of the | |
; TURN server, the transport (udp/tcp/tls) to use, and a set of valid | |
; credentials to authenticate... | |
;turn_server = numb.viagenie.ca | |
;turn_port = 80 | |
;turn_type = tcp | |
;turn_user = muazkh | |
;turn_pwd = webrtc@live.com | |
; ... or you can make use of the TURN REST API to get info on one or more | |
; TURN services dynamically. This makes use of the proposed standard of | |
; such an API (https://tools.ietf.org/html/draft-uberti-behave-turn-rest-00) | |
; which is currently available in both rfc5766-turn-server and coturn. | |
; You enable this by specifying the address of your TURN REST API backend | |
; and, if required, the API key Janus must provide. | |
;turn_rest_api = http://yourbackend.com/path/to/api | |
;turn_rest_api_key = anyapikeyyoumayhaveset | |
; You can also choose which interfaces should be explicitly used by the | |
; gateway for the purpose of ICE candidates gathering, thus excluding | |
; others that may be available. To do so, use the 'ice_enforce_list' | |
; setting and pass it a comma-separated list of interfaces or IP addresses | |
; to enforce. This is especially useful if the server hosting the gateway | |
; has several interfaces, and you only want a subset to be used. Any of | |
; the following examples are valid: | |
; ice_enforce_list = eth0 | |
; ice_enforce_list = eth0,eth1 | |
; ice_enforce_list = eth0,192.168. | |
; ice_enforce_list = eth0,192.168.0.1 | |
; By default, no interface is enforced, meaning Janus will try to use them all. | |
;ice_enforce_list = eth0 | |
; In case you don't want to specify specific interfaces to use, but would | |
; rather tell Janus to use all the available interfaces except some that | |
; you don't want to involve, you can also choose which interfaces or IP | |
; addresses should be excluded and ignored by the gateway for the purpose | |
; of ICE candidates gathering. To do so, use the 'ice_ignore_list' setting | |
; and pass it a comma-separated list of interfaces or IP addresses to | |
; ignore. This is especially useful if the server hosting the gateway | |
; has several interfaces you already know will not be used or will simply | |
; always slow down ICE (e.g., virtual interfaces created by VMware). | |
; Partial strings are supported, which means that any of the following | |
; examples are valid: | |
; ice_ignore_list = vmnet8,192.168.0.1,10.0.0.1 | |
; ice_ignore_list = vmnet,192.168. | |
; Just beware that the ICE ignore list is not used if an enforce list | |
; has been configured. By default, Janus ignores all interfaces whose | |
; name starts with 'vmnet', to skip VMware interfaces: | |
ice_ignore_list = vmnet | |
; Finally, you can choose which of the available plugins should be | |
; enabled or not. Use the 'disable' directive to prevent Janus from | |
; loading one or more plugins: use a comma separated list of plugin file | |
; names to identify the plugins to disable. By default all available | |
; plugins are enabled and loaded at startup. | |
[plugins] | |
; disable = libjanus_voicemail.so,libjanus_recordplay.so |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment