コード例 #1
0
ファイル: frei0r.hpp プロジェクト: d-j-a-y/frei0r
    void register_param(std::string& p_loc,
			const std::string& name,
			const std::string& desc)
    {
      param_ptrs.push_back(&p_loc);
      s_params.push_back(param_info(name,desc,F0R_PARAM_STRING));
    }
コード例 #2
0
ファイル: frei0r.hpp プロジェクト: d-j-a-y/frei0r
    void register_param(double& p_loc,
			const std::string& name,
			const std::string& desc)
    {
      param_ptrs.push_back(&p_loc);
      s_params.push_back(param_info(name,desc,F0R_PARAM_DOUBLE));
    }
コード例 #3
0
ファイル: frei0r.hpp プロジェクト: d-j-a-y/frei0r
    void register_param(f0r_param_position& p_loc,
			const std::string& name,
			const std::string& desc)
    {
      param_ptrs.push_back(&p_loc);
      s_params.push_back(param_info(name,desc,F0R_PARAM_POSITION));
    }
コード例 #4
0
ファイル: params.cpp プロジェクト: richardf/mdmgrasp_mcast
/**
 * Obtem o tipo do argumento 'arg' presente na linha de comando. Esta funcao e' usada
 * para verificar se um argumento e' do tipo requerido por 'tag'.
 * @param tag	identificador da tag procurada
 * @param arg	argumento a ser obter o tipo
 * @return o tipo de argumento 'arg'.
 * @date 22/05/2002
 */
PRIVATE PARAMTYPE param_arg_type (PCHAR tag, PCHAR arg)
{
  PPARAMINFO info;      // informacoes sobre o tag 'tag'
  PARAMTYPE  type;      // tipo do argumento 'arg'
  UINT       i;         // auxiliar

  // verifica se o argumento 'arg' e' um numero. se nao for e' string
  type = pt_int;
  for (i=0;arg[i];i++) {
    if (!isdigit (arg[i]))
      type = pt_str;
  }

  // como uma string tambem pode ser um caractere, verifica se o tag 'tag'
  // requer uma string ou um caractere e definido para 'arg' o tipo adequado
  if (assigned (tag)) {
    info = param_info (tag);
    if (assigned (info)) {
      if ((info->p_type == pt_char) && (strlen (arg) == 1))
        type = pt_char;
    }
  }

  return type;
}
コード例 #5
0
ファイル: frei0r.hpp プロジェクト: d-j-a-y/frei0r
    void register_param(f0r_param_color& p_loc,
			const std::string& name,
			const std::string& desc)
    {
      param_ptrs.push_back(&p_loc);
      s_params.push_back(param_info(name,desc,F0R_PARAM_COLOR));
    }
コード例 #6
0
ファイル: params.cpp プロジェクト: richardf/mdmgrasp_mcast
PUBLIC BOOL param_asbool (PCHAR tag)
{
  PPARAMINFO  info;

  info = param_info (tag);
  if (assigned (info)) {
    if (param_tag_index (info->p_tag) != -1)
      return TRUE;
    else
      return info->p_default.u_bool;
  }

  return FALSE;
}
コード例 #7
0
ファイル: params.cpp プロジェクト: richardf/mdmgrasp_mcast
PUBLIC PCHAR param_asstr (PCHAR tag)
{
  PPARAMINFO info;
  INT        i;

  info = param_info (tag);
  if (isnull (info))
    return 0;

  i = param_tag_index (info->p_tag);
  if (i != -1) {
    i++;
    if (!param_istag (params.p_argv[i]))
      return params.p_argv[i];
  }

  return info->p_default.u_str;
}
コード例 #8
0
ファイル: params.cpp プロジェクト: richardf/mdmgrasp_mcast
PUBLIC LONG param_aslong (PCHAR tag)
{
  PPARAMINFO info;
  INT        i;

  info = param_info (tag);
  if (isnull (info))
    return 0;

  i = param_tag_index (info->p_tag);
  if (i != -1) {
    i++;
    if (!param_istag (params.p_argv[i]))
      return (INT) atol (params.p_argv[i]);
  }

  return info->p_default.u_int;
}
コード例 #9
0
ファイル: params.cpp プロジェクト: richardf/mdmgrasp_mcast
PRIVATE UINT param_tag_args (PCHAR tag)
{
  PPARAMINFO  info;     // informacoes sobre 'tag'
  UINT        count;    // no. de argumentos de 'tag'
  INT         idx;      // indice de 'tag' na linha de comando

  count = 0;

  idx = param_tag_index (tag);
  if (idx >= 0) {
    info = param_info (tag);
    if (assigned (info)) {
      if ((info->p_type != pt_bool) && (++idx < params.p_argc)) {
        if (params.p_argv[idx][0] != '-') {
          if (param_arg_type (tag,params.p_argv[idx]) == info->p_type)
            count++;
        }
      }
    }
  }

  return count;
}
コード例 #10
0
ファイル: factory.c プロジェクト: rayl/MLT
static mlt_properties fill_param_info ( mlt_service_type type, const char *service_name, char *name )
{
	char file[ PATH_MAX ];
	char servicetype[ 1024 ]="";
	struct stat stat_buff;

	switch ( type ) {
		case producer_type:
			strcpy ( servicetype , "producer" );
			break;
		case filter_type:
			strcpy ( servicetype , "filter" );
			break;
		case transition_type:
			strcpy ( servicetype , "transition" ) ;
			break;
		default:
			strcpy ( servicetype , "" );
	};

	snprintf( file, PATH_MAX, "%s/frei0r/%s_%s.yml", mlt_environment( "MLT_DATA" ), servicetype, service_name );
	stat(file,&stat_buff);

	if (S_ISREG(stat_buff.st_mode)){
		return mlt_properties_parse_yaml( file );
	}

	void* handle=dlopen(name,RTLD_LAZY);
	if (!handle) return NULL;
	void (*plginfo)(f0r_plugin_info_t*)=dlsym(handle,"f0r_get_plugin_info");
	void (*param_info)(f0r_param_info_t*,int param_index)=dlsym(handle,"f0r_get_param_info");
	if (!plginfo || !param_info) {
		dlclose(handle);
		return NULL;
	}
	mlt_properties metadata = mlt_properties_new();
	f0r_plugin_info_t info;
	char string[48];
	int j=0;

	plginfo(&info);
	snprintf ( string, sizeof(string) , "%d.%d" , info.major_version , info.minor_version );
	mlt_properties_set ( metadata, "schema_version" , "0.1" );
	mlt_properties_set ( metadata, "title" , info.name );
	mlt_properties_set ( metadata, "version", string );
	mlt_properties_set ( metadata, "identifier" , service_name );
	mlt_properties_set ( metadata, "description" , info.explanation );
	mlt_properties_set ( metadata, "creator" , info.author );
	switch (type){
		case producer_type:
			mlt_properties_set ( metadata, "type" , "producer" );
			break;
		case filter_type:
			mlt_properties_set ( metadata, "type" , "filter" );
			break;
		case transition_type:
			mlt_properties_set ( metadata, "type" , "transition" );
			break;
		default:
			break;
	}

	mlt_properties parameter = mlt_properties_new ( );
	mlt_properties_set_data ( metadata , "parameters" , parameter , 0 , ( mlt_destructor )mlt_properties_close, NULL );
	mlt_properties tags = mlt_properties_new ( );
	mlt_properties_set_data ( metadata , "tags" , tags , 0 , ( mlt_destructor )mlt_properties_close, NULL );
	mlt_properties_set ( tags , "0" , "Video" );

	for (j=0;j<info.num_params;j++){
		snprintf ( string , sizeof(string), "%d" , j );
		mlt_properties pnum = mlt_properties_new ( );
		mlt_properties_set_data ( parameter , string , pnum , 0 , ( mlt_destructor )mlt_properties_close, NULL );
		f0r_param_info_t paraminfo;
		param_info(&paraminfo,j);
		mlt_properties_set ( pnum , "identifier" , paraminfo.name );
		mlt_properties_set ( pnum , "title" , paraminfo.name );
		mlt_properties_set ( pnum , "description" , paraminfo.explanation);
		if ( paraminfo.type == F0R_PARAM_DOUBLE ){
			mlt_properties_set ( pnum , "type" , "float" );
			mlt_properties_set ( pnum , "minimum" , "0" );
			mlt_properties_set ( pnum , "maximum" , "1" );
			mlt_properties_set ( pnum , "readonly" , "no" );
			mlt_properties_set ( pnum , "widget" , "spinner" );
		}else
		if ( paraminfo.type == F0R_PARAM_BOOL ){
			mlt_properties_set ( pnum , "type" , "boolean" );
			mlt_properties_set ( pnum , "minimum" , "0" );
			mlt_properties_set ( pnum , "maximum" , "1" );
			mlt_properties_set ( pnum , "readonly" , "no" );
		}else
		if ( paraminfo.type == F0R_PARAM_COLOR ){
			mlt_properties_set ( pnum , "type" , "color" );
			mlt_properties_set ( pnum , "readonly" , "no" );
		}else
		if ( paraminfo.type == F0R_PARAM_STRING ){
			mlt_properties_set ( pnum , "type" , "string" );
			mlt_properties_set ( pnum , "readonly" , "no" );
		}
	}
	dlclose(handle);
	free(name);

	return metadata;
}
コード例 #11
0
ファイル: factory.c プロジェクト: adiibanez/mlt
static mlt_properties fill_param_info ( mlt_service_type type, const char *service_name, char *name )
{
	char file[ PATH_MAX ];
	char servicetype[ 1024 ]="";
	struct stat stat_buff;

	switch ( type ) {
		case producer_type:
			strcpy ( servicetype , "producer" );
			break;
		case filter_type:
			strcpy ( servicetype , "filter" );
			break;
		case transition_type:
			strcpy ( servicetype , "transition" ) ;
			break;
		default:
			strcpy ( servicetype , "" );
	};

	snprintf( file, PATH_MAX, "%s/frei0r/%s_%s.yml", mlt_environment( "MLT_DATA" ), servicetype, service_name );
	memset(&stat_buff, 0, sizeof(stat_buff));
	stat(file,&stat_buff);

	if (S_ISREG(stat_buff.st_mode)){
		return mlt_properties_parse_yaml( file );
	}

	void* handle=dlopen(name,RTLD_LAZY);
	if (!handle) return NULL;
	void (*plginfo)(f0r_plugin_info_t*)=dlsym(handle,"f0r_get_plugin_info");
	void (*param_info)(f0r_param_info_t*,int param_index)=dlsym(handle,"f0r_get_param_info");
	void (*f0r_init)(void)=dlsym(handle,"f0r_init");
	void (*f0r_deinit)(void)=dlsym(handle,"f0r_deinit");
	f0r_instance_t (*f0r_construct)(unsigned int , unsigned int)=dlsym(handle, "f0r_construct");
	void (*f0r_destruct)(f0r_instance_t)=dlsym(handle, "f0r_destruct");
	void (*f0r_get_param_value)(f0r_instance_t instance, f0r_param_t param, int param_index)=dlsym(handle,"f0r_get_param_value" );
	if (!plginfo || !param_info) {
		dlclose(handle);
		return NULL;
	}
	mlt_properties metadata = mlt_properties_new();
	f0r_plugin_info_t info;
	char string[48];
	int j=0;

	f0r_init();
	f0r_instance_t instance = f0r_construct(720, 576);
	if (!instance) {
		f0r_deinit();
		dlclose(handle);
		mlt_properties_close(metadata);
		return NULL;
	}
	plginfo(&info);
	snprintf ( string, sizeof(string) , "%d" , info.minor_version );
	mlt_properties_set_double ( metadata, "schema_version" , 0.1 );
	mlt_properties_set ( metadata, "title" , info.name );
	mlt_properties_set_double ( metadata, "version",
		info.major_version +  info.minor_version / pow( 10, strlen( string ) ) );
	mlt_properties_set ( metadata, "identifier" , service_name );
	mlt_properties_set ( metadata, "description" , info.explanation );
	mlt_properties_set ( metadata, "creator" , info.author );
	switch (type){
		case producer_type:
			mlt_properties_set ( metadata, "type" , "producer" );
			break;
		case filter_type:
			mlt_properties_set ( metadata, "type" , "filter" );
			break;
		case transition_type:
			mlt_properties_set ( metadata, "type" , "transition" );
			break;
		default:
			break;
	}

	mlt_properties tags = mlt_properties_new ( );
	mlt_properties_set_data ( metadata , "tags" , tags , 0 , ( mlt_destructor )mlt_properties_close, NULL );
	mlt_properties_set ( tags , "0" , "Video" );

	mlt_properties parameter = mlt_properties_new ( );
	mlt_properties_set_data ( metadata , "parameters" , parameter , 0 , ( mlt_destructor )mlt_properties_close, NULL );

	for (j=0;j<info.num_params;j++){
		snprintf ( string , sizeof(string), "%d" , j );
		mlt_properties pnum = mlt_properties_new ( );
		mlt_properties_set_data ( parameter , string , pnum , 0 , ( mlt_destructor )mlt_properties_close, NULL );
		f0r_param_info_t paraminfo;
		param_info(&paraminfo,j);
		mlt_properties_set ( pnum , "identifier" , string );
		mlt_properties_set ( pnum , "title" , paraminfo.name );
		mlt_properties_set ( pnum , "description" , paraminfo.explanation);
		if ( paraminfo.type == F0R_PARAM_DOUBLE ){
			double deflt = 0;
			mlt_properties_set ( pnum , "type" , "float" );
			mlt_properties_set ( pnum , "minimum" , "0" );
			mlt_properties_set ( pnum , "maximum" , "1" );
			f0r_get_param_value( instance, &deflt, j);
			mlt_properties_set_double ( pnum, "default", CLAMP(deflt, 0.0, 1.0) );
			mlt_properties_set ( pnum , "mutable" , "yes" );
			mlt_properties_set ( pnum , "widget" , "spinner" );
		}else
		if ( paraminfo.type == F0R_PARAM_BOOL ){
			double deflt = 0;
			mlt_properties_set ( pnum , "type" , "boolean" );
			mlt_properties_set ( pnum , "minimum" , "0" );
			mlt_properties_set ( pnum , "maximum" , "1" );
			f0r_get_param_value( instance, &deflt, j);
			mlt_properties_set_int ( pnum, "default", deflt != 0.0 );
			mlt_properties_set ( pnum , "mutable" , "yes" );
			mlt_properties_set ( pnum , "widget" , "checkbox" );
		}else
		if ( paraminfo.type == F0R_PARAM_COLOR ){
			char colorstr[8];
			f0r_param_color_t deflt = {0, 0, 0};

			mlt_properties_set ( pnum , "type" , "color" );
			f0r_get_param_value( instance, &deflt, j);
			sprintf( colorstr, "#%02x%02x%02x", (unsigned) CLAMP(deflt.r * 255, 0 , 255),
				(unsigned) CLAMP(deflt.g * 255, 0 , 255), (unsigned) CLAMP(deflt.b * 255, 0 , 255));
			colorstr[7] = 0;
			mlt_properties_set ( pnum , "default", colorstr );
			mlt_properties_set ( pnum , "mutable" , "yes" );
			mlt_properties_set ( pnum , "widget" , "color" );
		}else
		if ( paraminfo.type == F0R_PARAM_STRING ){
			char *deflt = NULL;
			mlt_properties_set ( pnum , "type" , "string" );
			f0r_get_param_value( instance, &deflt, j );
			mlt_properties_set ( pnum , "default", deflt );
			mlt_properties_set ( pnum , "mutable" , "yes" );
			mlt_properties_set ( pnum , "widget" , "text" );
		}
	}
	f0r_destruct(instance);
	f0r_deinit();
	dlclose(handle);
	free(name);

	return metadata;
}
コード例 #12
0
ファイル: params.cpp プロジェクト: richardf/mdmgrasp_mcast
PUBLIC BOOL param_check (PCHAR msg)
{
  PPARAMINFO  info;
  PARAMTYPE   type;
  LONG        val_int;
  CHAR        val_char;
  UINT        i;

  for (i=1;i < params.p_argc;i++) {
    if (params.p_argv[i][0] == '-') {
      if (!param_istag (params.p_argv[i])) {
        sprintf (msg,PAR_INV,params.p_argv[i]);
        return FALSE;
      }
      else {
        info = param_info (params.p_argv[i]);
        if (info->p_type != pt_bool) {
          if (i < params.p_argc - 1) {
            i++;
            if (params.p_argv[i][0] != '-') {
              type = param_arg_type (info->p_tag,params.p_argv[i]);

              if (type != info->p_type) {
                switch (info->p_type) {
                  case pt_char:
                    sprintf (msg,PAR_ARG_CHAR,params.p_argv[i - 1]);
                    break;

                  case pt_int:
                    sprintf (msg,PAR_ARG_INT,params.p_argv[i - 1]);
                    break;

                  default:
                    sprintf (msg,PAR_ARG,params.p_argv[i - 1]);
                }
                return FALSE;
              }
              else {
                switch (type) {
                  case pt_int:
                    val_int = atol (params.p_argv[i]);
                    if ((val_int < info->p_range.r_min.u_int) ||
                        (val_int > info->p_range.r_max.u_int)) {
                       sprintf (msg,PAR_RANGE_INT,
                                    params.p_argv[i - 1],
                                    val_int,
                                    info->p_range.r_min.u_int,
                                    info->p_range.r_max.u_int);
                       return FALSE;
                    }
                    break;

                  case pt_char:
                    val_char = params.p_argv[i][0];
                    if ((val_char < info->p_range.r_min.u_char) ||
                        (val_char > info->p_range.r_max.u_char)) {
                       sprintf (msg,PAR_RANGE_CHAR,
                                    params.p_argv[i - 1],
                                    params.p_argv[i][0],
                                    info->p_range.r_min.u_char,
                                    info->p_range.r_max.u_char);
                       return FALSE;
                    }
                    break;

                  case pt_bool:
                  case pt_str:
                    break;
                }
              }
            }
            else {
              sprintf (msg,PAR_ARG,params.p_argv[i - 1]);
              return FALSE;
            }
          }
          else {
            sprintf (msg,PAR_ARG,params.p_argv[i]);
            return FALSE;
          }
        }
      }
    }
  }

  return TRUE;
}