mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-24 16:20:23 +08:00
rtmp: add new AMF0 encoder and encoder (#3069)
This improves performance, security and removes a dependency.
This commit is contained in:
@@ -6,9 +6,9 @@ import (
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/notedit/rtmp/format/flv/flvio"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/bluenviron/mediamtx/internal/protocols/rtmp/amf0"
|
||||
"github.com/bluenviron/mediamtx/internal/protocols/rtmp/bytecounter"
|
||||
"github.com/bluenviron/mediamtx/internal/protocols/rtmp/handshake"
|
||||
"github.com/bluenviron/mediamtx/internal/protocols/rtmp/message"
|
||||
@@ -64,15 +64,15 @@ func TestNewClientConn(t *testing.T) {
|
||||
Name: "connect",
|
||||
CommandID: 1,
|
||||
Arguments: []interface{}{
|
||||
flvio.AMFMap{
|
||||
{K: "app", V: "stream"},
|
||||
{K: "flashVer", V: "LNX 9,0,124,2"},
|
||||
{K: "tcUrl", V: "rtmp://127.0.0.1:9121/stream"},
|
||||
{K: "fpad", V: false},
|
||||
{K: "capabilities", V: float64(15)},
|
||||
{K: "audioCodecs", V: float64(4071)},
|
||||
{K: "videoCodecs", V: float64(252)},
|
||||
{K: "videoFunction", V: float64(1)},
|
||||
amf0.Object{
|
||||
{Key: "app", Value: "stream"},
|
||||
{Key: "flashVer", Value: "LNX 9,0,124,2"},
|
||||
{Key: "tcUrl", Value: "rtmp://127.0.0.1:9121/stream"},
|
||||
{Key: "fpad", Value: false},
|
||||
{Key: "capabilities", Value: float64(15)},
|
||||
{Key: "audioCodecs", Value: float64(4071)},
|
||||
{Key: "videoCodecs", Value: float64(252)},
|
||||
{Key: "videoFunction", Value: float64(1)},
|
||||
},
|
||||
},
|
||||
}, msg)
|
||||
@@ -82,15 +82,15 @@ func TestNewClientConn(t *testing.T) {
|
||||
Name: "_result",
|
||||
CommandID: 1,
|
||||
Arguments: []interface{}{
|
||||
flvio.AMFMap{
|
||||
{K: "fmsVer", V: "LNX 9,0,124,2"},
|
||||
{K: "capabilities", V: float64(31)},
|
||||
amf0.Object{
|
||||
{Key: "fmsVer", Value: "LNX 9,0,124,2"},
|
||||
{Key: "capabilities", Value: float64(31)},
|
||||
},
|
||||
flvio.AMFMap{
|
||||
{K: "level", V: "status"},
|
||||
{K: "code", V: "NetConnection.Connect.Success"},
|
||||
{K: "description", V: "Connection succeeded."},
|
||||
{K: "objectEncoding", V: float64(0)},
|
||||
amf0.Object{
|
||||
{Key: "level", Value: "status"},
|
||||
{Key: "code", Value: "NetConnection.Connect.Success"},
|
||||
{Key: "description", Value: "Connection succeeded."},
|
||||
{Key: "objectEncoding", Value: float64(0)},
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -151,10 +151,10 @@ func TestNewClientConn(t *testing.T) {
|
||||
}(),
|
||||
Arguments: []interface{}{
|
||||
nil,
|
||||
flvio.AMFMap{
|
||||
{K: "level", V: "status"},
|
||||
{K: "code", V: "NetStream.Play.Reset"},
|
||||
{K: "description", V: "play reset"},
|
||||
amf0.Object{
|
||||
{Key: "level", Value: "status"},
|
||||
{Key: "code", Value: "NetStream.Play.Reset"},
|
||||
{Key: "description", Value: "play reset"},
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -228,10 +228,10 @@ func TestNewClientConn(t *testing.T) {
|
||||
CommandID: 5,
|
||||
Arguments: []interface{}{
|
||||
nil,
|
||||
flvio.AMFMap{
|
||||
{K: "level", V: "status"},
|
||||
{K: "code", V: "NetStream.Publish.Start"},
|
||||
{K: "description", V: "publish start"},
|
||||
amf0.Object{
|
||||
{Key: "level", Value: "status"},
|
||||
{Key: "code", Value: "NetStream.Publish.Start"},
|
||||
{Key: "description", Value: "publish start"},
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -317,15 +317,15 @@ func TestNewServerConn(t *testing.T) {
|
||||
Name: "connect",
|
||||
CommandID: 1,
|
||||
Arguments: []interface{}{
|
||||
flvio.AMFMap{
|
||||
{K: "app", V: "/stream"},
|
||||
{K: "flashVer", V: "LNX 9,0,124,2"},
|
||||
{K: "tcUrl", V: tcURL},
|
||||
{K: "fpad", V: false},
|
||||
{K: "capabilities", V: 15},
|
||||
{K: "audioCodecs", V: 4071},
|
||||
{K: "videoCodecs", V: 252},
|
||||
{K: "videoFunction", V: 1},
|
||||
amf0.Object{
|
||||
{Key: "app", Value: "/stream"},
|
||||
{Key: "flashVer", Value: "LNX 9,0,124,2"},
|
||||
{Key: "tcUrl", Value: tcURL},
|
||||
{Key: "fpad", Value: false},
|
||||
{Key: "capabilities", Value: float64(15)},
|
||||
{Key: "audioCodecs", Value: float64(4071)},
|
||||
{Key: "videoCodecs", Value: float64(252)},
|
||||
{Key: "videoFunction", Value: float64(1)},
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -357,15 +357,15 @@ func TestNewServerConn(t *testing.T) {
|
||||
Name: "_result",
|
||||
CommandID: 1,
|
||||
Arguments: []interface{}{
|
||||
flvio.AMFMap{
|
||||
{K: "fmsVer", V: "LNX 9,0,124,2"},
|
||||
{K: "capabilities", V: float64(31)},
|
||||
amf0.Object{
|
||||
{Key: "fmsVer", Value: "LNX 9,0,124,2"},
|
||||
{Key: "capabilities", Value: float64(31)},
|
||||
},
|
||||
flvio.AMFMap{
|
||||
{K: "level", V: "status"},
|
||||
{K: "code", V: "NetConnection.Connect.Success"},
|
||||
{K: "description", V: "Connection succeeded."},
|
||||
{K: "objectEncoding", V: float64(0)},
|
||||
amf0.Object{
|
||||
{Key: "level", Value: "status"},
|
||||
{Key: "code", Value: "NetConnection.Connect.Success"},
|
||||
{Key: "description", Value: "Connection succeeded."},
|
||||
{Key: "objectEncoding", Value: float64(0)},
|
||||
},
|
||||
},
|
||||
}, msg)
|
||||
|
||||
Reference in New Issue
Block a user