summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Hiszpanski <chris.hiszpanski@verkada.com>2022-05-22 01:41:02 -0700
committerChris Hiszpanski <chris.hiszpanski@verkada.com>2022-05-22 01:41:12 -0700
commit1c21817646f1f3c8fc99f1fd6ad04324641da383 (patch)
tree1787d65e49422e00db5d7a48dab2627267b1c20f
parent8a4e7fabafd8d42b0b2cbdbd766bea49a62bfae1 (diff)
expand tabs and add vim modeline
-rw-r--r--example/main.c220
-rw-r--r--tinyrtc.c308
-rw-r--r--tinyrtc.h46
3 files changed, 290 insertions, 284 deletions
diff --git a/example/main.c b/example/main.c
index e850a40..77b68da 100644
--- a/example/main.c
+++ b/example/main.c
@@ -12,126 +12,128 @@
// Helper function for parsing JSON
static bool matches(const char *json, jsmntok_t *tok, const char *s) {
- if (JSMN_STRING != tok->type) return false;
- if (strlen(s) != tok->end - tok->start) return false;
- return 0 == strncmp(json + tok->start, s, tok->end - tok->start);
+ if (JSMN_STRING != tok->type) return false;
+ if (strlen(s) != tok->end - tok->start) return false;
+ return 0 == strncmp(json + tok->start, s, tok->end - tok->start);
}
// Parses ICE candidate from stringified JSON
struct trtc_ice_candidate_t parse_ice_candidate(const char *s)
{
- struct trtc_ice_candidate_t c = { 0 };
-
- int i, r;
- jsmn_parser p;
- jsmntok_t t[16];
- jsmn_init(&p);
-
- r = jsmn_parse(&p, s, strlen(s), t, sizeof(t) / sizeof(t[0]));
- if (r < 0) {
- printf("%s:%d: failed to parse json", __func__, __LINE__);
- return c;
- }
-
- if (r < 1 || t[0].type != JSMN_OBJECT) {
- printf("%s:%d: object expected", __func__, __LINE__);
- return c;
- }
-
- for (i = 1; i < r; i++) {
- if (matches(s, &t[i], "candidate")) {
- strncpy(c.candidate, s + t[i + 1].start,
- t[i + 1].end - t[i + 1].start);
- i++;
- } else if (matches(s, &t[i], "sdpMid")) {
- strncpy(c.sdp_mid, s + t[i + 1].start,
- t[i + 1].end - t[i + 1].start);
- i++;
- } else if (matches(s, &t[i], "sdpMLineIndex")) {
- c.sdp_mline_index = atoi(s + t[i + 1].start);
- i++;
- } else if (matches(s, &t[i], "usernameFragment")) {
- strncpy(c.username_fragment, s + t[i + 1].start,
- t[i + 1].end - t[i + 1].start);
- i++;
- }
- }
-
- return c;
+ struct trtc_ice_candidate_t c = { 0 };
+
+ int i, r;
+ jsmn_parser p;
+ jsmntok_t t[16];
+ jsmn_init(&p);
+
+ r = jsmn_parse(&p, s, strlen(s), t, sizeof(t) / sizeof(t[0]));
+ if (r < 0) {
+ printf("%s:%d: failed to parse json", __func__, __LINE__);
+ return c;
+ }
+
+ if (r < 1 || t[0].type != JSMN_OBJECT) {
+ printf("%s:%d: object expected", __func__, __LINE__);
+ return c;
+ }
+
+ for (i = 1; i < r; i++) {
+ if (matches(s, &t[i], "candidate")) {
+ strncpy(c.candidate, s + t[i + 1].start,
+ t[i + 1].end - t[i + 1].start);
+ i++;
+ } else if (matches(s, &t[i], "sdpMid")) {
+ strncpy(c.sdp_mid, s + t[i + 1].start,
+ t[i + 1].end - t[i + 1].start);
+ i++;
+ } else if (matches(s, &t[i], "sdpMLineIndex")) {
+ c.sdp_mline_index = atoi(s + t[i + 1].start);
+ i++;
+ } else if (matches(s, &t[i], "usernameFragment")) {
+ strncpy(c.username_fragment, s + t[i + 1].start,
+ t[i + 1].end - t[i + 1].start);
+ i++;
+ }
+ }
+
+ return c;
}
// (callback) Called for each discovered local ICE candidate
void on_ice_candidate(const struct trtc_ice_candidate_t c, void *arg) {
- // send ice candidate over signaling channel
- printf("{"
- "\"candidate\":\"%s\","
- "\"sdpMLineIndex\":%d,"
- "\"sdpMid\":\"%s\","
- "\"usernameFragment\":null"
- "}\n", c.candidate, c.sdp_mline_index, c.sdp_mid);
+ // send ice candidate over signaling channel
+ printf("{"
+ "\"candidate\":\"%s\","
+ "\"sdpMLineIndex\":%d,"
+ "\"sdpMid\":\"%s\","
+ "\"usernameFragment\":null"
+ "}\n", c.candidate, c.sdp_mline_index, c.sdp_mid);
}
int main(int argc, char **argv)
{
- openlog(NULL, LOG_PERROR, LOG_USER);
-
- // disable stdout buffering to ensure signaling messages send immediately
- setvbuf(stdout, NULL, _IONBF, 0);
-
- // initialize tinyrtc library
- trtc_init();
-
- // create peer connection
- struct trtc_config_t cfg = {
- .ice_servers = {
- {
- .urls = {
- "stun:stun.liburtc.org",
- },
- }
- }
- };
- struct trtc_peerconn_t* pc = trtc_peer_connection(cfg);
- if (!pc) {
- syslog(LOG_ERR, "trtc_peer_connection() failed");
- return -1;
- }
-
- trtc_set_on_ice_candidate(pc, on_ice_candidate, NULL);
-
- while (true) {
- int n;
- char *msg = NULL;
- size_t msglen = 0;
-
-
- if (n = getline(&msg, &msglen, stdin), -1 == n) {
- syslog(LOG_ERR, "%m");
- return -1;
- }
-
- // case: sdp offer
- if (strstr(msg, "\"sdp\"")) {
- // XXX trtc_set_remote_description(pc, offer);
- const char *answer = trtc_create_answer(pc);
-
- /* send SDP answer via stdout signaling channel */
- printf("{\"sdp\":\"%s\",\"type\":\"answer\"}\n", answer);
-
- trtc_set_local_description(pc, answer);
-
- // case: ice candidate
- } else if (strstr(msg, "\"candidate\"")) {
- struct trtc_ice_candidate_t c = parse_ice_candidate(msg);
- trtc_add_ice_candidate(pc, c);
-
- // case: error
- } else {
- printf("unrecognized signaling message\n");
- }
- }
-
- syslog(LOG_ERR, "terminating");
-
- return 0;
+ openlog(NULL, LOG_PERROR, LOG_USER);
+
+ // disable stdout buffering to ensure signaling messages send immediately
+ setvbuf(stdout, NULL, _IONBF, 0);
+
+ // initialize tinyrtc library
+ trtc_init();
+
+ // create peer connection
+ struct trtc_config_t cfg = {
+ .ice_servers = {
+ {
+ .urls = {
+ "stun:stun.liburtc.org",
+ },
+ }
+ }
+ };
+ struct trtc_peerconn_t* pc = trtc_peer_connection(cfg);
+ if (!pc) {
+ syslog(LOG_ERR, "trtc_peer_connection() failed");
+ return -1;
+ }
+
+ trtc_set_on_ice_candidate(pc, on_ice_candidate, NULL);
+
+ while (true) {
+ int n;
+ char *msg = NULL;
+ size_t msglen = 0;
+
+
+ if (n = getline(&msg, &msglen, stdin), -1 == n) {
+ syslog(LOG_ERR, "%m");
+ return -1;
+ }
+
+ // case: sdp offer
+ if (strstr(msg, "\"sdp\"")) {
+ // XXX trtc_set_remote_description(pc, offer);
+ const char *answer = trtc_create_answer(pc);
+
+ /* send SDP answer via stdout signaling channel */
+ printf("{\"sdp\":\"%s\",\"type\":\"answer\"}\n", answer);
+
+ trtc_set_local_description(pc, answer);
+
+ // case: ice candidate
+ } else if (strstr(msg, "\"candidate\"")) {
+ struct trtc_ice_candidate_t c = parse_ice_candidate(msg);
+ trtc_add_ice_candidate(pc, c);
+
+ // case: error
+ } else {
+ printf("unrecognized signaling message\n");
+ }
+ }
+
+ syslog(LOG_ERR, "terminating");
+
+ return 0;
}
+
+/* vim: set et ts=4 sw=4 : */
diff --git a/tinyrtc.c b/tinyrtc.c
index 2b74890..54bb9b9 100644
--- a/tinyrtc.c
+++ b/tinyrtc.c
@@ -26,11 +26,11 @@
* OF SUCH DAMAGE.
*/
-#include <ifaddrs.h> // freeifaddrs, getifaddrs
+#include <ifaddrs.h> // freeifaddrs, getifaddrs
#include <stdbool.h>
-#include <stdio.h> // snprintf
-#include <string.h> // memset
-#include <unistd.h> // close
+#include <stdio.h> // snprintf
+#include <string.h> // memset
+#include <unistd.h> // close
#include <arpa/inet.h>
#include <net/if.h>
@@ -43,26 +43,26 @@
/// OPAQUE TYPE DEFINITIONS ////////////////////////////////////////////////
struct trtc_peerconn_t {
- bool active;
+ bool active;
- char offer[TRTC_MAX_SDP_SIZE];
- char answer[TRTC_MAX_SDP_SIZE];
+ char offer[TRTC_MAX_SDP_SIZE];
+ char answer[TRTC_MAX_SDP_SIZE];
- /* local description */
- const char* ldesc;
+ /* local description */
+ const char* ldesc;
- /* remote description */
- const char* rdesc;
+ /* remote description */
+ const char* rdesc;
- char l_ice_pwd[TRTC_MAX_ICE_PWD_SIZE];
- char l_ice_ufrag[TRTC_MAX_ICE_UFRAG_SIZE];
+ char l_ice_pwd[TRTC_MAX_ICE_PWD_SIZE];
+ char l_ice_ufrag[TRTC_MAX_ICE_UFRAG_SIZE];
- /* onIceCandidate callback */
- trtc_on_ice_candidate_t* on_ice_candidate;
- void* on_ice_candidate_arg;
+ /* onIceCandidate callback */
+ trtc_on_ice_candidate_t* on_ice_candidate;
+ void* on_ice_candidate_arg;
- /* tcp host candidate socket */
- int host_tcp_fd;
+ /* tcp host candidate socket */
+ int host_tcp_fd;
};
@@ -74,7 +74,7 @@ static struct trtc_peerconn_t peer_connection_pool[TRTC_MAX_PEER_CONNECTIONS];
/// RTC PEER CONNECTION API ////////////////////////////////////////////////
void trtc_init() {
- memset(peer_connection_pool, 0, sizeof(peer_connection_pool));
+ memset(peer_connection_pool, 0, sizeof(peer_connection_pool));
}
/**
@@ -83,72 +83,72 @@ void trtc_init() {
* \return 0 on success, -1 on error.
*/
static int get_host_candidates(struct trtc_peerconn_t* pc) {
- struct ifaddrs *ifaddr, *ifa;
- socklen_t laddrlen;
-
- /* sanity check */
- if (!pc) return -1;
-
- /* create tcp socket */
- pc->host_tcp_fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (-1 == pc->host_tcp_fd) {
- return -1;
- }
-
- /* bind to arbitrary port */
- struct sockaddr_in laddr = {
- .sin_family = AF_INET,
- .sin_addr.s_addr = INADDR_ANY,
- .sin_port = 0,
- };
- if (-1 == bind(pc->host_tcp_fd, (struct sockaddr*)&laddr, sizeof(laddr))) {
- return -1;
- }
- laddrlen = sizeof(struct sockaddr_in);
- if (-1 == getsockname(pc->host_tcp_fd, (struct sockaddr *)&laddr, &laddrlen)) {
- return -1;
- }
-
- /* listen on socket */
- if (-1 == listen(pc->host_tcp_fd, 0)) {
- return -1;
- }
-
- /* get network interface addresses */
- if (-1 == getifaddrs(&ifaddr)) {
- return -1;
- }
-
- /* iterate over addresses */
- for (ifa = ifaddr; ifa; ifa = ifa->ifa_next) {
- if (!ifa->ifa_addr) continue;
-
- /* skip loopback interface addresses */
- if (IFF_LOOPBACK & ifa->ifa_flags) continue;
-
- if (AF_INET == ifa->ifa_addr->sa_family) {
- struct sockaddr_in *sa = (struct sockaddr_in*)ifa->ifa_addr;
-
- /* host tcp candidate */
- struct trtc_ice_candidate_t c = {
- .sdp_mid = "0",
- .sdp_mline_index = 0
- };
- snprintf(c.candidate, TRTC_MAX_ICE_CANDIDATE_SIZE,
- "candidate:2894319779 1 tcp 212260223 %s %d typ host tcptype passive",
- inet_ntoa(sa->sin_addr),
- laddr.sin_port); // XXXX
-
- /* callback */
- if (pc->on_ice_candidate) {
- pc->on_ice_candidate(c, pc->on_ice_candidate_arg);
- }
- }
- }
-
- freeifaddrs(ifaddr);
-
- return 0;
+ struct ifaddrs *ifaddr, *ifa;
+ socklen_t laddrlen;
+
+ /* sanity check */
+ if (!pc) return -1;
+
+ /* create tcp socket */
+ pc->host_tcp_fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (-1 == pc->host_tcp_fd) {
+ return -1;
+ }
+
+ /* bind to arbitrary port */
+ struct sockaddr_in laddr = {
+ .sin_family = AF_INET,
+ .sin_addr.s_addr = INADDR_ANY,
+ .sin_port = 0,
+ };
+ if (-1 == bind(pc->host_tcp_fd, (struct sockaddr*)&laddr, sizeof(laddr))) {
+ return -1;
+ }
+ laddrlen = sizeof(struct sockaddr_in);
+ if (-1 == getsockname(pc->host_tcp_fd, (struct sockaddr *)&laddr, &laddrlen)) {
+ return -1;
+ }
+
+ /* listen on socket */
+ if (-1 == listen(pc->host_tcp_fd, 0)) {
+ return -1;
+ }
+
+ /* get network interface addresses */
+ if (-1 == getifaddrs(&ifaddr)) {
+ return -1;
+ }
+
+ /* iterate over addresses */
+ for (ifa = ifaddr; ifa; ifa = ifa->ifa_next) {
+ if (!ifa->ifa_addr) continue;
+
+ /* skip loopback interface addresses */
+ if (IFF_LOOPBACK & ifa->ifa_flags) continue;
+
+ if (AF_INET == ifa->ifa_addr->sa_family) {
+ struct sockaddr_in *sa = (struct sockaddr_in*)ifa->ifa_addr;
+
+ /* host tcp candidate */
+ struct trtc_ice_candidate_t c = {
+ .sdp_mid = "0",
+ .sdp_mline_index = 0
+ };
+ snprintf(c.candidate, TRTC_MAX_ICE_CANDIDATE_SIZE,
+ "candidate:2894319779 1 tcp 212260223 %s %d typ host tcptype passive",
+ inet_ntoa(sa->sin_addr),
+ laddr.sin_port); // XXXX
+
+ /* callback */
+ if (pc->on_ice_candidate) {
+ pc->on_ice_candidate(c, pc->on_ice_candidate_arg);
+ }
+ }
+ }
+
+ freeifaddrs(ifaddr);
+
+ return 0;
}
/**
@@ -162,100 +162,102 @@ static int get_host_candidates(struct trtc_peerconn_t* pc) {
* \return NULL.
*/
static void* peer_connection_thread(void *arg) {
- return NULL;
+ return NULL;
}
struct trtc_peerconn_t* trtc_peer_connection(struct trtc_config_t cfg) {
- struct trtc_peerconn_t* pc = NULL;
+ struct trtc_peerconn_t* pc = NULL;
- for (int i = 0; i < TRTC_MAX_PEER_CONNECTIONS; i++) {
- if (!peer_connection_pool[i].active) {
- memset(&peer_connection_pool[i], 0, sizeof(struct trtc_peerconn_t));
- pc = &peer_connection_pool[i];
- break;
- }
- }
+ for (int i = 0; i < TRTC_MAX_PEER_CONNECTIONS; i++) {
+ if (!peer_connection_pool[i].active) {
+ memset(&peer_connection_pool[i], 0, sizeof(struct trtc_peerconn_t));
+ pc = &peer_connection_pool[i];
+ break;
+ }
+ }
- return pc;
+ return pc;
}
void trtc_peer_connection_destroy(struct trtc_peerconn_t* pc) {
- if (!pc) return;
+ if (!pc) return;
- close(pc->host_tcp_fd);
+ close(pc->host_tcp_fd);
- // XXX mark as available
+ // XXX mark as available
}
int trtc_set_on_ice_candidate(
- struct trtc_peerconn_t* pc,
- trtc_on_ice_candidate_t* cb,
- void* arg
+ struct trtc_peerconn_t* pc,
+ trtc_on_ice_candidate_t* cb,
+ void* arg
) {
- if (!pc || !cb) return -1;
+ if (!pc || !cb) return -1;
- pc->on_ice_candidate = cb;
- pc->on_ice_candidate_arg = arg;
+ pc->on_ice_candidate = cb;
+ pc->on_ice_candidate_arg = arg;
- return 0;
+ return 0;
}
int trtc_add_ice_candidate(struct trtc_peerconn_t *pc, const struct trtc_ice_candidate_t c) {
- return -1;
+ return -1;
};
const char * trtc_create_answer(struct trtc_peerconn_t *pc) {
- unsigned char fp[32];
-
- snprintf(pc->l_ice_ufrag, TRTC_MAX_ICE_UFRAG_SIZE, "xxxx"); // XXX
- snprintf(pc->l_ice_pwd, TRTC_MAX_ICE_PWD_SIZE, "xxxxxxxxxxxxxxxxxxxxxx"); // XXX
-
- snprintf(pc->answer, TRTC_MAX_SDP_SIZE,
- "v=0\\r\\n"
- "o=- 2210401696197537454 2 IN IP4 127.0.0.1\\r\\n" // XXX
- "s=-\\r\\n"
- "u=https://tinyrtc.org/\\r\\n"
- "t=0 0\\r\\n"
- "a=group:BUNDLE 0\\r\\n"
- "a=msid-semantic: WMS\\r\\n"
- "m=video 9 UDP/TLS/RTP/SAVPF 98\\r\\n" // XXX
- "c=IN IP4 0.0.0.0\\r\\n"
- "a=rtcp:9 IN IP4 0.0.0.0\\r\\n"
- "a=ice-ufrag:%s\\r\\n"
- "a=ice-pwd:%s\\r\\n"
- "a=ice-options:trickle\\r\\n"
- "a=fingerprint:sha-256 "
- "%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:"
- "%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:"
- "%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:"
- "%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX\\r\\n"
- "a=setup:passive\\r\\n"
- "a=mid:0\\r\\n"
- "a=sendonly\\r\\n"
- "a=rtcp-mux\\r\\n"
- "a=rtcp-rsize\\r\\n"
- "a=rtpmap:98 H264/90000\\r\\n"
- "a=rtcp-fb:98 nack\\r\\n"
- "a=rtcp-fb:98 nack pli\\r\\n"
- "a=fmtp:98 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\\r\\n",
- pc->l_ice_ufrag,
- pc->l_ice_pwd,
- fp[ 0], fp[ 1], fp[ 2], fp[ 3], fp[ 4], fp[ 5], fp[ 6], fp[ 7],
- fp[ 8], fp[ 9], fp[10], fp[11], fp[12], fp[13], fp[14], fp[15],
- fp[16], fp[17], fp[18], fp[19], fp[20], fp[21], fp[22], fp[23],
- fp[24], fp[25], fp[26], fp[27], fp[28], fp[29], fp[30], fp[31]
- );
-
- return pc->answer;
+ unsigned char fp[32];
+
+ snprintf(pc->l_ice_ufrag, TRTC_MAX_ICE_UFRAG_SIZE, "xxxx"); // XXX
+ snprintf(pc->l_ice_pwd, TRTC_MAX_ICE_PWD_SIZE, "xxxxxxxxxxxxxxxxxxxxxx"); // XXX
+
+ snprintf(pc->answer, TRTC_MAX_SDP_SIZE,
+ "v=0\\r\\n"
+ "o=- 2210401696197537454 2 IN IP4 127.0.0.1\\r\\n" // XXX
+ "s=-\\r\\n"
+ "u=https://tinyrtc.org/\\r\\n"
+ "t=0 0\\r\\n"
+ "a=group:BUNDLE 0\\r\\n"
+ "a=msid-semantic: WMS\\r\\n"
+ "m=video 9 UDP/TLS/RTP/SAVPF 98\\r\\n" // XXX
+ "c=IN IP4 0.0.0.0\\r\\n"
+ "a=rtcp:9 IN IP4 0.0.0.0\\r\\n"
+ "a=ice-ufrag:%s\\r\\n"
+ "a=ice-pwd:%s\\r\\n"
+ "a=ice-options:trickle\\r\\n"
+ "a=fingerprint:sha-256 "
+ "%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:"
+ "%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:"
+ "%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:"
+ "%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX\\r\\n"
+ "a=setup:passive\\r\\n"
+ "a=mid:0\\r\\n"
+ "a=sendonly\\r\\n"
+ "a=rtcp-mux\\r\\n"
+ "a=rtcp-rsize\\r\\n"
+ "a=rtpmap:98 H264/90000\\r\\n"
+ "a=rtcp-fb:98 nack\\r\\n"
+ "a=rtcp-fb:98 nack pli\\r\\n"
+ "a=fmtp:98 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\\r\\n",
+ pc->l_ice_ufrag,
+ pc->l_ice_pwd,
+ fp[ 0], fp[ 1], fp[ 2], fp[ 3], fp[ 4], fp[ 5], fp[ 6], fp[ 7],
+ fp[ 8], fp[ 9], fp[10], fp[11], fp[12], fp[13], fp[14], fp[15],
+ fp[16], fp[17], fp[18], fp[19], fp[20], fp[21], fp[22], fp[23],
+ fp[24], fp[25], fp[26], fp[27], fp[28], fp[29], fp[30], fp[31]
+ );
+
+ return pc->answer;
};
int trtc_set_local_description(struct trtc_peerconn_t *pc, const char *sdp) {
- pc->ldesc = sdp;
- get_host_candidates(pc);
- return -1;
+ pc->ldesc = sdp;
+ get_host_candidates(pc);
+ return -1;
};
int trtc_set_remote_description(struct trtc_peerconn_t *pc, const char *sdp) {
- pc->rdesc = sdp;
- return -1;
+ pc->rdesc = sdp;
+ return -1;
};
+
+/* vim: set et ts=4 sw=4 : */
diff --git a/tinyrtc.h b/tinyrtc.h
index ff29e15..1ff31e4 100644
--- a/tinyrtc.h
+++ b/tinyrtc.h
@@ -29,18 +29,18 @@
#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
+#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 ///////////////////////////////////////////////
@@ -51,20 +51,20 @@ struct trtc_peerconn_t;
/// PUBLIC TYPE DEFINITIONS ////////////////////////////////////////////////
struct trtc_ice_server_t {
- char credential[TRTC_MAX_ICE_SERVER_CREDENTIAL_SIZE];
- char urls[3][TRTC_MAX_ICE_SERVER_URL_SIZE];
- char username[TRTC_MAX_ICE_SERVER_USERNAME_SIZE];
+ char credential[TRTC_MAX_ICE_SERVER_CREDENTIAL_SIZE];
+ char urls[3][TRTC_MAX_ICE_SERVER_URL_SIZE];
+ char username[TRTC_MAX_ICE_SERVER_USERNAME_SIZE];
};
struct trtc_config_t {
- struct trtc_ice_server_t ice_servers[TRTC_MAX_ICE_SERVERS];
+ struct trtc_ice_server_t ice_servers[TRTC_MAX_ICE_SERVERS];
};
struct trtc_ice_candidate_t {
- char candidate[TRTC_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 candidate[TRTC_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];
};
@@ -99,7 +99,7 @@ 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);
+ struct trtc_peerconn_t *pc, const struct trtc_ice_candidate_t c);
int trtc_add_track(struct trtc_peerconn_t *pc);
@@ -122,9 +122,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);
+ 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
+
+/* vim: set et ts=4 sw=4 : */