summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--include/ice.h1
-rw-r--r--include/peerconn.h4
-rw-r--r--src/log.h16
-rw-r--r--src/mdns.c22
-rw-r--r--src/sdp.c6
-rw-r--r--src/sdp.h7
-rw-r--r--src/urtc.c14
8 files changed, 40 insertions, 31 deletions
diff --git a/AUTHORS b/AUTHORS
index 120ce43..26a123d 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1 +1,2 @@
Chris Hiszpanski <chris@liburtc.org>
+Matt Durgavich <matthew.durgavich@unity3d.com>
diff --git a/include/ice.h b/include/ice.h
index 0f929f7..f2e6364 100644
--- a/include/ice.h
+++ b/include/ice.h
@@ -55,6 +55,7 @@ typedef struct {
// ICE base
typedef struct {
+ int _;
} ice_base_t;
// ICE component
diff --git a/include/peerconn.h b/include/peerconn.h
index 63e83ce..fcc56e6 100644
--- a/include/peerconn.h
+++ b/include/peerconn.h
@@ -50,8 +50,8 @@ typedef struct urtc_peerconn {
ice_agent_t *agent;
// Local and remote session descriptions
- urtc_sdp_t *ldesc;
- urtc_sdp_t *rdesc;
+ sdp_t *ldesc;
+ sdp_t *rdesc;
// Event callbacks
void (*onIceCandidate)(const char *cand, void *arg);
diff --git a/src/log.h b/src/log.h
index 928e066..c17742e 100644
--- a/src/log.h
+++ b/src/log.h
@@ -33,13 +33,13 @@
extern "C" {
#endif
-enum level {
- TRACE = 0,
- DEBUG,
- INFO,
- WARN,
- ERROR,
- FATAL,
+enum urtc_level {
+ URTC_TRACE = 0,
+ URTC_DEBUG,
+ URTC_INFO,
+ URTC_WARN,
+ URTC_ERROR,
+ URTC_FATAL,
NUM_LEVELS // must be last
};
@@ -74,7 +74,7 @@ static const char *logr[NUM_LEVELS] = {
#define TOSTRING(x) STRINGIFY(x)
#define AT __FILE__ ":" TOSTRING(__LINE__)
-#define log(lvl, format, ...) \
+#define urtc_log(lvl, format, ...) \
do { \
fprintf(stderr, "%s" AT " %s" format "%s", logl[lvl], logn[lvl], ##__VA_ARGS__, logr[lvl]); \
} while (0);
diff --git a/src/mdns.c b/src/mdns.c
index 8d19b7c..e43d6dc 100644
--- a/src/mdns.c
+++ b/src/mdns.c
@@ -90,11 +90,11 @@ struct __attribute__((__packed__)) answer {
*
* \return Socket file descriptor on success, negative on error.
*/
-int mdns_subscribe() {
+int mdns_subscribe(void) {
// create socket
int sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (-1 == sockfd) {
- log(ERROR, "%s", strerror(errno));
+ urtc_log(URTC_ERROR, "%s", strerror(errno));
goto _fail_create_socket;
}
@@ -112,7 +112,7 @@ int mdns_subscribe() {
&opt,
sizeof(opt)
)) {
- log(ERROR, "%s", strerror(errno));
+ urtc_log(URTC_ERROR, "%s", strerror(errno));
goto _fail_enable_addr_reuse;
}
}
@@ -125,7 +125,7 @@ int mdns_subscribe() {
.sin_port = htons(MDNS_PORT)
};
if (-1 == bind(sockfd, (struct sockaddr *)(&mgroup), sizeof(mgroup))) {
- log(ERROR, "%s", strerror(errno));
+ urtc_log(URTC_ERROR, "%s", strerror(errno));
goto _fail_bind;
}
}
@@ -140,7 +140,7 @@ int mdns_subscribe() {
&opt,
sizeof(opt)
)) {
- log(ERROR, "setsockopt: %s", strerror(errno));
+ urtc_log(URTC_ERROR, "setsockopt: %s", strerror(errno));
goto _fail_disable_loopback;
}
}
@@ -158,7 +158,7 @@ int mdns_subscribe() {
&imr,
sizeof(imr)
)) {
- log(ERROR, "setsockopt: %s", strerror(errno));
+ urtc_log(URTC_ERROR, "setsockopt: %s", strerror(errno));
goto _fail_join_multicast_group;
}
}
@@ -186,7 +186,7 @@ _fail_create_socket:
*/
int mdns_unsubscribe(int sockfd) {
if (-1 == close(sockfd)) {
- log(ERROR, "close: %s", strerror(errno));
+ urtc_log(URTC_ERROR, "close: %s", strerror(errno));
return -URTC_ERR;
}
@@ -204,7 +204,7 @@ int mdns_query(const char *name) {
// create socket
int msockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (-1 == msockfd) {
- log(FATAL, "socket: %s", strerror(errno));
+ urtc_log(URTC_FATAL, "socket: %s", strerror(errno));
}
uint8_t q[512];
@@ -243,7 +243,7 @@ int mdns_query(const char *name) {
.sin_port = htons(MDNS_PORT)
};
if (-1 == sendto(msockfd, q, qlen, 0, (struct sockaddr *)(&mgroup), sizeof(mgroup))) {
- log(FATAL, "sendto: %s", strerror(errno));
+ urtc_log(URTC_FATAL, "sendto: %s", strerror(errno));
}
return 0;
@@ -523,7 +523,7 @@ int mdns_send_response(int sockfd, const char *hostname) {
// get linked list of network interfaces
if (-1 == getifaddrs(&ifaddrs)) {
- log(ERROR, "%s", strerror(errno));
+ urtc_log(URTC_ERROR, "%s", strerror(errno));
goto _fail_getifaddrs;
}
@@ -600,7 +600,7 @@ int mdns_send_response(int sockfd, const char *hostname) {
(struct sockaddr *)(&mgroup),
sizeof(mgroup)
)) {
- log(FATAL, "sendto: %s", strerror(errno));
+ urtc_log(URTC_FATAL, "sendto: %s", strerror(errno));
}
return 0;
diff --git a/src/sdp.c b/src/sdp.c
index ef73efc..c312d89 100644
--- a/src/sdp.c
+++ b/src/sdp.c
@@ -176,10 +176,10 @@ static int sdp_parse_attr_rtpmap(struct sdp *sdp, char *val) {
if (!val) return -URTC_ERR_SDP_MALFORMED;
unsigned int pt; // payload type
- char en[7]; // encoding name
+ char en[10]; // encoding name
unsigned int cr; // clock rate
- if (3 != sscanf(val, "%3d %6[a-zA-Z0-9]%*c%5d", &pt, en, &cr)) {
+ if (3 != sscanf(val, "%3d %9[a-zA-Z0-9]%*c%5d", &pt, en, &cr)) {
return -URTC_ERR_SDP_MALFORMED_ATTRIBUTE;
}
@@ -468,7 +468,7 @@ int sdp_parse(struct sdp *dst, const char *str) {
for (char *in = copy, *line = strsep(&in, "\r\n"); in; line = strsep(&in, "\r\n")) {
retval = sdp_parse_line(dst, line);
if (retval != 0) {
- log(ERROR, "sdp_parse_line returned %i for %s", retval, line);
+ urtc_log(URTC_ERROR, "sdp_parse_line returned %i for %s", retval, line);
break;
}
}
diff --git a/src/sdp.h b/src/sdp.h
index 53bc722..d343c15 100644
--- a/src/sdp.h
+++ b/src/sdp.h
@@ -113,6 +113,13 @@ typedef struct sdp {
int count;
} video;
+ // audio media
+ struct {
+ uint16_t port;
+ struct sdp_rtpmap params[SDP_MAX_RTP_PAYLOAD_TYPES];
+ int count;
+ } audio;
+
sdp_mode_t mode; // send, receive, and send-and-receive
bool rtcp_mux; // is rtcp multiplexed on same socket
diff --git a/src/urtc.c b/src/urtc.c
index 7cbf790..e111999 100644
--- a/src/urtc.c
+++ b/src/urtc.c
@@ -212,17 +212,17 @@ static int socket_event_handler(struct peerconn *pc) {
// rtp
if ((127 < buffer[0]) && (buffer[0] < 192)) {
- log(INFO, "[rtp] %s", inet_ntoa(ra.sin_addr));
+ urtc_log(URTC_INFO, "[rtp] %s", inet_ntoa(ra.sin_addr));
rtp_handler(pc, buffer, n);
} else
// dtls
if ((19 < buffer[0]) && (buffer[0] < 64)) {
- log(INFO, "[dtls] %s", inet_ntoa(ra.sin_addr));
+ urtc_log(URTC_INFO, "[dtls] %s", inet_ntoa(ra.sin_addr));
dtls_handler(pc, buffer, n);
} else
// stun
if (buffer[0] < 2) {
- log(INFO, "[stun] %s", inet_ntoa(ra.sin_addr));
+ urtc_log(URTC_INFO, "[stun] %s", inet_ntoa(ra.sin_addr));
stun_handler(pc, buffer, n);
}
@@ -265,7 +265,7 @@ static int mdns_handler(struct peerconn *pc) {
NULL,
NULL
), -1 == n) {
- log(ERROR, "%s", strerror(errno));
+ urtc_log(URTC_ERROR, "%s", strerror(errno));
goto _fail_recvfrom;
}
@@ -273,12 +273,12 @@ static int mdns_handler(struct peerconn *pc) {
int type = mdns_validate_query(buffer, n, pc->mdns.hostname);
if (type > 0) {
if (type | TYPE_A) {
- log(DEBUG, "[mdns] received A query");
+ urtc_log(URTC_DEBUG, "[mdns] received A query");
// ...respond to query with interface addresses
mdns_send_response(pc->mdns.sockfd, pc->mdns.hostname);
}
if (type | TYPE_AAAA) {
- log(DEBUG, "[mdns] received AAAA query");
+ urtc_log(URTC_DEBUG, "[mdns] received AAAA query");
}
}
@@ -385,7 +385,7 @@ urtc_peerconn_t * urtc_peerconn_create(const char *stun[]) {
// generate a unique local mDNS hostname
uuid_create_str(pc->mdns.hostname);
- log(INFO, "mDNS hostname is %s.local", pc->mdns.hostname);
+ urtc_log(URTC_INFO, "mDNS hostname is %s.local", pc->mdns.hostname);
// open multicast udp socket for replying to mDNS queries
pc->mdns.sockfd = mdns_subscribe();