37 #define COMMAND_FLAG_ENTER 1
38 #define COMMAND_FLAG_LEAVE 2
42 const char *flag_strings[] = {
"enter",
"leave" };
82 #define OFFSET(x) offsetof(SendCmdContext, x)
83 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_VIDEO_PARAM
92 #define SPACES " \f\t\n\r"
98 *buf += strspn(*buf,
SPACES);
105 *buf += strcspn(*buf,
"\n");
111 #define COMMAND_DELIMS " \f\t\n\r,;"
114 const char **
buf,
void *log_ctx)
118 memset(cmd, 0,
sizeof(
Command));
119 cmd->
index = cmd_count;
122 *buf += strspn(*buf,
SPACES);
129 int len = strcspn(*buf,
"|+]");
137 "Unknown flag '%s' in interval #%d, command #%d\n",
138 flag_buf, interval_count, cmd_count);
144 if (!strspn(*buf,
"+|")) {
146 "Invalid flags char '%c' in interval #%d, command #%d\n",
147 **buf, interval_count, cmd_count);
156 "Missing flag terminator or extraneous data found at the end of flags "
157 "in interval #%d, command #%d\n", interval_count, cmd_count);
165 *buf += strspn(*buf,
SPACES);
169 "No target specified in interval #%d, command #%d\n",
170 interval_count, cmd_count);
175 *buf += strspn(*buf,
SPACES);
179 "No command specified in interval #%d, command #%d\n",
180 interval_count, cmd_count);
185 *buf += strspn(*buf,
SPACES);
198 const char **
buf,
void *log_ctx)
210 if ((ret =
parse_command(&cmd, cmd_count, interval_count, buf, log_ctx)) < 0)
220 "Could not (re)allocate command array\n");
225 (*cmds)[(*nb_cmds)++] = cmd;
227 *buf += strspn(*buf,
SPACES);
228 if (**buf && **buf !=
';' && **buf !=
',') {
230 "Missing separator or extraneous data found at the end of "
231 "interval #%d, in command #%d\n",
232 interval_count, cmd_count);
234 "Command was parsed as: flags:[%s] target:%s command:%s arg:%s\n",
247 #define DELIMS " \f\t\n\r,;"
250 const char **
buf,
void *log_ctx)
255 *buf += strspn(*buf,
SPACES);
260 memset(interval, 0,
sizeof(
Interval));
261 interval->
index = interval_count;
267 if (intervalstr && intervalstr[0]) {
270 start =
av_strtok(intervalstr,
"-", &end);
273 "Invalid start time specification '%s' in interval #%d\n",
274 start, interval_count);
281 "Invalid end time specification '%s' in interval #%d\n",
282 end, interval_count);
286 interval->
end_ts = INT64_MAX;
290 "Invalid end time '%s' in interval #%d: "
291 "cannot be lesser than start time '%s'\n",
292 end, interval_count, start);
298 "No interval specified for interval #%d\n", interval_count);
305 interval_count, buf, log_ctx);
313 const char *
buf,
void *log_ctx)
315 int interval_count = 0;
328 if ((ret =
parse_interval(&interval, interval_count, &buf, log_ctx)) < 0)
331 buf += strspn(buf,
SPACES);
335 "Missing terminator or extraneous data found at the end of interval #%d\n",
344 if (*nb_intervals == n) {
349 "Could not (re)allocate intervals array\n");
354 (*intervals)[(*nb_intervals)++] = interval;
367 ret = ts_diff > 0 ? 1 : ts_diff < 0 ? -1 : 0;
378 "Only one of the filename or commands options must be specified\n");
386 &file_buf, &file_bufsize, 0, ctx);
396 memcpy(buf, file_buf, file_bufsize);
397 buf[file_bufsize] = 0;
417 " [%s] target:%s command:%s arg:%s index:%d\n",
455 #define WITHIN_INTERVAL(ts, start_ts, end_ts) ((ts) >= (start_ts) && (ts) < (end_ts))
473 "[%s] interval #%d start_ts:%f end_ts:%f ts:%f\n",
475 (
double)interval->
start_ts/1000000, (
double)interval->
end_ts/1000000,
478 for (j = 0; flags && j < interval->
nb_commands; j++) {
482 if (cmd->
flags & flags) {
484 "Processing command #%d target:%s command:%s arg:%s\n",
491 "Command reply for command #%d: ret:%s res:%s\n",
499 switch (inlink->
type) {
508 #if CONFIG_SENDCMD_FILTER
510 #define sendcmd_options options
539 .priv_class = &sendcmd_class,
544 #if CONFIG_ASENDCMD_FILTER
546 #define asendcmd_options options
573 .
inputs = asendcmd_inputs,
575 .priv_class = &asendcmd_class,