videosink

package
v3.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Overview

Package videosink provides a display driver implementing an HTTP request handler. Client requests get an initial snapshot of the graphics buffer and are updated further on every change.

The primary use case is the development of display outputs on a host machine. Additionally devices with network connectivity can use this driver to provide a copy of their local display via a web interface.

The protocol used is "MJPEG" (https://en.wikipedia.org/wiki/Motion_JPEG) which is often used by IP cameras. Because of its better suitability for computer-drawn graphics the PNG image format is used by default. JPEG as a format can be selected via Options.Format or using the "format" URL parameter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Display

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

Display is a virtual device receiving drawing operations and sending a stream of images to all connected HTTP clients.

func New

func New(opt *Options) *Display

New creates a new videosink device instance.

func (*Display) Bounds

func (d *Display) Bounds() image.Rectangle

Bounds implements display.Drawer.

func (*Display) ColorModel

func (d *Display) ColorModel() color.Model

ColorModel implements display.Drawer.

func (*Display) Draw

func (d *Display) Draw(dstRect image.Rectangle, src image.Image, srcPts image.Point) error

Draw implements display.Drawer.

func (*Display) Halt

func (d *Display) Halt() error

Halt implements conn.Resource and terminates all running client requests asynchronously.

func (*Display) ServeHTTP

func (d *Display) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles HTTP GET requests and sends a stream of images representing the display buffer in response. The display options control the default format and clients can explicitly request PNG or JPEG images using the "format" parameter ("?format=png", "?format=jpeg").

func (*Display) String

func (d *Display) String() string

String returns the name of the device.

type ImageFormat

type ImageFormat int
const (
	PNG ImageFormat = iota
	JPEG

	// DefaultFormat is the format used when not set explicitly in options or
	// as a URL parameter.
	DefaultFormat = PNG
)

func ImageFormatFromString

func ImageFormatFromString(value string) (ImageFormat, error)

ImageFormatFromString returns the ImageFormat value for the given format abbreviation.

func (ImageFormat) String

func (f ImageFormat) String() string

type Options

type Options struct {
	// Width and height of the image buffer.
	Width, Height int

	// Format specifies the image format to send to clients.
	Format ImageFormat

	// JPEG controls options for the JPEG encoder.
	JPEG jpeg.Options

	// PNG controls options for the PNG encoder.
	PNG struct {
		// CompressionLevel is the amount of compression applied by the PNG
		// encoder. Defaults to png.DefaultCompression.
		CompressionLevel png.CompressionLevel
	}

	// MinFrameInterval is the amount of time which needs to pass before
	// sending a new image, thus implementing rate-limiting. Defaults to 15
	// frames per second.
	MinFrameInterval time.Duration

	// KeepAliveInterval is the amount of time after which to send a new
	// image regardless of whether any changes have been made. Defaults to
	// once per minute.
	KeepAliveInterval time.Duration
}

Options for videosink devices.

Jump to

Keyboard shortcuts

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