mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-08 00:51:39 +08:00
rename Data into Unit (#1556)
This commit is contained in:
@@ -74,21 +74,21 @@ func rtpH265ExtractVPSSPSPPS(pkt *rtp.Packet) ([]byte, []byte, []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
// DataH265 is a H265 data unit.
|
||||
type DataH265 struct {
|
||||
// UnitH265 is a H265 data unit.
|
||||
type UnitH265 struct {
|
||||
RTPPackets []*rtp.Packet
|
||||
NTP time.Time
|
||||
PTS time.Duration
|
||||
AU [][]byte
|
||||
}
|
||||
|
||||
// GetRTPPackets implements Data.
|
||||
func (d *DataH265) GetRTPPackets() []*rtp.Packet {
|
||||
// GetRTPPackets implements Unit.
|
||||
func (d *UnitH265) GetRTPPackets() []*rtp.Packet {
|
||||
return d.RTPPackets
|
||||
}
|
||||
|
||||
// GetNTP implements Data.
|
||||
func (d *DataH265) GetNTP() time.Time {
|
||||
// GetNTP implements Unit.
|
||||
func (d *UnitH265) GetNTP() time.Time {
|
||||
return d.NTP
|
||||
}
|
||||
|
||||
@@ -219,11 +219,11 @@ func (t *formatProcessorH265) remuxAccessUnit(nalus [][]byte) [][]byte {
|
||||
return filteredNALUs
|
||||
}
|
||||
|
||||
func (t *formatProcessorH265) Process(dat Data, hasNonRTSPReaders bool) error { //nolint:dupl
|
||||
tdata := dat.(*DataH265)
|
||||
func (t *formatProcessorH265) Process(unit Unit, hasNonRTSPReaders bool) error { //nolint:dupl
|
||||
tunit := unit.(*UnitH265)
|
||||
|
||||
if tdata.RTPPackets != nil {
|
||||
pkt := tdata.RTPPackets[0]
|
||||
if tunit.RTPPackets != nil {
|
||||
pkt := tunit.RTPPackets[0]
|
||||
t.updateTrackParametersFromRTPPacket(pkt)
|
||||
|
||||
if t.encoder == nil {
|
||||
@@ -254,7 +254,7 @@ func (t *formatProcessorH265) Process(dat Data, hasNonRTSPReaders bool) error {
|
||||
}
|
||||
|
||||
if t.encoder != nil {
|
||||
tdata.RTPPackets = nil
|
||||
tunit.RTPPackets = nil
|
||||
}
|
||||
|
||||
// DecodeUntilMarker() is necessary, otherwise Encode() generates partial groups
|
||||
@@ -266,9 +266,9 @@ func (t *formatProcessorH265) Process(dat Data, hasNonRTSPReaders bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
tdata.AU = au
|
||||
tdata.PTS = PTS
|
||||
tdata.AU = t.remuxAccessUnit(tdata.AU)
|
||||
tunit.AU = au
|
||||
tunit.PTS = PTS
|
||||
tunit.AU = t.remuxAccessUnit(tunit.AU)
|
||||
}
|
||||
|
||||
// route packet as is
|
||||
@@ -276,18 +276,18 @@ func (t *formatProcessorH265) Process(dat Data, hasNonRTSPReaders bool) error {
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
t.updateTrackParametersFromNALUs(tdata.AU)
|
||||
tdata.AU = t.remuxAccessUnit(tdata.AU)
|
||||
t.updateTrackParametersFromNALUs(tunit.AU)
|
||||
tunit.AU = t.remuxAccessUnit(tunit.AU)
|
||||
}
|
||||
|
||||
if len(tdata.AU) != 0 {
|
||||
pkts, err := t.encoder.Encode(tdata.AU, tdata.PTS)
|
||||
if len(tunit.AU) != 0 {
|
||||
pkts, err := t.encoder.Encode(tunit.AU, tunit.PTS)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tdata.RTPPackets = pkts
|
||||
tunit.RTPPackets = pkts
|
||||
} else {
|
||||
tdata.RTPPackets = nil
|
||||
tunit.RTPPackets = nil
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user