Add pkt_size option fort RTSP server

This commit is contained in:
Alexey Khit
2023-04-24 06:40:11 +03:00
parent 813c8b3b3d
commit a20de73ab2
6 changed files with 29 additions and 3 deletions
+4
View File
@@ -94,6 +94,10 @@ func RTPDepay(codec *core.Codec, handler core.HandlerFunc) core.HandlerFunc {
}
func RTPPay(mtu uint16, handler core.HandlerFunc) core.HandlerFunc {
if mtu == 0 {
mtu = 1472
}
payloader := &Payloader{IsAVC: true}
sequencer := rtp.NewRandomSequencer()
mtu -= 12 // rtp.Header size
+4
View File
@@ -76,6 +76,10 @@ func RTPDepay(codec *core.Codec, handler core.HandlerFunc) core.HandlerFunc {
}
func RTPPay(mtu uint16, handler core.HandlerFunc) core.HandlerFunc {
if mtu == 0 {
mtu = 1472
}
payloader := &Payloader{}
sequencer := rtp.NewRandomSequencer()
mtu -= 12 // rtp.Header size
+1
View File
@@ -22,6 +22,7 @@ type Conn struct {
// public
Backchannel bool
PacketSize uint16
SessionName string
Medias []*core.Media
+11 -2
View File
@@ -104,14 +104,23 @@ func (c *Conn) packetWriter(codec *core.Codec, channel, payloadType uint8) core.
if !codec.IsRTP() {
switch codec.Name {
case core.CodecH264:
handlerFunc = h264.RTPPay(1500, handlerFunc)
handlerFunc = h264.RTPPay(c.PacketSize, handlerFunc)
case core.CodecH265:
handlerFunc = h265.RTPPay(1500, handlerFunc)
handlerFunc = h265.RTPPay(c.PacketSize, handlerFunc)
case core.CodecAAC:
handlerFunc = aac.RTPPay(handlerFunc)
case core.CodecJPEG:
handlerFunc = mjpeg.RTPPay(handlerFunc)
}
} else if c.PacketSize != 0 {
switch codec.Name {
case core.CodecH264:
handlerFunc = h264.RTPPay(c.PacketSize, handlerFunc)
handlerFunc = h264.RTPDepay(codec, handlerFunc)
case core.CodecH265:
handlerFunc = h265.RTPPay(c.PacketSize, handlerFunc)
handlerFunc = h265.RTPDepay(codec, handlerFunc)
}
}
return handlerFunc
+1
View File
@@ -9,6 +9,7 @@ import (
)
// ReceiveMTU = Ethernet MTU (1500) - IP Header (20) - UDP Header (8)
// https://ffmpeg.org/ffmpeg-all.html#Muxer
const ReceiveMTU = 1472
func NewAPI(address string) (*webrtc.API, error) {