feat: remove RecyclableMemory

This commit is contained in:
langhuihui
2024-05-21 15:19:04 +08:00
parent 5c52a159e0
commit 82deb3fbaa
25 changed files with 749 additions and 713 deletions

View File

@@ -15,7 +15,7 @@ import (
type RTPData struct {
*webrtc.RTPCodecParameters
Packets []*rtp.Packet
util.RecyclableMemory
util.RecyclableBuffers
}
func (r *RTPData) String() (s string) {
@@ -70,22 +70,23 @@ func (r *RTPCtx) GetSequenceFrame() IAVFrame {
}
func (r *RTPData) DecodeConfig(t *AVTrack, from ICodecCtx) (err error) {
switch fourCC := from.FourCC(); fourCC {
case codec.FourCC_H264:
h264ctx := from.(codec.IH264Ctx).GetH264Ctx()
switch c := from.(type) {
case codec.IH264Ctx:
var ctx RTPH264Ctx
ctx.H264Ctx = *h264ctx
ctx.H264Ctx = *c.GetH264Ctx()
ctx.PayloadType = 96
ctx.MimeType = webrtc.MimeTypeH264
ctx.ClockRate = 90000
spsInfo := h264ctx.SPSInfo
spsInfo := ctx.SPSInfo
ctx.SDPFmtpLine = fmt.Sprintf("profile-level-id=%02x%02x%02x;level-asymmetry-allowed=1;packetization-mode=1", spsInfo.ProfileIdc, spsInfo.ConstraintSetFlag, spsInfo.LevelIdc)
ctx.SSRC = uint32(uintptr(unsafe.Pointer(&ctx)))
t.ICodecCtx = &ctx
case codec.FourCC_H265:
h265ctx := from.(codec.IH265Ctx).GetH265Ctx()
case codec.IH265Ctx:
var ctx RTPH265Ctx
ctx.H265Ctx = *h265ctx
ctx.H265Ctx = *c.GetH265Ctx()
ctx.PayloadType = 98
ctx.MimeType = webrtc.MimeTypeH265
ctx.ClockRate = 90000
ctx.SSRC = uint32(uintptr(unsafe.Pointer(&ctx)))
t.ICodecCtx = &ctx
}

View File

@@ -96,6 +96,14 @@ func (r *RTPVideo) Parse(t *AVTrack) (isIDR, isSeq bool, raw any, err error) {
return
}
func (h264 *RTPH264Ctx) GetInfo() string {
return h264.SDPFmtpLine
}
func (h265 *RTPH265Ctx) GetInfo() string {
return h265.SDPFmtpLine
}
func (h264 *RTPH264Ctx) CreateFrame(from *AVFrame) (frame IAVFrame, err error) {
var r RTPVideo
r.ScalableMemoryAllocator = from.Wraps[0].GetScalableMemoryAllocator()