diff options
Diffstat (limited to 'src/rexmpp_jingle.h')
-rw-r--r-- | src/rexmpp_jingle.h | 93 |
1 files changed, 89 insertions, 4 deletions
diff --git a/src/rexmpp_jingle.h b/src/rexmpp_jingle.h index c8a2822..cd23efb 100644 --- a/src/rexmpp_jingle.h +++ b/src/rexmpp_jingle.h @@ -11,6 +11,16 @@ #ifndef REXMPP_JINGLE_H #define REXMPP_JINGLE_H +#include "config.h" + +#ifdef ENABLE_CALLS +#include <glib.h> +#include <agent.h> +#include <gnutls/gnutls.h> +#include <srtp2/srtp.h> +#define DTLS_SRTP_BUF_SIZE 0x4000 +#endif + #include "rexmpp.h" /** @brief Processes incoming Jingle IQs. */ @@ -38,18 +48,93 @@ rexmpp_jingle_session_terminate (rexmpp_t *s, xmlNodePtr reason_node, const char *reason_text); +typedef struct rexmpp_jingle_component rexmpp_jingle_component_t; typedef struct rexmpp_jingle_session rexmpp_jingle_session_t; +typedef struct rexmpp_jingle_ctx rexmpp_jingle_ctx_t; + +enum rexmpp_jingle_session_type { + REXMPP_JINGLE_SESSION_FILE, + REXMPP_JINGLE_SESSION_MEDIA +}; + +#ifdef ENABLE_CALLS +/* A structure used for callbacks, to pass rexmpp_t, + rexmpp_jingle_session_t, and the component ID. */ +struct rexmpp_jingle_component { + rexmpp_t *s; + rexmpp_jingle_session_t *session; + int component_id; + gnutls_session_t dtls_session; + char dtls_buf[DTLS_SRTP_BUF_SIZE]; + enum tls_st dtls_state; + size_t dtls_buf_len; + srtp_t srtp_in; + srtp_t srtp_out; + uint16_t udp_port_in; + uint16_t udp_port_out; + int udp_socket; +}; +#endif struct rexmpp_jingle_session { char *jid; char *sid; + xmlNodePtr initiate; + xmlNodePtr accept; + rexmpp_jingle_session_t *next; + /* Sessions are commonly passed to callbacks by external libraries, + so it's convenient to have the corresponding rexmpp_t accessible + through those. */ + rexmpp_t *s; + int initiator; + enum rexmpp_jingle_session_type type; + + /* IBB file transfers */ + FILE *ibb_fh; char *ibb_sid; uint16_t ibb_seq; - /* The most recent <jingle/> elmment in negotiation. */ - xmlNodePtr negotiation; - FILE *f; - rexmpp_jingle_session_t *next; + + /* ICE-UDP + DTLS-SRTP A/V calls */ +#ifdef ENABLE_CALLS + char *stun_host; + uint16_t stun_port; + char *turn_host; + uint16_t turn_port; + char *turn_username; + char *turn_password; + /* two component structures for callbacks: for SRTP and SRTCP */ + rexmpp_jingle_component_t component[2]; + int rtcp_mux; + NiceAgent *ice_agent; + int ice_stream_id; +#endif +}; + +struct rexmpp_jingle_ctx { +#ifdef ENABLE_CALLS + GMainLoop* gloop; + gnutls_certificate_credentials_t dtls_cred; +#endif + rexmpp_jingle_session_t *sessions; }; +int rexmpp_jingle_init (rexmpp_t *s); +rexmpp_err_t rexmpp_jingle_run (rexmpp_t *s, fd_set *read_fds, fd_set *write_fds); +struct timeval * rexmpp_jingle_timeout (rexmpp_t *s, + struct timeval *max_tv, + struct timeval *tv); +int rexmpp_jingle_fds(rexmpp_t *s, fd_set *read_fds, fd_set *write_fds); + +rexmpp_err_t +rexmpp_jingle_call (rexmpp_t *s, + const char *jid, + uint16_t rtp_port_in, + uint16_t rtp_port_out); +rexmpp_err_t +rexmpp_jingle_call_accept (rexmpp_t *s, + const char *sid, + uint16_t rtp_port_in, + uint16_t rtp_port_out); + #endif |