Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
meetecho committed Feb 11, 2014
0 parents commit be35fac
Show file tree
Hide file tree
Showing 89 changed files with 39,307 additions and 0 deletions.
661 changes: 661 additions & 0 deletions COPYING

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CC = gcc
STUFF = $(shell pkg-config --cflags glib-2.0 nice libmicrohttpd jansson libssl libcrypto sofia-sip-ua ini_config) -ldl -D_GNU_SOURCE
LIBS = $(shell pkg-config --libs glib-2.0 nice libmicrohttpd jansson libssl libcrypto sofia-sip-ua ini_config) -ldl -lsrtp -D_GNU_SOURCE
OPTS = -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wunused #-Werror #-O2
GDB = -g -ggdb #-gstabs
OBJS=janus.o cmdline.o config.o apierror.o rtcp.o dtls.o ice.o sdp.o

all: janus cmdline plugins

.PHONY: plugins docs

plugins:
$(MAKE) -C plugins

docs:
$(MAKE) -C docs

cmdline:
rm -f cmdline.o
gengetopt --set-package="janus" --set-version="0.0.1" < janus.ggo

%.o: %.c
$(CC) $(STUFF) -fPIC $(GDB) -c $< -o $@ $(OPTS)

janus : $(OBJS)
$(CC) $(GDB) -o janus $(OBJS) $(LIBS)

clean :
rm -f janus *.o plugins/*.o plugins/*.so
rm -rf docs/html
151 changes: 151 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
Janus WebRTC Gateway
====================

Janus is an open source, general purpose, WebRTC gateway. This version
of the gateway can only be installed on Linux systems: next versions
will take into account cross compilation on different environments.

For some online demos and documentations, make sure you pay the
[project website](http://janus.conf.meetecho.com/) a visit!

##Dependencies
To install it, you'll need to satisfy the following dependencies:

* [libmicrohttpd](http://www.gnu.org/software/libmicrohttpd/)
* [libini-config](https://fedorahosted.org/sssd/) (INI configurations)
* [Jansson](http://www.digip.org/jansson/)
* [libnice](http://nice.freedesktop.org/wiki/)
* [OpenSSL](http://www.openssl.org/) (at least v1.0.1e)
* [libsrtp](http://srtp.sourceforge.net/srtp.html)
* [Sofia-SIP](http://sofia-sip.sourceforge.net/)

A couple of plugins depend on a few more libraries:

* [libopus](http://opus-codec.org/) (only needed for the bridge plugin)
* [libogg](http://xiph.org/ogg/) (only needed for the voicemail plugin)

Additionally, you'll need the following libraries and tools:

* [GLib](http://library.gnome.org/devel/glib/)
* [pkg-config](http://www.freedesktop.org/wiki/Software/pkg-config/)
* [gengetopt](http://www.gnu.org/software/gengetopt/)

All of those libraries are usually available on most of the most common
distributions. Installing these libraries on a recent Fedora, for
instance, is very simple:

yum install libmicrohttpd-devel jansson-devel libnice-devel \
openssl-devel libsrtp-devel sofia-sip-devel glib-devel \
opus-devel libogg-devel libini_config-devel pkg-config gengetopt

On Ubuntu or Debian, it would require something like this:

aptitude install libmicrohttpd-dev libjansson-dev libnice-dev \
libssl-dev libsrtp-dev libsofia-sip-ua-dev libglib2.0-dev \
libogg-dev libini-config-dev libcollection-dev pkg-config gengetopt

* *Note:* apparently libopus is not available on Ubuntu: you'll have to
install it manually.

Should you be interested in building the gateway documentation as well,
you'll need an additional component installed too:

* [Doxygen](http://www.doxygen.org)
* [Graphviz](http://www.graphviz.org/)

On Fedora:

yum install doxygen graphviz

On Ubuntu/Debian:

aptitude install doxygen graphviz


##Compile
Once you have installed all the dependencies, just use:

sh install.sh

to start the whole compilation process. The script will try to check
whether you have all the dependencies installed, and then issue a 'make'
for you to start compiling. If Doxygen and graphviz are available, it
will also build the documentation for you as well.

If you prefer doing this manually, a simple

make

will start compiling the gateway. To build the documentation as well:

make docs

will create the documentation in the docs/html subfolder.


##Configure and start
To start the gateway, you can use the janus executable. There are several
things you can configure, either in a configuration file:

./conf/janus.cfg

or on the command line:

./janus --help

janus 0.0.1

Usage: janus [OPTIONS]...

-h, --help Print help and exit
-V, --version Print version and exit
-i, --interface=ipaddress Interface to use (will be the public IP)
-p, --port=portnumber Web server HTTP port (default=8088)
-s, --secure-port=portnumber Web server HTTPS port (default=no HTTPS)
-n, --no-http Disable insecure HTTP web server (default=off)
-b, --base-path=basepath Base path to bind to in the web server
(default=/janus)
-P, --plugins-folder=path Plugins folder (default=./plugins)
-C, --config=path Configuration file to use
-F, --configs-folder=path Configuration files folder (default=./conf)
-c, --cert-pem=filename HTTPS/DTLS certificate
-k, --cert-key=filename HTTPS/DTLS certificate key
-S, --stun-server=filename STUN server(:port) to use, if needed (e.g.,
gateway behind NAT, default=none)

Options passed through the command line have the precedence on those
specified in the configuration file. To start the gateway, simply run:

./janus

This will start the gateway, and have it look at the configuration file.
By default, only an HTTP webserver is started. To enable HTTPS support,
edit the configuration file accordingly or use the command line. The
webserver will make use of the same certificates provided for DTLS. You
can also change the base path that the webserver uses: by default this
is /janus, but you can change it to anything you want and with any nesting
you want (e.g., /mypath, /my/path, or /my/really/nested/path). This is
done to allow you to more easily customize rules in any frontend you
may have (e.g., Apache in front of your services).

In the absence of a configuration file, the only mandatory options to
specify in the command line are the ones related to the DTLS certificate.
A default certificate is provided with this package in the certs folder,
which you can use launching the executable with these parameters:

./janus -c certs/mycert.pem -k certs/mycert.key

At this point, the gateway will be listening on the 8088 port (or whatever
you changed that to) of your machine. To test whether it's working
correctly, you can use the demos provided with this package in the html
folder: these are exactly the same demos available online on the
[project website](http://janus.conf.meetecho.com/). Just copy the file
it contains in a webserver, and open the index.html page in either
Chrome or Firefox. A list of demo pages exploiting the different plugins
will be available.


##Help us!
Any thought, feedback or (hopefully not!) insult is welcome!

Developed by [@meetecho](https://github.com/meetecho)
43 changes: 43 additions & 0 deletions apierror.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "apierror.h"

const char *janus_get_api_error(int error) {
switch(error) {
case JANUS_OK:
return "Success";
case JANUS_ERROR_UNKNOWN:
return "Unknown error";
case JANUS_ERROR_USE_POST:
return "Use POST";
case JANUS_ERROR_MISSING_REQUEST:
return "Missing request";
case JANUS_ERROR_UNKNOWN_REQUEST:
return "Unknown request";
case JANUS_ERROR_INVALID_JSON:
return "Invalid JSON";
case JANUS_ERROR_INVALID_JSON_OBJECT:
return "Invalid JSON Object";
case JANUS_ERROR_MISSING_MANDATORY_ELEMENT:
return "Missing mandatory element";
case JANUS_ERROR_INVALID_REQUEST_PATH:
return "Invalid path for this request";
case JANUS_ERROR_SESSION_NOT_FOUND:
return "Session not found";
case JANUS_ERROR_HANDLE_NOT_FOUND:
return "Handle not found";
case JANUS_ERROR_PLUGIN_NOT_FOUND:
return "Plugin not found";
case JANUS_ERROR_PLUGIN_ATTACH:
return "Error attaching plugin";
case JANUS_ERROR_PLUGIN_MESSAGE:
return "Error sending message to plugin";
case JANUS_ERROR_PLUGIN_DETACH:
return "Error detaching from plugin";
case JANUS_ERROR_JSEP_UNKNOWN_TYPE:
return "Unsupported JSEP type";
case JANUS_ERROR_JSEP_INVALID_SDP:
return "Invalid SDP";
default:
return "Unknown error";
}
return "Unknown error";
}
59 changes: 59 additions & 0 deletions apierror.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*! \file apierror.h
* \author Lorenzo Miniero <lorenzo@meetecho.com>
* \copyright GNU Affero General Public License v3
* \brief Janus API errors definition
* \details Definition of all the API errors that may occur when invoking
* the Janus web-based JSON API.
* \todo This code still needs proper hooks in the JavaScript libraries that use the interface.
*
* \ingroup core
* \ref core
*/

#ifndef _JANUS_API_ERROR_H
#define _JANUS_API_ERROR_H

/*! \brief Success (no error) */
#define JANUS_OK 0

/*! \brief Unknown/undocumented error */
#define JANUS_ERROR_UNKNOWN 450
/*! \brief The client needs to use HTTP POST for this request */
#define JANUS_ERROR_USE_POST 451
/*! \brief The request is missing in the message */
#define JANUS_ERROR_MISSING_REQUEST 452
/*! \brief The gateway does not suppurt this request */
#define JANUS_ERROR_UNKNOWN_REQUEST 453
/*! \brief The payload is not a valid JSON message */
#define JANUS_ERROR_INVALID_JSON 454
/*! \brief The object is not a valid JSON object as expected */
#define JANUS_ERROR_INVALID_JSON_OBJECT 455
/*! \brief A mandatory element is missing in the message */
#define JANUS_ERROR_MISSING_MANDATORY_ELEMENT 456
/*! \brief The request cannot be handled for this webserver path */
#define JANUS_ERROR_INVALID_REQUEST_PATH 457
/*! \brief The session the request refers to doesn't exist */
#define JANUS_ERROR_SESSION_NOT_FOUND 458
/*! \brief The handle the request refers to doesn't exist */
#define JANUS_ERROR_HANDLE_NOT_FOUND 459
/*! \brief The plugin the request wants to talk to doesn't exist */
#define JANUS_ERROR_PLUGIN_NOT_FOUND 460
/*! \brief An error occurring when trying to attach to a plugin and create a handle */
#define JANUS_ERROR_PLUGIN_ATTACH 461
/*! \brief An error occurring when trying to send a message/request to the plugin */
#define JANUS_ERROR_PLUGIN_MESSAGE 462
/*! \brief An error occurring when trying to detach from a plugin and destroy the related handle */
#define JANUS_ERROR_PLUGIN_DETACH 463
/*! \brief The gateway doesn't support this SDP type
* \todo The gateway currently only supports OFFER and ANSWER. */
#define JANUS_ERROR_JSEP_UNKNOWN_TYPE 464
/*! \brief The Session Description provided by the peer is invalid */
#define JANUS_ERROR_JSEP_INVALID_SDP 465


/*! \brief Helper method to get a string representation of an API error code
* @param[in] error The API error code
* @returns A string representation of the error code */
const char *janus_get_api_error(int error);

#endif
9 changes: 9 additions & 0 deletions certs/mycert.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN RSA PRIVATE KEY-----
MIIBOgIBAAJBAOtEqXVklbHj85N4pdlOTtuEddeba9nQ7D4cznU7JF6GcwCC6mKU
3Lh0Q38RgvWkD2mCpeDrRXhVyB76vCy7zUECAwEAAQJAaxtbOoKMU+w/G8g1WPT5
mZ54N6weMY+Xvb9Hjr9aE12qxga6oBH3duZIReXyaNnOl3atvQj/3w9asGI/mUnE
AQIhAPozBZrD47grebUjWglWVaTuoburLJLOY4cXyvRYpF3xAiEA8LkFdOcapj39
wUn88CSSndAwh3iUIdQzuTAfnZVXVFECIQCxP0wNJBFC+6mxJWY3jy4FNfjl1pIx
Pn1LyxNAnztyQQIgTz45I6CoTy19CVIX593CPh04vH/fE7vNQxsqbS+qTeECIGxt
mLp1s3KthK3M6RQITWJcN59szWbvqL+I0habZg/0
-----END RSA PRIVATE KEY-----
19 changes: 19 additions & 0 deletions certs/mycert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDHTCCAsegAwIBAgIJAMl+Wbm0KD14MA0GCSqGSIb3DQEBBQUAMIGTMQswCQYD
VQQGEwJJVDEPMA0GA1UECBMGTmFwb2xpMQ8wDQYDVQQHEwZOYXBvbGkxEjAQBgNV
BAoTCVJhaW5tYWtlcjERMA8GA1UECxMIUmVzZWFyY2gxGDAWBgNVBAMTDzE0My4y
MjUuMjI5LjE3NDEhMB8GCSqGSIb3DQEJARYScmFpbm1ha2VyQG1haWwuY29tMB4X
DTA3MDIwOTE2MTg0NVoXDTA5MDIwODE2MTg0NVowgZMxCzAJBgNVBAYTAklUMQ8w
DQYDVQQIEwZOYXBvbGkxDzANBgNVBAcTBk5hcG9saTESMBAGA1UEChMJUmFpbm1h
a2VyMREwDwYDVQQLEwhSZXNlYXJjaDEYMBYGA1UEAxMPMTQzLjIyNS4yMjkuMTc0
MSEwHwYJKoZIhvcNAQkBFhJyYWlubWFrZXJAbWFpbC5jb20wXDANBgkqhkiG9w0B
AQEFAANLADBIAkEA60SpdWSVsePzk3il2U5O24R115tr2dDsPhzOdTskXoZzAILq
YpTcuHRDfxGC9aQPaYKl4OtFeFXIHvq8LLvNQQIDAQABo4H7MIH4MB0GA1UdDgQW
BBQ+rMDyJ7+bUk+Bgz1ptdNNhxMr8zCByAYDVR0jBIHAMIG9gBQ+rMDyJ7+bUk+B
gz1ptdNNhxMr86GBmaSBljCBkzELMAkGA1UEBhMCSVQxDzANBgNVBAgTBk5hcG9s
aTEPMA0GA1UEBxMGTmFwb2xpMRIwEAYDVQQKEwlSYWlubWFrZXIxETAPBgNVBAsT
CFJlc2VhcmNoMRgwFgYDVQQDEw8xNDMuMjI1LjIyOS4xNzQxITAfBgkqhkiG9w0B
CQEWEnJhaW5tYWtlckBtYWlsLmNvbYIJAMl+Wbm0KD14MAwGA1UdEwQFMAMBAf8w
DQYJKoZIhvcNAQEFBQADQQB89BzlT3o4EFOtg7Fs8tycc8A/SLutqtcumA1YrufZ
ISukISpvHFqAyWISkMv0snPtN6S4C5FK4EhJ0/A7JnsH
-----END CERTIFICATE-----
Loading

0 comments on commit be35fac

Please sign in to comment.