From c94727c8728963ef6b0e1bcc4e65fa1f736eda85 Mon Sep 17 00:00:00 2001 From: rubenrua Date: Mon, 24 Sep 2018 10:02:01 +0200 Subject: [PATCH] Fix ndiaudiosrc offset A buffer can also have one or both of a start and an end offset. These are media-type specific. For video buffers, the start offset will generally be the frame number. For audio buffers, it will be the number of samples produced so far. For compressed data, it could be the byte offset in a source or destination file. Likewise, the end offset will be the offset of the end of the buffer. These can only be meaningfully interpreted if you know the media type of the buffer (the preceding CAPS event). Either or both can be set to GST_BUFFER_OFFSET_NONE. https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstBuffer.html --- src/ndiaudiosrc.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ndiaudiosrc.rs b/src/ndiaudiosrc.rs index fe8db62af..34eb09344 100644 --- a/src/ndiaudiosrc.rs +++ b/src/ndiaudiosrc.rs @@ -375,9 +375,8 @@ impl BaseSrcImpl for NdiAudioSrc { buffer.set_pts(pts + ndi_struct.start_pts); buffer.set_duration(duration); - //TODO fix audio offset buffer.set_offset(timestamp_data.offset); - timestamp_data.offset += 1; + timestamp_data.offset += audio_frame.no_samples as u64/audio_frame.no_channels as u64; buffer.set_offset_end(timestamp_data.offset); buffer.copy_from_slice(0, &vec).unwrap(); }