sample

package
v0.0.0-...-7d1d8e6 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCannotDetermineMime = errors.New("cannot determine mime")
View Source
var ErrUnsupportedFileType = errors.New("unsupported file type")

Functions

func CreateVideoLoopers

func CreateVideoLoopers(resolution string, codecFilter string, simulcast bool) ([]videoLooper, error)

func ReaderTrackWithFrameDuration

func ReaderTrackWithFrameDuration(duration time.Duration) func(provider *Reader)

func ReaderTrackWithMime

func ReaderTrackWithMime(mime string) func(provider *Reader)

func ReaderTrackWithOnWriteComplete

func ReaderTrackWithOnWriteComplete(f func()) func(provider *Reader)

func ReaderTrackWithRTCPHandler

func ReaderTrackWithRTCPHandler(f func(rtcp.Packet)) func(provider *Reader)

Types

type AudioLooperOpus

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

func CreateAudioLooper

func CreateAudioLooper() (*AudioLooperOpus, error)

func NewAudioLooperOpus

func NewAudioLooperOpus(input io.Reader) (*AudioLooperOpus, error)

func (*AudioLooperOpus) Close

func (l *AudioLooperOpus) Close() error

func (*AudioLooperOpus) Codec

func (l *AudioLooperOpus) Codec() webrtc.RTPCodecCapability

func (*AudioLooperOpus) NextSample

func (l *AudioLooperOpus) NextSample() (media.Sample, error)

func (*AudioLooperOpus) OnBind

func (l *AudioLooperOpus) OnBind() error

func (*AudioLooperOpus) OnUnbind

func (l *AudioLooperOpus) OnUnbind() error

type LocalTrack

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

LocalTrack is a local track that simplifies writing samples. It handles timing and publishing of things, so as long as a SampleProvider is provided, the class takes care of publishing tracks at the right frequency This extends webrtc.TrackLocalStaticSample, and adds the ability to write RTP extensions

func NewLocalFileLooperTrack

func NewLocalFileLooperTrack(file string, options ...LocalTrackOptions) (*LocalTrack, error)

func NewLocalFileReaderTrack

func NewLocalFileReaderTrack(file string, options ...ReaderOption) (*LocalTrack, error)

func NewLocalLooperH264Track

func NewLocalLooperH264Track(input io.ReadCloser, mime string, spec *videoSpec, trackOpts ...LocalTrackOptions) (*LocalTrack, error)

func NewLocalLooperOpusTrack

func NewLocalLooperOpusTrack(input io.ReadCloser, mime string, trackOpts ...LocalTrackOptions) (*LocalTrack, error)

func NewLocalLooperVP8Track

func NewLocalLooperVP8Track(input io.ReadCloser, mime string, spec *videoSpec, trackOpts ...LocalTrackOptions) (*LocalTrack, error)

func NewLocalReaderTrack

func NewLocalReaderTrack(in io.ReadCloser, mime string, options ...ReaderOption) (*LocalTrack, error)

NewLocalReaderTrack uses io.ReadCloser interface to adapt to various ingress types - mime: has to be one of webrtc.MimeType... (e.g. webrtc.MimeTypeOpus)

func NewLocalTrack

func NewLocalTrack(c webrtc.RTPCodecCapability, opts ...LocalTrackOptions) (*LocalTrack, error)

func (*LocalTrack) Bind

func (s *LocalTrack) Bind(t webrtc.TrackLocalContext) (webrtc.RTPCodecParameters, error)

Bind is an interface for TrackLocal, not for external consumption

func (*LocalTrack) Close

func (s *LocalTrack) Close() error

func (*LocalTrack) Codec

func (s *LocalTrack) Codec() webrtc.RTPCodecCapability

Codec gets the Codec of the track

func (*LocalTrack) ID

func (s *LocalTrack) ID() string

ID is the unique identifier for this Track. This should be unique for the stream, but doesn't have to globally unique. A common example would be 'audio' or 'video' and StreamID would be 'desktop' or 'webcam'

func (*LocalTrack) IsBound

func (s *LocalTrack) IsBound() bool

func (*LocalTrack) Kind

func (s *LocalTrack) Kind() webrtc.RTPCodecType

Kind controls if this TrackLocal is audio or video

func (*LocalTrack) OnBind

func (s *LocalTrack) OnBind(f func())

OnBind sets a callback to be called when the track has been negotiated for publishing and bound to a peer connection

func (*LocalTrack) OnUnbind

func (s *LocalTrack) OnUnbind(f func())

OnUnbind sets a callback to be called after the track is removed from a peer connection

func (*LocalTrack) RID

func (s *LocalTrack) RID() string

RID is the RTP stream identifier.

func (*LocalTrack) SetTransceiver

func (s *LocalTrack) SetTransceiver(transceiver *webrtc.RTPTransceiver)

func (*LocalTrack) StartWrite

func (s *LocalTrack) StartWrite(provider sampler, onComplete func()) error

func (*LocalTrack) StreamID

func (s *LocalTrack) StreamID() string

StreamID is the group this track belongs too. This must be unique

func (*LocalTrack) Unbind

func (s *LocalTrack) Unbind(t webrtc.TrackLocalContext) error

Unbind is an interface for TrackLocal, not for external consumption

func (*LocalTrack) WriteSample

func (s *LocalTrack) WriteSample(sample media.Sample, opts *SampleWriteOptions) error

type LocalTrackOptions

type LocalTrackOptions func(s *LocalTrack)

func WithRTCPHandler

func WithRTCPHandler(cb func(rtcp.Packet)) LocalTrackOptions

func WithSimulcast

func WithSimulcast(simulcastID string, layer *rtp2.SimulcastLayer) LocalTrackOptions

WithSimulcast marks the current track for simulcasting. In order to use simulcast, simulcastID must be identical across all layers

func WithStreamID

func WithStreamID(streamID string) LocalTrackOptions

type Looper

type Looper interface {
	Codec() webrtc.RTPCodecCapability
	// contains filtered or unexported methods
}

type Reader

type Reader struct {
	// Configuration
	Mime            string
	FrameDuration   time.Duration
	OnWriteComplete func()
	AudioLevel      uint8
	// contains filtered or unexported fields
}

func (*Reader) Close

func (p *Reader) Close() error

func (*Reader) CurrentAudioLevel

func (p *Reader) CurrentAudioLevel() uint8

func (*Reader) NextSample

func (p *Reader) NextSample() (media.Sample, error)

func (*Reader) OnBind

func (p *Reader) OnBind() error

func (*Reader) OnUnbind

func (p *Reader) OnUnbind() error

type ReaderOption

type ReaderOption func(*Reader)

type SampleWriteOptions

type SampleWriteOptions struct {
	AudioLevel *uint8
}

type VideoLooperH264

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

func NewVideoLooperH264

func NewVideoLooperH264(input io.Reader, spec *videoSpec) (*VideoLooperH264, error)

func (*VideoLooperH264) Close

func (l *VideoLooperH264) Close() error

func (*VideoLooperH264) Codec

func (l *VideoLooperH264) Codec() webrtc.RTPCodecCapability

func (*VideoLooperH264) NextSample

func (l *VideoLooperH264) NextSample() (media.Sample, error)

func (*VideoLooperH264) OnBind

func (l *VideoLooperH264) OnBind() error

func (*VideoLooperH264) OnUnbind

func (l *VideoLooperH264) OnUnbind() error

func (*VideoLooperH264) ToLayer

func (l *VideoLooperH264) ToLayer(quality rtp.VideoQuality) *rtp.SimulcastLayer

type VideoLooperVP8

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

func NewVideoLooperVP8

func NewVideoLooperVP8(input io.Reader, spec *videoSpec) (*VideoLooperVP8, error)

func (*VideoLooperVP8) Close

func (l *VideoLooperVP8) Close() error

func (*VideoLooperVP8) Codec

func (l *VideoLooperVP8) Codec() webrtc.RTPCodecCapability

func (*VideoLooperVP8) NextSample

func (l *VideoLooperVP8) NextSample() (media.Sample, error)

func (*VideoLooperVP8) OnBind

func (l *VideoLooperVP8) OnBind() error

func (*VideoLooperVP8) OnUnbind

func (l *VideoLooperVP8) OnUnbind() error

func (*VideoLooperVP8) ToLayer

func (l *VideoLooperVP8) ToLayer(quality rtp.VideoQuality) *rtp.SimulcastLayer

Jump to

Keyboard shortcuts

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