talk

package
v0.2.14 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package talk plays audio from an RTSP client through a camera's speaker.

The camera side is internal/baichuan's: OpenTalk negotiates the session and Talk carries the blocks. What this package adds is the conversion between the two ends. An RTSP back channel arrives as G.711 at 8 kHz in packets of whatever size the client chose; the cameras surveyed here take IMA ADPCM at 16 kHz in blocks of exactly 1024 samples. So audio is resampled to the camera's rate, collected until a whole block is there, and sent a block at a time.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("talk: session closed")

ErrClosed is Write after Close.

Functions

This section is empty.

Types

type Dialer

type Dialer func(ctx context.Context) (*baichuan.Conn, error)

Dialer opens a fresh connection to one camera.

type Session

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

Session is one talk session on its own camera connection, separate from the ones carrying video, so talking never risks a stream.

func Open

func Open(ctx context.Context, dial Dialer) (*Session, error)

Open dials the camera and negotiates a talk session.

func (*Session) Close

func (s *Session) Close() error

Close sends what is left, padded to a block, and releases the camera.

func (*Session) Ping

func (s *Session) Ping() error

Ping keeps the connection alive between bursts of speech. The camera sends nothing back during a talk session, and a connection that hears nothing for baichuan.DefaultIdleTimeout gives up on itself.

func (*Session) SetGain added in v0.2.6

func (s *Session) SetGain(db int)

SetGain sets the talk gain in dB (config talk_gain_db) for what Write sends from now on.

func (*Session) Write

func (s *Session) Write(inRate int, pcm []int16) error

Write plays pcm, 16 bit mono at inRate, through the camera. Samples short of a whole block wait for the next call.

Jump to

Keyboard shortcuts

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