Documentation ¶
Index ¶
- Constants
- func CallbackOnFullBuffer(fn func(_ []byte)) func(*Encoder) error
- func CodecVersion() string
- func SampleBuffer(ms int, resampling bool) func(*Encoder) error
- type Application
- type Bandwidth
- type Bitrate
- type Buffer
- type Encoder
- type Error
- type LibOpusEncoder
- func (enc *LibOpusEncoder) Bitrate() (int, error)
- func (enc *LibOpusEncoder) Complexity() (int, error)
- func (enc *LibOpusEncoder) DTX() (bool, error)
- func (enc *LibOpusEncoder) Encode(pcm []int16, data []byte) (rez int, err error)
- func (enc *LibOpusEncoder) FEC() (bool, error)
- func (enc *LibOpusEncoder) MaxBandwidth() (Bandwidth, error)
- func (enc *LibOpusEncoder) PacketLossPerc() (int, error)
- func (enc *LibOpusEncoder) SampleRate() (int, error)
- func (enc *LibOpusEncoder) SetBitrate(b Bitrate) error
- func (enc *LibOpusEncoder) SetComplexity(complexity int) error
- func (enc *LibOpusEncoder) SetDTX(dtx bool) error
- func (enc *LibOpusEncoder) SetFEC(fec bool) error
- func (enc *LibOpusEncoder) SetMaxBandwidth(b Bandwidth) error
- func (enc *LibOpusEncoder) SetPacketLossPerc(lossPerc int) error
Constants ¶
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) )
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 CodecVersion ¶
func CodecVersion() string
Types ¶
type Application ¶
type Application int
type Encoder ¶
type Encoder struct { *LibOpusEncoder // contains filtered or unexported fields }
func NewEncoder ¶
func (*Encoder) BufferWrite ¶
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.