feat(appsink): expose buffer pts/dts on pulled samples - #26
Merged
Conversation
`gst_sample_to_js` already has the sample's `GstBuffer` in hand but only surfaces `buffer`, `flags` and `caps` — not the timing. So `onSample`/`getSample` consumers that need a frame's PTS have to add a separate pad probe and re-pair it with the sample by FIFO order, which is not 1:1 under drops/reorder. Extract `GST_BUFFER_PTS`/`GST_BUFFER_DTS` (nanoseconds, omitted when invalid) onto the returned sample object, mirroring the existing pad-probe path. Adds `pts?`/`dts?` to the `GStreamerSample` type and a test asserting consecutive 30fps PTS deltas. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
|
Will take a look ASAP |
repugraf
reviewed
Jul 13, 2026
repugraf
left a comment
Owner
There was a problem hiding this comment.
Thanks for the contribution!
A few minor comments.
Review feedback: the previous commit said it mirrored the pad-probe path but only carried `pts`/`dts`, while `BufferData` also exposes `duration`, `offset` and `offsetEnd`. Add the missing three, guarded the same way, so both paths surface the same buffer metadata instead of leaving an asymmetry behind. Also trim the code comment down to what it describes — the reason this beats a separate pad probe belongs in the PR description, not in the source. The appsink test now covers the frame duration and consecutive frame offsets as well. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
repugraf
approved these changes
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gst_sample_to_jsalready has the sample'sGstBufferin hand but only surfacesbuffer,flagsandcaps— not the timing. SoonSample/getSampleconsumersthat need a frame's PTS must add a separate pad probe and re-pair it with the sample
by FIFO order, which is not 1:1 under drops/reorder.
This extracts
GST_BUFFER_PTS/GST_BUFFER_DTS(nanoseconds, omitted when invalid)onto the returned sample, mirroring the existing pad-probe path, so a frame's PTS can
be read atomically with its buffer.
Changes
src/cpp/type-conversion.cpp: setpts/dtsingst_sample_to_js.src/ts/index.ts: addpts?/dts?toGStreamerSample.src/ts/appsink.test.ts: assert consecutive 30fps PTS deltas.Backward compatibility
Additive only — new optional fields; existing
buffer/flags/capsare unchanged.