diff --git a/gst/gst_bin.go b/gst/gst_bin.go index c122405..de7d1c5 100644 --- a/gst/gst_bin.go +++ b/gst/gst_bin.go @@ -250,7 +250,7 @@ func iteratorToElementSlice(iterator *C.GstIterator) ([]*Element, error) { case C.GST_ITERATOR_OK: cElemVoid := C.g_value_get_object((*C.GValue)(gval)) cElem := (*C.GstElement)(cElemVoid) - elems = append(elems, wrapElement(glib.Take(unsafe.Pointer(cElem)))) + elems = append(elems, wrapElement(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(cElem))})) C.g_value_reset((*C.GValue)(gval)) default: return nil, errors.New("Element iterator failed") diff --git a/gst/gst_buffer.go b/gst/gst_buffer.go index b9a2e55..28ae02d 100644 --- a/gst/gst_buffer.go +++ b/gst/gst_buffer.go @@ -144,9 +144,6 @@ func (b *Buffer) Reader() io.Reader { return bytes.NewBuffer(b.Bytes()) } // Bytes returns a byte slice of the data inside this buffer. func (b *Buffer) Bytes() []byte { mapInfo := b.Map(MapRead) - if mapInfo.ptr == nil { - return nil - } return mapInfo.Bytes() } diff --git a/gst/gst_device.go b/gst/gst_device.go index 91bb553..f01ed5d 100644 --- a/gst/gst_device.go +++ b/gst/gst_device.go @@ -26,7 +26,7 @@ func (d *Device) CreateElement(name string) *Element { defer C.free(unsafe.Pointer(cName)) } elem := C.gst_device_create_element(d.Instance(), cName) - return wrapElement(glib.Take(unsafe.Pointer(elem))) + return wrapElement(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(elem))}) } // Caps returns the caps that this device supports. Unref after usage. diff --git a/gst/gst_element.go b/gst/gst_element.go index ee6f8e3..425390f 100644 --- a/gst/gst_element.go +++ b/gst/gst_element.go @@ -72,7 +72,7 @@ func (e *Element) GetBus() *Bus { if bus == nil { return nil } - return wrapBus(glib.Take(unsafe.Pointer(bus))) + return wrapBus(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(bus))}) } // GetClock returns the Clock for this element. This is the clock as was last set with gst_element_set_clock. @@ -82,7 +82,7 @@ func (e *Element) GetClock() *Clock { if cClock == nil { return nil } - return wrapClock(glib.Take(unsafe.Pointer(cClock))) + return wrapClock(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(cClock))}) } // GetState returns the current state of this element. @@ -122,7 +122,7 @@ func (e *Element) GetFactory() *ElementFactory { if factory == nil { return nil } - return wrapElementFactory(glib.Take(unsafe.Pointer(factory))) + return wrapElementFactory(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(factory))}) } // GetPads retrieves a list of pads associated with the element. @@ -131,7 +131,7 @@ func (e *Element) GetPads() []*Pad { out := make([]*Pad, 0) goList.Foreach(func(item interface{}) { pt := item.(unsafe.Pointer) - out = append(out, wrapPad(glib.Take(pt))) + out = append(out, wrapPad(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(pt))})) }) return out } @@ -159,7 +159,7 @@ func (e *Element) GetPadTemplates() []*PadTemplate { out := make([]*PadTemplate, 0) goList.Foreach(func(item interface{}) { pt := item.(unsafe.Pointer) - out = append(out, wrapPadTemplate(glib.Take(pt))) + out = append(out, wrapPadTemplate(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(pt))})) }) return out } diff --git a/gst/gst_element_factory.go b/gst/gst_element_factory.go index 3ad5589..3916787 100644 --- a/gst/gst_element_factory.go +++ b/gst/gst_element_factory.go @@ -22,7 +22,7 @@ func NewElement(name string) (*Element, error) { if elem == nil { return nil, fmt.Errorf("Could not create element: %s", name) } - return wrapElement(glib.Take(unsafe.Pointer(elem))), nil + return wrapElement(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(elem))}), nil } // NewElementMany is a convenience wrapper around building many GstElements in a @@ -51,7 +51,7 @@ func Find(name string) *ElementFactory { if factory == nil { return nil } - return wrapElementFactory(glib.Take(unsafe.Pointer(factory))) + return wrapElementFactory(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(factory))}) } // Instance returns the C GstFactory instance diff --git a/gst/gst_message.go b/gst/gst_message.go index 7319757..f16ac8d 100644 --- a/gst/gst_message.go +++ b/gst/gst_message.go @@ -163,7 +163,7 @@ func (m *Message) ParseStreamStatus() (StreamStatusType, *Element) { (*C.GstStreamStatusType)(&cStatusType), (**C.GstElement)(&cElem), ) - return StreamStatusType(cStatusType), wrapElement(glib.Take(unsafe.Pointer(cElem))) + return StreamStatusType(cStatusType), wrapElement(toGObject(unsafe.Pointer(cElem))) } // ParseAsyncDone extracts the running time from the async task done message. @@ -282,7 +282,7 @@ func (m *Message) ParseStepDone() *StepDoneValues { func (m *Message) ParseNewClock() *Clock { var clock *C.GstClock C.gst_message_parse_new_clock((*C.GstMessage)(m.Instance()), &clock) - return wrapClock(glib.Take(unsafe.Pointer(clock))) + return wrapClock(toGObject(unsafe.Pointer(clock))) } // ParseClockProvide extracts the clock and ready flag from the GstMessage. @@ -291,7 +291,7 @@ func (m *Message) ParseClockProvide() (clock *Clock, ready bool) { var gclock *C.GstClock var gready C.gboolean C.gst_message_parse_clock_provide((*C.GstMessage)(m.Instance()), &gclock, &gready) - return wrapClock(glib.Take(unsafe.Pointer(clock))), gobool(gready) + return wrapClock(toGObject(unsafe.Pointer(clock))), gobool(gready) } // ParseStructureChange extracts the change type and completion status from the GstMessage. @@ -304,7 +304,7 @@ func (m *Message) ParseStructureChange() (chgType StructureChangeType, owner *El (*C.GstMessage)(m.Instance()), &gchgType, &gElem, &gbusy, ) - return StructureChangeType(gchgType), wrapElement(glib.Take(unsafe.Pointer(gElem))), gobool(gbusy) + return StructureChangeType(gchgType), wrapElement(toGObject(unsafe.Pointer(gElem))), gobool(gbusy) } // ParseSegmentStart extracts the position and format of the SegmentStart message. @@ -394,7 +394,7 @@ func (m *Message) ParseResetTime() time.Duration { func (m *Message) ParseDeviceAdded() *Device { var device *C.GstDevice C.gst_message_parse_device_added((*C.GstMessage)(m.Instance()), &device) - return wrapDevice(glib.Take(unsafe.Pointer(device))) + return wrapDevice(toGObject(unsafe.Pointer(device))) } // ParseDeviceRemoved parses a device-removed message. The device-removed message @@ -403,7 +403,7 @@ func (m *Message) ParseDeviceAdded() *Device { func (m *Message) ParseDeviceRemoved() *Device { var device *C.GstDevice C.gst_message_parse_device_removed((*C.GstMessage)(m.Instance()), &device) - return wrapDevice(glib.Take(unsafe.Pointer(device))) + return wrapDevice(toGObject(unsafe.Pointer(device))) } // ParseDeviceChanged Parses a device-changed message. The device-changed message is @@ -414,8 +414,8 @@ func (m *Message) ParseDeviceRemoved() *Device { func (m *Message) ParseDeviceChanged() (newDevice, oldDevice *Device) { var gstNewDevice, gstOldDevice *C.GstDevice C.gst_message_parse_device_changed((*C.GstMessage)(m.Instance()), &gstNewDevice, &gstOldDevice) - return wrapDevice(glib.Take(unsafe.Pointer(gstNewDevice))), - wrapDevice(glib.Take(unsafe.Pointer(gstOldDevice))) + return wrapDevice(toGObject(unsafe.Pointer(gstNewDevice))), + wrapDevice(toGObject(unsafe.Pointer(gstOldDevice))) } // ParsePropertyNotify parses a property-notify message. These will be posted on the bus only @@ -429,7 +429,7 @@ func (m *Message) ParsePropertyNotify() (obj *Object, propertName string, proper (*C.GstMessage)(m.Instance()), &gstobj, (**C.gchar)(unsafe.Pointer(namePtr)), &gval, ) - return wrapObject(glib.Take(unsafe.Pointer(gstobj))), + return wrapObject(toGObject(unsafe.Pointer(gstobj))), string(C.GoBytes(namePtr, C.sizeOfGCharArray((**C.gchar)(namePtr)))), glib.ValueFromNative(unsafe.Pointer(gval)) } @@ -441,7 +441,7 @@ func (m *Message) ParseStreamCollection() *StreamCollection { (*C.GstMessage)(m.Instance()), &collection, ) - return wrapStreamCollection(glib.Take(unsafe.Pointer(collection))) + return wrapStreamCollection(toGObject(unsafe.Pointer(collection))) } // ParseStreamsSelected parses a streams-selected message. @@ -451,7 +451,7 @@ func (m *Message) ParseStreamsSelected() *StreamCollection { (*C.GstMessage)(m.Instance()), &collection, ) - return wrapStreamCollection(glib.Take(unsafe.Pointer(collection))) + return wrapStreamCollection(toGObject(unsafe.Pointer(collection))) } // NumRedirectEntries returns the number of redirect entries in a MessageRedirect. diff --git a/gst/gst_pad.go b/gst/gst_pad.go index ce3cde5..6a2e5c6 100644 --- a/gst/gst_pad.go +++ b/gst/gst_pad.go @@ -812,7 +812,7 @@ func iteratorToPadSlice(iterator *C.GstIterator) ([]*Pad, error) { case C.GST_ITERATOR_OK: cPadVoid := C.g_value_get_object((*C.GValue)(gval)) cPad := (*C.GstPad)(cPadVoid) - pads = append(pads, wrapPad(glib.Take(unsafe.Pointer(cPad)))) + pads = append(pads, wrapPad(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(cPad))})) C.g_value_reset((*C.GValue)(gval)) default: return nil, errors.New("Element iterator failed") diff --git a/gst/gst_pipeline.go b/gst/gst_pipeline.go index fcaa13f..f238657 100644 --- a/gst/gst_pipeline.go +++ b/gst/gst_pipeline.go @@ -30,7 +30,7 @@ func NewPipeline(name string) (*Pipeline, error) { if pipeline == nil { return nil, errors.New("Could not create new pipeline") } - return wrapPipeline(glib.Take(unsafe.Pointer(pipeline))), nil + return wrapPipeline(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(pipeline))}), nil } // NewPipelineFromString creates a new gstreamer pipeline from the given launch string. @@ -47,7 +47,7 @@ func NewPipelineFromString(launchv string) (*Pipeline, error) { errMsg := C.GoString(gerr.message) return nil, errors.New(errMsg) } - return wrapPipeline(glib.Take(unsafe.Pointer(pipeline))), nil + return wrapPipeline(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(pipeline))}), nil } // Instance returns the native GstPipeline instance. @@ -57,7 +57,7 @@ func (p *Pipeline) Instance() *C.GstPipeline { return C.toGstPipeline(p.Unsafe() func (p *Pipeline) GetPipelineBus() *Bus { if p.bus == nil { cBus := C.gst_pipeline_get_bus((*C.GstPipeline)(p.Instance())) - p.bus = wrapBus(glib.Take(unsafe.Pointer(cBus))) + p.bus = wrapBus(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(cBus))}) } return p.bus } @@ -65,7 +65,7 @@ func (p *Pipeline) GetPipelineBus() *Bus { // GetPipelineClock returns the global clock for this pipeline. func (p *Pipeline) GetPipelineClock() *Clock { cClock := C.gst_pipeline_get_pipeline_clock((*C.GstPipeline)(p.Instance())) - return wrapClock(glib.Take(unsafe.Pointer(cClock))) + return wrapClock(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(cClock))}) } /* diff --git a/gst/gst_plugin_feature.go b/gst/gst_plugin_feature.go index d29c8ba..954da71 100644 --- a/gst/gst_plugin_feature.go +++ b/gst/gst_plugin_feature.go @@ -21,7 +21,7 @@ func (p *PluginFeature) GetPlugin() *Plugin { if plugin == nil { return nil } - return wrapPlugin(glib.Take(unsafe.Pointer(plugin))) + return wrapPlugin(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(plugin))}) } // GetPluginName returns the name of the plugin that provides this feature. diff --git a/gst/gst_registry.go b/gst/gst_registry.go index 5cdcb8b..e002281 100644 --- a/gst/gst_registry.go +++ b/gst/gst_registry.go @@ -16,7 +16,7 @@ type Registry struct{ *Object } // GetRegistry returns the default global GstRegistry. func GetRegistry() *Registry { registry := C.gst_registry_get() - return wrapRegistry(glib.Take(unsafe.Pointer(registry))) + return wrapRegistry(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(registry))}) } // Instance returns the underlying GstRegistry instance. @@ -30,7 +30,7 @@ func (r *Registry) FindPlugin(name string) (*Plugin, error) { if plugin == nil { return nil, fmt.Errorf("No plugin named %s found", name) } - return wrapPlugin(glib.Take(unsafe.Pointer(plugin))), nil + return wrapPlugin(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(plugin))}), nil } // LookupFeature looks up the given plugin feature by name. Unref after usage. @@ -41,5 +41,5 @@ func (r *Registry) LookupFeature(name string) (*PluginFeature, error) { if feat == nil { return nil, fmt.Errorf("No feature named %s found", name) } - return wrapPluginFeature(glib.Take(unsafe.Pointer(feat))), nil + return wrapPluginFeature(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(feat))}), nil } diff --git a/gst/gst_stream.go b/gst/gst_stream.go index e4c5bf9..9153f09 100644 --- a/gst/gst_stream.go +++ b/gst/gst_stream.go @@ -17,7 +17,7 @@ func NewStream(id string, caps *Caps, sType StreamType, flags StreamFlags) *Stre cID := C.CString(id) defer C.free(unsafe.Pointer(cID)) stream := C.gst_stream_new(cID, caps.Instance(), C.GstStreamType(sType), C.GstStreamFlags(flags)) - return wrapStream(glib.Take(unsafe.Pointer(stream))) + return wrapStream(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(stream))}) } // Instance returns the underlying GstStream. diff --git a/gst/gst_stream_collection.go b/gst/gst_stream_collection.go index e66456f..3758f7b 100644 --- a/gst/gst_stream_collection.go +++ b/gst/gst_stream_collection.go @@ -19,7 +19,7 @@ func NewStreamCollection(upstreamID string) *StreamCollection { cID := C.CString(upstreamID) defer C.free(unsafe.Pointer(cID)) collection := C.gst_stream_collection_new(cID) - return wrapStreamCollection(glib.Take(unsafe.Pointer(collection))) + return wrapStreamCollection(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(collection))}) } // Instance returns the underlying GstStreamCollection. @@ -43,7 +43,7 @@ func (s *StreamCollection) GetSize() uint { // GetStreamAt returns the stream at the given index in this collection. func (s *StreamCollection) GetStreamAt(idx uint) *Stream { stream := C.gst_stream_collection_get_stream(s.Instance(), C.guint(idx)) - return wrapStream(glib.Take(unsafe.Pointer(stream))) + return wrapStream(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(stream))}) } // GetUpstreamID retrieves the upstream ID for this collection.