mirror of https://bitbucket.org/ausocean/av.git
improved container/mts/encoder.go error wrapping and checking errors from encoder write in revid/senders_test.go
This commit is contained in:
parent
7a397ff96f
commit
e894abe339
|
@ -191,7 +191,7 @@ func (e *Encoder) Write(data []byte) (int, error) {
|
|||
e.pktCount = 0
|
||||
err := e.writePSI()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return 0, fmt.Errorf("could not write psi (psiMethodPacket): %w",err)
|
||||
}
|
||||
}
|
||||
case psiMethodNAL:
|
||||
|
@ -203,7 +203,7 @@ func (e *Encoder) Write(data []byte) (int, error) {
|
|||
if nalType == h264dec.NALTypeSPS {
|
||||
err := e.writePSI()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return 0, fmt.Errorf("could not write psi (psiMethodNAL): %w",err)
|
||||
}
|
||||
}
|
||||
case psiMethodTime:
|
||||
|
@ -214,7 +214,7 @@ func (e *Encoder) Write(data []byte) (int, error) {
|
|||
e.startTime = time.Now()
|
||||
err := e.writePSI()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return 0, fmt.Errorf("could not write psi (psiMethodTime): %w",err)
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
@ -259,7 +259,7 @@ func (e *Encoder) Write(data []byte) (int, error) {
|
|||
e.log.Debug("writing MTS packet to destination", "size", len(b), "pusi", pusi, "PID", pkt.PID, "PTS", pts, "PCR", pkt.PCR)
|
||||
_, err := e.dst.Write(b)
|
||||
if err != nil {
|
||||
return len(data), err
|
||||
return len(data), fmt.Errorf("could not write MTS packet to destination: %w",err)
|
||||
}
|
||||
e.pktCount++
|
||||
}
|
||||
|
@ -282,14 +282,13 @@ func (e *Encoder) writePSI() error {
|
|||
}
|
||||
_, err := e.dst.Write(patPkt.Bytes(e.tsSpace[:PacketSize]))
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("could not write pat packet: %w",err)
|
||||
}
|
||||
e.pktCount++
|
||||
|
||||
e.pmtBytes, err = updateMeta(e.pmtBytes, e.log)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("could not update pmt metadata: %w",err)
|
||||
}
|
||||
|
||||
// Create mts packet from pmt table.
|
||||
|
@ -302,7 +301,7 @@ func (e *Encoder) writePSI() error {
|
|||
}
|
||||
_, err = e.dst.Write(pmtPkt.Bytes(e.tsSpace[:PacketSize]))
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("could not write pmt packet: %w",err)
|
||||
}
|
||||
e.pktCount++
|
||||
|
||||
|
|
|
@ -201,7 +201,10 @@ func TestMtsSenderFailedSend(t *testing.T) {
|
|||
t.Log("writing packets")
|
||||
const noOfPacketsToWrite = 100
|
||||
for i := 0; i < noOfPacketsToWrite; i++ {
|
||||
encoder.Write([]byte{byte(i)})
|
||||
_, err := encoder.Write([]byte{byte(i)})
|
||||
if err != nil {
|
||||
t.Errorf("did not expect error from encoder write: %v",err)
|
||||
}
|
||||
}
|
||||
|
||||
// Wait until the destination has all the data, then close the sender.
|
||||
|
@ -281,7 +284,10 @@ func TestMtsSenderDiscontinuity(t *testing.T) {
|
|||
// Payload will just be packet number.
|
||||
const noOfPacketsToWrite = 100
|
||||
for i := 0; i < noOfPacketsToWrite; i++ {
|
||||
encoder.Write([]byte{byte(i)})
|
||||
_, err := encoder.Write([]byte{byte(i)})
|
||||
if err != nil {
|
||||
t.Errorf("did not expect error from encoder write: %v",err)
|
||||
}
|
||||
}
|
||||
|
||||
// Wait until the destination has all the data, then close the sender.
|
||||
|
|
Loading…
Reference in New Issue