diff --git a/revid/revid.go b/revid/revid.go index e44f6c19..eed58893 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -303,7 +303,7 @@ func output(output string) { now := time.Now() prevTime := now for { - if clip, clipSize, _ := ringBuffer.Read(); clip != nil { + if clip, clipSize, err := ringBuffer.Read(); err == nil { now := time.Now() err := sendClip(clip[:clipSize], output, conn) for err != nil { @@ -338,10 +338,6 @@ func sendClipToFile(clip []byte, _ string, _ net.Conn) error { // sendClipToHTPP posts a video clip via HTTP, using a new TCP connection each time. func sendClipToHTTP(clip []byte, output string, _ net.Conn) error { - if err := checkContinuityCounts(clip); err != nil { - return err - } - timeout := time.Duration(httpTimeOut * time.Second) client := http.Client{ Timeout: timeout, @@ -397,13 +393,12 @@ func sendClipToRTP(clip []byte, _ string, conn net.Conn) error { return nil } +// checkContinuityCounts checks that the continuity of the clip is correct func checkContinuityCounts(clip []byte) error { for offset := 0; offset < len(clip); offset += mp2tPacketSize { dumpCC = -1 pkt := clip[offset : offset+mp2tPacketSize] - cc := int(pkt[3] & 0xf) - if dumpCC != -1 && cc != dumpCC { return fmt.Errorf("Continuity count out of order. Expected %v, Got: %v.", dumpCC, cc) }