コード例 #1
0
ファイル: conf.c プロジェクト: rvs/libtc
extern int
tcconf_clearvalue(tcconf_section_t *ts, char *name)
{
    conf_section *sec = NULL;
    char *n = strdup(name);
    char *p = strrchr(n, '/');
    tcconf_section_t *s = NULL;
    int c = 0;

    if(p){
	*p++ = 0;
	if((s = tcconf_getsection(ts, n)))
	sec = s->sec;
    } else {
	p = n;
	sec = ts->sec;
    }

    if(sec)
	c = tclist_delete_matched(sec->entries, p, cmp_str_sec, tcfree);
    if(s)
	tcfree(s);

    free(n);
    return c;
}
コード例 #2
0
ファイル: conf.c プロジェクト: rvs/libtc
static v_state *
vstate(tcconf_section_t *sec, char *name, void **state)
{
    v_state *vs = *state;

    if(!vs){
	char *tmp = strdup(name);
	char *v = strrchr(tmp, '/');
	tcconf_section_t *ms;

	if(v){
	    *v++ = 0;
	    if(!(sec = tcconf_getsection(sec, tmp))){
		free(tmp);
		return NULL;
	    }
	} else {
	    v = tmp;
	    tcref(sec);
	}

	vs = *state = calloc(1, sizeof(v_state));
	vs->n = strdup(v);
	vs->ts = sec;
	ms = next_merge(sec, vs);
	if(ms)
	    sec = ms;
	vs->sec = sec;
	free(tmp);
    }

    return vs;
}
コード例 #3
0
ファイル: conf.c プロジェクト: rvs/libtc
static tcconf_section_t *
next_merge(tcconf_section_t *sec, v_state *vs)
{
    tcconf_section_t *s = NULL;
    char *m;

    while((m = tclist_next(sec->sec->merge, &vs->ml))){
	tcconf_section_t *ms = tcconf_getsection(sec->parent, m);
	if(ms){
	    s = ms;
	    break;
	}
    }

    return s;
}
コード例 #4
0
ファイル: skin.c プロジェクト: xaradevil/tcvp
static xtk_widget_t*
create_skinned_list(xtk_widget_t *win, skin_t *skin, tcconf_section_t *sec,
                    tchash_table_t *parameters)
{
    int x, y;
    int width, height;
    int i=0;
    char *action = NULL;
    widget_data_t *wd = tcallocdz(sizeof(*wd), NULL, widgetdata_free);
    xtk_widget_t *l;
    int disable = 0;
    int alpha = 0xff, calpha = 0xff;
    char *font, *color, *ccolor = NULL;
    tcconf_section_t *bfnt = NULL;
    tcconf_section_t *fig = NULL;
    int rows, spacing;
    int xs, ys;

    i += tcconf_getvalue(sec, "position", "%d %d", &x, &y);
    i += tcconf_getvalue(sec, "size", "%d %d", &width, &height);

    if((bfnt = tcconf_getsection(sec, "bitmap"))){
        tcconf_setvalue(bfnt, "path", "%s", skin->path);
        i++;
    } else if(tcconf_getvalue(sec, "font", "%s", &font) == 1){
        i++;
    }

    i += tcconf_getvalue(sec, "color", "%s %d", &color, &alpha) > 0;
    i += tcconf_getvalue(sec, "spacing", "%d", &spacing);
    i += tcconf_getvalue(sec, "rows", "%d", &rows);

    if(i != 8){
        return NULL;
    }

    tcconf_getvalue(sec, "current-color", "%s %d", &ccolor, &calpha);

    fig = tcconf_getsection(sec, "background_figure");

    tcconf_getvalue(sec, "action", "%s", &action);

    wd->action = action;
    wd->skin = tcref(skin);
    wd->values = calloc(1, sizeof(char *));

    l = xtk_widget_list_create(win, x, y, width, height);

    if(tcconf_getvalue(sec, "scroll", "%d %d", &xs, &ys) == 2) {
        xtk_widget_list_set_scroll(l, xs, ys);
    }

    if(fig != NULL) {
        tcconf_setvalue(fig, "position", "%d %d", 0, 0);
        tcconf_setvalue(fig, "size", "%d %d", width, height);

        image_t *img = draw_figure(fig);

        xtk_widget_list_set_image(l, img);

        tcfree(img);

        tcfree(fig);
    }

    xtk_widget_list_set_data(l, wd);
    xtk_widget_list_set_action(l, lookup_action);

    if(l) {
        void *c = NULL;
        char *value, *variable;

        if(bfnt){
            xtk_widget_list_set_bitmapfont(l, bfnt);
            tcfree(bfnt);
        } else {
            xtk_widget_list_set_font(l, font);
            free(font);
        }

        xtk_widget_list_set_color(l, color, alpha);
        free(color);

        if(ccolor) {
            xtk_widget_list_set_current_color(l, ccolor, calpha);
            free(ccolor);
        }

        xtk_widget_list_set_spacing(l, spacing);

        xtk_widget_list_set_rows(l, rows);

        while(i = tcconf_nextvalue(sec, "value", &c, "%s %s",
                                   &variable, &value), c) {
            if(i == 2) {
                if(strcmp(variable, "current_position") == 0) {
                    int *val = NULL, *def = NULL;
                    int p;

                    save_varcb(l, list_set_current, "integer", value);
                    register_varwidget(l, list_set_current, "integer",
                                       value);

                    parse_variable("integer", value, (void *)&val,
                                   (void *)&def);
                    if(!val) {
                        if(def) {
                            p = *def;
                            tcfree(def);
                        }
                        val = &p;
                    }

                    list_set_current(l, val);
                } else if(strcmp(variable, "number_of_entries") == 0) {
                    int *val = NULL, *def = NULL;
                    int p;

                    save_varcb(l, list_set_number_of_entries, "integer",
                               value);
                    register_varwidget(l, list_set_number_of_entries,
                                       "integer", value);

                    parse_variable("integer", value, (void *)&val,
                                   (void *)&def);
                    if(!val) {
                        if(def) {
                            p = *def;
                            tcfree(def);
                        }
                        val = &p;
                    }

                    list_set_number_of_entries(l, val);
                } else if(strcmp(variable, "entries") == 0) {
                    void *val = NULL;

                    save_varcb(l, list_set_entries, "string_array",
                               value);
                    register_varwidget(l, list_set_entries,
                                       "string_array", value);

                    parse_variable("string_array", value, &val, NULL);
                    if(val) {
                        list_set_entries(l, val);
                        tcfree(val);
                    }
                }
                free(value);
                free(variable);
            }
        }

        l->on_destroy = destroy_skinned_list;
        if(disable) xtk_widget_disable(l);
    }

    return l;
}
コード例 #5
0
ファイル: skin.c プロジェクト: xaradevil/tcvp
static xtk_widget_t*
create_skinned_label(xtk_widget_t *win, skin_t *skin, tcconf_section_t *sec,
                     tchash_table_t *parameters)
{
    int x, y;
    int width, height;
    int xoff = 0, yoff = 0;
    char *font;
    char *color, *align_s, *stype_s;
    int alpha = 0xff;
    int stype, align;
    int i = 0;
    char *action = NULL, *bg = NULL, *text, *default_text;
    widget_data_t *wd = tcallocdz(sizeof(*wd), NULL, widgetdata_free);
    xtk_widget_t *l, *w;
    tcconf_section_t *bfnt = NULL;
    image_t *bg_img;

    i += tcconf_getvalue(sec, "position", "%d %d", &x, &y);
    i += tcconf_getvalue(sec, "size", "%d %d", &width, &height);
    i += tcconf_getvalue(sec, "text", "%s", &text);

    if((bfnt = tcconf_getsection(sec, "bitmap"))){
        tcconf_setvalue(bfnt, "path", "%s", skin->path);
        i++;
    } else if(tcconf_getvalue(sec, "font", "%s", &font) == 1){
        i++;
    }

    i += tcconf_getvalue(sec, "color", "%s %d", &color, &alpha) > 0;

    if(tcconf_getvalue(sec, "scroll_style", "%s", &stype_s) < 1)
        stype_s = strdup("none");

    if(tcconf_getvalue(sec, "align", "%s", &align_s) < 1)
        align_s = strdup("left");


    if(strcasecmp(align_s, "left") == 0) {
        align = XTKLABELLEFT;
    } else if(strcasecmp(align_s, "right") == 0) {
        align = XTKLABELRIGHT;
    } else {
        align = XTKLABELCENTER;
    }
    free(align_s);

    if(strcasecmp(stype_s, "scroll") == 0) {
        stype = XTKLABELSCROLL;
    } else if(strcasecmp(stype_s, "pingpong") == 0) {
        stype = XTKLABELPINGPONG;
    } else {
        stype = 0;
    }
    free(stype_s);

    if(i != 7)
        return NULL;

    tcconf_getvalue(sec, "text_offset", "%d %d", &xoff, &yoff);
    tcconf_getvalue(sec, "action", "%s", &action);
    tcconf_getvalue(sec, "background", "%s", &bg);

    default_text = malloc(1024);
    parse_text(text, default_text, 1024);

    wd->action = action;
    wd->value = text;
    wd->skin = tcref(skin);
    l = xtk_widget_label_create(win, x, y, width, height);
    if(bfnt){
        xtk_widget_label_set_bitmapfont(l, bfnt);
        tcfree(bfnt);
    } else {
        xtk_widget_label_set_font(l, font);
        free(font);
    }
    xtk_widget_label_set_offset(l, xoff, yoff);
    xtk_widget_label_set_color(l, color, alpha);
    xtk_widget_label_set_text(l, default_text);
    xtk_widget_label_set_data(l, wd);
    xtk_widget_label_set_action(l, lookup_action);
    xtk_widget_label_set_align(l, align);
    xtk_widget_label_set_scroll(l, stype);

    bg_img = load_image(skin->path, bg);
    w = xtk_widget_image_create(win, x, y, width, height);
    xtk_widget_image_set_image(w, bg_img);
    tcfree(bg_img);

    xtk_widget_show(w);

    register_textwidget(l, text);
    l->on_destroy = destroy_skinned_label;
    free(default_text);
    if(color)
        free(color);
    free(bg);

    return l;
}
コード例 #6
0
ファイル: play.c プロジェクト: xaradevil/tcvp
extern tcvp_pipe_t *
new_pipe(tcvp_player_t *sh, muxed_stream_t *ms, stream_t *s)
{
    tcvp_pipe_t *pipe = NULL, *pp = NULL, *pn = NULL;
    tcconf_section_t *f, *mcf;
    tcconf_section_t *pr = NULL;
    void *cs = NULL;
    int skip = 0;

    switch(s->stream_type){
    case STREAM_TYPE_VIDEO:
        pr = tcconf_getsection(sh->profile, "video");
        break;
    case STREAM_TYPE_AUDIO:
        pr = tcconf_getsection(sh->profile, "audio");
        break;
    case STREAM_TYPE_SUBTITLE:
        pr = tcconf_getsection(sh->profile, "subtitle");
        break;
    }

    if(!pr)
        return NULL;

    while((f = tcconf_nextsection(pr, "filter", &cs))){
        char *type, *id = NULL;
        filter_new_t fn;

        if(skip){
            tcfree(f);
            continue;
        }

        pn = NULL;

        if(tcconf_getvalue(f, "type", "%s", &type) < 1){
            tc2_print("STREAM", TC2_PRINT_WARNING,
                      "bad filter specification\n");
            continue;
        }

        if(tcconf_getvalue(f, "id", "%s", &id) > 0)
            tchash_find(sh->filters, id, -1, &pn);

        if(!pn){
            tc2_print("STREAM", TC2_PRINT_DEBUG,
                      "opening new filter: %s\n", type);
            if(!(fn = tc2_get_symbol(type, "new")))
                break;

            mcf = tcconf_merge(NULL, f);
            tcconf_merge(mcf, sh->conf);
            if(sh->outfile)
                tcconf_setvalue(mcf, "mux/url", "%s", sh->outfile);

            if(!(pn = fn(pp? &pp->format: s, mcf, sh->timer, ms))){
                tc2_print("STREAM", TC2_PRINT_WARNING,
                          "error opening filter '%s'\n", type);
                break;
            }

            if(id){
                char *cid = tcalloc(strlen(id) + 1);
                strcpy(cid, id);
                tcattr_set(cid, "stream-shared", sh, NULL, NULL);
                tcattr_set(pn, "id", cid, NULL, pid_free);
                tchash_replace(sh->filters, id, -1, pn, NULL);
            }
            tcfree(mcf);
        } else {
            tcref(pn);
        }

        if(id)
            free(id);

        if(!pipe)
            pipe = pn;

        if(pp)
            pp->next = pn;
        pp = pn;
        free(type);
        tcfree(f);

        if(pp->next){
            while((pp = pp->next))
                tcref(pp);
            skip = 1;
        }
    }

    if(!pn){
        close_pipe(pipe);
        pipe = NULL;
    }

    tcfree(pr);
    return pipe;
}