Skip to content

Commit

Permalink
make netcat flags depend on OS
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberj0g committed Apr 5, 2022
1 parent ef9c733 commit e1b7d5c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions segmenter/video_segmenter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"path"
"runtime"
"testing"

"time"
Expand Down Expand Up @@ -437,15 +438,19 @@ func (s *ServerDisconnectStream) ReadRTMPFromStream(ctx context.Context, dst av.

func TestServerDisconnect(t *testing.T) {
ffmpeg.InitFFmpeg()
port := "1938" // because we can't yet close the listener on 1935?
port := 1938 // because we can't yet close the listener on 1935?
strm := &ServerDisconnectStream{}
strmUrl := fmt.Sprintf("rtmp://localhost:%v/stream/%v", port, strm.GetStreamID())
opt := SegmenterOptions{SegLength: time.Second * 4}
vs := NewFFMpegVideoSegmenter("tmp", strm.GetStreamID(), strmUrl, opt)

ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
cmd := "dd if=/dev/urandom count=1 ibs=2000 | nc -l " + port
nopt := "N"
if runtime.GOOS == `darwin` {
// N is invalid on MacOS
nopt = ""
}
cmd := fmt.Sprintf("dd if=/dev/urandom count=1 ibs=2000 | nc -%sl %d", nopt, port)
go exec.CommandContext(ctx, "bash", "-c", cmd).Output()

err := RunRTMPToHLS(vs, ctx)
Expand Down

0 comments on commit e1b7d5c

Please sign in to comment.