char *avs_serialize_retrieve_string_from_preset_section (char *section, VisParamEntry *param)
{
	char *string;
	int len;
    int i;

	/* FIXME should just get an int ? */
	len = AVS_SERIALIZE_GET_INT (section);
	AVS_SERIALIZE_SKIP_INT (section);

	if (len > 0) {
		string = visual_mem_malloc0 (len);

		strncpy (string, section, len);

		visual_param_entry_set_string (param, string);

		visual_mem_free (string);
	}

	AVS_SERIALIZE_SKIP_LENGTH (section, len);

    printf("after length skip :%s\n", section);
	return section;
}
Example #2
0
/* cur->name should be the element name */
static int parse_element (xmlNodePtr cur, LVAVSPresetElement *element)
{
  char *content;
  LVAVSPresetElement *child;
  VisParamEntry *param;

  for (cur = cur->xmlChildrenNode; cur; cur = cur->next)
  {
      if (xmlIsBlankNode (cur) || cur->type != XML_ELEMENT_NODE)
	continue;

	LVAVSPresetElementType type;
	xmlChar *prop = xmlGetProp(cur, (xmlChar *)"type");
	content = (char*)xmlNodeGetContent (cur);

	param = visual_param_entry_new((char *)cur->name);

	if(strcmp((char *)prop, "string") == 0) {
		visual_param_entry_set_string(param, content);
	} else if( strcmp((char *)prop, "float") == 0) {
		visual_param_entry_set_double(param, strtod(content, NULL));
	} else if( strcmp((char *)prop, "integer") == 0) {
		visual_param_entry_set_integer(param, (int)strtol(content, NULL, 0));
	} else if( strcmp((char *)prop, "color") == 0) {
		int r,g,b;
		char *s = content+1;
		r = strtoul (s, &s, 0);
		if (r > 255 || ! (s = strchr (s, ',')))
		  continue;
		g = strtoul (s+1, &s, 0);
		if (g > 255 || ! (s = strchr (s, ',')))
		  continue;
		b = strtoul (s+1, NULL, 0);
		if (b > 255)
		  continue;
		visual_param_entry_set_color(param, r, g, b);
	} else if( strcmp((char *)prop, "bool") == 0) {
		char *c, *d;
		int val;

#define isspace(c) (c == ' ' || c == '\t' || c == '\n')

		for (c=content; isspace (*c); c++);
		for (d=c; !isspace(*d); d++);
		*d = '\0';
		if (g_strcasecmp (c, "true") == 0)
		  val = TRUE;
		else if (g_strcasecmp (c, "false") == 0)
		  val = FALSE;
		else
			continue;
		visual_param_entry_set_integer(param, val);
	}

	visual_param_container_add(element->pcont, param);	

	xmlFree ((xmlChar*)content);
    }
    return TRUE;
}
Example #3
0
/**
 * Copies the value of the src param into the param. Also sets the param to the type of which the
 * source param is.
 *
 * @param param Pointer to the VisParamEntry to which a parameter is set.
 * @param src Pointer to the VisParamEntry from which the value is retrieved.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_PARAM_NULL, -VISUAL_ERROR_PARAM_INVALID_TYPE on failure.
 */
int visual_param_entry_set_from_param (VisParamEntry *param, VisParamEntry *src)
{
	visual_log_return_val_if_fail (param != NULL, -VISUAL_ERROR_PARAM_NULL);
	visual_log_return_val_if_fail (src != NULL, -VISUAL_ERROR_PARAM_NULL);

	switch (src->type) {
		case VISUAL_PARAM_ENTRY_TYPE_NULL:

			break;

		case VISUAL_PARAM_ENTRY_TYPE_STRING:
			visual_param_entry_set_string (param, visual_param_entry_get_string (src));
			break;

		case VISUAL_PARAM_ENTRY_TYPE_INTEGER:
			visual_param_entry_set_integer (param, visual_param_entry_get_integer (src));
			
			break;

		case VISUAL_PARAM_ENTRY_TYPE_FLOAT:
			visual_param_entry_set_float (param, visual_param_entry_get_float (src));

			break;

		case VISUAL_PARAM_ENTRY_TYPE_DOUBLE:
			visual_param_entry_set_double (param, visual_param_entry_get_double (src));

			break;

		case VISUAL_PARAM_ENTRY_TYPE_COLOR:
			visual_param_entry_set_color_by_color (param, visual_param_entry_get_color (src));

			break;

		case VISUAL_PARAM_ENTRY_TYPE_PALETTE:
			visual_param_entry_set_palette (param, visual_param_entry_get_palette (src));

			break;

		case VISUAL_PARAM_ENTRY_TYPE_OBJECT:
			visual_param_entry_set_object (param, visual_param_entry_get_object (src));

			break;
		
		default:
			visual_log (VISUAL_LOG_CRITICAL, _("param type is not valid"));

			return -VISUAL_ERROR_PARAM_INVALID_TYPE;

			break;
	}
	
	return VISUAL_OK;
}
Example #4
0
/**
 * generate a new config-string from current config
 */
void config_string_genstring(BlurskPrivate *priv) 
{
    char *string = paste_genstring();

    VisParamContainer *paramcontainer = visual_plugin_get_params(priv->plugin);
    
    VisParamEntry *param = visual_param_container_get(paramcontainer, "config_string");

    /* don't set if it has already been set */
    if(strcmp(string, visual_param_entry_get_string(param)) != 0)
        visual_param_entry_set_string(param, string);
    
    priv->update_config_string = 0;
}
AVSElement *avs_parse_trans_movement (AVSTree *avstree)
{
        AVSElement *movement;
        int len = avstree->cur_section_length;
        int pos=0;

        int effect;
        int rectangular;
        int blend;
        int sourcemapped;
        int subpixel;
        int wrap;
        int REFFECT_MAX = 23;
        int effect_exp_ch;

        char buf[257];

        VisParamContainer *pcont;

        static VisParamEntry params[] = {
                VISUAL_PARAM_LIST_ENTRY_INTEGER ("effect", 0),
                VISUAL_PARAM_LIST_ENTRY_INTEGER ("rectangular", 0),
                VISUAL_PARAM_LIST_ENTRY_INTEGER ("blend", 0),
                VISUAL_PARAM_LIST_ENTRY_INTEGER ("sourcemapped", 0),
                VISUAL_PARAM_LIST_ENTRY_INTEGER ("subpixel", 0),
                VISUAL_PARAM_LIST_ENTRY_INTEGER ("wrap", 0),
                VISUAL_PARAM_LIST_ENTRY_STRING ("code", ""),
                VISUAL_PARAM_LIST_END
        };

        visual_mem_set (buf, 0, sizeof (buf));

        pcont = visual_param_container_new ();

        visual_param_container_add_many(pcont, params);

        movement = visual_mem_new0 (AVSElement, 1);

        /* Do the VisObject initialization */
        visual_object_initialize (VISUAL_OBJECT (movement), TRUE, avs_element_dtor);

        AVS_ELEMENT (movement)->pcont = pcont;
        AVS_ELEMENT (movement)->type = AVS_ELEMENT_TYPE_TRANS_MOVEMENT;

        /* Deserialize without using the container, too complex (borked) serialization */
        if (len - pos >= 4) {
                effect=AVS_SERIALIZE_GET_INT (avstree->cur);
                AVS_SERIALIZE_SKIP_INT (avstree->cur);
                pos += 4;
        }
        if (effect == 32767)
        {
                if (!memcmp(avstree->cur,"!rect ",6))
                {
                        AVS_SERIALIZE_SKIP_LENGTH (avstree->cur, 6);
                        rectangular=1;
                }
                if (AVS_SERIALIZE_GET_BYTE (avstree->cur) == 1)
                {
                        AVS_SERIALIZE_SKIP_BYTE (avstree->cur);
                        pos++;

                        int l=AVS_SERIALIZE_GET_INT(avstree->cur); AVS_SERIALIZE_SKIP_INT (avstree->cur); pos += 4;
                        if (l > 0 && len-pos >= l)
                        {
//                              effect_exp.resize(l);
                                memcpy(buf, avstree->cur, l);
                                buf[l] = 0;

//                              memcpy(effect_exp.get(), data+pos, l);
                                AVS_SERIALIZE_SKIP_LENGTH (avstree->cur, l);
                                pos+=l;
                        }
                        else
                        {
//                              effect_exp.resize(1);
//                              effect_exp.get()[0]=0;
                        }
                }
                else if (len-pos >= 256)
                {
                        int l = 256 - (rectangular ? 6 : 0);
                        memcpy(buf,avstree->cur,l);
                        buf[l]=0;
//                      effect_exp.assign(buf);
                        AVS_SERIALIZE_SKIP_LENGTH (avstree->cur, l);
                        pos+=l;
                        printf ("trans_movement buf %s\n", buf);
                }
        }
        if (len-pos >= 4) { blend=AVS_SERIALIZE_GET_INT(avstree->cur); AVS_SERIALIZE_SKIP_INT (avstree->cur);pos+=4; }
        if (len-pos >= 4) { sourcemapped=AVS_SERIALIZE_GET_INT(avstree->cur); AVS_SERIALIZE_SKIP_INT (avstree->cur);pos+=4; }
        if (len-pos >= 4) { rectangular=AVS_SERIALIZE_GET_INT(avstree->cur); AVS_SERIALIZE_SKIP_INT (avstree->cur);pos+=4; }
        if (len-pos >= 4) { subpixel=AVS_SERIALIZE_GET_INT(avstree->cur); AVS_SERIALIZE_SKIP_INT (avstree->cur);pos+=4; }
        else subpixel=0;
        if (len-pos >= 4) { wrap=AVS_SERIALIZE_GET_INT(avstree->cur); AVS_SERIALIZE_SKIP_INT (avstree->cur);pos+=4; }
        else wrap=0;
        if (!effect && len-pos >= 4)
        {
                effect=AVS_SERIALIZE_GET_INT(avstree->cur); AVS_SERIALIZE_SKIP_INT (avstree->cur);pos+=4;
        }

        if (effect != 32767 && (effect > REFFECT_MAX || effect < 0))
                effect=0;
        effect_exp_ch=1;

        visual_param_entry_set_integer (visual_param_container_get (pcont, "effect"), effect);
        visual_param_entry_set_integer (visual_param_container_get (pcont, "rectangular"), rectangular);
        visual_param_entry_set_integer (visual_param_container_get (pcont, "blend"), blend);
        visual_param_entry_set_integer (visual_param_container_get (pcont, "sourcemapped"), sourcemapped);
        visual_param_entry_set_integer (visual_param_container_get (pcont, "subpixel"), subpixel);
        visual_param_entry_set_integer (visual_param_container_get (pcont, "wrap"), wrap);
        visual_param_entry_set_string (visual_param_container_get (pcont, "code"), buf);

        printf ("effect: %d, rectangular: %d, blend %d, sourcemapped %d, subpixel %d, wrap %d\n",
                        effect, rectangular, blend, sourcemapped, subpixel, wrap);

        return movement;
}
Example #6
0
/**
 * reflect the new values.
 */
static void _config_load_preset(BlurskPrivate *priv, BlurskConfig *conf)
{
    struct
    {
        char *name;
        int type;
        void *val;
    }entries[] =
    {
        {"color", VISUAL_PARAM_ENTRY_TYPE_COLOR, &conf->color},
        {"color_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->color_style},
        {"fade_speed", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->fade_speed},
        {"signal_color", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->signal_color},
        {"contour_lines", VISUAL_PARAM_ENTRY_TYPE_INTEGER, &conf->contour_lines},
        {"hue_on_beats", VISUAL_PARAM_ENTRY_TYPE_INTEGER, &conf->hue_on_beats},
        {"background", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->background},
        {"blur_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->blur_style},
        {"transition_speed", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->transition_speed},
        {"blur_when", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->blur_when},
        {"blur_stencil", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->blur_stencil},
        {"slow_motion", VISUAL_PARAM_ENTRY_TYPE_INTEGER, &conf->slow_motion},
        {"signal_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->signal_style},
        {"plot_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->plot_style},
        {"thick_on_beats", VISUAL_PARAM_ENTRY_TYPE_INTEGER, &conf->thick_on_beats},
        {"flash_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->flash_style},
        {"overall_effect", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->overall_effect},
        {"floaters", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->floaters},
    };
    
    
    
    int i;
        
    for(i = 0; i < QTY(entries); i++)
    {
        VisParamContainer *paramcontainer = visual_plugin_get_params(priv->plugin);
        VisParamEntry *ptmp = visual_param_container_get(paramcontainer, entries[i].name);
        
        switch(entries[i].type)
        {
            case VISUAL_PARAM_ENTRY_TYPE_INTEGER:
            {
                int *integer = entries[i].val;
                
                /* only update if values differ */
                if(*integer != visual_param_entry_get_integer(ptmp))
                    visual_param_entry_set_integer(ptmp, *integer);
                break;
            }
            
            
            case VISUAL_PARAM_ENTRY_TYPE_COLOR:
            {
                VisColor *color = visual_param_entry_get_color(ptmp);
                VisColor ncolor;
                uint32_t nicolor = (((color->b)<<16) + ((color->g)<<8) + color->r);
                uint32_t *icolor = entries[i].val;
            
                /* only update if values differ */
                if(*icolor != nicolor)
                {
                    visual_color_set(&ncolor, (*icolor&0xFF0000)>>16, (*icolor&0xFF00)>>8, (*icolor&0xFF));
                    visual_param_entry_set_color_by_color(ptmp, &ncolor);
                }
                break;
            }
            
            
            case VISUAL_PARAM_ENTRY_TYPE_STRING:
            {
                char **string = entries[i].val;
            
                /* only update if values differ */
                if(strcmp(*string, visual_param_entry_get_string(ptmp)) != 0)
                    visual_param_entry_set_string(ptmp, *string);
                break;
            }
        }
    }
Example #7
0
static void set_parameter_lv(void * data, const char * name,
                             const bg_parameter_value_t * val)
  {
  int supported;
  lv_priv_t * priv;
  int index;
  int i_tmp;
  uint8_t r, g, b;
  char * tmp_string;
  VisParamEntry * param;
  VisListEntry * list_entry;

  VisColor * color;
  const bg_parameter_info_t * info;
  
  if(!name)
    return;
  priv = (lv_priv_t*)data;

  info = bg_parameter_find(priv->parameters, name);
  if(!info)
    return;

  /* This would crash if multi_parameters were supported */
  index = info - priv->parameters;

  tmp_string = gavl_strdup(name);
  param = visual_param_entry_new(tmp_string);
  free(tmp_string);
  /* Menus have to be treated specially */
  if(info->type == BG_PARAMETER_STRINGLIST)
    {
    if(!priv->widgets[index])
      return;
    /* Get the selected index */
    supported = 0;
    list_entry = NULL;
    while(visual_list_next(&VISUAL_UI_CHOICE(priv->widgets[index])->choices.choices,
                           &list_entry))
      {
      if(!strcmp(((VisUIChoiceEntry*)(list_entry->data))->name, val->val_str))
        {
        visual_param_entry_set_from_param(param,
                                          ((VisUIChoiceEntry*)(list_entry->data))->value);
        supported = 1;
        break;
        }
      }
    }
  else
    {
    supported = 1;
    switch(priv->params[index]->type)
      {
      case VISUAL_PARAM_ENTRY_TYPE_NULL:     /**< No parameter. */
        supported = 0;
        break;
      case VISUAL_PARAM_ENTRY_TYPE_STRING:   /**< String parameter. */
        if(val->val_str)
          visual_param_entry_set_string(param, val->val_str);
        else
          supported = 0;
        break;
      case VISUAL_PARAM_ENTRY_TYPE_INTEGER:  /**< Integer parameter. */
        visual_param_entry_set_integer(param, val->val_i);
        break;
      case VISUAL_PARAM_ENTRY_TYPE_FLOAT:    /**< Floating point parameter. */
        visual_param_entry_set_float(param, val->val_f);
        break;
      case VISUAL_PARAM_ENTRY_TYPE_DOUBLE:   /**< Double floating point parameter. */
        visual_param_entry_set_double(param, val->val_f);
        break;
      case VISUAL_PARAM_ENTRY_TYPE_COLOR:    /**< VisColor parameter. */
        i_tmp = (int)(val->val_color[0] * 255.0 + 0.5);
        if(i_tmp < 0) i_tmp = 0;
        if(i_tmp > 255) i_tmp = 255;
        r = i_tmp;
        
        i_tmp = (int)(val->val_color[1] * 255.0 + 0.5);
        if(i_tmp < 0) i_tmp = 0;
        if(i_tmp > 255) i_tmp = 255;
        g = i_tmp;

        i_tmp = (int)(val->val_color[2] * 255.0 + 0.5);
        if(i_tmp < 0) i_tmp = 0;
        if(i_tmp > 255) i_tmp = 255;
        b = i_tmp;

        color = visual_color_new();
        visual_color_set(color, r, g, b);
        visual_param_entry_set_color_by_color(param, color);
        visual_object_unref(VISUAL_OBJECT(color));
        break;
      case VISUAL_PARAM_ENTRY_TYPE_PALETTE:  /**< VisPalette parameter. */
      case VISUAL_PARAM_ENTRY_TYPE_OBJECT:   /**< VisObject parameter. */
      case VISUAL_PARAM_ENTRY_TYPE_END:      /**< List end, and used as terminator for VisParamEntry lists. */
        supported = 0;
        break;
      }
    }
  if(supported)
    {
    visual_event_queue_add_param(visual_plugin_get_eventqueue(visual_actor_get_plugin(priv->actor)),
                              param);
    }
  else
    visual_object_unref(VISUAL_OBJECT(param));
  }