rtppassthrough

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: AGPL-3.0 Imports: 8 Imported by: 1

Documentation

Overview

Package rtppassthrough defines a Source of RTP packets

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrQueueFull indicates the Buffer's queue is full and that
	// the callback passed to Publish will not be executed.
	ErrQueueFull = errors.New("Buffer Publish queue full")
	// ErrClosed indicates the Buffer is not running.
	ErrClosed = errors.New("Buffer has been closed")
	// ErrBufferSize indicates that the Buffer size
	// can't be less than 0.
	ErrBufferSize = errors.New("Buffer size can't be negative")
)
View Source
var NilSubscription = Subscription{ID: uuid.Nil}

NilSubscription is the value of a nil Subscription.

Functions

func NewSubscription added in v0.27.0

func NewSubscription(size int) (Subscription, *Buffer, error)

NewSubscription allocates an rtppassthrough *Buffer and a Subscription. The *Buffer is intended to be used by the rtppassthrough.Source implemnter. The Subscription is intended to be returned to the SubscribeRTP caller (aka the subscriber). When the Subscription has terminated, the rtppassthrough.Source implemnter should call Close() on the *Buffer to notify the subscriber that the subscription has terminated.

Types

type Buffer added in v0.27.0

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

Buffer executes the callbacks sent to Publish in a single goroutine & drops Publish callbacks if the buffer is full. This is desirable behavior for streaming protocols where dropping stale packets is desirable to minimize latency.

func (*Buffer) Close added in v0.27.0

func (w *Buffer) Close()

Close closes the buffer goroutine and terminates the Subscription.

func (*Buffer) Publish added in v0.27.0

func (w *Buffer) Publish(cb func()) error

Publish publishes adds the callback to the buffer where it will be run in the future. If the buffer is full, it returnns an error and does add the callback to the buffer.

func (*Buffer) Start added in v0.27.0

func (w *Buffer) Start()

Start starts the buffer goroutine.

type PacketCallback

type PacketCallback func(pkts []*rtp.Packet)

PacketCallback is the signature of the SubscribeRTP callback.

type Source

type Source interface {
	// SubscribeRTP begins a subscription to receive RTP packets.
	// When the Subscription terminates the context in the returned Subscription
	// is cancelled
	SubscribeRTP(ctx context.Context, bufferSize int, packetsCB PacketCallback) (Subscription, error)
	// Unsubscribe terminates the subscription with the provided SubscriptionID.
	Unsubscribe(ctx context.Context, id SubscriptionID) error
}

Source is a source of video codec data.

type Subscription added in v0.27.0

type Subscription struct {
	// ID is the ID of the Subscription
	ID SubscriptionID
	// The Terminated context will be cancelled when the RTP Subscription has terminated.
	// A successful call to Unsubscribe terminates the RTP Subscription with that ID
	// An RTP Subscription may also terminate for other internal to the Source
	// (IO errors, reconfiguration, etc)
	Terminated context.Context
}

Subscription is the return value of a call to SubscribeRTP.

type SubscriptionID

type SubscriptionID = uuid.UUID

SubscriptionID is the ID of a Subscription.

Jump to

Keyboard shortcuts

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