summaryrefslogtreecommitdiff
path: root/src/pjctl.c
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2013-08-21 22:53:00 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2014-01-04 15:42:03 +0100
commit95f3a2e520736cd6c285e3c20db92074b075ab77 (patch)
tree86e1ef7e61224e0e88628a559ab6c428f370a6e7 /src/pjctl.c
parent52243841a73a34990859b3c01161b78b9419041d (diff)
downloadpjctl-95f3a2e520736cd6c285e3c20db92074b075ab77.tar.gz
pjctl-95f3a2e520736cd6c285e3c20db92074b075ab77.tar.bz2
pjctl-95f3a2e520736cd6c285e3c20db92074b075ab77.zip
Support toggle in avmute command
Diffstat (limited to 'src/pjctl.c')
-rw-r--r--src/pjctl.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/pjctl.c b/src/pjctl.c
index 0c5c7b1..3efe693 100644
--- a/src/pjctl.c
+++ b/src/pjctl.c
@@ -441,11 +441,15 @@ source(struct pjctl *pjctl, char **argv, int argc)
return 0;
}
+static int
+avmute(struct pjctl *pjctl, char **argv, int argc);
+
static void
avmute_response(struct pjctl *pjctl, struct queue_command *cmd,
char *op, char *param)
{
int ret;
+ char *params[3] = { "mute", NULL, NULL };
fputs(cmd->prefix, stdout);
free(cmd->prefix);
@@ -459,18 +463,28 @@ avmute_response(struct pjctl *pjctl, struct queue_command *cmd,
return;
switch (param[0]) {
case '1':
+ params[1] = "video";
printf("video");
break;
case '2':
+ params[1] = "audio";
printf("audio");
break;
case '3':
+ params[1] = "av";
printf("video & audio");
break;
+ default:
+ // error?
+ break;
}
printf(" mute ");
- printf("%s\n", param[1] == '1' ? "on" : "off");
+ params[2] = param[1] == '1' ? "on" : "off";
+ printf("%s\n", params[2]);
+
+ if (cmd->toggle)
+ avmute(pjctl, params, 3);
}
}
@@ -480,7 +494,7 @@ avmute(struct pjctl *pjctl, char **argv, int argc)
struct queue_command *cmd;
int type = -1;
int i;
- int on;
+ char code;
const char *targets[] = { "video", "audio", "av" };
cmd = calloc(1, sizeof *cmd);
@@ -506,19 +520,22 @@ avmute(struct pjctl *pjctl, char **argv, int argc)
}
if (strcmp(argv[2], "on") == 0)
- on = 1;
+ code = '1';
else if (strcmp(argv[2], "off") == 0)
- on = 0;
- else {
+ code = '0';
+ else if (strcmp(argv[2], "toggle") == 0) {
+ code = '?';
+ cmd->toggle = 1;
+ } else {
fprintf(stderr, "invalid mute parameter\n");
return -1;
}
- if (asprintf(&cmd->command, "%%1AVMT %d%d\r", type, on) < 0)
+ if (asprintf(&cmd->command, "%%1AVMT %d%c\r", type, code) < 0)
return -1;
cmd->response_func = avmute_response;
if (asprintf(&cmd->prefix, "%s mute %s: ",
- targets[type-1], argv[2]) < 0)
+ targets[type-1], cmd->toggle ? "status" : argv[2]) < 0)
return -1;
insert_at_head(&pjctl->queue, cmd);