Loading...
Searching...
No Matches
janus.h
Go to the documentation of this file.
#ifndef JANUS_CORE_H
#define JANUS_CORE_H
#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"
typedef struct janus_request janus_request;
typedef struct janus_session {
guint64 session_id;
GHashTable *ice_handles;
gint64 last_activity;
janus_request *source;
volatile gint timedout;
gint timeout;
volatile gint transport_gone;
janus_mutex mutex;
volatile gint destroyed;
janus_refcount ref;
} janus_session;
janus_session *janus_session_create(guint64 session_id);
janus_session *janus_session_find(guint64 session_id);
void janus_session_notify_event(janus_session *session, json_t *event);
gint janus_session_destroy(janus_session *session);
janus_ice_handle *janus_session_handles_find(janus_session *session, guint64 handle_id);
void janus_session_handles_insert(janus_session *session, janus_ice_handle *handle);
gint janus_session_handles_remove(janus_session *session, janus_ice_handle *handle);
void janus_session_handles_clear(janus_session *session);
json_t *janus_session_handles_list_json(janus_session *session);
struct janus_request {
janus_transport *transport;
janus_transport_session *instance;
void *request_id;
gboolean admin;
json_t *message;
json_error_t *error;
volatile gint destroyed;
janus_refcount ref;
};
janus_request *janus_request_new(janus_transport *transport, janus_transport_session *instance, void *request_id, gboolean admin, json_t *message, json_error_t *error);
void janus_request_destroy(janus_request *request);
int janus_process_incoming_request(janus_request *request);
int janus_process_incoming_admin_request(janus_request *request);
int janus_process_success(janus_request *request, json_t *payload);
int janus_process_error(janus_request *request, uint64_t session_id, const char *transaction, gint error, const char *format, ...) G_GNUC_PRINTF(5, 6);
void janus_transport_close(void *key, void *value, void *user_data);
void janus_transportso_close(void *key, void *value, void *user_data);
void janus_eventhandler_close(void *key, void *value, void *user_data);
void janus_eventhandlerso_close(void *key, void *value, void *user_data);
void janus_logger_close(void *key, void *value, void *user_data);
void janus_loggerso_close(void *key, void *value, void *user_data);
void janus_plugin_close(void *key, void *value, void *user_data);
void janus_pluginso_close(void *key, void *value, void *user_data);
janus_plugin *janus_plugin_find(const gchar *package);
gchar *janus_get_server_pem(void);
gchar *janus_get_server_key(void);
gchar *janus_get_local_ip(void);
gchar *janus_get_public_ip(guint index);
guint janus_get_public_ip_count(void);
void janus_add_public_ip(const char *ip);
gboolean janus_has_public_ipv4_ip(void);
gboolean janus_has_public_ipv6_ip(void);
gint janus_is_stopping(void);
gboolean janus_is_webrtc_encryption_enabled(void);
#endif
eventhandler.h
Modular Janus event handlers (headers).
ice.h
Janus handles and ICE/STUN/TURN processing (headers).
janus_has_public_ipv4_ip
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 manag...
Definition janus.c:249
janus_logger_close
void janus_logger_close(gpointer key, gpointer value, gpointer user_data)
Definition janus.c:3629
janus_plugin_find
janus_plugin * janus_plugin_find(const gchar *package)
Method to return a registered plugin instance out of its package name.
Definition janus.c:3660
janus_transportso_close
void janus_transportso_close(gpointer key, gpointer value, gpointer user_data)
Definition janus.c:3467
janus_is_webrtc_encryption_enabled
gboolean janus_is_webrtc_encryption_enabled(void)
Helper method to check whether WebRTC encryption is (as it should) enabled.
Definition janus.c:320
janus_pluginso_close
void janus_pluginso_close(gpointer key, gpointer value, gpointer user_data)
Definition janus.c:3652
janus_get_local_ip
gchar * janus_get_local_ip(void)
Helper method to return the local IP address (autodetected by default).
Definition janus.c:211
janus_loggerso_close
void janus_loggerso_close(gpointer key, gpointer value, gpointer user_data)
Definition janus.c:3636
janus_eventhandlerso_close
void janus_eventhandlerso_close(gpointer key, gpointer value, gpointer user_data)
Definition janus.c:3620
janus_is_stopping
gint janus_is_stopping(void)
Helper method to check whether the server is being shut down.
Definition janus.c:258
janus_transport_close
void janus_transport_close(gpointer key, gpointer value, gpointer user_data)
Definition janus.c:3460
janus_plugin_close
void janus_plugin_close(gpointer key, gpointer value, gpointer user_data)
Definition janus.c:3645
janus_get_public_ip
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...
Definition janus.c:220
janus_add_public_ip
void janus_add_public_ip(const gchar *ip)
Definition janus.c:230
janus_eventhandler_close
void janus_eventhandler_close(gpointer key, gpointer value, gpointer user_data)
Definition janus.c:3613
janus_get_public_ip_count
guint janus_get_public_ip_count(void)
Helper method to return the number of public IP addresses (if configured for 1-1 NAT).
Definition janus.c:217
janus_has_public_ipv6_ip
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 manag...
Definition janus.c:252
janus_session_create
janus_session * janus_session_create(guint64 session_id)
Method to create a new Janus Core-Client session.
Definition janus.c:777
janus_session_handles_list_json
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.
Definition janus.c:905
janus_session_find
janus_session * janus_session_find(guint64 session_id)
Method to find an existing Janus Core-Client session from its ID.
Definition janus.c:809
janus_session_handles_clear
void janus_session_handles_clear(janus_session *session)
Method to remove all Janus ICE handles from a session.
Definition janus.c:886
janus_session_notify_event
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.
Definition janus.c:821
janus_get_server_pem
gchar * janus_get_server_pem(void)
Helper method to return the path to the provided server certificate.
janus_session_handles_insert
void janus_session_handles_insert(janus_session *session, janus_ice_handle *handle)
Method to insert a Janus ICE handle in a session.
Definition janus.c:867
janus_process_error
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_request_destroy
void janus_request_destroy(janus_request *request)
Helper to destroy a janus_request instance.
Definition janus.c:962
janus_request_new
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.
Definition janus.c:943
janus_process_incoming_request
int janus_process_incoming_request(janus_request *request)
Helper to process an incoming request, no matter where it comes from.
Definition janus.c:1059
janus_session_handles_find
janus_ice_handle * janus_session_handles_find(janus_session *session, guint64 handle_id)
Method to find an existing Janus ICE handle from its ID.
Definition janus.c:853
janus_session_destroy
gint janus_session_destroy(janus_session *session)
Method to destroy a Janus Core-Client session.
Definition janus.c:841
janus_process_incoming_admin_request
int janus_process_incoming_admin_request(janus_request *request)
Helper to process an incoming admin/monitor request, no matter where it comes from.
Definition janus.c:2141
janus_process_success
int janus_process_success(janus_request *request, json_t *payload)
Method to return a successful Janus response message (JSON) to the browser.
Definition janus.c:3137
janus_session_handles_remove
gint janus_session_handles_remove(janus_session *session, janus_ice_handle *handle)
Method to remove a Janus ICE handle from a session.
Definition janus.c:877
janus_get_server_key
gchar * janus_get_server_key(void)
Helper method to return the path to the provided server certificate key.
logger.h
Modular Janus loggers (headers).
mutex.h
Semaphores, Mutexes and Conditions.
janus_mutex
GMutex janus_mutex
Janus mutex implementation.
Definition mutex.h:73
plugin.h
Plugin-Core communication (implementation).
json_t
struct json_t json_t
Definition plugin.h:236
refcount.h
Reference counter mechanism.
janus_ice_handle
Janus ICE handle.
Definition ice.h:347
janus_plugin
The plugin session and callbacks interface.
Definition plugin.h:252
janus_refcount
Definition refcount.h:78
janus_request
Helper to address requests and their sources (e.g., a specific HTTP connection, websocket,...
Definition janus.h:119
janus_request::destroyed
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition janus.h:133
janus_request::transport
janus_transport * transport
Pointer to the transport plugin.
Definition janus.h:121
janus_request::error
json_error_t * error
Pointer to any JSON errors parsing the original request.
Definition janus.h:131
janus_request::message
json_t * message
Pointer to the original request, if available.
Definition janus.h:129
janus_request::request_id
void * request_id
Opaque pointer to the request ID, if available.
Definition janus.h:125
janus_request::admin
gboolean admin
Whether this is a Janus API or admin API request.
Definition janus.h:127
janus_request::instance
janus_transport_session * instance
Pointer to the transport-provided session instance.
Definition janus.h:123
janus_request::ref
janus_refcount ref
Reference counter for this instance.
Definition janus.h:135
janus_session
Janus Core-Client session.
Definition janus.h:44
janus_session::source
janus_request * source
Pointer to the request instance (and the transport that originated the session).
Definition janus.h:52
janus_session::ice_handles
GHashTable * ice_handles
Map of handles this session is managing.
Definition janus.h:48
janus_session::ref
janus_refcount ref
Reference counter for this instance.
Definition janus.h:64
janus_session::timeout
gint timeout
Timeout value in seconds to use with this session, 0 is unlimited, -1 is global session timeout setti...
Definition janus.h:56
janus_session::destroyed
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition janus.h:62
janus_session::session_id
guint64 session_id
Janus Core-Client session ID.
Definition janus.h:46
janus_session::last_activity
gint64 last_activity
Time of the last activity on the session.
Definition janus.h:50
janus_session::timedout
volatile gint timedout
Flag to notify there's been a session timeout.
Definition janus.h:54
janus_session::transport_gone
volatile gint transport_gone
Flag to notify that transport is gone.
Definition janus.h:58
janus_session::mutex
janus_mutex mutex
Mutex to lock/unlock this session.
Definition janus.h:60
janus_transport_session
Transport-Gateway session mapping.
Definition transport.h:145
janus_transport
The transport plugin session and callbacks interface.
Definition transport.h:175
transport.h
Modular Janus API transports.