mediamtx/internal/core/rtmp_source_test.go

60 lines
1.3 KiB
Go
Raw Normal View History

package core
2021-03-19 22:04:30 +00:00
import (
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestRTMPSource(t *testing.T) {
2021-03-19 22:04:30 +00:00
for _, source := range []string{
"videoaudio",
"video",
} {
t.Run(source, func(t *testing.T) {
switch source {
case "videoaudio", "video":
cnt1, err := newContainer("nginx-rtmp", "rtmpserver", []string{})
require.NoError(t, err)
defer cnt1.close()
cnt2, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
2021-03-22 18:51:25 +00:00
"-i", "empty" + source + ".mkv",
2021-03-19 22:04:30 +00:00
"-c", "copy",
"-f", "flv",
"rtmp://" + cnt1.ip() + "/stream/test",
})
require.NoError(t, err)
defer cnt2.close()
time.Sleep(1 * time.Second)
p, ok := newInstance("hlsDisable: yes\n" +
"rtmpDisable: yes\n" +
2021-04-11 17:05:08 +00:00
"paths:\n" +
2021-03-19 22:04:30 +00:00
" proxied:\n" +
" source: rtmp://localhost/stream/test\n" +
2021-03-19 22:04:30 +00:00
" sourceOnDemand: yes\n")
require.Equal(t, true, ok)
defer p.close()
}
time.Sleep(1 * time.Second)
cnt3, err := newContainer("ffmpeg", "dest", []string{
"-rtsp_transport", "udp",
"-i", "rtsp://localhost:8554/proxied",
2021-03-19 22:04:30 +00:00
"-vframes", "1",
"-f", "image2",
"-y", "/dev/null",
})
require.NoError(t, err)
defer cnt3.close()
require.Equal(t, 0, cnt3.wait())
})
}
}