update dependencies (#2113)

This commit is contained in:
Alessandro Ros 2023-07-28 00:06:58 +02:00 committed by GitHub
parent 583fee26f6
commit e4bd1b35a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 225 additions and 290 deletions

View file

@ -6,6 +6,7 @@ import (
"github.com/bluenviron/gortsplib/v3/pkg/formats"
"github.com/bluenviron/gortsplib/v3/pkg/formats/rtpsimpleaudio"
"github.com/bluenviron/mediacommon/pkg/codecs/opus"
"github.com/pion/rtp"
"github.com/bluenviron/mediamtx/internal/logger"
@ -16,7 +17,7 @@ type UnitOpus struct {
RTPPackets []*rtp.Packet
NTP time.Time
PTS time.Duration
Frame []byte
Packets [][]byte
}
// GetRTPPackets implements Unit.
@ -91,12 +92,12 @@ func (t *formatProcessorOpus) Process(unit Unit, hasNonRTSPReaders bool) error {
}
}
frame, pts, err := t.decoder.Decode(pkt)
packet, pts, err := t.decoder.Decode(pkt)
if err != nil {
return err
}
tunit.Frame = frame
tunit.Packets = [][]byte{packet}
tunit.PTS = pts
}
@ -105,11 +106,18 @@ func (t *formatProcessorOpus) Process(unit Unit, hasNonRTSPReaders bool) error {
}
// encode into RTP
pkt, err := t.encoder.Encode(tunit.Frame, tunit.PTS)
if err != nil {
return err
var rtpPackets []*rtp.Packet //nolint:prealloc
pts := tunit.PTS
for _, packet := range tunit.Packets {
pkt, err := t.encoder.Encode(packet, pts)
if err != nil {
return err
}
rtpPackets = append(rtpPackets, pkt)
pts += opus.PacketDuration(packet)
}
tunit.RTPPackets = []*rtp.Packet{pkt}
tunit.RTPPackets = rtpPackets
return nil
}