gcc

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package gcc implements Google Congestion Control for bandwidth estimation

Index

Constants

This section is empty.

Variables

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

	Usage         usage
	State         state
	TargetBitrate int
	RTT           time.Duration
	TLCC          int

	ECTCount01   uint8
	ECTCount11   uint8
	ECNThreshold float64
	ECNState     state
	ECNUsage     usage
	// contains filtered or unexported fields
}

DelayStats contains some internal statistics of the delay based congestion controller

type ECNBasedBandwidthEstimator added in v0.0.10

type ECNBasedBandwidthEstimator struct {
	ECNRatio float64

	UpdateThreshold time.Duration

	ZeroCounter int
	// contains filtered or unexported fields
}

type ECNStats added in v0.0.10

type ECNStats struct {
	TargetBitrate int
	ECNRatio      float64
	// contains filtered or unexported fields
}

ECNStats contains internal statistics of the ECN based controller

type ECNThreshold added in v0.0.10

type ECNThreshold struct {
	Threshold float64
}

type ECNarrivalGroupAccumulator added in v0.0.10

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

func ECNnewArrivalGroupAccumulator added in v0.0.10

func ECNnewArrivalGroupAccumulator() *ECNarrivalGroupAccumulator

type ECNexponentialMovingAverage added in v0.0.10

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

type ECNoveruseDetector added in v0.0.10

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

type ECNrateController added in v0.0.10

type ECNrateController struct {
	Delaybeta float64
	ECNbeta   float64
	// contains filtered or unexported fields
}

func (*ECNrateController) Adddecrease added in v0.0.10

func (c *ECNrateController) Adddecrease(now time.Time) int

func (*ECNrateController) Addincrease added in v0.0.10

func (c *ECNrateController) Addincrease(now time.Time) int

func (*ECNrateController) Muldecrease added in v0.0.10

func (c *ECNrateController) Muldecrease(Delaybeta float64, ECNbeta float64, now time.Time) int

func (*ECNrateController) Mulincrease added in v0.0.10

func (c *ECNrateController) Mulincrease(Delaybeta float64, ECNbeta float64, now time.Time) int

type FusionUsage added in v0.0.10

type FusionUsage struct {
	Dusage DelayStats
	Eusage DelayStats
	// contains filtered or unexported fields
}

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 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 {
	ECNController *ECNBasedBandwidthEstimator
	// 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

func (e *SendSideBWE) AddStream(info *interceptor.StreamInfo, writer interceptor.RTPWriter) interceptor.RTPWriter

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) GetDelayBitrate added in v0.0.10

func (e *SendSideBWE) GetDelayBitrate() int

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) LogStats added in v0.0.10

func (e *SendSideBWE) LogStats()

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
	ECNStats
}

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