Fork me on GitHub
Loading...
Searching...
No Matches
janus.h
Go to the documentation of this file.
1
18#ifndef JANUS_CORE_H
19#define JANUS_CORE_H
20
21#include <inttypes.h>
22#include <stdlib.h>
23#include <stdint.h>
24#include <stdio.h>
25#include <string.h>
26#include <ctype.h>
27#include <unistd.h>
28
29#include <jansson.h>
30
31#include "mutex.h"
32#include "ice.h"
33#include "refcount.h"
35#include "events/eventhandler.h"
36#include "loggers/logger.h"
37#include "plugins/plugin.h"
38
39
42
44typedef struct janus_session {
46 guint64 session_id;
48 GHashTable *ice_handles;
54 volatile gint timedout;
56 gint timeout;
58 volatile gint transport_gone;
62 volatile gint destroyed;
66
67
71
74janus_session *janus_session_create(guint64 session_id);
78janus_session *janus_session_find(guint64 session_id);
109
110
118
127 gboolean admin;
131 json_error_t *error;
133 volatile gint destroyed;
136};
144janus_request *janus_request_new(janus_transport *transport, janus_transport_session *instance, void *request_id, gboolean admin, json_t *message, json_error_t *error);
164int janus_process_success(janus_request *request, json_t *payload);
175int janus_process_error(janus_request *request, uint64_t session_id, const char *transaction, gint error, const char *format, ...) G_GNUC_PRINTF(5, 6);
177
178
189
193void janus_transport_close(void *key, void *value, void *user_data);
198void janus_transportso_close(void *key, void *value, void *user_data);
200
211
215void janus_eventhandler_close(void *key, void *value, void *user_data);
220void janus_eventhandlerso_close(void *key, void *value, void *user_data);
222
231
235void janus_logger_close(void *key, void *value, void *user_data);
240void janus_loggerso_close(void *key, void *value, void *user_data);
242
252
256void janus_plugin_close(void *key, void *value, void *user_data);
261void janus_pluginso_close(void *key, void *value, void *user_data);
265janus_plugin *janus_plugin_find(const gchar *package);
267
272
273
275gchar *janus_get_local_ip(void);
277gchar *janus_get_public_ip(guint index);
279guint janus_get_public_ip_count(void);
281void janus_add_public_ip(const char *ip);
283gboolean janus_has_public_ipv4_ip(void);
285gboolean janus_has_public_ipv6_ip(void);
286
288gint janus_is_stopping(void);
289
298
299#endif
Modular Janus event handlers (headers)
Janus handles and ICE/STUN/TURN processing (headers)
janus_session * janus_session_create(guint64 session_id)
Method to create a new Janus Core-Client session.
Definition: janus.c:767
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.
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
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.
void janus_add_public_ip(const char *ip)
Helper method to add an IP address to use in the SDP.
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:895
janus_plugin * janus_plugin_find(const gchar *package)
Method to return a registered plugin instance out of its package name.
Definition: janus.c:3653
janus_session * janus_session_find(guint64 session_id)
Method to find an existing Janus Core-Client session from its ID.
Definition: janus.c:799
void janus_session_handles_clear(janus_session *session)
Method to remove all Janus ICE handles from a session.
Definition: janus.c:876
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.
gboolean janus_is_webrtc_encryption_enabled(void)
Helper method to check whether WebRTC encryption is (as it should) enabled.
Definition: janus.c:320
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:811
gchar * janus_get_local_ip(void)
Helper method to return the local IP address (autodetected by default)
Definition: janus.c:211
gchar * janus_get_server_pem(void)
Helper method to return the path to the provided server certificate.
gint janus_is_stopping(void)
Helper method to check whether the server is being shut down.
Definition: janus.c:258
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:857
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.
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_request_destroy(janus_request *request)
Helper to destroy a janus_request instance.
Definition: janus.c:952
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
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.
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:933
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.
int janus_process_incoming_request(janus_request *request)
Helper to process an incoming request, no matter where it comes from.
Definition: janus.c:1049
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.
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:843
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
gint janus_session_destroy(janus_session *session)
Method to destroy a Janus Core-Client session.
Definition: janus.c:831
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:2122
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:3139
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
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:867
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.
gchar * janus_get_server_key(void)
Helper method to return the path to the provided server certificate key.
Modular Janus loggers (headers)
Semaphors, Mutexes and Conditions.
GMutex janus_mutex
Janus mutex implementation.
Definition: mutex.h:73
Plugin-Core communication (implementation)
struct json_t json_t
Definition: plugin.h:236
Reference counter mechanism.
Janus ICE handle.
Definition: ice.h:354
The plugin session and callbacks interface.
Definition: plugin.h:252
Definition: refcount.h:78
Helper to address requests and their sources (e.g., a specific HTTP connection, websocket,...
Definition: janus.h:119
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition: janus.h:133
janus_transport * transport
Pointer to the transport plugin.
Definition: janus.h:121
json_error_t * error
Pointer to any JSON errors parsing the original request.
Definition: janus.h:131
json_t * message
Pointer to the original request, if available.
Definition: janus.h:129
void * request_id
Opaque pointer to the request ID, if available.
Definition: janus.h:125
gboolean admin
Whether this is a Janus API or admin API request.
Definition: janus.h:127
janus_transport_session * instance
Pointer to the transport-provided session instance.
Definition: janus.h:123
janus_refcount ref
Reference counter for this instance.
Definition: janus.h:135
Janus Core-Client session.
Definition: janus.h:44
janus_request * source
Pointer to the request instance (and the transport that originated the session)
Definition: janus.h:52
GHashTable * ice_handles
Map of handles this session is managing.
Definition: janus.h:48
janus_refcount ref
Reference counter for this instance.
Definition: janus.h:64
gint timeout
Timeout value in seconds to use with this session, 0 is unlimited, -1 is global session timeout setti...
Definition: janus.h:56
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition: janus.h:62
guint64 session_id
Janus Core-Client session ID.
Definition: janus.h:46
gint64 last_activity
Time of the last activity on the session.
Definition: janus.h:50
volatile gint timedout
Flag to notify there's been a session timeout.
Definition: janus.h:54
volatile gint transport_gone
Flag to notify that transport is gone.
Definition: janus.h:58
janus_mutex mutex
Mutex to lock/unlock this session.
Definition: janus.h:60
Transport-Gateway session mapping.
Definition: transport.h:145
The transport plugin session and callbacks interface.
Definition: transport.h:175
Modular Janus API transports.