Fork me on GitHub
Data Structures | Macros | Typedefs | Functions
janus_http.c File Reference

Janus RESTs transport plugin. More...

#include "transport.h"
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netdb.h>
#include <microhttpd.h>
#include "../debug.h"
#include "../apierror.h"
#include "../config.h"
#include "../mutex.h"
#include "../ip-utils.h"
#include "../utils.h"
Include dependency graph for janus_http.c:

Data Structures

struct  janus_http_msg
 
struct  janus_http_session
 
struct  janus_http_request_timeout
 

Macros

#define JANUS_REST_VERSION   2
 
#define JANUS_REST_VERSION_STRING   "0.0.2"
 
#define JANUS_REST_DESCRIPTION   "This transport plugin adds REST (HTTP/HTTPS) support to the Janus API via libmicrohttpd."
 
#define JANUS_REST_NAME   "JANUS REST (HTTP/HTTPS) transport plugin"
 
#define JANUS_REST_AUTHOR   "Meetecho s.r.l."
 
#define JANUS_REST_PACKAGE   "janus.transport.http"
 

Typedefs

typedef struct janus_http_msg janus_http_msg
 
typedef struct janus_http_session janus_http_session
 
typedef struct janus_http_request_timeout janus_http_request_timeout
 

Functions

janus_transportcreate (void)
 
int janus_http_init (janus_transport_callbacks *callback, const char *config_path)
 
void janus_http_destroy (void)
 
int janus_http_get_api_compatibility (void)
 
int janus_http_get_version (void)
 
const char * janus_http_get_version_string (void)
 
const char * janus_http_get_description (void)
 
const char * janus_http_get_name (void)
 
const char * janus_http_get_author (void)
 
const char * janus_http_get_package (void)
 
gboolean janus_http_is_janus_api_enabled (void)
 
gboolean janus_http_is_admin_api_enabled (void)
 
int janus_http_send_message (janus_transport_session *transport, void *request_id, gboolean admin, json_t *message)
 
void janus_http_session_created (janus_transport_session *transport, guint64 session_id)
 
void janus_http_session_over (janus_transport_session *transport, guint64 session_id, gboolean timeout, gboolean claimed)
 
void janus_http_session_claimed (janus_transport_session *transport, guint64 session_id)
 

Detailed Description

Janus RESTs transport plugin.

Author
Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om

This is an implementation of a RESTs transport for the Janus API, using the libmicrohttpd library (http://www.gnu.org/software/libmicrohttpd/). This module allows browsers to make use of HTTP to talk to the Janus core. Since a Janus instance may be deployed on a different domain than the web server hosting the web applications using it, the plugin automatically handles OPTIONS request to comply with the CORS specification. POST requests can be used to ask for the management of a session with the server, to attach to a plugin, to send messages to the plugin itself and so on. GET requests instead are used for getting events associated to a Janus session (and as such to all its plugin handles and the events plugins push in the session itself), using a long poll approach. A JavaScript library (janus.js) implements all of this on the client side automatically.

Note
There's a well known bug in libmicrohttpd that may cause it to spike to 100% of the CPU when using HTTPS on some distributions. In case you're interested in HTTPS support, it's better to just rely on HTTP in Janus, and put a frontend like Apache HTTPD or nginx to take care of securing the traffic. More details are available in Deploying Janus.

transports

Macro Definition Documentation

#define JANUS_REST_AUTHOR   "Meetecho s.r.l."
#define JANUS_REST_DESCRIPTION   "This transport plugin adds REST (HTTP/HTTPS) support to the Janus API via libmicrohttpd."
#define JANUS_REST_NAME   "JANUS REST (HTTP/HTTPS) transport plugin"
#define JANUS_REST_PACKAGE   "janus.transport.http"
#define JANUS_REST_VERSION   2
#define JANUS_REST_VERSION_STRING   "0.0.2"

Typedef Documentation

Function Documentation

janus_transport* create ( void  )
void janus_http_destroy ( void  )
int janus_http_get_api_compatibility ( void  )
const char * janus_http_get_author ( void  )
const char * janus_http_get_description ( void  )
const char * janus_http_get_name ( void  )
const char * janus_http_get_package ( void  )
int janus_http_get_version ( void  )
const char * janus_http_get_version_string ( void  )
int janus_http_init ( janus_transport_callbacks callback,
const char *  config_path 
)
gboolean janus_http_is_admin_api_enabled ( void  )
gboolean janus_http_is_janus_api_enabled ( void  )
int janus_http_send_message ( janus_transport_session transport,
void *  request_id,
gboolean  admin,
json_t message 
)
void janus_http_session_claimed ( janus_transport_session transport,
guint64  session_id 
)
void janus_http_session_created ( janus_transport_session transport,
guint64  session_id 
)
void janus_http_session_over ( janus_transport_session transport,
guint64  session_id,
gboolean  timeout,
gboolean  claimed 
)