comparison 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
comparison
equal deleted inserted replaced
186:068fce34e565 187:258932879f8b
1 /*
2 * In this module we implement our RTP handling: obtaining a PSTN-side
3 * RTP endpoint from themwi-rtp-mgr, then handling read select on RTP
4 * and RTCP UDP sockets.
5 */
6
7 #include <sys/types.h>
8 #include <sys/socket.h>
9 #include <netinet/in.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <strings.h>
14 #include "../include/tmgw_const.h"
15 #include "../librtpalloc/rtp_alloc_simple.h"
16
17 struct sockaddr_in rtp_local_addr;
18 int rtp_udp_fd, rtcp_udp_fd;
19
20 static int got_some_rtp, got_some_rtcp;
21
22 void
23 obtain_rtp_endp()
24 {
25 int rc;
26 struct rtp_alloc_simple res;
27
28 rc = rtp_alloc_simple(TMGW_EP_TYPE_PSTN_ONLY, &res);
29 if (rc < 0)
30 exit(1); /* error msg already printed */
31 bcopy(&res.pstn_addr, &rtp_local_addr, sizeof(struct sockaddr_in));
32 rtp_udp_fd = res.pstn_rtp_fd;
33 rtcp_udp_fd = res.pstn_rtcp_fd;
34 }
35
36 void
37 rtp_rx_select()
38 {
39 u_char buf[512];
40
41 recv(rtp_udp_fd, buf, sizeof buf, 0);
42 if (!got_some_rtp) {
43 printf("Got some RTP\n");
44 got_some_rtp = 1;
45 }
46 }
47
48 void
49 rtcp_rx_select()
50 {
51 u_char buf[512];
52
53 recv(rtcp_udp_fd, buf, sizeof buf, 0);
54 if (!got_some_rtcp) {
55 printf("Got some RTCP\n");
56 got_some_rtcp = 1;
57 }
58 }