gcc

package
v0.1.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2022 License: MIT Imports: 12 Imported by: 28

Documentation

Overview

Package gcc implements Google Congestion Control for bandwidth estimation

Index

Constants

This section is empty.

Variables

View Source
var ErrSendSideBWEClosed = errors.New("SendSideBwe closed")

ErrSendSideBWEClosed is raised when SendSideBWE.WriteRTCP is called after SendSideBWE.Close

View Source
var ErrUnknownStream = errors.New("unknown ssrc")

ErrUnknownStream is returned when trying to send a packet with a SSRC that was never registered with any stream

Functions

This section is empty.

Types

type DelayStats

type DelayStats struct {
	Measurement      time.Duration
	Estimate         time.Duration
	Threshold        time.Duration
	LastReceiveDelta time.Duration

	Usage         usage
	State         state
	TargetBitrate int
}

DelayStats contains some internal statistics of the delay based congestion controller

type LeakyBucketPacer

type LeakyBucketPacer struct {
	// contains filtered or unexported fields
}

LeakyBucketPacer implements a leaky bucket pacing algorithm

func NewLeakyBucketPacer

func NewLeakyBucketPacer(initialBitrate int) *LeakyBucketPacer

NewLeakyBucketPacer initializes a new LeakyBucketPacer

func (*LeakyBucketPacer) AddStream

func (p *LeakyBucketPacer) AddStream(ssrc uint32, writer interceptor.RTPWriter)

AddStream adds a new stream and its corresponding writer to the pacer

func (*LeakyBucketPacer) Close

func (p *LeakyBucketPacer) Close() error

Close closes the LeakyBucketPacer

func (*LeakyBucketPacer) Run

func (p *LeakyBucketPacer) Run()

Run starts the LeakyBucketPacer

func (*LeakyBucketPacer) SetTargetBitrate

func (p *LeakyBucketPacer) SetTargetBitrate(rate int)

SetTargetBitrate updates the target bitrate at which the pacer is allowed to send packets. The pacer may exceed this limit by p.f

func (*LeakyBucketPacer) Write

func (p *LeakyBucketPacer) Write(header *rtp.Header, payload []byte, attributes interceptor.Attributes) (int, error)

Write sends a packet with header and payload the a previously registered stream.

type LossStats

type LossStats struct {
	TargetBitrate int
	AverageLoss   float64
}

LossStats contains internal statistics of the loss based controller

type NoOpPacer

type NoOpPacer struct {
	// contains filtered or unexported fields
}

NoOpPacer implements a pacer that always immediately sends incoming packets

func NewNoOpPacer

func NewNoOpPacer() *NoOpPacer

NewNoOpPacer initializes a new NoOpPacer

func (*NoOpPacer) AddStream

func (p *NoOpPacer) AddStream(ssrc uint32, writer interceptor.RTPWriter)

AddStream adds a stream and corresponding writer to the p

func (*NoOpPacer) Close

func (p *NoOpPacer) Close() error

Close closes p

func (*NoOpPacer) SetTargetBitrate

func (p *NoOpPacer) SetTargetBitrate(int)

SetTargetBitrate sets the bitrate at which the pacer sends data. NoOp for NoOp pacer.

func (*NoOpPacer) Write

func (p *NoOpPacer) Write(header *rtp.Header, payload []byte, attributes interceptor.Attributes) (int, error)

Write sends a packet with header and payload to a previously added stream

type Option

type Option func(*SendSideBWE) error

Option configures a bandwidth estimator

func SendSideBWEInitialBitrate

func SendSideBWEInitialBitrate(rate int) Option

SendSideBWEInitialBitrate sets the initial bitrate of new GCC interceptors

func SendSideBWEMaxBitrate added in v0.1.12

func SendSideBWEMaxBitrate(rate int) Option

SendSideBWEMaxBitrate sets the initial bitrate of new GCC interceptors

func SendSideBWEMinBitrate added in v0.1.12

func SendSideBWEMinBitrate(rate int) Option

SendSideBWEMinBitrate sets the initial bitrate of new GCC interceptors

func SendSideBWEPacer

func SendSideBWEPacer(p Pacer) Option

SendSideBWEPacer sets the pacing algorithm to use.

type Pacer

type Pacer interface {
	interceptor.RTPWriter
	AddStream(ssrc uint32, writer interceptor.RTPWriter)
	SetTargetBitrate(int)
	Close() error
}

Pacer is the interface implemented by packet pacers

type SendSideBWE

type SendSideBWE struct {
	// contains filtered or unexported fields
}

SendSideBWE implements a combination of loss and delay based GCC

func NewSendSideBWE

func NewSendSideBWE(opts ...Option) (*SendSideBWE, error)

NewSendSideBWE creates a new sender side bandwidth estimator

func (*SendSideBWE) AddStream

AddStream adds a new stream to the bandwidth estimator

func (*SendSideBWE) Close

func (e *SendSideBWE) Close() error

Close stops and closes the bandwidth estimator

func (*SendSideBWE) GetStats

func (e *SendSideBWE) GetStats() map[string]interface{}

GetStats returns some internal statistics of the bandwidth estimator

func (*SendSideBWE) GetTargetBitrate

func (e *SendSideBWE) GetTargetBitrate() int

GetTargetBitrate returns the current target bitrate in bits per second

func (*SendSideBWE) OnTargetBitrateChange

func (e *SendSideBWE) OnTargetBitrateChange(f func(bitrate int))

OnTargetBitrateChange sets the callback that is called when the target bitrate in bits per second changes

func (*SendSideBWE) WriteRTCP

func (e *SendSideBWE) WriteRTCP(pkts []rtcp.Packet, attributes interceptor.Attributes) error

WriteRTCP adds some RTCP feedback to the bandwidth estimator

type Stats

type Stats struct {
	LossStats
	DelayStats
}

Stats contains internal statistics of the bandwidth estimator

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL