Fork me on GitHub
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 14
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 
232 
233 /* Use forward declaration to avoid including jansson.h */
234 typedef struct json_t json_t;
235 
244  volatile gint stopped;
247 };
248 
250 struct janus_plugin {
255  int (* const init)(janus_callbacks *callback, const char *config_path);
257  void (* const destroy)(void);
258 
265  int (* const get_api_compatibility)(void);
267  int (* const get_version)(void);
269  const char *(* const get_version_string)(void);
271  const char *(* const get_description)(void);
273  const char *(* const get_name)(void);
275  const char *(* const get_author)(void);
277  const char *(* const get_package)(void);
278 
282  void (* const create_session)(janus_plugin_session *handle, int *error);
290  struct janus_plugin_result * (* const handle_message)(janus_plugin_session *handle, char *transaction, json_t *message, json_t *jsep);
294  struct json_t * (* const handle_admin_message)(json_t *message);
297  void (* const setup_media)(janus_plugin_session *handle);
301  void (* const incoming_rtp)(janus_plugin_session *handle, janus_plugin_rtp *packet);
305  void (* const incoming_rtcp)(janus_plugin_session *handle, janus_plugin_rtcp *packet);
312  void (* const incoming_data)(janus_plugin_session *handle, janus_plugin_data *packet);
329  void (* const slow_link)(janus_plugin_session *handle, gboolean uplink, gboolean video);
332  void (* const hangup_media)(janus_plugin_session *handle);
336  void (* const destroy_session)(janus_plugin_session *handle, int *error);
343 
344 };
345 
357  int (* const push_event)(janus_plugin_session *handle, janus_plugin *plugin, const char *transaction, json_t *message, json_t *jsep);
358 
362  void (* const relay_rtp)(janus_plugin_session *handle, janus_plugin_rtp *packet);
366  void (* const relay_rtcp)(janus_plugin_session *handle, janus_plugin_rtcp *packet);
370  void (* const relay_data)(janus_plugin_session *handle, janus_plugin_data *packet);
371 
376  void (* const send_pli)(janus_plugin_session *handle);
382  void (* const send_remb)(janus_plugin_session *handle, guint32 bitrate);
383 
388  void (* const close_pc)(janus_plugin_session *handle);
393  void (* const end_session)(janus_plugin_session *handle);
394 
397  gboolean (* const events_is_enabled)(void);
403  void (* const notify_event)(janus_plugin *plugin, janus_plugin_session *handle, json_t *event);
404 
409  gboolean (* const auth_is_signature_valid)(janus_plugin *plugin, const char *token);
415  gboolean (* const auth_signature_contains)(janus_plugin *plugin, const char *token, const char *descriptor);
416 };
417 
419 typedef janus_plugin* create_p(void);
420 
421 
440 
450 
461  const char *text;
470 };
471 
478 
484 
485 
535 
539  int8_t audio_level;
542  gboolean audio_level_vad;
544  int16_t video_rotation;
550  gboolean video_flipped;
551 };
559 
563  gboolean video;
565  char *buffer;
567  uint16_t length;
570 };
577 
581  gboolean video;
583  char *buffer;
585  uint16_t length;
586 };
591 
598  char *label;
600  gboolean binary;
602  char *buffer;
604  uint16_t length;
605 };
611 
612 
613 #endif
janus_plugin_rtp_extensions::video_flipped
gboolean video_flipped
Whether the video orientation extension says it's flipped horizontally.
Definition: plugin.h:550
janus_callbacks::relay_rtcp
void(*const relay_rtcp)(janus_plugin_session *handle, janus_plugin_rtcp *packet)
Callback to relay RTCP messages to a peer.
Definition: plugin.h:366
janus_plugin_result_new
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:20
janus_plugin::setup_media
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:297
janus_plugin
The plugin session and callbacks interface.
Definition: plugin.h:250
JANUS_PLUGIN_OK_WAIT
The request was correctly handled and notifications will follow with more info (asynchronous)
Definition: plugin.h:448
janus_plugin_rtcp::video
gboolean video
Whether this is an audio or video RTCP packet.
Definition: plugin.h:581
janus_plugin::get_author
const char *(*const get_author)(void)
Informative method to request the author of the plugin.
Definition: plugin.h:275
janus_plugin_rtp::buffer
char * buffer
The packet data.
Definition: plugin.h:565
janus_plugin_data
Janus plugin data message.
Definition: plugin.h:596
janus_plugin_rtcp_reset
void janus_plugin_rtcp_reset(janus_plugin_rtcp *packet)
Helper method to initialise/reset the RTCP packet.
Definition: plugin.c:55
janus_plugin_session::stopped
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:244
janus_plugin_result_type
janus_plugin_result_type
Result types.
Definition: plugin.h:442
janus_plugin_rtp_extensions
Janus plugin RTP extensions.
Definition: plugin.h:537
janus_plugin_rtp
Janus plugin RTP packet.
Definition: plugin.h:561
janus_plugin_session::gateway_handle
void * gateway_handle
Opaque pointer to the Janus core-level handle.
Definition: plugin.h:239
janus_plugin_result_destroy
void janus_plugin_result_destroy(janus_plugin_result *result)
Helper to quickly destroy a janus_plugin_result instance.
Definition: plugin.c:29
janus_plugin_rtp_reset
void janus_plugin_rtp_reset(janus_plugin_rtp *packet)
Helper method to initialise/reset the RTP packet.
Definition: plugin.c:49
janus_plugin_session
Plugin-Gateway session mapping.
Definition: plugin.h:237
janus_callbacks::send_remb
void(*const send_remb)(janus_plugin_session *handle, guint32 bitrate)
Helper to ask for a keyframe via a RTCP PLI.
Definition: plugin.h:382
janus_callbacks::notify_event
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:403
janus_plugin_result::content
json_t * content
Result content.
Definition: plugin.h:469
janus_plugin_rtp::length
uint16_t length
The packet length.
Definition: plugin.h:567
janus_plugin::init
int(*const init)(janus_callbacks *callback, const char *config_path)
Plugin initialization/constructor.
Definition: plugin.h:255
JANUS_PLUGIN_ERROR
A severe error happened (not an application level error)
Definition: plugin.h:444
janus_callbacks::push_event
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:357
janus_plugin::handle_message
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:290
janus_plugin_result::text
const char * text
Text associated with this plugin result.
Definition: plugin.h:461
create_p
janus_plugin * create_p(void)
The hook that plugins need to implement to be created from the Janus core.
Definition: plugin.h:419
janus_plugin::get_version_string
const char *(*const get_version_string)(void)
Informative method to request the string version of the plugin.
Definition: plugin.h:269
JANUS_PLUGIN_OK
The request was correctly handled and a response is provided (synchronous)
Definition: plugin.h:446
janus_plugin_rtp::extensions
janus_plugin_rtp_extensions extensions
RTP extensions.
Definition: plugin.h:569
janus_plugin::get_package
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:277
janus_plugin_rtp_extensions_reset
void janus_plugin_rtp_extensions_reset(janus_plugin_rtp_extensions *extensions)
Helper method to initialise/reset the RTP extensions field.
Definition: plugin.c:39
janus_plugin::get_name
const char *(*const get_name)(void)
Informative method to request the name of the plugin.
Definition: plugin.h:273
janus_plugin_rtp::video
gboolean video
Whether this is an audio or video RTP packet.
Definition: plugin.h:563
janus_refcount
Definition: refcount.h:78
janus_plugin_data::length
uint16_t length
The message length.
Definition: plugin.h:604
janus_callbacks::relay_rtp
void(*const relay_rtp)(janus_plugin_session *handle, janus_plugin_rtp *packet)
Callback to relay RTP packets to a peer.
Definition: plugin.h:362
janus_plugin_rtp_extensions::video_back_camera
gboolean video_back_camera
Whether the video orientation extension says this is the back camera.
Definition: plugin.h:547
janus_plugin_result::type
janus_plugin_result_type type
Result type.
Definition: plugin.h:454
janus_plugin::hangup_media
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:332
janus_plugin_data_reset
void janus_plugin_data_reset(janus_plugin_data *packet)
Helper method to initialise/reset the data message.
Definition: plugin.c:59
janus_plugin::get_api_compatibility
int(*const get_api_compatibility)(void)
Informative method to request the API version this plugin was compiled against.
Definition: plugin.h:265
janus_plugin::create_session
void(*const create_session)(janus_plugin_session *handle, int *error)
Method to create a new session/handle for a peer.
Definition: plugin.h:282
janus_plugin::get_description
const char *(*const get_description)(void)
Informative method to request a description of the plugin.
Definition: plugin.h:271
janus_plugin_result
Janus plugin result.
Definition: plugin.h:452
janus_plugin_rtp_extensions::audio_level_vad
gboolean audio_level_vad
Whether the encoder detected voice activity (part of audio-level extension)
Definition: plugin.h:542
janus_plugin::incoming_rtcp
void(*const incoming_rtcp)(janus_plugin_session *handle, janus_plugin_rtcp *packet)
Method to handle an incoming RTCP packet from a peer.
Definition: plugin.h:305
json_t
struct json_t json_t
Definition: plugin.h:234
janus_plugin_rtp_extensions::video_rotation
int16_t video_rotation
Video orientation rotation (0, 90, 180, 270); -1 means no extension.
Definition: plugin.h:544
janus_callbacks::auth_is_signature_valid
gboolean(*const auth_is_signature_valid)(janus_plugin *plugin, const char *token)
Method to check whether a signed token is valid.
Definition: plugin.h:409
janus_callbacks::auth_signature_contains
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:415
janus_callbacks::send_pli
void(*const send_pli)(janus_plugin_session *handle)
Helper to ask for a keyframe via a RTCP PLI.
Definition: plugin.h:376
janus_plugin_rtp_extensions::audio_level
int8_t audio_level
Audio level, in DB (0-127, 127=silence); -1 means no extension.
Definition: plugin.h:539
janus_callbacks::events_is_enabled
gboolean(*const events_is_enabled)(void)
Callback to check whether the event handlers mechanism is enabled.
Definition: plugin.h:397
janus_plugin_rtcp::length
uint16_t length
The packet length.
Definition: plugin.h:585
janus_plugin::destroy
void(*const destroy)(void)
Plugin deinitialization/destructor.
Definition: plugin.h:257
janus_plugin_data::buffer
char * buffer
The message data.
Definition: plugin.h:602
janus_plugin_rtcp::buffer
char * buffer
The packet data.
Definition: plugin.h:583
janus_callbacks
Callbacks to contact the Janus core.
Definition: plugin.h:347
janus_plugin::handle_admin_message
struct json_t *(*const handle_admin_message)(json_t *message)
Method to handle an incoming Admin API message/request.
Definition: plugin.h:294
janus_plugin::get_version
int(*const get_version)(void)
Informative method to request the numeric version of the plugin.
Definition: plugin.h:267
janus_plugin::slow_link
void(*const slow_link)(janus_plugin_session *handle, gboolean uplink, gboolean video)
Method to be notified by the core when too many NACKs have been received or sent by Janus,...
Definition: plugin.h:329
janus_plugin_session::ref
janus_refcount ref
Reference counter for this instance.
Definition: plugin.h:246
janus_plugin_rtcp
Janus plugin RTCP packet.
Definition: plugin.h:579
refcount.h
Reference counter mechanism.
janus_plugin_data::label
char * label
The label this message belongs to.
Definition: plugin.h:598
janus_callbacks::relay_data
void(*const relay_data)(janus_plugin_session *handle, janus_plugin_data *packet)
Callback to relay SCTP/DataChannel messages to a peer.
Definition: plugin.h:370
janus_plugin_data::binary
gboolean binary
Whether the message data is text (default=FALSE) or binary.
Definition: plugin.h:600
janus_plugin::destroy_session
void(*const destroy_session)(janus_plugin_session *handle, int *error)
Method to destroy a session/handle for a peer.
Definition: plugin.h:336
janus_plugin_session::plugin_handle
void * plugin_handle
Opaque pointer to the plugin session.
Definition: plugin.h:241
janus_callbacks::close_pc
void(*const close_pc)(janus_plugin_session *handle)
Callback to ask the core to close a WebRTC PeerConnection.
Definition: plugin.h:388
janus_callbacks::end_session
void(*const end_session)(janus_plugin_session *handle)
Callback to ask the core to get rid of a plugin/gateway session.
Definition: plugin.h:393
janus_plugin::incoming_data
void(*const incoming_data)(janus_plugin_session *handle, janus_plugin_data *packet)
Method to handle incoming SCTP/DataChannel data from a peer (text only, for the moment)
Definition: plugin.h:312
janus_plugin::incoming_rtp
void(*const incoming_rtp)(janus_plugin_session *handle, janus_plugin_rtp *packet)
Method to handle an incoming RTP packet from a peer.
Definition: plugin.h:301
janus_plugin::query_session
json_t *(*const query_session)(janus_plugin_session *handle)
Method to get plugin-specific info of a session/handle.
Definition: plugin.h:342