Fork me on GitHub
Loading...
Searching...
No Matches
transport.h
Go to the documentation of this file.
1
82#ifndef JANUS_TRANSPORT_H
83#define JANUS_TRANSPORT_H
84
85#include <stdlib.h>
86#include <stdint.h>
87#include <stdio.h>
88#include <string.h>
89#include <ctype.h>
90#include <unistd.h>
91#include <inttypes.h>
92
93#include <glib.h>
94#include <jansson.h>
95
96#include "refcount.h"
97
98
100#define JANUS_TRANSPORT_API_VERSION 8
101
116#define JANUS_TRANSPORT_INIT(...) { \
117 .init = NULL, \
118 .destroy = NULL, \
119 .get_api_compatibility = NULL, \
120 .get_version = NULL, \
121 .get_version_string = NULL, \
122 .get_description = NULL, \
123 .get_name = NULL, \
124 .get_author = NULL, \
125 .get_package = NULL, \
126 .is_janus_api_enabled = NULL, \
127 .is_admin_api_enabled = NULL, \
128 .send_message = NULL, \
129 .session_created = NULL, \
130 .session_over = NULL, \
131 .session_claimed = NULL, \
132 .query_transport = NULL, \
133 ## __VA_ARGS__ }
134
135
142
143
149 void (*p_free)(void *);
152 volatile gint destroyed;
157};
163janus_transport_session *janus_transport_session_create(void *transport_p, void (*p_free)(void *));
172
173
180 int (* const init)(janus_transport_callbacks *callback, const char *config_path);
182 void (* const destroy)(void);
183
187 int (* const get_api_compatibility)(void);
189 int (* const get_version)(void);
191 const char *(* const get_version_string)(void);
193 const char *(* const get_description)(void);
195 const char *(* const get_name)(void);
197 const char *(* const get_author)(void);
199 const char *(* const get_package)(void);
200
202 gboolean (* const is_janus_api_enabled)(void);
204 gboolean (* const is_admin_api_enabled)(void);
205
215 int (* const send_message)(janus_transport_session *transport, void *request_id, gboolean admin, json_t *message);
220 void (* const session_created)(janus_transport_session *transport, guint64 session_id);
227 void (* const session_over)(janus_transport_session *transport, guint64 session_id, gboolean timeout, gboolean claimed);
232 void (* const session_claimed)(janus_transport_session *transport, guint64 session_id);
233
245 json_t *(* const query_transport)(json_t *request);
246
247};
248
257 void (* const incoming_request)(janus_transport *plugin, janus_transport_session *transport, void *request_id, gboolean admin, json_t *message, json_error_t *error);
267 void (* const transport_gone)(janus_transport *plugin, janus_transport_session *transport);
271 gboolean (* const is_api_secret_needed)(janus_transport *plugin);
279 gboolean (* const is_api_secret_valid)(janus_transport *plugin, const char *apisecret);
282 gboolean (* const is_auth_token_needed)(janus_transport *plugin);
290 gboolean (* const is_auth_token_valid)(janus_transport *plugin, const char *token);
291
294 gboolean (* const events_is_enabled)(void);
299 void (* const notify_event)(janus_transport *plugin, void *transport, json_t *event);
300};
301
304
305#endif
GMutex janus_mutex
Janus mutex implementation.
Definition: mutex.h:73
struct json_t json_t
Definition: plugin.h:236
Reference counter mechanism.
Definition: refcount.h:78
Callbacks to contact the Janus core.
Definition: transport.h:250
void(*const notify_event)(janus_transport *plugin, void *transport, json_t *event)
Callback to notify an event to the registered and subscribed event handlers.
Definition: transport.h:299
gboolean(*const is_api_secret_needed)(janus_transport *plugin)
Callback to check with the core if an API secret must be provided.
Definition: transport.h:271
gboolean(*const is_api_secret_valid)(janus_transport *plugin, const char *apisecret)
Callback to check with the core if a provided API secret is valid.
Definition: transport.h:279
gboolean(*const is_auth_token_needed)(janus_transport *plugin)
Callback to check with the core if an authentication token is needed.
Definition: transport.h:282
void(*const transport_gone)(janus_transport *plugin, janus_transport_session *transport)
Callback to notify an existing transport instance went away.
Definition: transport.h:267
void(*const incoming_request)(janus_transport *plugin, janus_transport_session *transport, void *request_id, gboolean admin, json_t *message, json_error_t *error)
Callback to notify a new incoming request.
Definition: transport.h:257
gboolean(*const events_is_enabled)(void)
Callback to check whether the event handlers mechanism is enabled.
Definition: transport.h:294
gboolean(*const is_auth_token_valid)(janus_transport *plugin, const char *token)
Callback to check with the core if a provided authentication token is valid.
Definition: transport.h:290
Transport-Gateway session mapping.
Definition: transport.h:145
volatile gint destroyed
Whether this mapping has been destroyed definitely or not: if so, the transport shouldn't make use of...
Definition: transport.h:152
void(* p_free)(void *)
Pointer to the transport-provided function, if needed, that will be used to free the opaque transport...
Definition: transport.h:149
janus_refcount ref
Reference counter for this instance.
Definition: transport.h:156
void * transport_p
Opaque pointer to the transport session.
Definition: transport.h:147
janus_mutex mutex
Mutex to protect changes to transport_p.
Definition: transport.h:154
The transport plugin session and callbacks interface.
Definition: transport.h:175
gboolean(*const is_admin_api_enabled)(void)
Informative method to check whether any Admin API support is currently enabled in this transport.
Definition: transport.h:204
void(*const session_over)(janus_transport_session *transport, guint64 session_id, gboolean timeout, gboolean claimed)
Method to notify the transport plugin that a session it originated timed out.
Definition: transport.h:227
int(*const send_message)(janus_transport_session *transport, void *request_id, gboolean admin, json_t *message)
Method to send a message to a client over a transport session.
Definition: transport.h:215
int(*const init)(janus_transport_callbacks *callback, const char *config_path)
Transport plugin initialization/constructor.
Definition: transport.h:180
void(*const session_claimed)(janus_transport_session *transport, guint64 session_id)
Method to notify the transport plugin that a session it owned was claimed by another transport.
Definition: transport.h:232
const char *(*const get_name)(void)
Informative method to request the name of the transport plugin.
Definition: transport.h:195
void(*const session_created)(janus_transport_session *transport, guint64 session_id)
Method to notify the transport plugin that a new session has been created from this transport.
Definition: transport.h:220
const char *(*const get_version_string)(void)
Informative method to request the string version of the transport plugin.
Definition: transport.h:191
json_t *(*const query_transport)(json_t *request)
Method to send a management request to this specific transport plugin.
Definition: transport.h:245
int(*const get_version)(void)
Informative method to request the numeric version of the transport plugin.
Definition: transport.h:189
int(*const get_api_compatibility)(void)
Informative method to request the API version this transport plugin was compiled against.
Definition: transport.h:187
const char *(*const get_author)(void)
Informative method to request the author of the transport plugin.
Definition: transport.h:197
const char *(*const get_description)(void)
Informative method to request a description of the transport plugin.
Definition: transport.h:193
gboolean(*const is_janus_api_enabled)(void)
Informative method to check whether any Janus API support is currently enabled in this transport.
Definition: transport.h:202
const char *(*const get_package)(void)
Informative method to request the package name of the transport plugin (what will be used in web appl...
Definition: transport.h:199
void(*const destroy)(void)
Transport plugin deinitialization/destructor.
Definition: transport.h:182
void janus_transport_session_destroy(janus_transport_session *session)
Helper to mark a janus_transport_session instance as destroyed.
Definition: transport.c:36
janus_transport * create_t(void)
The hook that transport plugins need to implement to be created from the Janus core.
Definition: transport.h:303
janus_transport_session * janus_transport_session_create(void *transport_p, void(*p_free)(void *))
Helper to create a janus_transport_session instance.
Definition: transport.c:24