Fork me on GitHub
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
plugin.h
Go to the documentation of this file.
1 
148 #ifndef JANUS_PLUGIN_H
149 #define JANUS_PLUGIN_H
150 
151 #include <stdlib.h>
152 #include <stdint.h>
153 #include <stdio.h>
154 #include <string.h>
155 #include <ctype.h>
156 #include <unistd.h>
157 #include <inttypes.h>
158 
159 #include <glib.h>
160 
161 #include "refcount.h"
162 
163 
173 #define JANUS_PLUGIN_API_VERSION 13
174 
191 #define JANUS_PLUGIN_INIT(...) { \
192  .init = NULL, \
193  .destroy = NULL, \
194  .get_api_compatibility = NULL, \
195  .get_version = NULL, \
196  .get_version_string = NULL, \
197  .get_description = NULL, \
198  .get_name = NULL, \
199  .get_author = NULL, \
200  .get_package = NULL, \
201  .create_session = NULL, \
202  .handle_message = NULL, \
203  .handle_admin_message = NULL, \
204  .setup_media = NULL, \
205  .incoming_rtp = NULL, \
206  .incoming_rtcp = NULL, \
207  .incoming_data = NULL, \
208  .slow_link = NULL, \
209  .hangup_media = NULL, \
210  .destroy_session = NULL, \
211  .query_session = NULL, \
212  ## __VA_ARGS__ }
213 
214 
218 typedef struct janus_plugin janus_plugin;
223 
224 /* Use forward declaration to avoid including jansson.h */
225 typedef struct json_t json_t;
226 
235  volatile gint stopped;
238 };
239 
241 struct janus_plugin {
246  int (* const init)(janus_callbacks *callback, const char *config_path);
248  void (* const destroy)(void);
249 
256  int (* const get_api_compatibility)(void);
258  int (* const get_version)(void);
260  const char *(* const get_version_string)(void);
262  const char *(* const get_description)(void);
264  const char *(* const get_name)(void);
266  const char *(* const get_author)(void);
268  const char *(* const get_package)(void);
269 
273  void (* const create_session)(janus_plugin_session *handle, int *error);
281  struct janus_plugin_result * (* const handle_message)(janus_plugin_session *handle, char *transaction, json_t *message, json_t *jsep);
285  struct json_t * (* const handle_admin_message)(json_t *message);
288  void (* const setup_media)(janus_plugin_session *handle);
295  void (* const incoming_rtp)(janus_plugin_session *handle, int mindex, gboolean video, char *buf, int len);
302  void (* const incoming_rtcp)(janus_plugin_session *handle, int mindex, gboolean video, char *buf, int len);
311  void (* const incoming_data)(janus_plugin_session *handle, char *label, char *buf, int len);
328  void (* const slow_link)(janus_plugin_session *handle, int mindex, gboolean video, gboolean uplink);
331  void (* const hangup_media)(janus_plugin_session *handle);
335  void (* const destroy_session)(janus_plugin_session *handle, int *error);
342 
343 };
344 
356  int (* const push_event)(janus_plugin_session *handle, janus_plugin *plugin, const char *transaction, json_t *message, json_t *jsep);
357 
364  void (* const relay_rtp)(janus_plugin_session *handle, int mindex, gboolean video, char *buf, int len);
371  void (* const relay_rtcp)(janus_plugin_session *handle, int mindex, gboolean video, char *buf, int len);
378  void (* const relay_data)(janus_plugin_session *handle, char *label, char *buf, int len);
379 
384  void (* const close_pc)(janus_plugin_session *handle);
389  void (* const end_session)(janus_plugin_session *handle);
390 
393  gboolean (* const events_is_enabled)(void);
399  void (* const notify_event)(janus_plugin *plugin, janus_plugin_session *handle, json_t *event);
400 
405  gboolean (* const auth_is_signature_valid)(janus_plugin *plugin, const char *token);
411  gboolean (* const auth_signature_contains)(janus_plugin *plugin, const char *token, const char *descriptor);
412 };
413 
415 typedef janus_plugin* create_p(void);
416 
417 
436 
446 
457  const char *text;
466 };
467 
474 
480 
481 
482 #endif
int(*const push_event)(janus_plugin_session *handle, janus_plugin *plugin, const char *transaction, json_t *message, json_t *jsep)
Callback to push events/messages to a peer.
Definition: plugin.h:356
void(*const close_pc)(janus_plugin_session *handle)
Callback to ask the core to close a WebRTC PeerConnection.
Definition: plugin.h:384
void(*const incoming_data)(janus_plugin_session *handle, char *label, char *buf, int len)
Method to handle incoming SCTP/DataChannel data from a peer (text only, for the moment) ...
Definition: plugin.h:311
The request was correctly handled and a response is provided (synchronous)
Definition: plugin.h:442
void(*const setup_media)(janus_plugin_session *handle)
Callback to be notified when the associated PeerConnection is up and ready to be used.
Definition: plugin.h:288
void(*const slow_link)(janus_plugin_session *handle, int mindex, gboolean video, gboolean uplink)
Method to be notified by the core when too many NACKs have been received or sent by Janus...
Definition: plugin.h:328
volatile gint stopped
Whether this mapping has been stopped definitely or not: if so, the plugin shouldn't make use of it a...
Definition: plugin.h:235
Reference counter mechanism.
struct json_t json_t
Definition: plugin.h:225
void * gateway_handle
Opaque pointer to the Janus core-level handle.
Definition: plugin.h:230
void(*const incoming_rtcp)(janus_plugin_session *handle, int mindex, gboolean video, char *buf, int len)
Method to handle an incoming RTCP packet from a peer.
Definition: plugin.h:302
struct janus_plugin_result *(*const handle_message)(janus_plugin_session *handle, char *transaction, json_t *message, json_t *jsep)
Method to handle an incoming message/request from a peer.
Definition: plugin.h:281
gboolean(*const events_is_enabled)(void)
Callback to check whether the event handlers mechanism is enabled.
Definition: plugin.h:393
const char *(*const get_description)(void)
Informative method to request a description of the plugin.
Definition: plugin.h:262
void(*const relay_data)(janus_plugin_session *handle, char *label, char *buf, int len)
Callback to relay SCTP/DataChannel messages to a peer.
Definition: plugin.h:378
Definition: refcount.h:78
const char *(*const get_name)(void)
Informative method to request the name of the plugin.
Definition: plugin.h:264
void janus_plugin_result_destroy(janus_plugin_result *result)
Helper to quickly destroy a janus_plugin_result instance.
Definition: plugin.c:32
Janus plugin result.
Definition: plugin.h:448
int(*const init)(janus_callbacks *callback, const char *config_path)
Plugin initialization/constructor.
Definition: plugin.h:246
janus_plugin_result_type
Result types.
Definition: plugin.h:438
const char *(*const get_author)(void)
Informative method to request the author of the plugin.
Definition: plugin.h:266
void(*const destroy_session)(janus_plugin_session *handle, int *error)
Method to destroy a session/handle for a peer.
Definition: plugin.h:335
The request was correctly handled and notifications will follow with more info (asynchronous) ...
Definition: plugin.h:444
The plugin session and callbacks interface.
Definition: plugin.h:241
const char *(*const get_package)(void)
Informative method to request the package name of the plugin (what will be used in web applications t...
Definition: plugin.h:268
json_t * content
Result content.
Definition: plugin.h:465
void(*const notify_event)(janus_plugin *plugin, janus_plugin_session *handle, json_t *event)
Callback to notify an event to the registered and subscribed event handlers.
Definition: plugin.h:399
int(*const get_version)(void)
Informative method to request the numeric version of the plugin.
Definition: plugin.h:258
A severe error happened (not an application level error)
Definition: plugin.h:440
int(*const get_api_compatibility)(void)
Informative method to request the API version this plugin was compiled against.
Definition: plugin.h:256
janus_refcount ref
Reference counter for this instance.
Definition: plugin.h:237
void(*const relay_rtcp)(janus_plugin_session *handle, int mindex, gboolean video, char *buf, int len)
Callback to relay RTCP messages to a peer.
Definition: plugin.h:371
janus_plugin * create_p(void)
The hook that plugins need to implement to be created from the Janus core.
Definition: plugin.h:415
Callbacks to contact the Janus core.
Definition: plugin.h:346
gboolean(*const auth_is_signature_valid)(janus_plugin *plugin, const char *token)
Method to check whether a signed token is valid.
Definition: plugin.h:405
janus_plugin_result * janus_plugin_result_new(janus_plugin_result_type type, const char *text, json_t *content)
Helper to quickly create a janus_plugin_result instance.
Definition: plugin.c:19
void(*const relay_rtp)(janus_plugin_session *handle, int mindex, gboolean video, char *buf, int len)
Callback to relay RTP packets to a peer.
Definition: plugin.h:364
void * plugin_handle
Opaque pointer to the plugin session.
Definition: plugin.h:232
void(*const incoming_rtp)(janus_plugin_session *handle, int mindex, gboolean video, char *buf, int len)
Method to handle an incoming RTP packet from a peer.
Definition: plugin.h:295
Plugin-Gateway session mapping.
Definition: plugin.h:228
const char * text
Text associated with this plugin result.
Definition: plugin.h:457
json_t *(*const query_session)(janus_plugin_session *handle)
Method to get plugin-specific info of a session/handle.
Definition: plugin.h:341
void(*const destroy)(void)
Plugin deinitialization/destructor.
Definition: plugin.h:248
void(*const hangup_media)(janus_plugin_session *handle)
Callback to be notified about DTLS alerts from a peer (i.e., the PeerConnection is not valid any more...
Definition: plugin.h:331
const char *(*const get_version_string)(void)
Informative method to request the string version of the plugin.
Definition: plugin.h:260
janus_plugin_result_type type
Result type.
Definition: plugin.h:450
struct json_t *(*const handle_admin_message)(json_t *message)
Method to handle an incoming Admin API message/request.
Definition: plugin.h:285
gboolean(*const auth_signature_contains)(janus_plugin *plugin, const char *token, const char *descriptor)
Method to verify a signed token grants access to a descriptor.
Definition: plugin.h:411
void(*const end_session)(janus_plugin_session *handle)
Callback to ask the core to get rid of a plugin/gateway session.
Definition: plugin.h:389
void(*const create_session)(janus_plugin_session *handle, int *error)
Method to create a new session/handle for a peer.
Definition: plugin.h:273