fakenvr

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 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 fakenvr fakes a Reolink NVR's Baichuan port for tests: it logs a client in, then serves every preview the client asks for, as many as it asks for and on as many channels, interleaved on the one connection the way a recorder interleaves them.

Unlike internal/fakecam, which replays bytes and knows nothing of the protocol, a recorder has to read what the client asks for to know which channels to send, so this package decodes the client's requests with internal/baichuan. The media it sends is a real capture's, its channel and stream bytes rewritten per preview, so a client decodes real frames.

The capture must be one internal/baichuan/testdata holds, made under an empty password: the recorder logs in with the capture's own nonce, so the client's AES key matches the key the capture's media was sealed with.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Preview

type Preview struct {
	Channel int
	Stream  string
}

Preview names one stream a client asked for.

type Recorder

type Recorder struct {

	// Gap is the pause between two media messages of one preview.
	Gap time.Duration

	// StopUnknownStartsMain models what #49 points at on an RLN8-410: a
	// stop naming a handle the recorder no longer has (its camera
	// dropped, see Forget) is taken as a new request with no stream type,
	// so the main stream, and is served tagged with the stop's own offset,
	// whose stream byte may be the sub stream's.
	StopUnknownStartsMain bool

	// NoCounterEcho clears the counter byte of every media message's
	// offset, for a recorder that does not echo it: a client must still
	// tell its previews apart by channel and stream.
	NoCounterEcho bool

	// StuckAfterDark models #62 on an RLN8-410. A preview asked for while
	// its channel is dark (see Silence) is served once the channel comes
	// back, under that request's offset, and a stop does not end it. Every
	// later request for the channel on that connection is answered with an
	// empty status reply carrying its offset, and no media. Only a new
	// connection is served normally.
	StuckAfterDark bool
	// contains filtered or unexported fields
}

Recorder is a fake NVR on a loopback address.

func New

func New(t testing.TB, capture []byte) *Recorder

New starts a fake recorder serving the media in capture, a server-side capture from internal/baichuan/testdata that begins with a login.

func (*Recorder) Accepts

func (r *Recorder) Accepts() int

Accepts is how many connections the recorder has accepted.

func (*Recorder) Addr

func (r *Recorder) Addr() string

Addr is the address to dial, host:port.

func (*Recorder) DropAll

func (r *Recorder) DropAll()

DropAll closes every open connection, as a recorder rebooting would.

func (*Recorder) Forget added in v0.2.10

func (r *Recorder) Forget(channel int)

Forget ends every preview of channel on every connection without a word to the client, as a recorder does when that channel's camera drops.

func (*Recorder) MaxOpen

func (r *Recorder) MaxOpen() int

MaxOpen is the most connections that were ever open at once.

func (*Recorder) Open

func (r *Recorder) Open() int

Open is how many connections are open now.

func (*Recorder) Silence

func (r *Recorder) Silence(channel int, on bool)

Silence stops sending channel's media, on every preview of it, while leaving the connection and every other channel running: a camera that has gone dark behind the recorder.

func (*Recorder) Starts

func (r *Recorder) Starts() []Preview

Starts lists every preview request, in order.

func (*Recorder) Stops

func (r *Recorder) Stops() []Preview

Stops lists every stream-stop request, in order.

Jump to

Keyboard shortcuts

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