rtmp server: fix compatibility with Neko (#1405)

This commit is contained in:
Alessandro Ros
2023-01-22 13:36:36 +01:00
committed by GitHub
parent 97c1e68c0b
commit ef214b7649
2 changed files with 16 additions and 5 deletions

View File

@@ -84,13 +84,13 @@ func getTcURL(u *url.URL) string {
return nu.String() + app return nu.String() + app
} }
func createURL(tcurl, app, play string) (*url.URL, error) { func createURL(tcURL string, app string, play string) (*url.URL, error) {
u, err := url.ParseRequestURI("/" + app + "/" + play) u, err := url.ParseRequestURI("/" + app + "/" + play)
if err != nil { if err != nil {
return nil, err return nil, err
} }
tu, err := url.Parse(tcurl) tu, err := url.Parse(tcURL)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -365,6 +365,8 @@ func (c *Conn) InitializeServer() (*url.URL, bool, error) {
} }
} }
tcURL = strings.Trim(tcURL, "'")
err = c.mrw.Write(&message.MsgSetWindowAckSize{ err = c.mrw.Write(&message.MsgSetWindowAckSize{
Value: 2500000, Value: 2500000,
}) })

View File

@@ -259,7 +259,11 @@ func TestInitializeClient(t *testing.T) {
} }
func TestInitializeServer(t *testing.T) { func TestInitializeServer(t *testing.T) {
for _, ca := range []string{"read", "publish"} { for _, ca := range []string{
"read",
"publish",
"publish neko",
} {
t.Run(ca, func(t *testing.T) { t.Run(ca, func(t *testing.T) {
ln, err := net.Listen("tcp", "127.0.0.1:9121") ln, err := net.Listen("tcp", "127.0.0.1:9121")
require.NoError(t, err) require.NoError(t, err)
@@ -280,7 +284,7 @@ func TestInitializeServer(t *testing.T) {
Host: "127.0.0.1:9121", Host: "127.0.0.1:9121",
Path: "//stream/", Path: "//stream/",
}, u) }, u)
require.Equal(t, ca == "publish", isPublishing) require.Equal(t, ca == "publish" || ca == "publish neko", isPublishing)
close(done) close(done)
}() }()
@@ -295,6 +299,11 @@ func TestInitializeServer(t *testing.T) {
mrw := message.NewReadWriter(bc, true) mrw := message.NewReadWriter(bc, true)
tcURL := "rtmp://127.0.0.1:9121/stream"
if ca == "publish neko" {
tcURL = "'rtmp://127.0.0.1:9121/stream"
}
err = mrw.Write(&message.MsgCommandAMF0{ err = mrw.Write(&message.MsgCommandAMF0{
ChunkStreamID: 3, ChunkStreamID: 3,
Name: "connect", Name: "connect",
@@ -303,7 +312,7 @@ func TestInitializeServer(t *testing.T) {
flvio.AMFMap{ flvio.AMFMap{
{K: "app", V: "/stream"}, {K: "app", V: "/stream"},
{K: "flashVer", V: "LNX 9,0,124,2"}, {K: "flashVer", V: "LNX 9,0,124,2"},
{K: "tcUrl", V: "rtmp://127.0.0.1:9121/stream"}, {K: "tcUrl", V: tcURL},
{K: "fpad", V: false}, {K: "fpad", V: false},
{K: "capabilities", V: 15}, {K: "capabilities", V: 15},
{K: "audioCodecs", V: 4071}, {K: "audioCodecs", V: 4071},