opus

package
v0.0.0-...-69fa46c Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const FrameSize = 20

Variables

View Source
var (
	ErrEncoderNotInitialized     = errors.New("audio encoder not initialized")
	ErrEncoderAlreadyInitialized = errors.New("audio encoder already initialized")

	ErrDecoderNotInitialized     = errors.New("audio decoder not initialized")
	ErrDecoderAlreadyInitialized = errors.New("audio decoder already initialized")

	ErrRepacketizerNotInitialized     = errors.New("audio repacketizer not initialized")
	ErrRepacketizerAlreadyInitialized = errors.New("audio repacketizer already initialized")
)

Functions

func GetOutputBuffSize

func GetOutputBuffSize(rate int, channels int) int

func Version

func Version() string

Types

type Application

type Application int
const (
	ApplicationVoip               Application = C.OPUS_APPLICATION_VOIP
	ApplicationAudio              Application = C.OPUS_APPLICATION_AUDIO
	ApplicationRestrictedLowdelay Application = C.OPUS_APPLICATION_RESTRICTED_LOWDELAY
)

type Decoder

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

func NewDecoder

func NewDecoder(sampleRate int, channels int) (*Decoder, error)

func (*Decoder) Channels

func (e *Decoder) Channels() int

func (*Decoder) Ctl

func (e *Decoder) Ctl(macro Macro[Decoder]) error

func (*Decoder) Decode

func (e *Decoder) Decode(data []byte, pcm []int16, decodeFec bool) (int, error)

func (*Decoder) DecodeFloat

func (e *Decoder) DecodeFloat(data []byte, pcm []float32, decodeFec bool) (int, error)

func (*Decoder) Destroy

func (e *Decoder) Destroy()

func (*Decoder) Init

func (e *Decoder) Init(sampleRate int, channels int) error

func (*Decoder) SampleRate

func (e *Decoder) SampleRate() (int, error)

type Encoder

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

func NewEncoder

func NewEncoder(sampleRate int, channels int, application Application) (*Encoder, error)

func (*Encoder) Channels

func (e *Encoder) Channels() int

func (*Encoder) Ctl

func (e *Encoder) Ctl(macro Macro[Encoder]) error

func (*Encoder) Destroy

func (e *Encoder) Destroy()

func (*Encoder) Encode

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

func (*Encoder) EncodeFloat

func (e *Encoder) EncodeFloat(pcm []float32, data []byte) (int, error)

func (*Encoder) Init

func (e *Encoder) Init(sampleRate int, channels int, application Application) error

func (*Encoder) SampleRate

func (e *Encoder) SampleRate() (int, error)

type Error

type Error int
const (
	ErrOK             Error = C.OPUS_OK
	ErrBadArg         Error = C.OPUS_BAD_ARG
	ErrBufferTooSmall Error = C.OPUS_BUFFER_TOO_SMALL
	ErrInternalError  Error = C.OPUS_INTERNAL_ERROR
	ErrInvalidPacket  Error = C.OPUS_INVALID_PACKET
	ErrUnimplemented  Error = C.OPUS_UNIMPLEMENTED
	ErrInvalidState   Error = C.OPUS_INVALID_STATE
	ErrAllocFail      Error = C.OPUS_ALLOC_FAIL
)

func (Error) Error

func (e Error) Error() string

type Macro

type Macro[T any] func(t *T) C.int

func GetDecoderSamplerRte

func GetDecoderSamplerRte(sampleRate *int) Macro[Decoder]

func GetEncoderSampleRate

func GetEncoderSampleRate(sampleRate *int) Macro[Encoder]

func SetBitrate

func SetBitrate(bitrate int) Macro[Encoder]

func SetComplexity

func SetComplexity(complexity int) Macro[Encoder]

func SetForceChannels

func SetForceChannels(channels int) Macro[Encoder]

Jump to

Keyboard shortcuts

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