clocklineage

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: Apache-2.0, MIT Imports: 5 Imported by: 0

Documentation

Overview

Package clocklineage observes RTCP Sender Reports and maps RTP timestamps to the publisher's NTP clock without adding a second packet-timing authority.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InterceptorFactory

type InterceptorFactory struct{ Registry *Registry }

InterceptorFactory observes Sender Reports without consuming RTCP from Pion's RTPSender or RTPReceiver application readers.

func (*InterceptorFactory) NewInterceptor

func (f *InterceptorFactory) NewInterceptor(string) (interceptor.Interceptor, error)

NewInterceptor creates one observer for a PeerConnection interceptor chain.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry bounds Sender Report state to active streams in one PeerConnection. Remote timelines describe publisher ingress; local timelines describe relay subscriber egress generated by Pion.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty per-PeerConnection registry.

func (*Registry) Local

func (r *Registry) Local(ssrc uint32) *Timeline

Local returns stable bounded state for an outgoing SSRC.

func (*Registry) Remote

func (r *Registry) Remote(ssrc uint32) *Timeline

Remote returns stable bounded state for an incoming SSRC.

type SenderReportSnapshot

type SenderReportSnapshot struct {
	SSRC         uint32 `json:"ssrc"`
	NTPTime      uint64 `json:"ntp_time"`
	RTPTime      uint32 `json:"rtp_time"`
	PacketCount  uint32 `json:"packet_count"`
	OctetCount   uint32 `json:"octet_count"`
	ObservedAtNs int64  `json:"observed_at_ns"`
	ReportCount  uint64 `json:"report_count"`
	Normalized   bool   `json:"normalized"`
}

SenderReportSnapshot is the latest immutable RTCP Sender Report observation for one SSRC. A Timeline retains exactly one snapshot.

type Timeline

type Timeline struct {
	// contains filtered or unexported fields
}

Timeline retains the latest Sender Report for one SSRC. RTCP updates publish an immutable snapshot; RTP readers perform one lock-free pointer load.

func NewTimeline

func NewTimeline(ssrc uint32) *Timeline

NewTimeline creates an empty timeline for ssrc.

func (*Timeline) CaptureTime

func (t *Timeline) CaptureTime(rtpTimestamp uint32, now time.Time, clockRateHz uint32, maxAge time.Duration) (time.Time, bool)

CaptureTime maps rtpTimestamp onto the publisher NTP clock. The int32 subtraction implements RFC 3550 serial arithmetic across uint32 wraparound. Reports older than maxAge are rejected so stale lineage is never stamped.

func (*Timeline) NormalizeSenderReport

func (t *Timeline) NormalizeSenderReport(sr *rtcp.SenderReport, now time.Time, clockRateHz uint32) bool

NormalizeSenderReport rewrites sr.NTPTime from the latest genuine publisher capture mapping while preserving Pion's outgoing RTP timestamp.

func (*Timeline) Observe

func (t *Timeline) Observe(sr *rtcp.SenderReport, observedAt time.Time)

Observe records sr as the latest clock mapping. This is called on the RTCP path, not the RTP forwarding path.

func (*Timeline) ObserveCapture

func (t *Timeline) ObserveCapture(rtpTimestamp uint32, captureTime, observedAt time.Time)

ObserveCapture records one RTP-to-capture-clock mapping without allocation. A seqlock keeps readers from combining fields from adjacent RTP packets.

func (*Timeline) Snapshot

func (t *Timeline) Snapshot() (SenderReportSnapshot, bool)

Snapshot returns the latest report and whether one has been observed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址