record

package
v4.7.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2018 License: Apache-2.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
)
View Source
var Logger = log15.New()

Logger defaults to a discard handler (null output). If you wish to enable logging, you can set your own handler like so:

ari.Logger.SetHandler(log15.StderrHandler)

Functions

This section is empty.

Types

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 Result

type Result struct {

	// Data holds the final data for the LiveRecording, if it was successful
	Data *ari.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() *ari.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 ari.Key for the LiveRecording of this session, if one exists.
	Key() *ari.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 ari.Recorder, opts ...OptionFunc) Session

Record starts a new recording Session

Jump to

Keyboard shortcuts

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