FreeCalypso > hg > sipout-test-utils
comparison test-voice/user_cmd.c @ 15:71f01a834820
sipout-test-voice: implement play with offset
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sat, 11 May 2024 22:27:07 -0800 |
| parents | f96153d15889 |
| children |
comparison
equal
deleted
inserted
replaced
| 14:f96153d15889 | 15:71f01a834820 |
|---|---|
| 32 } | 32 } |
| 33 set_pcm_fill_octet(octet); | 33 set_pcm_fill_octet(octet); |
| 34 } | 34 } |
| 35 | 35 |
| 36 static void | 36 static void |
| 37 play_file_cmd(args) | 37 play_cmd_plain(args) |
| 38 char *args; | 38 char *args; |
| 39 { | 39 { |
| 40 char *cp, *filename; | 40 char *cp, *filename; |
| 41 int loop; | 41 int loop; |
| 42 | 42 |
| 43 for (cp = args; isspace(*cp); cp++) | 43 for (cp = args; isspace(*cp); cp++) |
| 44 ; | 44 ; |
| 45 if (!*cp) { | 45 if (!*cp) { |
| 46 inv_syntax: fprintf(stderr, "error: play-file command invalid syntax\n"); | 46 inv_syntax: fprintf(stderr, "error: play command invalid syntax\n"); |
| 47 return; | 47 return; |
| 48 } | 48 } |
| 49 for (filename = cp; *cp && !isspace(*cp); cp++) | 49 for (filename = cp; *cp && !isspace(*cp); cp++) |
| 50 ; | 50 ; |
| 51 if (*cp) { | 51 if (*cp) { |
| 56 goto inv_syntax; | 56 goto inv_syntax; |
| 57 loop = 1; | 57 loop = 1; |
| 58 } else | 58 } else |
| 59 loop = 0; | 59 loop = 0; |
| 60 play_file_cmdop(filename, loop); | 60 play_file_cmdop(filename, loop); |
| 61 } | |
| 62 | |
| 63 static void | |
| 64 play_cmd_offset(args) | |
| 65 char *args; | |
| 66 { | |
| 67 char *cp, *filename; | |
| 68 unsigned offset; | |
| 69 | |
| 70 for (cp = args; isspace(*cp); cp++) | |
| 71 ; | |
| 72 if (!*cp) { | |
| 73 inv_syntax: fprintf(stderr, "error: play-offset command invalid syntax\n"); | |
| 74 return; | |
| 75 } | |
| 76 for (filename = cp; *cp && !isspace(*cp); cp++) | |
| 77 ; | |
| 78 if (!*cp) | |
| 79 goto inv_syntax; | |
| 80 *cp++ = '\0'; | |
| 81 while (isspace(*cp)) | |
| 82 cp++; | |
| 83 if (!isdigit(*cp)) | |
| 84 goto inv_syntax; | |
| 85 offset = strtoul(cp, &cp, 0); | |
| 86 if (*cp && !isspace(*cp)) | |
| 87 goto inv_syntax; | |
| 88 if (offset < 1 || offset > 159) { | |
| 89 fprintf(stderr, "error: offset argument out of range\n"); | |
| 90 return; | |
| 91 } | |
| 92 while (isspace(*cp)) | |
| 93 cp++; | |
| 94 if (*cp) | |
| 95 goto inv_syntax; | |
| 96 play_file_offset(filename, offset); | |
| 61 } | 97 } |
| 62 | 98 |
| 63 static void | 99 static void |
| 64 tfo_req_cmd(args) | 100 tfo_req_cmd(args) |
| 65 char *args; | 101 char *args; |
| 122 pcm_fill_cmd(cp + 9); | 158 pcm_fill_cmd(cp + 9); |
| 123 else if (!strcmp(cp, "dmw-on")) | 159 else if (!strcmp(cp, "dmw-on")) |
| 124 cmd_dmw_on(); | 160 cmd_dmw_on(); |
| 125 else if (!strcmp(cp, "dmw-off")) | 161 else if (!strcmp(cp, "dmw-off")) |
| 126 cmd_dmw_off(); | 162 cmd_dmw_off(); |
| 127 else if (!strncmp(cp, "play-file", 9) && isspace(cp[9])) | 163 else if (!strncmp(cp, "play", 4) && isspace(cp[4])) |
| 128 play_file_cmd(cp + 10); | 164 play_cmd_plain(cp + 5); |
| 165 else if (!strncmp(cp, "play-offset", 11) && isspace(cp[11])) | |
| 166 play_cmd_offset(cp + 12); | |
| 129 else if (!strcmp(cp, "play-stop")) | 167 else if (!strcmp(cp, "play-stop")) |
| 130 play_file_stop(); | 168 play_file_stop(); |
| 131 else if (!strncmp(cp, "tfo-req", 7) && isspace(cp[7])) | 169 else if (!strncmp(cp, "tfo-req", 7) && isspace(cp[7])) |
| 132 tfo_req_cmd(cp + 8); | 170 tfo_req_cmd(cp + 8); |
| 133 else if (!strcmp(cp, "tfo-stop")) | 171 else if (!strcmp(cp, "tfo-stop")) |
