audio appsrc using generated bindings

I need to push a slice of audio bytes using an appsrc

audioSrc, ok := gst.ElementFactoryMake("appsrc", "audioSrc").(gstapp.AppSrc) 	if !ok { 		log.Fatalf("failed to create appsrc") 	}  	audioInfo := gstaudio.NewAudioInfo() 	audioInfo.SetFormat(gstaudio.AudioFormatS16le, 44100, int32(gstaudio.AudioChannelPositionInvalid)) 	// if !ok { 	// 	log.Fatalf("failed to set audio format") 	// } 	// audioInfo.SetFramerate(25, 1) 	caps3 := audioInfo.ToCaps() 	// log.Printf("Caps: %s", caps3.String()) 	audioSrc.SetObjectProperty("caps", caps3) 	audioSrc.SetObjectProperty("format", gst.FormatTime)

appsrc can be mostly controlled through signals (and action signals). See appsrc

The generated bindings should contain ease-of-use methods on the appsrc interface for connecting and emitting these signals. The gstapp Package also contains more bindings that don’t work with signals and instead directly call the methods, e.g. AppSrc.PushBuffer.

See also the example: go-gst/examples/appsrc/main.go at generated_bindings · go-gst/go-gst · GitHub

If you want more help then please add more detail to your question

second attempt to enter preformatted code…

audioSrc, ok := gst.ElementFactoryMake("appsrc", "audioSrc").(gstapp.AppSrc)
audioInfo := gstaudio.NewAudioInfo()
audioInfo.SetFormat(gstaudio.AudioFormatS16le, 44100,  gstaudio.AudioChannelPositionInvalid)

caps3 := audioInfo.ToCaps()
audioSrc.SetObjectProperty("caps", caps3)
audioSrc.SetObjectProperty("format", gst.FormatTime)
  1. Clearly AudioChannelPositionInvalid doesn’t mean STEREO, so how to correct this?
  2. Am I setting format twice?

I’m modelling this on my working appsrc for pushing video frames, which is almost an exact copy of the generated appsrc example.

EDIT: I also tried the following

audioInfo := gstaudio.NewAudioInfo()
var channelPositions [64]gstaudio.AudioChannelPosition
channelPositions[0] = gstaudio.AudioChannelPositionFrontLeft
channelPositions[1] = gstaudio.AudioChannelPositionFrontRight
audioInfo.SetFormat(gstaudio.AudioFormatS16le, 44100, 2, channelPositions)

but it panics with

unimplemented conversion of [64]AudioChannelPosition (const GstAudioChannelPosition*)

Yes, I do need more help. Please could you add an appsrc for audio to your generated examples? This would probably get me started.

unimplemented conversion of [64]AudioChannelPosition (const GstAudioChannelPosition*)

That’s unfortunate, because that is an error thrown by the bindings if the generator doesn’t support the type conversion yet, in this case array conversions.

audio info Set Format requires an array of fixed size to be passed into C. Since I had no test case where I could easily test if the conversion works this is not yet implemented.

See also go-gst/pkg/gstaudio/gstaudio.gen.go at generated_bindings · go-gst/go-gst · GitHub

The generator needs to be changed in order for this to work properly. There are other cases where this panics because of the same reason.

I’m going to pick this up in the near future.

Thanks for picking this up. I think there could be at least one other related issue, where ```gst.UtilSetObjectArg``` can only accept a string for the value field.

@RSWilli At this time, is it possible for gstapp.AppSrc to push an array of S16LE audio?

Yesterday it was. Try it today again please, but note that I had to make some more changes to be able to change the license of the projects