mirror of https://bitbucket.org/ausocean/av.git
stream/mts: fixed commenting in discontinuity.go
This commit is contained in:
parent
3aa94887eb
commit
4044368837
|
@ -37,16 +37,20 @@ type DiscontinuityRepairer struct {
|
||||||
expCC uint8
|
expCC uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDiscontinuityRepairer returns a pointer to a new discontinuityRepairer
|
// NewDiscontinuityRepairer returns a pointer to a new discontinuityRepairer.
|
||||||
func NewDiscontinuityRepairer() *DiscontinuityRepairer {
|
func NewDiscontinuityRepairer() *DiscontinuityRepairer {
|
||||||
return &DiscontinuityRepairer{expCC: 16}
|
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() {
|
func (dr *DiscontinuityRepairer) Failed() {
|
||||||
dr.decExpectedCC()
|
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 {
|
func (dr *DiscontinuityRepairer) Repair(d []byte) error {
|
||||||
var pkt [PacketSize]byte
|
var pkt [PacketSize]byte
|
||||||
copy(pkt[:], d[:PacketSize])
|
copy(pkt[:], d[:PacketSize])
|
||||||
|
@ -74,8 +78,8 @@ func (dr *DiscontinuityRepairer) Repair(d []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// expectedCC returns the expected cc for the given pid. If the cc hasn't been
|
// expectedCC returns the expected cc. If the cc hasn't been used yet, then 16
|
||||||
// used yet, then 16 and false is returned.
|
// and false is returned.
|
||||||
func (dr *DiscontinuityRepairer) expectedCC() (byte, bool) {
|
func (dr *DiscontinuityRepairer) expectedCC() (byte, bool) {
|
||||||
if dr.expCC == 16 {
|
if dr.expCC == 16 {
|
||||||
return 16, false
|
return 16, false
|
||||||
|
@ -83,17 +87,17 @@ func (dr *DiscontinuityRepairer) expectedCC() (byte, bool) {
|
||||||
return dr.expCC, true
|
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() {
|
func (dr *DiscontinuityRepairer) incExpectedCC() {
|
||||||
dr.expCC = (dr.expCC + 1) & 0xf
|
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() {
|
func (dr *DiscontinuityRepairer) decExpectedCC() {
|
||||||
dr.expCC = (dr.expCC - 1) & 0xf
|
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) {
|
func (dr *DiscontinuityRepairer) setExpectedCC(cc uint8) {
|
||||||
dr.expCC = cc
|
dr.expCC = cc
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue