opus

package
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Optimize encoding for VoIP
	AppVoIP = Application(C.OPUS_APPLICATION_VOIP)
	// Optimize encoding for non-voice signals like music
	AppAudio = Application(C.OPUS_APPLICATION_AUDIO)
	// Optimize encoding for low latency applications
	AppRestrictedLowdelay = Application(C.OPUS_APPLICATION_RESTRICTED_LOWDELAY)

	// Auto/default setting
	BitrateAuto = Bitrate(-1000)
	BitrateMax  = Bitrate(-1)

	// 20 kHz bandpass
	FullBand = Bandwidth(C.OPUS_BANDWIDTH_FULLBAND)
)
View Source
const (
	ErrorOK             = Error(C.OPUS_OK)
	ErrorBadArg         = Error(C.OPUS_BAD_ARG)
	ErrorBufferTooSmall = Error(C.OPUS_BUFFER_TOO_SMALL)
	ErrorInternalError  = Error(C.OPUS_INTERNAL_ERROR)
	ErrorInvalidPacket  = Error(C.OPUS_INVALID_PACKET)
	ErrorUnimplemented  = Error(C.OPUS_UNIMPLEMENTED)
	ErrorInvalidState   = Error(C.OPUS_INVALID_STATE)
	ErrorAllocFail      = Error(C.OPUS_ALLOC_FAIL)
)

Variables

This section is empty.

Functions

func CallbackOnFullBuffer

func CallbackOnFullBuffer(fn func(_ []byte)) func(*Encoder) error

func CodecVersion

func CodecVersion() string

func SampleBuffer

func SampleBuffer(ms int, resampling bool) func(*Encoder) error

Types

type Application

type Application int

type Bandwidth

type Bandwidth int

type Bitrate

type Bitrate int

type Buffer

type Buffer struct {
	Data []int16
	// contains filtered or unexported fields
}

func (*Buffer) Full

func (b *Buffer) Full() bool

func (*Buffer) Write

func (b *Buffer) Write(samples []int16) (written int)

type Encoder

type Encoder struct {
	*LibOpusEncoder
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder(inputSampleRate, outputSampleRate, channels int, options ...func(*Encoder) error) (Encoder, error)

func (*Encoder) BufferWrite

func (e *Encoder) BufferWrite(samples []int16) (written int)

func (*Encoder) Encode

func (e *Encoder) Encode(pcm []int16) ([]byte, error)

func (*Encoder) GetInfo

func (e *Encoder) GetInfo() string

type Error

type Error int

func (Error) Error

func (e Error) Error() string

type LibOpusEncoder

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

func NewOpusEncoder

func NewOpusEncoder(sampleRate int, channels int, app Application) (*LibOpusEncoder, error)

NewOpusEncoder creates new Opus encoder.

func (*LibOpusEncoder) Bitrate

func (enc *LibOpusEncoder) Bitrate() (int, error)

Bitrate returns the bitrate of the encoder.

func (*LibOpusEncoder) Complexity

func (enc *LibOpusEncoder) Complexity() (int, error)

Complexity returns the value of the complexity.

func (*LibOpusEncoder) DTX

func (enc *LibOpusEncoder) DTX() (bool, error)

DTX says if discontinuous transmission is enabled.

func (*LibOpusEncoder) Encode

func (enc *LibOpusEncoder) Encode(pcm []int16, data []byte) (rez int, err error)

Encode converts raw PCM samples into the supplied Opus buffer. Returns the number of bytes converted.

func (*LibOpusEncoder) FEC

func (enc *LibOpusEncoder) FEC() (bool, error)

FEC says if forward error correction (FEC) is enabled.

func (*LibOpusEncoder) MaxBandwidth

func (enc *LibOpusEncoder) MaxBandwidth() (Bandwidth, error)

MaxBandwidth returns the maximum allowed bandpass value.

func (*LibOpusEncoder) PacketLossPerc

func (enc *LibOpusEncoder) PacketLossPerc() (int, error)

PacketLossPerc returns configured packet loss percentage.

func (*LibOpusEncoder) SampleRate

func (enc *LibOpusEncoder) SampleRate() (int, error)

SampleRate returns the sample rate of the encoder.

func (*LibOpusEncoder) SetBitrate

func (enc *LibOpusEncoder) SetBitrate(b Bitrate) error

SetBitrate sets the bitrate of the encoder. BitrateMax / BitrateAuto can be used here.

func (*LibOpusEncoder) SetComplexity

func (enc *LibOpusEncoder) SetComplexity(complexity int) error

SetComplexity sets the complexity factor for the encoder. Complexity is a value from 1 to 10, where 1 is the lowest complexity and 10 is the highest.

func (*LibOpusEncoder) SetDTX

func (enc *LibOpusEncoder) SetDTX(dtx bool) error

SetDTX switches discontinuous transmission.

func (*LibOpusEncoder) SetFEC

func (enc *LibOpusEncoder) SetFEC(fec bool) error

SetFEC switches the forward error correction (FEC).

func (*LibOpusEncoder) SetMaxBandwidth

func (enc *LibOpusEncoder) SetMaxBandwidth(b Bandwidth) error

SetMaxBandwidth sets the upper limit of the bandpass.

func (*LibOpusEncoder) SetPacketLossPerc

func (enc *LibOpusEncoder) SetPacketLossPerc(lossPerc int) error

SetPacketLossPerc sets expected packet loss percentage.

Jump to

Keyboard shortcuts

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