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

Method WriteAVCCAudio

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

Source from the content-addressed store, hash-verified

119}
120
121func (p *Publisher) WriteAVCCAudio(ts uint32, frame *util.BLL, pool util.BytesPool) {
122 if frame.ByteLength < 4 {
123 return
124 }
125 if p.AudioTrack == nil {
126 b0 := frame.GetByte(0)
127 t := p.CreateAudioTrack(codec.AudioCodecID(b0>>4), pool)
128 switch a := t.(type) {
129 case *track.AAC:
130 if frame.GetByte(1) != 0 {
131 return
132 }
133 a.AVCCHead = []byte{frame.GetByte(0), 1}
134 a.WriteAVCC(0, frame)
135 case *track.G711:
136 a.Audio.SampleRate = uint32(codec.SoundRate[(b0&0x0c)>>2])
137 if b0&0x02 == 0 {
138 a.Audio.SampleSize = 8
139 }
140 a.Channels = b0&0x01 + 1
141 a.AVCCHead = []byte{b0}
142 a.WriteAVCC(ts, frame)
143 default:
144 p.Stream.Error("audio codec not support yet", zap.Uint8("codecId", uint8(codec.AudioCodecID(b0>>4))))
145 }
146 } else {
147 p.AudioTrack.WriteAVCC(ts, frame)
148 }
149}

Callers

nothing calls this directly

Calls 5

CreateAudioTrackMethod · 0.95
AudioCodecIDTypeAlias · 0.92
GetByteMethod · 0.80
WriteAVCCMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected