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 ¶
- type InterceptorFactory
- type Registry
- type SenderReportSnapshot
- type Timeline
- func (t *Timeline) CaptureTime(rtpTimestamp uint32, now time.Time, clockRateHz uint32, maxAge time.Duration) (time.Time, bool)
- func (t *Timeline) NormalizeSenderReport(sr *rtcp.SenderReport, now time.Time, clockRateHz uint32) bool
- func (t *Timeline) Observe(sr *rtcp.SenderReport, observedAt time.Time)
- func (t *Timeline) ObserveCapture(rtpTimestamp uint32, captureTime, observedAt time.Time)
- func (t *Timeline) Snapshot() (SenderReportSnapshot, bool)
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.
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 ¶
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 ¶
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.