mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-04 23:32:44 +08:00
rtsp: emit log message when remuxing RTP packets (#4422)
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpac3"
|
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpac3"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ type ac3 struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format *format.AC3
|
Format *format.AC3
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
|
|
||||||
encoder *rtpac3.Encoder
|
encoder *rtpac3.Encoder
|
||||||
decoder *rtpac3.Decoder
|
decoder *rtpac3.Decoder
|
||||||
|
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpav1"
|
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpav1"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ type av1 struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format *format.AV1
|
Format *format.AV1
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
|
|
||||||
encoder *rtpav1.Encoder
|
encoder *rtpav1.Encoder
|
||||||
decoder *rtpav1.Decoder
|
decoder *rtpav1.Decoder
|
||||||
|
@@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/bluenviron/gortsplib/v4/pkg/format/rtplpcm"
|
"github.com/bluenviron/gortsplib/v4/pkg/format/rtplpcm"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@ type g711 struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format *format.G711
|
Format *format.G711
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
|
|
||||||
encoder *rtplpcm.Encoder
|
encoder *rtplpcm.Encoder
|
||||||
decoder *rtplpcm.Decoder
|
decoder *rtplpcm.Decoder
|
||||||
|
@@ -18,7 +18,7 @@ func TestG711Encode(t *testing.T) {
|
|||||||
ChannelCount: 1,
|
ChannelCount: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := New(1472, forma, true)
|
p, err := New(1472, forma, true, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
unit := &unit.G711{
|
unit := &unit.G711{
|
||||||
@@ -47,7 +47,7 @@ func TestG711Encode(t *testing.T) {
|
|||||||
ChannelCount: 1,
|
ChannelCount: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := New(1472, forma, true)
|
p, err := New(1472, forma, true, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
unit := &unit.G711{
|
unit := &unit.G711{
|
||||||
|
@@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/bluenviron/gortsplib/v4/pkg/format"
|
"github.com/bluenviron/gortsplib/v4/pkg/format"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ type generic struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format format.Format
|
Format format.Format
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *generic) initialize() error {
|
func (t *generic) initialize() error {
|
||||||
|
@@ -17,7 +17,7 @@ func TestGenericRemovePadding(t *testing.T) {
|
|||||||
err := forma.Init()
|
err := forma.Init()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
p, err := New(1472, forma, false)
|
p, err := New(1472, forma, false, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
pkt := &rtp.Packet{
|
pkt := &rtp.Packet{
|
||||||
|
@@ -10,6 +10,7 @@ import (
|
|||||||
mch264 "github.com/bluenviron/mediacommon/v2/pkg/codecs/h264"
|
mch264 "github.com/bluenviron/mediacommon/v2/pkg/codecs/h264"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -85,6 +86,7 @@ type h264 struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format *format.H264
|
Format *format.H264
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
|
|
||||||
encoder *rtph264.Encoder
|
encoder *rtph264.Encoder
|
||||||
decoder *rtph264.Decoder
|
decoder *rtph264.Decoder
|
||||||
@@ -266,6 +268,8 @@ func (t *h264) ProcessRTPPacket( //nolint:dupl
|
|||||||
|
|
||||||
// RTP packets exceed maximum size: start re-encoding them
|
// RTP packets exceed maximum size: start re-encoding them
|
||||||
if pkt.MarshalSize() > t.UDPMaxPayloadSize {
|
if pkt.MarshalSize() > t.UDPMaxPayloadSize {
|
||||||
|
t.Parent.Log(logger.Info, "RTP packets are too big, remuxing them into smaller ones")
|
||||||
|
|
||||||
v1 := pkt.SSRC
|
v1 := pkt.SSRC
|
||||||
v2 := pkt.SequenceNumber
|
v2 := pkt.SequenceNumber
|
||||||
err := t.createEncoder(&v1, &v2)
|
err := t.createEncoder(&v1, &v2)
|
||||||
|
@@ -2,6 +2,7 @@ package formatprocessor
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -10,9 +11,23 @@ import (
|
|||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type testLogger struct {
|
||||||
|
cb func(level logger.Level, format string, args ...interface{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *testLogger) Log(level logger.Level, format string, args ...interface{}) {
|
||||||
|
l.cb(level, format, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logger returns a dummy logger.
|
||||||
|
func Logger(cb func(logger.Level, string, ...interface{})) logger.Writer {
|
||||||
|
return &testLogger{cb: cb}
|
||||||
|
}
|
||||||
|
|
||||||
func TestH264DynamicParams(t *testing.T) {
|
func TestH264DynamicParams(t *testing.T) {
|
||||||
for _, ca := range []string{"standard", "aggregated"} {
|
for _, ca := range []string{"standard", "aggregated"} {
|
||||||
t.Run(ca, func(t *testing.T) {
|
t.Run(ca, func(t *testing.T) {
|
||||||
@@ -21,7 +36,7 @@ func TestH264DynamicParams(t *testing.T) {
|
|||||||
PacketizationMode: 1,
|
PacketizationMode: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := New(1472, forma, false)
|
p, err := New(1472, forma, false, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
enc, err := forma.CreateEncoder()
|
enc, err := forma.CreateEncoder()
|
||||||
@@ -86,7 +101,13 @@ func TestH264OversizedPackets(t *testing.T) {
|
|||||||
PacketizationMode: 1,
|
PacketizationMode: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := New(1472, forma, false)
|
logged := false
|
||||||
|
|
||||||
|
p, err := New(1472, forma, false,
|
||||||
|
Logger(func(_ logger.Level, s string, i ...interface{}) {
|
||||||
|
require.Equal(t, "RTP packets are too big, remuxing them into smaller ones", fmt.Sprintf(s, i...))
|
||||||
|
logged = true
|
||||||
|
}))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
var out []*rtp.Packet
|
var out []*rtp.Packet
|
||||||
@@ -176,6 +197,8 @@ func TestH264OversizedPackets(t *testing.T) {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
}, out)
|
}, out)
|
||||||
|
|
||||||
|
require.True(t, logged)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestH264EmptyPacket(t *testing.T) {
|
func TestH264EmptyPacket(t *testing.T) {
|
||||||
@@ -184,7 +207,7 @@ func TestH264EmptyPacket(t *testing.T) {
|
|||||||
PacketizationMode: 1,
|
PacketizationMode: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := New(1472, forma, true)
|
p, err := New(1472, forma, true, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
unit := &unit.H264{
|
unit := &unit.H264{
|
||||||
|
@@ -10,6 +10,7 @@ import (
|
|||||||
mch265 "github.com/bluenviron/mediacommon/v2/pkg/codecs/h265"
|
mch265 "github.com/bluenviron/mediacommon/v2/pkg/codecs/h265"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -105,6 +106,7 @@ type h265 struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format *format.H265
|
Format *format.H265
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
|
|
||||||
encoder *rtph265.Encoder
|
encoder *rtph265.Encoder
|
||||||
decoder *rtph265.Decoder
|
decoder *rtph265.Decoder
|
||||||
@@ -298,6 +300,8 @@ func (t *h265) ProcessRTPPacket( //nolint:dupl
|
|||||||
|
|
||||||
// RTP packets exceed maximum size: start re-encoding them
|
// RTP packets exceed maximum size: start re-encoding them
|
||||||
if pkt.MarshalSize() > t.UDPMaxPayloadSize {
|
if pkt.MarshalSize() > t.UDPMaxPayloadSize {
|
||||||
|
t.Parent.Log(logger.Info, "RTP packets are too big, remuxing them into smaller ones")
|
||||||
|
|
||||||
v1 := pkt.SSRC
|
v1 := pkt.SSRC
|
||||||
v2 := pkt.SequenceNumber
|
v2 := pkt.SequenceNumber
|
||||||
err := t.createEncoder(&v1, &v2)
|
err := t.createEncoder(&v1, &v2)
|
||||||
|
@@ -2,6 +2,7 @@ package formatprocessor
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -10,6 +11,7 @@ import (
|
|||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,7 +22,7 @@ func TestH265DynamicParams(t *testing.T) {
|
|||||||
PayloadTyp: 96,
|
PayloadTyp: 96,
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := New(1472, forma, false)
|
p, err := New(1472, forma, false, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
enc, err := forma.CreateEncoder()
|
enc, err := forma.CreateEncoder()
|
||||||
@@ -94,7 +96,13 @@ func TestH265OversizedPackets(t *testing.T) {
|
|||||||
PPS: []byte{byte(mch265.NALUType_PPS_NUT) << 1, 16, 17, 18},
|
PPS: []byte{byte(mch265.NALUType_PPS_NUT) << 1, 16, 17, 18},
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := New(1472, forma, false)
|
logged := false
|
||||||
|
|
||||||
|
p, err := New(1472, forma, false,
|
||||||
|
Logger(func(_ logger.Level, s string, i ...interface{}) {
|
||||||
|
require.Equal(t, "RTP packets are too big, remuxing them into smaller ones", fmt.Sprintf(s, i...))
|
||||||
|
logged = true
|
||||||
|
}))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
var out []*rtp.Packet
|
var out []*rtp.Packet
|
||||||
@@ -172,6 +180,8 @@ func TestH265OversizedPackets(t *testing.T) {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
}, out)
|
}, out)
|
||||||
|
|
||||||
|
require.True(t, logged)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestH265EmptyPacket(t *testing.T) {
|
func TestH265EmptyPacket(t *testing.T) {
|
||||||
@@ -179,7 +189,7 @@ func TestH265EmptyPacket(t *testing.T) {
|
|||||||
PayloadTyp: 96,
|
PayloadTyp: 96,
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := New(1472, forma, true)
|
p, err := New(1472, forma, true, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
unit := &unit.H265{
|
unit := &unit.H265{
|
||||||
|
@@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/bluenviron/gortsplib/v4/pkg/format/rtplpcm"
|
"github.com/bluenviron/gortsplib/v4/pkg/format/rtplpcm"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@ type lpcm struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format *format.LPCM
|
Format *format.LPCM
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
|
|
||||||
encoder *rtplpcm.Encoder
|
encoder *rtplpcm.Encoder
|
||||||
decoder *rtplpcm.Decoder
|
decoder *rtplpcm.Decoder
|
||||||
|
@@ -17,7 +17,7 @@ func TestLPCMEncode(t *testing.T) {
|
|||||||
ChannelCount: 2,
|
ChannelCount: 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := New(1472, forma, true)
|
p, err := New(1472, forma, true, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
unit := &unit.LPCM{
|
unit := &unit.LPCM{
|
||||||
|
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpmjpeg"
|
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpmjpeg"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ type mjpeg struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format *format.MJPEG
|
Format *format.MJPEG
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
|
|
||||||
encoder *rtpmjpeg.Encoder
|
encoder *rtpmjpeg.Encoder
|
||||||
decoder *rtpmjpeg.Decoder
|
decoder *rtpmjpeg.Decoder
|
||||||
|
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpmpeg1audio"
|
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpmpeg1audio"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ type mpeg1Audio struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format *format.MPEG1Audio
|
Format *format.MPEG1Audio
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
|
|
||||||
encoder *rtpmpeg1audio.Encoder
|
encoder *rtpmpeg1audio.Encoder
|
||||||
decoder *rtpmpeg1audio.Decoder
|
decoder *rtpmpeg1audio.Decoder
|
||||||
|
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpmpeg1video"
|
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpmpeg1video"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ type mpeg1Video struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format *format.MPEG1Video
|
Format *format.MPEG1Video
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
|
|
||||||
encoder *rtpmpeg1video.Encoder
|
encoder *rtpmpeg1video.Encoder
|
||||||
decoder *rtpmpeg1video.Decoder
|
decoder *rtpmpeg1video.Decoder
|
||||||
|
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpmpeg4audio"
|
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpmpeg4audio"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ type mpeg4Audio struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format *format.MPEG4Audio
|
Format *format.MPEG4Audio
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
|
|
||||||
encoder *rtpmpeg4audio.Encoder
|
encoder *rtpmpeg4audio.Encoder
|
||||||
decoder *rtpmpeg4audio.Decoder
|
decoder *rtpmpeg4audio.Decoder
|
||||||
|
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4video"
|
"github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4video"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ type mpeg4Video struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format *format.MPEG4Video
|
Format *format.MPEG4Video
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
|
|
||||||
encoder *rtpmpeg4video.Encoder
|
encoder *rtpmpeg4video.Encoder
|
||||||
decoder *rtpmpeg4video.Decoder
|
decoder *rtpmpeg4video.Decoder
|
||||||
|
@@ -9,6 +9,7 @@ import (
|
|||||||
mcopus "github.com/bluenviron/mediacommon/v2/pkg/codecs/opus"
|
mcopus "github.com/bluenviron/mediacommon/v2/pkg/codecs/opus"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ type opus struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format *format.Opus
|
Format *format.Opus
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
|
|
||||||
encoder *rtpsimpleaudio.Encoder
|
encoder *rtpsimpleaudio.Encoder
|
||||||
decoder *rtpsimpleaudio.Decoder
|
decoder *rtpsimpleaudio.Decoder
|
||||||
|
@@ -15,7 +15,7 @@ func TestOpusEncode(t *testing.T) {
|
|||||||
ChannelCount: 2,
|
ChannelCount: 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := New(1472, forma, true)
|
p, err := New(1472, forma, true, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
unit := &unit.Opus{
|
unit := &unit.Opus{
|
||||||
|
@@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/bluenviron/gortsplib/v4/pkg/format"
|
"github.com/bluenviron/gortsplib/v4/pkg/format"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ func New(
|
|||||||
udpMaxPayloadSize int,
|
udpMaxPayloadSize int,
|
||||||
forma format.Format,
|
forma format.Format,
|
||||||
generateRTPPackets bool,
|
generateRTPPackets bool,
|
||||||
|
parent logger.Writer,
|
||||||
) (Processor, error) {
|
) (Processor, error) {
|
||||||
var proc Processor
|
var proc Processor
|
||||||
|
|
||||||
@@ -50,6 +52,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.VP9:
|
case *format.VP9:
|
||||||
@@ -57,6 +60,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.VP8:
|
case *format.VP8:
|
||||||
@@ -64,6 +68,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.H265:
|
case *format.H265:
|
||||||
@@ -71,6 +76,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.H264:
|
case *format.H264:
|
||||||
@@ -78,6 +84,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.MPEG4Video:
|
case *format.MPEG4Video:
|
||||||
@@ -85,6 +92,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.MPEG1Video:
|
case *format.MPEG1Video:
|
||||||
@@ -92,6 +100,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.MJPEG:
|
case *format.MJPEG:
|
||||||
@@ -99,6 +108,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.Opus:
|
case *format.Opus:
|
||||||
@@ -106,6 +116,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.MPEG4Audio:
|
case *format.MPEG4Audio:
|
||||||
@@ -113,6 +124,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.MPEG1Audio:
|
case *format.MPEG1Audio:
|
||||||
@@ -120,6 +132,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.AC3:
|
case *format.AC3:
|
||||||
@@ -127,6 +140,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.G711:
|
case *format.G711:
|
||||||
@@ -134,6 +148,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.LPCM:
|
case *format.LPCM:
|
||||||
@@ -141,6 +156,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -148,6 +164,7 @@ func New(
|
|||||||
UDPMaxPayloadSize: udpMaxPayloadSize,
|
UDPMaxPayloadSize: udpMaxPayloadSize,
|
||||||
Format: forma,
|
Format: forma,
|
||||||
GenerateRTPPackets: generateRTPPackets,
|
GenerateRTPPackets: generateRTPPackets,
|
||||||
|
Parent: parent,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -90,7 +90,7 @@ func TestNew(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(ca.name, func(t *testing.T) {
|
t.Run(ca.name, func(t *testing.T) {
|
||||||
p, err := New(1472, ca.in, false)
|
p, err := New(1472, ca.in, false, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.IsType(t, ca.out, p)
|
require.IsType(t, ca.out, p)
|
||||||
})
|
})
|
||||||
|
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpvp8"
|
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpvp8"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ type vp8 struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format *format.VP8
|
Format *format.VP8
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
|
|
||||||
encoder *rtpvp8.Encoder
|
encoder *rtpvp8.Encoder
|
||||||
decoder *rtpvp8.Decoder
|
decoder *rtpvp8.Decoder
|
||||||
|
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpvp9"
|
"github.com/bluenviron/gortsplib/v4/pkg/format/rtpvp9"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ type vp9 struct {
|
|||||||
UDPMaxPayloadSize int
|
UDPMaxPayloadSize int
|
||||||
Format *format.VP9
|
Format *format.VP9
|
||||||
GenerateRTPPackets bool
|
GenerateRTPPackets bool
|
||||||
|
Parent logger.Writer
|
||||||
|
|
||||||
encoder *rtpvp9.Encoder
|
encoder *rtpvp9.Encoder
|
||||||
decoder *rtpvp9.Decoder
|
decoder *rtpvp9.Decoder
|
||||||
|
@@ -73,6 +73,7 @@ func (s *Stream) Initialize() error {
|
|||||||
media: media,
|
media: media,
|
||||||
generateRTPPackets: s.GenerateRTPPackets,
|
generateRTPPackets: s.GenerateRTPPackets,
|
||||||
processingErrors: s.processingErrors,
|
processingErrors: s.processingErrors,
|
||||||
|
parent: s.Parent,
|
||||||
}
|
}
|
||||||
err := s.streamMedias[media].initialize()
|
err := s.streamMedias[media].initialize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/bluenviron/mediamtx/internal/counterdumper"
|
"github.com/bluenviron/mediamtx/internal/counterdumper"
|
||||||
"github.com/bluenviron/mediamtx/internal/formatprocessor"
|
"github.com/bluenviron/mediamtx/internal/formatprocessor"
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/unit"
|
"github.com/bluenviron/mediamtx/internal/unit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ type streamFormat struct {
|
|||||||
format format.Format
|
format format.Format
|
||||||
generateRTPPackets bool
|
generateRTPPackets bool
|
||||||
processingErrors *counterdumper.CounterDumper
|
processingErrors *counterdumper.CounterDumper
|
||||||
|
parent logger.Writer
|
||||||
|
|
||||||
proc formatprocessor.Processor
|
proc formatprocessor.Processor
|
||||||
pausedReaders map[*streamReader]ReadFunc
|
pausedReaders map[*streamReader]ReadFunc
|
||||||
@@ -37,7 +39,7 @@ func (sf *streamFormat) initialize() error {
|
|||||||
sf.runningReaders = make(map[*streamReader]ReadFunc)
|
sf.runningReaders = make(map[*streamReader]ReadFunc)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
sf.proc, err = formatprocessor.New(sf.udpMaxPayloadSize, sf.format, sf.generateRTPPackets)
|
sf.proc, err = formatprocessor.New(sf.udpMaxPayloadSize, sf.format, sf.generateRTPPackets, sf.parent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/bluenviron/gortsplib/v4/pkg/description"
|
"github.com/bluenviron/gortsplib/v4/pkg/description"
|
||||||
"github.com/bluenviron/gortsplib/v4/pkg/format"
|
"github.com/bluenviron/gortsplib/v4/pkg/format"
|
||||||
"github.com/bluenviron/mediamtx/internal/counterdumper"
|
"github.com/bluenviron/mediamtx/internal/counterdumper"
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
type streamMedia struct {
|
type streamMedia struct {
|
||||||
@@ -11,6 +12,7 @@ type streamMedia struct {
|
|||||||
media *description.Media
|
media *description.Media
|
||||||
generateRTPPackets bool
|
generateRTPPackets bool
|
||||||
processingErrors *counterdumper.CounterDumper
|
processingErrors *counterdumper.CounterDumper
|
||||||
|
parent logger.Writer
|
||||||
|
|
||||||
formats map[format.Format]*streamFormat
|
formats map[format.Format]*streamFormat
|
||||||
}
|
}
|
||||||
@@ -24,6 +26,7 @@ func (sm *streamMedia) initialize() error {
|
|||||||
format: forma,
|
format: forma,
|
||||||
generateRTPPackets: sm.generateRTPPackets,
|
generateRTPPackets: sm.generateRTPPackets,
|
||||||
processingErrors: sm.processingErrors,
|
processingErrors: sm.processingErrors,
|
||||||
|
parent: sm.parent,
|
||||||
}
|
}
|
||||||
err := sf.initialize()
|
err := sf.initialize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user