FreeCalypso > hg > sipout-test-utils
annotate test-voice/user_cmd.c @ 18:f7321b25195e default tip
new build system for ThemWi sw components
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 14 May 2024 18:08:35 -0800 |
parents | 71f01a834820 |
children |
rev | line source |
---|---|
0
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we implement stdin command handling, supporting |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * user-initiated CANCEL and BYE as well as TFO testing commands. |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <ctype.h> |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdlib.h> |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <string.h> |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <strings.h> |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 static void |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 pcm_fill_cmd(arg) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 char *arg; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 { |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 char *cp; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 unsigned octet; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 for (cp = arg; isspace(*cp); cp++) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 ; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 if (!isxdigit(*cp)) { |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 inv_syntax: fprintf(stderr, "error: pcm-fill command invalid syntax\n"); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 return; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 } |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 octet = strtoul(cp, &cp, 16); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 if (*cp) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 goto inv_syntax; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 if (octet > 0xFF) { |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 fprintf(stderr, |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 "error: pcm-fill octet argument out of range\n"); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 return; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 set_pcm_fill_octet(octet); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 static void |
15
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
37 play_cmd_plain(args) |
14
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
38 char *args; |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
39 { |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
40 char *cp, *filename; |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
41 int loop; |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
42 |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
43 for (cp = args; isspace(*cp); cp++) |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
44 ; |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
45 if (!*cp) { |
15
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
46 inv_syntax: fprintf(stderr, "error: play command invalid syntax\n"); |
14
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
47 return; |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
48 } |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
49 for (filename = cp; *cp && !isspace(*cp); cp++) |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
50 ; |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
51 if (*cp) { |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
52 *cp++ = '\0'; |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
53 while (isspace(*cp)) |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
54 cp++; |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
55 if (strcmp(cp, "loop")) |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
56 goto inv_syntax; |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
57 loop = 1; |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
58 } else |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
59 loop = 0; |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
60 play_file_cmdop(filename, loop); |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
61 } |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
62 |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
63 static void |
15
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
64 play_cmd_offset(args) |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
65 char *args; |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
66 { |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
67 char *cp, *filename; |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
68 unsigned offset; |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
69 |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
70 for (cp = args; isspace(*cp); cp++) |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
71 ; |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
72 if (!*cp) { |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
73 inv_syntax: fprintf(stderr, "error: play-offset command invalid syntax\n"); |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
74 return; |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
75 } |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
76 for (filename = cp; *cp && !isspace(*cp); cp++) |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
77 ; |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
78 if (!*cp) |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
79 goto inv_syntax; |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
80 *cp++ = '\0'; |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
81 while (isspace(*cp)) |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
82 cp++; |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
83 if (!isdigit(*cp)) |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
84 goto inv_syntax; |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
85 offset = strtoul(cp, &cp, 0); |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
86 if (*cp && !isspace(*cp)) |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
87 goto inv_syntax; |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
88 if (offset < 1 || offset > 159) { |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
89 fprintf(stderr, "error: offset argument out of range\n"); |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
90 return; |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
91 } |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
92 while (isspace(*cp)) |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
93 cp++; |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
94 if (*cp) |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
95 goto inv_syntax; |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
96 play_file_offset(filename, offset); |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
97 } |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
98 |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
99 static void |
0
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 tfo_req_cmd(args) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 char *args; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 { |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 char *cp; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 unsigned sig, codec; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 for (cp = args; isspace(*cp); cp++) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 ; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 if (!isdigit(*cp)) { |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 inv_syntax: fprintf(stderr, "error: tfo-req command invalid syntax\n"); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 return; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 } |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 sig = strtoul(cp, &cp, 0); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 if (!isspace(*cp)) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 goto inv_syntax; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 if (sig > 0xFF) { |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 fprintf(stderr, "error: Sig argument out of range\n"); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 return; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 } |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 while (isspace(*cp)) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 cp++; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 if (!isdigit(*cp)) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 goto inv_syntax; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 codec = strtoul(cp, &cp, 0); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 if (*cp && !isspace(*cp)) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 goto inv_syntax; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 if (codec > 14) { |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 fprintf(stderr, "error: Codec_Type argument out of range\n"); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 return; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 } |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 while (isspace(*cp)) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 cp++; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 if (*cp) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 goto inv_syntax; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 send_tfo_req(sig, codec); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 } |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 void |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 select_stdin() |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 { |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 char buf[256], *cp; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 fgets(buf, sizeof buf, stdin); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 cp = index(buf, '\n'); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 if (cp) { |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 while (cp > buf && isspace(cp[-1])) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 cp--; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 *cp = '\0'; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 } |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 for (cp = buf; isspace(*cp); cp++) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 ; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 if (!*cp) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 return; |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 if (!strcmp(cp, "b") || !strcasecmp(cp, "bye")) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 send_bye_req(); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 else if (!strcmp(cp, "c") || !strcasecmp(cp, "cancel")) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 send_cancel_req(); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 else if (!strncmp(cp, "pcm-fill", 8) && isspace(cp[8])) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 pcm_fill_cmd(cp + 9); |
13
059b79c9f0c3
sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
159 else if (!strcmp(cp, "dmw-on")) |
059b79c9f0c3
sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
160 cmd_dmw_on(); |
059b79c9f0c3
sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
161 else if (!strcmp(cp, "dmw-off")) |
059b79c9f0c3
sipout-test-voice: add DMW output mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
162 cmd_dmw_off(); |
15
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
163 else if (!strncmp(cp, "play", 4) && isspace(cp[4])) |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
164 play_cmd_plain(cp + 5); |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
165 else if (!strncmp(cp, "play-offset", 11) && isspace(cp[11])) |
71f01a834820
sipout-test-voice: implement play with offset
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
166 play_cmd_offset(cp + 12); |
14
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
167 else if (!strcmp(cp, "play-stop")) |
f96153d15889
sipout-test-voice: implement play from file
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
168 play_file_stop(); |
0
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 else if (!strncmp(cp, "tfo-req", 7) && isspace(cp[7])) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 tfo_req_cmd(cp + 8); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 else if (!strcmp(cp, "tfo-stop")) |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 stop_tfo_out(); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 else |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 fprintf(stderr, "error: non-understood stdin command\n"); |
35c0d9f03c0a
beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 } |