revid: correct cc logic is discontinuity.go

This commit is contained in:
saxon 2019-02-17 12:50:33 +10:30
parent 819c9a784c
commit ca0a008c59
2 changed files with 6 additions and 8 deletions

View File

@ -59,7 +59,6 @@ type testSender struct {
func (ts *testSender) send(d []byte) error {
if ts.tstDiscon && ts.curPktNo == ts.disconAt {
fmt.Println("SendFailed")
ts.curPktNo++
return errors.New("could not send")
}
@ -135,7 +134,6 @@ func TestSegment(t *testing.T) {
if err != nil {
t.Fatalf("Unexpected err: %v\n", err)
}
loadSender.release()
}
}

View File

@ -29,7 +29,9 @@ LICENSE
package mts
import "github.com/Comcast/gots/packet"
import (
"github.com/Comcast/gots/packet"
)
// discontinuityRepairer provides function to detect discontinuities in mpegts
// and set the discontinuity indicator as appropriate.
@ -66,11 +68,8 @@ func (dr *DiscontinuityRepairer) Repair(d []byte) error {
panic("Clip to repair must have PAT first")
}
cc := p.ContinuityCounter()
expect, exists := dr.ExpectedCC(pid)
dr.IncExpectedCC(pid)
if !exists {
dr.SetExpectedCC(pid, cc)
} else if cc != int(expect) {
expect, _ := dr.ExpectedCC(pid)
if cc != int(expect) {
if packet.ContainsAdaptationField(p) {
(*packet.AdaptationField)(p).SetDiscontinuity(true)
} else {
@ -82,6 +81,7 @@ func (dr *DiscontinuityRepairer) Repair(d []byte) error {
dr.SetExpectedCC(pid, cc)
copy(d[:PacketSize], pkt[:])
}
dr.IncExpectedCC(pid)
return nil
}