Fork me on GitHub
janus.h
Go to the documentation of this file.
1 
18 #ifndef _JANUS_GATEWAY_H
19 #define _JANUS_GATEWAY_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 "dtls.h"
33 #include "ice.h"
34 #include "sctp.h"
35 #include "transports/transport.h"
36 #include "events/eventhandler.h"
37 #include "plugins/plugin.h"
38 
39 
40 #define JANUS_BUFSIZE 8192
41 
44 
46 typedef struct janus_session {
48  guint64 session_id;
50  GHashTable *ice_handles;
52  gint64 last_activity;
56  volatile gint destroy;
58  volatile gint timeout;
62 
63 
66 
78 void janus_session_notify_event(janus_session *session, json_t *event);
86 gint janus_session_destroy(guint64 session_id);
89 void janus_session_free(janus_session *session);
91 
92 
99 
105  void *instance;
107  void *request_id;
109  gboolean admin;
112 };
120 janus_request *janus_request_new(janus_transport *transport, void *instance, void *request_id, gboolean admin, json_t *message);
124 void janus_request_destroy(janus_request *request);
140 int janus_process_success(janus_request *request, json_t *payload);
151 int janus_process_error(janus_request *request, uint64_t session_id, const char *transaction, gint error, const char *format, ...) G_GNUC_PRINTF(5, 6);
153 
154 
164 
169 void janus_transport_close(void *key, void *value, void *user_data);
174 void janus_transportso_close(void *key, void *value, void *user_data);
176 
186 
191 void janus_eventhandler_close(void *key, void *value, void *user_data);
196 void janus_eventhandlerso_close(void *key, void *value, void *user_data);
198 
207 
212 void janus_plugin_close(void *key, void *value, void *user_data);
217 void janus_pluginso_close(void *key, void *value, void *user_data);
221 janus_plugin *janus_plugin_find(const gchar *package);
223 
225 gchar *janus_get_server_pem(void);
227 gchar *janus_get_server_key(void);
228 
229 
231 gchar *janus_get_local_ip(void);
233 gchar *janus_get_public_ip(void);
235 void janus_set_public_ip(const char *ip);
237 gint janus_is_stopping(void);
238 
239 
240 #endif
gint janus_session_destroy(guint64 session_id)
Method to destroy a Janus Gateway-Client session.
Definition: janus.c:572
gint janus_is_stopping(void)
Helper method to check whether the gateway is being shut down.
Definition: janus.c:164
janus_session * janus_session_find_destroyed(guint64 session_id)
Method to find an existing Janus Gateway-Client session scheduled to be destroyed from its ID...
Definition: janus.c:551
janus_transport * transport
Pointer to the transport plugin.
Definition: janus.h:103
SCTP processing for data channels (headers)
volatile gint timeout
Flag to notify there&#39;s been a session timeout.
Definition: janus.h:58
ICE/STUN/TURN processing (headers)
Modular Janus API transports.
struct json_t json_t
Definition: plugin.h:219
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:2372
void * instance
Opaque pointer to the transport-provided instance.
Definition: janus.h:105
janus_plugin * janus_plugin_find(const gchar *package)
Method to return a registered plugin instance out of its package name.
Definition: janus.c:2752
void janus_request_destroy(janus_request *request)
Helper to destroy a janus_request instance.
Definition: janus.c:615
void janus_set_public_ip(const char *ip)
Helper method to overwrite the IP address to use in the SDP.
Definition: janus.c:156
int janus_process_incoming_request(janus_request *request)
Helper to process an incoming request, no matter where it comes from.
Definition: janus.c:627
gint64 last_activity
Time of the last activity on the session.
Definition: janus.h:52
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.
volatile gint destroy
Flag to trigger a lazy session destruction.
Definition: janus.h:56
janus_session * janus_session_find(guint64 session_id)
Method to find an existing Janus Gateway-Client session from its ID.
Definition: janus.c:544
Plugin-Gateway communication (implementation)
void janus_pluginso_close(void *key, void *value, void *user_data)
Callback (g_hash_table_foreach) invoked when it&#39;s time to close a plugin.
Helper to address requests and their sources (e.g., a specific HTTP connection, websocket, RabbitMQ or others)
Definition: janus.h:101
janus_mutex mutex
Mutex to lock/unlock this session.
Definition: janus.h:60
Gateway-Client session.
Definition: janus.h:46
void janus_plugin_close(void *key, void *value, void *user_data)
Callback (g_hash_table_foreach) invoked when it&#39;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&#39;s time to close a transport plugin.
janus_session * janus_session_create(guint64 session_id)
Method to create a new Janus Gateway-Client session.
Definition: janus.c:516
gchar * janus_get_public_ip(void)
Helper method to return the IP address to use in the SDP (autodetected by default) ...
Definition: janus.c:152
void janus_eventhandlerso_close(void *key, void *value, void *user_data)
Callback (g_hash_table_foreach) invoked when it&#39;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:54
The plugin session and callbacks interface.
Definition: plugin.h:233
GHashTable * ice_handles
Map of handles this session is managing.
Definition: janus.h:50
json_t * message
Pointer to the original request, if available.
Definition: janus.h:111
void janus_transport_close(void *key, void *value, void *user_data)
Callback (g_hash_table_foreach) invoked when it&#39;s time to destroy a transport instance.
gchar * janus_get_server_key(void)
Helper method to return the path to the provided server certificate key.
DTLS/SRTP processing (headers)
void janus_eventhandler_close(void *key, void *value, void *user_data)
Callback (g_hash_table_foreach) invoked when it&#39;s time to destroy an eventhandler instance...
The transport plugin session and callbacks interface.
Definition: transport.h:138
Semaphors, Mutexes and Conditions.
gchar * janus_get_server_pem(void)
Helper method to return the path to the provided server certificate.
pthread_mutex_t janus_mutex
Janus mutex implementation.
Definition: mutex.h:19
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:559
janus_request * janus_request_new(janus_transport *transport, void *instance, void *request_id, gboolean admin, json_t *message)
Helper to allocate a janus_request instance.
Definition: janus.c:605
guint64 session_id
Janus Gateway-Client session ID.
Definition: janus.h:48
void * request_id
Opaque pointer to the request ID, if available.
Definition: janus.h:107
gchar * janus_get_local_ip(void)
Helper method to return the local IP address (autodetected by default)
Definition: janus.c:148
gboolean admin
Whether this is a Janus API or admin API request.
Definition: janus.h:109
void janus_session_free(janus_session *session)
Method to actually free the resources allocated by a Janus Gateway-Client session.
Definition: janus.c:586
struct janus_session janus_session
Gateway-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:1539