FreeCalypso > hg > themwi-system-sw
diff sip-manual-out/rtp.c @ 187:258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 16 Mar 2023 23:46:17 -0800 |
parents | |
children | 6aecee01cf0a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sip-manual-out/rtp.c Thu Mar 16 23:46:17 2023 -0800 @@ -0,0 +1,58 @@ +/* + * In this module we implement our RTP handling: obtaining a PSTN-side + * RTP endpoint from themwi-rtp-mgr, then handling read select on RTP + * and RTCP UDP sockets. + */ + +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include "../include/tmgw_const.h" +#include "../librtpalloc/rtp_alloc_simple.h" + +struct sockaddr_in rtp_local_addr; +int rtp_udp_fd, rtcp_udp_fd; + +static int got_some_rtp, got_some_rtcp; + +void +obtain_rtp_endp() +{ + int rc; + struct rtp_alloc_simple res; + + rc = rtp_alloc_simple(TMGW_EP_TYPE_PSTN_ONLY, &res); + if (rc < 0) + exit(1); /* error msg already printed */ + bcopy(&res.pstn_addr, &rtp_local_addr, sizeof(struct sockaddr_in)); + rtp_udp_fd = res.pstn_rtp_fd; + rtcp_udp_fd = res.pstn_rtcp_fd; +} + +void +rtp_rx_select() +{ + u_char buf[512]; + + recv(rtp_udp_fd, buf, sizeof buf, 0); + if (!got_some_rtp) { + printf("Got some RTP\n"); + got_some_rtp = 1; + } +} + +void +rtcp_rx_select() +{ + u_char buf[512]; + + recv(rtcp_udp_fd, buf, sizeof buf, 0); + if (!got_some_rtcp) { + printf("Got some RTCP\n"); + got_some_rtcp = 1; + } +}