Documentation
¶
Index ¶
- Variables
- func DecodeFrame(r io.Reader) (frame []byte, err error)
- type AudioApplication
- type EncodeOptions
- type EncodeSession
- func (e *EncodeSession) Cleanup()
- func (e *EncodeSession) Error() error
- func (e *EncodeSession) FrameDuration() time.Duration
- func (e *EncodeSession) Options() *EncodeOptions
- func (e *EncodeSession) OpusFrame() (frame []byte, err error)
- func (e *EncodeSession) Read(p []byte) (n int, err error)
- func (e *EncodeSession) ReadFrame() (frame []byte, err error)
- func (e *EncodeSession) Running() (running bool)
- func (e *EncodeSession) Stop() error
- func (e *EncodeSession) Truncate()
- type Frame
- type OpusReader
- type StreamingSession
Constants ¶
This section is empty.
Variables ¶
var ErrBadFrame = errors.New("Bad Frame")
ErrBadFrame
var ErrNegativeFrameSize = errors.New("Frame size is negative, possibly corrupted.")
var ErrVoiceConnClosed = errors.New("Voice connection closed")
var Logger *log.Logger
var StdEncodeOptions = &EncodeOptions{ FrameRate: 48000, FrameDuration: 20, Bitrate: 64, CompressionLevel: 10, PacketLoss: 1, BufferedFrames: 100, VariableBitrate: true, StartTime: 0, }
Functions ¶
Types ¶
type AudioApplication ¶
type AudioApplication string
AudioApplication is an application profile for opus encoding
type EncodeOptions ¶
type EncodeOptions struct {
FrameRate int // audio sampling rate (ex 48000)
FrameDuration int // audio frame duration can be 20, 40, or 60 (ms)
Bitrate int // audio encoding bitrate in kb/s can be 8 - 128
PacketLoss int // expected packet loss percentage
CompressionLevel int // Compression level, higher is better qualiy but slower encoding (0 - 10)
BufferedFrames int // How big the frame buffer should be
Threads int // Number of threads to use, 0 for auto
VariableBitrate bool // Whether vbr is used or not (variable bitrate)
StartTime int // Start Time of the input stream in seconds
}
EncodeOptions is a set of options for encoding dca
type EncodeSession ¶
func EncodeFile ¶
func EncodeFile(path string, options *EncodeOptions) (session *EncodeSession, err error)
EncodeFile encodes the file/url/other in path
func (*EncodeSession) Cleanup ¶
func (e *EncodeSession) Cleanup()
Cleanup cleans up the encoding session, throwring away all unread frames and stopping ffmpeg ensuring that no ffmpeg processes starts piling up on your system You should always call this after it's done
func (*EncodeSession) Error ¶
func (e *EncodeSession) Error() error
Error returns any error that occured during the encoding process
func (*EncodeSession) FrameDuration ¶
func (e *EncodeSession) FrameDuration() time.Duration
FrameDuration implements OpusReader, retruning the duration of each frame
func (*EncodeSession) Options ¶
func (e *EncodeSession) Options() *EncodeOptions
Options returns the options used
func (*EncodeSession) OpusFrame ¶
func (e *EncodeSession) OpusFrame() (frame []byte, err error)
OpusFrame implements OpusReader, returning the next opus frame
func (*EncodeSession) Read ¶
func (e *EncodeSession) Read(p []byte) (n int, err error)
Read implements io.Reader, n == len(p) if err == nil, otherwise n contains the number bytes read before an error occured
func (*EncodeSession) ReadFrame ¶
func (e *EncodeSession) ReadFrame() (frame []byte, err error)
ReadFrame blocks until a frame is read or there are no more frames Note: If rawoutput is not set, the first frame will be a metadata frame
func (*EncodeSession) Running ¶
func (e *EncodeSession) Running() (running bool)
Running returns true if running
func (*EncodeSession) Truncate ¶
func (e *EncodeSession) Truncate()
Truncate is deprecated, use Cleanup instead this will be removed in a future version
type OpusReader ¶
type StreamingSession ¶
StreamingSession provides an easy way to directly transmit opus audio to discord from an encode session.
func NewStream ¶
func NewStream(source OpusReader, vc *discordgo.VoiceConnection, done chan error) *StreamingSession
Creates a new stream from an Opusreader.
func (*StreamingSession) Finished ¶
func (s *StreamingSession) Finished() (bool, error)
Finished returns wether the stream finished or not, and any error that caused it to stop
func (*StreamingSession) Paused ¶
func (s *StreamingSession) Paused() bool
Paused returns wether the stream is paused or not
func (*StreamingSession) PlaybackPosition ¶
func (s *StreamingSession) PlaybackPosition() time.Duration
PlaybackPosition returns the the duration of content we have transmitted so far
func (*StreamingSession) SetPaused ¶
func (s *StreamingSession) SetPaused(paused bool)
SetPaused provides pause/unpause functionality