Beispiel #1
0
static int handle_enable(char *params)
{
    int filter_id;

    filter_id = tc_filter_find(params);
    if (!filter_id)
        return 0;
    else
        return tc_filter_enable(filter_id);
}
static void enable_levels_filter(void)
{
    int handle = 0, id = tc_filter_find("levels");
    if (id == 0) {
        tc_log_info(MOD_NAME, "input is mjpeg, reducing range from YUVJ420P to YUV420P");
        handle = tc_filter_add("levels", "output=16-240:pre=1");
        if (!handle) {
            tc_log_warn(MOD_NAME, "cannot load levels filter");
        }
    }
}
Beispiel #3
0
static int handle_parameter(char *params)
{
    int filter_id;
    const char *s;

    filter_id = tc_filter_find(params);
    if (!filter_id)
        return 0;
    s = tc_filter_get_conf(filter_id, NULL);
    if (!s)
        return 0;
    sendstr(client_sock, s);
    return 1;
}
Beispiel #4
0
static int handle_config(char *params)
{
    char *filter_name, *filter_params;
    int filter_id;

    filter_name = params;
    filter_params = filter_name + strcspn(filter_name, " \t");
    *filter_params++ = 0;
    filter_params += strspn(filter_params, " \t");
    if (!*filter_name || !*filter_params)
        return 0;

    filter_id = tc_filter_find(filter_name);
    if (!filter_id)
        return 0;
    return tc_filter_configure(filter_id, filter_params) == 0;
}
Beispiel #5
0
static int handle_preview(char *params)
{
    int filter_id, cmd, arg;
    char *cmdstr, *argstr;

    /* Check that the preview filter is loaded, and load it if not */
    filter_id = tc_filter_find("pv");
    if (!filter_id) {
        filter_id = tc_filter_add("pv", "cache=20");
        if (!filter_id)
            return 0;
    }

    /* Parse out preview command name and (optional) argument */
    cmdstr = strtok(params, " \t");
    if (cmdstr)  // there are strtok() implementations that crash without this!
        argstr = strtok(NULL, " \t");
    else
        argstr = NULL;
    if (argstr)
        arg = atoi(argstr);
    else
        arg = 0;

    if        (!strncasecmp(cmdstr, "draw",    2)) {
        cmd = TC_SOCK_PV_DRAW;
    } else if (!strncasecmp(cmdstr, "pause",  2)) {
        cmd = TC_SOCK_PV_PAUSE;
    } else if (!strncasecmp(cmdstr, "undo", 2)) {
        cmd = TC_SOCK_PV_UNDO;
    } else if (!strncasecmp(cmdstr, "fastfw", 6)) {
        cmd = TC_SOCK_PV_FAST_FW;
    } else if (!strncasecmp(cmdstr, "fastbw", 6)) {
        cmd = TC_SOCK_PV_FAST_BW;
    } else if (!strncasecmp(cmdstr, "slowfw", 6)) {
        cmd = TC_SOCK_PV_SLOW_FW;
    } else if (!strncasecmp(cmdstr, "slowbw", 6)) {
        cmd = TC_SOCK_PV_SLOW_BW;
    } else if (!strncasecmp(cmdstr, "toggle", 6)) {
        cmd = TC_SOCK_PV_TOGGLE;
    } else if (!strncasecmp(cmdstr, "slower", 6)) {
        cmd = TC_SOCK_PV_SLOWER;
    } else if (!strncasecmp(cmdstr, "faster", 6)) {
        cmd = TC_SOCK_PV_FASTER;
    } else if (!strncasecmp(cmdstr, "rotate", 6)) {
        cmd = TC_SOCK_PV_ROTATE;
    } else if (!strncasecmp(cmdstr, "display", 6)) {
        cmd = TC_SOCK_PV_DISPLAY;
    } else if (!strncasecmp(cmdstr, "grab", 4)) {
        cmd = TC_SOCK_PV_SAVE_JPG;
    } else {
        return 0;
    }

    tc_mutex_lock(&tc_socket_msg_lock);
    sock_cmd.cmd = cmd;
    sock_cmd.arg = arg;
    tc_mutex_unlock(&tc_socket_msg_lock);

    return 1;
}