datachannel

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BitrateDuration = 2 * time.Second
	BitrateWindow   = 100 * time.Millisecond
)

Variables

View Source
var ErrDataDroppedBySlowReader = errors.New("data dropped by slow reader")

Functions

This section is empty.

Types

type BitrateCalculator

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

BitrateCalculator calculates bitrate over sliding window

func NewBitrateCalculator

func NewBitrateCalculator(duration time.Duration, window time.Duration) *BitrateCalculator

func (*BitrateCalculator) AddBytes

func (c *BitrateCalculator) AddBytes(bytes int, bufferedAmout int, ts time.Time)

func (*BitrateCalculator) Bitrate

func (c *BitrateCalculator) Bitrate(ts time.Time) int

type BufferedAmountGetter

type BufferedAmountGetter interface {
	BufferedAmount() uint64
}

type DataChannelWriter

type DataChannelWriter[T BufferedAmountGetter] struct {
	// contains filtered or unexported fields
}

func NewDataChannelWriter

func NewDataChannelWriter[T BufferedAmountGetter](bufferGetter T, rawDC datachannel.ReadWriteCloserDeadliner, slowThreshold int) *DataChannelWriter[T]

NewDataChannelWriter creates a new DataChannelWriter by detaching the data channel, when writing to the datachanel times out, it will block and retry if the receiver's bitrate is above the slowThreshold or drop the data if it's below the threshold. If the slowThreshold is 0, it will never retry on write timeout.

func (*DataChannelWriter[T]) BufferedAmountGetter

func (w *DataChannelWriter[T]) BufferedAmountGetter() T

func (*DataChannelWriter[T]) Close

func (w *DataChannelWriter[T]) Close() error

func (*DataChannelWriter[T]) Write

func (w *DataChannelWriter[T]) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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