Documentation
¶
Index ¶
Constants ¶
const ( DefaultOpusSampleRate = 48000 DefaultOpusSampleDuration = 20 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomDecryptor ¶ added in v2.9.0
type CustomDecryptor struct {
// contains filtered or unexported fields
}
func NewCustomDecryptor ¶ added in v2.9.0
func (*CustomDecryptor) DecryptSample ¶ added in v2.9.0
func (d *CustomDecryptor) DecryptSample(payload []byte) ([]byte, error)
type CustomEncryptor ¶ added in v2.9.0
type CustomEncryptor struct {
// contains filtered or unexported fields
}
func NewCustomEncryptor ¶ added in v2.9.0
func NewCustomEncryptor(encryptFunc func(payload []byte) ([]byte, error)) *CustomEncryptor
func (*CustomEncryptor) EncryptSample ¶ added in v2.9.0
func (e *CustomEncryptor) EncryptSample(payload []byte) ([]byte, error)
type GCMDecryptor ¶ added in v2.9.0
type GCMDecryptor struct {
// contains filtered or unexported fields
}
func NewGCMDecryptor ¶ added in v2.9.0
func NewGCMDecryptor(key []byte, sifTrailer []byte) (*GCMDecryptor, error)
func (*GCMDecryptor) DecryptSample ¶ added in v2.9.0
func (d *GCMDecryptor) DecryptSample(payload []byte) ([]byte, error)
func (*GCMDecryptor) UpdateKey ¶ added in v2.9.0
func (d *GCMDecryptor) UpdateKey(key []byte) error
type GCMEncryptor ¶ added in v2.9.0
type GCMEncryptor struct {
// contains filtered or unexported fields
}
func NewGCMEncryptor ¶ added in v2.9.0
func NewGCMEncryptor(key []byte, kid uint8) (*GCMEncryptor, error)
func (*GCMEncryptor) EncryptSample ¶ added in v2.9.0
func (e *GCMEncryptor) EncryptSample(payload []byte) ([]byte, error)
func (*GCMEncryptor) UpdateKeyAndKid ¶ added in v2.9.0
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 ¶ added in v2.7.1
func (t *PCMLocalTrack) ClearQueue()
func (*PCMLocalTrack) Close ¶
func (t *PCMLocalTrack) Close()
func (*PCMLocalTrack) GetMuteFunc ¶ added in v2.9.1
func (*PCMLocalTrack) WaitForPlayout ¶ added in v2.7.1
func (t *PCMLocalTrack) WaitForPlayout()
func (*PCMLocalTrack) WriteSample ¶
func (t *PCMLocalTrack) WriteSample(chunk media.PCM16Sample) error
type PCMLocalTrackOption ¶
type PCMLocalTrackOption func(*PCMLocalTrackParams)
func WithEncryptor ¶ added in v2.9.0
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 ¶ added in v2.9.0
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 PCMRemoteTrackWriter ¶
type PCMRemoteTrackWriter interface {
WriteSample(sample media.PCM16Sample) error
Close() error
}