Fork me on GitHub
No Matches
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


#define JANUS_HTTP_DESCRIPTION   "This transport plugin adds REST (HTTP/HTTPS) support to the Janus API via libmicrohttpd."
#define JANUS_HTTP_NAME   "JANUS REST (HTTP/HTTPS) transport plugin"
#define JANUS_HTTP_AUTHOR   "Meetecho s.r.l."
#define JANUS_HTTP_PACKAGE   "janus.transport.http"


typedef int janus_MHD_Result
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


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)
json_tjanus_http_query_transport (json_t *request)

Detailed Description

Janus RESTs transport plugin.

Lorenzo Miniero

This is an implementation of a RESTs transport for the Janus API, using the libmicrohttpd library ( 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.

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.


Macro Definition Documentation




#define JANUS_HTTP_AUTHOR   "Meetecho s.r.l."


#define JANUS_HTTP_DESCRIPTION   "This transport plugin adds REST (HTTP/HTTPS) support to the Janus API via libmicrohttpd."










#define JANUS_HTTP_NAME   "JANUS REST (HTTP/HTTPS) transport plugin"


#define JANUS_HTTP_PACKAGE   "janus.transport.http"





Typedef Documentation

◆ janus_http_msg

typedef struct janus_http_msg janus_http_msg

◆ janus_http_request_timeout

typedef struct janus_http_request_timeout janus_http_request_timeout

◆ janus_http_session

typedef struct janus_http_session janus_http_session

◆ janus_MHD_Result

typedef int janus_MHD_Result

Function Documentation

◆ create()

janus_transport * create ( void )

◆ janus_http_destroy()

void janus_http_destroy ( void )

◆ janus_http_get_api_compatibility()

int janus_http_get_api_compatibility ( void )

◆ janus_http_get_author()

const char * janus_http_get_author ( void )

◆ janus_http_get_description()

const char * janus_http_get_description ( void )

◆ janus_http_get_name()

const char * janus_http_get_name ( void )

◆ janus_http_get_package()

const char * janus_http_get_package ( void )

◆ janus_http_get_version()

int janus_http_get_version ( void )

◆ janus_http_get_version_string()

const char * janus_http_get_version_string ( void )

◆ janus_http_init()

int janus_http_init ( janus_transport_callbacks * callback,
const char * config_path )

◆ janus_http_is_admin_api_enabled()

gboolean janus_http_is_admin_api_enabled ( void )

◆ janus_http_is_janus_api_enabled()

gboolean janus_http_is_janus_api_enabled ( void )

◆ janus_http_query_transport()

json_t * janus_http_query_transport ( json_t * request)

◆ janus_http_send_message()

int janus_http_send_message ( janus_transport_session * transport,
void * request_id,
gboolean admin,
json_t * message )

◆ janus_http_session_claimed()

void janus_http_session_claimed ( janus_transport_session * transport,
guint64 session_id )

◆ janus_http_session_created()

void janus_http_session_created ( janus_transport_session * transport,
guint64 session_id )

◆ janus_http_session_over()

void janus_http_session_over ( janus_transport_session * transport,
guint64 session_id,
gboolean timeout,
gboolean claimed )