mirror of
https://github.com/harshabose/transcode.git
synced 2025-10-05 23:16:58 +08:00
first-commit
This commit is contained in:
@@ -1 +1,41 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/pion/rtp"
|
||||
)
|
||||
|
||||
type rtpPool struct {
|
||||
pool sync.Pool
|
||||
}
|
||||
|
||||
func (pool *rtpPool) Get() *rtp.Packet {
|
||||
packet, ok := pool.pool.Get().(*rtp.Packet)
|
||||
|
||||
if packet == nil || !ok {
|
||||
return &rtp.Packet{}
|
||||
}
|
||||
return packet
|
||||
}
|
||||
|
||||
func (pool *rtpPool) Put(packet *rtp.Packet) {
|
||||
if packet == nil {
|
||||
return
|
||||
}
|
||||
pool.pool.Put(packet)
|
||||
}
|
||||
|
||||
func (pool *rtpPool) Release() {
|
||||
for {
|
||||
packet, ok := pool.pool.Get().(*rtp.Packet)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if packet == nil {
|
||||
break
|
||||
}
|
||||
|
||||
packet = nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user