From 9175048aa48dee44946bdf1f10f47fe5b3e47675 Mon Sep 17 00:00:00 2001 From: Chris Hiszpanski Date: Mon, 23 May 2022 01:14:00 -0700 Subject: Rename from trtc_ to rtc_ --- tinyrtc.h | 93 ++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 53 insertions(+), 40 deletions(-) (limited to 'tinyrtc.h') diff --git a/tinyrtc.h b/tinyrtc.h index 83666d1..02c8459 100644 --- a/tinyrtc.h +++ b/tinyrtc.h @@ -29,48 +29,62 @@ #ifndef TINYRTC_H #define TINYRTC_H -#define TRTC_MAX_ICE_CANDIDATE_SIZE 256 -#define TRTC_MAX_ICE_SERVER_CREDENTIAL_SIZE 128 -#define TRTC_MAX_ICE_SERVERS 2 -#define TRTC_MAX_ICE_SERVER_URL_SIZE 128 -#define TRTC_MAX_ICE_SERVER_URLS 3 -#define TRTC_MAX_ICE_SERVER_USERNAME_SIZE 128 -#define TRTC_MAX_ICE_CANDIDATE_USERNAME_FRAGMENT_SIZE 8 -#define TRTC_MAX_ICE_CANDIDATE_SDP_MID_SIZE 32 -#define TRTC_MAX_PEER_CONNECTIONS 5 -#define TRTC_MAX_SDP_SIZE 4096 -#define TRTC_MAX_ICE_UFRAG_SIZE 5 -#define TRTC_MAX_ICE_PWD_SIZE 32 - - -/// PRIVATE TYPE DEFINITIONS /////////////////////////////////////////////// +/// CUSTOMIZABLE PARAMETERS //////////////////////////////////////////////// + +#define TINYRTC_MAX_ICE_CANDIDATE_SIZE 256 +#define TINYRTC_MAX_ICE_SERVER_CREDENTIAL_SIZE 128 +#define TINYRTC_MAX_ICE_SERVERS 2 +#define TINYRTC_MAX_ICE_SERVER_URL_SIZE 128 +#define TINYRTC_MAX_ICE_SERVER_URLS 3 +#define TINYRTC_MAX_ICE_SERVER_USERNAME_SIZE 128 +#define TINYRTC_MAX_ICE_CANDIDATE_USERNAME_FRAGMENT_SIZE 8 +#define TINYRTC_MAX_ICE_CANDIDATE_SDP_MID_SIZE 32 +#define TINYRTC_MAX_PEER_CONNECTIONS 5 +#define TINYRTC_MAX_SDP_SIZE 4096 +#define TINYRTC_MAX_ICE_UFRAG_SIZE 5 +#define TINYRTC_MAX_ICE_PWD_SIZE 32 + + +/// PUBLIC ENUMS /////////////////////////////////////////////////////////// + +enum rtc_session_description_type { + RTC_SESSION_DESCRIPTION_TYPE_NONE = 0, + RTC_SESSION_DESCRIPTION_TYPE_OFFER, + RTC_SESSION_DESCRIPTION_TYPE_ANSWER +}; -struct trtc_peerconn_t; +/// PUBLIC STRUCTS ///////////////////////////////////////////////////////// -/// PUBLIC TYPE DEFINITIONS //////////////////////////////////////////////// +struct rtc_peer_connection; -struct trtc_ice_server_t { - char credential[TRTC_MAX_ICE_SERVER_CREDENTIAL_SIZE]; - char urls[TRTC_MAX_ICE_SERVER_URLS][TRTC_MAX_ICE_SERVER_URL_SIZE]; - char username[TRTC_MAX_ICE_SERVER_USERNAME_SIZE]; +struct rtc_ice_server { + char credential[TINYRTC_MAX_ICE_SERVER_CREDENTIAL_SIZE]; + char urls[TINYRTC_MAX_ICE_SERVER_URLS][TINYRTC_MAX_ICE_SERVER_URL_SIZE]; + char username[TINYRTC_MAX_ICE_SERVER_USERNAME_SIZE]; }; -struct trtc_config_t { - struct trtc_ice_server_t ice_servers[TRTC_MAX_ICE_SERVERS]; +struct rtc_configuration { + struct rtc_ice_server ice_servers[TINYRTC_MAX_ICE_SERVERS]; }; -struct trtc_ice_candidate_t { - char candidate[TRTC_MAX_ICE_CANDIDATE_SIZE]; +struct rtc_ice_candidate { + char candidate[TINYRTC_MAX_ICE_CANDIDATE_SIZE]; int sdp_mline_index; - char sdp_mid[TRTC_MAX_ICE_CANDIDATE_SDP_MID_SIZE]; - char username_fragment[TRTC_MAX_ICE_CANDIDATE_USERNAME_FRAGMENT_SIZE]; + char sdp_mid[TINYRTC_MAX_ICE_CANDIDATE_SDP_MID_SIZE]; + char username_fragment[TINYRTC_MAX_ICE_CANDIDATE_USERNAME_FRAGMENT_SIZE]; +}; + +struct rtc_session_description { + char sdp[TINYRTC_MAX_SDP_SIZE]; + enum rtc_session_description_type type; }; /// CALLBACKS ////////////////////////////////////////////////////////////// -typedef void (trtc_on_ice_candidate_t)(const struct trtc_ice_candidate_t c, void *arg); +typedef void (rtc_on_ice_candidate)(const struct rtc_ice_candidate c, + void *arg); /// RTC PEER CONNECTION API //////////////////////////////////////////////// @@ -78,7 +92,7 @@ typedef void (trtc_on_ice_candidate_t)(const struct trtc_ice_candidate_t c, void /** * Initialize library. Must call once before calling other functions. */ -void trtc_init(); +void rtc_init(); /** * Create new peer connection @@ -87,9 +101,10 @@ void trtc_init(); * * \return Peer connection. NULL if all peer connections are already in use. */ -struct trtc_peerconn_t* trtc_peer_connection(struct trtc_config_t cfg); +struct rtc_peer_connection* rtc_peer_connection_create( + struct rtc_configuration cfg); -void trtc_peer_connection_destroy(struct trtc_peerconn_t* pc); +void rtc_peer_connection_destroy(struct rtc_peer_connection* pc); /** * Adds remote ICE candidate to local ICE agent @@ -99,10 +114,8 @@ void trtc_peer_connection_destroy(struct trtc_peerconn_t* pc); * * \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); +int rtc_add_ice_candidate( + struct rtc_peer_connection* pc, const struct rtc_ice_candidate c); /** * Create SDP answer in response to a received SDP offer. @@ -111,7 +124,7 @@ int trtc_add_track(struct trtc_peerconn_t *pc); * * \return SDP answer. NULL on error. */ -const char * trtc_create_answer(struct trtc_peerconn_t *pc); +const char* rtc_create_answer(struct rtc_peer_connection* pc); /** * Sets callback to call for each discovered local ICE candidate @@ -122,11 +135,11 @@ const char * trtc_create_answer(struct trtc_peerconn_t *pc); * * \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 rtc_set_on_ice_candidate( + struct rtc_peer_connection* pc, rtc_on_ice_candidate* 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); +int rtc_set_local_description(struct rtc_peer_connection* pc, const char* sdp); +int rtc_set_remote_description(struct rtc_peer_connection* pc, const char* sdp); #endif -- cgit v1.2.3