diff --git a/stream/mts/discontinuity.go b/stream/mts/discontinuity.go index 69378916..5187dcb8 100644 --- a/stream/mts/discontinuity.go +++ b/stream/mts/discontinuity.go @@ -37,16 +37,20 @@ type DiscontinuityRepairer struct { expCC uint8 } -// NewDiscontinuityRepairer returns a pointer to a new discontinuityRepairer +// NewDiscontinuityRepairer returns a pointer to a new discontinuityRepairer. func NewDiscontinuityRepairer() *DiscontinuityRepairer { return &DiscontinuityRepairer{expCC: 16} } +// Failed is to be called in the case of a failed send. This will decrement the +// expectedCC so that it aligns with the failed chunks cc. func (dr *DiscontinuityRepairer) Failed() { dr.decExpectedCC() } -// Repair takes a slice of mpegts +// Repair takes a clip of mpegts and checks that the first packet, which should +// be a PAT, contains a cc that is expected, otherwise the discontinuity indicator +// is set to true. func (dr *DiscontinuityRepairer) Repair(d []byte) error { var pkt [PacketSize]byte copy(pkt[:], d[:PacketSize]) @@ -74,8 +78,8 @@ func (dr *DiscontinuityRepairer) Repair(d []byte) error { return nil } -// expectedCC returns the expected cc for the given pid. If the cc hasn't been -// used yet, then 16 and false is returned. +// expectedCC returns the expected cc. If the cc hasn't been used yet, then 16 +// and false is returned. func (dr *DiscontinuityRepairer) expectedCC() (byte, bool) { if dr.expCC == 16 { return 16, false @@ -83,17 +87,17 @@ func (dr *DiscontinuityRepairer) expectedCC() (byte, bool) { return dr.expCC, true } -// incExpectedCC increments the expected cc in dr's cc map for the given pid. +// incExpectedCC increments the expected cc. func (dr *DiscontinuityRepairer) incExpectedCC() { dr.expCC = (dr.expCC + 1) & 0xf } -// decExpectedCC decrements the expected cc in dr's cc map for the given pid. +// decExpectedCC decrements the expected cc. func (dr *DiscontinuityRepairer) decExpectedCC() { dr.expCC = (dr.expCC - 1) & 0xf } -// setExpectedCC sets the expected cc in dr's cc map for the given pid, and cc. +// setExpectedCC sets the expected cc. func (dr *DiscontinuityRepairer) setExpectedCC(cc uint8) { dr.expCC = cc }