forked from AlexxIT/go2rtc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix support 2 way audio for Reolink Doorbell AlexxIT#331
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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++ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters