Skip to content

SetPropertyValue(): Let enum type of property allow interget type of value #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions glib/gobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,18 @@ func (v *Object) SetPropertyValue(name string, value *Value) error {
if err != nil {
return err
}
if valType != propType {
return fmt.Errorf("Invalid type %s for property %s", value.TypeName(), name)
switch valType {
case TYPE_INT:
for ; propType.Depth() > 1; propType = propType.Parent() {
}
if propType == TYPE_ENUM {
break
}
fallthrough
default:
if valType != propType {
return fmt.Errorf("Invalid type %s for property %s(%s)", value.TypeName(), name, propType.Name())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifying type name of property given into error message would be helpful for debugging I think.

appSrc, err = gst.NewElement("appsrc")
err = appSrc.SetProperty("max-bytes", 1048576)
	if err != nil {
		logger.Errorf("gst appsrc err on set property max-bytes : %+v", err)
	}

property description (appsrc, max-bytes)

  max-bytes           : The maximum number of bytes to queue internally (0 = unlimited)
                        flags: readable, writable
                        Unsigned Integer64. Range: 0 - 18446744073709551615 Default: 200000

As is
Invalid type gint for property max-bytes

To be
Invalid type gint for property max-bytes(guint64)

}
}
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
Expand Down