fix probers test

This commit is contained in:
Leandro Moreira
2024-05-19 17:51:12 -03:00
parent fc39c17960
commit 644ad80756
3 changed files with 19 additions and 25 deletions
+10 -13
View File
@@ -1,7 +1,6 @@
package probers_test
import (
"fmt"
"testing"
"github.com/flavioribeiro/donut/internal/controllers/probers"
@@ -43,16 +42,15 @@ func TestSrtMpegTs_StreamInfo_264(t *testing.T) {
ffmpeg.Start()
req := &entities.RequestParams{
SRTHost: ffmpeg.Output().Host,
SRTPort: uint16(ffmpeg.Output().Port),
SRTStreamID: "test_id",
StreamURL: ffmpeg.Output().StreamURL,
StreamID: ffmpeg.Output().StreamID,
}
input := entities.DonutAppetizer{
URL: fmt.Sprintf("srt://%s:%d", ffmpeg.Output().Host, uint16(ffmpeg.Output().Port)),
Format: "mpegts", // it'll change based on input, i.e. rmtp flv
URL: ffmpeg.Output().StreamURL,
Format: "mpegts",
Options: map[entities.DonutInputOptionKey]string{
entities.DonutSRTStreamID: "test_id",
entities.DonutSRTStreamID: ffmpeg.Output().StreamID,
entities.DonutSRTTranstype: "live",
entities.DonutSRTsmoother: "live",
},
@@ -75,16 +73,15 @@ func TestSrtMpegTs_StreamInfo_265(t *testing.T) {
ffmpeg.Start()
req := &entities.RequestParams{
SRTHost: ffmpeg.Output().Host,
SRTPort: uint16(ffmpeg.Output().Port),
SRTStreamID: "test_id",
StreamURL: ffmpeg.Output().StreamURL,
StreamID: ffmpeg.Output().StreamID,
}
input := entities.DonutAppetizer{
URL: fmt.Sprintf("srt://%s:%d", ffmpeg.Output().Host, uint16(ffmpeg.Output().Port)),
Format: "mpegts", // it'll change based on input, i.e. rmtp flv
URL: ffmpeg.Output().StreamURL,
Format: "mpegts",
Options: map[entities.DonutInputOptionKey]string{
entities.DonutSRTStreamID: "test_id",
entities.DonutSRTStreamID: ffmpeg.Output().StreamID,
entities.DonutSRTTranstype: "live",
entities.DonutSRTsmoother: "live",
},
+3 -7
View File
@@ -17,18 +17,14 @@ type FFmpeg interface {
Start() error
Stop() error
ExpectedStreams() []entities.Stream
Output() FFmpegOutput
}
type FFmpegOutput struct {
Host string
Port int
Output() entities.RequestParams
}
type testFFmpeg struct {
arguments string
expectedStreams []entities.Stream
cmdExec *exec.Cmd
output FFmpegOutput
output entities.RequestParams
}
func (t *testFFmpeg) Start() error {
@@ -66,7 +62,7 @@ func (t *testFFmpeg) ExpectedStreams() []entities.Stream {
return t.expectedStreams
}
func (t *testFFmpeg) Output() FFmpegOutput {
func (t *testFFmpeg) Output() entities.RequestParams {
return t.output
}
+6 -5
View File
@@ -1,6 +1,7 @@
package teststreaming
import (
"fmt"
"strconv"
"github.com/flavioribeiro/donut/internal/entities"
@@ -18,19 +19,19 @@ var ffmpeg_input = `
`
// OUTPUT PORTS: the output port must be different for each ffmpeg case so it might run in parallel
var output_port = 45678
var outputPort = 45678
var FFMPEG_LIVE_SRT_MPEG_TS_H264_AAC = testFFmpeg{
arguments: ffmpeg_input + `
-c:v libx264 -preset veryfast -tune zerolatency -profile:v baseline
-b:v 500k -bufsize 1000k -x264opts keyint=30:min-keyint=30:scenecut=-1
-c:a aac -b:a 96k -f mpegts srt://0.0.0.0:` + strconv.Itoa(output_port+0) + `?mode=listener&smoother=live&transtype=live
-c:a aac -b:a 96k -f mpegts srt://0.0.0.0:` + strconv.Itoa(outputPort+0) + `?mode=listener&smoother=live&transtype=live
`,
expectedStreams: []entities.Stream{
{Index: 0, Id: uint16(256), Codec: entities.H264, Type: entities.VideoType},
{Index: 1, Id: uint16(257), Codec: entities.AAC, Type: entities.AudioType},
},
output: FFmpegOutput{Host: "127.0.0.1", Port: output_port + 0},
output: entities.RequestParams{StreamURL: fmt.Sprintf("srt://127.0.0.1:%d", outputPort+0), StreamID: "stream-id"},
}
// ref https://x265.readthedocs.io/en/stable/cli.html#executable-options
@@ -38,11 +39,11 @@ var FFMPEG_LIVE_SRT_MPEG_TS_H265_AAC = testFFmpeg{
arguments: ffmpeg_input + `
-c:v libx265 -preset veryfast -profile:v main
-b:v 500k -bufsize 1000k -x265-params keyint=30:min-keyint=30:scenecut=0
-c:a aac -b:a 96k -f mpegts srt://0.0.0.0:` + strconv.Itoa(output_port+1) + `?mode=listener&smoother=live&transtype=live
-c:a aac -b:a 96k -f mpegts srt://0.0.0.0:` + strconv.Itoa(outputPort+1) + `?mode=listener&smoother=live&transtype=live
`,
expectedStreams: []entities.Stream{
{Index: 0, Id: uint16(256), Codec: entities.H265, Type: entities.VideoType},
{Index: 1, Id: uint16(257), Codec: entities.AAC, Type: entities.AudioType},
},
output: FFmpegOutput{Host: "127.0.0.1", Port: output_port + 1},
output: entities.RequestParams{StreamURL: fmt.Sprintf("srt://127.0.0.1:%d", outputPort+1), StreamID: "stream-id"},
}