replay

package
v0.0.0-...-119448c Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2018 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterMonitoring

func RegisterMonitoring(reg prometheus.Registerer)

RegisterMonitoring registers all of this package's monitoring metrics.

Types

type PlaybackLeaser

type PlaybackLeaser interface {
	// AcquirePlaybackLease attempts to take out a playback lease.
	AcquirePlaybackLease()
	// ReleasePLaybackLease releases any held playback lease.
	//
	// No no lease is held, ReleasePlaybackLease will do nothing.
	ReleasePlaybackLease()
}

PlaybackLeaser is a mechanism that a Player can use to claim a playback lease, blocking (cooperatively) other facilities from performing their own playback and sending interfering signals.

PlaybackLeaser is cooperative; it is up to all participating playback mechanisms to sort out who gets the playback lease.

type Player

type Player struct {
	// SendPacket receives all playback packets. It must not be nil.
	//
	// SendPacket calls will be made synchronously.
	SendPacket func(ord device.Ordinal, id string, pkt *protocol.Packet) error

	// PlaybackLeaser, if not nil, will be used to acquire and release leases
	// depending on the Player's playback status.
	PlaybackLeaser PlaybackLeaser

	// Logger is the logger instance to use. If nil, no logging will be
	// performed.
	Logger logging.L

	// MaxLagAge is the maximum amount of time in the past that we will allow a
	// packet to be scheduled. If the packet is older than this, we will drop it
	// and resume the stream once we hit future packets.
	MaxLagAge time.Duration
	// contains filtered or unexported fields
}

Player plays a stream file back to a sink.

A Player is not safe for concurrent use. Its exported fields must not be changed after playback has begun.

func (*Player) Pause

func (p *Player) Pause()

Pause pauses a current play operation. If nothing is playiung, or if the playback is already paused, Pause will do nothing.

func (*Player) Play

Play clears any currently playing file and begins playback of sr.

Play takes ownership of sr, and Will close it when stopped.

func (*Player) Resume

func (p *Player) Resume()

Resume resumes a paused file. If nothing is playing, or if a file is not paused, Resume will do nothing.

func (*Player) Status

func (p *Player) Status() *PlayerStatus

Status returns the current player status.

If the player is not playing, Status will return nil.

func (*Player) Stop

func (p *Player) Stop()

Stop stops player playback and clears player resources.

type PlayerStatus

type PlayerStatus struct {
	Path           string
	Rounds         int64
	Position       time.Duration
	Duration       time.Duration
	TotalPlaytime  time.Duration
	Paused         bool
	NoRouteDevices []*PlayerStatusNoRouteDeviceEntry
}

PlayerStatus describes the player's current status.

type PlayerStatusNoRouteDeviceEntry

type PlayerStatusNoRouteDeviceEntry struct {
	ID      string
	Ordinal device.Ordinal
	Count   int64
}

PlayerStatusNoRouteDeviceEntry is a PlayetStatus entry in the NoRouteDevices.

type Recorder

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

A Recorder handles the recoridng and playback of packets.

func (*Recorder) RecordPacket

func (r *Recorder) RecordPacket(d device.D, pkt *protocol.Packet) error

RecordPacket adds pkt from device d to the recording.

func (*Recorder) Start

func (r *Recorder) Start(sw *streamfile.EventStreamWriter)

Start starts recording a stream.

The recording will continue until the Stop method is called.

Start will take ownership of sw and close it on completion (Stop).

func (*Recorder) Status

func (r *Recorder) Status() *RecorderStatus

Status returns a snapshot of the current Recorder status.

If the Recorder is not currently recording, Status will return nil.

func (*Recorder) Stop

func (r *Recorder) Stop() error

Stop stops the Recorder, finalizing its output file and releasing its resources.

type RecorderStatus

type RecorderStatus struct {
	Name     string
	Error    error
	Events   int64
	Bytes    int64
	Duration time.Duration
}

RecorderStatus is a snapshot of the current recorder status.

Directories

Path Synopsis
Package streamfile defines a file format to record and replay packet stream files.
Package streamfile defines a file format to record and replay packet stream files.

Jump to

Keyboard shortcuts

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