FreeCalypso > hg > themwi-interim
comparison mtctest/main.c @ 6:33d8b3177540
mtctest compiles in the new environment
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 09 Jun 2024 01:55:28 +0000 |
parents | e7b192a5dee5 |
children | a902ccbf6bbc |
comparison
equal
deleted
inserted
replaced
5:e7b192a5dee5 | 6:33d8b3177540 |
---|---|
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
11 #include <syslog.h> | 11 #include <syslog.h> |
12 #include <unistd.h> | 12 #include <unistd.h> |
13 #include <themwi/rtp/rtp_alloc_simple.h> | |
13 | 14 |
14 extern int mtc_socket; | 15 extern int mtc_socket; |
15 extern int disconnect_mode; | 16 extern int disconnect_mode; |
17 extern struct rtp_alloc_simple rtp_info; | |
16 | 18 |
17 struct timeval cur_event_time; | 19 struct timeval cur_event_time; |
18 | 20 |
19 static void | 21 static void |
20 drain_stdin() | 22 drain_stdin() |
29 { | 31 { |
30 extern int optind; | 32 extern int optind; |
31 extern char *optarg; | 33 extern char *optarg; |
32 char *from; | 34 char *from; |
33 fd_set fds; | 35 fd_set fds; |
34 int c; | 36 int c, max_fd; |
35 | 37 |
36 from = 0; | 38 from = 0; |
37 while ((c = getopt(argc, argv, "f:")) != EOF) { | 39 while ((c = getopt(argc, argv, "f:")) != EOF) { |
38 switch (c) { | 40 switch (c) { |
39 case 'f': | 41 case 'f': |
49 } | 51 } |
50 if (argc != optind + 1) | 52 if (argc != optind + 1) |
51 goto usage; | 53 goto usage; |
52 openlog("themwi-test-mtc", 0, LOG_LOCAL5); | 54 openlog("themwi-test-mtc", 0, LOG_LOCAL5); |
53 init_setup_msg(from, argv[optind]); | 55 init_setup_msg(from, argv[optind]); |
54 obtain_dummy_rtp(); | 56 obtain_rtp_endp(); |
55 connect_mtc_socket(); | 57 connect_mtc_socket(); |
56 send_setup_msg(); | 58 send_setup_msg(); |
57 /* main select loop */ | 59 /* main select loop */ |
60 max_fd = mtc_socket; | |
61 if (rtp_info.gsm_rtp_fd > mtc_socket) | |
62 max_fd = rtp_info.gsm_rtp_fd; | |
63 if (rtp_info.gsm_rtcp_fd > mtc_socket) | |
64 max_fd = rtp_info.gsm_rtcp_fd; | |
58 for (;;) { | 65 for (;;) { |
59 FD_ZERO(&fds); | 66 FD_ZERO(&fds); |
60 FD_SET(mtc_socket, &fds); | 67 FD_SET(mtc_socket, &fds); |
68 FD_SET(rtp_info.gsm_rtp_fd, &fds); | |
69 FD_SET(rtp_info.gsm_rtcp_fd, &fds); | |
61 if (!disconnect_mode) | 70 if (!disconnect_mode) |
62 FD_SET(0, &fds); | 71 FD_SET(0, &fds); |
63 c = select(mtc_socket+1, &fds, 0, 0, 0); | 72 c = select(max_fd+1, &fds, 0, 0, 0); |
64 if (c < 0) { | 73 if (c < 0) { |
65 if (errno == EINTR) | 74 if (errno == EINTR) |
66 continue; | 75 continue; |
67 perror("select"); | 76 perror("select"); |
68 exit(1); | 77 exit(1); |
72 mtc_socket_select(); | 81 mtc_socket_select(); |
73 if (!disconnect_mode && FD_ISSET(0, &fds)) { | 82 if (!disconnect_mode && FD_ISSET(0, &fds)) { |
74 drain_stdin(); | 83 drain_stdin(); |
75 send_disconnect_req(); | 84 send_disconnect_req(); |
76 } | 85 } |
86 if (FD_ISSET(rtp_info.gsm_rtp_fd, &fds)) | |
87 rtp_rx_select(); | |
88 if (FD_ISSET(rtp_info.gsm_rtcp_fd, &fds)) | |
89 rtcp_rx_select(); | |
77 } | 90 } |
78 } | 91 } |