From ca0a008c597580ddbaedb0f8d36e75920cc7fd2e Mon Sep 17 00:00:00 2001 From: saxon Date: Sun, 17 Feb 2019 12:50:33 +1030 Subject: [PATCH] revid: correct cc logic is discontinuity.go --- revid/mtsSender_test.go | 2 -- stream/mts/discontinuity.go | 12 ++++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/revid/mtsSender_test.go b/revid/mtsSender_test.go index 094d1844..de1b3ef4 100644 --- a/revid/mtsSender_test.go +++ b/revid/mtsSender_test.go @@ -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() } } diff --git a/stream/mts/discontinuity.go b/stream/mts/discontinuity.go index b7cc3bed..34624554 100644 --- a/stream/mts/discontinuity.go +++ b/stream/mts/discontinuity.go @@ -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 }