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

View File

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