dturing / node-gstreamer-superficial

Superficial gstreamer binding
MIT License
130 stars 45 forks source link

Cannot set int/enum type property using the object wrapper setter #55

Closed harrryhsu closed 11 months ago

harrryhsu commented 2 years ago

I was unable to set any "mode" kinda value on pad since "v8_to_gvalue" cast any number type to gfloat. Forking and add the below code solves my issue, is there a better way of doing this?

if (v->IsNumber()) { auto number = v->ToNumber(Nan::GetCurrentContext()).ToLocalChecked(); if (number->IsInt32()) { g_value_init(gv, G_TYPE_INT); g_value_set_int(gv, number->ToInteger(Nan::GetCurrentContext()).ToLocalChecked()->Value()); } else { g_value_init(gv, G_TYPE_FLOAT); g_value_set_float(gv, number->Value()); } }

dturing commented 11 months ago

can't come up with a better way, at least right now. please submit a PR if you want your fork integrated. thanks!