1
0
Fork 0
forked from External/mediamtx
mediamtx/internal/core/streamtrack_generic.go
Alessandro Ros 0943b269ab
Decode streams once and only when needed (#1218)
* split data into specialized structs

* move MPEG4-audio decoding into streamTrack

* restore video/audio synchronization in HLS muxer and RTMP server

* log decode errors

* move H264 decoding and re-encoding here from gortsplib

* add tests

* update gortsplib
2022-11-02 20:52:12 +01:00

33 lines
616 B
Go

package core
import (
"fmt"
)
const (
// 1500 (UDP MTU) - 20 (IP header) - 8 (UDP header)
maxPacketSize = 1472
)
type streamTrackGeneric struct{}
func newStreamTrackGeneric() *streamTrackGeneric {
return &streamTrackGeneric{}
}
func (t *streamTrackGeneric) onData(dat data, hasNonRTSPReaders bool) error {
tdata := dat.(*dataGeneric)
pkt := tdata.rtpPackets[0]
// remove padding
pkt.Header.Padding = false
pkt.PaddingSize = 0
if pkt.MarshalSize() > maxPacketSize {
return fmt.Errorf("payload size (%d) is greater than maximum allowed (%d)",
pkt.MarshalSize(), maxPacketSize)
}
return nil
}