From 8a4e7fabafd8d42b0b2cbdbd766bea49a62bfae1 Mon Sep 17 00:00:00 2001 From: Chris Hiszpanski Date: Sun, 22 May 2022 01:36:30 -0700 Subject: Added tcp host candidate --- tinyrtc.h | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'tinyrtc.h') diff --git a/tinyrtc.h b/tinyrtc.h index 205ae1b..ff29e15 100644 --- a/tinyrtc.h +++ b/tinyrtc.h @@ -70,21 +70,61 @@ struct trtc_ice_candidate_t { /// CALLBACKS ////////////////////////////////////////////////////////////// -typedef int (trtc_on_ice_candidate_t)(const struct trtc_ice_candidate_t c, void *arg); +typedef void (trtc_on_ice_candidate_t)(const struct trtc_ice_candidate_t c, void *arg); /// RTC PEER CONNECTION API //////////////////////////////////////////////// +/** + * Initialize library. Must call once before calling other functions. + */ +void trtc_init(); + +/** + * Create new peer connection + * + * \param cfg[in] Configuration. + * + * \return Peer connection. NULL if all peer connections are already in use. + */ struct trtc_peerconn_t* trtc_peer_connection(struct trtc_config_t cfg); +void trtc_peer_connection_destroy(struct trtc_peerconn_t* pc); -int trtc_add_ice_candidate(struct trtc_peerconn_t *pc, const struct trtc_ice_candidate_t c); +/** + * Adds remote ICE candidate to local ICE agent + * + * \param pc[in] Peer connection. + * \param c[in] ICE candidate from remote peer. + * + * \return 0 on success. -1 on error. + */ +int trtc_add_ice_candidate( + struct trtc_peerconn_t *pc, const struct trtc_ice_candidate_t c); int trtc_add_track(struct trtc_peerconn_t *pc); +/** + * Create SDP answer in response to a received SDP offer. + * + * \param pc[in] Peer connection. + * + * \return SDP answer. NULL on error. + */ const char * trtc_create_answer(struct trtc_peerconn_t *pc); -int trtc_set_local_description(struct trtc_peerconn_t *pc, const char *sdp); +/** + * Sets callback to call for each discovered local ICE candidate + * + * \param pc[in] Peer connection. + * \param cb[in] Callback function. + * \param arg[in] User-specified argument to pass to callback function. + * + * \return 0 on success. -1 on error. + */ +int trtc_set_on_ice_candidate( + struct trtc_peerconn_t* pc, trtc_on_ice_candidate_t* cb, void* arg); +int trtc_set_local_description(struct trtc_peerconn_t *pc, const char *sdp); int trtc_set_remote_description(struct trtc_peerconn_t *pc, const char *sdp); #endif -- cgit v1.2.3