[Sumover-dev] [svn commit] r3932 - in common/trunk: src
sumover-dev at cs.ucl.ac.uk
sumover-dev at cs.ucl.ac.uk
Wed Nov 15 18:12:16 GMT 2006
Author: ucacsva
Date: Wed Nov 15 18:11:13 2006
New Revision: 3932
Modified:
common/trunk/src/mbus.c
common/trunk/src/net_udp.c
common/trunk/src/net_udp.h
common/trunk/src/rtp.c
common/trunk/src/rtp.h
common/trunk/src/sap.c
common/trunk/tests/test_net_udp.c
Log:
commit_msg_15Nov2006.txt
Modified: common/trunk/src/mbus.c
==============================================================================
--- common/trunk/src/mbus.c (original)
+++ common/trunk/src/mbus.c Wed Nov 15 18:11:13 2006
@@ -305,7 +305,7 @@
mbus_validate(m);
- *mb_bufpos = '\0';
+ *mb_bufpos = '\0';
assert((mb_bufpos - mb_buffer) < MBUS_BUF_SIZE);
assert(strlen(mb_buffer) < MBUS_BUF_SIZE);
@@ -756,6 +756,8 @@
unsigned char initVec[8] = {0,0,0,0,0,0,0,0};
struct timeval t;
struct mbus_parser *mp, *mp2;
+ fd_set rfd;
+ fd_t max_fd;
mbus_validate(m);
@@ -768,11 +770,12 @@
memset(buffer, 0, MBUS_BUF_SIZE);
assert(m != NULL);
assert(m->s != NULL);
- udp_fd_zero();
- udp_fd_set(m->s);
+ udp_fd_zero( &rfd, &max_fd);
+ udp_fd_set( &rfd, &max_fd, m->s);
t.tv_sec = timeout->tv_sec;
t.tv_usec = timeout->tv_usec;
- if ((udp_select(&t) > 0) && udp_fd_isset(m->s)) {
+ if ((udp_select( &rfd, max_fd, &t) > 0) &&
+ udp_fd_isset( &rfd, &max_fd, m->s)) {
buffer_len = udp_recv(m->s, buffer, MBUS_BUF_SIZE);
if (buffer_len > 0) {
rx = TRUE;
Modified: common/trunk/src/net_udp.c
==============================================================================
--- common/trunk/src/net_udp.c (original)
+++ common/trunk/src/net_udp.c Wed Nov 15 18:11:13 2006
@@ -259,6 +259,37 @@
return FALSE;
}
+uint32_t udp_socket_addr4(socket_udp *s)
+{
+ if (s == NULL) {
+ return 0;
+ }
+
+ if (s->mode != IPv4) {
+ return 0;
+ }
+
+ return (uint32_t)(s->addr4.s_addr);
+}
+
+uint16_t udp_socket_txport(socket_udp *s)
+{
+ if (s == NULL) {
+ return 0;
+ }
+
+ return s->tx_port;
+}
+
+int udp_socket_ttl(socket_udp *s)
+{
+ if (s == NULL) {
+ return -1;
+ }
+
+ return s->ttl;
+}
+
static socket_udp *udp_init4(const char *addr, const char *iface, uint16_t rx_port, uint16_t tx_port, int ttl)
{
int reuse = 1, udpbufsize=131072;
@@ -387,6 +418,7 @@
assert(buffer != NULL);
assert(buflen > 0);
+ memset(&s_in, 0, sizeof(struct sockaddr_in));
s_in.sin_family = AF_INET;
s_in.sin_addr.s_addr = s->addr4.s_addr;
s_in.sin_port = htons(s->tx_port);
@@ -982,19 +1014,16 @@
return 0;
}
-static fd_set rfd;
-static fd_t max_fd;
-
/**
* udp_fd_zero:
*
* Clears file descriptor from set associated with UDP sessions (see select(2)).
*
**/
-void udp_fd_zero(void)
+void udp_fd_zero( fd_set *readset, fd_t *max_fd )
{
- FD_ZERO(&rfd);
- max_fd = 0;
+ FD_ZERO(readset);
+ *max_fd = 0;
}
/**
@@ -1003,11 +1032,11 @@
*
* Adds file descriptor associated of @s to set associated with UDP sessions.
**/
-void udp_fd_set(socket_udp *s)
+void udp_fd_set( fd_set *readset, fd_t *max_fd, socket_udp *s)
{
- FD_SET(s->fd, &rfd);
- if (s->fd > (fd_t)max_fd) {
- max_fd = s->fd;
+ FD_SET(s->fd, readset);
+ if (s->fd > (fd_t)*max_fd) {
+ *max_fd = s->fd;
}
}
@@ -1020,9 +1049,11 @@
*
* Returns: non-zero if set, zero otherwise.
**/
-int udp_fd_isset(socket_udp *s)
+int udp_fd_isset( fd_set *readset, fd_t *max_fd, socket_udp *s)
{
- return FD_ISSET(s->fd, &rfd);
+ UNUSED(max_fd);
+
+ return FD_ISSET(s->fd, readset);
}
/**
@@ -1033,9 +1064,9 @@
*
* Return value: number of UDP sessions ready for reading.
**/
-int udp_select(struct timeval *timeout)
+int udp_select( fd_set *readset, fd_t max_fd, struct timeval *timeout)
{
- return select(max_fd + 1, &rfd, NULL, NULL, timeout);
+ return select(max_fd + 1, readset, NULL, NULL, timeout);
}
/**
Modified: common/trunk/src/net_udp.h
==============================================================================
--- common/trunk/src/net_udp.h (original)
+++ common/trunk/src/net_udp.h Wed Nov 15 18:11:13 2006
@@ -53,13 +53,17 @@
int udp_sendv(socket_udp *s, struct iovec *vector, int count);
#endif
+uint32_t udp_socket_addr4(socket_udp *s);
+uint16_t udp_socket_txport(socket_udp *s);
+int udp_socket_ttl(socket_udp *s);
+
const char *udp_host_addr(socket_udp *s);
int udp_fd(socket_udp *s);
-int udp_select(struct timeval *timeout);
-void udp_fd_zero(void);
-void udp_fd_set(socket_udp *s);
-int udp_fd_isset(socket_udp *s);
+int udp_select( fd_set *readset, int max_fd, struct timeval *timeout);
+void udp_fd_zero( fd_set *readset, int *max_fd );
+void udp_fd_set( fd_set *readset, int *max_fd, socket_udp *s);
+int udp_fd_isset( fd_set *readset, int *max_fd, socket_udp *s);
#if defined(__cplusplus)
}
Modified: common/trunk/src/rtp.c
==============================================================================
--- common/trunk/src/rtp.c (original)
+++ common/trunk/src/rtp.c Wed Nov 15 18:11:13 2006
@@ -47,6 +47,7 @@
*/
#include <stddef.h>
+
#include "config_unix.h"
#include "config_win32.h"
#include "memory.h"
@@ -273,6 +274,7 @@
uint32_t magic; /* For debugging... */
};
+
static inline int
filter_event(struct rtp *session, uint32_t ssrc)
{
@@ -909,13 +911,14 @@
uname = NULL;
pwent = getpwuid(getuid());
if (pwent != NULL) {
- uname = pwent->pw_name;
+ uname = pwent->pw_name;
+ if (uname != NULL) {
+ strncpy(cname, uname, MAXCNAMELEN - 1);
+ strcat(cname, "@");
+ }
+ } else {
+ strncpy(cname, "nobody@", MAXCNAMELEN - 1);
}
- if (uname != NULL) {
- strncpy(cname, uname, MAXCNAMELEN - 1);
- strcat(cname, "@");
- }
-
#endif
/* Now the hostname. Must be dotted-quad IP address. */
@@ -1038,10 +1041,10 @@
}
if (rx_port % 2) {
debug_msg("rx_port should be even\n");
- }
+ }
if (tx_port % 2) {
debug_msg("tx_port should be even\n");
- }
+ }
session = (struct rtp *) xmalloc(sizeof(struct rtp));
memset (session, 0, sizeof(struct rtp));
@@ -1262,9 +1265,9 @@
rtp_event event;
struct timeval event_ts;
- if (packet->fields.cc > 0) {
- for (i = 0; i < packet->fields.cc; i++) {
- create_source(session, packet->meta.csrc[i], FALSE);
+ if (packet->fields.cc > 0) {
+ for (i = 0; i < packet->fields.cc; i++) {
+ create_source(session, packet->meta.csrc[i], FALSE);
}
}
/* Update the source database... */
@@ -1272,7 +1275,7 @@
s->sender = TRUE;
session->sender_count++;
}
- transit = curr_rtp_ts - packet->fields.ts;
+ transit = curr_rtp_ts - packet->fields.ts;
d = transit - s->transit;
s->transit = transit;
if (d < 0) {
@@ -1281,9 +1284,9 @@
s->jitter += d - ((s->jitter + 8) / 16);
/* Callback to the application to process the packet... */
- if (!filter_event(session, packet->fields.ssrc)) {
+ if (!filter_event(session, packet->fields.ssrc)) {
gettimeofday(&event_ts, NULL);
- event.ssrc = packet->fields.ssrc;
+ event.ssrc = packet->fields.ssrc;
event.type = RX_RTP;
event.data = (void *) packet; /* The callback function MUST free this! */
event.ts = &event_ts;
@@ -1295,9 +1298,9 @@
{
/* Check for valid payload types..... 72-76 are RTCP payload type numbers, with */
/* the high bit missing so we report that someone is running on the wrong port. */
- if (packet->fields.pt >= 72 && packet->fields.pt <= 76) {
+ if (packet->fields.pt >= 72 && packet->fields.pt <= 76) {
debug_msg("rtp_header_validation: payload-type invalid");
- if (packet->fields.m) {
+ if (packet->fields.m) {
debug_msg(" (RTCP packet on RTP port?)");
}
debug_msg("\n");
@@ -1306,14 +1309,14 @@
}
/* Check that the length of the packet is sensible... */
- if (len < (12 + (4 * packet->fields.cc))) {
+ if (len < (12 + (4 * packet->fields.cc))) {
debug_msg("rtp_header_validation: packet length is smaller than the header\n");
return FALSE;
}
/* Check that the amount of padding specified is sensible. */
/* Note: have to include the size of any extension header! */
- if (packet->fields.p) {
- int payload_len = len - 12 - (packet->fields.cc * 4);
+ if (packet->fields.p) {
+ int payload_len = len - 12 - (packet->fields.cc * 4);
if (packet->fields.x) {
/* extension header and data */
payload_len -= 4 * (1 + packet->meta.extn_len);
@@ -1326,7 +1329,7 @@
debug_msg("rtp_header_validation: padding zero\n");
return FALSE;
}
- }
+ }
return TRUE;
}
@@ -1340,7 +1343,7 @@
UNUSED(session);
/* We only accept RTPv2 packets... */
- if (packet->fields.v != 2) {
+ if (packet->fields.v != 2) {
debug_msg("rtp_header_validation: v != 2\n");
return FALSE;
}
@@ -1352,18 +1355,18 @@
rtp_recv_data(struct rtp *session, uint32_t curr_rtp_ts)
{
/* This routine preprocesses an incoming RTP packet, deciding whether to process it. */
- static rtp_packet *packet = NULL;
- static unsigned char *buffer = NULL;
- static unsigned char *buffer12 = NULL;
+ rtp_packet *packet = NULL;
+ uint8_t *buffer = NULL;
+ uint8_t *buffer12 = NULL;
int buflen;
source *s;
if (!session->opt->reuse_bufs || (packet == NULL)) {
packet = (rtp_packet *) xmalloc(RTP_MAX_PACKET_LEN);
buffer = ((unsigned char *) packet) + offsetof(rtp_packet, fields);
- buffer12 = buffer + 12;
+ buffer12 = buffer + 12;
}
-
+
buflen = udp_recv(session->rtp_socket, (char *)buffer, RTP_MAX_PACKET_LEN - offsetof(rtp_packet, fields));
if (buflen > 0) {
if (session->encryption_enabled) {
@@ -1371,44 +1374,44 @@
(session->decrypt_func)(session, buffer, buflen, initVec);
}
/* Convert header fields to host byte order... */
- packet->fields.seq = ntohs(packet->fields.seq);
- packet->fields.ts = ntohl(packet->fields.ts);
- packet->fields.ssrc = ntohl(packet->fields.ssrc);
+ packet->fields.seq = ntohs(packet->fields.seq);
+ packet->fields.ts = ntohl(packet->fields.ts);
+ packet->fields.ssrc = ntohl(packet->fields.ssrc);
/* Setup internal pointers, etc... */
- if (packet->fields.cc) {
+ if (packet->fields.cc) {
int i;
- packet->meta.csrc = (uint32_t *)(buffer12);
- for (i = 0; i < packet->fields.cc; i++) {
+ packet->meta.csrc = (uint32_t *)(buffer12);
+ for (i = 0; i < packet->fields.cc; i++) {
packet->meta.csrc[i] = ntohl(packet->meta.csrc[i]);
}
} else {
- packet->meta.csrc = NULL;
+ packet->meta.csrc = NULL;
}
- if (packet->fields.x) {
- packet->meta.extn = buffer12 + (packet->fields.cc * 4);
- packet->meta.extn_len = (packet->meta.extn[2] << 8) | packet->meta.extn[3];
- packet->meta.extn_type = (packet->meta.extn[0] << 8) | packet->meta.extn[1];
+ if (packet->fields.x) {
+ packet->meta.extn = buffer12 + (packet->fields.cc * 4);
+ packet->meta.extn_len = (packet->meta.extn[2] << 8) | packet->meta.extn[3];
+ packet->meta.extn_type = (packet->meta.extn[0] << 8) | packet->meta.extn[1];
} else {
- packet->meta.extn = NULL;
- packet->meta.extn_len = 0;
- packet->meta.extn_type = 0;
+ packet->meta.extn = NULL;
+ packet->meta.extn_len = 0;
+ packet->meta.extn_type = 0;
}
packet->meta.data = (char *) buffer12 + (packet->fields.cc * 4);
- packet->meta.data_len = buflen - (packet->fields.cc * 4) - 12;
- if (packet->meta.extn != NULL) {
- packet->meta.data += ((packet->meta.extn_len + 1) * 4);
- packet->meta.data_len -= ((packet->meta.extn_len + 1) * 4);
+ packet->meta.data_len = buflen - (packet->fields.cc * 4) - 12;
+ if (packet->meta.extn != NULL) {
+ packet->meta.data += ((packet->meta.extn_len + 1) * 4);
+ packet->meta.data_len -= ((packet->meta.extn_len + 1) * 4);
}
if (validate_rtp(session, packet, buflen)) {
if (session->opt->wait_for_rtcp) {
- s = create_source(session, packet->fields.ssrc, TRUE);
+ s = create_source(session, packet->fields.ssrc, TRUE);
} else {
- s = get_source(session, packet->fields.ssrc);
+ s = get_source(session, packet->fields.ssrc);
}
if (session->opt->promiscuous_mode) {
if (s == NULL) {
- create_source(session, packet->fields.ssrc, FALSE);
- s = get_source(session, packet->fields.ssrc);
+ create_source(session, packet->fields.ssrc, FALSE);
+ s = get_source(session, packet->fields.ssrc);
}
process_rtp(session, curr_rtp_ts, packet, s);
return; /* We don't free "packet", that's done by the callback function... */
@@ -1416,9 +1419,9 @@
if (s != NULL) {
if (s->probation == -1) {
s->probation = MIN_SEQUENTIAL;
- s->max_seq = packet->fields.seq - 1;
+ s->max_seq = packet->fields.seq - 1;
}
- if (update_seq(s, packet->fields.seq)) {
+ if (update_seq(s, packet->fields.seq)) {
process_rtp(session, curr_rtp_ts, packet, s);
return; /* we don't free "packet", that's done by the callback function... */
} else {
@@ -1873,18 +1876,21 @@
*/
int rtp_recv(struct rtp *session, struct timeval *timeout, uint32_t curr_rtp_ts)
{
+ fd_set rfd;
+ fd_t max_fd;
check_database(session);
- udp_fd_zero();
- udp_fd_set(session->rtp_socket);
- udp_fd_set(session->rtcp_socket);
- if (udp_select(timeout) > 0) {
- if (udp_fd_isset(session->rtp_socket)) {
+
+ udp_fd_zero( &rfd, &max_fd );
+ udp_fd_set( &rfd, &max_fd, session->rtp_socket);
+ udp_fd_set( &rfd, &max_fd, session->rtcp_socket);
+ if (udp_select( &rfd, max_fd, timeout) > 0) {
+ if (udp_fd_isset( &rfd, &max_fd, session->rtp_socket)) {
rtp_recv_data(session, curr_rtp_ts);
}
- if (udp_fd_isset(session->rtcp_socket)) {
- char buffer[RTP_MAX_PACKET_LEN];
+ if (udp_fd_isset( &rfd, &max_fd, session->rtcp_socket)) {
+ uint8_t buffer[RTP_MAX_PACKET_LEN];
int buflen;
- buflen = udp_recv(session->rtcp_socket, buffer, RTP_MAX_PACKET_LEN);
+ buflen = udp_recv(session->rtcp_socket, (char *)buffer, RTP_MAX_PACKET_LEN);
rtp_process_ctrl(session, (unsigned char *)buffer, buflen);
}
check_database(session);
@@ -2199,42 +2205,42 @@
packet = (rtp_packet *) buffer;
/* These are internal pointers into the buffer... */
- packet->meta.csrc = (uint32_t *) (buffer + offsetof(rtp_packet, fields) + 12);
- packet->meta.extn = (uint8_t *) (buffer + offsetof(rtp_packet, fields) + 12 + (4 * cc));
+ packet->meta.csrc = (uint32_t *) (buffer + offsetof(rtp_packet, fields) + 12);
+ packet->meta.extn = (uint8_t *) (buffer + offsetof(rtp_packet, fields) + 12 + (4 * cc));
packet->meta.data = (char *) (buffer + offsetof(rtp_packet, fields) + 12 + (4 * cc));
if (extn != NULL) {
- packet->meta.data += (extn_len + 1) * 4;
+ packet->meta.data += (extn_len + 1) * 4;
}
/* ...and the actual packet header... */
- packet->fields.v = 2;
- packet->fields.p = pad;
- packet->fields.x = (extn != NULL);
- packet->fields.cc = cc;
- packet->fields.m = m;
- packet->fields.pt = pt;
- packet->fields.seq = htons(session->rtp_seq++);
- packet->fields.ts = htonl(rtp_ts);
- packet->fields.ssrc = htonl(rtp_my_ssrc(session));
+ packet->fields.v = 2;
+ packet->fields.p = pad;
+ packet->fields.x = (extn != NULL);
+ packet->fields.cc = cc;
+ packet->fields.m = m;
+ packet->fields.pt = pt;
+ packet->fields.seq = htons(session->rtp_seq++);
+ packet->fields.ts = htonl(rtp_ts);
+ packet->fields.ssrc = htonl(rtp_my_ssrc(session));
/* ...now the CSRC list... */
for (i = 0; i < cc; i++) {
- packet->meta.csrc[i] = htonl(csrc[i]);
+ packet->meta.csrc[i] = htonl(csrc[i]);
}
/* ...a header extension? */
if (extn != NULL) {
/* We don't use the packet->fields.extn_type field here, that's for receive only... */
- uint16_t *base = (uint16_t *) packet->meta.extn;
+ uint16_t *base = (uint16_t *) packet->meta.extn;
base[0] = htons(extn_type);
base[1] = htons(extn_len);
- memcpy(packet->meta.extn + 4, extn, extn_len * 4);
+ memcpy(packet->meta.extn + 4, extn, extn_len * 4);
}
/* ...and the media data... */
- memcpy(packet->meta.data, data, data_len);
+ memcpy(packet->meta.data, data, data_len);
/* ...and any padding... */
if (pad) {
for (i = 0; i < pad_len; i++) {
- buffer[buffer_len + offsetof(rtp_packet, fields) - pad_len + i] = 0;
+ buffer[buffer_len + offsetof(rtp_packet, fields) - pad_len + i] = 0;
}
- buffer[buffer_len + offsetof(rtp_packet, fields) - 1] = (char) pad_len;
+ buffer[buffer_len + offsetof(rtp_packet, fields) - 1] = (char) pad_len;
}
/* Finally, encrypt if desired... */
@@ -2245,7 +2251,7 @@
buffer_len, initVec);
}
- rc = udp_send(session->rtp_socket, buffer + offsetof(rtp_packet, fields), buffer_len);
+ rc = udp_send(session->rtp_socket, buffer + offsetof(rtp_packet, fields), buffer_len);
xfree(buffer);
/* Update the RTCP statistics... */
@@ -2284,39 +2290,39 @@
packet = (rtp_packet *) buffer;
/* These are internal pointers into the buffer... */
- packet->meta.csrc = (uint32_t *) (buffer + offsetof(rtp_packet, fields) + 12);
- packet->meta.extn = (uint8_t *) (buffer + offsetof(rtp_packet, fields) + 12 + (4 * cc));
+ packet->meta.csrc = (uint32_t *) (buffer + offsetof(rtp_packet, fields) + 12);
+ packet->meta.extn = (uint8_t *) (buffer + offsetof(rtp_packet, fields) + 12 + (4 * cc));
packet->meta.data = (char *) (buffer + offsetof(rtp_packet, fields) + 12 + (4 * cc));
if (extn != NULL) {
- packet->meta.data += (extn_len + 1) * 4;
+ packet->meta.data += (extn_len + 1) * 4;
}
/* ...and the actual packet header... */
- packet->fields.v = 2;
- packet->fields.p = 0;
- packet->fields.x = (extn != NULL);
- packet->fields.cc = cc;
- packet->fields.m = m;
- packet->fields.pt = pt;
- packet->fields.seq = htons(session->rtp_seq++);
- packet->fields.ts = htonl(rtp_ts);
- packet->fields.ssrc = htonl(rtp_my_ssrc(session));
+ packet->fields.v = 2;
+ packet->fields.p = 0;
+ packet->fields.x = (extn != NULL);
+ packet->fields.cc = cc;
+ packet->fields.m = m;
+ packet->fields.pt = pt;
+ packet->fields.seq = htons(session->rtp_seq++);
+ packet->fields.ts = htonl(rtp_ts);
+ packet->fields.ssrc = htonl(rtp_my_ssrc(session));
/* ...now the CSRC list... */
for (i = 0; i < cc; i++) {
- packet->meta.csrc[i] = htonl(csrc[i]);
+ packet->meta.csrc[i] = htonl(csrc[i]);
}
/* ...a header extension? */
if (extn != NULL) {
/* We don't use the packet->fields.extn_type field here, that's for receive only... */
- uint16_t *base = (uint16_t *) packet->meta.extn;
+ uint16_t *base = (uint16_t *) packet->meta.extn;
base[0] = htons(extn_type);
base[1] = htons(extn_len);
- memcpy(packet->meta.extn + 4, extn, extn_len * 4);
+ memcpy(packet->meta.extn + 4, extn, extn_len * 4);
}
/* Add the RTP packet header to the beginning of the iov list */
my_iov = (struct iovec*)xmalloc(my_iov_count * sizeof(struct iovec));
- my_iov[0].iov_base = buffer + offsetof(rtp_packet, fields);
+ my_iov[0].iov_base = buffer + offsetof(rtp_packet, fields);
my_iov[0].iov_len = buffer_len;
for (i = 1; i < my_iov_count; i++) {
@@ -2584,12 +2590,12 @@
assert(buflen >= pkt_octets); /* ...else there isn't space for the APP packet. */
/* Copy one APP packet from "app" to "packet". */
- packet->version = RTP_VERSION;
- packet->p = app->p;
- packet->subtype = app->subtype;
- packet->pt = RTCP_APP;
- packet->length = htons(app->length);
- packet->ssrc = htonl(ssrc);
+ packet->version = RTP_VERSION;
+ packet->p = app->p;
+ packet->subtype = app->subtype;
+ packet->pt = RTCP_APP;
+ packet->length = htons(app->length);
+ packet->ssrc = htonl(ssrc);
memcpy(packet->name, app->name, 4);
memcpy(packet->data, app->data, data_octets);
@@ -2894,6 +2900,9 @@
uint8_t buffer[RTP_MAX_PACKET_LEN];
int buflen;
double new_interval;
+ fd_set rfd;
+ fd_t max_fd;
+
check_database(session);
@@ -2928,11 +2937,11 @@
timeout.tv_sec = 0;
timeout.tv_usec = 0;
tv_add(&timeout, tv_diff(session->next_rtcp_send_time, curr_time));
- udp_fd_zero();
- udp_fd_set(session->rtcp_socket);
- if ((udp_select(&timeout) > 0) && udp_fd_isset(session->rtcp_socket)) {
+ udp_fd_zero( &rfd, &max_fd );
+ udp_fd_set( &rfd, &max_fd, session->rtcp_socket);
+ if ((udp_select(&rfd, max_fd, &timeout) > 0) && udp_fd_isset( &rfd, &max_fd, session->rtcp_socket)) {
/* We woke up because an RTCP packet was received; process it... */
- buflen = udp_recv(session->rtcp_socket, (char *) buffer, RTP_MAX_PACKET_LEN);
+ buflen = udp_recv(session->rtcp_socket, (char *)buffer, RTP_MAX_PACKET_LEN);
rtp_process_ctrl(session, buffer, buflen);
}
/* Is it time to send our BYE? */
@@ -3092,7 +3101,7 @@
MD5Init(&context);
MD5Update(&context, (u_char *) canonical_passphrase, strlen(canonical_passphrase));
MD5Final((u_char *) hash, &context);
-
+
/* Initialize the encryption algorithm we've received */
if (strcmp(session->encryption_algorithm, "DES") == 0)
Modified: common/trunk/src/rtp.h
==============================================================================
--- common/trunk/src/rtp.h (original)
+++ common/trunk/src/rtp.h Wed Nov 15 18:11:13 2006
@@ -61,14 +61,14 @@
/* having to free the csrc, data and extn blocks separately. */
/* WARNING: Don't change the size of the first portion of the */
/* struct without changing RTP_PACKET_HEADER_SIZE to match. */
- struct _meta {
+ struct _meta {
uint32_t *csrc;
char *data;
int data_len;
unsigned char *extn;
uint16_t extn_len; /* Size of the extension in 32 bit words minus one */
uint16_t extn_type; /* Extension type field in the RTP packet header */
- } meta;
+ } meta;
struct _fields {
/* The following map directly onto the RTP packet header... */
@@ -204,6 +204,12 @@
rtp_callback callback,
uint8_t *userdata);
+int rtp_set_umtp_dest(struct rtp *session,
+ const char *addr,
+ uint16_t port,
+ uint16_t src_cookie,
+ uint16_t dst_cookie);
+
void rtp_send_bye(struct rtp *session);
void rtp_done(struct rtp *session);
@@ -249,4 +255,6 @@
int rtp_get_ttl(struct rtp *session);
uint8_t *rtp_get_userdata(struct rtp *session);
+int rtp_get_ssrc_count(struct rtp *session);
+
#endif /* __RTP_H__ */
Modified: common/trunk/src/sap.c
==============================================================================
--- common/trunk/src/sap.c (original)
+++ common/trunk/src/sap.c Wed Nov 15 18:11:13 2006
@@ -96,11 +96,13 @@
sap_packet sap_p;
sap_header *sap_h;
static unsigned char *packetptr;
+ fd_set rfd;
+ fd_t max_fd;
- udp_fd_zero();
- udp_fd_set(s->s);
- if(udp_select(timeout) > 0) {
- if(udp_fd_isset(s->s)) {
+ udp_fd_zero( &rfd, &max_fd );
+ udp_fd_set( &rfd, &max_fd, s->s);
+ if(udp_select( &rfd, max_fd, timeout) > 0) {
+ if(udp_fd_isset( &rfd, &max_fd, s->s)) {
uint8_t buffer[SAP_MAX_PACKET_LEN];
int buflen;
buflen = udp_recv(s->s, (char *)buffer, SAP_MAX_PACKET_LEN);
Modified: common/trunk/tests/test_net_udp.c
==============================================================================
--- common/trunk/tests/test_net_udp.c (original)
+++ common/trunk/tests/test_net_udp.c Wed Nov 15 18:11:13 2006
@@ -57,6 +57,9 @@
char buf1[BUFSIZE], buf2[BUFSIZE];
const char *hname;
int rc, i;
+ fd_set rfd;
+ fd_t max_fd;
+
#ifndef WIN32
@@ -87,9 +90,9 @@
}
timeout.tv_sec = 1;
timeout.tv_usec = 0;
- udp_fd_zero();
- udp_fd_set(s1);
- rc = udp_select(&timeout);
+ udp_fd_zero( &rfd, &max_fd );
+ udp_fd_set( &rfd, &max_fd, s1 );
+ rc = udp_select(&rfd, max_fd, &timeout);
if (rc < 0) {
perror("fail");
goto abort_loopback;
@@ -98,7 +101,7 @@
printf("fail: no data waiting\n");
goto abort_loopback;
}
- if (!udp_fd_isset(s1)) {
+ if (!udp_fd_isset(&rfd, &max_fd, s1)) {
printf("fail: no data on file descriptor\n");
goto abort_loopback;
}
@@ -138,10 +141,10 @@
}
timeout.tv_sec = 1;
timeout.tv_usec = 0;
- udp_fd_zero();
- udp_fd_set(s1);
- udp_fd_set(s2);
- rc = udp_select(&timeout);
+ udp_fd_zero( &rfd, &max_fd );
+ udp_fd_set( &rfd, &max_fd, s1 );
+ udp_fd_set( &rfd, &max_fd, s2 );
+ rc = udp_select(&rfd, max_fd, &timeout);
if (rc < 0) {
perror("fail");
goto abort_unicast;
@@ -150,7 +153,7 @@
printf("fail: no data waiting (no route to %s?)\n", hname);
goto abort_unicast;
}
- if (!udp_fd_isset(s2)) {
+ if (!udp_fd_isset(&rfd, &max_fd, s2)) {
printf("fail: no data on file descriptor\n");
goto abort_unicast;
}
@@ -183,9 +186,9 @@
}
timeout.tv_sec = 1;
timeout.tv_usec = 0;
- udp_fd_zero();
- udp_fd_set(s1);
- rc = udp_select(&timeout);
+ udp_fd_zero( &rfd, &max_fd );
+ udp_fd_set( &rfd, &max_fd, s1 );
+ rc = udp_select(&rfd, max_fd, &timeout);
if (rc < 0) {
perror("fail");
goto abort_multicast;
@@ -194,7 +197,7 @@
printf("fail: no data waiting (no multicast loopback route?)\n");
goto abort_multicast;
}
- if (!udp_fd_isset(s1)) {
+ if (!udp_fd_isset(&rfd, &max_fd, s1)) {
printf("fail: no data on file descriptor\n");
goto abort_multicast;
}
@@ -227,9 +230,9 @@
}
timeout.tv_sec = 1;
timeout.tv_usec = 0;
- udp_fd_zero();
- udp_fd_set(s1);
- rc = udp_select(&timeout);
+ udp_fd_zero( &rfd, &max_fd );
+ udp_fd_set( &rfd, &max_fd, s1 );
+ rc = udp_select(&rfd, max_fd, &timeout);
if (rc < 0) {
perror("fail");
goto abort_length;
@@ -238,7 +241,7 @@
printf("fail: no data waiting (no multicast loopback route?)\n");
goto abort_length;
}
- if (!udp_fd_isset(s1)) {
+ if (!udp_fd_isset(&rfd, &max_fd, s1)) {
printf("fail: no data on file descriptor\n");
goto abort_length;
}
@@ -274,9 +277,9 @@
}
timeout.tv_sec = 1;
timeout.tv_usec = 0;
- udp_fd_zero();
- udp_fd_set(s1);
- rc = udp_select(&timeout);
+ udp_fd_zero( &rfd, &max_fd );
+ udp_fd_set( &rfd, &max_fd, s1 );
+ rc = udp_select(&rfd, max_fd, &timeout);
if (rc < 0) {
perror("fail");
goto abort_loopback_ipv6;
@@ -285,7 +288,7 @@
printf("fail: no data waiting\n");
goto abort_loopback_ipv6;
}
- if (!udp_fd_isset(s1)) {
+ if (!udp_fd_isset(&rfd, &max_fd, s1)) {
printf("fail: no data on file descriptor\n");
goto abort_loopback_ipv6;
}
@@ -318,9 +321,9 @@
}
timeout.tv_sec = 1;
timeout.tv_usec = 0;
- udp_fd_zero();
- udp_fd_set(s1);
- rc = udp_select(&timeout);
+ udp_fd_zero( &rfd, &max_fd );
+ udp_fd_set( &rfd, &max_fd, s1 );
+ rc = udp_select(&rfd, max_fd, &timeout);
if (rc < 0) {
perror("fail");
goto abort_multicast_ipv6;
@@ -329,7 +332,7 @@
printf("fail: no data waiting (no multicast loopback route?)\n");
goto abort_multicast_ipv6;
}
- if (!udp_fd_isset(s1)) {
+ if (!udp_fd_isset(&rfd, &max_fd, s1)) {
printf("fail: no data on file descriptor\n");
goto abort_multicast_ipv6;
}
@@ -381,9 +384,9 @@
}
timeout.tv_sec = 10;
timeout.tv_usec = 0;
- udp_fd_zero();
- udp_fd_set(s2);
- rc = udp_select(&timeout);
+ udp_fd_zero( &rfd, &max_fd );
+ udp_fd_set( &rfd, &max_fd, s2 );
+ rc = udp_select(&rfd, max_fd, &timeout);
if (rc < 0) {
perror("fail (child)");
exit(0);
@@ -392,7 +395,7 @@
printf("fail (child): no data waiting (no multicast loopback route?)\n");
exit(0);
}
- if (!udp_fd_isset(s2)) {
+ if (!udp_fd_isset(&rfd, &max_fd, s2)) {
printf("fail (child): no data on file descriptor\n");
exit(0);
}
@@ -415,9 +418,9 @@
/* parent */
timeout.tv_sec = 10;
timeout.tv_usec = 0;
- udp_fd_zero();
- udp_fd_set(s1);
- rc = udp_select(&timeout);
+ udp_fd_zero( &rfd, &max_fd );
+ udp_fd_set( &rfd, &max_fd, s1 );
+ rc = udp_select(&rfd, max_fd, &timeout);
if (rc < 0) {
perror("fail (parent)");
goto abort_bsd;
@@ -426,7 +429,7 @@
printf("fail (parent): no data waiting (no multicast loopback route?)\n");
goto abort_bsd;
}
- if (!udp_fd_isset(s1)) {
+ if (!udp_fd_isset(&rfd, &max_fd, s1)) {
printf("fail (parent): no data on file descriptor\n");
goto abort_bsd;
}
More information about the Sumover-dev
mailing list