move units into dedicated package (#2245)

needed by #2244
This commit is contained in:
Alessandro Ros 2023-08-25 18:11:02 +02:00 committed by GitHub
parent 23ddaac481
commit e0fb11040e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 390 additions and 318 deletions

View file

@ -9,15 +9,9 @@ import (
"github.com/pion/rtp"
"github.com/bluenviron/mediamtx/internal/logger"
"github.com/bluenviron/mediamtx/internal/unit"
)
// UnitMPEG4AudioGeneric is a MPEG-4 Audio data unit.
type UnitMPEG4AudioGeneric struct {
BaseUnit
PTS time.Duration
AUs [][]byte
}
type formatProcessorMPEG4AudioGeneric struct {
udpMaxPayloadSize int
format *formats.MPEG4Audio
@ -58,8 +52,8 @@ func (t *formatProcessorMPEG4AudioGeneric) createEncoder() error {
return t.encoder.Init()
}
func (t *formatProcessorMPEG4AudioGeneric) Process(unit Unit, hasNonRTSPReaders bool) error { //nolint:dupl
tunit := unit.(*UnitMPEG4AudioGeneric)
func (t *formatProcessorMPEG4AudioGeneric) Process(u unit.Unit, hasNonRTSPReaders bool) error { //nolint:dupl
tunit := u.(*unit.MPEG4AudioGeneric)
if tunit.RTPPackets != nil {
pkt := tunit.RTPPackets[0]
@ -109,9 +103,9 @@ func (t *formatProcessorMPEG4AudioGeneric) Process(unit Unit, hasNonRTSPReaders
return nil
}
func (t *formatProcessorMPEG4AudioGeneric) UnitForRTPPacket(pkt *rtp.Packet, ntp time.Time) Unit {
return &UnitMPEG4AudioGeneric{
BaseUnit: BaseUnit{
func (t *formatProcessorMPEG4AudioGeneric) UnitForRTPPacket(pkt *rtp.Packet, ntp time.Time) unit.Unit {
return &unit.MPEG4AudioGeneric{
Base: unit.Base{
RTPPackets: []*rtp.Packet{pkt},
NTP: ntp,
},