audio

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package audio contains a buffer for streaming audio from a desktop to and from a websocket client. It is used by the kvdi-proxy to provide playback and microphone support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer provides a ReadWriteCloser for proxying audio data to and from a websocket connection. The read-buffer is populated with opus/webm data and writes to write-buffer can be in any format that gstreamer `decodebin` supports.

func NewBuffer

func NewBuffer(opts *BufferOpts) *Buffer

NewBuffer returns a new Buffer.

func (*Buffer) Close

func (a *Buffer) Close() error

Close kills the gstreamer pipelines.

func (*Buffer) IsClosed

func (a *Buffer) IsClosed() bool

IsClosed returns true if the buffer is closed.

func (*Buffer) Read

func (a *Buffer) Read(p []byte) (int, error)

Read implements ReadCloser and returns data from the audio buffer.

func (*Buffer) RunLoop

func (a *Buffer) RunLoop()

RunLoop will run the main loop, blocking until one of the pipelines ends, closes, or any errors.

func (*Buffer) Start

func (a *Buffer) Start() error

Start starts the gstreamer processes

func (*Buffer) Write

func (a *Buffer) Write(p []byte) (int, error)

Write implements a WriteCloser and writes data to the audio buffer.

type BufferOpts

type BufferOpts struct {
	// A Logger to log messages to, one will be created if this is nil.
	Logger logr.Logger
	// The path to the PulseAudio UNIX socket. The default server is selected
	// if omitted.
	PulseServer string
	// The format to use when streaming and writing to the pulse server.
	// Defaults to `S16LE` (signed 16-bit little-endian).
	PulseFormat string
	// The name of the device to monitor for playback on the read-buffer.
	// The default device is selected when this omitted.
	PulseMonitorName string
	// The sample rate to use on the playback monitor. Defaults to 24000.
	PulseMonitorSampleRate int
	// The number of channels to record on the playback monitor. Defaults to 2.
	PulseMonitorChannels int
	// The name of the PulseSource to write to when recording on the write-buffer.
	// This is required because an additional monitor needs to be created on the
	// mic device to allow PulseAudio to flush its buffers. Defaults to "virtmic".
	PulseMicName string
	// The path of the PulseAudio FIFO to write to when recording on the write-buffer.
	// Defaults to /var/run/kvdi/mic.fifo.
	PulseMicPath string
	// The sample rate of the pulse mic. Defaults to 16000.
	PulseMicSampleRate int
	// The number of channels on the mic. Defaults to 1.
	PulseMicChannels int
}

BufferOpts represents options passed to NewBuffer when building a recording or playback pipeline. Sane defaults are provided for every field, but may not be suitable for all use cases.

Directories

Path Synopsis
Package pa contains a PulseAudio C API wrapper for managing virtual devices on a system.
Package pa contains a PulseAudio C API wrapper for managing virtual devices on a system.

Jump to

Keyboard shortcuts

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