diff test-voice/user_cmd.c @ 14:f96153d15889

sipout-test-voice: implement play from file
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 11 May 2024 22:10:38 -0800
parents 059b79c9f0c3
children 71f01a834820
line wrap: on
line diff
--- a/test-voice/user_cmd.c	Sun Apr 07 17:09:32 2024 -0800
+++ b/test-voice/user_cmd.c	Sat May 11 22:10:38 2024 -0800
@@ -34,6 +34,33 @@
 }
 
 static void
+play_file_cmd(args)
+	char *args;
+{
+	char *cp, *filename;
+	int loop;
+
+	for (cp = args; isspace(*cp); cp++)
+		;
+	if (!*cp) {
+inv_syntax:	fprintf(stderr, "error: play-file command invalid syntax\n");
+		return;
+	}
+	for (filename = cp; *cp && !isspace(*cp); cp++)
+		;
+	if (*cp) {
+		*cp++ = '\0';
+		while (isspace(*cp))
+			cp++;
+		if (strcmp(cp, "loop"))
+			goto inv_syntax;
+		loop = 1;
+	} else
+		loop = 0;
+	play_file_cmdop(filename, loop);
+}
+
+static void
 tfo_req_cmd(args)
 	char *args;
 {
@@ -97,6 +124,10 @@
 		cmd_dmw_on();
 	else if (!strcmp(cp, "dmw-off"))
 		cmd_dmw_off();
+	else if (!strncmp(cp, "play-file", 9) && isspace(cp[9]))
+		play_file_cmd(cp + 10);
+	else if (!strcmp(cp, "play-stop"))
+		play_file_stop();
 	else if (!strncmp(cp, "tfo-req", 7) && isspace(cp[7]))
 		tfo_req_cmd(cp + 8);
 	else if (!strcmp(cp, "tfo-stop"))