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

Add support for adding audio meta data to a buffer #42

Open
danjenkins opened this issue Jul 5, 2022 · 2 comments
Open

Add support for adding audio meta data to a buffer #42

danjenkins opened this issue Jul 5, 2022 · 2 comments

Comments

@danjenkins
Copy link

If you have a buffer with non interleaved audio inside it, you need to add meta data to the buffer to say it's not interleaved and how to deal with it...

gst_buffer_add_audio_meta

https://gstreamer.freedesktop.org/documentation/audio/gstaudiometa.html?gi-language=c#GstAudioMeta

@danjenkins
Copy link
Author

danjenkins commented Jul 5, 2022

@tinyzimmer I made a start on this but the whole gsize pointer logic is confusing me.... any chance you can tell me what I've done wrong?

Branch diff here: https://github.com/tinyzimmer/go-gst/compare/main...broadcastervc:go-gst:audio-metadata-non-interlaced?expand=1

These are the errors coming back from gstreamer

(<unknown>:33979): GStreamer-Audio-CRITICAL **: 22:15:37.327: GstAudioMeta properties would cause out-of-bounds memory access on the buffer: max_offset 4535117456, samples 960, bps 4, buffer size 7680

and

(<unknown>:33979): GStreamer-Audio-CRITICAL **: 22:15:37.348: GstAudioMeta properties would cause channel memory areas to overlap! offsets: 8 (0), 214 (1) with plane size 3840

In my case I'm calling the new function with gstAudio.BufferAddAudioMeta(b, info, int64(samples), []int{0, 3840})
b is a gst buffer created with b := gst.NewBufferFromBytes(data) and info is created from the caps I'm passing in... info, _ := gstAudio.InfoFromCaps(caps) which are "audio/x-raw, format=F32LE, channels=%d, rate=%d, layout=non-interleaved" (obviously with values...)

Obviously once I know it works I'll make the PR :)

Oh and this is the test data for gst_buffer_add_audio_meta... https://github.com/GStreamer/gstreamer/blob/main/subprojects/gst-plugins-base/tests/check/libs/audio.c#L1368-L1401 for an idea of what it's expecting...

@danjenkins
Copy link
Author

Most recent commit I removed the offset parameter and passed in NULL because my audio samples are tightly packed. And it seems to work.... so just need to sort out the passing in off the offsets (and allow it to be null if someone chooses)

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

1 participant