Janus core (headers) More...
#include <inttypes.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <jansson.h>
#include "mutex.h"
#include "ice.h"
#include "refcount.h"
#include "transports/transport.h"
#include "events/eventhandler.h"
#include "loggers/logger.h"
#include "plugins/plugin.h"
Go to the source code of this file.
Data Structures | |
struct | janus_session |
Janus Core-Client session. More... | |
struct | janus_request |
Helper to address requests and their sources (e.g., a specific HTTP connection, websocket, RabbitMQ or others) More... | |
Typedefs | |
typedef struct janus_request | janus_request |
Helper to address requests and their sources (e.g., a specific HTTP connection, websocket, RabbitMQ or others) | |
typedef struct janus_session | janus_session |
Janus Core-Client session. | |
Functions | |
gchar * | janus_get_server_pem (void) |
Helper method to return the path to the provided server certificate. | |
gchar * | janus_get_server_key (void) |
Helper method to return the path to the provided server certificate key. | |
gchar * | janus_get_local_ip (void) |
Helper method to return the local IP address (autodetected by default) | |
gchar * | janus_get_public_ip (guint index) |
Helper method to return a given public IP address to use in the SDP (if multiple are configured for 1-1 NAT) | |
guint | janus_get_public_ip_count (void) |
Helper method to return the number of public IP addresses (if configured for 1-1 NAT) | |
void | janus_add_public_ip (const char *ip) |
Helper method to add an IP address to use in the SDP. | |
gboolean | janus_has_public_ipv4_ip (void) |
Helper method to check if we have at least one manually passed public IPv4 address (for 1-1 NAT management) | |
gboolean | janus_has_public_ipv6_ip (void) |
Helper method to check if we have at least one manually passed public IPv6 address (for 1-1 NAT management) | |
gint | janus_is_stopping (void) |
Helper method to check whether the server is being shut down. | |
gboolean | janus_is_webrtc_encryption_enabled (void) |
Helper method to check whether WebRTC encryption is (as it should) enabled. | |
Janus Core-Client session methods | |
janus_session * | janus_session_create (guint64 session_id) |
Method to create a new Janus Core-Client session. | |
janus_session * | janus_session_find (guint64 session_id) |
Method to find an existing Janus Core-Client session from its ID. | |
void | janus_session_notify_event (janus_session *session, json_t *event) |
Method to add an event to notify to the queue of notifications for this session. | |
gint | janus_session_destroy (janus_session *session) |
Method to destroy a Janus Core-Client session. | |
janus_ice_handle * | janus_session_handles_find (janus_session *session, guint64 handle_id) |
Method to find an existing Janus ICE handle from its ID. | |
void | janus_session_handles_insert (janus_session *session, janus_ice_handle *handle) |
Method to insert a Janus ICE handle in a session. | |
gint | janus_session_handles_remove (janus_session *session, janus_ice_handle *handle) |
Method to remove a Janus ICE handle from a session. | |
void | janus_session_handles_clear (janus_session *session) |
Method to remove all Janus ICE handles from a session. | |
json_t * | janus_session_handles_list_json (janus_session *session) |
Method to list the IDs of all Janus ICE handles of a session as JSON. | |
Janus request processing | |
Since messages may come from different sources (plain HTTP, WebSockets, RabbitMQ and potentially even more in the future), we have a shared way to process messages: a method to process a request, and helper methods to return a success or an error message. | |
janus_request * | janus_request_new (janus_transport *transport, janus_transport_session *instance, void *request_id, gboolean admin, json_t *message, json_error_t *error) |
Helper to allocate a janus_request instance. | |
void | janus_request_destroy (janus_request *request) |
Helper to destroy a janus_request instance. | |
int | janus_process_incoming_request (janus_request *request) |
Helper to process an incoming request, no matter where it comes from. | |
int | janus_process_incoming_admin_request (janus_request *request) |
Helper to process an incoming admin/monitor request, no matter where it comes from. | |
int | janus_process_success (janus_request *request, json_t *payload) |
Method to return a successful Janus response message (JSON) to the browser. | |
int | janus_process_error (janus_request *request, uint64_t session_id, const char *transaction, gint error, const char *format,...) G_GNUC_PRINTF(5 |
Method to return an error Janus response message (JSON) to the browser. | |
Janus transport plugin management | |
The core doesn't support any transport for the Janus API by default. In order to be able to with external clients, transport plugins are needed, e.g., to provide support for REST HTTP/HTTPS, WebSockets, RabbitMQ or others. These transport plugins are shared objects that need to implement the interfaces defined in transport.h and as such are dynamically loaded by the server at startup, and unloaded when the server closes. | |
void | janus_transport_close (void *key, void *value, void *user_data) |
Callback (g_hash_table_foreach) invoked when it's time to destroy a transport instance. | |
void | janus_transportso_close (void *key, void *value, void *user_data) |
Callback (g_hash_table_foreach) invoked when it's time to close a transport plugin. | |
Janus event handler plugin management | |
The core doesn't notify anyone, except session originators, and only then only about stuff relevant to them. In order to allow for a more apt management of core and plugin related events on a broader sense, event handler plugins are needed. These event handler plugins are shared objects that need to implement the interfaces defined in eventhandler.h and as such are dynamically loaded by the server at startup, and unloaded when the server closes. | |
void | janus_eventhandler_close (void *key, void *value, void *user_data) |
Callback (g_hash_table_foreach) invoked when it's time to destroy an eventhandler instance. | |
void | janus_eventhandlerso_close (void *key, void *value, void *user_data) |
Callback (g_hash_table_foreach) invoked when it's time to close an eventhandler plugin. | |
Janus external logger plugin management | |
By default, Janus has integrated support for logging to stdout and to a static file. Custom and advanced logging can be accomplished using additional logger plugins. These logger plugins are shared objects that need to implement the interfaces defined in logger.h and as such are dynamically loaded by the server at startup, and unloaded when the server closes. | |
void | janus_logger_close (void *key, void *value, void *user_data) |
Callback (g_hash_table_foreach) invoked when it's time to destroy a logger instance. | |
void | janus_loggerso_close (void *key, void *value, void *user_data) |
Callback (g_hash_table_foreach) invoked when it's time to close a logger plugin. | |
Janus plugin management | |
As anticipated, the server doesn't provide any specific feature: it takes care of WebRTC-related stuff, and of sending and receiving JSON-based messages. To implement applications based on these foundations, plugins can be used. These plugins are shared objects that need to implement the interfaces defined in plugin.h and as such are dynamically loaded by the server at startup, and unloaded when the server closes. | |
void | janus_plugin_close (void *key, void *value, void *user_data) |
Callback (g_hash_table_foreach) invoked when it's time to destroy a plugin instance. | |
void | janus_pluginso_close (void *key, void *value, void *user_data) |
Callback (g_hash_table_foreach) invoked when it's time to close a plugin. | |
janus_plugin * | janus_plugin_find (const gchar *package) |
Method to return a registered plugin instance out of its package name. | |
Janus core (headers)
Implementation of the Janus core. This code takes care of the server initialization (command line/configuration) and setup, and makes use of the available transport plugins (by default HTTP, WebSockets, RabbitMQ, if compiled) and Janus protocol (a JSON-based protocol) to interact with the applications, whether they're web based or not. The core also takes care of bridging peers and plugins accordingly, in terms of both messaging and real-time media transfer via WebRTC.
typedef struct janus_request janus_request |
Helper to address requests and their sources (e.g., a specific HTTP connection, websocket, RabbitMQ or others)
typedef struct janus_session janus_session |
Janus Core-Client session.
void janus_add_public_ip | ( | const char * | ip | ) |
Helper method to add an IP address to use in the SDP.
void janus_eventhandler_close | ( | void * | key, |
void * | value, | ||
void * | user_data ) |
Callback (g_hash_table_foreach) invoked when it's time to destroy an eventhandler instance.
[in] | key | Key of the events hash table (package name) |
[in] | value | The janus_eventhandler instance to destroy |
[in] | user_data | User provided data (unused) |
void janus_eventhandlerso_close | ( | void * | key, |
void * | value, | ||
void * | user_data ) |
Callback (g_hash_table_foreach) invoked when it's time to close an eventhandler plugin.
[in] | key | Key of the events hash table (package name) |
[in] | value | The janus_eventhandler instance to close |
[in] | user_data | User provided data (unused) |
gchar * janus_get_local_ip | ( | void | ) |
Helper method to return the local IP address (autodetected by default)
gchar * janus_get_public_ip | ( | guint | index | ) |
Helper method to return a given public IP address to use in the SDP (if multiple are configured for 1-1 NAT)
guint janus_get_public_ip_count | ( | void | ) |
Helper method to return the number of public IP addresses (if configured for 1-1 NAT)
gchar * janus_get_server_key | ( | void | ) |
Helper method to return the path to the provided server certificate key.
gchar * janus_get_server_pem | ( | void | ) |
Helper method to return the path to the provided server certificate.
gboolean janus_has_public_ipv4_ip | ( | void | ) |
Helper method to check if we have at least one manually passed public IPv4 address (for 1-1 NAT management)
gboolean janus_has_public_ipv6_ip | ( | void | ) |
Helper method to check if we have at least one manually passed public IPv6 address (for 1-1 NAT management)
gint janus_is_stopping | ( | void | ) |
Helper method to check whether the server is being shut down.
gboolean janus_is_webrtc_encryption_enabled | ( | void | ) |
Helper method to check whether WebRTC encryption is (as it should) enabled.
--disable-webrtc-encryption
, and you should NEVER use it otherwise (it would simply not work with regular WebRTC endpoints). void janus_logger_close | ( | void * | key, |
void * | value, | ||
void * | user_data ) |
Callback (g_hash_table_foreach) invoked when it's time to destroy a logger instance.
[in] | key | Key of the loggers hash table (package name) |
[in] | value | The janus_logger instance to destroy |
[in] | user_data | User provided data (unused) |
void janus_loggerso_close | ( | void * | key, |
void * | value, | ||
void * | user_data ) |
Callback (g_hash_table_foreach) invoked when it's time to close a logger plugin.
[in] | key | Key of the events hash table (package name) |
[in] | value | The janus_logger instance to close |
[in] | user_data | User provided data (unused) |
void janus_plugin_close | ( | void * | key, |
void * | value, | ||
void * | user_data ) |
Callback (g_hash_table_foreach) invoked when it's time to destroy a plugin instance.
[in] | key | Key of the plugins hash table (package name) |
[in] | value | The janus_plugin plugin instance to destroy |
[in] | user_data | User provided data (unused) |
janus_plugin * janus_plugin_find | ( | const gchar * | package | ) |
Method to return a registered plugin instance out of its package name.
[in] | package | The unique package name of the plugin |
void janus_pluginso_close | ( | void * | key, |
void * | value, | ||
void * | user_data ) |
Callback (g_hash_table_foreach) invoked when it's time to close a plugin.
[in] | key | Key of the plugins hash table (package name) |
[in] | value | The janus_plugin plugin instance to close |
[in] | user_data | User provided data (unused) |
int janus_process_error | ( | janus_request * | request, |
uint64_t | session_id, | ||
const char * | transaction, | ||
gint | error, | ||
const char * | format, | ||
... ) |
Method to return an error Janus response message (JSON) to the browser.
[in] | request | The request instance and its source |
[in] | session_id | Janus session identifier this error refers to |
[in] | transaction | The Janus transaction identifier |
[in] | error | The error code as defined in apierror.h |
[in] | format | The printf format of the reason string, followed by a variable number of arguments, if needed; if format is NULL, a pre-configured string associated with the error code is used |
int janus_process_incoming_admin_request | ( | janus_request * | request | ) |
Helper to process an incoming admin/monitor request, no matter where it comes from.
[in] | request | The request instance and its source |
int janus_process_incoming_request | ( | janus_request * | request | ) |
Helper to process an incoming request, no matter where it comes from.
[in] | request | The JSON request |
int janus_process_success | ( | janus_request * | request, |
json_t * | payload ) |
Method to return a successful Janus response message (JSON) to the browser.
[in] | request | The request instance and its source |
[in] | payload | The payload to return as a JSON object |
void janus_request_destroy | ( | janus_request * | request | ) |
Helper to destroy a janus_request instance.
[in] | request | The janus_request instance to destroy |
janus_request * janus_request_new | ( | janus_transport * | transport, |
janus_transport_session * | instance, | ||
void * | request_id, | ||
gboolean | admin, | ||
json_t * | message, | ||
json_error_t * | error ) |
Helper to allocate a janus_request instance.
[in] | transport | Pointer to the transport |
[in] | instance | Pointer to the transport-provided session instance |
[in] | request_id | Opaque pointer to the request ID, if available |
[in] | admin | Whether this is a Janus API or Admin API request |
[in] | message | Opaque pointer to the original request, if available |
[in] | error | If the transport detected a JSON parsing error, the error content |
janus_session * janus_session_create | ( | guint64 | session_id | ) |
Method to create a new Janus Core-Client session.
[in] | session_id | The desired Janus Core-Client session ID, or 0 if it needs to be generated randomly |
gint janus_session_destroy | ( | janus_session * | session | ) |
Method to destroy a Janus Core-Client session.
[in] | session | The Janus Core-Client session to destroy |
janus_session * janus_session_find | ( | guint64 | session_id | ) |
Method to find an existing Janus Core-Client session from its ID.
[in] | session_id | The Janus Core-Client session ID |
void janus_session_handles_clear | ( | janus_session * | session | ) |
Method to remove all Janus ICE handles from a session.
[in] | session | The Janus Core-Client session |
janus_ice_handle * janus_session_handles_find | ( | janus_session * | session, |
guint64 | handle_id ) |
Method to find an existing Janus ICE handle from its ID.
[in] | session | The Janus Core-Client session this ICE handle belongs to |
[in] | handle_id | The Janus ICE handle ID |
void janus_session_handles_insert | ( | janus_session * | session, |
janus_ice_handle * | handle ) |
Method to insert a Janus ICE handle in a session.
[in] | session | The Janus Core-Client session |
[in] | handle | The Janus ICE handle |
json_t * janus_session_handles_list_json | ( | janus_session * | session | ) |
Method to list the IDs of all Janus ICE handles of a session as JSON.
[in] | session | The Janus Core-Client session |
gint janus_session_handles_remove | ( | janus_session * | session, |
janus_ice_handle * | handle ) |
Method to remove a Janus ICE handle from a session.
[in] | session | The Janus Core-Client session |
[in] | handle | The Janus ICE handle |
void janus_session_notify_event | ( | janus_session * | session, |
json_t * | event ) |
Method to add an event to notify to the queue of notifications for this session.
[in] | session | The Janus Core-Client session this notification is related to |
[in] | event | The event to notify as a Jansson JSON object |
void janus_transport_close | ( | void * | key, |
void * | value, | ||
void * | user_data ) |
Callback (g_hash_table_foreach) invoked when it's time to destroy a transport instance.
[in] | key | Key of the transports hash table (package name) |
[in] | value | The janus_transport instance to destroy |
[in] | user_data | User provided data (unused) |
void janus_transportso_close | ( | void * | key, |
void * | value, | ||
void * | user_data ) |
Callback (g_hash_table_foreach) invoked when it's time to close a transport plugin.
[in] | key | Key of the transports hash table (package name) |
[in] | value | The janus_transport instance to close |
[in] | user_data | User provided data (unused) |