Skip to content
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

I get error when try SetPropery "muxer" for the "splitmuxsink" plugin. #30

Open
artofey opened this issue Feb 25, 2022 · 5 comments
Open

Comments

@artofey
Copy link

artofey commented Feb 25, 2022

Gstreamer's documentation allowed set property "muxer' for elelment "splitmuxsink".
But I got error in this code example:

pipeline, _ := gst.NewPipeline("")
splitMux, _ := gst.NewElement("splitmuxsink")
mux, _ := gst.NewElement("mp4mux")
splitMux.Set("muxer", mux)

err: fatal error: checkptr: pointer arithmetic result points to invalid allocation

I have tried other uses as well:
splitMux.Set("muxer", mux.GObject())
splitMux.Set("muxer", *mux)
but I also get errors (but different ones)

Does this library allow me to do what I want? When using the C language, I can do this easily.

@Medina312
Copy link

Hi, I don’t know

@artofey
Copy link
Author

artofey commented Feb 28, 2022

I think the proplem is here

For different runs of the same code, C.g_object_class_find_property function returns with random paramSpec.value_type values...

Function GetPropertyType return not valide Type.
GetPropertyType function returns wrong type. So this condition is true and we get an error

@clintlombard
Copy link

I'm having a similar issue with setting the active-pad property (requires *GstPad) of an input-selector element.

package main

import (
	"fmt"
	"log"
	"time"

	"github.com/tinyzimmer/go-gst/gst"
)


func main(){
	gst.Init(nil)
	pipeline, _ := gst.NewPipeline("")
	src0, _ := gst.NewElement("videotestsrc")
	src1, _ := gst.NewElement("videotestsrc")
	inputSelector, _ := gst.NewElement("input-selector")
	fakesink, _ := gst.NewElement("fakesink")

	pipeline.AddMany(
		src0,
		src1,
		inputSelector,
		fakesink,
	)
	src0.LinkFiltered(inputSelector, gst.NewCapsFromString("video/x-raw, framerate=16/1"))
	src1.LinkFiltered(inputSelector, gst.NewCapsFromString("video/x-raw, framerate=16/1"))
	inputSelector.Link(fakesink)
	pipeline.SetState(gst.StatePlaying)

	if inputSelector.GetState() != gst.StatePlaying {
		time.Sleep(10*time.Millisecond)
	}

	// Check the current active pad
	prop, _ := inputSelector.GetProperty("active-pad")
	fmt.Println("active-pad:", prop.(*gst.Pad).GetName())

	// Change the active pad
	pad := inputSelector.GetStaticPad("sink_1")

	err := inputSelector.SetProperty("active-pad", pad)
	if err != nil {
		log.Fatalf("Input selector failed to change inputs: %v\n", err)
	}
}

Output:

active-pad: sink_0
panic: runtime error: cgo argument has Go pointer to Go pointer

goroutine 1 [running]:
github.com/tinyzimmer/go-glib/glib.(*Value).SetPointer.func1(0xc000010060, 0x16)
        go/pkg/mod/github.com/tinyzimmer/[email protected]/glib/gvalue.go:557 +0x32
github.com/tinyzimmer/go-glib/glib.(*Value).SetPointer(0x55c720, 0xc000010058)
        go/pkg/mod/github.com/tinyzimmer/[email protected]/glib/gvalue.go:557 +0x19
github.com/tinyzimmer/go-glib/glib.gValue({0x55c720, 0xc000010058})
        go/pkg/mod/github.com/tinyzimmer/[email protected]/glib/gvalue.go:284 +0xa08
github.com/tinyzimmer/go-glib/glib.(*Object).SetProperty(0x587440, {0x55fed7, 0xa}, {0x55c720, 0xc000010058})
        go/pkg/mod/github.com/tinyzimmer/[email protected]/glib/gobject.go:211 +0x4f
main.main()

Seems like the issues is in go-glib. I've narrowed it down to gValue that can't handle *GObject derivatives like *GstObject so instead you must use .GObject(), i.e.

err := inputSelector.SetProperty("active-pad", pad.GObject())

This, however, opens another can of worms, because in SetPropertyValue it checks if the property type matches the value type, and this fails. The output now being

active-pad: sink_0
2022/03/17 13:57:29 Input selector failed to change inputs: Invalid type GObject for property active-pad

To fix this I think a simple solution would be to adjust the check in SetPropertyValue from

	if valType != propType {

to

	if !(valType.IsA(propType) || propType.IsA(valType)) {

@tinyzimmer how do you feel about this?

@normen
Copy link

normen commented Oct 18, 2022

+1

@RSWilli
Copy link

RSWilli commented Aug 24, 2023

@artofey move this issue to https://github.com/go-gst/go-gst (where future development of the bindings will take place) if you think it is necessary.

Alternatively move the linked PR to https://github.com/go-gst/go-glib

biglittlebigben pushed a commit to livekit/go-gst that referenced this issue Sep 1, 2023
Implement GetStructure on Element messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants