Exemple #1
0
func parseGstStructure(s *C.GstStructure) (name string, fields glib.Params) {
	name = C.GoString((*C.char)(C.gst_structure_get_name(s)))
	ps := C._parse_struct(s)
	n := (int)(ps.n)
	tab := (*[1 << 16]C.Field)(unsafe.Pointer(ps.tab))[:n]
	fields = make(glib.Params)
	for _, f := range tab {
		fields[C.GoString(f.name)] = g2v(f.val).Get()
	}
	return
}
Exemple #2
0
func (v *Structure) fromGstStructure(s *C.GstStructure) {
	v.Name = C.GoString((*C.char)(C.gst_structure_get_name(s)))
	n := uint(C.gst_structure_n_fields(s))
	v.Data = make(map[string]interface{})
	for i := uint(0); i < n; i++ {
		fn := C.gst_structure_nth_field_name(s, C.guint(i))
		fv := glib.ValueFromNative(unsafe.Pointer(C.gst_structure_id_get_value(s, C.g_quark_from_string(fn))))
		val, _ := fv.GoValue()
		v.Data[C.GoString((*C.char)(fn))] = val
	}
	return
}