forked from meetecho/janus-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjanus_duktape_data.h
84 lines (75 loc) · 4.04 KB
/
janus_duktape_data.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*! \file janus_duktape_data.h
* \author Lorenzo Miniero <lorenzo@meetecho.com>
* \copyright GNU General Public License v3
* \brief Janus Duktape data/session definition (headers)
* \details The Janus Duktape plugin implements all the mandatory hooks to
* allow the C code to interact with a custom JavaScript script, and viceversa.
* That said, the janus_duktape_extra.c code allows for custom hooks to be
* added in C, to expose additional JavaScript functions and implement more
* complex media management than the one provided by the stock plugin.
* For this to work, though, the janus_duktape_session object and its
* indexing in the hashtable need to be defined externally, which is
* what this file is for.
*
* Notice that all the management associated to sessions (creating or
* destroying sessions, locking their global mutex, updating the
* hashtable) is done in the core of the JavaScript plugin: here we only
* define them, so that they can be accessed/used by the extra code too.
*
* \ingroup jspapi
* \ref jspapi
*/
#ifndef JANUS_DUKTAPE_DATA_H
#define JANUS_DUKTAPE_DATA_H
#include "duktape-deps/duktape.h"
#include "duktape-deps/duk_console.h"
#include "duktape-deps/duk_module_duktape.h"
#include "plugin.h"
#include "debug.h"
#include "apierror.h"
#include "config.h"
#include "mutex.h"
#include "rtp.h"
#include "rtcp.h"
#include "sdp-utils.h"
#include "record.h"
#include "utils.h"
/* Core pointer and related flags */
extern volatile gint duktape_initialized, duktape_stopping;
extern janus_callbacks *janus_core;
/* Duktape context: we define context and mutex as extern */
extern duk_context *duktape_ctx;
extern janus_mutex duktape_mutex;
/* Duktape session: we keep only the barebone stuff here, the rest will be in the JavaScript script */
typedef struct janus_duktape_session {
janus_plugin_session *handle; /* Pointer to the core-plugin session */
uint32_t id; /* Unique session ID (will be used to correlate with the JavaScript script) */
/* The following are only needed for media manipulation, feedback and routing, and may not all be used */
gboolean accept_audio; /* Whether incoming audio can be accepted or must be dropped */
gboolean accept_video; /* Whether incoming video can be accepted or must be dropped */
gboolean accept_data; /* Whether incoming data can be accepted or must be dropped */
gboolean send_audio; /* Whether outgoing audio can be sent or must be dropped */
gboolean send_video; /* Whether outgoing video can be sent or must be dropped */
gboolean send_data; /* Whether outgoing data can be sent or must be dropped */
janus_rtp_switching_context rtpctx; /* Needed in case the source changes (e.g., stale operator/customer) */
uint32_t bitrate; /* Bitrate limit */
uint16_t pli_freq; /* Regular PLI frequency (0=disabled) */
gint64 pli_latest; /* Time of latest sent PLI (to avoid flooding) */
GSList *recipients; /* Sessions that should receive media from this session */
struct janus_duktape_session *sender; /* Other session this session is receiving media from */
janus_mutex recipients_mutex; /* Mutex to lock the recipients list */
janus_recorder *arc; /* The Janus recorder instance for audio, if enabled */
janus_recorder *vrc; /* The Janus recorder instance for video, if enabled */
janus_recorder *drc; /* The Janus recorder instance for data, if enabled */
janus_mutex rec_mutex; /* Mutex to protect the recorders from race conditions */
volatile gint started; /* Whether this session's PeerConnection is ready or not */
volatile gint hangingup; /* Whether this session's PeerConnection is hanging up */
volatile gint destroyed; /* Whether this session's been marked as destroyed */
/* If you need any additional property (e.g., for hooks you added in janus_duktape_extra.c) add them below this line */
/* Reference counter */
janus_refcount ref;
} janus_duktape_session;
extern GHashTable *duktape_sessions, *duktape_ids;
extern janus_mutex duktape_sessions_mutex;
janus_duktape_session *janus_duktape_lookup_session(janus_plugin_session *handle);
#endif