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"
Data Structures | |
struct | janus_http_msg |
struct | janus_http_session |
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 |
Functions | |
janus_transport * | create (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) |
int | janus_http_client_connect (void *cls, const struct sockaddr *addr, socklen_t addrlen) |
int | janus_http_admin_client_connect (void *cls, const struct sockaddr *addr, socklen_t addrlen) |
int | janus_http_handler (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **ptr) |
int | janus_http_admin_handler (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **ptr) |
int | janus_http_headers (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) |
void | janus_http_request_completed (void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe) |
int | janus_http_notifier (janus_transport_session *ts, janus_http_session *session, int max_events) |
int | janus_http_return_success (janus_transport_session *ts, char *payload) |
int | janus_http_return_error (janus_transport_session *ts, uint64_t session_id, const char *transaction, gint error, const char *format,...) G_GNUC_PRINTF(5 |
Variables | |
const char * | keepalive_id = "keepalive" |
GHashTable * | sessions = NULL |
janus_mutex | sessions_mutex = JANUS_MUTEX_INITIALIZER |
GList * | janus_http_access_list = NULL |
GList * | janus_http_admin_access_list = NULL |
janus_mutex | access_list_mutex |
Janus RESTs transport plugin.
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.
#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 struct janus_http_msg janus_http_msg |
typedef struct janus_http_session janus_http_session |
janus_transport* create | ( | void | ) |
int janus_http_admin_client_connect | ( | void * | cls, |
const struct sockaddr * | addr, | ||
socklen_t | addrlen | ||
) |
int janus_http_admin_handler | ( | void * | cls, |
struct MHD_Connection * | connection, | ||
const char * | url, | ||
const char * | method, | ||
const char * | version, | ||
const char * | upload_data, | ||
size_t * | upload_data_size, | ||
void ** | ptr | ||
) |
int janus_http_client_connect | ( | void * | cls, |
const struct sockaddr * | addr, | ||
socklen_t | addrlen | ||
) |
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_handler | ( | void * | cls, |
struct MHD_Connection * | connection, | ||
const char * | url, | ||
const char * | method, | ||
const char * | version, | ||
const char * | upload_data, | ||
size_t * | upload_data_size, | ||
void ** | ptr | ||
) |
int janus_http_headers | ( | void * | cls, |
enum MHD_ValueKind | kind, | ||
const char * | key, | ||
const char * | value | ||
) |
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_notifier | ( | janus_transport_session * | ts, |
janus_http_session * | session, | ||
int | max_events | ||
) |
void janus_http_request_completed | ( | void * | cls, |
struct MHD_Connection * | connection, | ||
void ** | con_cls, | ||
enum MHD_RequestTerminationCode | toe | ||
) |
int janus_http_return_error | ( | janus_transport_session * | ts, |
uint64_t | session_id, | ||
const char * | transaction, | ||
gint | error, | ||
const char * | format, | ||
... | |||
) |
int janus_http_return_success | ( | janus_transport_session * | ts, |
char * | payload | ||
) |
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 | ||
) |
janus_mutex access_list_mutex |
GList* janus_http_access_list = NULL |
GList * janus_http_admin_access_list = NULL |
const char* keepalive_id = "keepalive" |
GHashTable* sessions = NULL |
janus_mutex sessions_mutex = JANUS_MUTEX_INITIALIZER |