diff --git a/Makefile b/Makefile index 2e9a9ee8764..42e69cf5a7f 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ format: define DOCKERFILE_TEST FROM amd64/$(BASE_IMAGE) -RUN apk add --no-cache make docker-cli git +RUN apk add --no-cache make docker-cli git ffmpeg WORKDIR /s COPY go.mod go.sum ./ RUN go mod download diff --git a/main_test.go b/main_test.go index ed4de1724ef..cb8fff9deb3 100644 --- a/main_test.go +++ b/main_test.go @@ -352,7 +352,8 @@ func TestProxy(t *testing.T) { "paths:\n" + " proxied:\n" + " source: rtsp://testuser:testpass@localhost:8554/teststream\n" + - " sourceProtocol: " + proto + "\n") + " sourceProtocol: " + proto + "\n" + + " sourceOnDemand: yes\n") p2, err := newProgram([]string{"stdin"}, bytes.NewBuffer(stdin)) require.NoError(t, err) defer p2.close() @@ -374,3 +375,27 @@ func TestProxy(t *testing.T) { }) } } + +func TestRunOnDemand(t *testing.T) { + stdin := []byte("\n" + + "paths:\n" + + " ondemand:\n" + + " runOnDemand: ffmpeg -hide_banner -loglevel error -re -i test-images/ffmpeg/emptyvideo.ts -c copy -f rtsp rtsp://localhost:8554/ondemand\n") + p1, err := newProgram([]string{"stdin"}, bytes.NewBuffer(stdin)) + require.NoError(t, err) + defer p1.close() + + time.Sleep(1 * time.Second) + + cnt1, err := newContainer("ffmpeg", "dest", []string{ + "-i", "rtsp://" + ownDockerIp + ":8554/ondemand", + "-vframes", "1", + "-f", "image2", + "-y", "/dev/null", + }) + require.NoError(t, err) + defer cnt1.close() + + code := cnt1.wait() + require.Equal(t, 0, code) +}