# HG changeset patch # User Mychaela Falconia # Date 1717907577 0 # Node ID aa2ba9b432af2e047b79067d04ad0d429a3b4fe3 # Parent 395c56969bc409dd2642c31dbe00173b2debcfc7 mtctest: implement play and play-stop commands diff -r 395c56969bc4 -r aa2ba9b432af mtctest/rtp_play.c --- a/mtctest/rtp_play.c Sun Jun 09 04:24:53 2024 +0000 +++ b/mtctest/rtp_play.c Sun Jun 09 04:32:57 2024 +0000 @@ -77,8 +77,8 @@ void play_file_cmdop(filename, frame_len, loop) + char *filename; unsigned frame_len; - char *filename; { int fd; struct stat st; diff -r 395c56969bc4 -r aa2ba9b432af mtctest/user_cmd.c --- a/mtctest/user_cmd.c Sun Jun 09 04:24:53 2024 +0000 +++ b/mtctest/user_cmd.c Sun Jun 09 04:32:57 2024 +0000 @@ -1,7 +1,7 @@ /* - * In this module we implement stdin command handling: we start with - * 'disc' command for caller-initiated disconnect, and then we'll add - * play commands for RTP output. + * In this module we implement stdin command handling: 'disc' command + * for caller-initiated disconnect; 'play' and 'play-stop' commands + * for RTP output. */ #include @@ -10,6 +10,47 @@ #include #include +static void +play_cmd(args) + char *args; +{ + char *cp, *filename; + unsigned frame_len; + int loop; + + for (cp = args; isspace(*cp); cp++) + ; + if (!*cp) { +inv_syntax: fprintf(stderr, "error: play command invalid syntax\n"); + return; + } + for (filename = cp; *cp && !isspace(*cp); cp++) + ; + if (!*cp) + goto inv_syntax; + *cp++ = '\0'; + while (isspace(*cp)) + cp++; + if (!isdigit(*cp)) + goto inv_syntax; + frame_len = strtoul(cp, &cp, 0); + if (*cp && !isspace(*cp)) + goto inv_syntax; + if (frame_len < 1 || frame_len > 160) { + fprintf(stderr, "error: frame length argument out of range\n"); + return; + } + while (isspace(*cp)) + cp++; + if (*cp) { + if (strcmp(cp, "loop")) + goto inv_syntax; + loop = 1; + } else + loop = 0; + play_file_cmdop(filename, frame_len, loop); +} + void select_stdin() { @@ -28,6 +69,10 @@ return; if (!strcmp(cp, "disc")) disconnect_command(); + else if (!strncmp(cp, "play", 4) && isspace(cp[4])) + play_cmd(cp + 5); + else if (!strcmp(cp, "play-stop")) + play_file_stop(); else fprintf(stderr, "error: non-understood stdin command\n"); }