type H264 struct { // RTP payload type (96–127 or 35). PayloadTyp uint8 // Sequence Parameter Set, parsed from sprop-parameter-sets in SDP. // May be nil if not present in SDP. SPS []byte // Picture Parameter Set, parsed from sprop-parameter-sets in SDP. // May be nil if not present in SDP. PPS []byte // Packetization mode (0, 1, or 2). Use 1 for most cameras and encoders. PacketizationMode int}
// find the H264 media and formatvar forma *format.H264medi := desc.FindFormat(&forma)if medi == nil { panic("media not found")}// setup RTP -> H264 decoderrtpDec, err := forma.CreateDecoder()if err != nil { panic(err)}// if SPS and PPS are present in the SDP, send them to any downstream decoderif forma.SPS != nil { // process forma.SPS}if forma.PPS != nil { // process forma.PPS}_, err = c.Setup(desc.BaseURL, medi, 0, 0)if err != nil { panic(err)}c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { pts, ok := c.PacketPTS(medi, pkt) if !ok { return } au, err := rtpDec.Decode(pkt) if err != nil { if err != rtph264.ErrNonStartingPacketAndNoPrevious && err != rtph264.ErrMorePacketsNeeded { log.Printf("ERR: %v", err) } return } // au is [][]byte — a slice of NAL units log.Printf("received H264 access unit with PTS %v, %d NAL units", pts, len(au))})
rtph264.ErrNonStartingPacketAndNoPrevious and rtph264.ErrMorePacketsNeeded are non-fatal: the decoder is waiting for more packets to reassemble a complete access unit.
type H265 struct { // RTP payload type (96–127). PayloadTyp uint8 // Video Parameter Set, parsed from sprop-vps in SDP. May be nil. VPS []byte // Sequence Parameter Set, parsed from sprop-sps in SDP. May be nil. SPS []byte // Picture Parameter Set, parsed from sprop-pps in SDP. May be nil. PPS []byte // Maximum Decoding Order Number Difference. MaxDONDiff int}
// find the H265 media and formatvar forma *format.H265medi := desc.FindFormat(&forma)if medi == nil { panic("media not found")}// setup RTP -> H265 decoderrtpDec, err := forma.CreateDecoder()if err != nil { panic(err)}// if VPS, SPS and PPS are present in the SDP, pass them to any downstream decoderif forma.VPS != nil { // process forma.VPS}if forma.SPS != nil { // process forma.SPS}if forma.PPS != nil { // process forma.PPS}_, err = c.Setup(desc.BaseURL, medi, 0, 0)if err != nil { panic(err)}c.OnPacketRTP(medi, forma, func(pkt *rtp.Packet) { pts, ok := c.PacketPTS(medi, pkt) if !ok { return } au, err := rtpDec.Decode(pkt) if err != nil { if err != rtph265.ErrNonStartingPacketAndNoPrevious && err != rtph265.ErrMorePacketsNeeded { log.Printf("ERR: %v", err) } return } // au is [][]byte — a slice of NAL units log.Printf("received H265 access unit with PTS %v, %d NAL units", pts, len(au))})
AV1
Package path:github.com/bluenviron/gortsplib/v5/pkg/formatSpecification: RTP Payload Format For AV1 (v1.0)
type AV1 struct { // RTP payload type (96–127). PayloadTyp uint8 // Optional AV1 level index from the fmtp line. LevelIdx *int // Optional AV1 profile from the fmtp line. Profile *int // Optional AV1 tier from the fmtp line. Tier *int}
type VP9 struct { // RTP payload type (96–127). PayloadTyp uint8 // Optional maximum frame rate from fmtp. MaxFR *int // Optional maximum frame size from fmtp. MaxFS *int // Optional VP9 profile ID from fmtp. ProfileID *int}
type VP8 struct { // RTP payload type (96–127). PayloadTyp uint8 // Optional maximum frame rate from fmtp. MaxFR *int // Optional maximum frame size from fmtp. MaxFS *int}
type MPEG4Video struct { // RTP payload type (96–127). PayloadTyp uint8 // Profile and level indication. Defaults to 1. ProfileLevelID int // Decoder configuration, parsed from the config fmtp parameter. Config []byte}