Revert configurable packet size for RepackG711
This commit is contained in:
+6
-9
@@ -12,11 +12,8 @@ import (
|
|||||||
// 1. Fixes WebRTC audio quality issue (monotonic timestamp)
|
// 1. Fixes WebRTC audio quality issue (monotonic timestamp)
|
||||||
// 2. Fixes Reolink Doorbell backchannel issue (zero timestamp)
|
// 2. Fixes Reolink Doorbell backchannel issue (zero timestamp)
|
||||||
// https://github.com/AlexxIT/go2rtc/issues/331
|
// https://github.com/AlexxIT/go2rtc/issues/331
|
||||||
func RepackG711(zeroTS bool, size int, handler core.HandlerFunc) core.HandlerFunc {
|
func RepackG711(zeroTS bool, handler core.HandlerFunc) core.HandlerFunc {
|
||||||
packetSize := 1024
|
const PacketSize = 1024
|
||||||
if size > 0 {
|
|
||||||
packetSize = size
|
|
||||||
}
|
|
||||||
|
|
||||||
var buf []byte
|
var buf []byte
|
||||||
var seq uint16
|
var seq uint16
|
||||||
@@ -29,7 +26,7 @@ func RepackG711(zeroTS bool, size int, handler core.HandlerFunc) core.HandlerFun
|
|||||||
mu.Lock()
|
mu.Lock()
|
||||||
|
|
||||||
buf = append(buf, packet.Payload...)
|
buf = append(buf, packet.Payload...)
|
||||||
if len(buf) < packetSize {
|
if len(buf) < PacketSize {
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -42,7 +39,7 @@ func RepackG711(zeroTS bool, size int, handler core.HandlerFunc) core.HandlerFun
|
|||||||
SequenceNumber: seq,
|
SequenceNumber: seq,
|
||||||
SSRC: packet.SSRC,
|
SSRC: packet.SSRC,
|
||||||
},
|
},
|
||||||
Payload: buf[:packetSize],
|
Payload: buf[:PacketSize],
|
||||||
}
|
}
|
||||||
|
|
||||||
seq++
|
seq++
|
||||||
@@ -51,10 +48,10 @@ func RepackG711(zeroTS bool, size int, handler core.HandlerFunc) core.HandlerFun
|
|||||||
// don't have this strange devices for tests
|
// don't have this strange devices for tests
|
||||||
if !zeroTS {
|
if !zeroTS {
|
||||||
pkt.Timestamp = ts
|
pkt.Timestamp = ts
|
||||||
ts += uint32(packetSize)
|
ts += PacketSize
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = buf[packetSize:]
|
buf = buf[PacketSize:]
|
||||||
|
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func (c *Conn) AddTrack(media *core.Media, codec *core.Codec, track *core.Receiv
|
|||||||
|
|
||||||
if c.mode == core.ModeActiveProducer && track.Codec.Name == core.CodecPCMA {
|
if c.mode == core.ModeActiveProducer && track.Codec.Name == core.CodecPCMA {
|
||||||
// Fix Reolink Doorbell https://github.com/AlexxIT/go2rtc/issues/331
|
// Fix Reolink Doorbell https://github.com/AlexxIT/go2rtc/issues/331
|
||||||
sender.Handler = pcm.RepackG711(true, 0, sender.Handler)
|
sender.Handler = pcm.RepackG711(true, sender.Handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.HandleRTP(track)
|
sender.HandleRTP(track)
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ func (c *Conn) AddTrack(media *core.Media, codec *core.Codec, track *core.Receiv
|
|||||||
case core.CodecPCMA, core.CodecPCMU, core.CodecPCM, core.CodecPCML:
|
case core.CodecPCMA, core.CodecPCMU, core.CodecPCM, core.CodecPCML:
|
||||||
// Fix audio quality https://github.com/AlexxIT/WebRTC/issues/500
|
// Fix audio quality https://github.com/AlexxIT/WebRTC/issues/500
|
||||||
// should be before ResampleToG711, because it will be called last
|
// should be before ResampleToG711, because it will be called last
|
||||||
sender.Handler = pcm.RepackG711(false, 0, sender.Handler)
|
sender.Handler = pcm.RepackG711(false, sender.Handler)
|
||||||
|
|
||||||
if codec.ClockRate == 0 {
|
if codec.ClockRate == 0 {
|
||||||
if codec.Name == core.CodecPCM || codec.Name == core.CodecPCML {
|
if codec.Name == core.CodecPCM || codec.Name == core.CodecPCML {
|
||||||
|
|||||||
Reference in New Issue
Block a user