mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 15:16:51 +08:00
add server test with gstreamer
This commit is contained in:
@@ -74,7 +74,7 @@ func TestClientDialRead(t *testing.T) {
|
|||||||
cnt2, err := newContainer("ffmpeg", "publish", []string{
|
cnt2, err := newContainer("ffmpeg", "publish", []string{
|
||||||
"-re",
|
"-re",
|
||||||
"-stream_loop", "-1",
|
"-stream_loop", "-1",
|
||||||
"-i", "/emptyvideo.ts",
|
"-i", "emptyvideo.ts",
|
||||||
"-c", "copy",
|
"-c", "copy",
|
||||||
"-f", "rtsp",
|
"-f", "rtsp",
|
||||||
"-rtsp_transport", "udp",
|
"-rtsp_transport", "udp",
|
||||||
@@ -131,7 +131,7 @@ func TestClientDialReadAutomaticProtocol(t *testing.T) {
|
|||||||
cnt2, err := newContainer("ffmpeg", "publish", []string{
|
cnt2, err := newContainer("ffmpeg", "publish", []string{
|
||||||
"-re",
|
"-re",
|
||||||
"-stream_loop", "-1",
|
"-stream_loop", "-1",
|
||||||
"-i", "/emptyvideo.ts",
|
"-i", "emptyvideo.ts",
|
||||||
"-c", "copy",
|
"-c", "copy",
|
||||||
"-f", "rtsp",
|
"-f", "rtsp",
|
||||||
"-rtsp_transport", "tcp",
|
"-rtsp_transport", "tcp",
|
||||||
@@ -176,7 +176,7 @@ func TestClientDialReadRedirect(t *testing.T) {
|
|||||||
cnt2, err := newContainer("ffmpeg", "publish", []string{
|
cnt2, err := newContainer("ffmpeg", "publish", []string{
|
||||||
"-re",
|
"-re",
|
||||||
"-stream_loop", "-1",
|
"-stream_loop", "-1",
|
||||||
"-i", "/emptyvideo.ts",
|
"-i", "emptyvideo.ts",
|
||||||
"-c", "copy",
|
"-c", "copy",
|
||||||
"-f", "rtsp",
|
"-f", "rtsp",
|
||||||
"-rtsp_transport", "udp",
|
"-rtsp_transport", "udp",
|
||||||
@@ -218,7 +218,7 @@ func TestClientDialReadPause(t *testing.T) {
|
|||||||
cnt2, err := newContainer("ffmpeg", "publish", []string{
|
cnt2, err := newContainer("ffmpeg", "publish", []string{
|
||||||
"-re",
|
"-re",
|
||||||
"-stream_loop", "-1",
|
"-stream_loop", "-1",
|
||||||
"-i", "/emptyvideo.ts",
|
"-i", "emptyvideo.ts",
|
||||||
"-c", "copy",
|
"-c", "copy",
|
||||||
"-f", "rtsp",
|
"-f", "rtsp",
|
||||||
"-rtsp_transport", "udp",
|
"-rtsp_transport", "udp",
|
||||||
|
@@ -14,7 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// This example shows how to
|
// This example shows how to
|
||||||
// 1. create a RTSP server which accept only connections encrypted with TLS (RTSPS)
|
// 1. create a RTSP server which accepts only connections encrypted with TLS (RTSPS)
|
||||||
// 2. allow a single client to publish a stream with TCP
|
// 2. allow a single client to publish a stream with TCP
|
||||||
// 3. allow multiple clients to read that stream with TCP
|
// 3. allow multiple clients to read that stream with TCP
|
||||||
|
|
||||||
|
@@ -272,10 +272,13 @@ y++U32uuSFiXDcSLarfIsE992MEJLSAynbF1Rsgsr3gXbGiuToJRyxbIeVy7gwzD
|
|||||||
func TestServerPublishReadTCP(t *testing.T) {
|
func TestServerPublishReadTCP(t *testing.T) {
|
||||||
for _, ca := range []struct {
|
for _, ca := range []struct {
|
||||||
publisher string
|
publisher string
|
||||||
|
reader string
|
||||||
encrypted bool
|
encrypted bool
|
||||||
}{
|
}{
|
||||||
{"ffmpeg", false},
|
{"ffmpeg", "ffmpeg", false},
|
||||||
{"ffmpeg", true},
|
{"ffmpeg", "ffmpeg", true},
|
||||||
|
{"gstreamer", "ffmpeg", false},
|
||||||
|
{"gstreamer", "ffmpeg", true},
|
||||||
} {
|
} {
|
||||||
encryptedStr := func() string {
|
encryptedStr := func() string {
|
||||||
if ca.encrypted {
|
if ca.encrypted {
|
||||||
@@ -284,7 +287,7 @@ func TestServerPublishReadTCP(t *testing.T) {
|
|||||||
return "plain"
|
return "plain"
|
||||||
}()
|
}()
|
||||||
|
|
||||||
t.Run(ca.publisher+"_"+encryptedStr, func(t *testing.T) {
|
t.Run(ca.publisher+"_"+ca.reader+"_"+encryptedStr, func(t *testing.T) {
|
||||||
var proto string
|
var proto string
|
||||||
var tlsConf *tls.Config
|
var tlsConf *tls.Config
|
||||||
if !ca.encrypted {
|
if !ca.encrypted {
|
||||||
@@ -302,10 +305,12 @@ func TestServerPublishReadTCP(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer ts.close()
|
defer ts.close()
|
||||||
|
|
||||||
|
switch ca.publisher {
|
||||||
|
case "ffmpeg":
|
||||||
cnt1, err := newContainer("ffmpeg", "publish", []string{
|
cnt1, err := newContainer("ffmpeg", "publish", []string{
|
||||||
"-re",
|
"-re",
|
||||||
"-stream_loop", "-1",
|
"-stream_loop", "-1",
|
||||||
"-i", "/emptyvideo.ts",
|
"-i", "emptyvideo.ts",
|
||||||
"-c", "copy",
|
"-c", "copy",
|
||||||
"-f", "rtsp",
|
"-f", "rtsp",
|
||||||
"-rtsp_transport", "tcp",
|
"-rtsp_transport", "tcp",
|
||||||
@@ -314,8 +319,19 @@ func TestServerPublishReadTCP(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer cnt1.close()
|
defer cnt1.close()
|
||||||
|
|
||||||
|
case "gstreamer":
|
||||||
|
cnt1, err := newContainer("gstreamer", "publish", []string{
|
||||||
|
"filesrc location=emptyvideo.ts ! tsdemux ! queue ! video/x-h264 ! h264parse config-interval=1 ! rtspclientsink " +
|
||||||
|
"location=" + proto + "://127.0.0.1:8554/teststream protocols=tcp tls-validation-flags=0 latency=0 timeout=0 rtx-time=0",
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
defer cnt1.close()
|
||||||
|
}
|
||||||
|
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
|
switch ca.reader {
|
||||||
|
case "ffmpeg":
|
||||||
cnt2, err := newContainer("ffmpeg", "read", []string{
|
cnt2, err := newContainer("ffmpeg", "read", []string{
|
||||||
"-rtsp_transport", "tcp",
|
"-rtsp_transport", "tcp",
|
||||||
"-i", proto + "://localhost:8554/teststream",
|
"-i", proto + "://localhost:8554/teststream",
|
||||||
@@ -325,8 +341,8 @@ func TestServerPublishReadTCP(t *testing.T) {
|
|||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer cnt2.close()
|
defer cnt2.close()
|
||||||
|
|
||||||
require.Equal(t, 0, cnt2.wait())
|
require.Equal(t, 0, cnt2.wait())
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user