MCPcopy Create free account
hub / github.com/Monibuca/engine / WriteAVCCVideo

Method WriteAVCCVideo

publisher.go:86–119  ·  view source on GitHub ↗
(ts uint32, frame *util.BLL, pool util.BytesPool)

Source from the content-addressed store, hash-verified

84}
85
86func (p *Publisher) WriteAVCCVideo(ts uint32, frame *util.BLL, pool util.BytesPool) {
87 if frame.ByteLength < 6 {
88 return
89 }
90 if p.VideoTrack == nil {
91 b0 := frame.GetByte(0)
92 // https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
93 if isExtHeader := b0 & 0b1000_0000; isExtHeader != 0 {
94 fourCC := frame.GetUintN(1, 4)
95 switch fourCC {
96 case codec.FourCC_H265_32:
97 p.VideoTrack = track.NewH265(p, pool)
98 p.VideoTrack.WriteAVCC(ts, frame)
99 case codec.FourCC_AV1_32:
100 p.VideoTrack = track.NewAV1(p, pool)
101 p.VideoTrack.WriteAVCC(ts, frame)
102 }
103 } else {
104 if frame.GetByte(1) == 0 {
105 ts = 0
106 p.CreateVideoTrack(codec.VideoCodecID(b0&0x0F), pool)
107 if p.VideoTrack == nil {
108 p.Stream.Error("video codecID not support", zap.Uint8("codeId", uint8(codec.VideoCodecID(b0&0x0F))))
109 return
110 }
111 p.VideoTrack.WriteAVCC(ts, frame)
112 } else {
113 p.Stream.Warn("need sequence frame")
114 }
115 }
116 } else {
117 p.VideoTrack.WriteAVCC(ts, frame)
118 }
119}
120
121func (p *Publisher) WriteAVCCAudio(ts uint32, frame *util.BLL, pool util.BytesPool) {
122 if frame.ByteLength < 4 {

Callers

nothing calls this directly

Calls 9

CreateVideoTrackMethod · 0.95
NewH265Function · 0.92
NewAV1Function · 0.92
VideoCodecIDTypeAlias · 0.92
GetByteMethod · 0.80
GetUintNMethod · 0.80
WriteAVCCMethod · 0.65
ErrorMethod · 0.65
WarnMethod · 0.65

Tested by

no test coverage detected