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 ¶
- type Display
- func (d *Display) Bounds() image.Rectangle
- func (d *Display) ColorModel() color.Model
- func (d *Display) Draw(dstRect image.Rectangle, src image.Image, srcPts image.Point) error
- func (d *Display) Halt() error
- func (d *Display) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (d *Display) String() string
- type ImageFormat
- type Options
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 (*Display) ColorModel ¶
ColorModel implements display.Drawer.
func (*Display) Halt ¶
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").
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.