recordings

package
v0.0.0-...-2ec00d9 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// RecordingStartTimeout is the amount of time to wait for a recording to start
	// before declaring the recording to have failed.
	RecordingStartTimeout = 1 * time.Second

	// DefaultMaximumDuration is the default maximum amount of time a recording
	// should be allowed to continue before being terminated.
	DefaultMaximumDuration = 24 * time.Hour

	// DefaultMaximumSilence is the default maximum amount of time silence may be
	// detected before terminating the recording.
	DefaultMaximumSilence = 5 * time.Minute

	// ShutdownGracePeriod is the amount of time to allow a Stop transaction to
	// complete before shutting down the session anyway.
	ShutdownGracePeriod = 3 * time.Second
)

Functions

This section is empty.

Types

type LiveRecording

type LiveRecording interface {

	// Get gets the Recording by type
	Get(key *key.Key) *LiveRecordingHandle

	// Data gets the data for the live recording
	Data(key *key.Key) (*LiveRecordingData, error)

	// Stop stops the live recording
	Stop(key *key.Key) error

	// Pause pauses the live recording
	Pause(key *key.Key) error

	// Resume resumes the live recording
	Resume(key *key.Key) error

	// Mute mutes the live recording
	Mute(key *key.Key) error

	// Unmute unmutes the live recording
	Unmute(key *key.Key) error

	// Scrap Stops and deletes the current LiveRecording
	Scrap(key *key.Key) error

	// Stored returns the StoredRecording handle for this LiveRecording
	Stored(key *key.Key) *StoredRecordingHandle
}

LiveRecording represents a communication path interacting with an Asterisk server for live recording resources

type LiveRecordingData

type LiveRecordingData struct {
	// Key is the cluster-unique identifier for this live recording
	Key *key.Key `json:"key"`

	Cause     string        `json:"cause,omitempty"`            // If failed, the cause of the failure
	Duration  time.Duration `json:"duration,omitempty"`         // Length of recording in seconds
	Format    string        `json:"format"`                     // Format of recording (wav, gsm, etc)
	Name      string        `json:"name"`                       // (base) name for the recording
	Silence   time.Duration `json:"silence_duration,omitempty"` // If silence was detected in the recording, the duration in seconds of that silence (requires that maxSilenceSeconds be non-zero)
	State     string        `json:"state"`                      // Current state of the recording
	Talking   time.Duration `json:"talking_duration,omitempty"` // Duration of talking, in seconds, that has been detected in the recording (requires that maxSilenceSeconds be non-zero)
	TargetURI string        `json:"target_uri"`                 // URI for the channel or bridge which is being recorded (TODO: figure out format for this)
}

LiveRecordingData is the data for a live recording

func (*LiveRecordingData) ID

func (s *LiveRecordingData) ID() string

ID returns the identifier of the live recording

type LiveRecordingHandle

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

A LiveRecordingHandle is a reference to a live recording that can be operated on

func NewLiveRecordingHandle

func NewLiveRecordingHandle(ikey *key.Key, r LiveRecording, exec func(*LiveRecordingHandle) (err error)) *LiveRecordingHandle

NewLiveRecordingHandle creates a new live recording handle

func (*LiveRecordingHandle) Data

Data gets the data for the live recording

func (*LiveRecordingHandle) Exec

func (h *LiveRecordingHandle) Exec() (err error)

Exec executes any staged operations attached to the `LiveRecordingHandle`

func (*LiveRecordingHandle) ID

func (h *LiveRecordingHandle) ID() string

ID returns the identifier of the live recording

func (*LiveRecordingHandle) Key

func (h *LiveRecordingHandle) Key() *key.Key

Key returns the key of the live recording

func (*LiveRecordingHandle) Mute

func (h *LiveRecordingHandle) Mute() error

Mute mutes the recording

func (*LiveRecordingHandle) Pause

func (h *LiveRecordingHandle) Pause() error

Pause pauses the recording

func (*LiveRecordingHandle) Resume

func (h *LiveRecordingHandle) Resume() error

Resume resumes the recording

func (*LiveRecordingHandle) Scrap

func (h *LiveRecordingHandle) Scrap() error

Scrap stops and deletes the recording

func (*LiveRecordingHandle) Stop

func (h *LiveRecordingHandle) Stop() error

Stop stops and saves the recording

func (*LiveRecordingHandle) Stored

Stored returns the StoredRecordingHandle for this LiveRecordingHandle

func (*LiveRecordingHandle) Unmute

func (h *LiveRecordingHandle) Unmute() error

Unmute mutes the recording

type OptionFunc

type OptionFunc func(*Options)

OptionFunc is a function which applies changes to an Options set

func Beep

func Beep() OptionFunc

Beep indicates that a beep should be played to signal the start of recording

func Format

func Format(format string) OptionFunc

Format configures the file format to be used to store the recording

func IfExists

func IfExists(action string) OptionFunc

IfExists configures the behaviour of the recording if the file to be recorded already exists.

Valid options are: "fail" (default), "overwrite", and "append".

func MaxDuration

func MaxDuration(max time.Duration) OptionFunc

MaxDuration sets the maximum duration to allow for the recording. After this amount of time, the recording will be automatically Finished.

A setting of 0 disables the limit.

func MaxSilence

func MaxSilence(max time.Duration) OptionFunc

MaxSilence sets the amount of time a block of silence is allowed to become before the recording should be declared Finished.

A setting of 0 disables silence detection.

func Name

func Name(name string) OptionFunc

Name configures the recording to use the provided name

func TerminateOn

func TerminateOn(dtmf string) OptionFunc

TerminateOn configures the DTMF which, if received, will terminate the recording.

Valid values are "none" (default), "any", "*", and "#".

type Options

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

Options describes a set of recording options for a recording Session

func (*Options) Apply

func (o *Options) Apply(opts ...OptionFunc)

Apply applies a set of options for the recording Session

type Recorder

type Recorder interface {
	// Record starts a recording, using the provided options, and returning a handle for the live recording
	Record(string, *arioptions.RecordingOptions) (*LiveRecordingHandle, error)

	// StageRecord stages a recording, using the provided options, and returning a handle for the live recording.  The recording will actually be started only when Exec() is called.
	StageRecord(string, *arioptions.RecordingOptions) (*LiveRecordingHandle, error)
}

Recorder describes an interface of something which can Record

type Recording

type Recording struct {
	Stored StoredRecording
	Live   LiveRecording
}

Recording is a namespace for the recording types

type Result

type Result struct {

	// Data holds the final data for the LiveRecording, if it was successful
	Data *LiveRecordingData

	// DTMF holds any DTMF digits which are received during the recording session
	DTMF string

	// Duration indicates the duration of the recording
	Duration time.Duration

	// Error holds any error encountered during the recording session
	Error error

	// Hangup indicates that the Recorder disappeared (due to hangup or
	// destruction) during or after the recording.
	Hangup bool
	// contains filtered or unexported fields
}

Result represents the result of a recording Session. It provides an interface to disposition the recording.

func (*Result) Delete

func (r *Result) Delete() error

Delete discards the recording

func (*Result) Key

func (r *Result) Key() *key.Key

Key returns the ari.Key of the StoredRecording, if one exists.

func (*Result) Save

func (r *Result) Save(name string) error

Save stores the recording to the given name

func (*Result) URI

func (r *Result) URI() string

URI returns the AudioURI to play the recording

type Session

type Session interface {
	// Done returns a channel which is closed when the session is complete
	Done() <-chan struct{}

	// Err waits for the session to complete, then returns any error encountered
	// during its execution
	Err() error

	// Key returns the key.Key for the LiveRecording of this session, if one exists.
	Key() *key.Key

	// Pause temporarily stops the recording session without ending the session
	Pause() error

	// Result waits for the session to complete, then returns the Result
	Result() (*Result, error)

	// Resume restarts a paused recording session
	Resume() error

	// Scrap terminates the recording session and throws away the recording.
	Scrap() error

	// Stop stops the recording session
	Stop() *Result
}

Session desribes the interface to a generic recording session

func Record

func Record(ctx context.Context, r Recorder, opts ...OptionFunc) Session

Record starts a new recording Session

type StoredRecording

type StoredRecording interface {

	// Get gets the Recording by type
	Get(key *key.Key) *StoredRecordingHandle

	// data gets the data for the stored recording
	Data(key *key.Key) (*StoredRecordingData, error)

	// Copy copies the recording to the destination name
	//
	// NOTE: because ARI offers no forced-copy, Copy should always return the
	// StoredRecordingHandle of the destination, even if the Copy fails.  Doing so
	// allows the user to Delete the existing StoredRecording before retrying.
	Copy(key *key.Key, dest string) (*StoredRecordingHandle, error)

	// Delete deletes the recording
	Delete(key *key.Key) error
}

StoredRecording represents a communication path interacting with an Asterisk server for stored recording resources

type StoredRecordingData

type StoredRecordingData struct {
	// Key is the cluster-unique identifier for this stored recording
	Key *key.Key `json:"key"`

	Format string `json:"format"`
	Name   string `json:"name"`
}

StoredRecordingData is the data for a stored recording

func (StoredRecordingData) ID

func (d StoredRecordingData) ID() string

ID returns the identifier for the stored recording.

type StoredRecordingHandle

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

A StoredRecordingHandle is a reference to a stored recording that can be operated on

func NewStoredRecordingHandle

func NewStoredRecordingHandle(key *key.Key, s StoredRecording, exec func(a *StoredRecordingHandle) error) *StoredRecordingHandle

NewStoredRecordingHandle creates a new stored recording handle

func (*StoredRecordingHandle) Copy

Copy copies the stored recording.

NOTE: because ARI offers no forced-copy, this should always return the StoredRecordingHandle of the destination, even if the Copy fails. Doing so allows the user to Delete the existing StoredRecording before retrying.

func (*StoredRecordingHandle) Data

Data gets the data for the stored recording

func (*StoredRecordingHandle) Delete

func (s *StoredRecordingHandle) Delete() error

Delete deletes the recording

func (*StoredRecordingHandle) Exec

func (s *StoredRecordingHandle) Exec() (err error)

Exec executes any staged operations

func (*StoredRecordingHandle) ID

func (s *StoredRecordingHandle) ID() string

ID returns the identifier for the stored recording

func (*StoredRecordingHandle) Key

func (s *StoredRecordingHandle) Key() *key.Key

Key returns the Key for the stored recording

Jump to

Keyboard shortcuts

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