client: parse incoming RTP/H264 packets; fix RTCP receiver jitter

This commit is contained in:
aler9
2022-04-07 20:14:45 +02:00
committed by Alessandro Ros
parent 3c104d3727
commit f4efe9ceb5
13 changed files with 174 additions and 128 deletions

View File

@@ -5,8 +5,6 @@ import (
"github.com/aler9/gortsplib"
"github.com/aler9/gortsplib/pkg/base"
"github.com/aler9/gortsplib/pkg/rtph264"
"github.com/pion/rtp"
)
// This example shows how to
@@ -52,10 +50,6 @@ func main() {
panic("H264 track not found")
}
// setup RTP->H264 decoder
rtpDec := &rtph264.Decoder{}
rtpDec.Init()
// setup H264->raw frames decoder
h264dec, err := newH264Decoder()
if err != nil {
@@ -72,18 +66,16 @@ func main() {
}
// called when a RTP packet arrives
c.OnPacketRTP = func(trackID int, pkt *rtp.Packet) {
if trackID != h264TrackID {
c.OnPacketRTP = func(ctx *gortsplib.ClientOnPacketRTPCtx) {
if ctx.TrackID != h264TrackID {
return
}
// convert RTP packet to H264 NALUs
nalus, _, err := rtpDec.Decode(pkt)
if err != nil {
if ctx.H264NALUs == nil {
return
}
for _, nalu := range nalus {
for _, nalu := range ctx.H264NALUs {
// convert H264 NALUs to RGBA frames
img, err := h264dec.decode(nalu)
if err != nil {