mirror of
https://github.com/harshabose/transcode.git
synced 2025-10-06 02:06:50 +08:00
first-commit
This commit is contained in:
@@ -1 +1,43 @@
|
|||||||
package internal
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/asticode/go-astiav"
|
||||||
|
)
|
||||||
|
|
||||||
|
type framePool struct {
|
||||||
|
pool sync.Pool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pool *framePool) Get() *astiav.Frame {
|
||||||
|
frame, ok := pool.pool.Get().(*astiav.Frame)
|
||||||
|
|
||||||
|
if frame == nil || !ok {
|
||||||
|
return astiav.AllocFrame()
|
||||||
|
}
|
||||||
|
return frame
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pool *framePool) Put(frame *astiav.Frame) {
|
||||||
|
if frame == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
frame.Unref()
|
||||||
|
pool.pool.Put(frame)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pool *framePool) Release() {
|
||||||
|
for {
|
||||||
|
frame, ok := pool.pool.Get().(*astiav.Frame)
|
||||||
|
if frame == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
frame.Free()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -1 +1,43 @@
|
|||||||
package internal
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/asticode/go-astiav"
|
||||||
|
)
|
||||||
|
|
||||||
|
type packetPool struct {
|
||||||
|
pool sync.Pool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pool *packetPool) Get() *astiav.Packet {
|
||||||
|
packet, ok := pool.pool.Get().(*astiav.Packet)
|
||||||
|
|
||||||
|
if packet == nil || !ok {
|
||||||
|
return astiav.AllocPacket()
|
||||||
|
}
|
||||||
|
return packet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pool *packetPool) Put(packet *astiav.Packet) {
|
||||||
|
if packet == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
packet.Unref()
|
||||||
|
pool.pool.Put(packet)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pool *packetPool) Release() {
|
||||||
|
for {
|
||||||
|
packet, ok := pool.pool.Get().(*astiav.Packet)
|
||||||
|
if packet == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
packet.Free()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -1 +1,41 @@
|
|||||||
package internal
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -1 +1,41 @@
|
|||||||
package internal
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/pion/webrtc/v4/pkg/media"
|
||||||
|
)
|
||||||
|
|
||||||
|
type samplePool struct {
|
||||||
|
pool sync.Pool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pool *samplePool) Get() *media.Sample {
|
||||||
|
packet, ok := pool.pool.Get().(*media.Sample)
|
||||||
|
|
||||||
|
if packet == nil || !ok {
|
||||||
|
return &media.Sample{}
|
||||||
|
}
|
||||||
|
return packet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pool *samplePool) Put(sample *media.Sample) {
|
||||||
|
if sample == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pool.pool.Put(sample)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pool *samplePool) Release() {
|
||||||
|
for {
|
||||||
|
sample, ok := pool.pool.Get().(*media.Sample)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if sample == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
sample = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -109,8 +109,8 @@ func (decoder *Decoder) PutBack(frame *astiav.Frame) {
|
|||||||
decoder.buffer.PutBack(frame)
|
decoder.buffer.PutBack(frame)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (decoder *Decoder) GetSrcFilterContextOptions() func(filter types.BaseFilter) error {
|
func (decoder *Decoder) GetSrcFilterContextOptions() func(filter *Filter) error {
|
||||||
return filt.VideoSetFilterContextParameters(decoder.decoderContext)
|
return VideoSetFilterContextParameters(decoder.decoderContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (decoder *Decoder) close() {
|
func (decoder *Decoder) close() {
|
||||||
|
Reference in New Issue
Block a user