media

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultOpusSampleRate     = 48000
	DefaultOpusSampleDuration = 20 * time.Millisecond
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomDecryptor

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

func NewCustomDecryptor

func NewCustomDecryptor(decryptionFunc func(payload []byte, sifTrailer []byte) ([]byte, error), sifTrailer []byte) *CustomDecryptor

func (*CustomDecryptor) DecryptSample

func (d *CustomDecryptor) DecryptSample(payload []byte) ([]byte, error)

type CustomEncryptor

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

func NewCustomEncryptor

func NewCustomEncryptor(encryptFunc func(payload []byte) ([]byte, error)) *CustomEncryptor

func (*CustomEncryptor) EncryptSample

func (e *CustomEncryptor) EncryptSample(payload []byte) ([]byte, error)

type Decryptor

type Decryptor interface {
	DecryptSample(payload []byte) ([]byte, error)
}

type Encryptor

type Encryptor interface {
	EncryptSample(payload []byte) ([]byte, error)
}

type GCMDecryptor

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

func NewGCMDecryptor

func NewGCMDecryptor(key []byte, sifTrailer []byte) (*GCMDecryptor, error)

func (*GCMDecryptor) DecryptSample

func (d *GCMDecryptor) DecryptSample(payload []byte) ([]byte, error)

func (*GCMDecryptor) UpdateKey

func (d *GCMDecryptor) UpdateKey(key []byte) error

type GCMEncryptor

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

func NewGCMEncryptor

func NewGCMEncryptor(key []byte, kid uint8) (*GCMEncryptor, error)

func (*GCMEncryptor) EncryptSample

func (e *GCMEncryptor) EncryptSample(payload []byte) ([]byte, error)

func (*GCMEncryptor) UpdateKeyAndKid

func (e *GCMEncryptor) UpdateKeyAndKid(key []byte, kid uint8) error

type PCMLocalTrack

type PCMLocalTrack struct {
	*webrtc.TrackLocalStaticSample
	// contains filtered or unexported fields
}

func NewPCMLocalTrack

func NewPCMLocalTrack(
	sourceSampleRate int,
	sourceChannels int,
	logger protoLogger.Logger,
	opts ...PCMLocalTrackOption,
) (*PCMLocalTrack, error)

NewPCMLocalTrack creates a wrapper around a webrtc.TrackLocalStaticSample that accepts PCM16 samples via the WriteSample method, encodes them to opus, and writes them to the track. PCMLocalTrack can directly be used as a local track to publish to a room. The sourceSampleRate and sourceChannels are the sample rate and channels of the source audio.

func (*PCMLocalTrack) ClearQueue

func (t *PCMLocalTrack) ClearQueue()

func (*PCMLocalTrack) Close

func (t *PCMLocalTrack) Close()

func (*PCMLocalTrack) GetMuteFunc

func (t *PCMLocalTrack) GetMuteFunc(muted bool) lksdk.Private[lksdk.MuteFunc]

func (*PCMLocalTrack) WaitForPlayout

func (t *PCMLocalTrack) WaitForPlayout()

func (*PCMLocalTrack) WriteSample

func (t *PCMLocalTrack) WriteSample(chunk media.PCM16Sample) error

type PCMLocalTrackOption

type PCMLocalTrackOption func(*PCMLocalTrackParams)

func WithEncryptor

func WithEncryptor(encryptor Encryptor) PCMLocalTrackOption

type PCMLocalTrackParams

type PCMLocalTrackParams struct {
	Encryptor Encryptor
}

type PCMRemoteTrack

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

func NewPCMRemoteTrack

func NewPCMRemoteTrack(track *webrtc.TrackRemote, writer PCMRemoteTrackWriter, opts ...PCMRemoteTrackOption) (*PCMRemoteTrack, error)

PCMRemoteTrack takes a remote track (currently only opus is supported) and a WriterCloser interface that writes implements a WriteSample method to write PCM16 samples, where the user desires. The PCMRemoteTrack will read RTP packets from the remote track, decode them to PCM16 samples, and write them to the writer. Audio is resampled to targetSampleRate and upmixed/downmixed to targetChannels. It also provides an option to handle jitter, which is enabled by default. Stereo remote tracks are currently not supported, and are known to have a lot of unpleasant noise.

func (*PCMRemoteTrack) Close

func (t *PCMRemoteTrack) Close()

type PCMRemoteTrackOption

type PCMRemoteTrackOption func(*PCMRemoteTrackParams)

func WithDecryptor

func WithDecryptor(decryptor Decryptor) PCMRemoteTrackOption

func WithHandleJitter

func WithHandleJitter(handleJitter bool) PCMRemoteTrackOption

func WithTargetChannels

func WithTargetChannels(targetChannels int) PCMRemoteTrackOption

func WithTargetSampleRate

func WithTargetSampleRate(targetSampleRate int) PCMRemoteTrackOption

type PCMRemoteTrackParams

type PCMRemoteTrackParams struct {
	HandleJitter     bool
	TargetSampleRate int
	TargetChannels   int
	Decryptor        Decryptor
}

type PCMRemoteTrackWriter

type PCMRemoteTrackWriter interface {
	WriteSample(sample media.PCM16Sample) error
	Close() error
}

Jump to

Keyboard shortcuts

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