device

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2022 License: MIT Imports: 7 Imported by: 9

Documentation

Overview

Package device provides a device abstraction that supports video streaming.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllDevicePaths

func GetAllDevicePaths() ([]string, error)

GetAllDevicePaths return a slice of all mounted v4l2 devices

func IsDevice

func IsDevice(devpath string) (bool, error)

IsDevice tests whether the path matches a V4L device name and is a device file

Types

type Device

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

func Open

func Open(path string, options ...Option) (*Device, error)

Open creates opens the underlying device at specified path for streaming. It returns a *Device or an error if unable to open device.

func (*Device) BufferCount

func (d *Device) BufferCount() v4l2.BufType

BufferCount returns configured number of buffers to be used during streaming. If called after streaming start, this value could be updated by the driver.

func (*Device) BufferType

func (d *Device) BufferType() v4l2.BufType

BufferType this is a convenience method that returns the device mode (i.e. Capture, Output, etc) Use method Capability for detail about the device.

func (*Device) Buffers

func (d *Device) Buffers() [][]byte

Buffers returns the internal mapped buffers. This method should be called after streaming has been started otherwise it may return nil.

func (*Device) Capability

func (d *Device) Capability() v4l2.Capability

Capability returns device capability info.

func (*Device) Close

func (d *Device) Close() error

Close closes the underlying device associated with `d` .

func (*Device) Fd

func (d *Device) Fd() uintptr

Fd returns the file descriptor value for the device

func (*Device) GetCropCapability

func (d *Device) GetCropCapability() (v4l2.CropCapability, error)

GetCropCapability returns cropping info for device

func (*Device) GetFormatDescription

func (d *Device) GetFormatDescription(idx uint32) (v4l2.FormatDescription, error)

GetFormatDescription returns a format description for the device at specified format index

func (*Device) GetFormatDescriptions

func (d *Device) GetFormatDescriptions() ([]v4l2.FormatDescription, error)

GetFormatDescriptions returns all possible format descriptions for device

func (*Device) GetFrameRate

func (d *Device) GetFrameRate() (uint32, error)

GetFrameRate returns the FPS value for the device

func (*Device) GetMediaInfo

func (d *Device) GetMediaInfo() (v4l2.MediaDeviceInfo, error)

GetMediaInfo returns info for a device that supports the Media API

func (*Device) GetOutput

func (d *Device) GetOutput() <-chan []byte

GetOutput returns the channel that outputs streamed data that is captured from the underlying device driver.

func (*Device) GetPixFormat

func (d *Device) GetPixFormat() (v4l2.PixFormat, error)

GetPixFormat retrieves pixel format info for device

func (*Device) GetStreamParam

func (d *Device) GetStreamParam() (v4l2.StreamParam, error)

GetStreamParam returns streaming parameter information for device

func (*Device) GetVideoInputIndex

func (d *Device) GetVideoInputIndex() (int32, error)

GetVideoInputIndex returns current video input index for device

func (*Device) GetVideoInputInfo

func (d *Device) GetVideoInputInfo(index uint32) (v4l2.InputInfo, error)

GetVideoInputInfo returns video input info for device

func (*Device) MemIOType

func (d *Device) MemIOType() v4l2.IOType

MemIOType returns the device memory input/output type (i.e. Memory mapped, DMA, user pointer, etc)

func (*Device) Name

func (d *Device) Name() string

Name returns the device name (or path)

func (*Device) SetCropRect

func (d *Device) SetCropRect(r v4l2.Rect) error

SetCropRect crops the video dimension for the device

func (*Device) SetFrameRate

func (d *Device) SetFrameRate(fps uint32) error

SetFrameRate sets the FPS rate value of the device

func (*Device) SetInput

func (d *Device) SetInput(in <-chan []byte)

SetInput sets up an input channel for data this sent for output to the underlying device driver.

func (*Device) SetPixFormat

func (d *Device) SetPixFormat(pixFmt v4l2.PixFormat) error

SetPixFormat sets the pixel format for the associated device.

func (*Device) SetStreamParam

func (d *Device) SetStreamParam(param v4l2.StreamParam) error

SetStreamParam saves stream parameters for device

func (*Device) Start

func (d *Device) Start(ctx context.Context) error

func (*Device) Stop

func (d *Device) Stop() error

type Option

type Option func(*config)

func WithBufferSize

func WithBufferSize(size uint32) Option

func WithFPS

func WithFPS(fps uint32) Option

func WithIOType

func WithIOType(ioType v4l2.IOType) Option

func WithPixFormat

func WithPixFormat(pixFmt v4l2.PixFormat) Option

func WithVideoCaptureEnabled

func WithVideoCaptureEnabled() Option

func WithVideoOutputEnabled

func WithVideoOutputEnabled() Option

Jump to

Keyboard shortcuts

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