update gortsplib
This commit is contained in:
@@ -5,7 +5,7 @@ go 1.18
|
||||
require (
|
||||
code.cloudfoundry.org/bytefmt v0.0.0-20211005130812-5bb3c17173e5
|
||||
github.com/abema/go-mp4 v0.8.0
|
||||
github.com/aler9/gortsplib v0.0.0-20221110211534-12c8845fef0d
|
||||
github.com/aler9/gortsplib v0.0.0-20221115222755-87d5a512b129
|
||||
github.com/asticode/go-astits v1.10.1-0.20220319093903-4abe66a9b757
|
||||
github.com/fsnotify/fsnotify v1.4.9
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
|
||||
@@ -6,8 +6,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/aler9/gortsplib v0.0.0-20221110211534-12c8845fef0d h1:fRx79L1YMXaoiSMkB32xgVCUMbOcmQ4JfySaUv7XZpc=
|
||||
github.com/aler9/gortsplib v0.0.0-20221110211534-12c8845fef0d/go.mod h1:BOWNZ/QBkY/eVcRqUzJbPFEsRJshwxaxBT01K260Jeo=
|
||||
github.com/aler9/gortsplib v0.0.0-20221115222755-87d5a512b129 h1:CG96FPsxizdlpsRIsjU2xQR6G3QC0sPK+f+AeVEr0Tg=
|
||||
github.com/aler9/gortsplib v0.0.0-20221115222755-87d5a512b129/go.mod h1:BOWNZ/QBkY/eVcRqUzJbPFEsRJshwxaxBT01K260Jeo=
|
||||
github.com/aler9/writerseeker v0.0.0-20220601075008-6f0e685b9c82 h1:9WgSzBLo3a9ToSVV7sRTBYZ1GGOZUpq4+5H3SN0UZq4=
|
||||
github.com/aler9/writerseeker v0.0.0-20220601075008-6f0e685b9c82/go.mod h1:qsMrZCbeBf/mCLOeF16KDkPu4gktn/pOWyaq1aYQE7U=
|
||||
github.com/asticode/go-astikit v0.20.0 h1:+7N+J4E4lWx2QOkRdOf6DafWJMv6O4RRfgClwQokrH8=
|
||||
|
||||
+21
-15
@@ -193,9 +193,10 @@ func TestAPIPathsList(t *testing.T) {
|
||||
"rtsp://localhost:8554/mypath",
|
||||
gortsplib.Tracks{
|
||||
&gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
},
|
||||
&gortsplib.TrackMPEG4Audio{
|
||||
PayloadType: 96,
|
||||
@@ -218,7 +219,7 @@ func TestAPIPathsList(t *testing.T) {
|
||||
PayloadType: 96,
|
||||
},
|
||||
Payload: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
}, true)
|
||||
})
|
||||
|
||||
var out pathList
|
||||
err = httpRequest(http.MethodGet, "http://localhost:9997/v1/paths/list", nil, &out)
|
||||
@@ -257,9 +258,10 @@ func TestAPIPathsList(t *testing.T) {
|
||||
|
||||
tracks := gortsplib.Tracks{
|
||||
&gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
},
|
||||
&gortsplib.TrackMPEG4Audio{
|
||||
PayloadType: 97,
|
||||
@@ -413,9 +415,10 @@ func TestAPIProtocolSpecificList(t *testing.T) {
|
||||
defer p.Close()
|
||||
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
switch ca {
|
||||
@@ -468,7 +471,8 @@ func TestAPIProtocolSpecificList(t *testing.T) {
|
||||
0x27, 0xe5, 0x84, 0x00, 0x00, 0x03, 0x00, 0x04,
|
||||
0x00, 0x00, 0x03, 0x00, 0xf0, 0x3c, 0x60, 0xc9, 0x20,
|
||||
},
|
||||
PPS: []byte{0x08, 0x06, 0x07, 0x08},
|
||||
PPS: []byte{0x08, 0x06, 0x07, 0x08},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
err = conn.WriteTracks(videoTrack, nil)
|
||||
@@ -585,9 +589,10 @@ func TestAPIKick(t *testing.T) {
|
||||
defer p.Close()
|
||||
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
switch ca {
|
||||
@@ -628,7 +633,8 @@ func TestAPIKick(t *testing.T) {
|
||||
0x27, 0xe5, 0x84, 0x00, 0x00, 0x03, 0x00, 0x04,
|
||||
0x00, 0x00, 0x03, 0x00, 0xf0, 0x3c, 0x60, 0xc9, 0x20,
|
||||
},
|
||||
PPS: []byte{0x08, 0x06, 0x07, 0x08},
|
||||
PPS: []byte{0x08, 0x06, 0x07, 0x08},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
err = conn.WriteTracks(videoTrack, nil)
|
||||
|
||||
@@ -194,6 +194,7 @@ func main() {
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
source := gortsplib.Client{}
|
||||
@@ -321,9 +322,10 @@ func TestCorePathRunOnReady(t *testing.T) {
|
||||
defer p.Close()
|
||||
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
c := gortsplib.Client{}
|
||||
@@ -357,9 +359,10 @@ func TestCoreHotReloading(t *testing.T) {
|
||||
|
||||
func() {
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
c := gortsplib.Client{}
|
||||
@@ -379,9 +382,10 @@ func TestCoreHotReloading(t *testing.T) {
|
||||
|
||||
func() {
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
conn := gortsplib.Client{}
|
||||
|
||||
+6
-21
@@ -10,13 +10,11 @@ import (
|
||||
type data interface {
|
||||
getTrackID() int
|
||||
getRTPPackets() []*rtp.Packet
|
||||
getPTSEqualsDTS() bool
|
||||
}
|
||||
|
||||
type dataGeneric struct {
|
||||
trackID int
|
||||
rtpPackets []*rtp.Packet
|
||||
ptsEqualsDTS bool
|
||||
trackID int
|
||||
rtpPackets []*rtp.Packet
|
||||
}
|
||||
|
||||
func (d *dataGeneric) getTrackID() int {
|
||||
@@ -27,16 +25,11 @@ func (d *dataGeneric) getRTPPackets() []*rtp.Packet {
|
||||
return d.rtpPackets
|
||||
}
|
||||
|
||||
func (d *dataGeneric) getPTSEqualsDTS() bool {
|
||||
return d.ptsEqualsDTS
|
||||
}
|
||||
|
||||
type dataH264 struct {
|
||||
trackID int
|
||||
rtpPackets []*rtp.Packet
|
||||
ptsEqualsDTS bool
|
||||
pts time.Duration
|
||||
nalus [][]byte
|
||||
trackID int
|
||||
rtpPackets []*rtp.Packet
|
||||
pts time.Duration
|
||||
nalus [][]byte
|
||||
}
|
||||
|
||||
func (d *dataH264) getTrackID() int {
|
||||
@@ -47,10 +40,6 @@ func (d *dataH264) getRTPPackets() []*rtp.Packet {
|
||||
return d.rtpPackets
|
||||
}
|
||||
|
||||
func (d *dataH264) getPTSEqualsDTS() bool {
|
||||
return d.ptsEqualsDTS
|
||||
}
|
||||
|
||||
type dataMPEG4Audio struct {
|
||||
trackID int
|
||||
rtpPackets []*rtp.Packet
|
||||
@@ -65,7 +54,3 @@ func (d *dataMPEG4Audio) getTrackID() int {
|
||||
func (d *dataMPEG4Audio) getRTPPackets() []*rtp.Packet {
|
||||
return d.rtpPackets
|
||||
}
|
||||
|
||||
func (d *dataMPEG4Audio) getPTSEqualsDTS() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/h264"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/hls"
|
||||
"github.com/aler9/rtsp-simple-server/internal/logger"
|
||||
@@ -80,10 +79,9 @@ func (s *hlsSource) run(ctx context.Context) error {
|
||||
|
||||
onVideoData := func(pts time.Duration, nalus [][]byte) {
|
||||
err := stream.writeData(&dataH264{
|
||||
trackID: videoTrackID,
|
||||
ptsEqualsDTS: h264.IDRPresent(nalus),
|
||||
pts: pts,
|
||||
nalus: nalus,
|
||||
trackID: videoTrackID,
|
||||
pts: pts,
|
||||
nalus: nalus,
|
||||
})
|
||||
if err != nil {
|
||||
s.Log(logger.Warn, "%v", err)
|
||||
|
||||
@@ -34,9 +34,10 @@ func TestMetrics(t *testing.T) {
|
||||
defer p.Close()
|
||||
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
source := gortsplib.Client{}
|
||||
@@ -69,7 +70,8 @@ func TestMetrics(t *testing.T) {
|
||||
0x27, 0xe5, 0x84, 0x00, 0x00, 0x03, 0x00, 0x04,
|
||||
0x00, 0x00, 0x03, 0x00, 0xf0, 0x3c, 0x60, 0xc9, 0x20,
|
||||
},
|
||||
PPS: []byte{0x08, 0x06, 0x07, 0x08},
|
||||
PPS: []byte{0x08, 0x06, 0x07, 0x08},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
err = conn.WriteTracks(videoTrack, nil)
|
||||
|
||||
@@ -5,8 +5,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/h264"
|
||||
"github.com/aler9/gortsplib/pkg/rtph264"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/logger"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rpicamera"
|
||||
@@ -39,10 +37,11 @@ func (s *rpiCameraSource) Log(level logger.Level, format string, args ...interfa
|
||||
|
||||
// run implements sourceStaticImpl.
|
||||
func (s *rpiCameraSource) run(ctx context.Context) error {
|
||||
track := &gortsplib.TrackH264{PayloadType: 96}
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
tracks := gortsplib.Tracks{track}
|
||||
enc := &rtph264.Encoder{PayloadType: 96}
|
||||
enc.Init()
|
||||
var stream *stream
|
||||
|
||||
onData := func(dts time.Duration, nalus [][]byte) {
|
||||
@@ -60,10 +59,9 @@ func (s *rpiCameraSource) run(ctx context.Context) error {
|
||||
}
|
||||
|
||||
err := stream.writeData(&dataH264{
|
||||
trackID: 0,
|
||||
ptsEqualsDTS: h264.IDRPresent(nalus),
|
||||
pts: dts,
|
||||
nalus: nalus,
|
||||
trackID: 0,
|
||||
pts: dts,
|
||||
nalus: nalus,
|
||||
})
|
||||
if err != nil {
|
||||
s.Log(logger.Warn, "%v", err)
|
||||
|
||||
@@ -559,10 +559,9 @@ func (c *rtmpConn) runPublish(ctx context.Context, u *url.URL) error {
|
||||
}
|
||||
|
||||
err := rres.stream.writeData(&dataH264{
|
||||
trackID: videoTrackID,
|
||||
ptsEqualsDTS: false,
|
||||
pts: tmsg.DTS + tmsg.PTSDelta,
|
||||
nalus: nalus,
|
||||
trackID: videoTrackID,
|
||||
pts: tmsg.DTS + tmsg.PTSDelta,
|
||||
nalus: nalus,
|
||||
})
|
||||
if err != nil {
|
||||
c.log(logger.Warn, "%v", err)
|
||||
@@ -598,10 +597,9 @@ func (c *rtmpConn) runPublish(ctx context.Context, u *url.URL) error {
|
||||
}
|
||||
|
||||
err = rres.stream.writeData(&dataH264{
|
||||
trackID: videoTrackID,
|
||||
ptsEqualsDTS: h264.IDRPresent(validNALUs),
|
||||
pts: tmsg.DTS + tmsg.PTSDelta,
|
||||
nalus: validNALUs,
|
||||
trackID: videoTrackID,
|
||||
pts: tmsg.DTS + tmsg.PTSDelta,
|
||||
nalus: validNALUs,
|
||||
})
|
||||
if err != nil {
|
||||
c.log(logger.Warn, "%v", err)
|
||||
|
||||
@@ -75,7 +75,8 @@ func TestRTMPServerPublishRead(t *testing.T) {
|
||||
0x27, 0xe5, 0x84, 0x00, 0x00, 0x03, 0x00, 0x04,
|
||||
0x00, 0x00, 0x03, 0x00, 0xf0, 0x3c, 0x60, 0xc9, 0x20,
|
||||
},
|
||||
PPS: []byte{0x08, 0x06, 0x07, 0x08},
|
||||
PPS: []byte{0x08, 0x06, 0x07, 0x08},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
audioTrack := &gortsplib.TrackMPEG4Audio{
|
||||
@@ -199,6 +200,7 @@ func TestRTMPServerAuth(t *testing.T) {
|
||||
PPS: []byte{
|
||||
0x68, 0xee, 0x3c, 0x80,
|
||||
},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
err = conn1.WriteTracks(videoTrack, nil)
|
||||
@@ -262,6 +264,7 @@ func TestRTMPServerAuthFail(t *testing.T) {
|
||||
PPS: []byte{
|
||||
0x68, 0xee, 0x3c, 0x80,
|
||||
},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
err = conn1.WriteTracks(videoTrack, nil)
|
||||
@@ -316,6 +319,7 @@ func TestRTMPServerAuthFail(t *testing.T) {
|
||||
PPS: []byte{
|
||||
0x68, 0xee, 0x3c, 0x80,
|
||||
},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
err = conn1.WriteTracks(videoTrack, nil)
|
||||
@@ -369,6 +373,7 @@ func TestRTMPServerAuthFail(t *testing.T) {
|
||||
PPS: []byte{
|
||||
0x68, 0xee, 0x3c, 0x80,
|
||||
},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
err = conn1.WriteTracks(videoTrack, nil)
|
||||
|
||||
@@ -171,10 +171,9 @@ func (s *rtmpSource) run(ctx context.Context) error {
|
||||
}
|
||||
|
||||
err = res.stream.writeData(&dataH264{
|
||||
trackID: videoTrackID,
|
||||
ptsEqualsDTS: h264.IDRPresent(nalus),
|
||||
pts: tmsg.DTS + tmsg.PTSDelta,
|
||||
nalus: nalus,
|
||||
trackID: videoTrackID,
|
||||
pts: tmsg.DTS + tmsg.PTSDelta,
|
||||
nalus: nalus,
|
||||
})
|
||||
if err != nil {
|
||||
s.Log(logger.Warn, "%v", err)
|
||||
|
||||
@@ -64,7 +64,8 @@ func TestRTMPSource(t *testing.T) {
|
||||
0x27, 0xe5, 0x84, 0x00, 0x00, 0x03, 0x00, 0x04,
|
||||
0x00, 0x00, 0x03, 0x00, 0xf0, 0x3c, 0x60, 0xc9, 0x20,
|
||||
},
|
||||
PPS: []byte{0x08, 0x06, 0x07, 0x08},
|
||||
PPS: []byte{0x08, 0x06, 0x07, 0x08},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
audioTrack := &gortsplib.TrackMPEG4Audio{
|
||||
|
||||
@@ -45,9 +45,10 @@ func TestRTSPServerAuth(t *testing.T) {
|
||||
}
|
||||
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
source := gortsplib.Client{}
|
||||
@@ -94,9 +95,10 @@ func TestRTSPServerAuth(t *testing.T) {
|
||||
defer p.Close()
|
||||
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
source := gortsplib.Client{}
|
||||
@@ -142,9 +144,10 @@ func TestRTSPServerAuthFail(t *testing.T) {
|
||||
defer p.Close()
|
||||
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
c := gortsplib.Client{}
|
||||
@@ -212,9 +215,10 @@ func TestRTSPServerAuthFail(t *testing.T) {
|
||||
defer p.Close()
|
||||
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
c := gortsplib.Client{}
|
||||
@@ -238,9 +242,10 @@ func TestRTSPServerAuthFail(t *testing.T) {
|
||||
defer a.close()
|
||||
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
c := gortsplib.Client{}
|
||||
@@ -273,9 +278,10 @@ func TestRTSPServerPublisherOverride(t *testing.T) {
|
||||
defer p.Close()
|
||||
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
s1 := gortsplib.Client{}
|
||||
@@ -332,7 +338,7 @@ func TestRTSPServerPublisherOverride(t *testing.T) {
|
||||
Marker: true,
|
||||
},
|
||||
Payload: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
}, true)
|
||||
})
|
||||
if ca == "enabled" {
|
||||
require.Error(t, err)
|
||||
} else {
|
||||
@@ -350,7 +356,7 @@ func TestRTSPServerPublisherOverride(t *testing.T) {
|
||||
Marker: true,
|
||||
},
|
||||
Payload: []byte{0x05, 0x06, 0x07, 0x08},
|
||||
}, true)
|
||||
})
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -384,9 +390,10 @@ func TestRTSPServerFallback(t *testing.T) {
|
||||
source := gortsplib.Client{}
|
||||
err := source.StartPublishing("rtsp://localhost:8554/path2",
|
||||
gortsplib.Tracks{&gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
defer source.Close()
|
||||
|
||||
@@ -384,9 +384,8 @@ func (s *rtspSession) onPacketRTP(ctx *gortsplib.ServerHandlerOnPacketRTPCtx) {
|
||||
switch s.session.AnnouncedTracks()[ctx.TrackID].(type) {
|
||||
case *gortsplib.TrackH264:
|
||||
err = s.stream.writeData(&dataH264{
|
||||
trackID: ctx.TrackID,
|
||||
rtpPackets: []*rtp.Packet{ctx.Packet},
|
||||
ptsEqualsDTS: ctx.PTSEqualsDTS,
|
||||
trackID: ctx.TrackID,
|
||||
rtpPackets: []*rtp.Packet{ctx.Packet},
|
||||
})
|
||||
|
||||
case *gortsplib.TrackMPEG4Audio:
|
||||
@@ -397,9 +396,8 @@ func (s *rtspSession) onPacketRTP(ctx *gortsplib.ServerHandlerOnPacketRTPCtx) {
|
||||
|
||||
default:
|
||||
err = s.stream.writeData(&dataGeneric{
|
||||
trackID: ctx.TrackID,
|
||||
rtpPackets: []*rtp.Packet{ctx.Packet},
|
||||
ptsEqualsDTS: ctx.PTSEqualsDTS,
|
||||
trackID: ctx.TrackID,
|
||||
rtpPackets: []*rtp.Packet{ctx.Packet},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -149,9 +149,8 @@ func (s *rtspSource) run(ctx context.Context) error {
|
||||
switch tracks[ctx.TrackID].(type) {
|
||||
case *gortsplib.TrackH264:
|
||||
err = res.stream.writeData(&dataH264{
|
||||
trackID: ctx.TrackID,
|
||||
rtpPackets: []*rtp.Packet{ctx.Packet},
|
||||
ptsEqualsDTS: ctx.PTSEqualsDTS,
|
||||
trackID: ctx.TrackID,
|
||||
rtpPackets: []*rtp.Packet{ctx.Packet},
|
||||
})
|
||||
|
||||
case *gortsplib.TrackMPEG4Audio:
|
||||
@@ -162,9 +161,8 @@ func (s *rtspSource) run(ctx context.Context) error {
|
||||
|
||||
default:
|
||||
err = res.stream.writeData(&dataGeneric{
|
||||
trackID: ctx.TrackID,
|
||||
rtpPackets: []*rtp.Packet{ctx.Packet},
|
||||
ptsEqualsDTS: ctx.PTSEqualsDTS,
|
||||
trackID: ctx.TrackID,
|
||||
rtpPackets: []*rtp.Packet{ctx.Packet},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"github.com/aler9/gortsplib/pkg/base"
|
||||
"github.com/aler9/gortsplib/pkg/conn"
|
||||
"github.com/aler9/gortsplib/pkg/headers"
|
||||
"github.com/aler9/gortsplib/pkg/rtph264"
|
||||
"github.com/aler9/gortsplib/pkg/url"
|
||||
"github.com/pion/rtp"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -47,9 +46,10 @@ func TestRTSPSource(t *testing.T) {
|
||||
} {
|
||||
t.Run(source, func(t *testing.T) {
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
stream := gortsplib.NewServerStream(gortsplib.Tracks{track})
|
||||
@@ -96,7 +96,7 @@ func TestRTSPSource(t *testing.T) {
|
||||
Marker: true,
|
||||
},
|
||||
Payload: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
}, true)
|
||||
})
|
||||
}()
|
||||
|
||||
return &base.Response{
|
||||
@@ -179,9 +179,10 @@ func TestRTSPSource(t *testing.T) {
|
||||
|
||||
func TestRTSPSourceNoPassword(t *testing.T) {
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
stream := gortsplib.NewServerStream(gortsplib.Tracks{track})
|
||||
@@ -242,9 +243,11 @@ func TestRTSPSourceNoPassword(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRTSPSourceDynamicH264Params(t *testing.T) {
|
||||
stream := gortsplib.NewServerStream(gortsplib.Tracks{&gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
}})
|
||||
track := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
stream := gortsplib.NewServerStream(gortsplib.Tracks{track})
|
||||
defer stream.Close()
|
||||
|
||||
s := gortsplib.Server{
|
||||
@@ -282,16 +285,15 @@ func TestRTSPSourceDynamicH264Params(t *testing.T) {
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
enc := &rtph264.Encoder{PayloadType: 96}
|
||||
enc.Init()
|
||||
enc := track.CreateEncoder()
|
||||
|
||||
pkts, err := enc.Encode([][]byte{{7, 1, 2, 3}}, 0) // SPS
|
||||
require.NoError(t, err)
|
||||
stream.WritePacketRTP(0, pkts[0], true)
|
||||
stream.WritePacketRTP(0, pkts[0])
|
||||
|
||||
pkts, err = enc.Encode([][]byte{{8}}, 0) // PPS
|
||||
require.NoError(t, err)
|
||||
stream.WritePacketRTP(0, pkts[0], true)
|
||||
stream.WritePacketRTP(0, pkts[0])
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
||||
@@ -316,11 +318,11 @@ func TestRTSPSourceDynamicH264Params(t *testing.T) {
|
||||
|
||||
pkts, err = enc.Encode([][]byte{{7, 4, 5, 6}}, 0) // SPS
|
||||
require.NoError(t, err)
|
||||
stream.WritePacketRTP(0, pkts[0], true)
|
||||
stream.WritePacketRTP(0, pkts[0])
|
||||
|
||||
pkts, err = enc.Encode([][]byte{{8, 1}}, 0) // PPS
|
||||
require.NoError(t, err)
|
||||
stream.WritePacketRTP(0, pkts[0], true)
|
||||
stream.WritePacketRTP(0, pkts[0])
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
||||
@@ -346,7 +348,8 @@ func TestRTSPSourceDynamicH264Params(t *testing.T) {
|
||||
|
||||
func TestRTSPSourceRemovePadding(t *testing.T) {
|
||||
stream := gortsplib.NewServerStream(gortsplib.Tracks{&gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
PayloadType: 96,
|
||||
PacketizationMode: 1,
|
||||
}})
|
||||
defer stream.Close()
|
||||
|
||||
@@ -430,7 +433,7 @@ func TestRTSPSourceRemovePadding(t *testing.T) {
|
||||
},
|
||||
Payload: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PaddingSize: 20,
|
||||
}, true)
|
||||
})
|
||||
|
||||
<-packetRecv
|
||||
}
|
||||
@@ -473,9 +476,10 @@ func TestRTSPSourceOversizedPackets(t *testing.T) {
|
||||
require.Equal(t, base.Describe, req.Method)
|
||||
|
||||
tracks := gortsplib.Tracks{&gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PayloadType: 96,
|
||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
PacketizationMode: 1,
|
||||
}}
|
||||
|
||||
err = conn.WriteResponse(&base.Response{
|
||||
|
||||
@@ -112,7 +112,7 @@ func (s *stream) writeData(data data) error {
|
||||
// forward RTP packets to RTSP readers
|
||||
for _, pkt := range data.getRTPPackets() {
|
||||
atomic.AddUint64(s.bytesReceived, uint64(pkt.MarshalSize()))
|
||||
s.rtspStream.WritePacketRTP(data.getTrackID(), pkt, data.getPTSEqualsDTS())
|
||||
s.rtspStream.WritePacketRTP(data.getTrackID(), pkt)
|
||||
}
|
||||
|
||||
// forward data to non-RTSP readers
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/h264"
|
||||
"github.com/aler9/gortsplib/pkg/rtph264"
|
||||
"github.com/aler9/gortsplib/pkg/rtpcodecs/rtph264"
|
||||
"github.com/pion/rtp"
|
||||
)
|
||||
|
||||
@@ -77,8 +77,7 @@ func newStreamTrackH264(
|
||||
}
|
||||
|
||||
if allocateEncoder {
|
||||
t.encoder = &rtph264.Encoder{PayloadType: 96}
|
||||
t.encoder.Init()
|
||||
t.encoder = track.CreateEncoder()
|
||||
}
|
||||
|
||||
return t
|
||||
@@ -200,6 +199,7 @@ func (t *streamTrackH264) onData(dat data, hasNonRTSPReaders bool) error {
|
||||
SSRC: &v1,
|
||||
InitialSequenceNumber: &v2,
|
||||
InitialTimestamp: &v3,
|
||||
PacketizationMode: t.track.PacketizationMode,
|
||||
}
|
||||
t.encoder.Init()
|
||||
}
|
||||
@@ -208,8 +208,7 @@ func (t *streamTrackH264) onData(dat data, hasNonRTSPReaders bool) error {
|
||||
// decode from RTP
|
||||
if hasNonRTSPReaders || t.encoder != nil {
|
||||
if t.decoder == nil {
|
||||
t.decoder = &rtph264.Decoder{}
|
||||
t.decoder.Init()
|
||||
t.decoder = t.track.CreateDecoder()
|
||||
}
|
||||
|
||||
nalus, pts, err := t.decoder.Decode(pkt)
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/rtpmpeg4audio"
|
||||
"github.com/aler9/gortsplib/pkg/rtpcodecs/rtpmpeg4audio"
|
||||
)
|
||||
|
||||
type streamTrackMPEG4Audio struct {
|
||||
@@ -22,14 +22,7 @@ func newStreamTrackMPEG4Audio(
|
||||
}
|
||||
|
||||
if allocateEncoder {
|
||||
t.encoder = &rtpmpeg4audio.Encoder{
|
||||
PayloadType: 96,
|
||||
SampleRate: track.ClockRate(),
|
||||
SizeLength: 13,
|
||||
IndexLength: 3,
|
||||
IndexDeltaLength: 3,
|
||||
}
|
||||
t.encoder.Init()
|
||||
t.encoder = track.CreateEncoder()
|
||||
}
|
||||
|
||||
return t
|
||||
@@ -63,13 +56,7 @@ func (t *streamTrackMPEG4Audio) onData(dat data, hasNonRTSPReaders bool) error {
|
||||
// decode from RTP
|
||||
if hasNonRTSPReaders {
|
||||
if t.decoder == nil {
|
||||
t.decoder = &rtpmpeg4audio.Decoder{
|
||||
SampleRate: t.track.Config.SampleRate,
|
||||
SizeLength: t.track.SizeLength,
|
||||
IndexLength: t.track.IndexLength,
|
||||
IndexDeltaLength: t.track.IndexDeltaLength,
|
||||
}
|
||||
t.decoder.Init()
|
||||
t.decoder = t.track.CreateDecoder()
|
||||
}
|
||||
|
||||
aus, pts, err := t.decoder.Decode(pkt)
|
||||
|
||||
@@ -106,9 +106,10 @@ func (i *Init) Unmarshal(byts []byte) error {
|
||||
}
|
||||
|
||||
curTrack.Track = &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: sps,
|
||||
PPS: pps,
|
||||
PayloadType: 96,
|
||||
SPS: sps,
|
||||
PPS: pps,
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
state = waitingTrak
|
||||
|
||||
|
||||
@@ -17,9 +17,10 @@ var testSPS = []byte{
|
||||
}
|
||||
|
||||
var testVideoTrack = &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: testSPS,
|
||||
PPS: []byte{0x08},
|
||||
PayloadType: 96,
|
||||
SPS: testSPS,
|
||||
PPS: []byte{0x08},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
var testAudioTrack = &gortsplib.TrackMPEG4Audio{
|
||||
@@ -567,6 +568,7 @@ func TestInitUnmarshal(t *testing.T) {
|
||||
PPS: []byte{
|
||||
0x68, 0xcb, 0x8c, 0xb2,
|
||||
},
|
||||
PacketizationMode: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -78,7 +78,8 @@ func FindTracks(byts []byte) ([]*Track, error) {
|
||||
switch t.ES.StreamType {
|
||||
case astits.StreamTypeH264Video:
|
||||
t.Track = &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
PayloadType: 96,
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
case astits.StreamTypeAACAudio:
|
||||
|
||||
@@ -22,9 +22,10 @@ func TestWriter(t *testing.T) {
|
||||
}
|
||||
|
||||
testVideoTrack := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: testSPS,
|
||||
PPS: []byte{0x08},
|
||||
PayloadType: 96,
|
||||
SPS: testSPS,
|
||||
PPS: []byte{0x08},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
testAudioTrack := &gortsplib.TrackMPEG4Audio{
|
||||
|
||||
+20
-15
@@ -23,9 +23,10 @@ var testSPS = []byte{
|
||||
|
||||
func TestMuxerVideoAudio(t *testing.T) {
|
||||
videoTrack := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: testSPS,
|
||||
PPS: []byte{0x08},
|
||||
PayloadType: 96,
|
||||
SPS: testSPS,
|
||||
PPS: []byte{0x08},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
audioTrack := &gortsplib.TrackMPEG4Audio{
|
||||
@@ -180,9 +181,10 @@ func TestMuxerVideoAudio(t *testing.T) {
|
||||
|
||||
func TestMuxerVideoOnly(t *testing.T) {
|
||||
videoTrack := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: testSPS,
|
||||
PPS: []byte{0x08},
|
||||
PayloadType: 96,
|
||||
SPS: testSPS,
|
||||
PPS: []byte{0x08},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
for _, ca := range []string{
|
||||
@@ -404,9 +406,10 @@ func TestMuxerAudioOnly(t *testing.T) {
|
||||
|
||||
func TestMuxerCloseBeforeFirstSegmentReader(t *testing.T) {
|
||||
videoTrack := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: testSPS,
|
||||
PPS: []byte{0x08},
|
||||
PayloadType: 96,
|
||||
SPS: testSPS,
|
||||
PPS: []byte{0x08},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
m, err := NewMuxer(MuxerVariantMPEGTS, 3, 1*time.Second, 0, 50*1024*1024, videoTrack, nil)
|
||||
@@ -428,9 +431,10 @@ func TestMuxerCloseBeforeFirstSegmentReader(t *testing.T) {
|
||||
|
||||
func TestMuxerMaxSegmentSize(t *testing.T) {
|
||||
videoTrack := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: testSPS,
|
||||
PPS: []byte{0x08},
|
||||
PayloadType: 96,
|
||||
SPS: testSPS,
|
||||
PPS: []byte{0x08},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
m, err := NewMuxer(MuxerVariantMPEGTS, 3, 1*time.Second, 0, 0, videoTrack, nil)
|
||||
@@ -446,9 +450,10 @@ func TestMuxerMaxSegmentSize(t *testing.T) {
|
||||
|
||||
func TestMuxerDoubleRead(t *testing.T) {
|
||||
videoTrack := &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: testSPS,
|
||||
PPS: []byte{0x08},
|
||||
PayloadType: 96,
|
||||
SPS: testSPS,
|
||||
PPS: []byte{0x08},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
m, err := NewMuxer(MuxerVariantMPEGTS, 3, 1*time.Second, 0, 50*1024*1024, videoTrack, nil)
|
||||
|
||||
@@ -588,9 +588,10 @@ func trackFromH264DecoderConfig(data []byte) (*gortsplib.TrackH264, error) {
|
||||
}
|
||||
|
||||
return &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: conf.SPS,
|
||||
PPS: conf.PPS,
|
||||
PayloadType: 96,
|
||||
SPS: conf.SPS,
|
||||
PPS: conf.PPS,
|
||||
PacketizationMode: 1,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
+17
-12
@@ -499,9 +499,10 @@ func TestReadTracks(t *testing.T) {
|
||||
switch ca {
|
||||
case "video+audio":
|
||||
require.Equal(t, &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: sps,
|
||||
PPS: pps,
|
||||
PayloadType: 96,
|
||||
SPS: sps,
|
||||
PPS: pps,
|
||||
PacketizationMode: 1,
|
||||
}, videoTrack)
|
||||
|
||||
require.Equal(t, &gortsplib.TrackMPEG4Audio{
|
||||
@@ -518,18 +519,20 @@ func TestReadTracks(t *testing.T) {
|
||||
|
||||
case "video":
|
||||
require.Equal(t, &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: sps,
|
||||
PPS: pps,
|
||||
PayloadType: 96,
|
||||
SPS: sps,
|
||||
PPS: pps,
|
||||
PacketizationMode: 1,
|
||||
}, videoTrack)
|
||||
|
||||
require.Nil(t, audioTrack)
|
||||
|
||||
case "metadata without codec id":
|
||||
require.Equal(t, &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: sps,
|
||||
PPS: pps,
|
||||
PayloadType: 96,
|
||||
SPS: sps,
|
||||
PPS: pps,
|
||||
PacketizationMode: 1,
|
||||
}, videoTrack)
|
||||
|
||||
require.Equal(t, &gortsplib.TrackMPEG4Audio{
|
||||
@@ -546,9 +549,10 @@ func TestReadTracks(t *testing.T) {
|
||||
|
||||
case "missing metadata":
|
||||
require.Equal(t, &gortsplib.TrackH264{
|
||||
PayloadType: 96,
|
||||
SPS: sps,
|
||||
PPS: pps,
|
||||
PayloadType: 96,
|
||||
SPS: sps,
|
||||
PPS: pps,
|
||||
PacketizationMode: 1,
|
||||
}, videoTrack)
|
||||
|
||||
require.Equal(t, &gortsplib.TrackMPEG4Audio{
|
||||
@@ -936,6 +940,7 @@ func TestWriteTracks(t *testing.T) {
|
||||
PPS: []byte{
|
||||
0x68, 0xee, 0x3c, 0x80,
|
||||
},
|
||||
PacketizationMode: 1,
|
||||
}
|
||||
|
||||
audioTrack := &gortsplib.TrackMPEG4Audio{
|
||||
|
||||
Reference in New Issue
Block a user