Fix support 2 way audio for Reolink Doorbell #331

This commit is contained in:
Alexey Khit
2023-05-03 08:01:33 +03:00
parent c1923627c0
commit 6d9d89bbe3
2 changed files with 42 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
package pcm
import (
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/pion/rtp"
)
func RepackBackchannel(handler core.HandlerFunc) core.HandlerFunc {
var buf []byte
var seq uint16
return func(packet *rtp.Packet) {
buf = append(buf, packet.Payload...)
if len(buf) < 1024 {
return
}
pkt := &rtp.Packet{
Header: rtp.Header{
Version: 2,
Marker: true, // should be true
PayloadType: packet.PayloadType, // will be owerwriten
SequenceNumber: seq,
Timestamp: 0, // should be always zero
SSRC: packet.SSRC,
},
Payload: buf[:1024],
}
handler(pkt)
buf = buf[1024:]
seq++
}
}