forked from External/mediamtx
srt: fix memory leak during reader disconnection (#2273)
This commit is contained in:
parent
fc353ce66b
commit
95baade478
5 changed files with 60 additions and 58 deletions
|
|
@ -161,6 +161,25 @@ func (s *udpSource) runReader(pc net.PacketConn) error {
|
|||
var medi *description.Media
|
||||
|
||||
switch tcodec := track.Codec.(type) {
|
||||
case *mpegts.CodecH265:
|
||||
medi = &description.Media{
|
||||
Type: description.MediaTypeVideo,
|
||||
Formats: []format.Format{&format.H265{
|
||||
PayloadTyp: 96,
|
||||
}},
|
||||
}
|
||||
|
||||
r.OnDataH26x(track, func(pts int64, _ int64, au [][]byte) error {
|
||||
stream.WriteUnit(medi, medi.Formats[0], &unit.H265{
|
||||
Base: unit.Base{
|
||||
NTP: time.Now(),
|
||||
PTS: decodeTime(pts),
|
||||
},
|
||||
AU: au,
|
||||
})
|
||||
return nil
|
||||
})
|
||||
|
||||
case *mpegts.CodecH264:
|
||||
medi = &description.Media{
|
||||
Type: description.MediaTypeVideo,
|
||||
|
|
@ -181,21 +200,22 @@ func (s *udpSource) runReader(pc net.PacketConn) error {
|
|||
return nil
|
||||
})
|
||||
|
||||
case *mpegts.CodecH265:
|
||||
case *mpegts.CodecOpus:
|
||||
medi = &description.Media{
|
||||
Type: description.MediaTypeVideo,
|
||||
Formats: []format.Format{&format.H265{
|
||||
Type: description.MediaTypeAudio,
|
||||
Formats: []format.Format{&format.Opus{
|
||||
PayloadTyp: 96,
|
||||
IsStereo: (tcodec.ChannelCount == 2),
|
||||
}},
|
||||
}
|
||||
|
||||
r.OnDataH26x(track, func(pts int64, _ int64, au [][]byte) error {
|
||||
stream.WriteUnit(medi, medi.Formats[0], &unit.H265{
|
||||
r.OnDataOpus(track, func(pts int64, packets [][]byte) error {
|
||||
stream.WriteUnit(medi, medi.Formats[0], &unit.Opus{
|
||||
Base: unit.Base{
|
||||
NTP: time.Now(),
|
||||
PTS: decodeTime(pts),
|
||||
},
|
||||
AU: au,
|
||||
Packets: packets,
|
||||
})
|
||||
return nil
|
||||
})
|
||||
|
|
@ -223,26 +243,6 @@ func (s *udpSource) runReader(pc net.PacketConn) error {
|
|||
return nil
|
||||
})
|
||||
|
||||
case *mpegts.CodecOpus:
|
||||
medi = &description.Media{
|
||||
Type: description.MediaTypeAudio,
|
||||
Formats: []format.Format{&format.Opus{
|
||||
PayloadTyp: 96,
|
||||
IsStereo: (tcodec.ChannelCount == 2),
|
||||
}},
|
||||
}
|
||||
|
||||
r.OnDataOpus(track, func(pts int64, packets [][]byte) error {
|
||||
stream.WriteUnit(medi, medi.Formats[0], &unit.Opus{
|
||||
Base: unit.Base{
|
||||
NTP: time.Now(),
|
||||
PTS: decodeTime(pts),
|
||||
},
|
||||
Packets: packets,
|
||||
})
|
||||
return nil
|
||||
})
|
||||
|
||||
case *mpegts.CodecMPEG1Audio:
|
||||
medi = &description.Media{
|
||||
Type: description.MediaTypeAudio,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue