コード例 #1
0
ファイル: VEditProducerScript.cpp プロジェクト: amongll/AVFX
void AsisScript::pre_judge() throw (Exception)
{
    ScriptProps::Property& service_prop = type_spec_props->get_property("service");
    if (!service_prop.Evaluable::finished())
        throw_error_v(ErrorScriptFmtError,"asis producer script service should be determinated");

    ScriptProps::Property& resource_prop = type_spec_props->get_property("resource");
    if (!resource_prop.Evaluable::finished())
        throw_error_v(ErrorScriptFmtError,"asis producer script resource should be determinated");

    json_t* svc_value = service_prop.compile();
    json_t* res_value = resource_prop.compile();
    JsonWrap svc_wrap(svc_value,1);
    JsonWrap res_wrap(res_value,1);

    if ( !svc_value || !json_is_string(svc_value) || !strlen(json_string_value(svc_value)))
        throw_error_v(ErrorScriptFmtError,"asis producer script service should be string value");
    if ( !res_value || !json_is_string(res_value) || !strlen(json_string_value(res_value)))
        throw_error_v(ErrorScriptFmtError,"asis producer script resource should be string value");

    mlt_profile prof = mlt_profile_clone(MltLoader::global_profile);
    mlt_producer tmp_prod = mlt_factory_producer(prof, json_string_value(svc_value), json_string_value(res_value));
    MltSvcWrap prod_wrap(mlt_producer_service(tmp_prod), 1);

    if (tmp_prod == NULL) {
        throw_error_v(ErrorRuntimeLoadFailed, "producer %s load failed", json_string_value(svc_value));
    }

    if ( mlt_props ) {
        ScriptProps::PropIter it = mlt_props->begin();
        for ( ; it!=mlt_props->end(); it++) {
            if ( it->second->Evaluable::finished() ) {
                json_t* prop_v = it->second->compile();
                JsonWrap prop_wrap(prop_v, 1);

                switch(prop_v->type) {
                case JSON_INTEGER:
                    mlt_properties_set_int64(mlt_producer_properties(tmp_prod),
                                             it->first.c_str(), json_integer_value(prop_v));
                    break;
                case JSON_REAL:
                    mlt_properties_set_double(mlt_producer_properties(tmp_prod),
                                              it->first.c_str(), json_real_value(prop_v));
                    break;
                case JSON_STRING:
                    mlt_properties_set(mlt_producer_properties(tmp_prod),
                                       it->first.c_str(), json_string_value(prop_v));
                    break;
                case JSON_TRUE:
                    mlt_properties_set_int(mlt_producer_properties(tmp_prod),
                                           it->first.c_str(), 1);
                    break;
                case JSON_FALSE:
                    mlt_properties_set_int(mlt_producer_properties(tmp_prod),
                                           it->first.c_str(), 0);
                    break;
                default:
                    throw_error_v(ErrorRuntimeLoadFailed, "producer %s load failed. %s prop invalid",
                                  json_string_value(svc_value), it->first.c_str());
                }
            }
        }
    }

    int in = mlt_producer_get_in(tmp_prod);
    int out = mlt_producer_get_out(tmp_prod);
    set_frame_range(in, out);

    if ( !mlt_props.get()) {
        mlt_props.reset(new ScriptProps(*this, NULL));
    }
    json_t* jv = json_integer(in);
    mlt_props->add_property("in", jv);
    json_decref(jv);

    jv = json_integer(out);
    mlt_props->add_property("out", jv);
    json_decref(jv);

    string uuid = Vm::uuid();
    type_spec_props->add_property("uuid", JsonWrap(json_string(uuid.c_str()),1).h);
    prod_wrap.obj = NULL;
    MltLoader::push_mlt_registry(mlt_producer_service(tmp_prod), uuid.c_str());
}
コード例 #2
0
ファイル: hid_resource.c プロジェクト: BenBergman/geda-pcb
void
load_mouse_resource (const Resource *res)
{
  int bi, mi, a;
  int action_count;
#ifdef DEBUG_HID_RESOURCE
  fprintf(stderr, "note mouse resource:\n");
  resource_dump (res);
#endif

  button_count = res->c;
  button_nums = (int *)malloc(res->c * sizeof(int));
  mod_count = (int *)malloc(res->c * sizeof(int));
  action_count = 0;
  for (bi=0; bi<res->c; bi++)
    {
      if (res->v[bi].value)
        action_count++;

      if (res->v[bi].subres)
        action_count += res->v[bi].subres->c;

    }
  mods = (unsigned int *)malloc(action_count * sizeof(int));
  actions = (Resource **)malloc(action_count * sizeof(Resource*));

  a = 0;
  for (bi=0; bi<res->c; bi++)
    {
      int button_num = button_name_to_num(res->v[bi].name);

      if (button_num < 0)
	continue;

      button_nums[bi] = button_num;
      mod_count[bi] = 0;

      if (res->v[bi].value)
        {
          mods[a] = 0;
          actions[a++] = res_wrap (res->v[bi].value);         
          mod_count[bi] = 1;
        }

      if (res->v[bi].subres)
	{
	  Resource *m = res->v[bi].subres;
          mod_count[bi] += m->c;

	  for (mi=0; mi<m->c; mi++, a++)
	    {
	      switch (resource_type (m->v[mi]))
		{
		case 1: /* subres only */
                  mods[a] = 0;
                  actions[a] = m->v[mi].subres;
		  break;

		case 10: /* value only */
                  mods[a] = 0;
                  actions[a] = res_wrap (m->v[mi].value);
		  break;

		case 101: /* name = subres */
		  mods[a] = parse_mods (m->v[mi].name);
		  actions[a] = m->v[mi].subres;
		  break;

		case 110: /* name = value */
		  mods[a] = parse_mods (m->v[mi].name);
		  actions[a] = res_wrap (m->v[mi].value);
		  break;
		}
	    }
	}
    }
}