[svn-commits] file: branch 1.4 r48461 - /branches/1.4/main/rtp.c
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Wed Dec 13 20:33:30 MST 2006
Author: file
Date: Wed Dec 13 21:33:30 2006
New Revision: 48461
URL: http://svn.digium.com/view/asterisk?view=rev&rev=48461
Log:
Remove direct RTCP bridging. I've come to the conclusion that we should handle this through the core and not just forward it on. Should solve a few bugs.
Modified:
branches/1.4/main/rtp.c
Modified: branches/1.4/main/rtp.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/rtp.c?view=diff&rev=48461&r1=48460&r2=48461
==============================================================================
--- branches/1.4/main/rtp.c (original)
+++ branches/1.4/main/rtp.c Wed Dec 13 21:33:30 2006
@@ -177,7 +177,6 @@
static unsigned int ast_rtcp_calc_interval(struct ast_rtp *rtp);
static int ast_rtp_senddigit_continuation(struct ast_rtp *rtp);
int ast_rtp_senddigit_end(struct ast_rtp *rtp, char digit);
-static int bridge_p2p_rtcp_write(struct ast_rtp *rtp, unsigned int *rtcpheader, int len);
#define FLAG_3389_WARNING (1 << 0)
#define FLAG_NAT_ACTIVE (3 << 1)
@@ -857,10 +856,6 @@
ast_log(LOG_DEBUG, "RTCP NAT: Got RTCP from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
}
}
-
- /* If we are P2P bridged to another RTP stream, send it directly over */
- if (ast_rtp_get_bridged(rtp) && !bridge_p2p_rtcp_write(rtp, rtcpheader, res))
- return &ast_null_frame;
if (option_debug)
ast_log(LOG_DEBUG, "Got RTCP report of %d bytes\n", res);
@@ -1015,29 +1010,6 @@
rtp->rtcp->minrxjitter = rtp->rxjitter;
}
-/*! \brief Perform a Packet2Packet RTCP write */
-static int bridge_p2p_rtcp_write(struct ast_rtp *rtp, unsigned int *rtcpheader, int len)
-{
- struct ast_rtp *bridged = ast_rtp_get_bridged(rtp);
- int res = 0;
-
- /* If RTCP is not present on the bridged RTP session, then ignore this */
- if (!bridged->rtcp)
- return 0;
-
- /* Send the data out */
- res = sendto(bridged->rtcp->s, (void *)rtcpheader, len, 0, (struct sockaddr *)&bridged->rtcp->them, sizeof(bridged->rtcp->them));
- if (res < 0) {
- if (!bridged->nat || (bridged->nat && (ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_ACTIVE)))
- ast_log(LOG_DEBUG, "RTCP Transmission error of packet to %s:%d: %s\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port), strerror(errno));
- else if ((((ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug)) && (option_debug || rtpdebug))
- ast_log(LOG_DEBUG, "RTCP NAT: Can't write RTCP to private address %s:%d, waiting for other end to send first...\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port));
- } else if (rtp_debug_test_addr(&bridged->rtcp->them))
- ast_verbose("Sent RTCP P2P packet to %s:%d (len %-6.6u)\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port), len);
-
- return 0;
-}
-
/*! \brief Perform a Packet2Packet RTP write */
static int bridge_p2p_rtp_write(struct ast_rtp *rtp, unsigned int *rtpheader, int len, int hdrlen)
{
@@ -2876,39 +2848,6 @@
return 1;
}
-/*! \brief P2P RTCP Callback */
-static int p2p_rtcp_callback(int *id, int fd, short events, void *cbdata)
-{
- int res = 0;
- struct sockaddr_in sin;
- socklen_t len;
- unsigned int *header;
- struct ast_rtp *rtp = cbdata;
- struct ast_rtcp *rtcp = NULL;
-
- if (!rtp || !(rtcp = rtp->rtcp))
- return 1;
-
- len = sizeof(sin);
- if ((res = recvfrom(fd, rtp->rawdata + AST_FRIENDLY_OFFSET, sizeof(rtp->rawdata) - AST_FRIENDLY_OFFSET, 0, (struct sockaddr *)&sin, &len)) < 0)
- return 1;
-
- header = (unsigned int *)(rtp->rawdata + AST_FRIENDLY_OFFSET);
-
- if ((rtp->nat) &&
- ((rtcp->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
- (rtcp->them.sin_port != sin.sin_port))) {
- rtcp->them = sin;
- if (option_debug || rtpdebug)
- ast_log(LOG_DEBUG, "P2P RTCP NAT: Got RTCP from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtcp->them.sin_addr), ntohs(rtcp->them.sin_port));
- }
-
- if (ast_rtp_get_bridged(rtp))
- bridge_p2p_rtcp_write(rtp, header, res);
-
- return 1;
-}
-
/*! \brief Helper function to switch a channel and RTP stream into callback mode */
static int p2p_callback_enable(struct ast_channel *chan, struct ast_rtp *rtp, int *fds, int **iod)
{
@@ -2924,14 +2863,10 @@
/* Steal the file descriptors from the channel and stash them away */
fds[0] = chan->fds[0];
- fds[1] = chan->fds[1];
chan->fds[0] = -1;
- chan->fds[1] = -1;
/* Now, fire up callback mode */
iod[0] = ast_io_add(rtp->io, fds[0], p2p_rtp_callback, AST_IO_IN, rtp);
- if (fds[1] >= 0)
- iod[1] = ast_io_add(rtp->io, fds[1], p2p_rtcp_callback, AST_IO_IN, rtp);
return 1;
}
@@ -2944,17 +2879,13 @@
/* Remove the callback from the IO context */
ast_io_remove(rtp->io, iod[0]);
- if (iod[1])
- ast_io_remove(rtp->io, iod[1]);
-
/* Restore file descriptors */
chan->fds[0] = fds[0];
- chan->fds[1] = fds[1];
ast_channel_unlock(chan);
/* Restore callback mode if previously used */
if (ast_test_flag(rtp, FLAG_CALLBACK_MODE))
- rtp->ioid = ast_io_add(rtp->io, rtp->s, rtpread, AST_IO_IN, rtp);
+ rtp->ioid = ast_io_add(rtp->io, rtp->s, rtpread, AST_IO_IN, rtp);
return 0;
}
More information about the svn-commits
mailing list