Fork me on GitHub
plugin.h
Go to the documentation of this file.
1 
147 #ifndef _JANUS_PLUGIN_H
148 #define _JANUS_PLUGIN_H
149 
150 #include <stdlib.h>
151 #include <stdint.h>
152 #include <stdio.h>
153 #include <string.h>
154 #include <ctype.h>
155 #include <unistd.h>
156 #include <inttypes.h>
157 
158 #include <glib.h>
159 
160 #include "refcount.h"
161 
162 
172 #define JANUS_PLUGIN_API_VERSION 10
173 
190 #define JANUS_PLUGIN_INIT(...) { \
191  .init = NULL, \
192  .destroy = NULL, \
193  .get_api_compatibility = NULL, \
194  .get_version = NULL, \
195  .get_version_string = NULL, \
196  .get_description = NULL, \
197  .get_name = NULL, \
198  .get_author = NULL, \
199  .get_package = NULL, \
200  .create_session = NULL, \
201  .handle_message = NULL, \
202  .setup_media = NULL, \
203  .incoming_rtp = NULL, \
204  .incoming_rtcp = NULL, \
205  .incoming_data = NULL, \
206  .slow_link = NULL, \
207  .hangup_media = NULL, \
208  .destroy_session = NULL, \
209  .query_session = NULL, \
210  ## __VA_ARGS__ }
211 
212 
216 typedef struct janus_plugin janus_plugin;
221 
222 /* Use forward declaration to avoid including jansson.h */
223 typedef struct json_t json_t;
224 
233  volatile gint stopped;
236 };
237 
239 struct janus_plugin {
244  int (* const init)(janus_callbacks *callback, const char *config_path);
246  void (* const destroy)(void);
247 
254  int (* const get_api_compatibility)(void);
256  int (* const get_version)(void);
258  const char *(* const get_version_string)(void);
260  const char *(* const get_description)(void);
262  const char *(* const get_name)(void);
264  const char *(* const get_author)(void);
266  const char *(* const get_package)(void);
267 
271  void (* const create_session)(janus_plugin_session *handle, int *error);
279  struct janus_plugin_result * (* const handle_message)(janus_plugin_session *handle, char *transaction, json_t *message, json_t *jsep);
282  void (* const setup_media)(janus_plugin_session *handle);
288  void (* const incoming_rtp)(janus_plugin_session *handle, int video, char *buf, int len);
294  void (* const incoming_rtcp)(janus_plugin_session *handle, int video, char *buf, int len);
302  void (* const incoming_data)(janus_plugin_session *handle, char *buf, int len);
319  void (* const slow_link)(janus_plugin_session *handle, int uplink, int video);
322  void (* const hangup_media)(janus_plugin_session *handle);
326  void (* const destroy_session)(janus_plugin_session *handle, int *error);
333 
334 };
335 
347  int (* const push_event)(janus_plugin_session *handle, janus_plugin *plugin, const char *transaction, json_t *message, json_t *jsep);
348 
354  void (* const relay_rtp)(janus_plugin_session *handle, int video, char *buf, int len);
360  void (* const relay_rtcp)(janus_plugin_session *handle, int video, char *buf, int len);
365  void (* const relay_data)(janus_plugin_session *handle, char *buf, int len);
366 
371  void (* const close_pc)(janus_plugin_session *handle);
376  void (* const end_session)(janus_plugin_session *handle);
377 
380  gboolean (* const events_is_enabled)(void);
386  void (* const notify_event)(janus_plugin *plugin, janus_plugin_session *handle, json_t *event);
387 
392  gboolean (* const auth_is_signature_valid)(janus_plugin *plugin, const char *token);
398  gboolean (* const auth_signature_contains)(janus_plugin *plugin, const char *token, const char *descriptor);
399 };
400 
402 typedef janus_plugin* create_p(void);
403 
404 
423 
433 
437  janus_plugin_result_type type;
444  const char *text;
453 };
454 
460 janus_plugin_result *janus_plugin_result_new(janus_plugin_result_type type, const char *text, json_t *content);
461 
467 
468 
469 #endif
The request was correctly handled and a response is provided (synchronous)
Definition: plugin.h:429
volatile gint stopped
Whether this mapping has been stopped definitely or not: if so, the plugin shouldn&#39;t make use of it a...
Definition: plugin.h:233
Reference counter mechanism.
json_t *(*const query_session)(janus_plugin_session *handle)
Method to get plugin-specific info of a session/handle.
Definition: plugin.h:332
struct json_t json_t
Definition: plugin.h:223
void * gateway_handle
Opaque pointer to the Janus core-level handle.
Definition: plugin.h:228
const char *(*const get_author)(void)
Informative method to request the author of the plugin.
Definition: plugin.h:264
const char *(*const get_version_string)(void)
Informative method to request the string version of the plugin.
Definition: plugin.h:258
const char *(*const get_name)(void)
Informative method to request the name of the plugin.
Definition: plugin.h:262
Definition: refcount.h:78
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:435
janus_plugin_result_type
Result types.
Definition: plugin.h:425
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:266
The request was correctly handled and notifications will follow with more info (asynchronous) ...
Definition: plugin.h:431
The plugin session and callbacks interface.
Definition: plugin.h:239
const char *(*const get_description)(void)
Informative method to request a description of the plugin.
Definition: plugin.h:260
json_t * content
Result content.
Definition: plugin.h:452
A severe error happened (not an application level error)
Definition: plugin.h:427
janus_refcount ref
Reference counter for this instance.
Definition: plugin.h:235
janus_plugin * create_p(void)
The hook that plugins need to implement to be created from the Janus core.
Definition: plugin.h:402
Callbacks to contact the Janus core.
Definition: plugin.h:337
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 * plugin_handle
Opaque pointer to the plugin session.
Definition: plugin.h:230
Plugin-Gateway session mapping.
Definition: plugin.h:226
const char * text
Text associated with this plugin result.
Definition: plugin.h:444
janus_plugin_result_type type
Result type.
Definition: plugin.h:437