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

Method WriteRTPFrame

track/av1.go:51–86  ·  view source on GitHub ↗
(rtpItem *LIRTP)

Source from the content-addressed store, hash-verified

49}
50
51func (vt *AV1) WriteRTPFrame(rtpItem *LIRTP) {
52 defer func() {
53 err := recover()
54 if err != nil {
55 vt.Error("WriteRTPFrame panic", zap.Any("err", err))
56 vt.Publisher.Stop(zap.Any("err", err))
57 }
58 }()
59 if vt.lastSeq != vt.lastSeq2+1 && vt.lastSeq2 != 0 {
60 vt.lostFlag = true
61 vt.Warn("lost rtp packet", zap.Uint16("lastSeq", vt.lastSeq), zap.Uint16("lastSeq2", vt.lastSeq2))
62 }
63 frame := &rtpItem.Value
64 rv := vt.Value
65 rv.RTP.Push(rtpItem)
66 obus, err := vt.decoder.Decode(frame.Packet)
67 for _, obu := range obus {
68 var obuHeader av1.OBUHeader
69 obuHeader.Unmarshal(obu)
70 switch obuHeader.Type {
71 case av1.OBUTypeSequenceHeader:
72 rtmpHead := []byte{0b1001_0000 | byte(codec.PacketTypeMPEG2TSSequenceStart), 0, 0, 0, 0}
73 util.BigEndian.PutUint32(rtmpHead[1:], codec.FourCC_AV1_32)
74 // TODO: 生成 head
75 rtmpHead = append(rtmpHead, obu...)
76 vt.Video.WriteSequenceHead(rtmpHead)
77 vt.ParamaterSets[0] = obu
78 default:
79 rv.AUList.Push(vt.BytesPool.GetShell(obu))
80 }
81 }
82 if err == nil {
83 vt.generateTimestamp(frame.Timestamp)
84 vt.Flush()
85 }
86}
87
88func (vt *AV1) writeAVCCFrame(ts uint32, r *util.BLLReader, frame *util.BLL) (err error) {
89 vt.Value.PTS = time.Duration(ts) * 90

Callers

nothing calls this directly

Calls 11

GetShellMethod · 0.80
ErrorMethod · 0.65
StopMethod · 0.65
WarnMethod · 0.65
PushMethod · 0.65
UnmarshalMethod · 0.65
WriteSequenceHeadMethod · 0.65
generateTimestampMethod · 0.65
FlushMethod · 0.65
Uint16Method · 0.45
PutUint32Method · 0.45

Tested by

no test coverage detected