Source File
retainable_packet.go
Belonging Package
github.com/pion/interceptor/internal/rtpbuffer
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage rtpbufferimport ()// RetainablePacket is a referenced counted RTP packet.type RetainablePacket struct {onRelease func(*rtp.Header, *[]byte)countMu sync.Mutexcount intheader *rtp.Headerbuffer *[]bytepayload []bytesequenceNumber uint16}// Header returns the RTP Header of the RetainablePacket.func ( *RetainablePacket) () *rtp.Header {return .header}// Payload returns the RTP Payload of the RetainablePacket.func ( *RetainablePacket) () []byte {return .payload}// Retain increases the reference count of the RetainablePacket.func ( *RetainablePacket) () error {.countMu.Lock()defer .countMu.Unlock()if .count == 0 {// already releasedreturn errPacketReleased}.count++return nil}// Release decreases the reference count of the RetainablePacket and frees if needed.func ( *RetainablePacket) () {.countMu.Lock()defer .countMu.Unlock().count--if .count == 0 {// release back to pool.onRelease(.header, .buffer).header = nil.buffer = nil.payload = nil}}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |