annotate mtctest/user_cmd.c @ 9:0ec938ed530b

mtctest: capture MSC RTP info for play command
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 09 Jun 2024 03:37:44 +0000
parents a902ccbf6bbc
children aa2ba9b432af
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement stdin command handling: we start with
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * 'disc' command for caller-initiated disconnect, and then we'll add
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * play commands for RTP output.
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <ctype.h>
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <string.h>
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <strings.h>
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 void
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 select_stdin()
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 {
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 char buf[256], *cp;
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 fgets(buf, sizeof buf, stdin);
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 cp = index(buf, '\n');
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 if (cp) {
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 while (cp > buf && isspace(cp[-1]))
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 cp--;
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 *cp = '\0';
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 for (cp = buf; isspace(*cp); cp++)
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 ;
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 if (!*cp)
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 return;
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 if (!strcmp(cp, "disc"))
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 disconnect_command();
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 else
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 fprintf(stderr, "error: non-understood stdin command\n");
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }