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

Method WriteADTS

track/aac.go:39–66  ·  view source on GitHub ↗
(ts uint32, b util.IBytes)

Source from the content-addressed store, hash-verified

37}
38
39func (aac *AAC) WriteADTS(ts uint32, b util.IBytes) {
40 adts := b.Bytes()
41 if aac.SequenceHead == nil {
42 profile := ((adts[2] & 0xc0) >> 6) + 1
43 sampleRate := (adts[2] & 0x3c) >> 2
44 channel := ((adts[2] & 0x1) << 2) | ((adts[3] & 0xc0) >> 6)
45 config1 := (profile << 3) | ((sampleRate & 0xe) >> 1)
46 config2 := ((sampleRate & 0x1) << 7) | (channel << 3)
47 aac.Media.WriteSequenceHead([]byte{0xAF, 0x00, config1, config2})
48 aac.SampleRate = uint32(codec.SamplingFrequencies[sampleRate])
49 aac.Channels = channel
50 aac.Parse(aac.SequenceHead[2:])
51 aac.iframeReceived = true
52 aac.Attach()
53 }
54 aac.generateTimestamp(ts)
55 frameLen := (int(adts[3]&3) << 11) | (int(adts[4]) << 3) | (int(adts[5]) >> 5)
56 for len(adts) >= frameLen {
57 aac.Value.AUList.Push(aac.BytesPool.GetShell(adts[7:frameLen]))
58 adts = adts[frameLen:]
59 if len(adts) < 7 {
60 break
61 }
62 frameLen = (int(adts[3]&3) << 11) | (int(adts[4]) << 3) | (int(adts[5]) >> 5)
63 }
64 aac.Value.ADTS = aac.GetFromPool(b)
65 aac.Flush()
66}
67
68// https://datatracker.ietf.org/doc/html/rfc3640#section-3.2.1
69func (aac *AAC) WriteRTPFrame(rtpItem *LIRTP) {

Callers

nothing calls this directly

Calls 9

GetShellMethod · 0.80
BytesMethod · 0.65
WriteSequenceHeadMethod · 0.65
AttachMethod · 0.65
generateTimestampMethod · 0.65
PushMethod · 0.65
GetFromPoolMethod · 0.65
FlushMethod · 0.65
ParseMethod · 0.45

Tested by

no test coverage detected