FreeCalypso > hg > themwi-system-sw
annotate sip-manual-out/main.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 | a36b731bfef9 |
children | f8a33603288f |
rev | line source |
---|---|
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This is the main module for sip-manual-out test program. |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/time.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/socket.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <sys/errno.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <netinet/in.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <arpa/inet.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdio.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <stdlib.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <string.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <strings.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <unistd.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "../libsip/out_msg.h" |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "../libsip/sdp.h" |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 extern int sip_socket; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 extern struct in_addr sip_bind_ip, sip_dest_ip; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 extern unsigned sip_bind_port, sip_dest_port; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 extern char sip_dest_domain[]; |
187
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
23 extern struct sockaddr_in rtp_local_addr; |
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
24 extern int rtp_udp_fd, rtcp_udp_fd; |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 struct sockaddr_in sip_dest_sin; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 char from_uri[128], to_uri[128], call_id[128]; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 struct timeval cur_event_time; |
120
c62d0f28da6f
sip-manual-out: make Max-Forwards configurable
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
29 unsigned max_forwards = 70; |
121
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
30 int declare_100rel_supp; |
122
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
31 int pcma_codec_pref, pcma_codec_force; |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 send_invite_req() |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 struct sip_msg_out msg; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 struct sdp_gen sdp; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 int rc; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 rc = start_request_out_msg(&msg, "INVITE", to_uri); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 if (rc < 0) { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 msg_size_err: fprintf(stderr, "composing INVITE req: msg size error\n"); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 exit(1); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 } |
123
a36b731bfef9
sip-manual-out: implement sending BYE and CANCEL
Mychaela Falconia <falcon@freecalypso.org>
parents:
122
diff
changeset
|
44 rc = add_req_boilerplate(&msg, "1 INVITE", 0); |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 if (rc < 0) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 goto msg_size_err; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 rc = add_contact_header(&msg); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 if (rc < 0) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 goto msg_size_err; |
121
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
50 if (declare_100rel_supp) { |
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
51 rc = out_msg_add_header(&msg, "Supported", "100rel"); |
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
52 if (rc < 0) |
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
53 goto msg_size_err; |
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
54 } |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 rc = out_msg_add_header(&msg, "Content-Type", "application/sdp"); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 if (rc < 0) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 goto msg_size_err; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 bzero(&sdp, sizeof sdp); |
187
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
59 sdp.conn_ip = rtp_local_addr.sin_addr; |
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
60 sdp.conn_port = ntohs(rtp_local_addr.sin_port); |
122
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
61 if (pcma_codec_force) |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
62 sdp.codec_mask = SDP_CODEC_MASK_PCMA; |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
63 else { |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
64 sdp.codec_mask = SDP_CODEC_MASK_BOTH; |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
65 if (pcma_codec_pref) |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
66 sdp.codec_mask |= SDP_CODEC_MASK_PCMA_PREF; |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
67 } |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 sdp.session_id = sdp.conn_port << 16; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 sdp.owner_ip = sip_bind_ip; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 rc = out_msg_finish_sdp(&msg, &sdp); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 if (rc < 0) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 goto msg_size_err; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 sip_tx_packet(&msg, &sip_dest_sin); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 } |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 |
119
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
76 static void |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
77 preliminary_proc(argc, argv) |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
78 char **argv; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
79 { |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
80 extern int optind; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
81 extern char *optarg; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
82 char *logfile; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
83 int opt, rc; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
84 |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
85 logfile = 0; |
122
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
86 while ((opt = getopt(argc, argv, "aAl:m:r")) != EOF) { |
119
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
87 switch (opt) { |
122
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
88 case 'a': |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
89 pcma_codec_pref = 1; |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
90 continue; |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
91 case 'A': |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
92 pcma_codec_force = 1; |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
93 continue; |
119
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
94 case 'l': |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
95 logfile = optarg; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
96 continue; |
120
c62d0f28da6f
sip-manual-out: make Max-Forwards configurable
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
97 case 'm': |
c62d0f28da6f
sip-manual-out: make Max-Forwards configurable
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
98 max_forwards = atoi(optarg); |
c62d0f28da6f
sip-manual-out: make Max-Forwards configurable
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
99 continue; |
121
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
100 case 'r': |
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
101 declare_100rel_supp = 1; |
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
102 continue; |
119
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
103 default: |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
104 usage: |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
105 fprintf(stderr, |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
106 "usage: %s [options] dest-conf from-num to-num\n", |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
107 argv[0]); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
108 exit(1); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
109 } |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
110 } |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
111 if (argc != optind + 3) |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
112 goto usage; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
113 read_config_file(argv[optind]); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
114 open_sip_udp_socket(); |
187
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
115 obtain_rtp_endp(); |
119
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
116 sip_dest_sin.sin_family = AF_INET; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
117 sip_dest_sin.sin_addr = sip_dest_ip; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
118 sip_dest_sin.sin_port = htons(sip_dest_port); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
119 sprintf(from_uri, "<sip:%s@%s>;tag=out%u", argv[optind+1], |
187
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
120 inet_ntoa(sip_bind_ip), ntohs(rtp_local_addr.sin_port)); |
119
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
121 sprintf(to_uri, "sip:%s@%s", argv[optind+2], sip_dest_domain); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
122 if (logfile) { |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
123 rc = open_sip_log_file(logfile); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
124 if (rc < 0) |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
125 exit(1); /* error msg already printed */ |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
126 } |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
127 } |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
128 |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 main(argc, argv) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 char **argv; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 fd_set fds; |
187
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
133 int rc, max_fd; |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 |
119
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
135 preliminary_proc(argc, argv); |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 gettimeofday(&cur_event_time, 0); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 sprintf(call_id, "%08u_%u@%s", |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 (unsigned)(cur_event_time.tv_sec % 100000000), |
187
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
139 ntohs(rtp_local_addr.sin_port), inet_ntoa(sip_bind_ip)); |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 send_invite_req(); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 /* main select loop */ |
187
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
142 max_fd = sip_socket; |
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
143 if (rtp_udp_fd > max_fd) |
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
144 max_fd = rtp_udp_fd; |
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
145 if (rtcp_udp_fd > max_fd) |
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
146 max_fd = rtcp_udp_fd; |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 for (;;) { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 FD_ZERO(&fds); |
123
a36b731bfef9
sip-manual-out: implement sending BYE and CANCEL
Mychaela Falconia <falcon@freecalypso.org>
parents:
122
diff
changeset
|
149 FD_SET(0, &fds); |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 FD_SET(sip_socket, &fds); |
187
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
151 FD_SET(rtp_udp_fd, &fds); |
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
152 FD_SET(rtcp_udp_fd, &fds); |
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
153 rc = select(max_fd+1, &fds, 0, 0, 0); |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 if (rc < 0) { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 if (errno == EINTR) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 continue; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 perror("select"); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 exit(1); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 } |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 gettimeofday(&cur_event_time, 0); |
123
a36b731bfef9
sip-manual-out: implement sending BYE and CANCEL
Mychaela Falconia <falcon@freecalypso.org>
parents:
122
diff
changeset
|
161 if (FD_ISSET(0, &fds)) |
a36b731bfef9
sip-manual-out: implement sending BYE and CANCEL
Mychaela Falconia <falcon@freecalypso.org>
parents:
122
diff
changeset
|
162 select_stdin(); |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 if (FD_ISSET(sip_socket, &fds)) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 sip_socket_select(); |
187
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
165 if (FD_ISSET(rtp_udp_fd, &fds)) |
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
166 rtp_rx_select(); |
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
167 if (FD_ISSET(rtcp_udp_fd, &fds)) |
258932879f8b
sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
123
diff
changeset
|
168 rtcp_rx_select(); |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 } |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 } |