client: decode and encode RTP/RTCP packets

This commit is contained in:
aler9
2021-12-04 21:23:34 +01:00
committed by Alessandro Ros
parent 9a0eed07b3
commit b7df36d4ad
26 changed files with 422 additions and 332 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/aler9/gortsplib"
"github.com/aler9/gortsplib/pkg/rtph264"
"github.com/pion/rtp"
)
// This example shows how to
@@ -55,6 +56,7 @@ func main() {
for {
go func() {
buf := make([]byte, 2048)
var pkt rtp.Packet
for {
// read packets from the source
n, _, err := pc.ReadFrom(buf)
@@ -62,8 +64,14 @@ func main() {
break
}
// marshal RTP packets
err = pkt.Unmarshal(buf[:n])
if err != nil {
panic(err)
}
// route RTP packets to the server
err = c.WritePacketRTP(0, buf[:n])
err = c.WritePacketRTP(0, &pkt)
if err != nil {
break
}