Loading...
Searching...
No Matches
transport.h
Go to the documentation of this file.
#ifndef JANUS_TRANSPORT_H
#define JANUS_TRANSPORT_H
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <inttypes.h>
#include <glib.h>
#include <jansson.h>
#include "../refcount.h"
#define JANUS_TRANSPORT_API_VERSION 8
#define JANUS_TRANSPORT_INIT(...) { \
.init = NULL, \
.destroy = NULL, \
.get_api_compatibility = NULL, \
.get_version = NULL, \
.get_version_string = NULL, \
.get_description = NULL, \
.get_name = NULL, \
.get_author = NULL, \
.get_package = NULL, \
.is_janus_api_enabled = NULL, \
.is_admin_api_enabled = NULL, \
.send_message = NULL, \
.session_created = NULL, \
.session_over = NULL, \
.session_claimed = NULL, \
.query_transport = NULL, \
## __VA_ARGS__ }
typedef struct janus_transport_callbacks janus_transport_callbacks;
typedef struct janus_transport janus_transport;
typedef struct janus_transport_session janus_transport_session;
struct janus_transport_session {
void *transport_p;
void (*p_free)(void *);
volatile gint destroyed;
janus_mutex mutex;
janus_refcount ref;
};
janus_transport_session *janus_transport_session_create(void *transport_p, void (*p_free)(void *));
void janus_transport_session_destroy(janus_transport_session *session);
struct janus_transport {
int (* const init)(janus_transport_callbacks *callback, const char *config_path);
void (* const destroy)(void);
int (* const get_api_compatibility)(void);
int (* const get_version)(void);
const char *(* const get_version_string)(void);
const char *(* const get_description)(void);
const char *(* const get_name)(void);
const char *(* const get_author)(void);
const char *(* const get_package)(void);
gboolean (* const is_janus_api_enabled)(void);
gboolean (* const is_admin_api_enabled)(void);
int (* const send_message)(janus_transport_session *transport, void *request_id, gboolean admin, json_t *message);
void (* const session_created)(janus_transport_session *transport, guint64 session_id);
void (* const session_over)(janus_transport_session *transport, guint64 session_id, gboolean timeout, gboolean claimed);
void (* const session_claimed)(janus_transport_session *transport, guint64 session_id);
json_t *(* const query_transport)(json_t *request);
};
struct janus_transport_callbacks {
void (* const incoming_request)(janus_transport *plugin, janus_transport_session *transport, void *request_id, gboolean admin, json_t *message, json_error_t *error);
void (* const transport_gone)(janus_transport *plugin, janus_transport_session *transport);
gboolean (* const is_api_secret_needed)(janus_transport *plugin);
gboolean (* const is_api_secret_valid)(janus_transport *plugin, const char *apisecret);
gboolean (* const is_auth_token_needed)(janus_transport *plugin);
gboolean (* const is_auth_token_valid)(janus_transport *plugin, const char *token);
gboolean (* const events_is_enabled)(void);
void (* const notify_event)(janus_transport *plugin, void *transport, json_t *event);
};
typedef janus_transport* create_t(void);
#endif
janus_mutex
GMutex janus_mutex
Janus mutex implementation.
Definition mutex.h:73
json_t
struct json_t json_t
Definition plugin.h:236
refcount.h
Reference counter mechanism.
janus_refcount
Definition refcount.h:78
janus_transport_callbacks
Callbacks to contact the Janus core.
Definition transport.h:250
janus_transport_callbacks::notify_event
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
janus_transport_callbacks::is_api_secret_needed
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
janus_transport_callbacks::is_api_secret_valid
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
janus_transport_callbacks::is_auth_token_needed
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
janus_transport_callbacks::transport_gone
void(*const transport_gone)(janus_transport *plugin, janus_transport_session *transport)
Callback to notify an existing transport instance went away.
Definition transport.h:267
janus_transport_callbacks::incoming_request
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
janus_transport_callbacks::events_is_enabled
gboolean(*const events_is_enabled)(void)
Callback to check whether the event handlers mechanism is enabled.
Definition transport.h:294
janus_transport_callbacks::is_auth_token_valid
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
janus_transport_session
Transport-Gateway session mapping.
Definition transport.h:145
janus_transport_session::destroyed
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
janus_transport_session::p_free
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_transport_session::ref
janus_refcount ref
Reference counter for this instance.
Definition transport.h:156
janus_transport_session::transport_p
void * transport_p
Opaque pointer to the transport session.
Definition transport.h:147
janus_transport_session::mutex
janus_mutex mutex
Mutex to protect changes to transport_p.
Definition transport.h:154
janus_transport
The transport plugin session and callbacks interface.
Definition transport.h:175
janus_transport::is_admin_api_enabled
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
janus_transport::session_over
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
janus_transport::send_message
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
janus_transport::init
int(*const init)(janus_transport_callbacks *callback, const char *config_path)
Transport plugin initialization/constructor.
Definition transport.h:180
janus_transport::session_claimed
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
janus_transport::get_name
const char *(*const get_name)(void)
Informative method to request the name of the transport plugin.
Definition transport.h:195
janus_transport::session_created
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
janus_transport::get_version_string
const char *(*const get_version_string)(void)
Informative method to request the string version of the transport plugin.
Definition transport.h:191
janus_transport::query_transport
json_t *(*const query_transport)(json_t *request)
Method to send a management request to this specific transport plugin.
Definition transport.h:245
janus_transport::get_version
int(*const get_version)(void)
Informative method to request the numeric version of the transport plugin.
Definition transport.h:189
janus_transport::get_api_compatibility
int(*const get_api_compatibility)(void)
Informative method to request the API version this transport plugin was compiled against.
Definition transport.h:187
janus_transport::get_author
const char *(*const get_author)(void)
Informative method to request the author of the transport plugin.
Definition transport.h:197
janus_transport::get_description
const char *(*const get_description)(void)
Informative method to request a description of the transport plugin.
Definition transport.h:193
janus_transport::is_janus_api_enabled
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
janus_transport::get_package
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
janus_transport::destroy
void(*const destroy)(void)
Transport plugin deinitialization/destructor.
Definition transport.h:182
janus_transport_session_destroy
void janus_transport_session_destroy(janus_transport_session *session)
Helper to mark a janus_transport_session instance as destroyed.
Definition transport.c:37
create_t
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_create
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:25