mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-05 15:46:58 +08:00
rename Data into Unit (#1556)
This commit is contained in:
@@ -9,21 +9,21 @@ import (
|
||||
"github.com/pion/rtp"
|
||||
)
|
||||
|
||||
// DataOpus is a Opus data unit.
|
||||
type DataOpus struct {
|
||||
// UnitOpus is a Opus data unit.
|
||||
type UnitOpus struct {
|
||||
RTPPackets []*rtp.Packet
|
||||
NTP time.Time
|
||||
PTS time.Duration
|
||||
Frame []byte
|
||||
}
|
||||
|
||||
// GetRTPPackets implements Data.
|
||||
func (d *DataOpus) GetRTPPackets() []*rtp.Packet {
|
||||
// GetRTPPackets implements Unit.
|
||||
func (d *UnitOpus) GetRTPPackets() []*rtp.Packet {
|
||||
return d.RTPPackets
|
||||
}
|
||||
|
||||
// GetNTP implements Data.
|
||||
func (d *DataOpus) GetNTP() time.Time {
|
||||
// GetNTP implements Unit.
|
||||
func (d *UnitOpus) GetNTP() time.Time {
|
||||
return d.NTP
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ func newOpus(
|
||||
return t, nil
|
||||
}
|
||||
|
||||
func (t *formatProcessorOpus) Process(dat Data, hasNonRTSPReaders bool) error { //nolint:dupl
|
||||
tdata := dat.(*DataOpus)
|
||||
func (t *formatProcessorOpus) Process(unit Unit, hasNonRTSPReaders bool) error { //nolint:dupl
|
||||
tunit := unit.(*UnitOpus)
|
||||
|
||||
if tdata.RTPPackets != nil {
|
||||
pkt := tdata.RTPPackets[0]
|
||||
if tunit.RTPPackets != nil {
|
||||
pkt := tunit.RTPPackets[0]
|
||||
|
||||
// remove padding
|
||||
pkt.Header.Padding = false
|
||||
@@ -74,19 +74,19 @@ func (t *formatProcessorOpus) Process(dat Data, hasNonRTSPReaders bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
tdata.Frame = frame
|
||||
tdata.PTS = PTS
|
||||
tunit.Frame = frame
|
||||
tunit.PTS = PTS
|
||||
}
|
||||
|
||||
// route packet as is
|
||||
return nil
|
||||
}
|
||||
|
||||
pkt, err := t.encoder.Encode(tdata.Frame, tdata.PTS)
|
||||
pkt, err := t.encoder.Encode(tunit.Frame, tunit.PTS)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tdata.RTPPackets = []*rtp.Packet{pkt}
|
||||
tunit.RTPPackets = []*rtp.Packet{pkt}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user