feat(time-offset): add Time Offset block for live PTS shifting#555
Merged
feat(time-offset): add Time Offset block for live PTS shifting#555
Conversation
Generic media-agnostic block that shifts buffer running_time via gst_pad_set_offset. Use cases: lipsync between audio/video inputs to a mixer, and per-branch latency shaping (e.g. PGM vs multiview WHEP outputs). The `offset_ms` exposed property is live-updatable. A new interceptor in update_element_property catches it before the default property-set path and applies the offset directly to the identity src pad, then triggers recalculate_latency() so downstream sinks resync. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
builtin.time_offsetblock: a singleidentityelement whose src pad has a GStreamer pad-offset applied. Media-agnostic (Generic in/out pads), so the same block works on audio or video branches.offset_ms(Float, signed) is live-updatable. A small interceptor inupdate_element_propertycatches it before the default property-set path and appliespad.set_offset()directly, then triggerspipeline.recalculate_latency()so downstream sinks resync.Why
Two use cases drove this:
Design notes
offset_msshifts buffers later (delay), negative shifts them earlier (advance). Negative is accepted in the API, but with live sources only positive is physically meaningful — the pipeline cannot emit data ahead of the source. Documented in the property description.(prop_name == "offset_ms", element_id ends_with ":offset_identity"). Coupling to the block'sPropertyMappingand element naming is documented at the function site.Test plan
cargo test --lib time_offset— 6 unit tests covering definition shape, live apply (positive, negative, non-matching element, non-matching property), and initial offset on buildcargo test --test openapi_test— snapshot unchanged (no new API types)cargo test --test pipeline_lifecycle_test— leak regression still passescargo checkand clippy pre-commit hooks clean🤖 Generated with Claude Code