Fork me on GitHub
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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"
34 #include "transports/transport.h"
35 #include "events/eventhandler.h"
36 #include "plugins/plugin.h"
37 
38 
39 #define JANUS_BUFSIZE 8192
40 
43 
45 typedef struct janus_session {
47  guint64 session_id;
49  GHashTable *handles;
51  gint64 last_activity;
55  volatile gint timeout;
57  volatile gint transport_gone;
61  volatile gint destroyed;
65 
66 
69 
73 janus_session *janus_session_create(guint64 session_id);
77 janus_session *janus_session_find(guint64 session_id);
81 void janus_session_notify_event(janus_session *session, json_t *event);
90 janus_handle *janus_session_handles_find(janus_session *session, guint64 handle_id);
108 
109 
116 
124  void *request_id;
126  gboolean admin;
129 };
137 janus_request *janus_request_new(janus_transport *transport, janus_transport_session *instance, void *request_id, gboolean admin, json_t *message);
141 void janus_request_destroy(janus_request *request);
157 int janus_process_success(janus_request *request, json_t *payload);
168 int janus_process_error(janus_request *request, uint64_t session_id, const char *transaction, gint error, const char *format, ...) G_GNUC_PRINTF(5, 6);
170 
171 
181 
186 void janus_transport_close(void *key, void *value, void *user_data);
191 void janus_transportso_close(void *key, void *value, void *user_data);
193 
203 
208 void janus_eventhandler_close(void *key, void *value, void *user_data);
213 void janus_eventhandlerso_close(void *key, void *value, void *user_data);
215 
224 
229 void janus_plugin_close(void *key, void *value, void *user_data);
234 void janus_pluginso_close(void *key, void *value, void *user_data);
238 janus_plugin *janus_plugin_find(const gchar *package);
240 
242 gchar *janus_get_server_pem(void);
244 gchar *janus_get_server_key(void);
245 
246 
248 gchar *janus_get_local_ip(void);
250 gchar *janus_get_public_ip(void);
252 void janus_set_public_ip(const char *ip);
254 gint janus_is_stopping(void);
255 
264 
265 #endif
janus_handle * janus_session_handles_find(janus_session *session, guint64 handle_id)
Method to find an existing Janus handle from its ID.
Definition: janus.c:661
gint janus_is_stopping(void)
Helper method to check whether the server is being shut down.
Definition: janus.c:194
janus_transport * transport
Pointer to the transport plugin.
Definition: janus.h:120
volatile gint timeout
Flag to notify there's been a session timeout.
Definition: janus.h:55
Janus handles and ICE/STUN/TURN processing (headers)
Reference counter mechanism.
Modular Janus API transports.
struct json_t json_t
Definition: plugin.h:225
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:2544
GHashTable * handles
Map of handles this session is managing.
Definition: janus.h:49
janus_plugin * janus_plugin_find(const gchar *package)
Method to return a registered plugin instance out of its package name.
Definition: janus.c:3007
void janus_request_destroy(janus_request *request)
Helper to destroy a janus_request instance.
Definition: janus.c:740
void janus_set_public_ip(const char *ip)
Helper method to overwrite the IP address to use in the SDP.
Definition: janus.c:186
int janus_process_incoming_request(janus_request *request)
Helper to process an incoming request, no matter where it comes from.
Definition: janus.c:844
gint64 last_activity
Time of the last activity on the session.
Definition: janus.h:51
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.
GMutex janus_mutex
Janus mutex implementation.
Definition: mutex.h:61
janus_session * janus_session_find(guint64 session_id)
Method to find an existing Janus Core-Client session from its ID.
Definition: janus.c:624
Plugin-Core communication (implementation)
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.
Definition: refcount.h:78
Helper to address requests and their sources (e.g., a specific HTTP connection, websocket, RabbitMQ or others)
Definition: janus.h:118
janus_mutex mutex
Mutex to lock/unlock this session.
Definition: janus.h:59
Janus Core-Client session.
Definition: janus.h:45
void janus_session_handles_clear(janus_session *session)
Method to remove all Janus handles from a session.
Definition: janus.c:692
janus_transport_session * instance
Pointer to the transport-provided session instance.
Definition: janus.h:122
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_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_session * janus_session_create(guint64 session_id)
Method to create a new Janus Core-Client session.
Definition: janus.c:594
gchar * janus_get_public_ip(void)
Helper method to return the IP address to use in the SDP (autodetected by default) ...
Definition: janus.c:182
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_request * source
Pointer to the request instance (and the transport that originated the session)
Definition: janus.h:53
The plugin session and callbacks interface.
Definition: plugin.h:241
Janus handle.
Definition: ice.h:276
gboolean janus_is_webrtc_encryption_enabled(void)
Helper method to check whether WebRTC encryption is (as it should) enabled.
Definition: janus.c:252
json_t * message
Pointer to the original request, if available.
Definition: janus.h:128
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.
volatile gint transport_gone
Flag to notify that transport is gone.
Definition: janus.h:57
gchar * janus_get_server_key(void)
Helper method to return the path to the provided server certificate key.
janus_refcount ref
Reference counter for this instance.
Definition: janus.h:63
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition: janus.h:61
Modular Janus event handlers (headers)
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...
The transport plugin session and callbacks interface.
Definition: transport.h:174
janus_request * janus_request_new(janus_transport *transport, janus_transport_session *instance, void *request_id, gboolean admin, json_t *message)
Helper to allocate a janus_request instance.
Definition: janus.c:729
json_t * janus_session_handles_list_json(janus_session *session)
Method to list the IDs of all Janus handles of a session as JSON.
Definition: janus.c:710
void janus_session_handles_insert(janus_session *session, janus_handle *handle)
Method to insert a Janus handle in a session.
Definition: janus.c:675
Semaphors, Mutexes and Conditions.
gchar * janus_get_server_pem(void)
Helper method to return the path to the provided server certificate.
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:636
Transport-Gateway session mapping.
Definition: transport.h:144
gint janus_session_destroy(janus_session *session)
Method to destroy a Janus Core-Client session.
Definition: janus.c:649
guint64 session_id
Janus Core-Client session ID.
Definition: janus.h:47
void * request_id
Opaque pointer to the request ID, if available.
Definition: janus.h:124
gchar * janus_get_local_ip(void)
Helper method to return the local IP address (autodetected by default)
Definition: janus.c:178
gboolean admin
Whether this is a Janus API or admin API request.
Definition: janus.h:126
gint janus_session_handles_remove(janus_session *session, janus_handle *handle)
Method to remove a Janus handle from a session.
Definition: janus.c:684
struct janus_session janus_session
Janus Core-Client session.
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:1699