revid: cleaned up code structure in mtsSender_test.go

This commit is contained in:
Saxon 2019-03-01 15:28:40 +10:30
parent ef5e43dac7
commit 8452d8f3d1
1 changed files with 6 additions and 10 deletions

View File

@ -116,11 +116,10 @@ func TestSegment(t *testing.T) {
mts.Meta = meta.New()
// Create ringBuffer, sender, loadsender and the MPEGTS encoder.
rb := ring.NewBuffer(rbSize, rbElementSize, wTimeout)
tstSender := &sender{}
loadSender := newMtsSender(tstSender, log)
packer := &tstPacker{rb: rb}
encoder := mts.NewEncoder(packer, 25)
rb := ring.NewBuffer(rbSize, rbElementSize, wTimeout)
encoder := mts.NewEncoder(&tstPacker{rb: rb}, 25)
// Turn time based PSI writing off for encoder.
const psiSendCount = 10
@ -174,10 +173,8 @@ func TestSegment(t *testing.T) {
// Check that the clip data is okay.
for i := 0; i < len(clip); i += mts.PacketSize {
firstPkt := clip[i : i+mts.PacketSize]
copy(pkt[:], firstPkt)
pid := pkt.PID()
if pid == mts.VideoPid {
copy(pkt[:], clip[i:i+mts.PacketSize])
if pkt.PID() == mts.VideoPid {
payload, err := pkt.Payload()
if err != nil {
t.Fatalf("Unexpected err: %v\n", err)
@ -206,12 +203,11 @@ func TestSendFailDiscontinuity(t *testing.T) {
mts.Meta = meta.New()
// Create ringBuffer sender, loadSender and the MPEGTS encoder.
rb := ring.NewBuffer(rbSize, rbElementSize, wTimeout)
const clipWithDiscontinuity = 3
tstSender := &sender{testDiscontinuities: true, discontinuityAt: clipWithDiscontinuity}
loadSender := newMtsSender(tstSender, log)
packer := tstPacker{rb: rb}
encoder := mts.NewEncoder(&packer, 25)
rb := ring.NewBuffer(rbSize, rbElementSize, wTimeout)
encoder := mts.NewEncoder(&tstPacker{rb: rb}, 25)
// Turn time based PSI writing off for encoder.
const psiSendCount = 10