27#ifndef __CWIST_NET_WEBRTC_H__
28#define __CWIST_NET_WEBRTC_H__
51 const uint8_t *data,
size_t len,
58 const char *label,
void *user);
struct cwist_reactor cwist_reactor_t
One peer: ICE state, DTLS session, SCTP association.
A UDP endpoint bound to one reactor, serving many conns.
void cwist_webrtc_conn_close(cwist_webrtc_conn *conn)
Close a connection (SCTP abort, DTLS teardown). Safe from any thread; the close handler runs on the r...
const char * cwist_webrtc_ctx_fingerprint(const cwist_webrtc_ctx *ctx)
Local certificate fingerprint (SHA-256, colon-separated hex).
void cwist_webrtc_ctx_set_close_handler(cwist_webrtc_ctx *ctx, cwist_webrtc_close_cb cb, void *user)
Set the callback for closed connections.
size_t cwist_webrtc_conn_buffered_amount(const cwist_webrtc_conn *conn)
Bytes accepted by cwist_webrtc_conn_send() and not yet handed to SCTP (like RTCDataChannel....
void(* cwist_webrtc_channel_cb)(cwist_webrtc_conn *conn, uint16_t channel_id, const char *label, void *user)
Optional DataChannel open notification (remote peer opened a channel).
cwist_webrtc_ctx * cwist_webrtc_ctx_new(uint16_t port)
Create a WebRTC context bound to a UDP port (0 picks an ephemeral port), running on its own reactor t...
cwist_webrtc_ctx * cwist_webrtc_ctx_new_on(cwist_reactor_t *reactor, uint16_t port)
Create a WebRTC context on a reactor the caller runs.
@ CWIST_WEBRTC_DATA_STRING
@ CWIST_WEBRTC_DATA_BINARY
void(* cwist_webrtc_close_cb)(cwist_webrtc_conn *conn, void *user)
Optional connection-closed notification. Runs once per connection whose SCTP association came up; aft...
int cwist_webrtc_ctx_connection_count(const cwist_webrtc_ctx *ctx)
Number of connections whose SCTP association is up.
void cwist_webrtc_ctx_free(cwist_webrtc_ctx *ctx)
Close every connection and free the context.
void cwist_webrtc_conn_release(cwist_webrtc_conn *conn)
Drop a reference taken with cwist_webrtc_conn_retain().
void(* cwist_webrtc_message_cb)(cwist_webrtc_conn *conn, uint16_t channel_id, const uint8_t *data, size_t len, cwist_webrtc_data_type type, void *user)
DataChannel message callback, invoked on the ctx's reactor thread.
void cwist_webrtc_ctx_set_message_handler(cwist_webrtc_ctx *ctx, cwist_webrtc_message_cb cb, void *user)
Set the callback for incoming DataChannel messages. Set handlers before answering the first offer.
void cwist_webrtc_conn_retain(cwist_webrtc_conn *conn)
Take a reference on conn so it stays valid outside a callback.
uint16_t cwist_webrtc_ctx_port(const cwist_webrtc_ctx *ctx)
UDP port the context is bound to.
int cwist_webrtc_conn_send(cwist_webrtc_conn *conn, uint16_t channel_id, const uint8_t *data, size_t len, cwist_webrtc_data_type type)
Send a message on a DataChannel.
int cwist_webrtc_handle_offer(cwist_webrtc_ctx *ctx, const char *offer, char *answer_out, size_t out_len)
Answer a browser SDP offer (ICE-lite, setup:passive).
void cwist_webrtc_ctx_set_channel_handler(cwist_webrtc_ctx *ctx, cwist_webrtc_channel_cb cb, void *user)
Set the callback for incoming DataChannel open (DCEP) events.