VideoFrame和AudioFrame增加track的指针方便访问track,rtp写入采用内存复用机制

This commit is contained in:
dexter
2023-02-26 10:36:37 +08:00
parent 4d008cfc5e
commit fd2c7b8cb6
11 changed files with 78 additions and 110 deletions

View File

@@ -21,26 +21,27 @@ func SplitAnnexB[T ~[]byte](frame T, process func(T), delimiter []byte) {
}
type RTPFrame struct {
rtp.Packet
*rtp.Packet
Raw []byte
}
func (rtp *RTPFrame) Clone() *RTPFrame {
return &RTPFrame{*rtp.Packet.Clone()}
func (r *RTPFrame) H264Type() (naluType codec.H264NALUType) {
return naluType.Parse(r.Payload[0])
}
func (r *RTPFrame) H265Type() (naluType codec.H265NALUType) {
return naluType.Parse(r.Payload[0])
}
func (rtp *RTPFrame) H264Type() (naluType codec.H264NALUType) {
return naluType.Parse(rtp.Payload[0])
}
func (rtp *RTPFrame) H265Type() (naluType codec.H265NALUType) {
return naluType.Parse(rtp.Payload[0])
}
func (rtp *RTPFrame) Unmarshal(raw []byte) *RTPFrame {
if err := rtp.Packet.Unmarshal(raw); err != nil {
func (r *RTPFrame) Unmarshal(raw []byte) *RTPFrame {
if r.Packet == nil {
r.Packet = &rtp.Packet{}
}
r.Raw = raw
if err := r.Packet.Unmarshal(raw); err != nil {
log.Error(err)
return nil
}
return rtp
return r
}
type BaseFrame struct {