Fork me on GitHub
plugin.h
Go to the documentation of this file.
1 
149 #ifndef JANUS_PLUGIN_H
150 #define JANUS_PLUGIN_H
151 
152 #include <stdlib.h>
153 #include <stdint.h>
154 #include <stdio.h>
155 #include <string.h>
156 #include <ctype.h>
157 #include <unistd.h>
158 #include <inttypes.h>
159 
160 #include <glib.h>
161 
162 #include "../refcount.h"
163 
164 
174 #define JANUS_PLUGIN_API_VERSION 106
175 
192 #define JANUS_PLUGIN_INIT(...) { \
193  .init = NULL, \
194  .destroy = NULL, \
195  .get_api_compatibility = NULL, \
196  .get_version = NULL, \
197  .get_version_string = NULL, \
198  .get_description = NULL, \
199  .get_name = NULL, \
200  .get_author = NULL, \
201  .get_package = NULL, \
202  .create_session = NULL, \
203  .handle_message = NULL, \
204  .handle_admin_message = NULL, \
205  .setup_media = NULL, \
206  .incoming_rtp = NULL, \
207  .incoming_rtcp = NULL, \
208  .incoming_data = NULL, \
209  .data_ready = NULL, \
210  .slow_link = NULL, \
211  .hangup_media = NULL, \
212  .destroy_session = NULL, \
213  .query_session = NULL, \
214  ## __VA_ARGS__ }
215 
216 
220 typedef struct janus_plugin janus_plugin;
225 
234 
235 /* Use forward declaration to avoid including jansson.h */
236 typedef struct json_t json_t;
237 
246  volatile gint stopped;
249 };
250 
252 struct janus_plugin {
257  int (* const init)(janus_callbacks *callback, const char *config_path);
259  void (* const destroy)(void);
260 
267  int (* const get_api_compatibility)(void);
269  int (* const get_version)(void);
271  const char *(* const get_version_string)(void);
273  const char *(* const get_description)(void);
275  const char *(* const get_name)(void);
277  const char *(* const get_author)(void);
279  const char *(* const get_package)(void);
280 
284  void (* const create_session)(janus_plugin_session *handle, int *error);
296  struct janus_plugin_result * (* const handle_message)(janus_plugin_session *handle, char *transaction, json_t *message, json_t *jsep);
300  struct json_t * (* const handle_admin_message)(json_t *message);
303  void (* const setup_media)(janus_plugin_session *handle);
307  void (* const incoming_rtp)(janus_plugin_session *handle, janus_plugin_rtp *packet);
311  void (* const incoming_rtcp)(janus_plugin_session *handle, janus_plugin_rtcp *packet);
318  void (* const incoming_data)(janus_plugin_session *handle, janus_plugin_data *packet);
323  void (* const data_ready)(janus_plugin_session *handle);
341  void (* const slow_link)(janus_plugin_session *handle, int mindex, gboolean video, gboolean uplink);
344  void (* const hangup_media)(janus_plugin_session *handle);
348  void (* const destroy_session)(janus_plugin_session *handle, int *error);
355 
356 };
357 
369  int (* const push_event)(janus_plugin_session *handle, janus_plugin *plugin, const char *transaction, json_t *message, json_t *jsep);
370 
374  void (* const relay_rtp)(janus_plugin_session *handle, janus_plugin_rtp *packet);
378  void (* const relay_rtcp)(janus_plugin_session *handle, janus_plugin_rtcp *packet);
385  void (* const relay_data)(janus_plugin_session *handle, janus_plugin_data *packet);
386 
391  void (* const send_pli)(janus_plugin_session *handle);
398  void (* const send_pli_stream)(janus_plugin_session *handle, int mindex);
404  void (* const send_remb)(janus_plugin_session *handle, guint32 bitrate);
405 
411  void (* const close_pc)(janus_plugin_session *handle);
416  void (* const end_session)(janus_plugin_session *handle);
417 
420  gboolean (* const events_is_enabled)(void);
426  void (* const notify_event)(janus_plugin *plugin, janus_plugin_session *handle, json_t *event);
427 
430  gboolean (* const auth_is_signed)(void);
435  gboolean (* const auth_is_signature_valid)(janus_plugin *plugin, const char *token);
441  gboolean (* const auth_signature_contains)(janus_plugin *plugin, const char *token, const char *descriptor);
442 };
443 
445 typedef janus_plugin* create_p(void);
446 
447 
466 
476 
487  const char *text;
496 };
497 
504 
509 
510 
560 
564  int8_t audio_level;
567  gboolean audio_level_vad;
569  int16_t video_rotation;
575  gboolean video_flipped;
579  uint8_t dd_len;
581  uint8_t dd_content[256];
583  uint64_t abs_capture_ts;
584 };
592 
601  int mindex;
603  gboolean video;
605  char *buffer;
607  uint16_t length;
610 };
624 
633  int mindex;
635  gboolean video;
637  char *buffer;
639  uint16_t length;
640 };
645 
652  char *label;
654  char *protocol;
656  gboolean binary;
658  char *buffer;
660  uint16_t length;
661 };
667 
668 
669 #endif
void(*const relay_data)(janus_plugin_session *handle, janus_plugin_data *packet)
Callback to relay SCTP/DataChannel messages to a peer.
Definition: plugin.h:385
void janus_plugin_rtp_reset(janus_plugin_rtp *packet)
Helper method to initialise/reset the RTP packet.
Definition: plugin.c:53
gboolean video
Whether this is an audio or video RTP packet.
Definition: plugin.h:603
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:303
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:318
The request was correctly handled and a response is provided (synchronous)
Definition: plugin.h:472
Janus plugin data message.
Definition: plugin.h:650
char * buffer
The message data.
Definition: plugin.h:658
gboolean video
Whether this is an audio or video RTCP packet.
Definition: plugin.h:635
void(*const end_session)(janus_plugin_session *handle)
Callback to ask the core to get rid of a plugin/gateway session.
Definition: plugin.h:416
uint16_t length
The packet length.
Definition: plugin.h:607
int mindex
Index of the stream (relative to the SDP)
Definition: plugin.h:601
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:246
json_t *(*const query_session)(janus_plugin_session *handle)
Method to get plugin-specific info of a session/handle.
Definition: plugin.h:354
struct json_t json_t
Definition: plugin.h:236
void * gateway_handle
Opaque pointer to the Janus core-level handle.
Definition: plugin.h:241
int16_t min_delay
Min and max playout delay, if available; -1 means no extension.
Definition: plugin.h:577
void janus_plugin_data_reset(janus_plugin_data *packet)
Helper method to initialise/reset the data message.
Definition: plugin.c:84
Janus plugin RTP packet.
Definition: plugin.h:594
const char *(*const get_author)(void)
Informative method to request the author of the plugin.
Definition: plugin.h:277
void(*const send_remb)(janus_plugin_session *handle, guint32 bitrate)
Helper to ask for a keyframe via a RTCP PLI.
Definition: plugin.h:404
const char *(*const get_version_string)(void)
Informative method to request the string version of the plugin.
Definition: plugin.h:271
const char *(*const get_name)(void)
Informative method to request the name of the plugin.
Definition: plugin.h:275
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:369
janus_plugin_rtp * janus_plugin_rtp_duplicate(janus_plugin_rtp *packet)
Helper method to duplicate the RTP packet and its buffer.
Definition: plugin.c:60
Definition: refcount.h:78
void(*const send_pli_stream)(janus_plugin_session *handle, int mindex)
Helper to ask for a keyframe via a RTCP PLI to a specific video stream.
Definition: plugin.h:398
int16_t max_delay
Definition: plugin.h:577
void janus_plugin_result_destroy(janus_plugin_result *result)
Helper to quickly destroy a janus_plugin_result instance.
Definition: plugin.c:29
Janus plugin result.
Definition: plugin.h:478
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:341
int(*const init)(janus_callbacks *callback, const char *config_path)
Plugin initialization/constructor.
Definition: plugin.h:257
gboolean audio_level_vad
Whether the encoder detected voice activity (part of audio-level extension)
Definition: plugin.h:567
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:426
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:296
janus_plugin_result_type
Result types.
Definition: plugin.h:468
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:279
The request was correctly handled and notifications will follow with more info (asynchronous) ...
Definition: plugin.h:474
The plugin session and callbacks interface.
Definition: plugin.h:252
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:344
char * label
The label this message belongs to.
Definition: plugin.h:652
gboolean(*const auth_is_signed)(void)
Method to check whether the core is using signed tokens.
Definition: plugin.h:430
int8_t audio_level
Audio level, in DB (0-127, 127=silence); -1 means no extension.
Definition: plugin.h:564
gboolean binary
Whether the message data is text (default=FALSE) or binary.
Definition: plugin.h:656
void(*const data_ready)(janus_plugin_session *handle)
Method to be notified about the fact that the datachannel is ready to be written. ...
Definition: plugin.h:323
const char *(*const get_description)(void)
Informative method to request a description of the plugin.
Definition: plugin.h:273
json_t * content
Result content.
Definition: plugin.h:495
char * protocol
The subprotocol this message refers to.
Definition: plugin.h:654
char * buffer
The packet data.
Definition: plugin.h:637
void(*const destroy)(void)
Plugin deinitialization/destructor.
Definition: plugin.h:259
janus_plugin_rtp_extensions extensions
RTP extensions.
Definition: plugin.h:609
uint8_t dd_content[256]
Dependency Descriptor content.
Definition: plugin.h:581
void(*const create_session)(janus_plugin_session *handle, int *error)
Method to create a new session/handle for a peer.
Definition: plugin.h:284
A severe error happened (not an application level error)
Definition: plugin.h:470
void(*const relay_rtp)(janus_plugin_session *handle, janus_plugin_rtp *packet)
Callback to relay RTP packets to a peer.
Definition: plugin.h:374
janus_refcount ref
Reference counter for this instance.
Definition: plugin.h:248
void(*const send_pli)(janus_plugin_session *handle)
Helper to ask for a keyframe via a RTCP PLI to all video streams.
Definition: plugin.h:391
janus_plugin * create_p(void)
The hook that plugins need to implement to be created from the Janus core.
Definition: plugin.h:445
Callbacks to contact the Janus core.
Definition: plugin.h:359
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:311
uint16_t length
The message length.
Definition: plugin.h:660
struct json_t *(*const handle_admin_message)(json_t *message)
Method to handle an incoming Admin API message/request.
Definition: plugin.h:300
int mindex
Index of the stream (relative to the SDP)
Definition: plugin.h:633
int(*const get_api_compatibility)(void)
Informative method to request the API version this plugin was compiled against.
Definition: plugin.h:267
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
gboolean(*const auth_is_signature_valid)(janus_plugin *plugin, const char *token)
Method to check whether a signed token is valid.
Definition: plugin.h:435
Janus plugin RTP extensions.
Definition: plugin.h:562
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:441
uint16_t length
The packet length.
Definition: plugin.h:639
void * plugin_handle
Opaque pointer to the plugin session.
Definition: plugin.h:243
int16_t video_rotation
Video orientation rotation (0, 90, 180, 270); -1 means no extension.
Definition: plugin.h:569
uint8_t dd_len
Length of Dependency Descriptor data, if available.
Definition: plugin.h:579
Janus plugin RTCP packet.
Definition: plugin.h:626
gboolean(*const events_is_enabled)(void)
Callback to check whether the event handlers mechanism is enabled.
Definition: plugin.h:420
void janus_plugin_rtcp_reset(janus_plugin_rtcp *packet)
Helper method to initialise/reset the RTCP packet.
Definition: plugin.c:78
int(*const get_version)(void)
Informative method to request the numeric version of the plugin.
Definition: plugin.h:269
Plugin-Gateway session mapping.
Definition: plugin.h:239
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:307
const char * text
Text associated with this plugin result.
Definition: plugin.h:487
void(*const destroy_session)(janus_plugin_session *handle, int *error)
Method to destroy a session/handle for a peer.
Definition: plugin.h:348
char * buffer
The packet data.
Definition: plugin.h:605
void(*const close_pc)(janus_plugin_session *handle)
Callback to ask the core to close a WebRTC PeerConnection.
Definition: plugin.h:411
uint64_t abs_capture_ts
Absolute Capture Time timestamp.
Definition: plugin.h:583
gboolean video_flipped
Whether the video orientation extension says it&#39;s flipped horizontally.
Definition: plugin.h:575
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_result_type type
Result type.
Definition: plugin.h:480
gboolean video_back_camera
Whether the video orientation extension says this is the back camera.
Definition: plugin.h:572
void(*const relay_rtcp)(janus_plugin_session *handle, janus_plugin_rtcp *packet)
Callback to relay RTCP messages to a peer.
Definition: plugin.h:378