split RTP packet handling from data handling (#2337)

This commit is contained in:
Alessandro Ros
2023-09-16 17:16:33 +02:00
committed by GitHub
parent f786f64690
commit c4cb4200ff
20 changed files with 656 additions and 654 deletions

View File

@@ -28,29 +28,32 @@ func newGeneric(
}, nil
}
func (t *formatProcessorGeneric) Process(u unit.Unit, _ bool) error {
tunit := u.(*unit.Generic)
pkt := tunit.RTPPackets[0]
// remove padding
pkt.Header.Padding = false
pkt.PaddingSize = 0
if pkt.MarshalSize() > t.udpMaxPayloadSize {
return fmt.Errorf("payload size (%d) is greater than maximum allowed (%d)",
pkt.MarshalSize(), t.udpMaxPayloadSize)
}
return nil
func (t *formatProcessorGeneric) ProcessUnit(_ unit.Unit) error {
return fmt.Errorf("using a generic unit without RTP is not supported")
}
func (t *formatProcessorGeneric) UnitForRTPPacket(pkt *rtp.Packet, ntp time.Time, pts time.Duration) Unit {
return &unit.Generic{
func (t *formatProcessorGeneric) ProcessRTPPacket(
pkt *rtp.Packet,
ntp time.Time,
pts time.Duration,
_ bool,
) (Unit, error) {
u := &unit.Generic{
Base: unit.Base{
RTPPackets: []*rtp.Packet{pkt},
NTP: ntp,
PTS: pts,
},
}
// remove padding
pkt.Header.Padding = false
pkt.PaddingSize = 0
if pkt.MarshalSize() > t.udpMaxPayloadSize {
return nil, fmt.Errorf("payload size (%d) is greater than maximum allowed (%d)",
pkt.MarshalSize(), t.udpMaxPayloadSize)
}
return u, nil
}